This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'irb' | |
require 'term/ansicolor' | |
require 'open3' | |
module LT | |
module Term class << self | |
include ::Term::ANSIColor | |
end; end | |
end | |
# Monitors all files matching "test_*" in ./test and subfolders for changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def self.ltlog(obj = self) | |
puts "class Hello" | |
if obj.class == Class then | |
puts obj.to_s | |
else | |
puts obj.class.to_s | |
end | |
if obj.kind_of?(String) then | |
puts "Special string object handling here" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yajl/ffi' | |
json = File::open('lr-test.txt') | |
@parser = Yajl::FFI::Parser.new | |
@parser.start_document { puts "start document" } | |
@parser.end_document { puts "end document" } | |
@parser.start_object { |o| | |
puts "start object" | |
puts o.class if o | |
puts 'start o end' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"doc_type": "resource_data", | |
"resource_locator": "http://beyondpenguins.nsdl.org/issue/column.php?date=June2008&departmentid=curriculum&columnid=curriculum!learning", | |
"update_timestamp": "2011-10-28T18:10:00.296692Z", | |
"resource_data": "<nsdl_dc:nsdl_dc xmlns:nsdl_dc=\"http://ns.nsdl.org/nsdl_dc_v1.02/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dct=\"http://purl.org/dc/terms/\" xmlns:ieee=\"http://www.ieee.org/xsd/LOMv1p0\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.openarchives.org/OAI/2.0/\" schemaVersion=\"1.02.020\" xsi:schemaLocation=\"http://ns.nsdl.org/nsdl_dc_v1.02/ http://ns.nsdl.org/schemas/nsdl_dc/nsdl_dc_v1.02.xsd\">\n <dc:identifier xsi:type=\"dct:URI\">http://beyondpenguins.nsdl.org/issue/column.php?date=June2008&departmentid=curriculum&columnid=curriculum!learning</dc:identifier>\n <dc:title>Free Podcasts on Climate and Climate Change</dc:title>\n <dc:description>In partnership with t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pass in an appropriate AR Model for :reset_id_sequence option if you want to reset the sequence after loading | |
# Options include: | |
# :delete_existing_data => truncates all data before loading (default: false) | |
# :sql_parameters => permits specifying sql parameters for COPY such as DELIMETER and NULL (default: '') | |
# :skip_header_row => skips the first row of table when true (default: false) | |
def TableLoader.copy_from_file_to_table(table_name, field_names, import_file_path, options = {}) | |
delete_existing_data = options[:delete_existing_data] || false | |
sql_parameters = options[:sql_parameters] || '' | |
skip_header_row = options[:skip_header_row] || false | |
# expects appropriate model for resetting sequence |
OlderNewer