Skip to content

Instantly share code, notes, and snippets.

View pads's full-sized avatar

Ben Paddock pads

View GitHub Profile
// https://github.com/CodeYourFuture/JavaScript-Core-2-Homework/blob/master/Week-1/InClass/C-more-complex-objects/exercise-3.js
/*
Given the same "house" object again
Write the code for the functions as per the description above them
*/
let kinningParkHouse = {
address: "1 Kinning Park",
price: 180000,
currentOwner: {
@pads
pads / keybase.md
Created February 27, 2016 22:33
Proof of GitHub account ownership

Keybase proof

I hereby claim:

  • I am pads on github.
  • I am pads (https://keybase.io/pads) on keybase.
  • I have a public key ASAMRTsoYKHrT860S21K4fwb52UDFu3BD2JT_imEx_mYgQo

To claim this, I am signing this object:

@pads
pads / update_shrinkwrap.sh
Last active February 24, 2017 10:55
The NPM shrinkwrap dance
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo "Usage: update_shrinkwrap.sh <package-name@version|git-repo#version>"
exit 1;
fi
npm cache clean
npm prune
rm -rf node_modules
@pads
pads / config.js
Created June 26, 2015 16:00
Angular Bootstrap Dynamic Popover Placement
$tooltipProvider.setTriggers({
// other trigger config
'customOpen':'customClose'
});
@pads
pads / multi_csv_processor.rb
Created April 3, 2015 10:05
Processing some CSV files for some Psychology PhD statistics work
require 'csv'
# Iterate through each CSV file in the current folder
Dir.glob('*.csv') do |csv_filename|
# Create and open a new file to store the modified rows
csv_output_file = CSV.open("modified-#{csv_filename}", 'wb')
# Open the current file by filename
CSV.open(csv_filename, 'r') do |csv_contents|
# Iterate through each row in the CSV file
csv_contents.each do |row|
@pads
pads / processor.rb
Last active August 29, 2015 14:13
Find the location(s) of the max value in two result sets within a CSV of survey results
require 'csv'
csv_contents = CSV.read('Data.csv')
# Shift 3 rows of headers to get to the data
csv_contents.shift
csv_contents.shift
csv_contents.shift
set1 = []
set2 = []
@pads
pads / recursive-rollback.coffee
Created December 18, 2014 13:58
Ember Recursive Model Rollback
# Ember data does not dirty the parent model if any of it's children change so
# no rollback can occur for a child. This fixes this by resetting a child's
# data to the internal data tracked by the parent model.
DS.Model.reopen
rollbackBelongsTo: (relationshipName) ->
thisName = @constructor.typeKey
relationshipInstance = @get relationshipName
# Rollback any attributes that were changed in the relationship
relationshipInstance.rollback()
@pads
pads / relationship-rollback.coffee
Last active February 7, 2016 14:31
Dynamically rollback Ember model relationships
App.MyModel.eachRelationship (name, relationship) ->
relationshipInstance = modelInstance.get name
if relationshipInstance
if relationship.kind is 'belongsTo'
relationshipInstance.rollback()
else if relationshipInstance.content and relationship.kind is 'hasMany'
relationshipInstance.content.forEach (record) ->
record.rollback()
@pads
pads / Hole 1
Created November 28, 2014 09:24
WMRUG Code Golf Solutions
puts gets.to_i.to_s(2)
#
# Best solution found:
#
#puts"%b"%gets
@pads
pads / bot.js
Created November 28, 2014 09:17
BrumJS Rock Paper Scissors Bot
var hands = [
'rock',
'paper',
'scissors',
'water',
'dynamite'
];
var opponents = []