( Source: the mongoid cheatsheet )
class User
include Mongoid::Document
| # Simple and Stupid Ruby API for Coderwall.com | |
| # Vivien Didelot <vivien@didelot.org> | |
| require "open-uri" | |
| require "json" | |
| module CoderWall | |
| class Achievement | |
| attr_reader :name, :badge, :description |
| /* | |
| * | |
| * coderwall.js | |
| * | |
| * Code to display coderwall.com badges | |
| * | |
| */ | |
| var coderwallJSONurl ="http://www.coderwall.com/hermanjunge.json?callback=?"; | |
| var height = 75; |
| match = request.env['REQUEST_URI'].match(/(\/.*)/) | |
| if match | |
| redirect "http://www.#{host}#{match[1]}",301 | |
| else | |
| redirect "http://www.#{host}/",301 | |
| end |
| #!/usr/bin/env ruby | |
| if ARGV.size < 1 | |
| puts "usage: t_extrator dir" | |
| exit(1) | |
| end | |
| Dir.glob("#{ARGV[0]}/**/*").each do |file| | |
| if FileTest.file? file | |
| c = File.read(file) |
| # original source: http://code.activestate.com/recipes/483732-asynchronous-port-forwarding/ | |
| import socket | |
| import asyncore | |
| class forwarder(asyncore.dispatcher): | |
| def __init__(self, ip, port, remoteip,remoteport,backlog=5): | |
| asyncore.dispatcher.__init__(self) | |
| self.remoteip=remoteip | |
| self.remoteport=remoteport |
( Source: the mongoid cheatsheet )
class User
include Mongoid::Document
| In response to all the responses to: | |
| http://twitter.com/rtomayko/status/1155906157 | |
| You should never do this in a source file included with your library, | |
| app, or tests: | |
| require 'rubygems' | |
| The system I use to manage my $LOAD_PATH is not your library/app/tests |
| #!/usr/bin/ruby | |
| require 'tempfile' | |
| if ARGV.size < 3 | |
| # Example test_runner unit post "can delete" | |
| puts "usage: test_runner [type=unit,functional,integration] [testname] [testmethod]" | |
| exit | |
| end | |
| class TestRunner |
| --[[ | |
| Simple Class Implementation for Lua using Metetables. | |
| This is very clean and simple, sticking to some very | |
| simple principles. | |
| Static methods defined with . (dot) and instance methods | |
| with : (semicolon) . | |
| Default values declared when defining the initial table. | |
| The .new static method implements the constructor which |