Skip to content

Instantly share code, notes, and snippets.

View madebydna's full-sized avatar

Andrea Singh madebydna

  • Ad Hoc, LLC
  • CA
  • 19:17 (UTC -07:00)
View GitHub Profile
@madebydna
madebydna / RMU_mentoring.rb
Created April 30, 2011 14:17
RMU Mentoring: Puzzlenode problem #4
#!/usr/bin/ruby
require 'pp'
f = File.open("input.txt", "r")
o = File.open("output.txt", "w+")
cases = f.readlines ''
cases.each do |c|
kase = c.split("\n").map{|i| i.split('')}
nl = kase[0]
@madebydna
madebydna / logo
Created July 2, 2011 14:52
RMU Logo w/Logo
@madebydna
madebydna / logo.rb
Created August 11, 2011 13:35
Turtle solution example (#puzzlenode)
module Logo
module Parser
def self.unroll_repeats(str)
str.gsub(/REPEAT (\d+) \[\s*(.*)\s*\]/) { |x|
$1.to_i.times.map { $2.strip }.join(" ")
}
end
def self.parse(source)
unroll_repeats(source).scan(/(RT|LT|FD|BK)\s+(\d+)/m)
module Stockreturns
class Stockreturns
end
module Application
extend self
def run
@madebydna
madebydna / import_job.rb
Last active July 1, 2022 14:59
Nested Batch workflow with Sidekiq Pro
class ImportJob
include Sidekiq::Worker
sidekiq_options :queue => :import, :retry => false, :backtrace => true
def perform(project_id)
# create master batch
a = Sidekiq::Batch.new
a.description = "Master Batch A"
a.on(:success, "ImportJob#on_success", {"step" => "a"})
logger.info "Master Batch A starting #{a.bid}"
@madebydna
madebydna / day2.rb
Created December 2, 2021 05:36
Advent of Code, Day 2
instructions = File.readlines("input_d2.txt").map(&:chomp!)
x, y = 0, 0
instructions.each do |cmd|
direction, amt = cmd.match(/(forward|up|down) (\d+)/)[1..-1]
case direction
when "forward"
x += amt.to_i
when "up"
y -= amt.to_i

Keybase proof

I hereby claim:

  • I am madebydna on github.
  • I am andrea_singh (https://keybase.io/andrea_singh) on keybase.
  • I have a public key ASABnGyvVjWQ_Aq1XYaqELkoXj8knsKY3I9uZGbY9wBJSQo

To claim this, I am signing this object: