Skip to content

Instantly share code, notes, and snippets.

Martin Vielsmaier moser

Block or report user

Report or block moser

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
moser / pyplot_histogram_on_axes.ipynb
Last active Mar 23, 2018
Pyplot: Histogram on X/Y axis
View pyplot_histogram_on_axes.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am moser on github.
  • I am moser ( on keybase.
  • I have a public key whose fingerprint is B068 15D6 ED68 61B2 285E FA44 561F E468 D14F EFDE

To claim this, I am signing this object:

moser / solve.hs
Created Sep 22, 2015
Solving a minotauros cube in haskell: see blog post:
View solve.hs
import Data.Maybe
import Data.List
import qualified Data.Set as Set
type Point = (Int, Int, Int)
type Shape = Set.Set Point
keys = [1..3]
allKeys = [(x, y, z) | x <- keys, y <- keys, z <- keys]
moser / gist:9949291
Created Apr 3, 2014
Poor man's autotest for any language
View gist:9949291
while true; do inotifywait -e modify file1 my_test_file1 ... && MY_TEST_COMMAND; done
moser / printCurrentStackTrace
Created Oct 21, 2010
Print the current stack trace
View printCurrentStackTrace
public void printCurrentStackTrace() {
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
for(int i= 2; i < elements.length; i++) { //2 to remove Thread#getStackTrace and this method
View mocha mock generation with block.rb
# defined in my spec_helper
# requires mocha
# needed because
# mock() { expects(:foo).with(:bar, anything) }
# does not work. (fails with "Mocha::ExpectationError: unexpected invocation: #<Mock:0x1d8>.anything()")
# Usage:
# mock_block() do |m|
# m.expects(:foo).with(:bar, anything)
# end
def mock_block(&block)
moser / AR association accessor with string acceptance
Created Apr 2, 2009
AR association accessor with string acceptance
View AR association accessor with string acceptance
# Host is a simple two row model: id, name
# I think the check whether a host with the given
# name exists, should go right there.
# Still it accepts normal host objects.
# A big advantage over Host.find_or_create is,
# that I can use "host" as a normal text field in
# my forms and it's all done automatically.
class MyModel < ActiveRecord::Base
belongs_to :host
View Rails model default order.rb
Class Model < ActiveRecord::Base
def self.find(*args)
order = {:order => "name ASC"}
if args.length <= 1
args << order
args[1] = order.merge(args[1])
You can’t perform that action at this time.