Skip to content

Instantly share code, notes, and snippets.

View tiwiz's full-sized avatar

Roberto Orgiu tiwiz

View GitHub Profile
@tiwiz
tiwiz / Generator.java
Last active August 29, 2015 14:05
This class provides the essential implementation of ZXing library in order to generate a QR Code with custom foreground and background color and specified size.
import android.graphics.Bitmap;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
/**
* This class contains a single method that will generate a QR Code
* with given text, foreground and background color, and dimension of the side
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}

Launch Sublime Text 3 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@tiwiz
tiwiz / tabname.md
Last active August 29, 2015 14:05
Add name for the current tab of Terminal in Mac OS X

#Set a custom name for the current Tab on Mac OS X terminal alt text

Open your ~/.bash_profile file and add the following lines:

function tabname {
	printf "\e]1;$1\a"
}

Then, save the file and close the editor and invoke source ~/.bash_profileon a terminal window.

@tiwiz
tiwiz / Script
Created June 6, 2015 08:18
Implementing Crashlytics on a multiflavour and multi-key environment
final File fabricFile = file("fabric.properties")
afterEvaluate {
android.applicationVariants.all { variant ->
final String variantName = variant.getName().capitalize()
final Task targetTask = tasks["process${variantName}Manifest"]
if (fabricTask != null) {
final Task generateFabricFile = task("generateFabricFile$variantName") {
doLast {
String fabricApiSecret = 'verySecretApiSecretForEveryoneGuessItsNotThatSecret'
@tiwiz
tiwiz / build.gradle
Last active August 29, 2015 14:22 — forked from Takhion/build.gradle
String getJavaHome(String version)
{
def stdout = new ByteArrayOutputStream()
exec {
commandLine "/usr/libexec/java_home", "-v", version
standardOutput = stdout;
}
return stdout.toString().trim()
}
@tiwiz
tiwiz / Builder
Created June 22, 2015 15:06
This is a Builder template (as in Android's Dialog.Builder) for IntelliJ/Android Studio. To import it, open any Java file and right click on an empty space. Go then to Generate > Getter and Setter and click on the "..." button on the Setter's line. From there create a new template with the "+" icon and paste this code
#set($paramName = $helper.getParamName($field, $project))
public ##
#if($field.modifierStatic)
static void ##
#else
$classname ##
#end
set$StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))($field.type $paramName) {
#if ($field.name == $paramName)
#if (!$field.modifierStatic)
@tiwiz
tiwiz / build.gradle
Last active June 12, 2018 19:26
How to make Retrolambda work with both Mac OS X and Windows. Thanks to @Takhion - https://gist.github.com/Takhion/5c0f6c0c5aba9db5a488
import org.gradle.internal.os.OperatingSystem;
String getJavaHome(String version) {
def stdout = new ByteArrayOutputStream()
exec {
commandLine "/usr/libexec/java_home", "-v", version
standardOutput = stdout;
}
return stdout.toString().trim()
}
@tiwiz
tiwiz / AndroidManifest.xml
Created November 23, 2015 16:03
Draw over other apps on Android 6
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
@tiwiz
tiwiz / grabdng.py
Created March 21, 2016 11:24 — forked from rock3r/grabdng.py
Grabs all DNG files from the connected Android device's camera roll
#!/usr/bin/python
import argparse, os, subprocess
# Grab the script directory to use as default
current_directory = os.path.dirname(os.path.abspath(__file__))
def parse_cli_arguments():
parser = argparse.ArgumentParser(description = 'Grabs all DNG files from the connected Android device\'s camera roll.')