Skip to content

Instantly share code, notes, and snippets.

@aGHz
aGHz / catee.sh
Created January 21, 2022 20:12
cat + tee = catee
#!/usr/bin/env bash
if [ -t 0 ]; then
cat "$@";
else
tee "$@" <&0
fi
@aGHz
aGHz / google-sheets-dataclip-autoupdate.md
Last active October 6, 2021 18:24
Auto-updating importData of Heroku Dataclips in Google Sheets

Dataclips URLs

Dataclips has a reliable way to construct the URL of a clip's CSV version:

https://dataclips.heroku.com/<hash>-<description>.csv

Thankfully the description is irrelevant, so we can just get the hash from the web interface (looks like aujqawhjdmlbbwrqxutcpzzqyika) and add -1 at the end. Every time we change the

@aGHz
aGHz / syntree.py
Created November 28, 2020 16:42
Parse vim syntax scripts
import json
import pprint
import re
import sys
TOK = re.compile(r'\s+')
SYN_ARGS = [
'conceal', 'concealends',

JavaScript Static Analysis Tools

Most people are familiar with these three tools:

  1. [JSHint][1]
  2. [JSLint][2]
  3. [Google Closure Linter][3]

The first one is more popular among developers because it is style-agnostic. The other two enforce rules of [Crockford Style][4] and [Google Code Style][5] respectively.

@aGHz
aGHz / kronolog.txt
Last active April 27, 2016 21:25
Kronolog syntax
+ generic item, sub-tasks track progress
- open task
~ in progress task
= completed task
* informational item, sub-tasks do not track progress
- generic sub-item (not necessarily task)
x n/a, wontfix, cancelled
/ n/a, wontfix, cancelled
> command
from bs4 import BeautifulSoup
import functools
import inspect
class Field(object):
def __init__(self, selector=None):
self._value = None
self.selector = selector
def _get_element(self, selector=None):
@aGHz
aGHz / gist:6024190
Created July 17, 2013 20:32
Dat frequency
A = new webkitAudioContext();
vol = A.createGainNode(); vol.gain.value = 0.3; vol.connect(A.destination);
osc1 = A.createOscillator(); osc1.frequency.value = 40; osc1.noteOn(0); osc1.connect(vol);
osc2 = A.createOscillator(); osc2.frequency.value = 75; osc2.noteOn(0); osc2.connect(vol);
@aGHz
aGHz / gist:5781787
Last active December 18, 2015 12:19
A and Z are collections of closed segments defined by their 1-d endpoints.
Each is sorted according to the start position of the segment.
Place these segments on a line according to the following constraints:
- segments from Z must absolutely retain their position.
- if a segment from A starts before a segment from Z but overlaps with it,
split it in two. The part before the segment in Z retains its position, and
the second part comes after the segment from Z. This can happen multiple
times as needed.
- if a segment from A overlaps with a segment from Z but doesn't start
before, simply move it after the segment from Z.
table.prod-specs {
font-size: 12px;
width: 100%;
margin-bottom: 25px;
}
table.prod-specs thead {
border-bottom: 1px solid #000;
}
@aGHz
aGHz / python_repr.md
Created October 30, 2012 14:48
Strange behaviour with repr() and __repr__ in Python

The Python builtin repr() doesn't seem to take into account the object's __repr__

class Foo(object):
    __repr__ = lambda self: "class"

    def __init__(self, a):
        self.__repr__ = lambda: "object"

foo = Foo('object')

print foo # "class"