Skip to content

Instantly share code, notes, and snippets.

View sarahzrf's full-sized avatar

sarahzrf sarahzrf

View GitHub Profile
Array.new(2) { |i|
Thread.new do
binding.pry_remote("localhost", 6000 + i)
end
}.each(&:join)
class Deck
RANKS = %w(2 3 4 5 6 7 8 9 10 J Q K A)
SUITS = %w(s h c d)
def initialize
@cards = RANKS.product(SUITS).map {|r, s| {rank: r, suit: s}}
end
end
#!/usr/bin/perl
use JSON;
use LWP::Simple;
mkdir "album";
get(shift) =~ m/^\s+trackinfo : (.+),$/m;
$dat = from_json($1);
for (@$dat)
{
$_->{title} =~ s/'/'"'"'/g;
$_->{track_num} =~ s/^(\d)$/0\1/;
// ==UserScript==
// @name prev/next with left/right arrows on sites
// @namespace http://omgmog.net
// @description Binds left/right arrow keys to click on urls with rel="prev" and rel="next" -- useful for navigating comic sites and image galleries
// @include http://*
// @version 1.0
// ==/UserScript==
function addJQuery(a){var b=document.createElement("script");b.setAttribute("src","http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js");b.addEventListener("load",function(){var b=document.createElement("script");b.textContent="("+a.toString()+")();";document.body.appendChild(b)},false);document.body.appendChild(b)}
function main(){
/* overflow.c, by sarahzrf
* Demonstrates the pitfalls of undefined behavior.
* Examine the code below and guess what it should output. Then continue
* reading for the answer(s) and an explanation, plus some bonus moralizing!
*/
#include <limits.h>
#include <stdio.h>
void test_overflow(int n, int m) {
module Conway where
import Prelude hiding ((**))
import Data.List
import Data.Maybe
import Data.Ratio
import qualified Data.Map as M
import Control.Monad
data Face = H | T deriving (Show, Eq, Ord, Enum, Bounded)
{-# LANGUAGE Arrows #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE ScopedTypeVariables #-}
#define OD_DEBUG 0
module Collated where
data CQueue a = CQ [a] [a] deriving (Show)
interleave :: [a] -> [a] -> [a]
interleave [] _ = []
interleave (x:xs) ys = x : interleave ys xs
buildCQ :: [a] -> CQueue a
buildCQ l = CQ (interleave l1 (reverse l2)) []
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
module OpenDynamicalVis where
import OpenDynamical
import Control.Arrow
import Linear.Vector
import Linear.Affine
-- import Control.Concurrent
import Data.Time.Clock
class Board
def self.read(stream=$<)
new(5.times.map do
stream.gets.split.map(&:to_i)
end)
end
def initialize(grid)
@num_grid = grid
@mark_grid = grid.map {|row| row.map {false}}