Skip to content

Instantly share code, notes, and snippets.

View todvora's full-sized avatar

Tomas Dvorak todvora

View GitHub Profile
@todvora
todvora / elit-cz.md
Created November 18, 2015 15:32
ecat.elit.cz adblock rules
ecat.elit.cz##.overlay
ecat.elit.cz##.modalBackgroud
ecat.elit.cz###ctl00_inline_content_not_logged
ecat.elit.cz###ctl00_divEmptyDarkOverlayVisible
@todvora
todvora / StreamOfOptional.java
Created October 30, 2015 10:11
Lazy optional stream
package optional;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Stream;
public class StreamOfOptional {
public static void main(String[] args) {
System.out.println("--Before eager--");
@todvora
todvora / analyze-all.sh
Created May 20, 2015 05:43
Variety.js - analyze all available collections
#!/usr/bin/env bash
# the database name, that will be analyzed
DATABASE_NAME="test"
# read all collection names, using mongo shell
COLLECTIONS=$(mongo $DATABASE_NAME --eval "db.getCollectionNames().join('\n');" --quiet)
echo -e "Found collections: \n$COLLECTIONS"
@todvora
todvora / Chickens.java
Created October 21, 2014 15:18
Chickens
/**
* https://plus.google.com/114134834346472219368/posts/CR1ZoNe9ojQ
*
* Three farmers were selling chickens at the local market.
* One farmer had 10 chickens to sell, another had 16 chickens to sell,
* and the last had 26 chickens to sell. In order not to compete with
* each other, they agreed to all sell their chickens at the same price.
* But by lunchtime, they decided that sales were not going so well,
* and they all decided to lower their prices to the same lower price point.
* By the end of the day, they had sold all their chickens.
@todvora
todvora / Mailgun.java
Created August 14, 2014 16:08
Mailgun Java Example
public static Response SendSimpleMessage() {
Client client = ClientBuilder.newClient();
client.register(HttpAuthenticationFeature.basic("api", "key-################################"));
WebTarget target = client.target("https://api.mailgun.net/v2/sandbox################################.mailgun.org/messages");
MultivaluedMapImpl formData = new MultivaluedMapImpl();
formData.add("from", "Mailgun Sandbox <postmaster@sandbox################################.mailgun.org>");
formData.add("to", "Tomas Dvorak <todvora@gmail.com>");
formData.add("subject", "Hello Tomas Dvorak");
formData.add("text", "Congratulations Tomas Dvorak, you just sent an email with Mailgun! You are truly awesome! You can see a record of this email in your logs: https://mailgun.com/cp/log . You can send up to 300 emails/day from this sandbox server. Next, you should add your own domain so you can send 10,000 emails/month for free.");
return target.request(MediaType.APPLICATION_FORM_URLENCODED).post(Entity.
@todvora
todvora / .travis.yml
Created June 20, 2014 12:55
Travis CI as a JS/CSS linter
language: node_js
node_js:
- "0.11"
install:
- npm install jshint -g
- npm install PrettyCSS -g
script:
- jshint main.js
- prettycss main.css