Skip to content

Instantly share code, notes, and snippets.

View dustinsmith1024's full-sized avatar
🏀
⛹️

Dustin Smith dustinsmith1024

🏀
⛹️
View GitHub Profile
@dustinsmith1024
dustinsmith1024 / notify.js
Created March 9, 2015 15:40
PG Notify Sample
var pg = require ('pg');
var pgConString = "postgres://localhost/xxxx"
pg.connect(pgConString, function(err, client) {
if(err) {
console.log(err);
}
client.on('notification', function(msg) {
console.log(msg);
@dustinsmith1024
dustinsmith1024 / index.js
Created July 23, 2014 01:42
Simple Koa Example
var koa = require('koala');
var app = koa();
app.use(function *(){
//console.log(this.req, this.path);
if(this.path==='/hey'){
this.body = yield dogs;
}else{
if(this.path!=='/favicon.ico'){
// don't call the function...it needs to return a function
/** 30_days_of_code
* Playing with promise implementations
*
* used doc here to step by step build: http://mattgreer.org/articles/promises-in-wicked-detail/
*/
function Promise(fn) {
var state = 'pending';
var value;
var deferred = null;
@dustinsmith1024
dustinsmith1024 / remove.js
Last active June 3, 2016 10:49
AngularFire Remove Examples
;<!doctype html>
<html ng-app="myapp">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.min.js"></script>
<script src="https://cdn.firebase.com/v0/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/0.6.0/angularfire.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://www.firebase.com/css/example.css">
</head>
<body ng-controller="MyController">
<div id="messagesDiv">
@dustinsmith1024
dustinsmith1024 / nba_players.rb
Created October 8, 2013 03:15
A capybara script for getting all the NBA teams and players.
#!/usr/bin/env ruby
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'capybara/poltergeist'
require 'json'
filename = ARGV[0] || false
if filename
@dustinsmith1024
dustinsmith1024 / index.html
Created July 26, 2013 11:53
sample ember app
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" />
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.0-rc.6/ember.min.js"></script>
<script src="http://builds.emberjs.com.s3.amazonaws.com/ember-data-latest.js"></script>
$(document).on("page:change", function(){
window.prevPageYOffset = window.pageYOffset;
window.prevPageXOffset = window.pageXOffset;
});
//fix-scroll want needed for me
$(document).on("page:load", function(){
window.scrollTo(window.prevPageXOffset, window.prevPageYOffset);
});
@dustinsmith1024
dustinsmith1024 / routes.rb
Created May 17, 2013 18:08
A way to filter a route based on query params. You can also make the module a class and then initialize it to pass in whatever you want.
module QueryParamConstraint
extend self
def matches?(request)
request.query_parameters["view"] == request.path_parameters[:action]
end
end
MyPortal::Application.routes.draw do
@dustinsmith1024
dustinsmith1024 / _component.html.haml
Created February 26, 2013 03:53
Style guiding example
%section.component{class: defined?(main_classes) && main_classes, id: defined?(id) && id}
%h1.component-header{class: defined?(header_classes) && header_classes, id: defined?(header_id) && header_id}= header
.component-content{class: defined?(content_classes) && content_classes, id: defined?(content_id) && content_id}
=body
@dustinsmith1024
dustinsmith1024 / bootstrap-fluid-grid-mixin.css
Last active December 12, 2015 08:09
A way to mixin fluid bootstrap grids
.fluid-row {
div, section, article, li { /* Needs testing on li's */
&:first-child { /* using first child and margin-left for IE support */
margin-left: 0;
}
}
}
.fluid-column(@columns: 1, @offset: 0, @reset: default) {
.input-block-level();