Skip to content

Instantly share code, notes, and snippets.

View zidarsk8's full-sized avatar
🐢

Miha Zidar zidarsk8

🐢
View GitHub Profile
#include <WindowsConstants.au3>
Global $SS_CENTER
$_GuiCountDown = GUICreate ( "CountDown...", 500, 200, @DesktopWidth/2 +200, @DesktopHeight/2 +100, $WS_EX_TOPMOST )
GUISetBkColor ( 0xCCCCCC )
$TimeLabel = GUICtrlCreateLabel ( "", 35, 0, 400, 180, $SS_CENTER )
@zidarsk8
zidarsk8 / gist:4992029
Created February 20, 2013 01:50
i am a bad bad person
def remove(id: String) = Action { implicit request =>
// user match {
// case Some(u) => {
// Users.remove(id)
// Redirect(routes.Application.index()).flashing("message" -> "User Deleted!")
// }
// case None => {
// Redirect(routes.Application.index()).flashing("message" -> "You can't do that! You're a bad perosn")
// }
// }
@zidarsk8
zidarsk8 / gist:5390872
Last active December 16, 2015 06:19
ugly code
val memo = HashMap[(Int, Int), (Int, Int)]((0, 0) -> (0, 0))
def cost(from: Int, to: Int): (Int, Int) = {
if (memo.contains((from, to))) {
memo((from, to))
} else if (to - from < 1) {
(to, 0)
} else if (to - from < 3) {
(Math.max(0, to - 1), Math.max(0, to - 1))
} else {
val costList = (from to to).map(i => (Math.max(cost(from, i - 1)._2, cost(i + 1, to)._2) + i))
@zidarsk8
zidarsk8 / gist:5397588
Created April 16, 2013 16:59
ugly code
object Tree {
private var current = 0
def inc = { current += 1; current }
def elements = current
}
class Tree {
var root: Node = new Node(Tree.inc)
@zidarsk8
zidarsk8 / gist:5438072
Created April 22, 2013 20:07
regula falsi
def regulaFalsi(eps:Double)(from:Double, to:Double, f: Double => Double) : Double = {
var i = 1000
var a = from
var fa = f(a)
var b = to
var fb = f(b)
var c = a - fa * (b-a)/(fb-fa)
var fc = f(c)
while (abs(fc)>eps && b-a > eps && {i-=1;i} > 0){
@zidarsk8
zidarsk8 / gist:5567867
Created May 13, 2013 12:09
simple occurrence combo
def combinations(occurrences: Occurrences): List[Occurrences] = {
def combo(l: Occurrences): List[Occurrences] = {
l match {
case Nil => List()
case occurrence :: tail => {
val rest = combo(tail)
val occurrenceList = (1 to occurrence._2).map( num => List( (occurrence._1,num) )).toList
occurrenceList ::: occurrenceList.flatMap(x => rest.map(y => x ::: y).toList).toList ::: rest
}
}
import java.util.LinkedList;
public class LevenshteinDistance {
public static final int NONE = 0;
public static final int DELETE = 1;
public static final int INSERT = 2;
public static final int CHANGE = 3;
private static int minimum(int a, int b, int c) {
public class EditDistance {
/**
* @param args
*/
public static void main(String[] args) {
int[] a = LevenshteinDistance.getOperations("aa", "aac");
for (int i = 0; i < a.length; i++) {
System.out.println(a[i]);
@zidarsk8
zidarsk8 / gist:5827509
Last active December 18, 2015 18:39
test
package test;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
zidar@haxor ~/programming/myproject
$ cat test.py
from flask import Flask
import flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return str(flask.app.request)