Skip to content

Instantly share code, notes, and snippets.

View madebydna's full-sized avatar
🏠
Working from home

Andrea Singh madebydna

🏠
Working from home
  • Ad Hoc, LLC
  • CA
  • 03:38 (UTC -07:00)
View GitHub Profile

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:

@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
@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}"
module Stockreturns
class Stockreturns
end
module Application
extend self
def run
@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)
@madebydna
madebydna / logo
Created July 2, 2011 14:52
RMU Logo w/Logo
@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]
<?xml version="1.0" encoding="UTF-8"?>
<sphinx:docset>
<sphinx:schema>
<sphinx:field name="keywords"/>
.... other fields and attributes omitted
</sphinx:schema>
<sphinx:document id="163">
<title>Logic of Architecture</title>
<keywords>Architekturtheorie, Entwurfsprozess in der Architektur, Computer Aided Design, S&#228;ulenordnungen, Formengrammatik</keywords>
</sphinx:document>
class Address < ActiveRecord::Base
DELTA = 0.001
validates :line1, :city, :presence => true
belongs_to :country
belongs_to :organisation
belongs_to :person
belongs_to :address_type
belongs_to :service
@madebydna
madebydna / table_simple.rb
Created January 7, 2011 03:39
simple table implementation with tests
class Table
attr_reader :rows, :headers, :header_support
def initialize(data = [], options = {})
@header_support = options[:headers]
@headers = @header_support ? data.shift : []
@rows = data
end
def column_index(pos)