Skip to content

Instantly share code, notes, and snippets.

View rahcola's full-sized avatar

Jani Rahkola rahcola

  • Helsinki, Finland
View GitHub Profile
@rahcola
rahcola / gist:8020264
Created December 18, 2013 10:34
i3 statusbar conf
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
output_format = "i3bar"
@rahcola
rahcola / laskin_code.js
Created November 10, 2012 18:56 — forked from anonymous/laskin_code.js
Selainohjelmointi, viikko 2
function init() {
naytaLuku("0");
/*eka näytä nolla */
var nappula = document.getElementById("nappi");
var laskin = new Laskin();
/* on nyt tosi rumasti tehty, mutta en keksinyt parempaakaan
* eli siis en päässyt tuolta hanskaaHomma-funktiosta
* käsiksi laskimeen, yritin vaikka mitä esim. antaa sen olion
* tolle hanskaaHommalle parametrina, mutta ei jostain
* syystä toiminut. Terkuin 4 tuntia myöhemmin päätin muuttaa
@rahcola
rahcola / gist:3807597
Created September 30, 2012 16:59
a PSEUDO C translation of week 4. exercise 2.
/*THIS IS PSEUDO*/
divResult mod_div_polynomials(int mod,
termNode* p,
termNode* q) {
termNode* r = p;
termNode* s = NULL;
int b_inverse = ...;
for (int i = p->deg - q->deg; i >= 0; i--) {
if (r->deg == q->deg + i) {
@rahcola
rahcola / gist:3806989
Created September 30, 2012 14:51
addition and multiplication for polynomials
typedef struct termNode {
int coef;
int deg;
struct termNode* greater;
struct termNode* lesser;
} termNode;
termNode* make_term(int coef, int deg) {
termNode* p = malloc(sizeof(termNode));
p->coef = coef;
(ns kineticc.behaviors
(:refer-clojure :exclude [delay loop])
(:require [kineticc.epochal :as e])
(:require [kineticc.operators :as o])
(:require [clojure.data.json :as j]))
(defn remove-nil-vals
"Filter key-val pair in which val is nil."
[map]
(into {} (remove (comp nil? second) map)))
hFetchLines :: Handle -> [Int] -> IO [String]
hFetchLines h nums = do; end <- hIsEOF h; hFetchLines' nums end 1 []
where
hFetchLines' [] _ _ acc = return acc
hFetchLines' _ False _ acc = return acc
hFetchLines' nums _ row acc = do
line <- hGetLine h
end <- hIsEOF h
if (head nums) == row
then hFetchLines' (tail nums) end (row+1) (line:acc)
module Kuulaskuri (luo, monesko, seuraava) where
import Data.IORef
newtype Kuulaskuri = Kuulaskuri (IORef Int)
luo :: IO Kuulaskuri
luo = do
c <- newIORef 1
return $ Kuulaskuri c
@rahcola
rahcola / gist:2314574
Created April 5, 2012 22:09
Tyypillinen kuulaskuri
module Kuukausi where
data Kuukausi = Tammikuu
| Helmikuu
| Maaliskuu
| Huhtikuu
| Toukokuu
| Kesäkuu
| Elokuu
| Heinäkuu
@rahcola
rahcola / Cargo.toml
Last active August 29, 2015 14:12
Noober
[package]
name = "noober"
version = "0.0.1"
authors = ["Jani Rahkola <jani.rahkola@iki.fi>"]
[[bin]]
name = "noober"
[dependencies]
rustc-serialize = "0.1.0"
@rahcola
rahcola / gist:9850dfc6cfe05839f4f9
Last active August 29, 2015 14:10
Fuzzer monad
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
import Control.Applicative
import Control.Monad
import qualified Control.Monad.Random as R
import qualified Control.Monad.State as S
import qualified Control.Monad.Trans.Either as E
newtype Fuzzer s a = Fuzzer {
runFuzzer :: E.EitherT () (S.StateT s (R.Rand R.StdGen)) a