Skip to content

Instantly share code, notes, and snippets.

@Androguide
Androguide / tel-regex.js
Last active March 15, 2021 20:58
French phone number regex
var regex = new RegExp(/^[+](\d{3})\)?(\d{3})(\d{5,6})$|^(\d{10,10})$/);
regex.test('0612345678') // true
regex.test('06123456789') // false
regex.test('+33612345678') // true
regex.test('+330612345678') // true
regex.test('+3306123456789') // false
@Androguide
Androguide / launch-app.sh
Created January 28, 2014 09:50
Launch an Android app through adb using the apk name instead of the package name (e.g: launch-app.sh yourapp.apk)
pkg=$(aapt dump badging $1|awk -F" " '/package/ {print $2}'|awk -F"'" '/name=/ {print $2}')
act=$(aapt dump badging $1|awk -F" " '/launchable-activity/ {print $2}'|awk -F"'" '/name=/ {print $2}')
adb shell am start -n $pkg/$act
@Androguide
Androguide / set-opacity.scss
Created January 29, 2014 09:23
Sass mixin for prefixing the opacity propery
@mixin setOpacity($amount) {
-moz-opacity: $amount / 100;
-khtml-opacity: $amount / 100;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + $amount + ")";
filter: alpha(opacity=$amount);
opacity: $amount / 100;
}
@Androguide
Androguide / cherry-pick.sh
Last active January 4, 2016 19:09
Git cherry-pick a commit from an external online repository
git fetch https://gerrit.omnirom.org/repo_url refs/changes/XX/XXXX/X && git checkout FETCH_HEAD
@Androguide
Androguide / external-cherry-pick.sh
Created January 27, 2014 19:58
Git one-liner to cherry-pick a commit from another repo
git --git-dir=../other/repo/path/.git \
format-patch -k -1 --stdout <commit SHA> | \
git am -3 -k
@Androguide
Androguide / boilerplate.sh
Last active January 4, 2016 02:39
Bash boilerplate for coloured scripts and checking for passed arguments
#!/bin/bash
CYAN="\\033[1;36m"
GREEN="\\033[1;32m"
YELLOW="\\E[33;44m"
RED="\\033[1;31m"
RESET="\\e[0m"
MODE='blah'
if [ -z "$1" ]
@Androguide
Androguide / 51-android.rules
Created January 15, 2014 21:42
Linux udev rules for adb & fastboot protocols on a variety of vendors and devices (location: /etc/udev/rules.d/51-android.rules)
#Lenovo
SUBSYSTEM=="usb", ATTR{idVendor}=="17EF", MODE="0666", OWNER="androguide"
#LG
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", OWNER="androguide"
#Motorola
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", OWNER="androguide"
#NEC
@Androguide
Androguide / cm_rhine_honami_row_defconfig
Last active January 1, 2016 09:39
msm8974 kernel defconfig for Ubuntu Touch on honami (Sony Xperia Z1)
# CONFIG_ARM_PATCH_PHYS_VIRT is not set
CONFIG_EXPERIMENTAL=y
CONFIG_LOCALVERSION="-perf"
CONFIG_KERNEL_LZO=y
CONFIG_SYSVIPC=y
CONFIG_AUDIT=y
CONFIG_RCU_FAST_NO_HZ=y
CONFIG_IKCONFIG=y
CONFIG_CGROUPS=y
CONFIG_CGROUP_DEBUG=y
@Androguide
Androguide / gist:7872884
Created December 9, 2013 14:19
Remove blue overlay in the Android WebView when a button/link is clicked, in order to let the CSS handle the pressed state.
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
@Androguide
Androguide / wyswyg_saver.js
Created November 18, 2013 09:50
WYSWYG website editor bookmarklet : Saver
document.body.contentEditable = 'false';
document.designMode = 'off';
var content = document.documentElement.outerHTML;
document.body.innerHTML = "<br><br><br><br><center><button style='width: 50%; font-size: 1.7em; background-color: #3f9fe0; color: #fff' onclick='generate()'>Your HTML</button></center>";
function generate() {
document.location = "data:text/json," + escape(content);
}