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
#!/bin/sh | |
# requires graphicsmagick (brew install graphicsmagick) | |
for i in 1 2 3 4 5 | |
do | |
gm convert \ | |
-size 200x200 \ | |
xc:black \ | |
-gravity center \ | |
-fill white \ |
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 "test/unit" | |
require "./at-and-at-at-class" | |
class TestAtAtVariables < Test::Unit::TestCase | |
def test_direct_assignment | |
SampleClass.c = 1 | |
assert_equal(1, SampleClass.c) | |
refute_equal(1, SampleSubClassA.c) | |
refute_equal(1, SampleSubClassB.c) | |
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 "test/unit" | |
require "./at-and-at-at-class" | |
class TestAtAtVariables < Test::Unit::TestCase | |
def test_direct_assignment | |
SampleClass.b = 1 | |
assert_equal(1, SampleClass.b) | |
refute_equal(1, SampleSubClassA.b) | |
refute_equal(1, SampleSubClassB.b) | |
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 "test/unit" | |
require "./at-and-at-at-class" | |
class TestAtAtVariables < Test::Unit::TestCase | |
def test_direct_assignment | |
SampleClass.a = 1 | |
assert_equal(1, SampleClass.a) | |
assert_equal(1, SampleSubClassA.a) | |
assert_equal(1, SampleSubClassB.a) | |
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
class SampleClass | |
# (#1) class-level setter and getter for a | |
def self.a=(value) | |
@@a = value | |
end | |
def self.a | |
@@a | |
end | |
# (#2) instance-level setter and getter for a |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu/vivid64" | |
config.vm.network "forwarded_port", guest: 3000, host: 3000 | |
config.vm.provider "virtualbox" do |vb| | |
vb.memory = "1024" | |
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
def timer | |
start_time = Time.now | |
1_000_000.times do | |
yield | |
end | |
Time.now - start_time | |
end | |
time_a = timer do | |
x = "this this this this this this this this this this this this this this this " + |
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 'minitest/autorun' | |
class Monkey | |
@@m1 = "monkey" | |
class << self | |
attr_accessor :m2 | |
end | |
def self.m1=(m) |
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
#!/usr/bin/env ruby | |
require "thor" | |
require "yaml" | |
require "open3" | |
class App < Thor | |
MAILLOG_REGEX = /^.+:(?<timestamp>\w+\s+\d+ \d\d+:\d\d:\d\d) (?<server>[^\s]+) .+ to=<(?<to>[^>]+)>.+ relay=(?<relay>[^,]+),.+status=(?<status>.+)$/ | |
# other mail analysis-type stuff... | |
NewerOlder