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 'thread' | |
require 'bundler/setup' | |
require 'system' | |
from, to = Queue.new, Queue.new | |
item_count = rand(100) + 100 | |
thread_count = (System::CPU.count * 4) | |
(1..item_count).each { |item| from.push(item) } |
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 System | |
extend self | |
def cpu_count | |
return Java::Java.lang.Runtime.getRuntime.availableProcessors if defined? Java::Java | |
return File.read('/proc/cpuinfo').scan(/^processor\s*:/).size if File.exist? '/proc/cpuinfo' | |
require 'win32ole' | |
WIN32OLE.connect("winmgmts://").ExecQuery("select * from Win32_ComputerSystem").NumberOfProcessors | |
rescue LoadError | |
Integer `sysctl -n hw.ncpu 2>/dev/null` rescue 1 | |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>My Site</title> | |
<style type="text/less"> | |
.clearfix:after { | |
content: "."; |
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
int limit = 100; | |
// moop through each number from 1 to the limit (100) | |
for(int i=1; i <= limit; i++){ | |
// everything in this block of code will be ran for each number | |
// if the number is divisible by 2 then it is even | |
if (i % 2 == 0) { | |
// print out the number with a space after it | |
System.out.print(i + " "); |
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
Function::define = (prop, desc) -> | |
Object.defineProperty this.prototype, prop, desc | |
class GetterSetterTest | |
constructor: (@_obj = {}) -> | |
# 'obj' is defined via the prototype, the definition proxied through | |
# to 'Object.defineProperty' via a function called 'define' providing | |
# some nice syntactic sugar. Remember, the value of '@' is | |
# GetterSetterTest itself when used in the body of it's class definition. |
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 CacheableAttr | |
def cacheable_attr(*attributes) | |
opts = { ttl: 60 } | |
opts = opts.merge(attributes.pop) if attributes.last.is_a?(Hash) | |
attributes.each do |attribute| | |
define_method attribute do | |
if !instance_variable_defined?("@#{attribute}_updated_at") || (opts[:ttl] != nil && Time.now >= instance_variable_get("@#{attribute}_updated_at") + opts[:ttl]) | |
value = send("#{attribute}_uncached") |
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
ActiveRecord::Schema.define(:version => 00000000000000) do | |
create_table "users", :force => true do |t| | |
t.string "username", :default => "", :null => false | |
t.string "email", :default => "", :null => false | |
t.string "encrypted_password", :default => "", :null => false | |
# Devise fluff here... | |
t.string "first_name", :default => "", :null => false |
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
/Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:503:in `load_missing_constant': Expected /Users/Ryguy/Code/Ruby/Gems/proctor/app/models/client.rb to define Client (LoadError) | |
from /Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:192:in `block in const_missing' | |
from /Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in `each' | |
from /Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in `const_missing' | |
from /Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:229:in `block in constantize' | |
from /Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:228:in `each' | |
from /Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/infle |
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
# omitted... | |
RSpec.configure do |config| | |
# omitted... | |
config.before(:suite) do | |
if RUBY_PLATFORM =~ /darwin/ | |
# Focus on Terminal | |
system %{osascript -e 'tell application "Terminal" to activate'} | |
# Send CMD+K to clear |
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
ryguy@RyBook ~/Code/Ruby/Scratchpad/slop-test $ gem list slop | |
*** LOCAL GEMS *** | |
slop (3.1.1) | |
ryguy@RyBook ~/Code/Ruby/Scratchpad/slop-test $ cat test.rb | |
require 'slop' | |
opts = Slop.new do |