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 Puzzle | |
| def initialize(n=3) | |
| @size = n | |
| @goal = (n ** 2).times.to_a.rotate | |
| end | |
| def resolve(start) | |
| raise 'invalid size' unless start.size == @goal.size | |
| visited = Set.new | |
| queue = [[start]] |
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 PeriodicCue | |
| def initialize(*interval) | |
| @interval = interval.cycle | |
| @time = nil | |
| end | |
| def sleep_until(t) | |
| sleep((t - Time.now).clamp(0..)) | |
| 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 'singleton' | |
| require 'monitor' | |
| require 'drb' | |
| module DRb | |
| class DRbObjectSpace | |
| include Singleton | |
| include MonitorMixin | |
| def initialize |
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 'erb' | |
| class MySVG | |
| include ERB::Util | |
| SRC = <<EOS | |
| <svg xmlns='http://www.w3.org/2000/svg'><% | |
| x = 10 | |
| dy = 18 | |
| y = dy | |
| font = 16 |
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 'rinda/tuplespace' | |
| class Rdv | |
| def initialize(ts=nil) | |
| @ts = ts || Rinda::TupleSpace.new | |
| end | |
| def select?(*chan) | |
| template = Template.new(*chan) | |
| t, k = @ts.take([template, nil]) |
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 'erb' | |
| class ERB | |
| class ERBOut | |
| Buffer = String # SafeBuffer if rails | |
| def initialize(s='') | |
| @str = Buffer.new(s) | |
| 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
| <!DOCTYPE html> | |
| <html lang="ja"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <style> | |
| .bubble { | |
| transition: all 0.5s; | |
| } | |
| </style> |
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 'serialport' | |
| require 'json' | |
| class EpeaNdir07 | |
| def initialize | |
| @dev = "/dev/tty.usbserial-12210" | |
| end | |
| def get_ppm | |
| sp = SerialPort.new(@dev, 115200) |
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
| name = ARGV.shift || 'p5.pgm' | |
| buf = "P5 256 256 65535\n" + (0...(256 ** 2)).to_a.pack('n*') | |
| File.write(name, buf) |
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 'discordrb' | |
| module Discordrb::Voice | |
| class VoiceBot | |
| def play_internal | |
| count = 0 | |
| @playing = true | |
| # Default play length (ms), will be adjusted later | |
| @length = IDEAL_LENGTH |
NewerOlder