Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Slight modifications to code posted by Gregory Brown at http://pastie.org/515450 | |
require 'delegate' | |
module Decoration | |
def decorator_for(*types, &block) | |
types.each do |type| | |
decorators[type] = Module.new(&block) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<!-- | |
BBEdit Language Module for CoffeeScript | |
Put this file in | |
~/Library/Application Support/BBEdit/Language Modules | |
or equivalent. | |
Based off of the examples shipped in the BBEdit SDK. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
# ... | |
unless Rails.application.config.consider_all_requests_local | |
rescue_from Exception, with: lambda { |exception| render_error 500, exception } | |
rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception } | |
end | |
private | |
def render_error(status, exception) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Future do | |
def new(fun) do | |
fn(x) -> | |
spawn_link fn -> | |
value = try do | |
{ :ok, fun.(x) } | |
rescue | |
e -> { :error, e } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export PATH="$HOME/erlang/current/bin:$PATH" | |
erlcur() { | |
DIR=`ls -lr $HOME/erlang | awk '/current/ { print $NF }'` | |
echo -n ${DIR##*/} | |
} | |
erlsw() { | |
TARGET=`find $HOME/erlang -depth 1 -type d -name "*$1*" | head -1` | |
if [ -z "$TARGET" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# A wrapper around "git commit" that provides a template message | |
# conforming to RentPath conventions. | |
# Assumes branches are named with the following components separated | |
# by underscores: | |
# 1. developer initials (one or more of these components are allowed) | |
# 2. story number | |
# 3. free text description (optional; may contain underscores) | |
# Examples: | |
# "sb_12345_fix_serious_bug" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Set Leader key | |
let mapleader = "," | |
" Since we mapped , as leader, let's map ',' default backwards ; | |
nnoremap \ , | |
map <Space> <Leader> | |
" Use jk to escape | |
inoremap jk <ESC> |
Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.
There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.
1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]
struct foo {
struct bar {
int x;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO: replace :token, :user, and :repo | |
curl -H "Authorization: token :token" \ | |
-H 'Accept: application/vnd.github.everest-preview+json' \ | |
"https://api.github.com/repos/:user/:repo/dispatches" \ | |
-d '{"event_type": "awesomeness", "client_payload": {"foo": "bar"}}' |
OlderNewer