Skip to content

Instantly share code, notes, and snippets.

View boffbowsh's full-sized avatar

Paul Bowsher boffbowsh

View GitHub Profile
@boffbowsh
boffbowsh / metastore.rb
Created July 24, 2008 15:14
Put has_metadata.rb in lib, then use has_metadata :os in your model
class Metadata < ActiveRecord::Base
set_table_name "meta_metadata"
belongs_to :meta_object, :polymorphic => true
end
#!/bin/bash
# apt-get install jq
#set -eu
shopt -s nullglob
readonly base_dir=$1
if [ -z "$base_dir" ] ; then
echo 'please location docker registry store location!';
exit;
fi
@boffbowsh
boffbowsh / edit.hbs
Created December 30, 2014 00:48
Set a form to use the shadowModel of the controller, and changes won't be saved back to the model (and your list-of-models next to the form) until you call `save()`. Will probably break with relationships, that'll need fixing.
{{#em-form model=shadowModel}}
{{em-input property="name" label="Name"}}
{{em-input property="slug" label="Slug"}}
{{/em-form}}
KEY_COLUMN = 2
with csv.reader(f1) as csv1:
d1 = {r[KEY_COLUMN]: r for r in csv1}
with csv.reader(f2) as csv2:
d2 = {r[KEY_COLUMN]: r for r in csv2}
merged_dict = {x:d1[x] for x in d1 if x in d2}
121 Recruitment
Abbeywood International Recruitment T/A ABW recruitment
ABRS Limited
AdRoc Limited
Advanced Resource Managers IT Limited
@boffbowsh
boffbowsh / gist:28da0cdd02022b26eada
Created May 17, 2015 10:17
Diff of output of Sass and SassC for Whitehall
< html input[type="button"],
< input[type="reset"],
> html input[type="button"], input[type="reset"],
< .row:before, .row:after {
> .row:before,
> .row:after {
< .row-fluid:before, .row-fluid:after {
> .row-fluid:before,
> .row-fluid:after {
< *margin-left: 85.0%;
source "https://rubygems.org"
@boffbowsh
boffbowsh / cve_2015_3226_fix.rb
Last active August 29, 2015 14:23
curl / wget this (retaining the name) into `config/initializers` to fix the CVE-2015-3226 vulnerability in Rails 3.2.22 apps
raise "Check monkey patch for CVE-2015-3226 is still needed" unless Rails::VERSION::STRING == '3.2.22'
module ActiveSupport
module JSON
module Encoding
private
class EscapedString
def to_s
self
end
end
@boffbowsh
boffbowsh / lite_bootstrap.php
Created January 8, 2009 12:55
Bootstrapping Kohana to just use it's libraries
function __autoload( $sClass )
{
// Your own autoload code goes here
// Failed to load, try Kohana's autoloader
// Bootstrap it first
if ( !defined('SYSPATH') )
{
define('SYSPATH', ROOT.'kohana/system/');
define('APPPATH', ROOT.'kohana/application/');
define('EXT', '.php');
# Delete unnecessary files
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/javascripts/prototype.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/controls.js"
# Copy database.yml for distribution use
run "cp config/database.yml config/database.yml.example"