Skip to content

Instantly share code, notes, and snippets.

View anicholson's full-sized avatar

Andy Nicholson anicholson

View GitHub Profile
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@tylerneylon
tylerneylon / learn.lua
Last active April 28, 2024 22:23
Learn Lua quickly with this short yet comprehensive and friendly script. It's written as both an introduction and a quick reference. It's also a valid Lua script so you can verify that the code does what it says, and learn more by modifying and running this script in your Lua interpreter.
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@paulmach
paulmach / serve.go
Last active March 28, 2024 15:31
Simple Static File Server in Go
/*
Serve is a very simple static file server in go
Usage:
-p="8100": port to serve on
-d=".": the directory of static files to host
Navigating to http://localhost:8100 will display the index.html or directory
listing file.
*/
package main
javascript:(function()%7Bconsole.log(%0A%20%20Array.from(document.querySelectorAll('h1%2C%20h2%2C%20h3%2C%20h4%2C%20h5%2C%20h6')).reduce((str%2C%20heading%2C%20index%2C%20arr)%20%3D%3E%20%7B%0A%20%20%20%20const%20level%20%3D%20Number(heading.tagName.slice(1))%3B%0A%0A%20%20%20%20if%20(level%20%3D%3D%3D%201%20%26%26%20heading.textContent%20%3D%3D%3D%20'No%20Preview')%20%7B%0A%20%20%20%20%20%20return%20str%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20const%20previousLevel%20%3D%20index%20%3D%3D%3D%200%20%3F%20level%20%3A%20Number(arr%5Bindex%20-%201%5D.tagName.slice(1))%3B%0A%20%20%20%20const%20indentation%20%3D%20(level%20-%20previousLevel%20%3E%201%20%3F%20'*'%20%3A%20'-').repeat(level)%3B%0A%20%20%20%20const%20isAriaHidden%20%3D%20heading.getAttribute('aria-hidden')%20%3D%3D%3D%20'true'%3B%0A%20%20%20%20const%20isDisplayNone%20%3D%20getComputedStyle(heading).display%20%3D%3D%3D%20'none'%3B%0A%20%20%20%20const%20isVisibilityHidden%20%3D%20getComputedStyle(heading).visibility%20%3D%3D%3D%20'hidden'%3B%0A%20%20%20%20c
@mpasternacki
mpasternacki / freebsd_on_mbp.md
Created January 23, 2015 17:12
FreeBSD on a MacBook Pro

FreeBSD on a MacBook Pro

Since 2008 or 2009 I work on Apple hardware and OS: back then I grew tired of Linux desktop (which is going to be MASSIVE NEXT YEAR, at least since 2001), and switched to something that Just Works. Six years later, it less and less Just Works, started turning into spyware and nagware, and doesn't need much less maintenance than Linux desktop — at least for my work, which is system administration and software development, probably it is better for the mythical End User person. Work needed to get software I need running is not less obscure than work I'd need to do on Linux or othe Unix-like system. I am finding myself turning away from GUI programs that I used to appreciate, and most of the time I use OSX to just run a terminal, Firefox, and Emacs. GUI that used to be nice and unintrusive, got annoying. Either I came full circle in the last 15 years of my computer usage, or the OSX experience degraded in last 5 years. Again, this is from a sysadmin/developer ki

@joelittlejohn
joelittlejohn / test.clj
Last active July 3, 2023 21:08
Dynamically generate clojure.test deftests (and other tricks)
(ns dynamic.test
(:require [clojure.test :refer :all]))
;; This example shows how tests can be generated dynamically, by
;; creating new vars with the correct metadata.
(defn add-test
"Add a test to the given namespace. The body of the test is given as
the thunk test-fn. Useful for adding dynamically generated deftests."
[name ns test-fn & [metadata]]

Zero downtime deploys with unicorn + nginx + runit + rvm + chef

Below are the actual files we use in one of our latest production applications at Agora Games to achieve zero downtime deploys with unicorn. You've probably already read the GitHub blog post on Unicorn and would like to try zero downtime deploys for your application. I hope these files and notes help. I am happy to update these files or these notes if there are comments/questions. YMMV (of course).

Other application notes:

  • Our application uses MongoDB, so we don't have database migrations to worry about as with MySQL or postgresql. That does not mean that we won't have to worry about issues with the database with indexes being built in MongoDB or what have you.
  • We use capistrano for deployment.

Salient points for each file:

@tomstuart
tomstuart / gist:1466504
Created December 12, 2011 10:40
FizzBuzz in the lambda calculus in Ruby
>> IF = -> b { b }
=> #<Proc:0x007fb4e4049cc8 (lambda)>
>> LEFT = -> p { p[-> x { -> y { x } } ] }
=> #<Proc:0x007fb4e403d680 (lambda)>
>> RIGHT = -> p { p[-> x { -> y { y } } ] }
=> #<Proc:0x007fb4e4028ff0 (lambda)>
>> IS_EMPTY = LEFT
@JoshCheek
JoshCheek / why_i_chose_fish_over_bash_for_students.md
Last active December 14, 2021 20:30
Why I Chose Fish Over Bash For Students

Why I chose Fish over Bash for students

I'm currently the lead instructor at Code Platoon and an instructor/developer at the Turing School of Software and Design.

I've been advocating the Fish shell and when the choice is up to me, I choose that for my students. Enough people ask about the decision, particularly in relation to the preinstalled Bash shell, that I figured it's worth laying out my reasoning.

TL;DR

@jharjono
jharjono / sinatra_sass_coffee.rb
Created March 7, 2011 19:12
a setup of Sinatra using Slim for HTML, Sass for CSS, and CoffeeScript for JavaScript
#!/usr/bin/env ruby
# Libraries:::::::::::::::::::::::::::::::::::::::::::::::::::::::
require 'rubygems'
require 'sinatra/base'
require 'slim'
require 'sass'
require 'coffee-script'
# Application:::::::::::::::::::::::::::::::::::::::::::::::::::