Skip to content

Instantly share code, notes, and snippets.

View tfrisk-old's full-sized avatar

Teemu Frisk tfrisk-old

  • Helsinki
View GitHub Profile
#!/bin/sh
# Older docker which does not have prune command
#
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@tfrisk-old
tfrisk-old / finnkino-api-harjoitus.clj
Created February 3, 2017 11:54
Finnkinon API-rajapinnan käsittelyä Clojurella
; Clojure-harjoituskoodi Finnkinon XML-rajapinnan lukemiseen.
; Tarkoitettu alunperin ClojureBridgeen osallistuneille oppilaille
; ohjelmoinnin jatkoharjoittelua varten.
(ns finnkino-api-lukija.core
(:require [clojure.xml :as xml])
(:gen-class))
; Käytettävän rajapinnan osoitteet
(def teatterit-api "http://www.finnkino.fi/xml/TheatreAreas/")
@tfrisk-old
tfrisk-old / paradox-csv-converter.py
Created May 4, 2016 05:32
Paradox database -> CSV converter
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Paradox database -> CSV converter
# (C) 2016 Teemu Frisk / Pandia Ltd
# MIT License
#
# Usage:
# 1) Make sure this script and its related paradox.py files are in the same dir
# 2) Create directory for paradox files and copy the entire db there
@tfrisk-old
tfrisk-old / gist:27ba1ef9b59316aaaa94
Created May 15, 2015 13:20
Clojurebridge snippets
; ---------------------------------------------------
; https://github.com/ClojureBridge/curriculum/blob/master/outline/flow_control.md
(defn ordinal [n]
(let [r (rem n 10)]
(if (and (> n 10) (< n 15))
(str n "th")
(if (= r 1)
(str n "st")
(if (= r 2)
(str n "nd")
test_helper.exs:
exclude =
if Node.alive?, do: [], else: [distributed: true]
ExUnit.start(exclude: exclude)
router_test.exs:
@tfrisk-old
tfrisk-old / gist:6a60b968c8b9780d987b
Created February 6, 2015 08:03
How to setup local postgres database for local Rails project
# I have to look this up every time so it's about time to write it down
# Source: https://stackoverflow.com/questions/19953653/how-to-set-up-postgres-database-for-local-rails-project
Login to postgresql prompt as the postgres user
# sudo su postgres -c psql
Create a postgresql user for your project
=# create user username with password 'password';
@tfrisk-old
tfrisk-old / gist:bc7c896798f9f54c5078
Created January 21, 2015 09:02
Find count of code lines in Clojure source files
# Find count of code lines in Clojure source files
cat file.clj | grep -e '^$' -e '^;' -v | wc -l
# How it works?
#
# cat file.clj view file with cat command
# | pipe the output of cat command to the following commands
# grep read the input (piped cat) and match it to given regular expressions
# -e '^$' look for line start (^) followed by immediate end ($) -> empty line
# -e '^;' look for line start (^) followed by Clojure comment mark (;)
@tfrisk-old
tfrisk-old / alastalon_salissa.clj
Last active August 29, 2015 14:13
Hassuimmat sanat Alastalon salissa -koodaustehtävä
; Wunderdogin koodaustehtävän ratkaisuehdotukseni, alkuperäinen sivu täällä: http://wunderdog.fi/koodaus-hassuimmat-sanat/
; Julkistettu kaikille kilpailun päättymisen jälkeen.
(ns alastalon-salissa-clj.core)
; sanojen pisteytys:
; Jokainen vokaaliketju saa n×2n pistettä, jossa n on vokaalien määrä ketjussa.
; Sanan vokaaliketjujen saamat pisteet lasketaan yhteen, jolloin saadaan sanan
; hassuuspisteet.
;
@tfrisk-old
tfrisk-old / lotto.clj
Created November 7, 2014 08:11
Finnish Lottery (Lotto) calculations in Clojure
; ##############
; vaativampi ESIMERKKI: lottoarvonta
; tila myohempaa kayttoa varten, ei viela kaytossa
(def app-state (atom
{:rivimaara 0 ; montako rivia pelataan?
:rivit [] ; arvotut n rivia
:voittorivi [] ; arvottu voittorivi
:tulokset [] ; montako oikein per rivi?
:voittosumma 0 ; yhteenlaskettu voittosumma tuloksista
@tfrisk-old
tfrisk-old / gist:11286970
Created April 25, 2014 11:52
Install Erlang and Elixir on Debian Wheezy (7.4)
#!/bin/sh
# Debian has older Erlang package (R15) in official repositories, Elixir requires newer (R17)
wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
sudo apt-get update
sudo apt-get install -y erlang
rm erlang-solutions_1.0_all.deb
# compile Elixir from source