Skip to content

Instantly share code, notes, and snippets.

Ewoud Kohl van Wijngaarden ekohl

Block or report user

Report or block ekohl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View fragment.pp
define foreman::config::passenger::fragment(
$content='',
$ssl_content='',
) {
require foreman::config::passenger
file { "${apache::mod_dir}/05-foreman.d/${name}.conf":
ensure => present,
content => $content,
owner => 'root',
@ekohl
ekohl / pullify.sh
Created Sep 5, 2014
pullify as taken from some other gist.
View pullify.sh
pullify() {
REMOTES=$(
echo '+refs/pull/*/head:refs/remotes/origin/pr/*' ;
git config --get-all remote.origin.fetch | grep -v 'refs/remotes/origin/pr/\*$'
)
git config --unset-all remote.origin.fetch
echo "$REMOTES" | while read LINE ; do
git config --add remote.origin.fetch "$LINE"
done
}
View celery.service.erb
[Unit]
Description=Celery workers
After=network.target
[Service]
User=<%= @user %>
Group=<%= @user %>
WorkingDirectory=<%= @homedir %>
ExecStart=<%= @homedir %>/virtualenv/bin/sentry celery worker -B
@ekohl
ekohl / unique.py
Created Dec 3, 2009
Retrieves all unique values of a specific LDAP attribute
View unique.py
from ldap import initialize, SCOPE_SUBTREE
from operator import add
config = {'host': 'ldap://HOST', 'base': 'dc=example,dc=com', 'attr': 'l'}
result = initialize(config['host']).search_s(config['base'], SCOPE_SUBTREE, '(%s=*)' % config['attr'], [ config['attr'] ] )
data = reduce(add, [ entry[config['attr']] for (dn, entry) in result ])
print "\n".join(sorted(set(map(str.lower, data))))
@ekohl
ekohl / higherorder.py
Created Jan 21, 2010
Simple demonstration of higher order functions in python
View higherorder.py
#!/usr/bin/python
from operator import add
lijst = range(50)
print "lijst:", lijst
f = lambda x: x * 2
print "map:", map(f, lijst)
g = lambda x: x % 2 == 0
@ekohl
ekohl / problem6.py
Created Jan 24, 2010
Euler problem 6
View problem6.py
#!/usr/bin/python
"""
The sum of the squares of the first ten natural numbers is,
1^2 + 2^2 + ... + 10^2 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)^2 = 55^2 = 3025
Hence the difference between the sum of the squares of the first ten natural
numbers and the square of the sum is 3025 - 385 = 2640.
View fqdn2path.py
#!/usr/bin/env python
import sys
if len(sys.argv) != 2:
print "Usage: %s fqdn" % sys.argv[0]
sys.exit(1)
fqdn = sys.argv[1]
split = fqdn.split(".")
domain = ".".join(split[-2:])
View webtester.py
#!/usr/bin/env python
import urllib2
import sys
for site in sys.argv[1:]:
try:
s = urllib2.urlopen(site)
print s.url, s.code, s.msg, s.headers.get('X-Server', None)
except urllib2.HTTPError, e:
print >> sys.stderr, e.url
View dynzoom.py
#!/usr/bin/env python
# dynzoom.py - dynamic zooming for uzbl, based on dynzoom.js
# Usage:
# @on_event GEOMETRY_CHANGED spawn /path/to/dynzoom.py \@geometry 1024 768
# Where 1024x768 is the resolution where we start to zoom out
import sys, re
" Parses WxH+X+Y into a 4-tuple of ints "
View dictreader.py
#!/usr/bin/env python
import csv
import sys
import random
# For each argument to the program
for arg in sys.argv[1:]:
# Store all the data
rows = list(csv.DictReader(open(arg)))
trackers = list(set(row['Tracker'] for row in rows))
You can’t perform that action at this time.