Skip to content

Instantly share code, notes, and snippets.

View edvardm's full-sized avatar

Edvard Majakari edvardm

  • Rakettitiede Oy
  • Finland
  • 02:59 (UTC +03:00)
View GitHub Profile
s = filterM (const [True, False])
@edvardm
edvardm / main.cf
Created March 31, 2017 09:00
postfix config for local mail delivery in MacOS
queue_directory = /private/var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = _postfix
inet_interfaces = $myhostname, localhost
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
debug_peer_level = 2
debugger_command =
@edvardm
edvardm / Vagrantfile
Last active February 17, 2017 16:34
Quick vagrant ubuntu box for toying /w Docker
# -*- mode: ruby -*-
# vi: set ft=ruby :
### NOTE: you need to run
# vagrant plugin install vagrant-docker-compose
# before running this to make docker-compose provisioner work
Vagrant.configure("2") do |config|
config.vm.box = "cbednarski/ubuntu-1604-large"
# Create a forwarded port mapping which allows access to a specific port
@edvardm
edvardm / checklist.md
Last active December 21, 2016 10:29
checklist.md

Developer checklist

  1. Rebased with current master
  2. There are tests for new feature/bugfix
  3. Tests pass
  4. Changes arm relevant only to the current feature/bugfix[URC]
  5. Does it have proper logging?
  6. Does it use network? what if there's a network error?
  7. Does it write to disk? what if the disk is full?
  8. Have you considered other edge cases, other than "happy paths"? What is the edge case?
@edvardm
edvardm / sanapeli.rb
Created August 4, 2016 15:18
sanapeli.rb
# Toiminnallisuus tiiviisti: peli lukee komentoriviltä käytettyjen kirjainten
# määrän. Ohjelma arpoo sen jälkeen näin monta kirjainta. Pelaaja muodostaa
# näistä mahdollisimman monta sanaa syöttämällä joko sanan tai pisteen (.) jos
# ei enää kykene muodostamaan sanoja.
#
# Sana pisteytetään vain, jos se löytyy annetusta sanastosta. Pisteyttämiseen on
# annettu valmiiksi oma funktio. Sanan pitää olla ainakin 2 merkkiä pitkä, jotta
# siitä saa pisteitä.
#
# Kunkin syötteen jälkeen ja lopetettaessa peli kertoo, montako pistettä
@edvardm
edvardm / peli.rb
Last active August 4, 2016 15:03
peli-1.rb
AAKKOSET = ('a'..'z').to_a
AAKKOS_LKM = 20
def jaa_aakkoset
taulukko = []
AAKKOS_LKM.times do
taulukko.push(AAKKOSET.sample)
end
taulukko
@edvardm
edvardm / peli-0.rb
Created August 3, 2016 16:06
peli-0.rb
AAKKOSET = ('a'..'z').to_a
AAKKOS_LKM = 7
def jaa_aakkoset
taulukko = []
AAKKOS_LKM.times do
taulukko.push(AAKKOSET.sample)
end
taulukko
@edvardm
edvardm / bmi.rb
Created August 2, 2016 16:51
bmi.rb
NIMI_INDEKSI = 0
PITUUS_INDEKSI = 1
MASSA_INDEKSI = 2
SUKUPUOLI_INDEKSI = 3
ihmiset = [
["Ed", 1.84, 90, 'm'],
["Jaakko", 1.75, 62, 'm'],
["Anne", 1.65, 53, 'f'],
["Pertti", 1.9, 95, 'm']
@edvardm
edvardm / taulukot.rb
Created August 2, 2016 16:47
taulukot.rb
jäsenet = ["Ed", "Liisa", "Pertti"]
jäsenet.each do |nimi|
puts nimi
end
# Yleinen muoto käydä läpi taulukkoja:
# taulukko.each do |alkio|
# .. tee jotain muuttujalla 'alkio'
# end
@edvardm
edvardm / rekursio.rb
Created August 2, 2016 16:44
rekursio.rb
# Rekursiosta: kertoma
#
# n! = n * n-1 * n-2 * .. * 1
#
# Esim.
# 2! = 2 * 1
# 3! = 3 * 2 * 1 = 6
# 4! = 4 * 3 * 2 * 1 = 24
# 5! = 5 * 4 * 3 * 2 * 1 = 120
# 6! = 6 ... = 720