Skip to content

Instantly share code, notes, and snippets.

View kylehill's full-sized avatar

Kyle Hill kylehill

  • Skylight Digital
  • Washington, DC
View GitHub Profile
@kylehill
kylehill / ajax_breakdown.js
Created April 9, 2012 15:17 — forked from ryanmcgrath/ajax_breakdown.js
$.ajax breakdown for cross-domain requests.
// An AJAX query is broken down like this...
$.ajax({
// This means we're going to pull data; if you're
// creating something new on the server, this'll be POST
type: "GET",
// This tells jQuery to use a cross-domain fetching trick
dataType: "jsonp",
// The BASE URL we want to query data from
@kylehill
kylehill / gist:2345247
Created April 9, 2012 18:25
Here's a fun code snippet
// Go to any https://capitalbikeshare.com page
// Open up Chrome Inspector, Javascript console
// Paste in this, insert your credentials, submit
$.post(
'https://capitalbikeshare.com/login',
[{name:'username', value:'USERNAME'},{name:'password', value:'PASSWORD'}],
function(data, textStatus, xhr) {
console.log('logged in');
$.get(
@kylehill
kylehill / gist:3757235
Created September 20, 2012 17:32
Mass-quantity safe debugger for AS3
public function emitter(... args):void {
var output:Array = [];
for (var param:Number = 0; param < args.length; param++) {
try {
if (getQualifiedClassName(args[param]) === "Array") {
var obj = args[param][0];
if (obj == "splice") {
obj = args[param][1]
for (var level:Number = 2; level < args[param].length; level++) {
obj = obj[level];
@kylehill
kylehill / gist:3845414
Created October 6, 2012 16:37
538 screen scraping code
var states=[];
jQuery(".eg2012-538-state-projections-container.eg2012-president").each(function(){
var state = {};
var raw_name = jQuery(this).find("h2").text().trim();
state.name = raw_name.split('\n')[2].trim();
var data_row = jQuery(this).find(".moe").parent().parent();
var raw_moe = jQuery(data_row).find(".moe").text();
state.moe = parseFloat(raw_moe.substr(1));
@kylehill
kylehill / gist:5620802
Created May 21, 2013 15:40
Fix for "just keep scrolling, damnit" on nclud.me/welcome
var pageHeight = $("body > div:last-child").height();
var tickCount = 0;
var maxTicks = (77 * 15);
var pixelsPerTick = (pageHeight / maxTicks);
var autoscroller = function() {
if (tickCount < maxTicks) {
tickCount++;
window.scrollBy(0, pixelsPerTick);
setTimeout(autoscroller, (1000 / 77));
@kylehill
kylehill / filter.js
Last active December 21, 2015 10:09
Common functional programming patterns. From Functional Programming 101 talk at nodeDC/dcjQuery meetup, 8/22/2013
var filter = function (array, action) {
var outbound = [];
for (var i = 0; i < array.length; i++) {
if (action(array[i]) {
outbound.push(array[i]);
}
}
return outbound;
};
function asyncFunction (param) {
// Scope local variables to this function
// param is also both locally scoped
var n = param.name
var e = param.extension
// Simulate something asynchronous happening
setTimeout(function(){
console.log("Downloaded file: " + n + "." + e)
}, 500 + (Math.random() * 500))

After almost a decade of working on larger software development teams, one of the parts I (surprisingly) miss the most is the daily, early-morning standup meeting. Without a routine or direct teammates, it's easy to lose sight of that steady, healthy track of progress that makers should aspire to.

So, I'd like to try an experiment. Every morning around 9:30 I'll post the following prompt in #virtual-standup; anyone in the room is encouraged to check in.


Good morning, @channel -- let's have a quick standup.

  1. What did you get done yesterday?
  2. What are you working on today?
@kylehill
kylehill / closures.js
Created April 23, 2015 16:44
Closures
/*
A "closure" is created whenever
- a function is executed and variables are scoped inside of it, either as params or with var
- that function returns an executable function, either by itself or as part of an object/array
The locally-scoped variables are then "closed over." Like any other variables defined inside of a function,
they are not accessible outside of that scope, but in the special case of a closure they are still accessible
by the **returned function**.
*/
export PATH="/usr/local/bin:$PATH"
export LSCOLORS=GxFxCxDxBxegedabagaced
export CLICOLOR=1
bind "set completion-ignore-case on"
. /usr/local/etc/profile.d/z.sh
alias s="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl ."
alias psql="'/Applications/Postgres.app/Contents/Versions/9.4/bin'/psql -p5432"