Skip to content

Instantly share code, notes, and snippets.

View bretdavidson's full-sized avatar

Bret Davidson bretdavidson

  • North Carolina State University Libraries
View GitHub Profile
Handlebars.registerHelper('quotify', function (string) {
var string = string.replace(/[\u2018\u2019]/g, "'").replace(/[\u201C\u201D]/g, '"');
return string;
});
@bretdavidson
bretdavidson / database.yml
Created March 13, 2013 17:12
Example for connecting RoR to a MAMP hosted database. Socket path assumes MAMP has been installed in the default directory. DATABASE_NAME, USERNAME, and PASSWORD will need to be replaced with the appropriate values from the database in MAMP. Default username and password are both root.
development:
adapter: mysql2
database: DATABASE_NAME
username: USERNAME
password: PASSWORD
socket: /Applications/MAMP/tmp/mysql/mysql.sock
host: localhost
pool: 5
timeout: 5000
encoding: utf8
<!DOCTYPE html>
<html>
<head>
<title>Data Join Demo</title>
<style>
#control {
margin-bottom: 20px;
}
#chart {
width:500px;
@bretdavidson
bretdavidson / README.md
Last active December 11, 2015 00:18 — forked from mbostock/README.md
Underscore.js equivalents in D3

Collections

each(array)

Underscore example:

_.each([1, 2, 3], function(num) { alert(num); });
@bretdavidson
bretdavidson / gist:3442123
Created August 23, 2012 21:32 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="u.nest.js"></script>
<style>
.node circle {
fill: #fff;
stroke: steelblue;
@bretdavidson
bretdavidson / gist:1a769920d3a90fac4c5d
Created April 3, 2015 19:22
Vagrant config stuff
# Before Vagrant.configure()
required_plugins = %w(vagrant-timezone)
required_plugins.each do |plugin|
need_restart = false
unless Vagrant.has_plugin? plugin
puts "Installing" + plugin + "..."
system "vagrant plugin install #{plugin}"
need_restart = true
end
var Friend = function(name, id, friends, x, y, theta) {
this.d = 5;
this.name = name;
this.id = id;
this.theta = theta;
this.name = name;
this.pos = createVector(x, y, 0);
this.mutual = friends; // Array of ids/names
this.friends = []; // Array of friend instances
};
{"eventType":"didRangeBeaconsInRegion","beacons":[{"major":65215,"minor":38409,"uuid":"B9407F30-F5F8-466E-AFF9-25556B57FE6D","rssi":-70,"proximity":"ProximityNear"},{"major":50499,"minor":1311,"uuid":"B9407F30-F5F8-466E-AFF9-25556B57FE6D","rssi":-73,"proximity":"ProximityNear"},{"major":28680,"minor":57614,"uuid":"B9407F30-F5F8-466E-AFF9-25556B57FE6D","rssi":-86,"proximity":"ProximityNear"},{"major":65523,"minor":5129,"uuid":"B9407F30-F5F8-466E-AFF9-25556B57FE6D","rssi":-78,"proximity":"ProximityNear"},{"major":161,"minor":7854,"uuid":"B9407F30-F5F8-466E-AFF9-25556B57FE6D","rssi":-74,"proximity":"ProximityNear"},{"major":16258,"minor":63095,"uuid":"B9407F30-F5F8-466E-AFF9-25556B57FE6D","rssi":-80,"proximity":"ProximityFar"}],"region":{"uuid":"B9407F30-F5F8-466E-AFF9-25556B57FE6D","identifier":"banana","typeName":"BeaconRegion"}}
[ {
"year": "2016",
"semester": "summer 2",
"start": "2016-06-23",
"end": "2016-07-29"
},
{
"year": "2016",
"semester": "summer 1",
"start": "2016-05-16",