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 / strpos_multi.php
Last active August 29, 2015 14:22
An implementation of the Aho-Corasick string matching algorithm for PHP.
<?php
/**
* An implementation of the Aho-Corasick string matching algorithm for PHP.
*
* Alfred V. Aho and Margaret J. Corasick, "Efficient string matching: an aid to
* bibliographic search", CACM, 18(6):333-340, June 1975.
*
* <http://xlinux.nist.gov/dads//HTML/ahoCorasick.html>
*
* Copyright (C) 2015 Ori Livneh <ori@wikimedia.org>
@atdt
atdt / aho_corasick.py
Last active April 12, 2024 19:29
Aho-Corasick string matching in Python
# Python implementation of Aho-Corasick string matching
#
# Alfred V. Aho and Margaret J. Corasick, "Efficient string matching: an aid to
# bibliographic search", CACM, 18(6):333-340, June 1975.
#
# <http://xlinux.nist.gov/dads//HTML/ahoCorasick.html>
#
# Copyright (C) 2015 Ori Livneh <ori@wikimedia.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
@atdt
atdt / vsl.py
Created May 23, 2015 01:04
Basic Python bindings for the Varnish log API
# -*- coding: utf-8 -*-
"""
vsl.py
~~~~~~
Basic Python bindings for the Varnish log API
Copyright 2015 Ori Livneh <ori@wikimedia.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@atdt
atdt / check-jemalloc
Last active November 5, 2019 09:53
Memory leak isolation with HHVM
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Check that jemalloc was built with `--enable-prof`.
from ctypes import CDLL, byref, c_bool, c_size_t, sizeof
from ctypes.util import find_library
p = c_bool()
jemalloc = CDLL(find_library('jemalloc'))
jemalloc.mallctl(b'config.prof', byref(p), byref(c_size_t(1)), None, None)
print('jemalloc %s built with `--enable-prof`.' % ('was' if p.value else 'was not'))
@atdt
atdt / setfsuid.py
Last active April 13, 2025 15:25
Python wrapper for setfsuid
# Copyright (c) 2019 Ori Livneh
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# -*- coding: utf-8 -*-
import rrdtool
# We're going to keep a full set of metrics for each of these.
PLATFORMS = ('mobile', 'desktop')
# TODO: Document.
METRICS = (
'backend',
@atdt
atdt / check_svg_gzip.py
Last active August 29, 2015 14:18
Check SVG gzip compression on Wikimedia varnishes
# -*- coding: utf-8 -*-
""" Check SVG gzip compression on Wikimedia varnishes """
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import StringIO
import gzip
import time
import urllib2
@atdt
atdt / perf-test.sh
Created March 24, 2015 13:10
VE benchmark for Q3
#!/usr/bin/env bash
set +m
cd /srv/mediawiki-local/extensions/VisualEditor
die() { echo "$@" 1>&2 ; exit 1; }
do_test() {
/usr/lib/chromium-browser/chromium-browser \
--incognito \
--remote-debugging-port=9222 \
@atdt
atdt / watch_startup.py
Created March 14, 2015 00:41
Watch the startup module for changes.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Watch the startup module for changes.
import json
import re
import time
import urllib2
URL = ('https://bits.wikimedia.org/en.wikipedia.org/load.php?debug=false&'

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: