Skip to content

Instantly share code, notes, and snippets.

View julianwachholz's full-sized avatar
🤓

Julian Wachholz julianwachholz

🤓
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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

Keybase proof

I hereby claim:

  • I am julianwachholz on github.
  • I am juio (https://keybase.io/juio) on keybase.
  • I have a public key ASAKlzM8becIo_ddeoySGXGSqjylxrL8hzSeC4emuFU_Vgo

To claim this, I am signing this object:

@julianwachholz
julianwachholz / form.html.eex
Created July 13, 2018 06:37
Phoenix & Ecto Many-to-Many m2m Relation
<%= form_for @changeset, @action, [multipart: true], fn f -> %>
<!-- ... other fields ... -->
<!-- `selected` accepts only a list of IDs -->
<div class="form-group">
<%= label f, :categories, class: "control-label" %>
<%= multiple_select f, :categories, @categories, selected: Enum.map(@changeset.data.categories, &(&1.id)), class: "form-control" %>
</div>
@julianwachholz
julianwachholz / base.ts
Last active July 30, 2019 14:51
typescript constructor properties
export abstract class BaseStore<T> {
@observable
objects: T[] = [];
constructor(private dao: BaseDAO<T>) {}
}
const MyForm: React.FC<any> = observer(({match, store}) => {
const obj = store.get(match.params.id);
if (obj === null) {
return <MyLoadingForm />;
}
// Invariant violation: Rendered more hooks than during the previous render.
const [data, setData] = useState(obj.data);
return <MyLoadedForm data={data} onSubmit={setData} />
});