Skip to content

Instantly share code, notes, and snippets.

Brain fog coping strategies
Intro: Playfulness and experimentation will help you find strategies that work for you.
Memory
Navigating your memory landscape (vs constructing memory palaces)
The problem with mnemonics
Mnemonic techniques (such as memory palaces) are powerful, but ...
Mnemonics only help when you know ahead of time exactly what you want to remember _and_ when writing it down is not sufficient _and_ when you have the time and energy to do the encoding
Very few cases meet this criteria
Memorizing foreign language vocabulary
Memorizing material for an exam
@danallison
danallison / datetime_cycles.py
Created June 4, 2018 00:11
Get the cyclic properties of a datetime, represented as points on the unit circle.
from datetime import datetime
from math import sin, cos, pi
days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def sin_cos(n):
theta = 2 * pi * n
return (sin(theta), cos(theta))
def get_cycles(d):
@danallison
danallison / cc2ld.py
Created May 16, 2018 21:28
A Python dictionary of second-level domains, keyed by country code. Useful when parsing URLs.
# https://en.wikipedia.org/wiki/Second-level_domain
# https://www.quackit.com/domain-names/country_domain_extensions.cfm
from collections import defaultdict
second_level_domains_by_country_code = defaultdict(set)
d = second_level_domains_by_country_code
# Afghanistan
d['af'] = set((
'com',
'edu',
@danallison
danallison / with_sql_session.py
Last active August 29, 2024 10:08
Connect to Postgresql locally or through SSH tunnel
from sshtunnel import SSHTunnelForwarder
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from functools import wraps
# secrets.py contains credentials, etc.
import secrets
def get_engine_for_port(port):
return create_engine('postgresql://{user}:{password}@{host}:{port}/{db}'.format(
import requests
import datetime
auth_token = '** replace this with your auth token **'
def get_time_entries_for_project(project_id, date_range=None):
'''
Fetches time entries from the API, including suggestions and phases
'''
base_url = 'https://api.10000ft.com'
@danallison
danallison / 10kft_api_example.get_users_currently_assigned_to_a_project.ipynb
Last active July 21, 2017 19:07
10kft API Example. Get users currently assigned to a project
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am danallison on github.
  • I am danallison (https://keybase.io/danallison) on keybase.
  • I have a public key ASDUznCpicoQz-TtNd0WOBIMNXMAYktgZzXbIRT3TjIJlAo

To claim this, I am signing this object:

@danallison
danallison / flowMap.js
Created January 7, 2016 23:09
Like _.flow, but also accepts arrays of functions.
function flowMap () {
var functions = [].slice.call(arguments); // convert arguments to array
return function () {
var _this = this; // maintain context
return functions.reduce(function (args, fn) {
// for each function or array of functions,
// pass in the previous return value.
if (_.isArray(fn)) {
return [fn.map(function (_fn) { return _fn.apply(_this, args); })];
} else {
@danallison
danallison / downloadString.js
Created September 29, 2014 16:44
download string as text file
function downloadString(text, fileType, fileName) {
var blob = new Blob([text], { type: fileType });
var a = document.createElement('a');
a.download = fileName;
a.href = URL.createObjectURL(blob);
a.dataset.downloadurl = [fileType, a.download, a.href].join(':');
a.style.display = "none";
document.body.appendChild(a);
a.click();
@danallison
danallison / dispatcher.coffee
Last active August 29, 2015 14:05
Bare bones event system
dispatcher = {}
dispatcher._subscribers = {}
dispatcher.on = (eventName, callback, context) ->
(dispatcher._subscribers[eventName] or = [])
.push {
callback: callback
context: context
}