Skip to content

Instantly share code, notes, and snippets.

Kuniaki IGARASHI igaiga

Block or report user

Report or block igaiga

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ss.rb
# $ gem i selenium-webdriver
require "selenium-webdriver"
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
# headless指定すると普段Chromeで指定しているフォント指定が効かなくなる
driver = Selenium::WebDriver.for :chrome, options: options
driver.get("https://igarashikuniaki.net/diary/")
driver.save_screenshot("ss.png")
View gem_source.txt
## rubyforge
$ gem sources -l
*** CURRENT SOURCES ***
http://gems.rubyforge.org/
$ gem i awesome_print
ERROR: While executing gem ... (TypeError)
View enc_test.rb
# enc_test.txt に 日本語 を1行書いておく
File.open("enc_test.txt") do |f|
puts out_str = f.each_line.first
puts out_str.encoding
end
puts in_str = "中の日本語"
puts in_str.encoding
@igaiga
igaiga / imgge_uploader.m
Created Nov 10, 2011
Multipart POST to upload jpeg sample code for iOS
View imgge_uploader.m
@interface ImageUploader : NSObject {
NSData *theImage;
}
@property (retain) NSData *theImage;
- (void) syncUpload:(NSData *) uploadImage;
@end
#import "ImageUploader.h"
View hoimi.rb
module Hoimirable
def hoimi
@hp = [@hp + 20, @max_hp].min
end
end
class Sumaltria
include Hoimirable
end
View hash_default_proc.rb
h1 = {}
h1.default= []
h1[:a] = h1[:a] << "hi"
h1[:b] = h1[:b] << "ho"
p h1 #=> {:a=>["hi", "ho"], :b=>["hi", "ho"]}
h2 = {}
h2.default_proc = ->(hash, key){ [] }
h2[:a] = h2[:a] << "hi"
h2[:b] = h2[:b] << "ho"
View smalrubot_sample.rb
require 'smalrubot'
board = Smalrubot::Board.new(Smalrubot::TxRx::Serial.new)
100.times do
p board.analog_read(0)
sleep 1
end
View self.rb
class Foo
p self #=> Foo (Fooクラス)
@bar = "hello!"
def foo
p self #=> #<Foo:0x007ff63a2471f0> (Fooクラスインスタンス)
p @bar = "hi!"
end
def self.foo
p self #=> Foo (Fooクラス)
p @bar #=> "hello!"
View hash_example.rb
h = {}
["a", "a", "b"].each do |x|
h[x] = [] unless h[x]
h[x] << x
end
p h
#=> {"a"=>["a", "a"], "b"=>["b"]}
You can’t perform that action at this time.