Skip to content

Instantly share code, notes, and snippets.

@ciiqr
ciiqr / dispatch.sh
Last active April 5, 2024 02:23
github actions, repository_dispatch with client_payload
# 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"}}'
@fay59
fay59 / Quirks of C.md
Last active January 23, 2024 04:24
Quirks of C

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;
@john2x
john2x / 00_destructuring.md
Last active April 23, 2024 13:18
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

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.

Vectors and Sequences

@zph
zph / .vimrc
Created October 16, 2013 15:30
" 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>
@sbrauer
sbrauer / gitcommit
Last active December 22, 2015 09:49
git commit wrapper script
#!/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"
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
@josephwilk
josephwilk / future.ex
Created July 30, 2013 20:06
Future experiments from Elixir meetup
defmodule Future do
def new(fun) do
fn(x) ->
spawn_link fn ->
value = try do
{ :ok, fun.(x) }
rescue
e -> { :error, e }
end
@gonzedge
gonzedge / application_controller.rb
Created January 5, 2012 02:34
Rails 3.1 - Adding custom 404 and 500 error pages
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)
@pmuellr
pmuellr / gist:1004413
Created June 2, 2011 13:24
BBEdit Language Module for CoffeeScript
<?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.
# 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