{{ message }}

Instantly share code, notes, and snippets.

# Matthias Sieber manonthemat

Created Apr 2, 2014
Example of a simple algorithm with a running time that grows proportional to the input size
View gist:9938961
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 def find_max(data): """Return the maximum element from a nonempty Python list.""" biggest = data[0] for val in data: if val > biggest: biggest = val return biggest
Created May 21, 2014
simple math fun with haskell - custom number base systems
View base.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 import Data.Char (digitToInt) numberToBaseString :: Int -> Int -> String numberToBaseString n base | n < base = show n | otherwise = numberToBaseString ((n - (n `mod` base)) `div` base) base ++ show (n `mod` base) baseStringToValue :: String -> Int -> Int baseStringToValue n base | n == [] = 0
Created Aug 16, 2014
for debugging
View gist:dda18bb2f28dee2c528a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 puts' ______________________________ ' puts'< What\'s wrong with this food? >' puts' ------------------------------ ' puts' \ ^__^' puts' \ (oo)\_______' puts' (__)\ )\/\'' puts' ||----w |' puts' || ||'
Created Jan 19, 2015
first draft of a simple roman calculator
View roman.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #include #include #include #include #include #include #include using namespace std;
Last active Aug 29, 2015
simple stack data structure in C++
View stack.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #include using namespace std; class Stack_overflow {}; class Stack_underflow {}; class Stack { public: Stack(int sz) : sz{sz}, top{-1}, elem {new int[sz]} {};
Created Apr 13, 2015
simple token strategy with hapi
View gist:687c5457d09ea0c1235d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 server.register(require('hapi-auth-jwt2'), function(err) { if (err) { throw err; } server.auth.strategy('token', 'jwt', false, { key: constants.application.secretKey, validateFunc: function(decoded, request, callback) { if (!decoded || !decoded.verified) { return callback(null, false);
Created Oct 20, 2013 — forked from jeremyblow/gist:7060658
View gist:7063263
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 import urllib2 import random import difflib import datetime def fetch(url): """Fetches requested url, returns lines in list""" response = urllib2.urlopen(url) lines = response.readlines() return lines
Created Nov 18, 2013
function to sort a shell history file and print out the lines of commands that has been executed the most
View top_history.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 def sortCommands(histFile, limit=10) file = open(histFile, 'r') lines = file.readlines file.close freqs = Hash.new(0) lines.each do |line| freqs[line] += 1 end a = freqs.sort_by {|k, v| -v}[0..limit] i = 0
Created Feb 6, 2016
copying nodes with labels and properties - hacky
View gist:cfb8272ef6695daf7624
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 // requires cypher-rest // npm i cypher-rest // gist for http://stackoverflow.com/questions/35191765/how-can-we-copy-labels-from-one-node-to-another-in-one-cypher 'use strict'; const util = require('util'); const c = require('cypher-rest'); const neoUrl = 'http://127.0.0.1:7474/db/data/transaction/commit';
Created Nov 18, 2017
quick and dirty javascript "lib" to prepare for a statistics exam
View m.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 'use strict'; var _fstore = []; function factorial (n) { if (n == 0 || n == 1) { return 1; } if (_fstore[n] > 0) { return _fstore[n]; }