Skip to content

Instantly share code, notes, and snippets.

@catb0t
catb0t / mypy_json.pyi
Last active October 3, 2020 09:37
Strict no-Any MyPy JSON type
# modified from Original source: https://github.com/python/mypy/issues/731#issuecomment-539905783
from typing import Union, Dict, List
JSONPrimitive = Union[str, int, bool, None]
JSONType = Union[JSONPrimitive, 'JSONList', 'JSONDict']
# work around mypy#731: no recursive structural types yet
class JSONList(List[JSONType]):
pass
@ifyoumakeit
ifyoumakeit / templatejs.js
Last active March 19, 2018 17:23
Quick JS templating with string template literals
const resolveExpression = exp => {
const resolved = typeof exp === "function" ? exp() : exp;
return Array.isArray(resolved)
? resolved.join("")
: typeof resolved !== "undefined" ? resolved : "";
};
const html = (strings, ...exps) => {
return strings.reduce((acc, str, i) => {
return `${acc}${resolveExpression(exps[i - 1])}${str}`;
@jaymcgavren
jaymcgavren / desert_golfing_hole_2866.md
Last active September 18, 2022 12:20
How to beat the "impossible" hole 2866 on Desert Golfing

Here's a picture of Desert Golfing Hole 2866, which even the developer believed was impossible at first.

Desert Golfing Hole 2866

And here it is together with a picture of the following hole, 2867.

Desert Golfing Hole 2866 and 2867, stitched together

As you probably know, even though the next hole is off the screen and invisible, you can still bounce the ball off of its landscape features and back into the playfield. You can do a hail-Mary shot from the tee on 2866, aiming for the offscreen hill on the far side of the water hazard (which technically belongs to hole 2867). It will bounce off the hill and straight into the hole.

@orez-
orez- / git-stash-inbox.py
Last active October 2, 2021 16:18
Run through your git stashes, either committing them to branches or deleting them.
#!/usr/bin/env python2.7
import collections
import os
import re
import readline
import subprocess
tty_bold = '\x1b[1m'
tty_af = '\x1b[{}m'.format
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell

Example output, where | is the cursor:

function () {
  |
};
foo(function () {
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active April 23, 2024 19:14
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@joaopizani
joaopizani / .screenrc
Created May 17, 2012 11:55
A killer GNU Screen Config
# the following two lines give a two-line status, with the current window highlighted
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]'
# huge scrollback buffer
defscrollback 5000
# no welcome message
startup_message off
@ziadoz
ziadoz / awesome-php.md
Last active April 17, 2024 21:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@aemkei
aemkei / LICENSE.txt
Last active April 12, 2024 21:27 — forked from 140bytes/LICENSE.txt
Binary Tetris - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE