Skip to content

Instantly share code, notes, and snippets.

@mbarrben
mbarrben / squash_steps.txt
Last active November 8, 2015 10:30
Squash steps
1. Check out develop and make pull from origin
git checkout develop
git pull
2. Check out your branch
git checkout <your-branch-name-here>
3. Merge develop into your branch
git merge develop
4. git reset --soft origin/develop
5. Commit the pending changes in a single commit
git commit -m "<your-commit-message-here>"
@mbarrben
mbarrben / gist:e80e4dd3b02663bdc7a3
Created February 3, 2015 18:59
Proguard rules for Retrofit, OkHttp, Gson, Dagger
# Retrofit, OkHttp, Gson
-keepattributes *Annotation*
-keepattributes Signature
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
-dontwarn rx.**
-dontwarn retrofit.**
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
@mbarrben
mbarrben / mapper.java
Created October 28, 2014 11:12
Mapper
/**Transforms an input object into an output object */
public interface Mapper<OUT, IN> {
OUT map(IN in);
}
#To delete all branches that are already merged into the currently checked out branch:
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
@mbarrben
mbarrben / MediaSelector.java
Last active January 3, 2016 13:39
Create IntentChooser dialog to get images in an Android app. Based on http://stackoverflow.com/a/12347567/626787
public interface MediaSelector {
Intent getIntentChooser();
Uri getMediaUriFromActivityResult(int requestCode, Intent data);
}
@mbarrben
mbarrben / emoji.txt
Created November 4, 2013 09:56
Emojis
iOS Emoji
by Eric Fredricksen 2012 (source code)
This'll only work on Safari.
[dense] [descriptive]
People
😄 &#x1f604; SMILING FACE WITH OPEN MOUTH AND SMILING EYES
😃 &#x1f603; SMILING FACE WITH OPEN MOUTH
😀 &#x1f600; GRINNING FACE
😊 &#x1f60a; SMILING FACE WITH SMILING EYES
@mbarrben
mbarrben / decrypt.java
Created November 4, 2013 09:51
java encrypt and decrypt
MessageDigest digest = MessageDigest.getInstance("SHA");
digest.update(password.getBytes());
SecretKeySpec key = new SecretKeySpec(digest.digest(), 0, 16, "AES");
Cipher c = Cipher.getInstance("AES");
c.init(Cipher.DECRYPT_MODE, key);
cis = new CipherInputStream(stream, c);
reader = new BufferedReader(new InputStreamReader(cis));
String data = reader.readLine();
array = new JSONArray(data);
reader.close();
@mbarrben
mbarrben / move_remote_git_tag
Created July 29, 2013 09:44
Move remote Git tag
git pull # to marge changes from others
git tag -d v0.99 # delete the tag
git push origin :refs/tags/v0.99 # this remove tag from remote repository
git tag v0.99 # this mark the most recent commit
git push origin v0.99 # push a new tag position to remote repository
@mbarrben
mbarrben / excel_sample.txt
Last active December 10, 2015 23:38
Build an MS Excel sheet with all the strings defined in every strings.xml file from an Android project separated in columns.
---------------------------------------------------------
| | en | es-rES | ...
---------------------------------------------------------
| hello_world | Hello world! | ¡Hola, mundo! | ...
---------------------------------------------------------
| good_bye | Good bye | Adiós | ...
. . .
. . .
. . .
@mbarrben
mbarrben / excel_format.txt
Last active December 10, 2015 22:18
Create full directory structure (also lang code suffix) and localised string.xml files for an Android project from an MS Excel file. For those not using xliff or gettext...
------------------------------------------------
| | lang_code_1 | lang_code_2 | ...
------------------------------------------------
| key_1 | translation | translation | ...
------------------------------------------------
| key_2 | translation | translation | ...
. . .
. . .
. . .