Skip to content

Instantly share code, notes, and snippets.

public class Comparator { // Třída Comparator, porovnává filter a databázi
public static List<Applicant> compare(List<Applicant> applicants, HashMap<String, List<Integer>> filter) {
Map<Integer, Integer> score = new TreeMap<Integer, Integer>(); // Iaždý kandidát bude mít skóre, podle kterého řadíme
Integer i = 0;
for (Applicant a : applicants) {
System.out.println(a.getName() + " " + i);
score.put(i, 0); // Inicializace
i++;
}
@Mikulas
Mikulas / git _deploy.markdown
Created December 15, 2012 13:19
Git deploy with gitolite (backend) and gitlabhq (frontend)

GitlabHQ enforces it's own hooks, but it stores them in ~gitlab\gitlab\lib\hooks\. Adding the following line at the end of the iteration will call our hooks properly.

sudo /srv/virtual_hosts/deploybot.eu/deploy_hook $reponame $oldrev $newrev $GL_USER $ref $pwd

@Mikulas
Mikulas / compute.php
Last active December 10, 2015 18:58
Percentage win Omaha vs Texas Holdem when omaha player doesn't have to use two cards from his hand.
<?php
$games = 0;
$score = (object) ['o' => 0, 'or' => 0, 'th' => 0];
while (TRUE) {
// build deck
$cards = [];
for ($i = 2; $i <= 14; $i++) {
foreach (['c', 'd', 'h', 's'] as $c) {
Get all playlists from http://khan-report.appspot.com/translations/subtitlestatus?language=Czech&playlist=all&display=1
$("a[href^='/translations/subtitleactions?playlist=']").each(function(i,el) {console.log(decodeURIComponent(el.href.replace("http://khan-report.appspot.com/translations/subtitleactions?playlist=", "").replace("&language=Czech", "")));});
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Formulář</title>
<style type='text/css'>
form {margin-top: 2ex;}
label, input {font-family: Helvetica, Arial}
label {display: inline-block; width: 100px; text-align: right;}
input {margin-bottom: 1ex;}
GPoint getCenter(int row, int led) {
return GPoint(12 + led * 24, 70 + 27 * row);
}
void color_led(GContext* ctx, int row, int led, bool on) {
graphics_context_set_fill_color(ctx, on ? GColorWhite : GColorBlack);
graphics_fill_circle(ctx, getCenter(row, led), CIRCLE_RADIUS);
}
// ############### for PCB binary
@Mikulas
Mikulas / crack.php
Last active December 16, 2015 22:49
PHP bruteforce
<?php
require __DIR__ . '/permute.php';
define('CONCURRENCY', 20);
$descriptors = [
0 => ["pipe", "r"],
1 => ["pipe", "w"],
@Mikulas
Mikulas / gist:5664541
Created May 28, 2013 17:34
Sublime 2 custom settings
{
"ignored_packages":
[
"2pdf",
"Vintage"
],
"theme": "Soda Dark.sublime-theme",
"detect_slow_plugins": false,
"scroll_past_end": true,
"show_tab_close_buttons": false,
@Mikulas
Mikulas / gist:5807905
Last active December 18, 2015 15:58
DibiEvent.php patch for Diagnostics Panel - don't show source file from libs
diff --git a/DibiEvent.php b/DibiEvent.php
index 9c5e609..89fe867 100644
--- a/DibiEvent.php
+++ b/DibiEvent.php
@@ -71,9 +71,9 @@ class DibiEvent
}
$rc = new ReflectionClass('dibi');
- $dibiDir = dirname($rc->getFileName()) . DIRECTORY_SEPARATOR;
+ $libsDir = realpath(__DIR__ . '/../../../../') . DIRECTORY_SEPARATOR;
@Mikulas
Mikulas / gist:5849553
Created June 24, 2013 11:56
Ramdisk mysql data
#!/bin/bash
# Tweaked from http://tomislavsantek.iz.hr/2011/03/moving-mysql-databases-to-ramdisk-in-ubuntu-linux
# @author Tomas Susanka
# @author Mikulas Dite
DB_PATH="/var/lib/mysql"
TMP_PATH="/tmp/ramdisk"
CONFIG_PATH="/etc/mysql/conf.d/ramdisk_datadir.cnf"
RAMDB_PATH="$TMP_PATH/mysql"