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
| DO | |
| $$ | |
| DECLARE | |
| s name; | |
| t name; | |
| rowc bigint; | |
| BEGIN | |
| FOR s, t IN select table_schema, table_name | |
| from information_schema.tables |
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 'benchmark/ips' | |
| class SelfRuby | |
| attr_accessor :foo | |
| def initialize | |
| self.foo = 1 | |
| end | |
| end | |
| # SLOWEST! |
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 'benchmark/ips' | |
| class A | |
| def test | |
| 10.times do | |
| yield | |
| end | |
| 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 '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 |
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
| (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)> |
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
| // 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 |
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
| # 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: |
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 "io/console" | |
| require "socket" | |
| require "net/http" | |
| require "uri" | |
| require 'cgi' | |
| SSDP_ADDR = "239.255.255.250"; | |
| SSDP_PORT = 1900; | |
| SSDP_ST = "roku:ecp"; |
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
| # Setup the Service::Api | |
| Service::Api.set(:environment, :production) | |
| Service::Api.set(:root, Service.root) | |
| Service::Api.set(:service, Service::Provider.new) |
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
| 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 .. |
NewerOlder