This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Copyright 2014 Ori Livneh | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getId() { | |
var id = null; | |
try { | |
id = localStorage.getItem( 'popupsId' ); | |
if ( id === null ) { | |
id = mw.user.generateRandomSessionId(); | |
localStorage.setItem( 'popupsId', id ); | |
} | |
} catch (e) {} | |
return id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
class Stats: | |
"""A simple StatsD metric client. | |
See <https://github.com/etsy/statsd/wiki/Protocol> for details. | |
""" | |
def __init__(self, host, port): | |
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
self.address = (host, port) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env bash | |
# Unit tests for /geoiplookup | |
# Usage: geotests HOSTNAME | |
url="${1:-localhost}/geoiplookup" fails=0 | |
pass() { echo "$(tput bold; tput setaf 2)PASSED:$(tput sgr0) $*"; } | |
fail() { echo "$(tput bold; tput setaf 1)FAILED:$(tput sgr0) $*"; fails=$(($fails+1)); } | |
assert() { curl -s -H "Host: bits.wikimedia.org" \ | |
${3:+-H "X-Forwarded-For: ${3}"} ${url} | grep -q "${2}" && pass $1 || fail $1; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
words = itertools.cycle(line.strip() for line in open('/usr/share/dict/words', 'rt')) | |
def py_djb_hash(s): | |
'''Return the value of DJB's hash function for the given 8-bit string.''' | |
h = 5381 | |
for c in s: | |
h = (((h << 5) + h) ^ ord(c)) & 0xffffffff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var checkUsername = ( function () { | |
var api = new mw.Api(), | |
req = null, | |
checked = {}; | |
return function ( username ) { | |
if ( !checked.hasOwnProperty( username ) ) { | |
checked[ username ] = $.Deferred(); | |
if ( req ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function rawGet( $key ) { | |
$socket = socket_create( AF_INET, SOCK_STREAM, SOL_TCP ); | |
socket_connect( $socket, '127.0.0.1', 11211 ); | |
socket_write($socket, "get $key\r\n" ); | |
$value = trim( socket_read( $socket, 4096 ) ); | |
socket_close( $socket ); | |
return $value; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
description "HipHop Virtual Machine for PHP" | |
setuid www-data | |
setgid www-data | |
exec /usr/bin/hhvm --config /etc/hhvm/server.hdf --mode server -vServer.Type=fastcgi -vServer.Port=9000 | |
respawn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From cfec08d7ead003480481c9736e04e868214ea8f9 Mon Sep 17 00:00:00 2001 | |
From: Ori Livneh <ori@wikimedia.org> | |
Date: Tue, 8 Apr 2014 16:11:22 -0700 | |
Subject: [PATCH] Backport of e291667 for v0.2.0 | |
--- | |
phantomjs/main.js | 32 +++++++++++++++++--------------- | |
1 file changed, 17 insertions(+), 15 deletions(-) | |
diff --git a/phantomjs/main.js b/phantomjs/main.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import collections | |
records = [json.loads(line) for line in open('deprecated-js.json')] | |
def iter_modules(): | |
for record in records: | |
for module in record.get('modules', ()): | |
yield module |
OlderNewer