Skip to content

Instantly share code, notes, and snippets.

View dustinsmith1024's full-sized avatar
🏀
⛹️

Dustin Smith dustinsmith1024

🏀
⛹️
View GitHub Profile
@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">
/** 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 / 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
@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 / timer.go
Created July 16, 2015 19:56
Our Golang timing with logger
// for our internal time
saverTimer := logger.Timer()
var totalParseTime time.Duration
var totalTime time.Duration
for {
row, err := csvReader.ReadMap(false)
...
start := time.Now()
@dustinsmith1024
dustinsmith1024 / globalize-test.js
Last active July 26, 2016 21:33
Globalize by Locale
'use strict';
/**
* This shows the currency formatting by locales.
* To add a new locale just update the locales var below.
*
* To run:
* `node translations/tasks/example_outputs.js` to view the output.
*/
@dustinsmith1024
dustinsmith1024 / tz_test.js
Created October 14, 2016 21:36
Sample for testing moment parsing methods and timezones
"use strict";
console.log(process.env.TZ);
// process.env.TZ = "Asia/Shanghai";
let moment = require('moment');
const format = "YYYY-MM-DD";
let d, dUTC, dTZ, dJS;
const hours = ["00","01","02","03","04","05","06","07","08","09","10","11","12",
"13","14","15","16","17","18","19","20","21","22","23","24"];
@dustinsmith1024
dustinsmith1024 / chrome-in-tz.sh
Created October 17, 2016 20:29
Open a new chrome in specific timezone
#!/usr/bin/env bash
# fresh-chrome
#
# Use this script on OS X to launch a new instance of Google Chrome
# with its own empty cache, cookies, and user configuration.
#
# The first time you run this script, it will launch a new Google
# Chrome instance with a permanent user-data directory, which you can
# customize below. Perform any initial setup you want to keep on every
@dustinsmith1024
dustinsmith1024 / postgres_queries_and_commands.sql
Last active March 28, 2018 14:58 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
https://www.postgresql.org/docs/9.4/static/monitoring-stats.html
https://www.postgresql.org/docs/9.4/static/functions-admin.html
-- show blocking pids in a nice tree
-- query as blocked_query
-- 9.6++
select pid, usename,
age(query_start, clock_timestamp()),
pg_blocking_pids(pid) as blocked_by,
query
@dustinsmith1024
dustinsmith1024 / keybindings.json
Last active April 13, 2017 21:02
VS Code Settings
// Place your key bindings in this file to overwrite the defaults
[
{ "key": "cmd+,", "command": "workbench.action.navigateBack" },
{ "key": "cmd+.", "command": "workbench.action.navigateForward" }
]