Skip to content

Instantly share code, notes, and snippets.

View adamyeats-zz's full-sized avatar

Adam Yeats adamyeats-zz

  • Ocasta Studios
  • Brighton, England
View GitHub Profile
@adamyeats-zz
adamyeats-zz / gist:3426030
Last active October 9, 2015 02:47
Get all Twitter followers and status objects (old v1 API)
function sendRequest() {
var username = encodeURIComponent(jQuery('#username').val()),
reqUrl = 'https://api.twitter.com/1/friends/ids.json?screen_name=' + username + '&cursor=-1&stringify_ids=true&callback=?';
return jQuery.getJSON(reqUrl);
}
function getUsers(data) {
var seperatedArray = unflatten(data.ids, 100),
promises = [];
@adamyeats-zz
adamyeats-zz / script.js
Last active April 7, 2017 21:18
Typekit Hack
/*
This small hack loads fonts from the Typekit webfontloader (https://github.com/typekit/webfontloader)
contextually, effectively "patching" in a new font if a media query is fired.
You need to have 2 seperate kits on Typekit, one for your main fonts, and another for the fonts you want
when the media query is fired.
Improvements or suggestions welcome!
@adamyeats-zz
adamyeats-zz / health-endpoint.rb
Last active April 17, 2018 20:05
Server health endpoint based on @dshaw's JSDay tip
# In his JSDay talk (online here: http://dshaw.github.com/2012-05-jsday/), @dshaw proposed having a
# 'health' endpoint for Node servers that gave you important system stats.
#
# Here's an example of what that would look like for Sinatra.
require "time"
require "sinatra"
require "json"
get "/health" do

"Programming is science dressed up as art because most of us don't understand the physics of software and it's rarely, if ever, taught. The physics of software is not algorithms, data structures, languages and abstractions. These are just tools we make, use, throw away. The real physics of software is the physics of people—specifically, our limitations when it comes to complexity, and our desire to work together to solve large problems in pieces. This is the science of programming: make building blocks that people can understand and use easily, and people will work together to solve the very largest problems."

  • Pieter Hintjens, ØMQ - The Guide
@adamyeats-zz
adamyeats-zz / app.js
Last active December 22, 2015 07:18
Charade dreamcode
var Charade = require('charade'),
c = new Charade();
// c.endpoint() creates an endpoint at the root URL
// the endpoint name must be singular as Charade will create a pluralisation
// e.g. GET /users will be magically set up to GET all users
var endpoint = c.endpoint('user');
// At the simplest level, Charade performs CRUD actions against a DB.
// respondsTo('get') will get a singular record (based on req.route.path) from the DB.
@adamyeats-zz
adamyeats-zz / app.js
Last active December 25, 2015 04:59
Presence channel queueing
var pusher = new Pusher(PUSHER_KEY, { authEndpoint: 'pusher_auth.php' });
// use three channels, one for users waiting in the queue (waiting)
// another for users connected to the TV (control)
// another for sending messages to a specific user (user)
var user = pusher.subscribe('user-id'),
waiting = pusher.subscribe('presence-screen'),
control = pusher.subscribe('control');
waiting.bind('pusher:subscription_succeeded', function (members) {
@adamyeats-zz
adamyeats-zz / keyargs.rb
Last active April 17, 2018 20:07
Keyword Arguments in Ruby
def my_method(thing, string: "bacon")
[thing, string]
end
puts my_method("chunky") #=> [chunky, bacon]
puts my_method("awesome", string: "chocolate") #=> [awesome, chocolate]
@adamyeats-zz
adamyeats-zz / gist:11160179
Last active August 29, 2015 14:00
Example Casper test
casper.test.begin('button exists', 1, function(test) {
casper.start('http://localhost:8989/contacts').then(function() {
test.assertExists('#form');
}).run(function() {
test.done();
});
});
var p = $('<p></p>').text(resource.title);
var div = $('<div></div>').addClass('title')
div.append(p).appendTo('#assertion-section');
@adamyeats-zz
adamyeats-zz / Dockerfile
Created October 24, 2014 15:17
Docker WTF
FROM centos:centos6
MAINTAINER Adam Yeats
# Pull base image.
FROM centos:centos6
# Install Node.js
RUN yum install epel-release -y
RUN yum update -y \
&& yum install nodejs npm -y