Skip to content

Instantly share code, notes, and snippets.

View mohamedagamy's full-sized avatar
:octocat:
coding...

mohamedelagamy mohamedagamy

:octocat:
coding...
View GitHub Profile
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
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;
@mohamedagamy
mohamedagamy / KeyboardEditText
Created September 12, 2019 09:04
prevent keyboard disappear
//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.
//https://stackoverflow.com/questions/13591012/implementing-onkeypreimeint-keycode-keyevent-event-in-fragment
public class CustomKonashaEditText extends AppCompatEditText {
public CustomKonashaEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}
https://blog.testlodge.com/what-is-bdd/
https://prezi.com/5lw2osodzhqj/tdd-vs-bdd-vs-ddd/
https://qr.ae/TWrej6
https://stackoverflow.com/questions/184618/
========================================================
https://qr.ae/TWreQR
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,
//https://stackoverflow.com/questions/39374227/how-to-load-all-the-images-in-the-background-of-a-recyclerview-in-android
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) {
super(context);
this.context = context;
@mohamedagamy
mohamedagamy / installing-postman.md
Created January 30, 2019 13:25 — forked from ba11b0y/installing-postman.md
Installing Postman on Ubuntu/Gnome

Since Chrome apps are now being depracated. Download postman from https://dl.pstmn.io/download/latest/linux

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
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application android:label="@string/app_name">
@mohamedagamy
mohamedagamy / OpenWithSublimeText3.bat
Created August 27, 2016 07:31 — forked from roundand/OpenWithSublimeText3.bat
Open folders and files with Sublime Text 3 from windows explorer context menu (tested in Windows 7)
@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
mohamedagamy / Method 1
Created August 13, 2016 02:59 — forked from udacityandroid/Method 1
Android Development for Beginners : Define a Method
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
mohamedagamy / Option A
Created August 13, 2016 00:51 — forked from udacityandroid/Option A
Android Development for Beginners : Calculate the Price Method
/**
* 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;
}