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 Alarm < Sequel::Model | |
| DAYS = %w[sunday monday tuesday wednesday thursday friday saturday] | |
| def self.utc_day_and_time(local_day, local_time, zone = "Etc/UTC") | |
| offset = Timezone::Zone.new(:zone => zone).utc_offset | |
| utc_time = Time.at(local_time.to_i - offset).utc | |
| # Handle day math if UTC time is new day |
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/local/bin/ruby | |
| require "curses" | |
| def print_at_center(str) | |
| lines, cols = Curses.lines, Curses.cols | |
| Curses.clear | |
| Curses.setpos((lines / 2 ) - 1, ((cols - str.length) / 2) - 1) | |
| Curses.addstr(str) | |
| Curses.refresh | |
| 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
| #!/usr/local/bin/ruby | |
| require "curses" | |
| def show_message(message) | |
| width = message.length + 6 | |
| win = Curses::Window.new(5, width, | |
| (Curses.lines - 5) / 2, (Curses.cols - width) / 2) | |
| win.box("|", "-") | |
| win.setpos(2, 3) | |
| win.addstr(message) |
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/local/bin/ruby | |
| require "curses" | |
| begin | |
| Curses.init_screen # bring it | |
| line = "" | |
| str = "Enter a string ('quit' to quit):" | |
| win = Curses::Window.new(5, 50, 10, 10) |
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/local/bin/ruby | |
| require "curses" | |
| begin | |
| Curses.init_screen # bring it | |
| line = nil | |
| win = Curses::Window.new(5, 50, 10, 10) | |
| wout = Curses::Window.new(5, 50, 20, 10) |
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/local/bin/ruby | |
| require "curses" | |
| begin | |
| Curses.init_screen | |
| Curses.noecho | |
| win = Curses::Window.new(Curses.lines-10, Curses.cols - 10, 5, 5) | |
| win.keypad(true) |
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
| ====================== | |
| Google Drive Companion | |
| ====================== | |
| gdriver s # start server | |
| == Upload Files == | |
| gdpush [local file] [remote file] | |
| gdpush /tmp/foo remote/path/bar # push local file /tmp/foo -> remote/path/bar | |
| gdpush /tmp/foo [remote file] # push local file /tmp/foo -> remote /tmp/foo |
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
| # This purpose of this module is to assist developers in moving towards a more | |
| # hexagonal architecture | |
| # | |
| # Driver demo program for hexagonal helper | |
| # | |
| # | |
| # require "./hexagonal_helper.rb" | |
| # | |
| # module Foo; end | |
| # module Foo::Persistence; 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
| 13:37 $ cat parse.rb | |
| require "nokogiri" | |
| require "awesome_print" | |
| def ten_year_key_ratios | |
| # investing.money.msn.com/investments/key-ratios?symbol=aapl&page=TenYearSummary | |
| doc = Nokogiri::HTML File.read("./10_yr_key_ratios") | |
| data = [] | |
| doc.css("table.mnytbl tr").each do |n| | |
| foo = n.search('th/span').map { |x| x.text.strip } |
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 'rubygems' | |
| require 'capybara' | |
| require 'capybara/dsl' | |
| require "selenium-webdriver" | |
| Capybara.run_server = false | |
| Capybara.app_host = 'http://financials.morningstar.com' | |
| Capybara.register_driver :auto_dl do |app| |