Skip to content

Instantly share code, notes, and snippets.

@kamawanu
kamawanu / facebook_oldxhr_hack.js
Created March 21, 2011 15:49
facebook old xd_receiver.js resize hack.
var pos = document.location.hash.search( /setCanvasHeight/ )
if( pos >= 0 ){
hashvpos = document.location.hash.search( /setCanvasHeight%22%2C%22([0-9]+)px/ );
crop = document.location.hash.substring(hashvpos+24);
pxpos = crop.search("px");
heighthack = crop.substring( 0, pxpos );
if( heighthack > 300 ){
newv = document.location.hash.replace( "setCanvasHeight%22%2C%22"+heighthack, "setCanvasHeight%22%2C%22300" );
document.location.hash = newv;
}
@kamawanu
kamawanu / object2array.php
Created April 16, 2011 10:51
converting between nested object and nested array, bidirectional
<?php
/**
* https://gist.github.com/923041
*
* converting between nested object and nested array, bidirectional
*/
function object2array( $srcobject , array $exclude_propnames = null ){
assert( gettype($srcobject) == "object" );
@kamawanu
kamawanu / unescape2utf8.php
Created April 24, 2011 14:42
unescape unicode string and convert utf-8
<?php
function unicode2utf8($aa){
###var_dump(func_get_args());
return mb_convert_encoding( pack("n", hexdec($aa[1]) ), "utf-8", "ucs2" );
}
while( ($f=fgets(STDIN))!==false ){
$a = str_replace('\\','\',$a );
$a = preg_replace_callback('/\\\u([a-f0-9]{4})/i', "unicode2utf8", $f );
@kamawanu
kamawanu / debugmode.py
Created November 23, 2011 07:47
DEBUGMODE = ( time.time() - timeo.st_mtime ) < 60
import sys,os, time
timeo = os.stat(sys.argv[0])
DEBUGMODE = ( time.time() - timeo.st_mtime ) < 60
#!/bin/bash -x
TMP=/tmp/$$
mkdir $TMP
trap "/bin/rm -rf $TMP" 0 3 6 9 15
lsusb | (
if [ $# -gt 0 ]
then
fgrep $1
else
cat
@kamawanu
kamawanu / _.awk
Last active October 27, 2015 01:38
tiny build prop parser
#
# https://gist.github.com/kamawanu/6820f0bc061351d0dd14/
#
# https://gist.githubusercontent.com/kamawanu/6820f0bc061351d0dd14/raw/_.awk
#
# adb shell cat /system/build.prop | awk -f $ITS
#
BEGIN {
FS="="
}
@kamawanu
kamawanu / add-sparse-vdisk.sh
Last active December 15, 2015 07:59
add sparse virtualdisk for linuxmint
#!/bin/sh -x
PART=$1
MSIZE=${2-20}
FS=${3-ext4}
SIZE=$( expr $MSIZE \* 1024 \* 1024 )
LAST=$( expr $SIZE - 1 )
dd if=/dev/zero bs=1k count=1 seek=$LAST of=/host/linuxmint/$PART.disk
mkfs.$FS /host/linuxmint/$PART.disk || exit 9
ls -l /host/linuxmint/$PART.disk
du -sm /host/linuxmint/$PART.disk
.post_thumb , .image, .grid .image .icon, .grid .photoset .icon, .grid .video .bg, .grid .image .bg {
width: 200px; height: 200px;
}