Skip to content

Instantly share code, notes, and snippets.

@MichaelXavier
MichaelXavier / gist:9488102
Created March 11, 2014 15:26
rvm failing to build new rubies
compiling callback-2.c
make[2]: Leaving directory '/home/michael/.rvm/src/ruby-2.1.1/ext/date'
make[2]: Entering directory '/home/michael/.rvm/src/ruby-2.1.1/ext/mathn/complex'
compiling complex.c
installing default complex libraries
linking shared-object mathn/complex.so
make[2]: Leaving directory '/home/michael/.rvm/src/ruby-2.1.1/ext/mathn/complex'
compiling callback-3.c
installing default parser libraries
linking shared-object json/ext/parser.so
@MichaelXavier
MichaelXavier / age.hs
Created June 26, 2014 00:43
Age in context
{-# LANGUAGE FlexibleContexts #-}
module Main (main) where
import Control.Monad.Reader
type Year = Int
-- a person record has a birth year
data Person = Person { birthYear :: Year }
{-# LANGUAGE OverloadedStrings #-}
data GUIEvent = KeyDownEvent { key_down__ctrl :: !Bool
, key_down__shift :: !Bool
, key_down__code :: !Int }
| MouseEvent { mouse__x :: !Int
, mouse__y ::!Int }
deriving (Show)
instance FromJSON GUIEvent where
parseJSON = withObject "GUIObject" parseGUIEvent
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Data.Monoid
import Test.QuickCheck
data JoinList m a = Empty
| Single m a
| Append m (JoinList m a) (JoinList m a)
@MichaelXavier
MichaelXavier / loop_functions.js
Created December 15, 2014 15:39
reasonable use of defining functions in a loop?
function OOPShim() {
}
function proxyMethods(names) {
for (var i = 0; i < names.length; i++) {
var name = names[i];
OOPShim.prototype[name] = function(a) {
var args = Array.prototype.slice.call(arguments, 0);
args.unshift(this.state);
return FunctionalAPI[name].apply(this, args)();
require 'test_helper'
class CheckinProcessingTest < ActionController::IntegrationTest
context "a user filling out the checkin form" do
should "do his thing" do
visit '/'
#fill out the account form
select 'No', :from => 'account[prev_cust_claim]'
#!/usr/bin/env ruby
#
# A one file test to show ...
require 'rubygems'
require 'dm-core'
# setup the logger
DataMapper::Logger.new(STDOUT, :debug)
#!/usr/bin/env ruby
require 'optparse'
require 'rest_client'
require 'open-uri'
CLIENT_LOGIN_URI = URI.parse('https://www.google.com/accounts/ClientLogin')
CLIENT_LOGIN_HEADERS = {'Content-type' => 'application/x-www-form-urlencoded'}
SERVICE = 'mail'
ACCOUNT_TYPE = 'GOOGLE'
SOURCE = 'myaname-myprogram-0.0.1'
ORG $1000
START: ; first instruction of program
green_t EQU 60
yello_t EQU 5
lights EQU $2000
timer EQU $2001
n_ymask EQU %100010 ; EW will be red when NS yellow
n_gmask EQU %100001
e_ymask EQU %010100
e_gmask EQU %001100
class MyDir < Dir
class << self
def [](args)
super(args).collect {|entry| do_junk(entry)}
end
end
end
describe MyDir
before do