Skip to content

Instantly share code, notes, and snippets.

Always shipping.

Dan Loewenherz dlo

Always shipping.
View GitHub Profile
View handle.ts
Typescript erroring:
Type 'Promise<(T | undefined)[] | [any, undefined]>' is not assignable to type 'Promise<[void | Error, void | T]>'.
Type '(T | undefined)[] | [any, undefined]' is not assignable to type '[void | Error, void | T]'.
Type '(T | undefined)[]' is not assignable to type '[void | Error, void | T]'.
Target requires 2 element(s) but source may have fewer.ts(2322)
export default function <T> (promise: Promise<T>): Promise<[Error | void, T | void]> {
dlo / .gitignore
Created Feb 9, 2011
Using filesystem events and git to version my Notational Velocity notes
View .gitignore
Interim Note-Changes
dlo /
Last active Aug 26, 2020
How to adjust a view's height with Auto Layout when a keyboard appears or disappears in iOS 7.

This gist outlines how to resize a view when a keyboard appears using Auto Layout (there are a bunch of code samples out there that manually adjust the view's frame, but that's just so 2013). The method I outline below works universally on both iPhone and iPad, portrait and landscape, and is pretty darn simple.

Setting Up

The first thing to do is to define our containing view controller, the view, and the bottom constraint that we'll use to adjust its size.

Here's HeightAdjustingViewController.h. We don't need to expose any public properties, so it's pretty bare.

dlo /
Created Dec 25, 2009
surround.vim reference


Text              Command    New Text
---------------   -------    -----------
'Hello W|orld'    ds'        Hello World
(12|3+4*56)/2     ds(        123+4*56/2
<div>fo|o</div>   dst        foo
dlo /
Last active Feb 27, 2020
Download all your Foursquare checkins with Python.
# pip install requests
import requests
import json
url_template = '{}&v=20131026&offset={}'
# If you navigate to, Foursquare
# will generate an OAuth token for you automatically. Cut and paste that token
# below.
token = ""
dlo /
Created Nov 1, 2017
Automatically generate a Content.json file for an iOS icon set from a list of iOS icons in a folder.
#!/usr/bin/env python
# Usage: ls *.png | ./
import sys
import re
import json
r = re.compile(".*(AppStore|iPhone|iPad).*-([\d\.]+)(@\dx)?\.png")
Copyright (C) Daniel Loewenherz, 2009. All Rights Reserved.
from django.contrib import admin
from linonia.lin.models import *
class PhotoAdmin(admin.ModelAdmin):
list_display = ['hash', 'album']
dlo /
Last active Sep 5, 2019 — forked from ttscoff/allpinboard.rb
Python version of that pulls all bookmarks on the first sync, and does incremental updates afterwards. Also uses the Mac OS X keychain to retrieve your password so it doesn't need to live in a file on your computer in plain text.
#!/usr/bin/env python
This script is designed to generate a simple html file with _all_ of your bookmarks The HTML file can be added to Launchbar's index as a
custom bookmark file and you can search your entire collection
instantly from Launchbar (by title only). It includes any applied tags as part
of the title to aid in searching.
You should edit the `username`, `bookmark_filename`, and `local_timezone`
View gist:f41d3a579d7603814d904362d643766e
Verifying my Blockstack ID is secured with the address 1NBmXpzWD5qHQNR7gB7Weod1d7FhFBXeuV
#!/usr/bin/env python
import json
import datetime
def date_from_row(row):
year = row['year']
month = row['month']
day = row['day']
hour = row['hour']
You can’t perform that action at this time.