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 / 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 / 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>
/* Inspired by Python's useful re.findall method */
function findall(regex, str) {
var matches = [], m;
regex.lastIndex = 0;
while (m = regex.exec(str, regex.lastIndex)) {
matches[matches.length] = m;
}
return matches;
}
@allex
allex / .gitconfig
Created August 1, 2012 15:26 — forked from karlwestin/.gitconfig
Make git diff ignore whitespace and don't try to open jpgs and shit
# this can be put in [repo]/.git/config for local settings
# or ~/.gitconfig for global settings
# create a difftool "nodiff" that just returns true
# this path is for Mac. On linux it's /bin/true i guess
[diff "nodiff"]
command = /usr/bin/true
# make git ignore white space differences, many different possibilites here
@allex
allex / gist:4014879
Created November 5, 2012 02:03 — forked from nateps/gist:1172490
Hide the address bar in a fullscreen iPhone or Android web app
<!DOCTYPE html>
<meta charset=utf-8>
<meta name=viewport content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name=apple-mobile-web-app-capable content=yes>
<meta name=apple-mobile-web-app-status-bar-style content=black>
<title>Test fullscreen</title>
<style>
html, body {
margin: 0;
padding: 0;
@allex
allex / gist:5931372
Last active December 19, 2015 09:09 — forked from isaacs/gist:5914757
// Generated via:
// node -e "s=require('http').STATUS_CODES;Object.keys(s).map(function(c){console.log('#define HTTP_STATUS_%d %j',c,c+' '+s[c])})"
#define HTTP_STATUS_100 "100 Continue"
#define HTTP_STATUS_101 "101 Switching Protocols"
#define HTTP_STATUS_102 "102 Processing"
#define HTTP_STATUS_200 "200 OK"
#define HTTP_STATUS_201 "201 Created"
#define HTTP_STATUS_202 "202 Accepted"
#define HTTP_STATUS_203 "203 Non-Authoritative Information"
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.*;
public class JsonHelper {
public static Object toJSON(Object object) throws JSONException {
if (object instanceof Map) {
JSONObject json = new JSONObject();
@mixin background_image ($filename) {
background-image: image-url(1x/#{$filename});
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
background-image: image-url(2x/#{$filename});
}
}
@allex
allex / bbs.js
Last active August 29, 2015 14:20 — forked from TooTallNate/bbs.js
/**
* Requires node v0.7.7 or greater.
*
* To connect: $ curl -sSNT. localhost:8000
*/
var http = require('http')
, repl = require('repl')
, buf0 = new Buffer([0])