Skip to content

Instantly share code, notes, and snippets.

@allex
allex / gist:1057802
Created July 1, 2011 03:14
Counting linux source code
find . -name \*.h -exec wc {} \; > /tmp/src.txt
find . -name \*.c -exec wc {} \; >> /tmp/src.txt
cat sample.py
total = 0
myfile = open('src.txt')
lines = myfile.readlines()
for line in lines:
print line.split()[0]
@allex
allex / gist:1070928
Created July 8, 2011 01:39
calc specific disk space as integer
function disk(v) {
// var r = ((v - 1) * 1028) + 1024;
return Math.ceil(Math.ceil(v * 1024 / 7.84423828125) * 7.84423828125);
}
@allex
allex / gist:1158485
Created August 20, 2011 01:49
window.close method of JavaScript not working in Chrome
window.open('', '_self', '');
window.close();
@allex
allex / gist:1307393
Created October 23, 2011 14:07
boot ubuntu manally
title Ubuntu 11.04
find –set-root –ignore-floppies –ignore-cd /boot/grub/core.img
kernel /boot/grub/core.img
boot
@allex
allex / ubuntu-notes.md
Last active September 28, 2015 01:18
Ubuntu customize setting notes, (update lately)

Removed the warning: Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",

allex@WANG:~$ sudo install the gtk2-engines-pixbuf

Check unity features supports:

/usr/lib/nux/unity_support_test -p

@allex
allex / socksproxy.js
Created February 8, 2012 03:05 — forked from telamon/socksproxy.js
Socks5 proxy implementation in Node.JS
// http://www.ietf.org/rfc/rfc1928.txt
// Tested with: curl http://www.google.se/ --socks5 1080 --proxy-user foo:bar
var States = {
CONNECTED:0,
VERIFYING:1,
READY:2,
PROXY: 3
};
@allex
allex / getPrefix.js
Created February 19, 2012 02:49
Get vendor style prefix
/* vim: set ft=javascript */
// http://addyosmani.com/polyfillthehtml5gaps/slides/#78
function getPrefix(prop){
var prefixes = ['Moz','Khtml','Webkit','O','ms'],
elem = document.createElement('div'),
upper = prop.charAt(0).toUpperCase() + prop.slice(1);
if (prop in elem.style)
return prop;
@allex
allex / gist:1880618
Created February 22, 2012 02:00
Hide the iOs soft keyboard
/* vim: set ft=javascript: */
// Javascript: Hide the iOS soft keyboard
//
// http://uihacker.blogspot.com/2011/10/javascript-hide-ios-soft-keyboard.html
// http://stackoverflow.com/questions/5937339/ipad-safari-make-keyboard-disappear
// -------------------------------------------------------------------------------
// I was having some trouble getting my text input field to relieve itself of focus on the
// iPhone, and after a little searching, I came up with a couple options. It's pretty
// self-explanatory. The 2nd line will de-focus all input fields, and it relies on jQuery.
@allex
allex / gist:2515452
Created April 28, 2012 03:30
getElementsByTagName
/* vim: set ft=javascript: */
// http://dean.edwards.name/weblog/2009/12/getelementsbytagname/
function getElementsByTagName(node, tagName) {
var elements = [], i = 0, anyTag = tagName === "*", next = node.firstChild;
while ((node = next)) {
if (anyTag ? node.nodeType === 1 : node.nodeName === tagName) elements[i++] = node;
next = node.firstChild || node.nextSibling;
while (!next && (node = node.parentNode)) next = node.nextSibling;
}
return elements;
@allex
allex / i.html
Created June 1, 2012 06:06 — forked from Victa/i.html
Canvas Spinner
<!doctype html>
<title>Canvas spinner</title>
<link rel=stylesheet href=s.css>
<script src=s.js></script>