Skip to content

Instantly share code, notes, and snippets.

View jirkapenzes's full-sized avatar

jirkapenzes jirkapenzes

View GitHub Profile
@jirkapenzes
jirkapenzes / barcamp.txt
Created October 14, 2016 21:12
Barcamp
https://docs.google.com/presentation/d/1OAiTyyIyUFszdvdnX_RZv1NmB7OCg1GL_RvL1c0uY0g/edit?usp=sharing
package demo;
public class Calculator {
enum Operation {
Addition, Subtraction
}
public int calculate(Operation operation, int a, int b) {
switch (operation) {
(defn- load-post [file]
(try
(->> (slurp file)
(parser/parse)
(convert-date)
(split-tags)
(add-author)
(add-file-name (.getName file))
(add-relative-url (.getName file))
(add-absolute-url (.getName file))
@jirkapenzes
jirkapenzes / PerfRequest.java
Created February 3, 2016 10:29
Request sender
public class PerfRequest {
public static void main(String[] args) throws Exception {
int index = 0;
int numberOfErrors = 0;
while(index < 100000)
{
URL url = new URL("http://localhost:8080");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
@jirkapenzes
jirkapenzes / ThreeLawsOfRobotics.java
Last active May 26, 2020 07:33
Three Laws of Robotics
// Three Laws of Robotics
public void processAction(Ai ai, Action action, Environment environment) {
List<Human> humans = detectHumans(environment);
// A robot may not injure a human being or, through inaction,
// allow a human being to come to harm.
if (ai.predict(action).injure(humans)) {
throw new FirstLawsException();
}
@jirkapenzes
jirkapenzes / gol.clj
Created November 13, 2015 20:41
Coderetreat clojure template
(ns game-of-life
(:require [clojure.test :refer :all]))
(defn test-function []
:true)
(deftest game-of-life
(testing "test-function"
(is (= :false (test-function)))))
@jirkapenzes
jirkapenzes / commit-msg
Created November 4, 2015 14:22
Script to check Jira issue number in commit message
#!/bin/sh
#
# The hook check if commit message include jira ticket number.
# Example:
# Message: Refactoring (WEBAPI-100)
#
# Script location: .git/hooks/commit-msg
#
test "" != "$(grep '\(WEBAPI-[0-9]\+\)' "$1")" || {
echo >&2 "ERROR: Commit message is missing Jira issue number."
@jirkapenzes
jirkapenzes / jihlava.clj
Created October 30, 2015 10:36
GDG Jihlava talk - fizzbuzz demo
(ns gdg-jihlava)
;1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz Buzz
(defn fizz-buzz-number [number]
(cond
(= 0 (mod number 3) (mod number 5)) :fizz/buzz
(= 0 (mod number 3)) :fizz
(= 0 (mod number 5)) :buzz
:else number))
@jirkapenzes
jirkapenzes / webrtc.txt
Last active September 3, 2015 09:12
WebRTC - Štěpán
[Štěpán]: Používám knihovnu peerjs, který řeši problémy s rozdíli implementace ff a chrome;
a problém je, když se mi spojí 20 (víc jsem netestoval) prohlížečů, tak se to spojí,
vše je connected, readu a super; všechny kontrolní proměnné webrtc (connected, closed,
destroyed a ještě jeden tam je) všechno se tváří správně (tak jak by mělo),
ale vždy (myšleno jako v 98% případů) se najde nějaká svoji dvojice prohlížečů (tj. spojení webrtc),
mezi kterými žádné zprávy neprojdou (ale vše se opět tváří jako že ok)
@jirkapenzes
jirkapenzes / RouteMatcherTest.java
Created August 25, 2015 09:30
Route Matcher Test
package com.topmonks.monkbox.engine;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
/**