Skip to content

Instantly share code, notes, and snippets.

View damncabbage's full-sized avatar
🙅‍♀️
permanent omnishambles

Robin Howard damncabbage

🙅‍♀️
permanent omnishambles
View GitHub Profile
function randomChoice(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
function randint(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function drawCircleANotFilled(ctx, x, y, radius, width, color) {
ctx.beginPath();
@lengarvey
lengarvey / assets_location_nginx.conf
Created September 25, 2012 01:14
Access control allow origin header for nginx
location /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
add_header Access-Control-Allow-Origin *;
}
@ndarville
ndarville / free-icon-licensing.mdown
Last active December 10, 2015 13:58
Licenses for a number of popular and interesting “free” icons, be they image- or font-based.
Font Font License General License
Glyphish Free Image, N/A [On-site attribution with link][glyphish]
IcoMoon Free ? [CC BY-SA 3.0][icomoon]
Iconic ? [CC SA 3.0][iconic] *
Entypo SIL [CC BY 3.0][entypo]
Font Awesome 3.0 SIL [CC BY 3.0][fa-3.0], [MIT][fa-3.0] for code

* The SA license does not appear to exist. Use BY-SA instead.

module Foo where
data FooArgs = FooArgs { foo :: String,
baz :: Integer }
fooer :: FooArgs -> String
fooer = undefined -- doesn't really matter what it does
-- missingArg = fooer (FooArgs { foo = "abc" })
@mipearson
mipearson / check_coverage.rb
Created January 22, 2013 23:21
Assert that a set of specs actually give 100% coverage for the files they're supposed to test.
#!/usr/bin/env ruby
COVERED = %w{
app/models/ ...
}
failures = COVERED.select do |app_file|
spec_file = app_file.gsub('app', 'spec').gsub('.rb', '_spec.rb')
cmd = "sh -c 'SIMPLECOV_FOR=#{app_file} rspec #{spec_file}'"
puts "Running #{cmd}"
module Admin
class CategoriesController < BaseController
def new
@form = CategoryForm.new
end
def create
@form = CategoryForm.new(params[:category])
if @form.valid?
#!/usr/bin/python -E
# -*- coding: UTF-8 -*-
# Usage: In ~/.tmuxrc,
# set default-command /Users/chirayu/ck/vcs/ck5/scripts/for_os_x/tmux_shell_with_clipboard_support.sh
import ctypes
import os
import platform
@parndt
parndt / pre-commit
Last active December 16, 2015 11:59 — forked from ideasasylum/pre-commit
Place this in ~/.git_template/hooks/pre-commit and chmod to 755. Now, ensure you have git >= 1.7.1 and run: git config --global init.templatedir '~/.git_template' Back in your repository, run git init again and the hook will appear.
#!/usr/bin/env ruby
spec_hits = []
checks = {
'_spec\.rb$' => ['focus:[:space:]*true'],
'\.rb$' => ['binding\.pry', 'debugger']
}
# Find the names of all the filenames that have been (A)dded (C)opied or (M)odified
filenames = `git diff --cached --name-only --diff-filter=ACM`.split("\n")
@lengarvey
lengarvey / gist:5481777
Created April 29, 2013 14:08
Some vim hackery tonight led me to: https://github.com/benmills/vimux/pull/66
" open an IRB session in my current folder in the 20% tmux split below
map <Leader>irb :call VimuxRunCommand("clear;irb", 1, 0)<CR>
" Close the 20% tmux split below
map <Leader>cp :call VimuxCloseRunner()<CR>
" Open a shell in the 20% tmux split
map <Leader>sh :call VimuxRunCommand("clear", 1, 0)<CR>
@pyrmont
pyrmont / router.php
Created May 7, 2013 06:43
Routing file for PHP's built-in web server to work on WordPress (and serve PDFs).
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
chdir($root);
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
if(file_exists($root.$path)) {
if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/') {