Skip to content

Instantly share code, notes, and snippets.

View ruffrey's full-sized avatar
🥦

ruffrey ruffrey

🥦
View GitHub Profile
@ruffrey
ruffrey / keybase.md
Last active September 2, 2016 03:46

Keybase proof

I hereby claim:

  • I am ruffrey on github.
  • I am ruffrey (https://keybase.io/ruffrey) on keybase.
  • I have a public key whose fingerprint is 2F0D E27F 91D3 B701 1BF8 8376 FA24 5B5F 7252 8C7D

To claim this, I am signing this object:

@ruffrey
ruffrey / turnserver.conf
Created January 31, 2016 18:41
rfc5766-turn-server config file (/etc/turnserver.conf)
lt-cred-mech=1
realm=<IP ADDRESS>
relay-ip=<IP ADDRESS>
listening-ip=<IP ADDRESS>
tls-listening-port=5349
@ruffrey
ruffrey / getty-image-search-example.js
Created December 15, 2015 16:02 — forked from anonymous/getty-image-search-example.js
Example of doing an image search on getty images and doing something with the first result
var API_KEY_NOT_SECRET = 'insert here';
var xhr = new XMLHttpRequest();
xhr.onload = function () {
console.log('response', JSON.parse(xhr.responseText));
var img = document.createElement('img');
img.src = JSON.parse(xhr.responseText).images[0].display_sizes[0].uri;
document.getElementsByTagName('body')[0].appendChild(img);
};
xhr.onerror = function (e) { console.error(e); };
@ruffrey
ruffrey / pixies.js
Last active August 29, 2015 14:09
pixies
/*!
* Based on pixies particle parallax example by Timothy Poon.
* http://timothypoon.com/blog/demos/canvas-particle-parallax/
* Copyright timothycpoon@gmail.com
* licensed BSD 3-clause http://opensource.org/licenses/BSD-3-Clause
*
* Edited gingerly by @ruffrey
* licensed MIT http://opensource.org/licenses/MIT
*/
(function () {
@ruffrey
ruffrey / dateSuffixFilter.js
Created September 25, 2014 13:06
An Angular filter for outputting the date suffix - th, st, nd, rd
var app = angular.module('app', []);
app.filter('dateSuffix', function ($filter) {
var suffixes = ["th", "st", "nd", "rd"];
return function (input) {
var dtfilter = $filter('date')(input, 'dd');
var day = parseInt(dtfilter, 10);
var relevantDigits = (day < 30) ? day % 20 : day % 30;
var suffix = (relevantDigits <= 3) ? suffixes[relevantDigits] : suffixes[0];
return suffix;
@ruffrey
ruffrey / .block
Last active March 3, 2022 12:53
HTML5 Canvas Pong with AI
license: mit
@ruffrey
ruffrey / listRoutesController.js
Last active August 29, 2015 14:03
Generating documentation from Node Express routes
function listRoutes(req, res, next) {
var routes = 'get post patch put delete', // which methods do you want to inspect?
ordered = [],
Controller = new require('../classes/Controller'),
tempController = new Controller("Account"),
No = tempController.no.toString(),
Plural = tempController.plural.toString(),
reString = config.odm.models.map(
function(m){
@ruffrey
ruffrey / extract-from-page.js
Created July 14, 2013 15:21
JSON of GMT offsets and names of places for each of the offsets. Extracted from http://en.wikipedia.org/wiki/List_of_UTC_time_offsets
// Run this code from the javascript console on the following wikipedia page to generate the output JSON:
// http://en.wikipedia.org/wiki/List_of_UTC_time_offsets
var u = {};
function sr(k){
return function(){
if($(this).text().indexOf('[')==-1)
u[k].push($(this).text());
};
@ruffrey
ruffrey / events-list.html
Last active December 19, 2015 00:19
Example events list which displays event time period. From bootstrap-calendar (tmpls): https://github.com/Serhioromano/bootstrap-calendar
<span class="hide" id="cal-slide-tick"></span>
<div id="cal-slide-content">
<ul class="unstyled">
<% _.each(events, function(event){ %>
<li>
<span class="pull-left event <%= $(event).data('event-class') %>"></span>&nbsp;
<a href="<%= $(event).attr('href') %>" target="_blank"
data-event-id="<%= $(event).data('event-id') %>"
data-event-class="<%= $(event).data('event-class') %>"
class="event-item">