Skip to content

Instantly share code, notes, and snippets.

View miikka's full-sized avatar

Miikka Koskinen miikka

View GitHub Profile
@miikka
miikka / git-b
Last active August 8, 2018 07:27
#!/bin/bash
# Intearctively select one of the recent branches and checkout it.
set -e
git rev-parse --is-inside-work-tree >/dev/null
git checkout $(git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/ | fzf -q "$*")
var x = cos * sideHexOffset - sin * (vertHexOffest + sideVertHexOffset);
var y = cos * (sideVertHexOffset + vertHexOffest) + sin * sideHexOffset;
% cabal install hledger-web
Resolving dependencies...
Configuring hledger-web-0.22.1...
Building hledger-web-0.22.1...
Preprocessing library hledger-web-0.22.1...
Application.hs:31:7:
warning: missing terminating ' character [-Winvalid-pp-token]
-- Don't forget to add new modules to your cabal file!
^
#!/usr/bin/env python
import fnmatch
from ftplib import FTP
import os
import sys
class Downloader(object):
destdir = '.'
pattern = '*'
#!/bin/sh
# Etsitään tiedostot hakemistosta foo ja siirretään ne hakemistoon bar
find foo -type f -exec mv {} bar \;
# Vaihtoehtoinen tapa, joka lienee nopeampi jos on paljon tiedostoja:
find foo -type f -print0 | xargs -0 -n 25 mv -t bar
# Tiedostot on siirrety pois foosta, poistetaan foo
rm -r foo
#include <ctime>
#include <iostream>
int main(int argc, char**argv)
{
std::time_t start = std::time(NULL);
while (std::time(NULL) - start < 10) {
std::cout << "piip!" << std::endl;
sleep(1);
function eval_(foo) {
return eval(foo);
}
eval_("var quux = 1");
eval_("console.log(quux)");
@miikka
miikka / my_popen.c
Created October 2, 2012 15:00
Capturing the output of an external program in C
#include <stdio.h>
#include <unistd.h>
int my_popen(char *cmd, FILE *handles[2]) {
/* Naming convention: the child's input and output */
int input[2];
int output[2];
pipe(input);
pipe(output);
@miikka
miikka / facecrop.py
Created April 7, 2012 20:00
Create a thumbnail of a face photo.
#!/usr/bin/python
# A small script to create a square thumbnail out of a picture of a human face.
# Written by Miikka Koskinen (http://miikka.me/) on 2012-04-07.
# Based on:
# http://recursive-design.com/blog/2010/12/14/face-detection-with-osx-and-python/
import cv
import sys
@miikka
miikka / Sass.hs
Created February 20, 2011 14:11
Hakyll + Sass
module Sass (sass) where
import Control.Monad.IO.Class (liftIO)
import Text.Hakyll.File (makeDirectories, toDestination)
import Text.Hakyll.HakyllAction (HakyllAction(..), runHakyllActionIfNeeded)
import Text.Hakyll.HakyllMonad (Hakyll)
import System.FilePath (replaceExtension)
import System.Process (readProcess)