Skip to content

Instantly share code, notes, and snippets.

View vonconrad's full-sized avatar

Sebastian von Conrad vonconrad

View GitHub Profile

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 August 12, 2023 16:13
Sebastian's guide to Stockholm

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).
class WeeklyAppointmentsProjector
include Projector
processes_events :appointment_scheduled,
:appointment_rescheduled,
:appointment_name_changed,
:appointment_canceled
table :weekly_appointments do
# ...
end
### 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 April 13, 2012 02:29
MongoDB structure

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>
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
# 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)
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