Skip to content

Instantly share code, notes, and snippets.

View gipi's full-sized avatar
😎
code for food

Gianluca Pacchiella gipi

😎
code for food
View GitHub Profile
@gipi
gipi / Dockerfile
Last active August 29, 2015 14:17
#asciicinema
FROM debian:jessie
RUN apt-get update
RUN echo '\nHere we are going to test permissions\n' > /root/instructions
RUN useradd --create-home --shell /bin/bash user1
RUN useradd --create-home --shell /bin/bash user2
@gipi
gipi / index.md
Created May 8, 2015 07:39
#blender
- http://kukuruku.co/hub/algorithms/julia-set
@gipi
gipi / gist:1267311
Created October 6, 2011 12:46
To launch a web page in a browser from an activity
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
@gipi
gipi / gist:1267393
Created October 6, 2011 13:29
Retrieve an identification ID from an android device
// http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id
final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, tmPhone, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());
String deviceId = deviceUuid.toString();
@gipi
gipi / SegmentedButton.java
Created October 7, 2011 09:13
Customized Segmented button
/**
* Customization of the RadioButton in order to allow behaviour
* and appearance like the iOS ones.
*
* Inspired from http://blog.bookworm.at/2010/10/segmented-controls-in-android.html
*/
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.GradientDrawable;
import android.graphics.Canvas;
@gipi
gipi / gist:1289605
Created October 15, 2011 14:03
Simple shell routine to calculate dpi
function calcdpi() {
echo "sqrt($1^2+$2^2)/$3" | bc
}
@gipi
gipi / gist:1292237
Created October 17, 2011 09:02
Install an APK in all running emulators/devices
# ant clean && ant debug && adbInstallAll
adbInstallAll() {
adb devices | \
sed '1d;/^$/d;' | \
awk '{print $1}' | \
while read device;
do
adb -s $device install -r bin/*-debug.apk
done
@gipi
gipi / gist:1292453
Created October 17, 2011 11:49
Set term title
set_console_title() {
PROMPT_COMMAND='echo -ne "\033]0;"'$1'"\007"';
}
@gipi
gipi / gist:1292623
Created October 17, 2011 13:38
Add a documentation target to Android ant build file
<target name="docs">
<javadoc
sourcepath="src/"
destdir="docs/"
/>
</target>