Skip to content

Instantly share code, notes, and snippets.

View stefanooldeman's full-sized avatar

Stefano Oldeman stefanooldeman

  • bol.com
  • Netherlands, Utrecht
View GitHub Profile
# treating each 16-bit word as an integer
# devisor = 16
# mod = (2**16-1)
words = [
int('1111111111111111', 2),
int('1111111100000000', 2),
int('1111000011110000', 2),
int('1100000011000000', 2),
]
@stefanooldeman
stefanooldeman / _helpers.tpl
Last active August 2, 2018 09:06
my helm chart template functions
{{/*
imagePullPolicy:
this function will parse the imageTag with semver
imagePullPolicy is determined based of a versions prerelease
example usage:
```
image: {{ .Values.ImageTag }}
{{ include "imagePullPolicy" .Values.ImageTag | indent 8 }}
env: ...
@stefanooldeman
stefanooldeman / fetcher.go
Last active August 29, 2015 14:17
Go interfaces to play with
// this is based on a blog post from @relistan, http://relistan.com/writing-testable-apps-in-go/
package main
import (
"errors"
"fmt"
"strings"
)
@stefanooldeman
stefanooldeman / README.md
Last active August 29, 2015 14:14
Move files from one bucket to the other with style

Archiving script for exising buckets in s3. To use make install s3cmd.

@stefanooldeman
stefanooldeman / install_packages.R
Created November 25, 2014 14:38
Install a list of packages
common_packages <- c('batch','data.table','plyr','sqldf')
## adjust as necessary, see help('download.packages')
repos <- "http://cran.rstudio.com"
## this makes sense on Debian where no packages touch /usr/local
lib.loc <- "/usr/local/lib/R/site-library/"
## install packages
sapply(common_packages, function (pkg) install.packages(pkg, lib.loc, repos))
@stefanooldeman
stefanooldeman / my-file.py
Last active August 29, 2015 14:05
generate partitions (manual patch)
days = range(16,30) # the days of the month=
p = "ALTER TABLE set_videoads_valid ADD IF NOT EXISTS PARTITION (year={year:d}, month={month:d}, day={day:d}, hour={hour:d}) LOCATION 'hdfs://spil-hadoop/datain/set/portal/valid/year={year:04d}/month={month:02d}/day={day:02d}/hour={hour:02d}'; "
print "USE datain; "
for x in days:
for h in range(0,24):
print p.format(year=2014, month=7, day=x, hour=h)
from ConfigParser import ConfigParser
class LoaderConfig(dict):
def __init__(self, config_path, section):
_dyn_kwargs = self.load_config(config_path)
super(LoaderConfig, self).__init__(_dyn_kwargs[section])
self.__dict__ = self
package require http
namespace eval twitter {
variable status_url "http://api.twitter.com/1/statuses/user_timeline/"
bind pub -|- "!twitter" twitter::tweet
}
proc twitter::tweet {nick uhost hand chan argv} {
if {[string length $argv] < 1} {
@stefanooldeman
stefanooldeman / loggers_bootstrap.py
Last active December 15, 2015 09:39
Working example of python's logging module, configured from python dict. have fun.
import logging
import logging.config
console = {
'class': 'logging.StreamHandler',
'formatter': 'console',
'level': 'NOTSET', # log everything!!
}
logfile = {
@stefanooldeman
stefanooldeman / before_epoch.php
Created January 13, 2012 10:50
wip trying to check on negative timestamp support and how to detect it
<?php
//if this php version is greater than 5.1 pass
echo strtotime('1766-06-04') . '<br />';
if (version_compare(PHP_VERSION, '5.1', '>')) {
echo 'we support negative dates';
} else {
echo 'we DON'T support negative dates';
}