Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/env python
# Aleksandr Pasechnik
# Looks through the Day One journal and finds the latest entry that starts with
# the "Entry Start Text" provided on the command line. The script then asks for
# input, reading lines until it comes to one that contains just a single full
# stop "." . The script asks for confirmation and appends a new line followed
# by the entered text to the end of the entry.
#
# NOTE: the user is responsible for creating new entries as necessary,
# export_dayone_entries.py
# Aleksandr Pasechnik
#
# This script goes through the Day One journal and exports each of the entries
# to a new markdown file in the `exportdir` directory. The `exportdir`
# directory is deleted and recreated each time the script is run, so best set
# it to something temporary (a subdirectory on the Desktop, for example).
# Photos are copied into the export directory too, with the same basename as
# the exported entries. The timestamp, location, weather, and tags are appended
# to the end of the file, if they are available. The script also sticks a '#'

On the OS X bash command line

brew install multimarkdown
brew install fswatch

echo '#!/bin/bash
multimarkdown --full "file.md" > /tmp/file.html && open -g /tmp/file.html' > /tmp/rebuild.sh && chmod +x /tmp/rebuild.sh; fswatch -o "file.md" | xargs -n1 /tmp/rebuild.sh
( (1 or 2 or 3) and (not (4 and (5 or 6 ) ) ) )
{
"operator": "AND",
"subsections": [
{
"operator": "OR",
"entities": [ 1, 2, 3 ]
},
{
#!/usr/bin/env python3
# licence: ¯\_(ツ)_/¯
import requests
s = requests.Session()
d = {
'client_id': 'client_id',
'client_secret': 'client_secret',
@apiarian
apiarian / Golang Channels Cheatsheet.md
Created March 26, 2017 13:11
because sometimes i forget

Golang Channels

  • send blocks forever
  • receive blocks forever
  • send blocks until received
  • receive blocks until sent

Keybase proof

I hereby claim:

  • I am apiarian on github.
  • I am apiarian (https://keybase.io/apiarian) on keybase.
  • I have a public key ASDql2jnKyQKDqepzcSb1x9Rxxw-PGFC0ajwDZsfzZPX3wo

To claim this, I am signing this object:

#!/usr/bin/env python3
# This script reads a journal located at the basedir in the following format:
# YYYY/MM/journal-entry.md (I usually have a YYYY-MM-DD HH-MM-SS Mon.md
# formatted entry name). It deletes the contents of the outputdir and replaces
# them with an HTML representation of the markdown files, complete with handy
# index pages and some keyboard navigation. Requires multimarkdown. Other files
# that might be in the basedir are copied to to the output directory structure
# alongside the generated HTML, so you can include things like images and even
# sounds in the markdown and they should "just work". Adjust as necessary. I
/*
go test -bench Map -run Map -benchmem -benchtime 10s
BenchmarkMapNestedPopulate-4 50000000 493 ns/op 72 B/op 1 allocs/op
BenchmarkMapNestedQuery-4 50000000 336 ns/op 1 B/op 1 allocs/op
BenchmarkMapCompoundPopulate-4 30000000 723 ns/op 209 B/op 0 allocs/op
BenchmarkMapCompoundQuery-4 50000000 387 ns/op 0 B/op 0 allocs/op
*/
func BenchmarkMapNestedPopulate(b *testing.B) {
m := make(map[string]map[int64]int64)