Skip to content

Instantly share code, notes, and snippets.

View tuner's full-sized avatar

Kari Lavikka tuner

View GitHub Profile
package harjoitus9;
import java.util.Arrays;
import java.util.List;
/**
* @author Kari
*/
public class Alkusolmu {
static class Solmu {

Keybase proof

I hereby claim:

  • I am tuner on github.
  • I am klavikka (https://keybase.io/klavikka) on keybase.
  • I have a public key whose fingerprint is 297D EB71 AE84 46D7 4BD6 6FD5 C2CA 3963 DF9A 4818

To claim this, I am signing this object:

@tuner
tuner / IncludeBean.java
Created June 4, 2015 18:22
JSF dynamic <ui:include> problem
import javax.faces.bean.SessionScoped;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import java.io.Serializable;
/**
* @author Kari
*/
@Named
@ViewScoped
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandDescriptor {
Class [] supportedChannels();
boolean moderatorRequired();
String [] commands();
}
//////////////////////////////////////////
public class StandardCommands {
@tuner
tuner / build-common
Created January 14, 2011 12:20
Check that we have a clean working tree...
<macrodef name="git-status">
<attribute name="dir" default=""/>
<sequential>
<echo>Check that we have a clean working tree...</echo>
<exec executable="sh" dir="@{dir}" resultproperty="gitStatusResult">
<arg value="-c"/>
<arg value="git status --porcelain | grep -E '.[^\?] '"/>
</exec>
<fail>
<condition>
@tuner
tuner / CmsFaceletCache.java
Created August 26, 2016 06:50
A FaceletCache that expires facelets by using a FileWatcher
package fi.bdb.cms.utils;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@tuner
tuner / snake.py
Created March 11, 2017 15:02 — forked from sanchitgangwar/snake.py
Snakes Game using Python
# SNAKES GAME
# Use ARROW KEYS to play, SPACE BAR for pausing/resuming and Esc Key for exiting
import curses
from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN
from random import randint
curses.initscr()
win = curses.newwin(20, 60, 0, 0)
@tuner
tuner / flask_test.py
Created June 19, 2017 16:48
sqlite & flask test
from flask import Flask, g, render_template
import sqlite3
import html
app = Flask(__name__)
def get_db():
"""Opens a new database connection if there is none yet for the
current application context.
"""
@tuner
tuner / spam_bayes.py
Created September 27, 2017 08:44
Bayes spam "filter"
import re
import pathlib
from collections import defaultdict
from math import log, exp
def read_table(filename):
pattern = re.compile("^\s+(\d+)\s+([^\s]+)$")
table = {}
@tuner
tuner / sne.R
Created April 16, 2018 09:43
Stochastic neighborhood embedding in R
#
# (c) Kari Lavikka 2018
#
library(stats)
source("mnist.R")
mnist <- load_mnist()