Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
int main(int argvc, char * argv)
{
printf("hello world\n");
return 0;
}
@daniel-barlow
daniel-barlow / rationale.md
Last active June 18, 2020 08:15
What to put in a Pull Request
As a developer
I want to get better at making my PRs easier to review
So that they get reviewed sooner and I can merge faster => shorter cycle times

As a code reviewer
I want PRs that are easier to review
So that it's less work
import qualified Data.Map as Map
import qualified Data.List as List
-- Getting started
-- download this file as e.g. hello.hs
-- brew install ghc
-- ghci
-- :r hello.hs
-- -- --
@daniel-barlow
daniel-barlow / 0-instructions.md
Last active June 21, 2017 13:58
NixOS demo system on Virtualbox
  • get NixOS Virtualbox appliance from https://nixos.org/nixos/download.html#virtualbox-appliances
  • start Virtualbox and "File -> Import Appliance" the downloaded OVA file
  • go into Machine -> Settings, then Network / Adapter 1 / Advanced / ensure "Cable Connected" is checked
  • start the machine, and wait for it to boot
  • login at the graphical login screen, user: demo pw: demo
  • when the desktop appears, go to "start" button (it is not labelled in any way) in bottom left, click to get menu
  • open a shell with Applications -> System -> Terminal
  • sudo -i
  • nixos-generate-config --force
  • nano /etc/nixos/configuration.nix and make the changes as shown in the diff (choose your own username)
Line 13:
. /etc/sysconfig/network
^-- SC1091: Not following: /etc/sysconfig/network was not specified as input (see shellcheck -x).
Line 15:
if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then
^-- SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
Line 34:
@daniel-barlow
daniel-barlow / piezo.clj
Created September 29, 2016 11:14
WIP slightly pseudocode
;; Piezo is not a real bell
(ns piezo.core
(:require [clojure.core.async :as async :refer [chan >! >!! <! <!! go]]))
;; stubs to be filled in later
(defn http-listening-chan
"A channel which sends ring request maps on incoming HTTP requests
whose uri paths begin with `prefix`"

What is this about?

Convert your ruby app to run on JRuby (often fairly painless) then deploy it by generating a JAR file (should be reasonably painless) and copying it to the servers you're running on (should be bordering on trivial).

If you've never done Java programming, a JAR is a "Java ARchive" file which is basically a single ZIP file containing all the stuff your app needs to run. So you can install java on a new machine and copy the JAR file onto it, and you're ready to go.

What's wrong with how we do it now?

The usual way of deploying a Ruby app is to write (or copypasta) some Capistrano recipes to have the production machines check it out from a git repo then build it in exactly the same way you do on your Mac. This has downsides:

@daniel-barlow
daniel-barlow / gist:56d00d2cbc8a5195a1ef
Created August 13, 2015 08:01
flexisip config for ec2
[global]
debug=true
#debug=false
# substitute your ec2 external ip for 52.x.y.x and your internal addr for 10.x.y.z
aliases=sip.52.19.37.223.xip.io
transports=sip:sip.52.19.37.223.xip.io;maddr=10.40.0.165
[module::Registrar]
enabled=true
reg-domains=sip.52.19.37.223.xip.io
building mongodb seems to hang forever in patchPhase. It has no prePatch hooks, no patches, and a postPatch
hook as follows
postPatch = ''
# fix environment variable reading
substituteInPlace SConstruct \
--replace "env = Environment(" "env = Environment(ENV = os.environ,"
'';
and it's that substituteInPlace call that takes forever
@daniel-barlow
daniel-barlow / gist:7dfce6d2b30dce035e9e
Created June 8, 2015 14:19
TIL: don't put global constants in your Vagrantfiles
dbarlow@macdbarlow-2 ~/src/geppetto (master=) $ vagrant box remove centipede
/Users/dbarlow/src/2geppetto/Vagrantfile:9: warning: already initialized constant CLOUDINIT_YML
/Users/dbarlow/src/geppetto/Vagrantfile:7: warning: previous definition of CLOUDINIT_YML was here
/Users/dbarlow/src/kitten/Vagrantfile:4: warning: already initialized constant REGION
/Users/dbarlow/src/chopin/Vagrantfile:4: warning: previous definition of REGION was here
/Users/dbarlow/src/kitten/Vagrantfile:5: warning: already initialized constant STAGE
/Users/dbarlow/src/chopin/Vagrantfile:5: warning: previous definition of STAGE was here
/Users/dbarlow/src/kitten/Vagrantfile:6: warning: already initialized constant APP
/Users/dbarlow/src/chopin/Vagrantfile:6: warning: previous definition of APP was here
/Users/dbarlow/src/kitten/Vagrantfile:7: warning: already initialized constant ROLE