Skip to content

Instantly share code, notes, and snippets.

@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 / 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
@hilfritz
hilfritz / gist:5a8ca9e172918bc224f03c3dac9c39f3
Last active November 6, 2024 16:19
Android OnClickListener Prevent multiple clicks
import android.view.View;
/**
* inspired and credits
* @see http://stackoverflow.com/questions/16534369/avoid-button-multiple-rapid-clicks
* A Debounced OnClickListener
* Rejects clicks that are too close together in time.
* This class is safe to use as an OnClickListener for multiple views, and will debounce each one separately.
* This class allows a single click and prevents multiple clicks on
* the same button in rapid succession. Setting unclickable is not enough
@Kishanjvaghela
Kishanjvaghela / converter.sh
Last active July 8, 2024 21:36
Create Image drawable for all resolutions
if [ $# -eq 0 ]; then
echo "No arguments supplied"
else if [ -f "$1" ]; then
echo " Creating different dimensions (dips) of "$1" ..."
mkdir -p drawable-xxhdpi
mkdir -p drawable-xhdpi
mkdir -p drawable-hdpi
mkdir -p drawable-mdpi
if [ $1 = "ic_launcher.png" ]; then
@Jonalogy
Jonalogy / handling_multiple_github_accounts.md
Last active October 31, 2025 02:52
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@guavabot
guavabot / draw_behind_status_bar.md
Created September 30, 2016 11:43
Draw behind status bar
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

    getWindow().setStatusBarColor(ContextCompat.getColor(this, android.R.color.transparent));
}
@cutiko
cutiko / LoginActivity.java
Last active April 27, 2025 07:59
How to customize firebase-ui-auth for Android
public class LoginActivity extends AppCompatActivity {
private static final int RC_SIGN_IN = 343;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@nstarke
nstarke / release-android-debuggable.md
Last active August 17, 2025 16:32
How to make a Release Android App debuggable

How to make a Release Android App debuggable

Let's say you want to access the application shared preferences in /data/data/com.mypackage.
You could try to run adb shell and then run-as com.mypackage ( or adb shell run-as com.mypackge ls /data/data/com.mypackage/shared_prefs), but on a production release app downloaded from an app store you're most likely to see:

run-as: Package 'com.mypackage' is not debuggable
@lopspower
lopspower / README.md
Last active November 7, 2025 16:05
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

All hex value from 100% to 0% alpha: