Skip to content

Instantly share code, notes, and snippets.

dspinellis / Makefile
Last active Mar 5, 2022
Add a help target for any Makefile
View Makefile
love: # Help: Create a file name love
touch love
money: # Help: Hit the jackpot
yes $$ | fmt | head
me a wizard: MOOC # Help: Become a Unix command-line wizard
mahemoff /
Last active Sep 21, 2022
Vim Terminal Mode - A short introduction

Vim has a Terminal Mode!

Since v8.1 (May 2018), Vim has shipped with a built-in terminal. See or type :help terminal for more info.

Why use this? Mainly because it saves you jumping to a separate terminal window. You can also use Vim commands to manipulate a shell session and easily transfer clipboard content between the terminal and files you're working on.

Key Bindings

narrowtux / model.ex
Last active Jun 14, 2022
Recursive models with ecto
View model.ex
defmodule Model do
schema "models" do
field :foo, :string
has_many :children, Model, foreign_key: :parent_id
belongs_to :parent, Model, foreign_key: :parent_id
@doc """
Recursively loads parents into the given struct until it hits nil
View stack.rb
# Corey's challenge is to make the second test pass without ever making the first test fail.
# run ruby stack.rb to run the tests
# For more information see
class Stack
def empty?
def push(element)
@empty = false
lelandbatey /
Last active Aug 31, 2022
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!


This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"


Odaeus / application_controller.rb
Last active Jun 15, 2021
Alternative to Rails' sharing of instance variables between controller and views.
View application_controller.rb
class ApplicationController < ActionController::Base
# Creates an accessor which is exposed to the view
def self.view_accessor(*names)
attr_accessor *names
helper_method *names
# Compile and show [GFM]( docs in your browser.
# Before this works you need to `gem install bcat`
# Usage:
curl --silent --data-binary @- -H "Content-Type: text/plain" | bcat
andkerosine / raskell.rb
Created Aug 15, 2012
Haskell-like list comprehensions in Ruby
View raskell.rb
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
class Array
def +@
View oauth-v2-rfc6749.markdown

The OAuth 2.0 Authorization Framework

This document is intended to be a simplified version of the OAuth 2.0 specification. In particular it has been written with implementors in mind, and as such attempts to trim the spec down to just what you need to implement an OAuth provider or client. It is necessarily not complete, but attempts to introduce spec requirements in the same order in which the protocol proceeds in practise, with everything you need to know about each protocol endpoint brought together in one place rather than scattered across a large document.