Skip to content

Instantly share code, notes, and snippets.

View NaserKhoshfetrat's full-sized avatar

Naser Khoshfetrat NaserKhoshfetrat

View GitHub Profile
@Anass-ABEA
Anass-ABEA / AES.java
Last active October 19, 2024 19:26
AES ENCRYPTION
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import java.util.Base64;
/**
* Possible KEY_SIZE values are 128, 192 and 256
* Possible T_LEN values are 128, 120, 112, 104 and 96
*/
@Anass-ABEA
Anass-ABEA / RSA.java
Last active November 11, 2021 09:57
helper methods to encode and decode Strings using the Base64 encoder and decoder
import javax.crypto.Cipher;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Base64;
/**
* @author Anass AIT BEN EL ARBI
* <ul>
@Abdallah-Abdelazim
Abdallah-Abdelazim / drawablegen.sh
Last active November 30, 2023 22:16 — forked from Kishanjvaghela/converter.sh
drawablegen - A shell script to resize icon images and generate the alternative drawables with the proper screen pixel densities (dip) for Android.
#!/bin/sh
# A shell script to resize icon images and generate the alternative drawables with the proper screen pixel densities (dip) for Android.
# The passed icon image would be the xxxhdpi drawable & the other drawables (xxhdpi, xhdpi, hdpi & mdpi) would be scaled down from that.
# How to use:
# ./drawablegen.sh <icon image file relative path>
# Example:
# ./drawablegen.sh my_image.png
# This will create all the drawable folders, if not has already, in a res folder inside the current directory (as returned by pwd).
# Use only with PNG images.
# Requires ImageMagick to be installed & added to the path environment variable. Install with: sudo apt install imagemagick
@dtodt
dtodt / Retry.java
Last active February 23, 2023 18:18
[email protected] - Retry Adapter Factory - Call & CompletableFuture
package com.company.retrofit2.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
@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
@SimonMarquis
SimonMarquis / PreventScreenshot.java
Created October 21, 2016 08:23
Prevent screenshot on Activity, Dialog, Surface, etc.
import android.app.Activity;
import android.app.Dialog;
import android.app.Fragment;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.view.SurfaceView;
import android.view.Window;
import android.view.WindowManager;
/**
@danielesegato
danielesegato / CreditCardFormatTextWatcher.java
Last active April 8, 2021 08:42 — forked from liberorignanese/MarginSpan.java
Android TextInputLayout with credit card mask
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.Spannable;
import android.text.TextWatcher;
@milechainsaw
milechainsaw / BackoffCallback.java
Created July 19, 2016 12:53
Exponential backoff support for Retrofit2.
/**
* Created by milechainsaw on 7/19/16.
*
* Exponential backoff callback for Retrofit2
*
*/
public abstract class BackoffCallback<T> implements Callback<T> {
private static final int RETRY_COUNT = 3;
/**
* Base retry delay for exponential backoff, in Milliseconds
@pallavahooja
pallavahooja / APIHelper.java
Last active November 9, 2020 16:48
Retrofit Retry
package app.goplus.in.v2.network;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by pallavahooja on 16/05/16.
*/
public class APIHelper {
@ianxtreem
ianxtreem / 100 5min ma
Created November 11, 2015 12:45
A pine script for a 100 period 5 minute moving average that shows up on all minute charts less than 15 minutes. For tradingview.
study(title="Moving Average", shorttitle="MA100 5min", overlay=true)
out = interval > 15 ? na : isintraday ? security(ticker, "5", sma(close,100)) : na
plot(out, color=blue, style=circles, title="MA100 5min")