Skip to content

Instantly share code, notes, and snippets.

View martiner's full-sized avatar

Martin Caslavsky martiner

  • Brno, Czech Republic
View GitHub Profile
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.*;
public class TrueStory {
private static final int SLEEP = 1;
private final int count = 10;
private final ExecutorService service = Executors.newFixedThreadPool(count);
@martiner
martiner / Pokus.java
Created November 11, 2015 15:56
jopt simple value converter
import joptsimple.ValueConverter;
import java.util.HashMap;
import java.util.Map;
import static org.springframework.core.GenericTypeResolver.resolveTypeArgument;
public class Pokus {
public static void main(String... args) {
@martiner
martiner / ihned-pw.user.js
Created October 30, 2015 19:20
iHned Paywall Remover
// ==UserScript==
// @name iHned Paywall Remover
// @namespace http://ihned.cz
// @description Removes iHned paywall cookie
// @include http:/ihned.cz/*
// @include http://*.ihned.cz/*
// @version 2
// @grant none
// ==/UserScript==
document.cookie = "pw=; path=/; domain=.ihned.cz; expires=Thu, 01-Jan-1970 00:00:01 GMT;";
@martiner
martiner / schema.xsd
Created September 7, 2015 21:08
Kontrolni hlaseni
<?xml version="1.0" encoding="utf-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified">
<xs:simpleType xmlns:xalan="http://xml.apache.org/xslt" name="dateInMultiFormat">
<xs:restriction base="xs:string">
<xs:pattern value="(([1-9])|((0[1-9])|([12][0-9]))|(3[0-1]))\.((0?[1-9])|(1[0-2]))\.((19[0-9]{2})|(2[0-9]{3}))"/>
</xs:restriction>
</xs:simpleType>
<xs:element xmlns:xalan="http://xml.apache.org/xslt" name="Pisemnost">
<xs:complexType>
<xs:sequence>
<xs:element name="DPHKH1">
@martiner
martiner / apache2.pp
Created January 31, 2015 14:20
Dear Debian Apache2 maintainers, thank you for all the a2en* stuff! It can be even more tweaked with Puppet:
file {'/etc/apache2/sites-enabled':
ensure => directory,
purge => true,
recurse => true,
force => true,
}
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@martiner
martiner / Depend.java
Created January 6, 2013 12:23
Class load dependency
public class Depend {
public Depend() {
System.out.println("Hello World!");
}
}
@martiner
martiner / upload.php
Created November 22, 2012 19:31
PHP upload
<html>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
<label>Filename: <input type="file" name="file"></label>
<input type="submit" value="Submit">
</form>
<?php
if ($_FILES["file"]["error"] > 0) {
echo "Error: " . $_FILES["file"]["error"] . "<br>";
@martiner
martiner / abter.java
Created September 18, 2012 13:17
how to format code
assertEquals(new SOQLQuery("SELECT (SELECT FirstName FROM Contacts where FirstName='Eva' limit 1),Name FROM Account",
"Account", new SelectField("Contact@FirstName"), new SelectField("Name")),
processor.process("select (select FirstName from Contacts where FirstName='Eva' limit 1),Name from Account", loginResult));
class Gtype {
def list;
void write() {
list.each {
write(it)
}
}