Skip to content

Instantly share code, notes, and snippets.

Avatar
🛋️

Dave Cottlehuber dch

🛋️
View GitHub Profile
View emacs-indent-erlang
;;; File: emacs-indent-erlang
;;; adapted from http://www.cslab.pepperdine.edu/warford/BatchIndentationEmacs.html
;; this has to be set to the real path on your system
(add-to-list 'load-path "~/.emacs.d/elpa/erlang-20131025.6")
(load-library "erlang")
;; comment out the call to untabify if you want the mixed tabs and spaces
(defun emacs-indent-function ()
View prealloc_bin.S
{module, prealloc_bin}. %% version = 0
{exports, [{module_info,0},{module_info,1},{new,1}]}.
{attributes, []}.
{labels, 7}.
{function, new, 1, 2}.
View build_otp.sh
#!/usr/bin/env bash
# Note: erlang depends on ncurses, openssl at a minimum
usage ()
{
echo "usage: $0 <release> <type>"
echo " release: R14B01|R14B02|R14B03|R14B04|R15B|R15B01|R15B02|R15B03|R16B|R16B01|R16B02"
echo " type: normal, opt, gcov, gprof, debug, valgrind, or lcnt"
@dch
dch / report.erl
Created Feb 21, 2014
online version of crash_dump viewer that doesn't require blowing up your vm. Snaffled off erlang-questions.
View report.erl
-module(report).
-author("Matthew Evans <mattevans123@hotmail.com>").
-export([crash_report/0]).
crash_report() ->
Date = erlang:list_to_binary(rfc1123_local_date()),
Header = binary:list_to_bin([<<"=erl_crash_dump:0.2\n">>,Date,<<"\nSystem version: ">>]),
Ets = ets_info(),
Report = binary:list_to_bin([Header,erlang:list_to_binary(erlang:system_info(system_version)),erlang:system_info(info),erlang:system_info(procs),Ets,erlang:system_info(dist),
<<"=loaded_modules\n">>,binary:replace(erlang:system_info(loaded),<<"\n">>,<<"\n=mod:">>,[global])]),
@dch
dch / git-orphan
Created Feb 25, 2014
`git orphan` sets up a new git branch with no parent commit. Needs git 1.8 at least, maybe earlier versions.
View git-orphan
#!/bin/sh
git checkout --orphan $* && git rm -rf .
@dch
dch / erlang.rb
Last active Aug 29, 2015
Install OTP 17.0-rc2 via homebrew: `brew install wxmac && brew install --no-docs --with-dirty-schedulers --time --devel -v https://gist.githubusercontent.com/dch/9267866/raw/erlang.rb`
View erlang.rb
require 'formula'
# Major releases of erlang should typically start out as separate formula in
# Homebrew-versions, and only be merged to master when things like couchdb and
# elixir are compatible.
class Erlang < Formula
homepage 'http://www.erlang.org'
# Download tarball from GitHub; it is served faster than the official tarball.
url 'https://github.com/erlang/otp/archive/OTP_R16B03-1.tar.gz'
sha1 'b8f6ff90d9eb766984bb63bf553c3be72674d970'
@dch
dch / ppsp-tp-feedback.md
Last active Aug 29, 2015
PPSP-TP feedback
View ppsp-tp-feedback.md

Tracker Review

Summary

  • the draft is too long for the 4 requirements from [rfc6972]
  • much of the included content is not directly relevant and arguably confusing
  • there is not enough separation of concern between TP and PPSP
  • technically it might be replaced with simpler alternatives (with some compromises)
  • I'm not intending to implement this in its current form
View Makefile-erlang.mk
APPDIRS := $(wildcard apps/*)
## Example hack to filter one out:
## APPDIRS := $(filter-out apps/fooapp, $(APPDIRS))
define PROXY_TARGET
$(1):
$(foreach appdir,$(APPDIRS),$(MAKE) -C $(appdir) $(1) ;)
endef
View .gitignore
*.beam
*.swp
deps/
ebin/*.app
ebin/*.beam
logs/*
.eunit
erl_crash.dump
/swirl
View backup-github.sh
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=${GHBU_ORG-"<CHANGE-ME>"} # the GitHub organization whose repos will be backed up
# (if you're backing up a user's repos instead, this should be your GitHub username)
GHBU_UNAME=${GHBU_UNAME-"<CHANGE-ME>"} # the username of a GitHub account (to use with the GitHub API)
GHBU_PASSWD=${GHBU_PASSWD-"<CHANGE-ME>"} # the password for that account
GHBU_GITHOST=${GHBU_GITHOST-"github.com"} # the GitHub hostname (see comments)
GHBU_PRUNE_OLD=${GHBU_PRUNE_OLD-true} # when `true`, old backups will be deleted