This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CHORDII := chordii -a | |
pdfs := $(patsubst %.chordpro,%.pdf,$(wildcard *.chordpro)) | |
all: $(pdfs) | |
%.ps : %.chordpro | |
$(CHORDII) $< > $@ | |
%.pdf : %.ps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEPLOYHOST=ben@awesomehost.co.nz | |
DEPLOYDIR=/var/www | |
# WARNING: The --delete flag will delete anything on the remote end that isn't | |
# on the local end. But you've got backups, right? | |
upload: | |
rsync -vax -e ssh --exclude .git --delete . $(DEPLOYHOST):$(DEPLOYDIR)/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/generators/test_generator/USAGE | |
Description: | |
A minimal rails 3 generator example | |
Example: | |
rails generate NewClass method1 method2 | |
This will create: | |
app/models/new_class.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'net/http' | |
require 'json' | |
require 'nokogiri' | |
require 'open-uri' | |
# Lat long boundaries | |
# | |
# Around the casino | |
#xmin=172.6299226284027 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/inotify.h> | |
#include <stdio.h> | |
#include <errno.h> | |
/* size of the event structure, not counting name */ | |
#define EVENT_SIZE (sizeof (struct inotify_event)) | |
/* reasonable guess as to size of 1024 events */ | |
#define BUF_LEN (1024 * (EVENT_SIZE + 16)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Create your custom stylesheets based on the taxonomy tid in | |
* $theme_dir/css/taxonomy/$tid.css | |
*/ | |
function THEME_preprocess_node(&$vars, $hook) { | |
if ($terms = taxonomy_node_get_terms($vars->['node'])) { | |
foreach ($terms as $term) { | |
$stylesheet = '/css/taxonomy/'. $term->tid .'.css'; | |
if (file_exists(dirname(__FILE__) . $stylesheet)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'delegate' | |
class CaseInsensitiveHashWriter < SimpleDelegator | |
def []=(key, value) | |
return __getobj__[key] unless key.respond_to?(:downcase) | |
matched_key = keys.detect do |k| | |
k.respond_to?(:downcase) && k.downcase == key.downcase | |
end | |
if matched_key | |
__getobj__[matched_key] = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Log an exception with the backtrace cleaned as per the 'Application Trace' | |
# in the development mode browser exception view. | |
logger.error( | |
"some_tag: exception = %s: %s" % [ | |
exception.inspect, | |
Rails.backtrace_cleaner.clean(exception.backtrace) | |
] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def value_of_first_matching_key_in_hash(hash, array_of_keys) | |
end | |
describe do | |
it 'searches a hash for an array of keys and returns the value of the first found' do | |
keys = [:a, :b, :c] | |
hash = {:c => 3, :b => 2, :a => 1} | |
expect(value_of_first_matching_key_in_hash(hash, keys)).to eql 1 |