Skip to content

Instantly share code, notes, and snippets.

View thomd's full-sized avatar

Thomas Dürr thomd

  • Hamburg, Germany
View GitHub Profile
@thomd
thomd / reduce.js
Created March 10, 2016 13:34
Array.prototype.reducePolyfill()
import expect from 'expect'
let items = [{price: 19.9}, {price: 59}, {price: 120}, {price: 29.9}]
// the reducer
const add = function add(sum, item) {
return sum + item.price
}
expect(items.reduce(add, 0)).toEqual(228.8)
@thomd
thomd / module_hook.rb
Created February 5, 2016 11:56
module hooks in ruby
module Module1
def self.method1
puts "method1 called"
end
end
class Test
def self.method_missing(name, *args)
if Module1.respond_to?(name)
return Module1.__send__(name, *args)
@thomd
thomd / monit
Created February 5, 2016 11:10 — forked from gaishimo/monit
#!/bin/sh
# move this file to /etc/init.d/monit
### BEGIN INIT INFO
# Provides: monit
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Should-Start: $all
# Should-Stop: $all
@thomd
thomd / pricebook-multi-currency-transform.js
Last active February 5, 2016 11:02
transform demandware pricebooks to other currencies for testing multi-currency sites
var request = require("request")
var replaceStream = require('replacestream')
var fs = require('fs')
var path = require('path')
var originCurrency = "EUR"
var originFile = "eu-prices.xml"
var targetCurrency = "NOK"
var rate = 1
@thomd
thomd / streaming-server.js
Last active June 1, 2016 13:15
a streaming node server
var http = require('http');
http.createServer(function (request, response) {
response.setHeader('Content-Type', 'text/html; charset=UTF-8');
//response.setHeader('Transfer-Encoding', 'chunked');
var html =
'<!DOCTYPE html>' +
'<html lang="en">' +
'<head>' +
@thomd
thomd / create-dot-project-files.sh
Created December 18, 2015 16:08
create .project files for eclipse
#!/usr/bin/env bash
for folder in $(find * -maxdepth 0 -type d)
do
cat <<EOF > $folder/.project
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>$folder</name>
<comment></comment>
<projects>
@thomd
thomd / post-commit
Created November 3, 2015 19:39
post commit hook for TODOs
#!/bin/bash
set -e
# source: http://jezenthomas.com/using-git-to-manage-todos/
main() {
while IFS= read -r todo; do
printf "%s\n" "$(file_path):$(line_number) $(line_author) $(message)"
done < <(todo_list)
}
@thomd
thomd / rwd-pattern.md
Created September 29, 2015 19:09
Examples of Responsive Layout Pattern
@thomd
thomd / apis.md
Last active August 29, 2024 10:38
A list of public APIs (REST, GraphQL) #list #api #rest #graphql
@thomd
thomd / markdown.css
Last active August 29, 2015 14:24 — forked from imjasonh/markdown.css
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}