Skip to content

Instantly share code, notes, and snippets.

View ihabunek's full-sized avatar

Ivan Habunek ihabunek

View GitHub Profile
@Justkant
Justkant / i18next-scanner.config.js
Created August 16, 2019 11:37
Scan + merge except for defaultLng, with support for removeUnusedKeys option
/* eslint-disable import/no-extraneous-dependencies */
const _ = require('lodash');
const fs = require('fs');
const eol = require('eol');
const path = require('path');
const VirtualFile = require('vinyl');
const flattenObjectKeys = require('i18next-scanner/lib/flatten-object-keys')
.default;
const omitEmptyObject = require('i18next-scanner/lib/omit-empty-object')
.default;
# http://adventofcode.com/2017/day/1
defmodule Day1 do
def sum1(digits), do:
digits
|> Stream.concat(Enum.take(digits, 1))
|> Stream.chunk_every(2, 1, :discard)
|> Stream.filter(&match?([el, el], &1))
|> Stream.map(&hd(&1))
|> Enum.sum()
@Nagyman
Nagyman / workflows-in-django.md
Last active January 27, 2024 08:29
Workflows in Django

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
@senko
senko / singleton.py
Created February 25, 2013 08:01
Singleton Django Model
# Written by Senko Rasic <senko.rasic@goodcode.io>
# Released into Public Domain. Use it as you like.
from django.db import models
class SingletonModel(models.Model):
"""Singleton Django Model
Ensures there's always only one entry in the database, and can fix the
@senko
senko / trigger.py
Created January 9, 2013 09:49
When triggered via a HTTP request, execute a command.
#!/usr/bin/env python
#
# When triggered via a HTTP request, execute a command.
#
# Written by Senko Rasic <senko.rasic@goodcode.io>
# Released into Public Domain. Use it as you like.
#
# Usage: python trigger.py <host> <port> <key> <command>...
#
# HTTP GET and POST requests are supported. If you need more verbs or need
@defunkt
defunkt / zombies.md
Created December 29, 2010 22:57
—All You Zombies— by Robert A. Heinlein

All You Zombies

2217 Time Zone V (EST) 7 Nov. 1970--NTC-- "Pop's Place": I was polishing a brandy snifter when the Unmarried Mother came in. I noted the time---10:17 P. M. zone five, or eastern time, November 7th, 1970. Temporal agents always notice time and date; we must.

The Unmarried Mother was a man twenty--five years old, no taller than I am, childish features and a touchy temper. I didn't like his looks---I never had---but he was a lad I was here to recruit, he was my boy. I gave him my best barkeep's smile.

Maybe I'm too critical. He wasn't swish; his nickname came from what he always said when some nosy type asked him his line: "I'm an unmarried mother." If he felt less than murderous he would add: "at four cents a word. I write confession stories."

If he felt nasty, he would wait for somebody to make something of it. He had a lethal style of infighting, like a female cop---reason I wanted him. Not the only one.