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
#include <CurieBLE.h> | |
const int ledPin = 13; // set ledPin to use on-board LED | |
BLEPeripheral blePeripheral; // create peripheral instance | |
BLEService alcoholService("29B10000-E8F2-537E-4F6C-D104768A1214"); // create service | |
BLEShortCharacteristic alcoholChar("29B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite | BLENotify); | |
const int termLedPin = 13; | |
const int alcoholSensorPin = 0; |
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
#include <CurieBLE.h> | |
const int ledPin = 13; // set ledPin to use on-board LED | |
BLEPeripheral blePeripheral; // create peripheral instance | |
BLEService alcoholService("29B10000-E8F2-537E-4F6C-D104768A1214"); // create service | |
BLEShortCharacteristic alcoholChar("29B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite | BLENotify); | |
const int termLedPin = 13; | |
const int alcoholSensorPin = 0; |
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
const int pin_a = 10; | |
const int pin_b = 12; | |
const int pin_c = 9; | |
const int pin_d = 4; | |
const int pin_e = 5; | |
const int pin_f = 8; | |
const int pin_g = 11; | |
const int pin_dp = 13; | |
const int dig1 = 2; | |
const int dig2 = 3; |
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
public class Game { | |
public static Player matchUp(Player player1, Player player2) { | |
String left = player1.getStrategy(player2.getStrategySize()); | |
String right = player2.getStrategy(player1.getStrategySize()); | |
for(int i=0; i < left.length(); i++) { | |
char left_hand = left.charAt(i); | |
char right_hand = right.charAt(i); | |
if( left_hand == 'R' && right_hand =='S') { | |
return player1; |
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 Tournament | |
def self.start(players) | |
if players.length == 2 | |
game(players, []).first | |
else | |
left_count = players.length / 2 | |
right_count = players.length - left_count | |
right = players.pop(right_count) | |
left = players |
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 Point | |
attr_accessor :point, :color | |
def initialize(point, color) | |
@point = point | |
@color = color | |
end | |
def toggle | |
@color = color == 'R' ? 'W' : 'R' |
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 WebkitToPng | |
def self.create(urls, options={}) | |
urls.each do |url| | |
puts "convert #{url} to #{options[:dir]}" | |
url.sub!('//', "//#{options[:auth]}@") if options[:auth] | |
op = "-F -D #{options[:dir]} -o #{url.split('/').last}" | |
op += " --user-agent='#{user_agent}'" if options[:mobile] | |
exec(url, op) | |
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
ruby -e 'puts `vm_stat`.gsub!(/([0-9]*)\.$/){ "#{($1.to_i * 4096 / 1000000.0).round(2)}M" }' |
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
@hoges =Kaminari::paginate_array(Hoge.find_by_sql('select * from hoges limit 25'), total_count: 37,).page(1).per(25) | |
paginate @hoges | |
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
# changedの振る舞い | |
t = Event.new | |
param = {:year=>2000, :month=>'', :day=>nil} | |
t.attributes = param | |
t.changed? #=> true | |
t.year_changed? #=> true | |
t.month_changed? #=> false | |
t.day_changed? #=> false | |
t.changes #=> {"year"=>[nil, 2000]} |
NewerOlder