Skip to content

Instantly share code, notes, and snippets.

View stefanlindbohm's full-sized avatar

Stefan Lindbohm stefanlindbohm

View GitHub Profile
@stefanlindbohm
stefanlindbohm / dracula-blink.js
Created August 28, 2018 16:02
Dracula theme for Blink with same colors as official Dracula theme for iTerm
@stefanlindbohm
stefanlindbohm / README.md
Last active June 27, 2018 18:37
Swedish personal identity number validator & formatter

This is some code golfing that got out of hand. Written in a playground and as such uses simplistic test helpers that just return output strings. Copy and paste into Swift Playgrounds on iOS or a playground in XCode to run.

@stefanlindbohm
stefanlindbohm / JSONObject.swift
Last active December 30, 2015 12:06
Extensible JSON interface in Swift enforced by types
//
// JSON.swift
// BonAppetit
//
// Created by Stefan Lindbohm on 17/02/15.
// Copyright (c) 2015 Stefan Lindbohm. All rights reserved.
//
import Foundation
@stefanlindbohm
stefanlindbohm / keybase.md
Last active April 28, 2017 07:38
keybase.md

Keybase proof

I hereby claim:

  • I am stefanlindbohm on github.
  • I am kolizz (https://keybase.io/kolizz) on keybase.
  • I have a public key ASCFO_Vri1lXrvU7n2PO5sb43XiMBciLKmNR-LJwRR1vTQo

To claim this, I am signing this object:

@stefanlindbohm
stefanlindbohm / NamingArguments.swift
Last active August 29, 2015 14:02
Naming arguments in Swift
// Defaults: inconsistent calls
class Default {
init(first: Int, second: Int) { }
func method(first: Int, second: Int) { }
}
func defaultFunction(first: Int, second: Int) { }
let defaultObject = Default(first: 1, second: 1)
@stefanlindbohm
stefanlindbohm / class.js
Last active January 1, 2016 01:19
Simple JavaScript class implementation with inheritance.
// Class implementation with inheritance.
//
// Creates a constructor function with all the properties of ``params`` and
// keeps the ``constructor`` property of the prototype intact.
//
// Chains the object of special ``params`` key ``Extends`` on the prototype
// and prevents multiple calls to initialize in a MooTools Class compatible
// way. Property ``parent`` of the prototype is set to the chained object.
var Class = function(params) {
this.createConstructor();
@stefanlindbohm
stefanlindbohm / example.js
Last active December 21, 2015 23:08
Get components from POST data names in Javascript, similar to how Rails among others parses params.
postParameterNameComponents("postdata[with][dimensions]")
-> ["postdata", "with", "dimensions"]
@stefanlindbohm
stefanlindbohm / typography.less
Created February 12, 2012 03:15
Baseline Less Mixin
.font-size-leading(@font-size, @leading-ratio, @baseline-end-ratio) {
@leading: @baseline*round(@leading-ratio);
@baseline-end-distance: round(@font-size * @baseline-end-ratio + (@leading - @font-size) / 2);
font-size: @font-size;
line-height: @leading;
padding-top: @baseline-end-distance;
padding-bottom: @leading - @baseline-end-distance - (@baseline * (@leading-ratio - 1));
}