View instance-bm.rb
require 'benchmark/ips' | |
class SelfRuby | |
attr_accessor :foo | |
def initialize | |
self.foo = 1 | |
end | |
end | |
# SLOWEST! |
View yield-call-benchmark.rb
require 'benchmark/ips' | |
class A | |
def test | |
10.times do | |
yield | |
end | |
end | |
end |
View poro-hashie-ostruct-benchmark.rb
require 'hashie' | |
require 'ostruct' | |
require 'benchmark/ips' | |
class PORO | |
attr_reader :foo, :bar, :baz | |
def initialize attrs = {} | |
attrs.each do |attr, value| | |
instance_variable_set "@#{attr}", value |
View debugger.rb
(byebug) hello = instance_double("Planet") | |
#<InstanceDouble(Planet) (anonymous)> | |
# Using RSpec block syntax to specific a return value. | |
(byebug) allow(hello).to receive(:world) { "hello, world" } | |
#<RSpec::Mocks::VerifyingMessageExpectation #<InstanceDouble(Planet) (anonymous)>.world(any arguments)> |
View timestamp.proto
// Example lifted from https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | |
// | |
// Example 6: Compute Timestamp from current time in Ruby | |
// | |
// [1] pry(main)> now = Time.now | |
// => 2016-05-20 00:33:04 -0700 | |
// [2] pry(main)> seconds = now.to_i | |
// => 1463729584 | |
// [3] pry(main)> nanos = now.nsec | |
// => 204053000 |
View callback.py
# Example of using callbacks with Python | |
# | |
# To run this code | |
# 1. Copy the content into a file called `callback.py` | |
# 2. Open Terminal and type: `python /path/to/callback.py` | |
# 3. Enter | |
def add(numbers, callback): | |
results = [] | |
for i in numbers: |
View roku.rb
require "io/console" | |
require "socket" | |
require "net/http" | |
require "uri" | |
require 'cgi' | |
SSDP_ADDR = "239.255.255.250"; | |
SSDP_PORT = 1900; | |
SSDP_ST = "roku:ecp"; |
View boot.rb
# Setup the Service::Api | |
Service::Api.set(:environment, :production) | |
Service::Api.set(:root, Service.root) | |
Service::Api.set(:service, Service::Provider.new) |
View ree-1.8.7-2011.03
build_package_patched() { | |
# These three patches are included when RVM builds REE | |
cd source | |
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/tcmalloc.patch' | |
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/stdout-rouge-fix.patch' | |
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/no_sslv2.diff' | |
patch -p1 < tcmalloc.patch | |
patch -p1 < stdout-rouge-fix.patch | |
patch -p1 < no_sslv2.diff | |
cd .. |
View sourcing.io.html
<div class="preview"> | |
<div class="inner"> | |
<img src="/assets/site/placeholder-4abfbbec6d239b5708837804f8149b32.png"> | |
<video preload="auto"> | |
<source src="https://di3zio5pem6rb.cloudfront.net/site/preview.mp4" type="video/mp4"> | |
<source src="https://di3zio5pem6rb.cloudfront.net/site/preview.ogv" type="video/ogv"> | |
<source src="https://di3zio5pem6rb.cloudfront.net/site/preview.webm" type="video/webm"> | |
</video> | |
</div> |
NewerOlder