This file contains 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" | |
require "benchmark/ips" | |
require "dish" | |
hash = { | |
title: "My Title", | |
authors: [ | |
{ id: 1, name: "Mike Anderson" }, | |
{ id: 2, name: "Well D." } | |
], |
This file contains 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" | |
require "benchmark/ips" | |
range = Array(1..100_000) | |
Benchmark.ips do |x| | |
x.report("each") { range.each { |x| } } | |
x.report("for") { for x in range; end } | |
end |
This file contains 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
class Symbol | |
def [](*args) | |
proc do |object| | |
object.send self, *args | |
end | |
end | |
def ~ | |
proc do |object, *args| | |
object.send self, *args |
This file contains 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
Benchmark.ips do |x| | |
x.report { x="str"; x =~ /foo/ || x =~ /bar/ } | |
x.report { x="str"; x.include?("foo") || x.include?("bar") } | |
x.report { x="str"; x["foo"] || x["bar"] } | |
end |
This file contains 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
["Del", "Delmar", "mar", "mariachi", "chickpea", "pea", "peahen", "henpecking", "ingraining", "ingratiated", "tedious", "ousters", "ersatzes", "zest", "estranging", "ingenuously", "sly", "slyness", "essayist", "isthmus", "mushing", "ingredient", "entertainment", "entryway", "waywardness", "essences", "cession", "ion", "ionization", "ionizer", "zeros", "roses", "sesame", "amelioration", "ionosphere", "erection", "ionospheres", "resale", "alerted", "tediously", "slyest", "establishment", "entrenchment", "entombed", "bedevilment", "entailing", "inglorious", "ousting", "ingested", "tediousness", "essay", "saying", "ingrown", "ownership", "hippie", "piercingly", "glycerin", "ringing", "ingrains", "insurgent", "entertainingly", "glycerol", "rolling", "ingenuousness", "essaying", "ingenuous", "ouster", "terracing", "ingesting", "ingratiating", "ingestion", "ionizing", "ingot", "got", "gotten", "tensing", "ingrates", "testable", "blest", "estimations", "onshore", "ore", "ores", "restructure", "urea", "rears", "arseni |
This file contains 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
def does_care(*a) | |
"hi" | |
end | |
def cares_a_little(*_a) | |
"hi" | |
end | |
def does_not_care(*_) | |
"hi" |
This file contains 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
# I turned the script into a Ruby gem. To install it, first install Rubygems if you haven't already. Instructions are here: https://rubygems.org/pages/download. Next type: sudo gem install trades | |
# | |
# To run the script type: | |
# trades | |
# | |
# Or if you only want to see trades from specific exchanges: | |
# trades mtgoxUSD thUSD britcoinGBP | |
# | |
# You can specify as many exchanges as you want. Just make sure you use the same name Bitcoincharts uses. | |
# |
This file contains 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
on textualcmd(ignore, destination) | |
if destination is equal to "" then | |
return "/debug Invalid destination channel." | |
error number -128 | |
end if | |
-- iTunes | |
if isRunning("iTunes") then | |
tell application "iTunes" | |
if player state is playing then |
This file contains 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 Namespace | |
class String | |
def a | |
String.inspect | |
end | |
def b | |
::String.inspect | |
end | |
end |
This file contains 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
class String | |
def sample | |
slice rand(length) | |
end | |
end | |
puts "hahaha".sample # => "h" |
OlderNewer