Skip to content

Instantly share code, notes, and snippets.

View atdt's full-sized avatar
💭
in rainbows

Ori Livneh atdt

💭
in rainbows
  • Google
  • New York City
View GitHub Profile
@atdt
atdt / qsort.js
Created April 26, 2012 07:45
naive javascript quicksort
// naive quicksort
function qsort(a) {
var len = a.length;
if ( !len || len === 1 )
return a;
var pivot = a[0],
@atdt
atdt / npm-test-pre-commit.js
Created May 24, 2012 20:09
simple pre-commit hook to run npm test
#!/usr/bin/env node
(function () {
var npm = require('npm');
function done( error ) {
process.exit( error === null ? 1 : 0 );
}
function test() {
@atdt
atdt / test.js
Created May 31, 2012 18:55
hashing test.js
function iter( iters ) {
values = mw.config.values;
iters = iters || 100000;
var hits = 0;
for ( var i = 0; i < iters; i++ ) {
values['wgArticleId'] = i + '';
if (isEligible()) {
hits++;
}
}
@atdt
atdt / udp2log_filter.sh
Created June 6, 2012 19:15
udp2log filter
#!/usr/bin/env bash
LOGDIR="/var/log" # destination for log files
# Reads lines from standard input. For each line, write into a log file whose
# name is generate from the first field in the line and the current date.
# Fields are whitespace-delimited. For example, the line "foo bar buzz 123"
# will be recorded in the file "foo-2012-06-06.log"
while read -r line ; do
95:42:94:48:75
var bucketCookies = $.getBuckets();
bucketCookies['lastModified'][0] = 'expr1';
$.cookie('userbuckets', $.toJSON( bucketCookies ) , { expires: 365 }); //expires in 1 year
select page_id, page_title from page where page_id in (220, 252, 292, 445, 606, 792, 1004, 1047, 1048, 1076, 1252, 1430, 1448, 1501, 1504, 1567, 1734, 1752, 1771, 1929, 2431, 2659, 2673, 2691, 2823, 2872, 2991, 3009, 3065, 3185, 3249, 3294, 3305, 3375, 3427, 3856, 3859, 4133, 4232, 4430, 4609, 4815, 4854, 4888, 5568, 5749, 5853, 6210, 6298, 6359, 6446, 6816, 7179, 7636, 7919, 8003, 8053, 8191, 8378, 8759, 8785, 8792, 9001, 9427, 9682, 9891, 9897, 9995, 10028, 10076, 10270, 10495, 10669, 10943, 10958, 11468, 11578, 11863, 11970, 12074, 12087, 12335, 12375, 13224, 13307, 13625, 13751, 14101, 14180, 14619, 14858, 15147, 15463, 15480, 15515, 15615, 15697, 15899, 16718, 17051);
var bucketCookies = $.getBuckets();
bucketCookies['lastModified'][0] = 'expr1';
$.cookie('userbuckets', $.toJSON( bucketCookies ) , { expires: 365 }); //expires in 1 year
@atdt
atdt / tobytearray.js
Created June 20, 2012 16:24
stringToByteArray
function stringToByteArray( str ) {
var codepoint, stack, bytes = [];
for ( var i = 0; i < str.length; i++ ) {
codepoint = str.charCodeAt( i );
stack = [];
do {
// Get 8 lowest bits of character g
stack.unshift( codepoint & 0xff );
@atdt
atdt / add-edit-count.php
Created June 22, 2012 19:58
excerpt from post-edit feedback ext.
function onBeforePageDisplay( &$out, &$skin ) {
global $wgRequest;
global $wgUser;
global $wgOut;
if ( $wgRequest->getCheck('postedit') ) {
$wgOut->addJsConfigVars( array (
"wgUserEditCount" => $wgUser->getEditCount(),
"wgArticleUpdate" => true
) );