Skip to content

Instantly share code, notes, and snippets.

View joaomilho's full-sized avatar
🐫

Yo Lulkin joaomilho

🐫
  • Choco.com
  • Berlin, Germany
View GitHub Profile
# Generator for valid Swedish personnummer: http://en.wikipedia.org/wiki/Personal_identity_number_(Sweden)
# By Henrik Nyh <http://henrik.nyh.se> 2009-01-29 under the MIT license.
require 'date'
module Personnummer
def self.generate(date=nil, serial=nil)
date ||= Date.new(1900+rand(100), 1+rand(12), 1+rand(28))
serial = serial ? serial.to_s : format("%03d", 1+rand(999)) # 001-999
import Char
r = flip mod
b [l] = l
b l = b $ map (\x -> read [x]) $ show $ sum l
s = b . map ((+1) . r 9 . r 97 . ord . toLower) . filter isAlpha
main = do
x <- getLine
putStr $ show $ s x
@joaomilho
joaomilho / 1.png
Created September 16, 2013 14:16 — forked from jeffkreeftmeijer/1.png
1.png
# LiquidView is a action view extension class. You can register it with rails
# and use liquid as an template system for .liquid files
#
# Example
#
# ActionView::Base::register_template_handler :liquid, LiquidView
class LiquidView
PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
_response url _request _cookies variables_added _flash params _headers request cookies
ignore_missing_templates flash _params logger before_filter_chain_aborted headers )
$base-font-size: 16px;
$base-line-height: 1.5;
// this value may vary for each font
// unitless value relative to 1em
$cap-height: 0.68;
@mixin baseline($font-size, $scale: 2) {
-- relational.hs
import Database.HDBC
import Database.HDBC.PostgreSQL
import Data.List
printTuples conn rel = quickQuery' conn ("SELECT DISTINCT * FROM " ++ rel) []
(⋈) = intercalate " NATURAL JOIN "
(π) fields rel1 = "(SELECT " ++ (intercalate "," fields) ++ " FROM " ++ rel1 ++ ") a"
module ChameleonBass where
import Haskore.Music
import Haskore.Melody
import Haskore.Basic.Pitch
import Haskore.Basic.Duration
import Haskore.Music.GeneralMIDI
import Haskore.Interface.MIDI.Render
pitch_line = map (\(x,y,z) -> x (y :: Octave) z () )
@joaomilho
joaomilho / operation.hs
Last active August 29, 2015 14:01 — forked from softa/operation.hs
module Main where
import Text.ParserCombinators.Parsec
runop :: Char -> Integer -> Integer -> Integer
runop '+' firstOperand secondOperand = firstOperand + secondOperand
runop '-' firstOperand secondOperand = firstOperand - secondOperand
runop '*' firstOperand secondOperand = firstOperand * secondOperand
runop '^' firstOperand secondOperand = firstOperand ^ secondOperand
operation :: Parser Integer