Skip to content

Instantly share code, notes, and snippets.

View atdt's full-sized avatar
💭
I may be slow to respond.

Ori Livneh atdt

💭
I may be slow to respond.
  • Google
  • New York City
View GitHub Profile
@atdt
atdt / apcu_vs_opcache.php
Last active December 13, 2019 20:30
loading i10n messages from opcache vs apc
<?php
// apcu vs. opcache benchmark
// loads mediawiki en messages from cache 1000 times
// you need languages/i18n/en.json in the same directory as this script.
//
// ini settings you need:
// zend_extension=opcache.so
// opcache.enable=1
// opcache.enable_cli=1
// extension=apcu.so
@atdt
atdt / package.json
Last active August 7, 2019 15:01
for code next
{
"name": "furry-garbanzo ",
"description": "blah blah blah",
"author": "atdt@google.com",
"version": "0.0.1",
"devDependencies": {
"jshint":"^2.10.0"
},
"scripts": {
"test": "jshint **/*.js"
@atdt
atdt / human_duration.py
Created May 19, 2019 17:08
Human-readable duration
def human_duration(seconds):
if seconds <= 1:
return '0 seconds'
units = (
('day', 86400),
('hour', 3600),
('minute', 60),
('second', 1),
)
parts = []
@atdt
atdt / coupon-codes.txt
Created February 22, 2019 22:09 — forked from ethagnawl/coupon-codes.txt
Top 100 Ecommerce Coupon Codes
# source: https://www.slideshare.net/CouponFollow/top-100-most-common-coupon-code-phrases
fall
twitter
black
MEMORIAL
TWEET20
FREESHIP
earlybird
MONDAY
holidays
@atdt
atdt / x.sh
Created October 1, 2018 15:16 — forked from d630/x.sh
bash: any idea how to use the readline function 'history-and-alias-expand-line' in a recursive way?!
#!/usr/bin/env bash
# Method 1
bind -x '"\C-x4": history_and_alias_expand_line';
bind '"\C-x3": history-and-alias-expand-line';
bind -x '"\C-x2": READLINE_LINE_OLD="$READLINE_LINE"';
bind '"\C-x1": "\C-x2\C-x3\C-x4\C-x5"';
function history_and_alias_expand_line {
@atdt
atdt / links.md
Last active January 12, 2020 00:32 — forked from eloquence/gist:8750334
Getting involved in Wikimedia as a Technical Contributor
@atdt
atdt / make-client-cert.sh
Last active October 16, 2016 03:22
ZNC on Jessie
openssl req -nodes -newkey rsa:4096 -keyout atdt.pem -x509 -days 3650 -out atdt.pem -subj "/CN=atdt"
openssl x509 -sha1 -noout -fingerprint -in atdt.pem | sed -e 's/^.*=//;s/://g;y/ABCDEF/abcdef/'
@atdt
atdt / diffbranches
Created September 12, 2016 19:33
Diff JavaScript (or any other type of file) across two production branches
#!/usr/bin/env bash
file_pattern='*.js' # Which files to consider
v1="php-1.28.0-wmf.18" # Base branch
v2="php-1.28.0-wmf.17" # Target branch
while IFS= read -r a; do
b="${a/$v1/$v2}"
diff -u "$a" "$b" # Change '-u' to '-q' if you only want
# to list which files have changed.
done < <(find "/srv/mediawiki/${v1}" -name "$file_pattern")
#!/usr/bin/env bash
# Crude script to detect Backdoor.OSX.Mokes.a, as described in
# https://securelist.com/blog/research/75990/the-missing-piece-sophisticated-os-x-backdoor-discovered/
locations=(
"$HOME/Library/App Store/storeuserd"
"$HOME/Library/com.apple.spotlight/SpotlightHelper"
"$HOME/Library/Dock/com.apple.dock.cache"
"$HOME/Library/Skype/SkypeHelper"
"$HOME/Library/Dropbox/DropboxCache"
"$HOME/Library/Google/Chrome/nacld"
@atdt
atdt / takeover.py
Last active December 3, 2022 17:53
Zero-downtime restarts via interprocess descriptor transfer
#!/usr/bin/env python3
# -*- coding: utf8 -*-
"""
takeover.py
~~~~~~~~~~~
This script demonstrates a technique for zero-downtime restarts via
interprocess descriptor transfer.
The script operates a simple echo service on port 9999. When a new instance
is launched, the old instance will transfer the server socket to the new