Skip to content

Instantly share code, notes, and snippets.

View jackofseattle's full-sized avatar

Jack Morgan jackofseattle

View GitHub Profile
@jackofseattle
jackofseattle / postgres_queries_and_commands.sql
Created August 27, 2019 18:46 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@jackofseattle
jackofseattle / Update remote repo
Last active February 7, 2018 13:50 — forked from mandiwise/Update remote repo
Transfer repo from Bitbucket to Github
git remote rename origin bitbucket
git remote add origin {new repo url}
git push origin --all
$ git remote rm bitbucket
@jackofseattle
jackofseattle / Main.elm
Created April 26, 2016 12:04
Etch-a-sketch in Elm! Go to http://elm-lang.org/try and paste in this code.
-- Etch-a-sketch with Elm
-- Paste this code into http://elm-lang.org/try
-- Use the arrow keys to draw a line etch-a-sketch style
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Keyboard
import Time exposing (fps)
@jackofseattle
jackofseattle / gist:e28631e321bdd607200b
Created May 28, 2015 21:51
connect to stores as a decorator for flummox
const React = require('react');
const connectToStores = require('flummox/connect');
function connect(...args) {
return function(target) {
return connectToStores(target, ...args);
}
}
@jackofseattle
jackofseattle / injectable.js
Last active August 29, 2015 14:07
Basic injectable class for AngularJS
/**
* injectable
*
* Provides a constructor to move items from the $inject property to local object members.
*
* inject = ['$q', '$http'] //translates to
*
* this.$q
* this.$http
*/
What is the output of this function? Why?
for(var i = 0; i < 5; i++) {
setTimeout(function() {
console.log('The value of i is ', i);
}, 500);
}
var serialize = function(obj, prefix) {
var str = [];
for(var p in obj) {
var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p];
str.push(typeof v == "object" ?
serialize(v, k) :
encodeURIComponent(k) + "=" + encodeURIComponent(v));
}
return str.join("&");
}