Skip to content

Instantly share code, notes, and snippets.

View ncornette's full-sized avatar

Nicolas Cornette ncornette

View GitHub Profile
@ncornette
ncornette / gist:3272344
Created August 6, 2012 08:49
An interactive Bash function that allow you to select an Android device in a list then Sets ANDROID_SERIAL
# Display a list of all connected Android devices
# Set ANDROID_SERIAL environment from selected item
# Example of use : # adb-setdev && adb install -r myapp.apk
function adb-setdev()
{
devices=($(adb devices|grep "device$"|cut -f1))
devices_count=${#devices[*]}
if [ "$devices_count" -eq "0" ]
then
unset ANDROID_SERIAL
@ncornette
ncornette / gist:3370010
Last active February 25, 2017 23:24
An interactive Bash function for Android that runs emulator by prompting you a list of all installed avd
# Display a list of all installed avd,
# prompt user to select,
# then run emulator with option -avd set
# Example of use : # emulator-avd
function emulator-avd()
{
avds=($(for f in `find ~/.android/avd/*.ini -iname "*.ini"`; do echo `basename $f .ini`; done))
select avd in ${avds[*]}
do
@ncornette
ncornette / colors2html.py
Created August 20, 2012 13:28
converts color codes to html for colors to be displayed in a browser
#!/usr/bin/env python
#
# Converts color codes from text to html
# so that colors can be visible in a browser
#
import re
import sys
HTML_START="<html><head /><body><pre>"
@ncornette
ncornette / ipython_console.py
Last active November 3, 2023 23:28
Gimp plugin for interactive Gimp scripting using IPython
#!/usr/bin/env python
# 1. Save this file in your ~/.gimp-2.8/plug-ins/ directory
# 2. Run gimp from terminal
# 3. Go to Filters/Python-Fu/IPython Console
# 4. Go back to terminal to enjoy interactive Gimp scripting
#
import gimpfu
import gimp
from gimpfu import pdb
@ncornette
ncornette / .xinitrc
Created December 4, 2014 09:15
.xinitrc for kiosk mode
#!/bin/sh
# invoke global X session script
#. /etc/X11/Xsession
# HOW-TO :
# 1. Disable any Display Manager (lightdm/gdm/gdm3) from executing on startup
# 2. Allow user to start X :
# a. Edit /etc/X11/Xwrapper.config
# b. Set value : "allowed_users=anybody"
# 3. insert "su kiosk -c xinit &" into /etc/rc.local
#!/usr/bin/env python
import sys
import gtk
from gtk import gdk
import webkit
import gobject
page_url = len(sys.argv)>1 and sys.argv[1] or 'http://www.google.com'
gobject.threads_init()
win = gtk.Window()
@ncornette
ncornette / gist:77fdf6ee4777965813d4
Created February 19, 2015 09:37
Git track all remote branches
#1 create fresh git clone
#2 track all remote branches
for b in `git branch -r | sed "s/ origin\///g"`; do git branch $b -t origin/$b; done
package com.vsct;
import org.junit.Test;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public class DynamicProxy {
private static final InvocationHandler INVOKE_DO_NOTHING = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return null;
@ncornette
ncornette / unused-layouts.sh
Created November 19, 2015 15:27
Command to find unused layouts in android project
#!/bin/bash
# Find Unused (unreferences) layouts in android project
for f in `find ./src -iname "*.xml" | grep res/layout`; do echo $f ; git grep --count -e "R\.layout\.$(basename $f .xml)\W" --or -e "@layout/$(basename $f .xml)\W" | wc -l ; done | grep -B1 "^0"