Skip to content

Instantly share code, notes, and snippets.

View sourcevault's full-sized avatar

sourcevault

View GitHub Profile
@nifl
nifl / grok_vi.mdown
Created August 29, 2011 17:23
Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@briancavalier
briancavalier / promise-monad-proof.js
Created August 8, 2012 15:57
A proof that Promises/A is a Monad
//-------------------------------------------------------------
//
// Hypothesis:
//
// Promises/A is a Monad
//
// To be a Monad, it must provide at least:
// - A unit (aka return or mreturn) operation that creates a corresponding
// monadic value from a non-monadic value.
// - A bind operation that applies a function to a monadic value
@datagrok
datagrok / git-branch-simplify.md
Last active April 16, 2024 17:26
How to simplify the graph produced by git log --graph

Ideas for improvements to git log --graph

I will maybe someday get around to dusting off my C and making these changes myself unless someone else does it first.

Make the graph for --topo-order less wiggly

Imagine a long-running development branch periodically merges from master. The git log --graph --all --topo-order is not as simple as it could be, as of git version 1.7.10.4.

It doesn't seem like a big deal in this example, but when you're trying to follow the history trails in ASCII and you've got several different branches displayed at once, it gets difficult quickly.

@clausreinke
clausreinke / bind-for-arrows.html
Created July 12, 2013 21:11
using _this=this to emulate arrow functions is fast but error-prone, requiring non-trivial analysis for use in transpilers. using .bind to emulate arrow functions is simpler, but slow in current engines. using an apply-based partial polyfill (bind) for .bind is fast in v8, slow in other engines.
// <script>
/* sample output
$ node ../bind-for-arrows.html
_this: 4ms
.bind: 25ms
bind: 4ms
_this, calls only: 1ms
.bind, calls only: 4ms
bind, calls only: 0ms
@rosswd
rosswd / multi-git-win.md
Last active November 9, 2024 17:31
Setting up a Github and Bitbucket account on the same computer on Mac OS. Now with a guide for Windows 10.

Setting up github and bitbucket on the same computer (Windows)

Guide for Windows

mix3d asked for some help using this guide with windows so here we go. This was tested with Windows 10. Run all commands in Git Bash once it's installed.

Github will be the main account and bitbucket the secondary.

Git for Windows

  • Download and install Git for Windows
    • In the installer, select everything but decide if you want a desktop icon (2nd step)
@randrews
randrews / hoc2.lua
Created June 3, 2015 04:45
Toy calculator in Lua, version 2
setmetatable(_ENV, { __index=lpeg })
VARS = {}
function eval(...)
local args = {...}
local accum = args[1]
for i = 2, #args, 2 do
local operator = args[i]
local num2 = args[i+1]
@randrews
randrews / hoc4.lua
Created June 21, 2015 20:53
Toy calculator in Lua, version 4
setmetatable(_ENV, { __index=lpeg })
Scopes = { {} }
function eval_expr(expr)
local accum = eval(expr[2]) -- because 1 is "expr"
for i = 3, #expr, 2 do
local operator = expr[i]
local num2 = eval(expr[i+1])
@Avaq
Avaq / combinators.js
Last active September 26, 2024 18:53
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@ysr23
ysr23 / pi zero W ap setup.md
Last active September 18, 2024 14:50
Raspberry Pi Zero W Access Point (ap) setup

These are my own personal notes on how i setup a Pi Zero W as an access points it is a blatant copy of this: https://gist.github.com/tcg/0c1d32770fcf6a0acf448b7358c5d059 but is just missing a couple of things from: http://imti.co/post/145442415333/raspberry-pi-3-wifi-station-ap and like tcg, this is not intended as a guide but notes as i will invariably have to rebuild this sometime and i have broken biscuits for brains.

1. making the pi zero accesible from a computer

this is really just the same info as here https://gist.github.com/gbaman/975e2db164b3ca2b51ae11e45e8fd40a

  • flash raspbian lite to sd card
  • unplug and replug sd card adapter if necessary to see 'boot' drive
  • edit cmdline.txt add: modules-load=dwc2,g_ether after the word rootwait
  • edit config.txt and add dtoverlay=dwc2 to the end of the file
  • create a blank file called ssh
@dominikwilkowski
dominikwilkowski / Readme.md
Last active October 9, 2024 15:00
How to install a man page into a node.js app

How to install a man page into a node.js app

Cuttlebelle man page

Installing a man page is not easy as there are little infos out there about it.

After a lot of trial and error, google searches and alpha publishing my app I finally have a collection of things I need to do to get it working: