Skip to content

Instantly share code, notes, and snippets.

View science's full-sized avatar

Steve Midgley science

  • California, USA
View GitHub Profile
@science
science / instance-class-include.rb
Last active August 29, 2015 14:12
How to "include" Instance and Class methods into a class in ruby
module Lib
# this loads our class methods when called by "include"
def self.included(base)
base.extend(ClassMethods)
# code here will run when lib is imported, in Lib module context
puts "Lib context: #{self.to_s}"
# this calls the lib_init method to run any class set up code
base.send(:lib_init)
end
import java.util.HashMap;
public class CodeRunner {
TestClass testClass = new TestClass();
String answer_format = "Test1: %s\nTest2: %s";
static String default_output_template = "Correct answers:\nTest1=%s\nTest2=%s\n";
public static void main(String[] args) {
CodeRunner code = new CodeRunner();
HashMap answers = code.tests();
@science
science / lrmi-download.rb
Created July 25, 2013 02:30
Ruby script to pull all LRMI documents from Learning Registry and save them to local files
require 'json'
require 'net/http'
# adds resumption token to URL if needed
def slice_url(options ={})
resume = options[:resume]
url = "http://node01.public.learningregistry.net/slice?any_tags=lrmi"
if resume
url = "http://node01.public.learningregistry.net/slice?any_tags=lrmi&resumption_token=#{resume}"
end
# Scans a CouchApp folder for changes, and on detection auto pushes to Couch
# this allows you to simply save your JS files and test them from CLI without re-loading manually every time
# (c) Steve Midgley 2011
# Released under Apache 2.0 license
# (http://www.apache.org/licenses/LICENSE-2.0.html)
require 'rake'
def running_windows?
!(RUBY_PLATFORM =~ /win32/).nil?
// (c) Steve Midgley 2011
// Released under Apache 2.0 license
// (http://www.apache.org/licenses/LICENSE-2.0.html)
// Use: This file validates an incoming CouchDB JSON document for compatibility
// with Learning Registry specification (currently 0.15.0)
// Install: For use with CouchDB/CouchApp. This file goes in the root
// of a CouchApp, and should be pushed along with the rest of the app:
// E.g., "couchapp push"