This file contains hidden or 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 'moped' | |
| db = Moped::Session.new(["localhost:27017"]) | |
| db.use('foo') | |
| wrapped_result = db.command(:aggregate => 'patient_cache', :pipeline => [ | |
| {'$unwind' => "$values"}, | |
| {'$group' => {'_id' => '$values', 'count' => {"$sum" => 1}}} | |
| ]) |
This file contains hidden or 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 'sinatra' | |
| require 'rack/oauth2' | |
| require 'json' | |
| require 'json/jwt' | |
| def client | |
| # app id, app secret, and site are all test-env specific | |
| Rack::OAuth2::Client.new( | |
| :identifier => 'd7633f880b4771b4f91f107a1a27835e', | |
| :secret => '40dc03bf175980bccd15df10f9db1aa2', |
This file contains hidden or 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
| diff --git a/config.ru b/config.ru | |
| index 88a4115..d453cc6 100644 | |
| --- a/config.ru | |
| +++ b/config.ru | |
| @@ -7,6 +7,31 @@ require 'warden' | |
| require 'warden_omniauth' | |
| require 'yaml' | |
| +module OpenIDConnect | |
| + class AccessToken |
This file contains hidden or 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
| host: localhost | |
| client_id: "4119a135-63cf-4074-bcc5-6e9619b71d55" | |
| client_secret: "rhexrhex" | |
| additional_properties: | |
| authorization_endpoint: "/simpledb-openid-connect-server/authorize" | |
| user_info_endpoint: "/simpledb-openid-connect-server/userinfo?schema=openid" | |
| token_endpoint: "/simpledb-openid-connect-server/token" | |
| jwk_url: "/jwk" | |
| issuer: "http://localhost:8080/simpledb-openid-connect-server/" | |
| scope: "openid profile" |
This file contains hidden or 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 'rest_client' | |
| require 'json' | |
| class Twitter | |
| def initialize(username) | |
| @username = username | |
| end | |
| def timeline | |
| raw_json = RestClient.get "http://api.twitter.com/1/statuses/user_timeline.json?screen_name=#{@username}" |
This file contains hidden or 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 'minitest/autorun' | |
| require 'properties' | |
| class PropertiesTest < MiniTest::Unit::TestCase | |
| class Foo | |
| extend Properties | |
| property :bar | |
| end | |
| def setup |
This file contains hidden or 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 Properties | |
| def property(property_name) | |
| define_method(property_name) do | |
| instance_variable_get("@#{property_name}".to_sym) | |
| end | |
| define_method("#{property_name}=".to_sym) do |value| | |
| instance_variable_set("@#{property_name}".to_sym, value) | |
| end | |
| end |
This file contains hidden or 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 'mongo' | |
| require 'ap' | |
| include Mongo | |
| # Create a connection to a local MongdDB Instance | |
| db = Connection.new.db('underscore-demo') | |
| # Read and eval Underscore.js | |
| underscore = File.read('underscore-min.js') |
This file contains hidden or 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
| # Install the gem, then | |
| require 'v8' | |
| cxt = V8::Context.new | |
| cxt["effectiveTime"] = Time.gm(2010, 9, 19).to_i | |
| cxt.eval("effectiveTime - (365 * 24 * 60 * 60)") #=> 1253318400 |
This file contains hidden or 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
| Gwibber Dispatcher: DEBUG <twitter:receive> Performing operation | |
| Traceback (most recent call last): | |
| File "/usr/lib/python2.6/dist-packages/gwibber/microblog/network.py", line 32, in __init__ | |
| self.curl.perform() | |
| error: (6, 'name lookup timed out') | |
| Gwibber Dispatcher: ERROR Failed to communicate with http://api.flickr.com/services/rest?username=eedrummer&api_key=36f660117e6555a9cbda4309cfaf72d0&nojsoncallback=1&method=flickr.people.findByUsername&format=json | |
| Gwibber Dispatcher: ERROR Failed to parse the response, error was: No JSON object could be decoded | |
| Gwibber Dispatcher: ERROR <flickr:images> Operation failed | |
| Traceback (most recent call last): | |
| File "/usr/lib/python2.6/dist-packages/gwibber/microblog/network.py", line 32, in __init__ |