Skip to content

Instantly share code, notes, and snippets.

commands :
open a port :
$/sbin/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8389 -j ACCEPT
download in china :
$rsync --partial --progress --timeout=60000 [email protected]:/path/file .
mp4 to gif :
$ffmpeg -i file.m4v -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=1 > fille.gif
@JulienGenoud
JulienGenoud / PrefrenceUtils.java
Created October 27, 2015 12:13
sharedpref helper
private static SharedPreferences preferences;
private static SharedPreferences getAppPreference(Context context) {
if (preferences == null) {
preferences = context.getSharedPreferences(APP_PREFERENCE_NAME, Context.MODE_PRIVATE);
}
return preferences;
}
@JulienGenoud
JulienGenoud / gist:41d5f1348436b5f9ce965524ef8c49f5
Last active August 4, 2016 14:38 — forked from ec84b4/gist:d56c00fb5fd2dfaf279b
recycler view header adapter
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
/**
* Created by khaled bakhtiari on 10/26/2014.
* <a href="http://about.me/kh.bakhtiari">
*/
viewHolder.tvTitle.post(new Runnable() {
@Override
public void run() {
Layout l = viewHolder.tvTitle.getLayout();
SpannableString ss;
if (l.getText().toString().contains("…")) {
String text = l.getText().toString().split("…")[0];
ss = new SpannableString(text.subSequence(0, text.length() - 10) + "…\u00A0\u00A0\u00A0\u00A0");
} else {
public class RecyclerArrayAdapter extends RecyclerView.Adapter<RecyclerArrayAdapter.ArrayAdaperViewHolder> {
private List<String> mObjects;
private OnItemClickListener mListener;
public interface OnItemClickListener {
void onItemClick(String query);
}
public RecyclerArrayAdapter(final List<String> objects, OnItemClickListener listener) {
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
} else {
Fabric.with(this, new Crashlytics());
}
@JulienGenoud
JulienGenoud / aes.java
Created April 4, 2018 15:17
AES SAMPLE
String str = "coucou";
byte[] keyStart = "this is a key".getBytes();
KeyGenerator kgen = KeyGenerator.getInstance("AES");
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
sr.setSeed(keyStart);
kgen.init(256, sr); // 192 and 256 bits may not be available
SecretKey skey = kgen.generateKey();
String str = "coucou";
String seed = "seedFromSensor";
// generate public and private keys
final int keySize = 2048;
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
SecureRandom sr = new SecureRandom(seed.getBytes());
keyPairGenerator.initialize(keySize, sr);
version: 2
updates:
- package-ecosystem: gradle
directory: "."
schedule:
interval: "monthly"
time: "22:00"
open-pull-requests-limit: 15
target-branch: dev
labels:
name: CI
on:
pull_request:
push:
branches:
- master
jobs:
test: