Skip to content

Instantly share code, notes, and snippets.


Ryan Rampersad ryanmr

View GitHub Profile
View gist:264220
var body = $(document.body);
var b = body.getElement("b");
//Listener class executes a logging function each time a method is called.
var Listener = new Class({
listenStack: {},
addListener: function(mth, fn) {
this.listenStack[mth] = this[mth];
this[mth] = function() {
var rtrn = this.listenStack[mth].attempt(arguments);
ryanmr / gist:4230184
Created Dec 7, 2012
updated, still bugged, dimensions error at 32
View gist:4230184
/* begin clever */
pixel get_pixel(int dim, int i, int j, pixel *src) {
return src[RIDX(i, j, dim)];
void four_corners(int dim, pixel *src, pixel *dst) {
pixel top_left = src[RIDX(0, 0, dim)];
pixel top_right = src[RIDX(0, dim, dim)];
ryanmr / abstar.cff.cpp
Last active Dec 17, 2015
which do you like better? else if on the same bracket line or on their own new line?
View abstar.cff.cpp
void ABStar::Final() {
if ( platform->get_nextChar() == 'a' ) {
platform->set_outputBuffer("In Final, found A");
} else if ( platform->get_nextChar() != '\0' ) {
platform->set_outputBuffer("In Final, found something other than B");
ryanmr / feed.php
Last active Dec 21, 2015
Include related episodes in the feed by getting the usual posts, reading their post meta value, and then re-running the query
View feed.php
// pre_get_posts is hooked to run `include_the_fringe`
public function include_the_fringe( $query ) {
if ( $query->is_feed() && $query->is_main_query() && isset($_GET['fringe']) ) {
$ids = $this->find_fringe_episodes($query);
// $ids = json_decode('["490","491","381","245","219","168","132","130","126","122"]');
ryanmr / utility.php
Created Sep 6, 2013
Original human_time_difference function; given a timestamp and optionally another, it will return the largest reasonable time differential between the two.
View utility.php
public static function human_time_difference($from, $to = '') {
if ( empty($to) ) {
$to = time();
$periods = array(
'minutes' => array('%s minute', '%s minutes'),
'hours' => array('%s hour', '%s hours'),
'days' => array('%s day', '%s days'),
'weeks' => array('%s week', '%s weeks'),
View grid.c
to generate a matrix and global values.
Then paste that generated code here.
void loop() {
package com.ifupdown.odin.adapters;
import android.content.Context;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
View record.bash
# don't forget to include ADB in your path
# for example, in your ~/.bashrc, somewhere near the top
# export PATH=$PATH:/path/to/android-sdk/sdk/platform-tools
# check if there is a filename
if [ -z "$1" ]; then
echo usage: $0 filename
use std::io;
use std::rand;
struct Monte {
h: uint,
k: uint,
r: uint
fn main() {
fn multi() {
let tasks:uint = 4;
let (tx, rx): (Sender<uint>, Receiver<uint>) = channel();
let mut senders = Vec::<Sender<uint>>::new();
let mut receivers = Vec::<Receiver<uint>>::new();
for i in range(0, tasks) {