Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / BcdConverter.java
Last active February 23, 2026 19:53
BCD Conversion in Java
/**
* Convert between decimal & BCD (binary-coded decimal).
*/
public class BcdConverter {
/**
* Encodes a positive integer number into an unsigned packed BCD.
*
* @param num a positive integer number to encode (maximum value of 2<sup>63</sup>-1).
* @return BCD representation of the passed number argument.
@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 / 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 / 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;
};