Skip to content

Instantly share code, notes, and snippets.

Example output, where | is the cursor:

function () {
  |
};
foo(function () {
@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}`;
[alias]
wip = !"git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m \"wip\""
unwip = !"git log -n 1 | grep -q -c wip && git reset HEAD~1"
rb = !"git wip;git rebase -i origin/master;git unwip"
pr = !"git fetch;git wip;git rebase --stat origin;git unwip;git heads"
head = !"git log -n1"
lost = !"git fsck | awk '/dangling commit/ {print $3}' | git show --format='SHA1: %C(yellow)%h%Creset %f' --stdin | awk '/SHA1/ {sub(\"SHA1: \", \"\"); print}'"
heads = !"git log origin/master.. --format='%Cred%h%Creset;%C(yellow)%an%Creset;%H;%Cblue%f%Creset' | git name-rev --stdin --always --name-only | column -t -s';'"
@alx
alx / git.rb
Created December 6, 2010 14:24
Jekyll plugin to add Git activity inside a list
require 'git'
module Jekyll
class GitActivityTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
end
def render(context)
@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
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell
@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
@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.

@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
@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