Skip to content

Instantly share code, notes, and snippets.

@crgarridos
crgarridos / SplashActivity.java
Created August 19, 2015 08:23
Simple Splash Activity
public class SplashActivity extends BaseActivity {
private final int SPLASH_DISPLAY_LENGHT = 1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
new Handler().postDelayed(new Runnable() {
@Override
@crgarridos
crgarridos / genRetrofitApis.js
Last active November 18, 2015 17:41
Script to generate Retrofits Interfaces from Symfony API's doc site
var operations = $(".operation");
var div = $("<div>");
div.css({
background: "whitesmoke",
/*position: "fixed",
top: 0,
//margin: "5%",
"overflow-y": "scroll",*/
width : "100%",
height : "100%",
@crgarridos
crgarridos / _MySQL2GreenDao.sql
Last active December 2, 2015 13:21
Script to generate GreenDao entities from a MySQL procedure
CALL fetchTables('from-this-database');
@crgarridos
crgarridos / mysql2sqlite.sh
Last active December 2, 2015 16:46 — forked from esperlu/mysql2sqlite.sh
MySQL to Android Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
public void unzip() {
try {
FileInputStream inputStream = new FileInputStream(filePath);
ZipInputStream zipStream = new ZipInputStream(inputStream);
ZipEntry zEntry = null;
while ((zEntry = zipStream.getNextEntry()) != null) {
Log.d("Unzip", "Unzipping " + zEntry.getName() + " at "
+ destination);
@crgarridos
crgarridos / README.md
Created August 5, 2016 08:58 — forked from polbins/README.md
Simple RecyclerView Divider

Simple RecyclerView Divider

Simple Horizontal Divider Item Decoration for RecyclerView

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(
            getApplicationContext()
    	));

NOTE: Add item decoration prior to setting the adapter

@crgarridos
crgarridos / themes-debug.xml
Created September 8, 2016 14:58 — forked from dlew/themes-debug.xml
With the new theming in AppCompat, a lot of assets are tinted automatically for you via theme attributes. That has often led me to wonder "where the hell did this color come from?" You can replace your normal theme with this debug theme to help figure out the source of that color.
<!-- You can change the parent around to whatever you normally use -->
<style name="DebugColors" parent="Theme.AppCompat">
<!-- System colors -->
<item name="android:windowBackground">@color/__debugWindowBackground</item>
<item name="android:colorPressedHighlight">#FF4400</item>
<item name="android:colorLongPressedHighlight">#FF0044</item>
<item name="android:colorFocusedHighlight">#44FF00</item>
<item name="android:colorActivatedHighlight">#00FF44</item>
[ ]+?android:(.*)="(.+)"
<item name="android:$1">$2</item>
@crgarridos
crgarridos / BaseActivity.java
Last active October 18, 2016 10:50
A BaseActivity to manage easily the storage permissions in Android
abstract public class BaseActivity extends AppCompatActivity {
// Storage Permissions variables
private static final int REQUEST_CODE_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
};
private Runnable mOnWritePermissionGranted;
@crgarridos
crgarridos / YoutubePopup.js
Last active May 19, 2017 08:44
Javascript snippet to allow popup a youtube video (check http://cgarrido.me/?p=66)
javascript:(function(){
var id = location.href.match(/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/);
if(id != null && typeof id == "object" && id.length > 1){
id = id[1];
var time = 0;
try {
time = parseInt(yt.player.utils.VideoTagPool.instance.A[0].getCurrentTime());
yt.player.utils.VideoTagPool.instance.A[0].pause();
}
catch(ex){console.log(ex);}