Skip to content

Instantly share code, notes, and snippets.

Sebastian von Conrad vonconrad

Block or report user

Report or block vonconrad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am vonconrad on github.
  • I am vonconrad (https://keybase.io/vonconrad) on keybase.
  • I have a public key ASADOfFy3NsNx3Ly4gtoa8f4zqy2VqYGgjTmi_Otylvj-wo

To claim this, I am signing this object:

@vonconrad
vonconrad / stockholm.md
Last active Feb 19, 2019
Sebastian's guide to Stockholm
View stockholm.md

Sebastian's guide to Stockholm

Where to stay

I always stay with family when I visit, so I don't have a lot of first-hand experience with the accommodation in Stockholm. I'd advise checking out AirBNB as well as hotels though.

  • For a central location, stay in Norrmalm or Östermalm.
    • The best spots (and also most expensive) are on Blaiseholmen and around Nybroviken.
    • There are plenty of places around Centralstationen (Central Station) on Vasagatan as well.
    • Some hotels that I hear are decent: Freys, Royal Viking, Diplomat, Esplanade, Hotel Skeppsholmen, Haymarket, Miss Clara, Kung Carl, Berns--and Grand Hotel of course (though very expensive).
View es_slides.rb
class WeeklyAppointmentsProjector
include Projector
processes_events :appointment_scheduled,
:appointment_rescheduled,
:appointment_name_changed,
:appointment_canceled
table :weekly_appointments do
# ...
end
View gist:229e8bb04165d7d160dd
### Keybase proof
I hereby claim:
* I am vonconrad on github.
* I am vonconrad (https://keybase.io/vonconrad) on keybase.
* I have a public key whose fingerprint is 0B6B 64AE 9967 1923 8727 3EB4 CC0E E50F 0801 280D
To claim this, I am signing this object:
@vonconrad
vonconrad / gist:2373086
Created Apr 13, 2012
MongoDB structure
View gist:2373086

So, I'm putting together a MongoDB database to store XML documents. There are plenty of reasons for why I would want to do something seemingly insane like this; most importantly, I need to be able to see what's changed in the document as well as easily access individual element and attribute values.

I want to store each individual "item" as a row. By "item," I mean each child of the root element. Each item will have standard XML attributes and element children.

Now, one thing to keep in mind: Some of these documents are going to be small (< 100kb), others pretty big (> 100mb). Obviously, plenty in between as well. The documents are going range from a few hundred items to potentially hundreds of thousands.

My initial thought was to have an Item model for each item, with its child elements and attributes as nested documents. Consider this XML doc:

<root>
View benchmark.rb
require 'rubygems'
require 'bcrypt'
require 'digest'
require 'benchmark'
require 'forgery'
password = Forgery(:basic).password(:at_least => 8, :at_most => 20)
Benchmark.bm do |x|
x.report('md5 ') do
View ruby csv benchmarks
# File: 10.1 MB / ~135,000 rows
user system total real
csv 61.090000 0.340000 61.430000 ( 77.955225)
fastercsv 12.990000 0.330000 13.320000 ( 13.826669)
excelsior 0.500000 0.020000 0.520000 ( 0.526380)
ccsv 0.430000 0.020000 0.450000 ( 0.445827)
csvscan 0.400000 0.020000 0.420000 ( 0.423212)
View after_method_missing.rb
class DoNotDisturb
def initialize
@desk = InformationDesk.new
end
def method_missing(name, *args)
unless name.to_s == "emergency"
hour = Time.now.hour
raise "Out for lunch" if hour >= 12 && hour < 14
end
You can’t perform that action at this time.