Skip to content

Instantly share code, notes, and snippets.

View ryanmr's full-sized avatar

Ryan Rampersad ryanmr

View GitHub Profile
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
ryanmr / gist:4230184
Created December 7, 2012 02:11
updated, still bugged, dimensions error at 32
/* 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
ryanmr / abstar.cff.cpp
Last active December 17, 2015 05:49
which do you like better? else if on the same bracket line or on their own new line?
void ABStar::Final() {
platform->enter_state();
if ( platform->get_nextChar() == 'a' ) {
platform->set_outputBuffer("In Final, found A");
platform->next_state();
NeedB();
} else if ( platform->get_nextChar() != '\0' ) {
platform->set_outputBuffer("In Final, found something other than B");
platform->next_state();
@ryanmr
ryanmr / feed.php
Last active December 21, 2015 02:28
Include related episodes in the feed by getting the usual posts, reading their post meta value, and then re-running the query
<?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
ryanmr / utility.php
Created September 6, 2013 05:57
Original human_time_difference function; given a timestamp and optionally another, it will return the largest reasonable time differential between the two.
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'),
/*
Use ifupdown.com/putnam/generator.html
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.support.v7.widget.RecyclerView;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
#!/bin/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
exit
use std::io;
use std::rand;
struct Monte {
h: uint,
k: uint,
r: uint
}
fn main() {
@ryanmr
ryanmr / simul.rs
Last active August 29, 2015 14:12
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) {