Skip to content

Instantly share code, notes, and snippets.

@ninowalker
ninowalker / README.md
Last active March 24, 2023 23:45
Import search engine definitions by CLI
@ninowalker
ninowalker / README.md
Last active March 24, 2023 23:42 — forked from pmkay/top-brew-packages.txt
Top homebrew packages

Installation

Brew

curl -s https://gist.githubusercontent.com/ninowalker/aea5964256e2212a807c6d9e5e12051a/raw/top-brew-packages.txt \
  | perl -ne 'print "$1 " if m%^(\w+):%' | xargs -n 5 brew install

BASH

function __rc_include {

local program; program=$1; shift

#!/bin/bash
# LICENSE: MIT
# Check if the required arguments are provided
if [ $# -ne 2 ]; then
echo "Usage: $0 <input_audio_file:path> <minimum_length_of_silence:float>"
exit 1
fi
@ninowalker
ninowalker / mstatsd.py
Created December 20, 2014 19:38
Mock Statsd
# Based on
# http://stackoverflow.com/questions/15734219/simple-python-udp-server-trouble-receiving-packets-from-clients-other-than-loca
import socket
UDP_IP = ""
UDP_PORT = 8125
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
(env)kevlar-1785 ~/dev/perseids $ make test_api
source env/bin/activate; /Users/nino/dev/perseids/env/bin/apirunner --log=INFO --ts=src/test/rester/suite.yaml
############################ FAILED ############################
src/test/rester/ping.yaml : ping http
0.
Assert Statement : "text/plain; charset=UTF-8 == text/plain; charset=utf-8" ---> Fail!
-------- LOG OUTPUT --------
@ninowalker
ninowalker / gist:8292135
Created January 6, 2014 23:45
Load/invert the DB from http://urlblacklist.com
import glob
import collections
import re
def load(root="./"):
h = {}
for f in glob.glob(root + "*/domains"):
d = f.replace(root, "").replace("/domains", "")
h[d] = set()
with open(f) as _f:
This is a test
@ninowalker
ninowalker / gist:1482729
Created December 15, 2011 20:28
Convert HTML entities to unicode
import htmlentitydefs
import re
def unescape_entities(m):
return unichr(htmlentitydefs.name2codepoint[m.group(1)])
print re.sub(r'&(\w+);', unescape_entities, "&times;&nbsp;&trade;Foo&bar")
@ninowalker
ninowalker / server.py
Created December 10, 2011 02:02
A simple web server in two (three) steps
#
# Source: http://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python
#
# Simple server in two steps:
# - create an index.html file.
# - run:
# python server.py [<port>]
# - go to:
@ninowalker
ninowalker / gist:106fb133295867a60971
Last active August 29, 2015 14:13
Celery + Redis trickle backlog
function trickle_backlog() {
queue=$1
backlog=$2
max_depth=$3
host=$4
db=$5
while [ $(redis-cli -h $host -n $db llen $backlog) -gt 0 ]; do
while [ $(redis-cli -h $host -n $db llen $queue) -gt $max_depth ]; do
echo "snoozing..."
sleep 1