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
<?php
use CirrusSearch\Connection;
use CirrusSearch\Updater;
use ConfigFactory;
$config = ConfigFactory::getDefaultInstance()->makeConfig( 'CirrusSearch' );
$connection = Connection::getPool( $config );
$updater = new Updater( $connection, array() );
$dbr = wfGetDB( DB_SLAVE );
# -*- coding: utf-8 -*-
"""
Iterate enwiki talk pages which embed Template:WPBannerMeta and extract
article quality assessments.
"""
import re
import requests
appendfilename tools-redis-01-6379.aof
auto-aof-rewrite-min-size 512mb
client-output-buffer-limit slave 512mb 200mb 60
dbfilename tools-redis-01-6379.rdb
dir /srv/redis
logfile /var/log/redis/redis.log
maxmemory 12GB
maxmemory-policy allkeys-lru
maxmemory-samples 5
no-appendfsync-on-rewrite yes
function Buffer( callback ) {
var queue = [], timer = null;
return {
push: function ( item ) {
queue.push( item );
timer = timer || setTimeout( function () {
timer = null;
callback( queue );
queue = [];
}, 0 );
@atdt
atdt / interwiki.php
Created November 1, 2015 06:54
PHP dump of interwiki.cdb, 31-Oct-2015
<?php
return array(
"__global:acronym" => "0 http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=$1",
"__global:advisory" => "1 //advisory.wikimedia.org/wiki/$1",
"__global:advogato" => "0 http://www.advogato.org/$1",
"__global:aew" => "0 http://wiki.arabeyes.org/$1",
"__global:appropedia" => "0 http://www.appropedia.org/$1",
"__global:aquariumwiki" => "0 http://www.theaquariumwiki.com/$1",
"__global:arborwiki" => "0 https://localwiki.org/ann-arbor/$1",
"__global:arxiv" => "0 http://arxiv.org/abs/$1",
import requests
import json
cookies = {'GerritAccount': 'xxx'}
headers = {'X-Gerrit-Auth': 'xxx'}
r = requests.get('https://gerrit.wikimedia.org/r/groups/', cookies=cookies, headers=headers)
groups = json.loads(r.text[5:])
for name, params in groups.items():
if params.get('owner') == 'Project and Group Creators':
@atdt
atdt / bench.php
Last active October 29, 2015 04:22
psquare bench
<?php
require_once __DIR__ . '/PSquare.php';
// words.txt contains "The frequency of occurrence of unique words in the novel
// Moby Dick by Herman Melville." from http://tuvalu.santafe.edu/~aaronc/powerlaws/data.htm
$words = array_map( 'intval', file( 'words.txt' ) );
$start = microtime( true );
$ps = new \RunningStat\PSquare( 0.90 );
foreach ( $words as $freq ) {
@atdt
atdt / ProFi.lua
Created October 27, 2015 09:01 — forked from perky/ProFi.lua
ProFi, a simple lua profiler that works with LuaJIT and prints a pretty report file in columns.
--[[
ProFi v1.3, by Luke Perkin 2012. MIT Licence http://www.opensource.org/licenses/mit-license.php.
Example:
ProFi = require 'ProFi'
ProFi:start()
some_function()
another_function()
coroutine.resume( some_coroutine )
ProFi:stop()
@atdt
atdt / term_colors.py
Created October 20, 2015 20:24 — forked from christian-oudard/term_colors.py
Terminal output colors in python
from __future__ import print_function
"""
Utilities for 256 color support in terminals.
Adapted from:
http://stackoverflow.com/questions/1403353/256-color-terminal-library-for-ruby
The color palette is indexed as follows:
0-15: System colors
# This one doesn't work
#
#
# 2015/10/13 18:23:41 [I] Ldap User Info: (*login.ldapUserInfo)(0xc2080470a0)({
# DN: (string) (len=37) "uid=ori,ou=people,dc=wikimedia,dc=org",
# FirstName: (string) "",
# LastName: (string) (len=10) "Ori.livneh",
# Username: (string) (len=10) "Ori.livneh",
# Email: (string) (len=20) "ori.livneh@gmail.com",
# MemberOf: ([]string) {