This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static SharedPreferences preferences; | |
private static SharedPreferences getAppPreference(Context context) { | |
if (preferences == null) { | |
preferences = context.getSharedPreferences(APP_PREFERENCE_NAME, Context.MODE_PRIVATE); | |
} | |
return preferences; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (BuildConfig.DEBUG) { | |
Timber.plant(new Timber.DebugTree()); | |
} else { | |
Fabric.with(this, new Crashlytics()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 | |
updates: | |
- package-ecosystem: gradle | |
directory: "." | |
schedule: | |
interval: "monthly" | |
time: "22:00" | |
open-pull-requests-limit: 15 | |
target-branch: dev | |
labels: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
jobs: | |
test: |