Skip to content

Instantly share code, notes, and snippets.


mohamedelagamy mohamedagamy

View GitHub Profile
View Formatting Numbers Locale
fun String.formatCreditCardNumber(): String {
val delimiter = ' '
return this.replace(".{4}(?!$)".toRegex(), "$0$delimiter")
fun Float.formatPriceFloat(): String {
val isEnglish = Utils.getLang()
val symbols = DecimalFormatSymbols(Locale.US)
val decimalFormat = DecimalFormat("#,###.000",symbols)
val output = if(isEnglish) decimalFormat.format(this) else
mohamedagamy / KeyboardEditText
Created Sep 12, 2019
prevent keyboard disappear
View KeyboardEditText
//The goal is to make a custom lock screen that the user must enter a pass code
//or leave the application.
//When the user taps the "keyboard down" button the keyboard does not disappear.
public class CustomKonashaEditText extends AppCompatEditText {
public CustomKonashaEditText(Context context, AttributeSet attrs) {
super(context, attrs);
import android.content.Context;
import android.content.res.TypedArray;
import android.text.method.PasswordTransformationMethod;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
View clean code
Get your mind right.
takes practice and study, over many years
The key is deliberative practice: not just doing it again and again, but challenging yourself with a task that is just beyond your current ability, trying it,
public class PreCachingLayoutManager extends LinearLayoutManager {
private static final int DEFAULT_EXTRA_LAYOUT_SPACE = 600;
private int extraLayoutSpace = -1;
private Context context;
public PreCachingLayoutManager(Context context) {
this.context = context;
mohamedagamy /
Created Jan 30, 2019 — forked from ba11b0y/
Installing Postman on Ubuntu/Gnome

Since Chrome apps are now being depracated. Download postman from

Installing Postman

tar -xzf Postman-linux-x64-5.3.2.tar.gz

If any version is installed before, remove it.

sudo rm -rf /opt/Postman
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
<uses-sdk android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application android:label="@string/app_name">
mohamedagamy / OpenWithSublimeText3.bat
Created Aug 27, 2016 — forked from roundand/OpenWithSublimeText3.bat
Open folders and files with Sublime Text 3 from windows explorer context menu (tested in Windows 7)
View OpenWithSublimeText3.bat
@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
mohamedagamy / Method 1
Created Aug 13, 2016 — forked from udacityandroid/Method 1
Android Development for Beginners : Define a Method
View Method 1
private String createCalendarEventReminder(String eventName, String location, int minutesAway) {
String reminder = "You have an upcoming event in " + minutesAway + " minutes.";
reminder = reminder + " It is " + eventName + " held at " + location + ".";
return reminder;
mohamedagamy / Option A
Created Aug 13, 2016 — forked from udacityandroid/Option A
Android Development for Beginners : Calculate the Price Method
View Option A
* Calculates the price of the order based on the current quantity.
* @return the price
private int calculate price(int quantity {
int price = quantity * 5;
return price;