Skip to content

Instantly share code, notes, and snippets.

View draptik's full-sized avatar

Patrick Drechsler draptik

View GitHub Profile
#!/bin/bash
docker run \
--rm \
-it \
-e LOCAL_USER_ID=`id -u $USER` \
-p 4001:4001 \
-v ${PWD}/share/octopress:/octopress \
-v ${PWD}/post-install.sh:/home/user/post-install.sh \
draptik/octopress:0.2 \
#!/bin/bash
gem install bundler execjs
cd /octopress
# Important: use `--path...`!
bundle install --path $HOME/.gem
@draptik
draptik / CustomerController.cs
Created November 8, 2016 19:40 — forked from vkhorikov/CustomerController.cs
Handling failures and input errors in a functional way
[HttpPost]
public HttpResponseMessage CreateCustomer(string name, string billingInfo)
{
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo);
Result<CustomerName> customerNameResult = CustomerName.Create(name);
return Result.Combine(billingInfoResult, customerNameResult)
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value))
.OnSuccess(() => new Customer(customerNameResult.Value))
.OnSuccess(
@draptik
draptik / JS-LINQ.js
Created July 18, 2016 17:08 — forked from DanDiplo/JS-LINQ.js
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
{ name: "Judy", age: 42 },
{ name: "Tim", age: 8 }
@draptik
draptik / javascript-nested-groupby-with-aggregation
Last active June 25, 2016 23:00
multi-level nesting (aka groupby) in javascript using d3.js (adapted from http://learnjsdata.com/group_data.html)
var expect = require('chai').expect;
var d3 = require('d3');
describe('app', function () {
var myData = [
{ countryCode: 'DE', areaName: 'DE1', speciesName: 's1', totalScore: 1000 },
{ countryCode: 'DE', areaName: 'DE1', speciesName: 's2', totalScore: 2000 },
{ countryCode: 'DE', areaName: 'DE1', speciesName: 's3', totalScore: 3000 },
{ countryCode: 'DE', areaName: 'DE2', speciesName: 's1', totalScore: 1000 },
@draptik
draptik / monitor-temperatures.py
Last active September 14, 2017 09:46
Python script for monitoring temperatures sent from ciseco sensors and weather underground.
#!/usr/bin/env python
import sqlite3
import threading
from time import time, sleep, gmtime, strftime
import serial
import requests
# global variales
@draptik
draptik / gist:614fe988c929525b25d5
Created May 22, 2015 09:35
Git alias settings in gitconfig
alias.ec=config --global -e
alias.up=pull --rebase
alias.co=checkout
alias.cob=checkout -b
alias.ls=log --pretty=format:'%C(yellow)%h%Creset%C(bold red)%d %Creset%s%Cgreen [%cn] %C(bold green)(%cr)%Creset' --decorate
alias.ll=log --graph --pretty=format:'%Cred%h%Creset -%C(bold yellow)%d%Creset %s %Cgreen(%cr) %C(dim green)<%an>%Creset' --abbrev-commit --
date=relative
alias.f=!git ls-files | grep -i
alias.grep=grep -Ii
alias.m=merge
crontab -e
*/5 * * * * /usr/bin/sudo -H /home/pi/my-scripts/checkwifi.sh >> /dev/null 2>&1

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@draptik
draptik / chocolatey-sample-dev-tools.txt
Created September 25, 2014 21:45
Chocolatey packages for developers001 (browsers, git, keepass, truecrypt)
C:\>choco install GoogleChrome Firefox fiddler git TortoiseGit Emacs 7zip keepass truecrypt