Skip to content

Instantly share code, notes, and snippets.

View Ahmed-Emad's full-sized avatar

Ahmed Emad Barakat Ahmed-Emad

  • Alexandria, Egypt
View GitHub Profile
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
@Bramengton
Bramengton / NavigationApps.java
Last active December 9, 2020 11:37
Open navigation app and build route by coordinates (google map, waze, maps.me, navitel. city guide, osmand, yandex navigation, 2gis)
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
@ArthurNagy
ArthurNagy / RoundedBottomSheetDialogFragment.kt
Last active November 2, 2025 09:21
Rounded modal bottom sheet as seen in new Google products(Tasks, News, etc.), described in this article: https://medium.com/halcyon-mobile/implementing-googles-refreshed-modal-bottom-sheet-4e76cb5de65b
package com.your.package
import android.app.Dialog
import android.os.Bundle
import com.your.package.R
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
/**
* BottomSheetDialog fragment that uses a custom
import Foundation
// MARK: - Theme Protocol
@objc protocol Themeable: class {
optional func themeDidChange(to theme: Theme)
}
// MARK: - Theme and ThemeManager
final class Theme {
let text: UIColor
@chrisbanes
chrisbanes / KotterKnife.kt
Last active February 7, 2021 15:25
LifecycleAware KotterKnife
package kotterknife
import android.app.Activity
import android.app.Dialog
import android.app.DialogFragment
import android.app.Fragment
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleObserver
import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.OnLifecycleEvent
@chourobin
chourobin / 0-bridging-react-native-cheatsheet.md
Last active February 15, 2026 08:09
React Native Bridging Cheatsheet
@mandybess
mandybess / RestClient.java
Created July 27, 2016 01:58
How to send multiple query parameters of same name with Retrofit
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import okhttp3.HttpUrl;
import okhttp3.HttpUrl.Builder;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import retrofit2.Retrofit;
@alopresto
alopresto / gpg_git_signing.md
Last active July 1, 2025 15:59
Steps to enable GPG signing of git commits.

If anyone is interested in setting up their system to automatically (or manually) sign their git commits with their GPG key, here are the steps:

  1. Generate and add your key to GitHub
  2. $ git config --global commit.gpgsign true ([OPTIONAL] every commit will now be signed)
  3. $ git config --global user.signingkey ABCDEF01 (where ABCDEF01 is the fingerprint of the key to use)
  4. $ git config --global alias.logs "log --show-signature" (now available as $ git logs)
  5. $ git config --global alias.cis "commit -S" (optional if global signing is false)
  6. $ echo "Some content" >> example.txt
  7. $ git add example.txt
  8. $ git cis -m "This commit is signed by a GPG key." (regular commit will work if global signing is enabled)
module Ratyrate
def update_rate_average(stars, dimension=nil)
if average(dimension).nil?
RatingCache.create! do |avg|
avg.cacheable_id = self.id
avg.cacheable_type = self.class.name
avg.avg = stars
avg.qty = 1
avg.dimension = dimension
end
@varunachar
varunachar / ANestObject.json
Last active February 25, 2020 01:17
Google Gson TypeAdapterFactory to use with Retrofit when the the object is nested inside another object (Typically an object which contains status code etc) and when the root changes per object like shown below in the sample ANestedObject.json. Then you can use Retrofit normally! Enjoy
// Root is hotel
{
status : "ok",
statusCode : 200,
hotels : [{
name : "Taj Palace",
location : {
lat : 12
lng : 77