Skip to content

Instantly share code, notes, and snippets.

@Abdallah-Abdelazim
Abdallah-Abdelazim / oojs_es5.js
Last active June 19, 2023 17:24
Complete Object-Oriented JavaScript example (ES5).
function Person(first, last, age, gender, interests) {
this.name = {
first,
last
};
this.age = age;
this.gender = gender;
this.interests = interests;
};
@Abdallah-Abdelazim
Abdallah-Abdelazim / linux_desktop_entry_template.md
Last active June 1, 2021 19:01
Template for creating desktop entries (launchers) on Linux

Template for creating desktop entries (launchers) on Linux

Create the following file, with your favourite editor:

  • Across all users: /usr/share/applications/application_name.desktop
  • For current user only: ~/.local/share/applications/application_name.desktop

Add the following content to the file and save:

[Desktop Entry]
Version=1.0
@Abdallah-Abdelazim
Abdallah-Abdelazim / StrPad.java
Created October 21, 2019 13:06
Useful utility methods for controlling the length & adding padding to strings in Java.
/**
* Useful utility methods for controlling the length & adding padding to strings.
*
* @author Abdallah Abdelazim
*/
public final class StrPad {
/**
* Prevent instantiation.
*/
@Abdallah-Abdelazim
Abdallah-Abdelazim / BcdConverter.java
Last active October 27, 2019 10:39 — forked from neuro-sys/BCD.java
BCD Conversion in Java
/*
* Copyright 2010 Firat Salgur
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
@Abdallah-Abdelazim
Abdallah-Abdelazim / SingleLiveEvent.java
Last active November 19, 2020 11:48
SingleLiveEvent: A lifecycle-aware observable that sends only new updates after subscription, used for events like navigation and Snackbar messages.
/*
* Copyright 2017 Google Inc.
* Copyright 2020 Abdallah Abdelazim.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@Abdallah-Abdelazim
Abdallah-Abdelazim / BaseDao.java
Created March 31, 2020 01:44
A BaseDao interface that provides the methods needed for inserting, updating & deleting an entity in a Room Dao interface.
package com.example.app.data.local.dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Update;
import java.util.List;
/**
@Abdallah-Abdelazim
Abdallah-Abdelazim / _fix_alt_shift_layout_switching_kde.md
Last active May 5, 2023 21:49
Fix: Alt+Shift layout switching not working in Arabic keyboard layout on KDE neon/Kubuntu
@Abdallah-Abdelazim
Abdallah-Abdelazim / drawablegen.sh
Last active November 30, 2023 22:16 — forked from Kishanjvaghela/converter.sh
drawablegen - A shell script to resize icon images and generate the alternative drawables with the proper screen pixel densities (dip) for Android.
#!/bin/sh
# A shell script to resize icon images and generate the alternative drawables with the proper screen pixel densities (dip) for Android.
# The passed icon image would be the xxxhdpi drawable & the other drawables (xxhdpi, xhdpi, hdpi & mdpi) would be scaled down from that.
# How to use:
# ./drawablegen.sh <icon image file relative path>
# Example:
# ./drawablegen.sh my_image.png
# This will create all the drawable folders, if not has already, in a res folder inside the current directory (as returned by pwd).
# Use only with PNG images.
# Requires ImageMagick to be installed & added to the path environment variable. Install with: sudo apt install imagemagick
@Abdallah-Abdelazim
Abdallah-Abdelazim / RoundedFrameLayout.java
Created January 11, 2021 20:30
A custom FrameLayout that allows you to round & clip the corners of this layout, and its children, with radii that you specify either in XML or with code.
package com.example;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.widget.FrameLayout;
@Abdallah-Abdelazim
Abdallah-Abdelazim / InputValidationUtils.java
Last active March 12, 2021 00:42
Various utility functions to validate user input.
package com.example.util;
import android.text.TextUtils;
import android.util.Patterns;
import androidx.annotation.NonNull;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;