Skip to content

Instantly share code, notes, and snippets.

View julianwachholz's full-sized avatar
🤓

Julian Wachholz julianwachholz

🤓
View GitHub Profile
@julianwachholz
julianwachholz / init.vim
Last active October 17, 2017 14:07
NeoVIM configuration (wip)
" NeoVIM Configuration
" Map the leader key to SPACE
let mapleader="\<SPACE>"
nnoremap <SPACE> <nop>
" Set options {{{
set title " Set window title to file
set showcmd " Show (partial) command in status line
set showmatch " Show matching brackets
@julianwachholz
julianwachholz / millionenlos.py
Last active December 5, 2016 18:24
Check if you have won with your "Millionenlos"!
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals, print_function
"""
Usage: python millionenlos.py <symbols.txt>
Shows today's winning symbols from Millionenlos.ch;
Or shows your winnings when given a file
containing winning symbols for each day.
@julianwachholz
julianwachholz / python34.rb
Last active November 2, 2015 10:14
Python 3.4 Brew Formula
class Python34 < Formula
desc "Interpreted, interactive, object-oriented programming language"
homepage "https://www.python.org/"
url "https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz"
sha256 "b5b3963533768d5fc325a4d7a6bd6f666726002d696f1d399ec06b043ea996b8"
revision 2
bottle do
revision 1
sha256 "58ae656ea0e46d63d7bd13bc4662032e0f27f614e003f3b06314f3688fcb0685" => :el_capitan
@julianwachholz
julianwachholz / megagon.js
Created July 8, 2015 09:16
Generates a Megagon SVG
#!/usr/bin/env node
'use strict';
var size = 10000;
var sides = 1000000;
var padding = 50;
var path = polygon(size / 2 + padding, size / 2 + padding, size / 2, sides)
.map(function (p) { return p.x + ',' + p.y; })
.join(' ');
@julianwachholz
julianwachholz / views.py
Created May 4, 2015 11:10
Python/Django written by a PHP developer
def tadastaffregister(request):
if request.method == "POST":
start_date = request.POST['start_date']
end_date = request.POST['end_date']
result = []
date = 0
staff_member = []
staff = []
list_item = []
total = 0
@julianwachholz
julianwachholz / migration.py
Last active August 29, 2015 14:17
Django migration from `time without time zone` to `timestamp with time zone`
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('offers', '0001_initial'),
@julianwachholz
julianwachholz / inputhistory.js
Last active August 28, 2020 10:04
JavaScript <input> history with arrow buttons, a.k.a. poor man's readline
/**
* License: WTFPL - http://www.wtfpl.net/
*
* Usage: element.addEventListener('keydown', inputHistory());
*/
function inputHistory(max_history) {
var PREV = 38, NEXT = 40, ENTER = 13,
history = [''], current = 0;
if (!max_history) {
@julianwachholz
julianwachholz / int2bytes.coffee
Created January 29, 2015 14:56
Ever needed to convert integers to bytes and back in javascript?
INT_BYTES = 8 # but note that javascript only does 2^53
int2bytes = (x) ->
if x > Number.MAX_SAFE_INTEGER
throw new Error "Number is larger than Number.MAX_SAFE_INTEGER (2⁵³-1)!"
bytes = []
i = INT_BYTES
loop
bytes[--i] = x & 0xff
jwa ~> dig A ju.io
; <<>> DiG 9.8.3-P1 <<>> A ju.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39104
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;ju.io. IN A
@julianwachholz
julianwachholz / chroot.sh
Created December 12, 2014 10:42
Autoinstall ArchLinux on a existing OS
#!/bin/sh -e
ARCH_VERSION="2014.12.01"
ARCH_FILE="archlinux-bootstrap-$ARCH_VERSION-x86_64.tar.gz"
ARCH_BOOTSTRAP="http://archlinux.mirrors.ovh.net/archlinux/iso/$ARCH_VERSION/$ARCH_FILE"
ARCH_SUMS="http://archlinux.mirrors.ovh.net/archlinux/iso/$ARCH_VERSION/sha1sums.txt"
# download bootstrap image
cd /tmp
wget $ARCH_BOOTSTRAP