Skip to content

Instantly share code, notes, and snippets.

View nerdinand's full-sized avatar
💭
wat

Ferdinand Niedermann nerdinand

💭
wat
View GitHub Profile
@nerdinand
nerdinand / spreadsheet_range.rb
Created June 13, 2012 13:40
Class for dealing with ranges of cells (2-dimensional) in spreadsheet gem
class SpreadSheetRange
BORDER_EDGES=[:bottom, :top, :right, :left]
def initialize(worksheet, row_range, col_range)
@worksheet = worksheet
@row_range = row_range
@col_range = col_range
end
def draw_border(where = :all, color = nil)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@nerdinand
nerdinand / gist:dcd0b3da194fe2ff2bcb
Last active August 29, 2015 14:01
Ruby one-liner for calculating the total activity of each of the tracks from an Auphonic production description file
require "json"; p JSON.parse(File.read("ZCH042.json", external_encoding: "iso-8859-1", internal_encoding: "utf-8"))["statistics"]["tracks"].map{|t| [t["identifier"], t["activity"].nil? ? nil : t["activity"].map{|kv| kv[1] - kv[0]}.inject(:+)/60 ]}
@nerdinand
nerdinand / gist:9e8a86ad6b42f0527d89
Created September 12, 2014 06:51
OS X compilation errors
Scanning dependencies of target ontology_shared
[ 20%] Building CXX object ontology/CMakeFiles/ontology_shared.dir/src/Entity.cpp.o
In file included from /Users/ferdi/projects/ontology/ontology/src/Entity.cpp:8:
/Users/ferdi/projects/ontology/ontology/include/ontology/Entity.hpp:128:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
#endif / /__ONTOLOGY_ENTITY_HPP__
^
//
In file included from /Users/ferdi/projects/ontology/ontology/src/Entity.cpp:8:
In file included from /Users/ferdi/projects/ontology/ontology/include/ontology/Entity.hpp:12:
In file included from /Users/ferdi/projects/ontology/ontology/include/ontology/TypeContainers.hpp:14:
I, [2014-09-15T17:06:07.484254 #70521] INFO -- : Registering connection 'joystick'...
I, [2014-09-15T17:06:07.484324 #70521] INFO -- : Registering device 'controller'...
I, [2014-09-15T17:06:07.484346 #70521] INFO -- : Preparing work...
I, [2014-09-15T17:06:07.485001 #70521] INFO -- : Initializing connection joystick...
I, [2014-09-15T17:06:07.490029 #70521] INFO -- : Initializing device controller...
E, [2014-09-15T17:06:07.629455 #70521] ERROR -- : Actor crashed!
LoadError: cannot load such file -- artoo/drivers/ouya
/Users/ferdi/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:126:in `require'
/Users/ferdi/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:126:in `require'
/Users/ferdi/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/artoo-1.8.0/lib/artoo/device.rb:121:in `require_driver'
@nerdinand
nerdinand / keybase.md
Created November 28, 2014 11:33
keybase.md

Keybase proof

I hereby claim:

  • I am nerdinand on github.
  • I am nerdinand (https://keybase.io/nerdinand) on keybase.
  • I have a public key whose fingerprint is 7DEB BEB5 A188 D39C 5210 5C0C EE6D 8028 69DA B208

To claim this, I am signing this object:

ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'testing.db'
)
class Testing < ActiveRecord::Base
end
Testing.connection.create_table :testings do |t|
require 'bundler'
Bundler.setup(:default)
require 'pg'
require_relative 'lib/active_record'
require 'minitest/autorun'
require 'logger'
require 'byebug'
require 'bundler'
Bundler.setup(:default)
require 'pg'
require_relative 'lib/active_record'
require 'minitest/autorun'
require 'logger'
require 'byebug'
@nerdinand
nerdinand / de_CH.yml
Last active August 29, 2015 14:26
Rails de_CH (Swiss high german) locale
---
de:
date:
abbr_day_names:
- So
- Mo
- Di
- Mi
- Do
- Fr