Skip to content

Instantly share code, notes, and snippets.

@EinLama
EinLama / maketv.rb
Created March 31, 2017 11:29
Test bei Make.tv
class Node
attr_accessor :value, :next
def initialize(value, _next)
@value = value
@next = _next
end
def to_s
"#{self.value} -> #{self.next ? self.next.to_s : nil}"
@EinLama
EinLama / slow_vim.rb
Created December 10, 2013 10:37
This is painfully slow in vim. I am using vim 7.4 with compiled ruby support and the vim-tomorrow-colorscheme. ``:syntax off`` and the performance is as good as you would expect. ``:syntax on`` and it's barely useable. ``set re=1`` as suggested on various SO-posts doesn't help.
def test
dummy = [
{ a: 123, b: "hello", c: :whoa, another_key: "i don't know what to say here", even_more: "okay now it gets huge" },
{ a: 123, b: "hello", c: :whoa, another_key: "i don't know what to say here", even_more: "okay now it gets huge" },
{ a: 123, b: "hello", c: :whoa, another_key: "i don't know what to say here", even_more: "okay now it gets huge" },
{ a: 123, b: "hello", c: :whoa, another_key: "i don't know what to say here", even_more: "okay now it gets huge" },
{ a: 123, b: "hello", c: :whoa, another_key: "i don't know what to say here", even_more: "okay now it gets huge" },
{ a: 123, b: "hello", c: :whoa, another_key: "i don't know what to say here", even_more: "okay now it gets huge" },
@EinLama
EinLama / project_spec.rb
Created December 5, 2011 18:55
How to test :dependent => :destroy using minitest::spec?
describe Project do
it "should be valid" do
project = Fabricate.build :project
project.must_be_valid
end
it "should have a name" do
project_without_name = Fabricate.build :project, name: nil
project_without_name.wont_be_valid
Dreamforge::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
@EinLama
EinLama / clock.rb
Created May 6, 2011 12:58
Timetracker for projects. Only a quick hack. I intend to build it from scratch - clean.
#!/usr/bin/ruby
require 'yaml'
class Timestamp
attr_accessor :start, :end
def initialize(start_time)
@start = start_time
end
@EinLama
EinLama / magicWarden.rb
Created April 21, 2011 13:54
Small helper script. Watches a folder and magically compiles HAML and Coffeescript-code :)
# magicWarden.rb - 2011 (c) Tobias Eilert
#
# Watches a folder recursively for changes and takes certain actions when files
# are changed. You can specify the directory you want to watch on startup.
# If no directory is passed, the magical warden will take care of the current place.
#
# $ magicWarden.rb some/path/to/some/place
# $ magicWarden.rb # same as magicWarden.rb .
#
# Runs on Mac OS X, Windows and GNU/Linux with Ruby >= 1.9.2