Skip to content

Instantly share code, notes, and snippets.

View moonglum's full-sized avatar

Lucas Dohmen moonglum

View GitHub Profile
@moonglum
moonglum / ideas.js
Created December 4, 2013 20:28
Ideas for Foxx from the discussion with @mulderp
// Feedback Foxx
Movie = Model.extend({
// attribute? schema?
schema: {
// Long Form
// title: {
// required: false,
// defaultValue: "Unknown",
// type: "String"
@moonglum
moonglum / media-center.md
Created October 6, 2013 08:15
Ok, Nerds. I need some help here.

Media Center

Given I have a Beamer and a Soundbar and I would want to watch movies from an external HDD, the web (Flash + HTML5) and BluRay/DVD. Plus would be Airplay Mirroring, but it's not necessary.

I want to choose the core of this media center. What would you choose? Why?

require "ashikawa-core"
db = Ashikawa::Core::Database.new do |config|
config.url = "http://localhost:8529"
end
collection = db["documenttests"]
document = collection.create_document(:name => "The Dude")
document_key = document.key
@moonglum
moonglum / CommonRescue.rb
Last active December 14, 2015 05:40
A question of taste...
# Imagine you need to "translate" certain exceptions in a
# wrapper around an external library.
# These exceptions can occur in multiple methods, so you
# want to reuse the translation mechanism.
#
# How do you do it? I came up with two solutions:
# 1. Solution: The Bubblewrap
def get_request(params)
bubblewrap_request do
@moonglum
moonglum / fizzbuzz.html
Last active November 24, 2015 13:47
This is a FizzBuzz Solution I found on Twitter. It was always shared as a screenshot, so I typed it myself, to try it out ;) Source: https://twitter.com/ericwastl/status/667567483432402944
<html>
<head>
<style>
body {
counter-reset: n;
}
div:before {
counter-increment: n;
content: counter(n);
}
@moonglum
moonglum / mongo_visitor.rb
Created November 24, 2012 14:33
I don't really understand this behavior
relation = base_relation.restrict do |r|
r.name.eq "Cologne"
end.sort_by do |r|
[ r.name, r.country ]
end
mongo_visitor = Veritas::Adapter::Mongo::Visitor.new relation
p mongo_visitor.query
#=> {:name=>"Cologne"}
@moonglum
moonglum / ashikawa.rb
Created November 17, 2012 09:33
A small example for Arrays in Ashikawa::AR
require "ashikawa-ar"
Ashikawa::AR.setup :default, "127.0.0.1:8529"
class MyFineModel
include Ashikawa::AR::Model
attribute :name
# This is where the magic happens!
attribute :my_strings, Array[String]
@moonglum
moonglum / Gemfile
Created October 19, 2012 11:06
Potential Subquery Problem
source :rubygems
gem "ashikawa-core", "~> 0.3.0"
@moonglum
moonglum / top.rb
Created August 18, 2012 11:33
`Top -p <PID> -b` Parser
#! /usr/bin/env ruby
## Parses results from:
# `top -p <PID> -b`
start = 0
File.read(ARGV[0]).each_line do |line|
if line.match(/^\d+/)
parsed = line.split
cpu = parsed[2]
@moonglum
moonglum / notes.mdown
Created August 3, 2012 20:21
Notes on: Building a Ruby Library, the Parts No One Talks About

Notes on: Building a Ruby Library, the Parts No One Talks About

by Mitchell Hashimoto at Euruko 2012 and the according Video

  • Idiomatic Ruby: Don't try to be cool
  • Configurable
    • Plain old Ruby – config should have NO MAGIC
    • Central configuration – keep it in one place
    • Mylib.configure do |config|
  • Instance configuration via option hash