Skip to content

Instantly share code, notes, and snippets.

View chrisbolin's full-sized avatar
❤️

Chris Bolin chrisbolin

❤️
View GitHub Profile
@chrisbolin
chrisbolin / app.js
Last active August 29, 2015 14:07
Stupid Simple Angular Boilerplate
"use strict";
angular
.module('app', [])
.controller('HomeController', HomeController);
function HomeController ($scope) {
$scope.hello = "oh, hi"
}
@chrisbolin
chrisbolin / serve.py
Last active March 22, 2023 13:53
Python SimpleHTTPServer for Static Serving (React / Angular / Ember) in HTML5 mode (a la mod_rewrite)
'''
Taken from:
http://stackoverflow.com/users/1074592/fakerainbrigand
http://stackoverflow.com/questions/15401815/python-simplehttpserver
'''
import SimpleHTTPServer, SocketServer
import urlparse, os
PORT = 3000
@chrisbolin
chrisbolin / about.md
Last active August 29, 2015 14:08
Firebase Circular Buffer

A circule buffer for firebase. Elements are dequeued and enqueue, and a callback function is run on their dataSnapshot.

@chrisbolin
chrisbolin / queue.js
Last active August 29, 2015 14:09
Firebase Work Queue
// ref.transaction() can be used in place of ref.set()
queueChildRef.transaction(function(theItem) {
dataToProcess = theItem;
if(theItem) {
return null; // if there is still a value, delete it and claim job
} else {
return; // if there is not a value, abort transaction. job already claimed
}
}, function(error, committed, snapshot, dummy) {
if (error) throw error;
@chrisbolin
chrisbolin / csv-to-sql-table.bash
Created January 10, 2015 23:00
Create MySQL Table from CSV File
## prints create and insert SQL statements from a csv ##
# csv-to-table [path] [name]
# $ csv-to-table ./data.csv data_table
# create table adapted from John Swapceinski,
# http://dev.mysql.com/doc/refman/5.0/en/load-data.html#c12001
path=$(pwd)
@chrisbolin
chrisbolin / mongodb-collection-sizes.js
Last active October 8, 2015 17:28 — forked from joeyAghion/mongodb_collection_sizes.js
List mongodb collections in descending order of storageSize. Helpful for finding largest collections.
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['storageSize'] - a['storageSize']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['storageSize']); }
@chrisbolin
chrisbolin / export.sh
Last active January 12, 2016 00:30
Export / Source a .env File
# .env as used in https://github.com/bkeepers/dotenv
export $(cat .env)
@chrisbolin
chrisbolin / shell.js
Last active November 12, 2015 21:06
Keystone.js REPL Shell (using Headstone)
var repl = require('repl'),
keystone = require('keystone');
module.exports = function(done) {
var shell = repl.start({
prompt: 'keystone > '
});
// expose keystone to the shell
shell.context.keystone = keystone;
@chrisbolin
chrisbolin / index.html
Last active January 25, 2016 05:47
Codepen Preview
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>chris bolin 2</title>
<link rel="stylesheet" href="css/normalize.css">
@chrisbolin
chrisbolin / populate.js
Last active May 19, 2016 15:27
Meteor Populate / Join (Quick & Dirty)
// quick and dirty populating ("joining") in Meteor
Mongo.Collection.prototype.findAndPopulate = function (selector, options, populates) {
/*
selector and options: from Mongo.Collection.prototype.find(selector, options)
populates: [Object] or Object
[{id, as, from}] or {id, as, from}
e.g. {id: 'userId', as: 'thisUser', from: Users}
will look up doc.userId in Users and assign to doc.thisUser
--> doc.thisUser = Users.findOne(doc.userId);
*/