Skip to content

Instantly share code, notes, and snippets.

package pl.lamvak.utils;
public class CompositingRepository<K, L, V> implements Repository<K, V> {
private Repository<K, L> first;
private Repository<L, V> second;
public CompositingRepository(Repository<K, L> first, Repository<L, V> second) {
this.first = first;
this.second = second;
}
package pl.lamvak.examples;
import com.google.common.collect.ImmutableList;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.jbake:jbake-core:jar:2.5.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ line 111, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ line 122, column 18
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.jbake:jbake-core:jar:2.5.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ line 122, column 18
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ line 111, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.jbake:jbake-core:jar:2.5.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ line 111, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ line 122, column 18
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.jbake:jbake-core:jar:2.5.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ line 111, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ line 122, column 18
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
@lamvak
lamvak / aero2.reconnector
Last active December 21, 2015 20:18
short bash script for reconnecting aero2 connection using network manager with modem manager
#!/bin/bash
while true;
do
sleep 30s;
ping -c 1 8.8.8.8 > /dev/null 2>&1;
if [[ $? != 0 ]];
then
echo "connection dropped; reconnecting now";
date;
killall -HUP modem-manager && sleep 30s && nmcli con up uuid <<PLACE your aero2 connection uuid here>> && sleep 120s;
@lamvak
lamvak / local-nginx
Created July 3, 2013 20:46
rule for logcheck that will ignore any HEAD/GET/POST reuqest with status either of 200/206/301/304, other than requests of /wp-admin or /wp-login (which will still be reported); log entries formatted with nginx configuration: log_format main '$remote_addr - $remote_user [$time_local] ' '"$request" $status $bytes_sent ' '"$http_referer" "$http_us…
^[.0-9]+ - [^ ]+ \[[^]]+\] "(HEAD|GET|POST) ([^"/][^"]*|/([^"w][^"]*|w([^"p][^"]*|(p([^"-][^"]*|(-([^"al][^"]*|(l([^"o][^"]*|(o([^"g][^"]*|(g([^"i][^"]*|(i([^"n][^"]*|(n([^".][^"]*|(\.([^"p][^"]*|(p([^"h][^"]*|(h([^"p][^"]*|(p[^ "?]+)))))))))))))))))|(a([^"d][^"]*|(d([^"m][^"]*|(m([^"i][^"]*|(i([^"n][^"]*|(n([^"/][^"]*)))))))))))))))))HTTP/[.0-9]+" (200|206|301|304) [0-9]+ "[^"]*" "[^"]*" "[^"]*"$
module Main where
import System.IO.MMap
import qualified Data.ByteString.Lazy as BL
somedata:: IO BL.ByteString
somedata = mmapFileByteStringLazy "some.data" Nothing
main = somedata >>= return . show . BL.last >>= putStrLn
{- some.data file is 1625424 bytes long (in case that matters)
@lamvak
lamvak / makedict.go
Created May 11, 2012 00:11
particularly disturbing fragment of my new poliqarp binding (in progress)
func MakeDict(prefix string, strings []string) (dict *Dict, err error) {
image_file_size := 0
dict, err = nil, nil
for _, s := range strings {
// accomodate the string itself, length counter and zero-byte marker
// for the reason of backwards debility
image_file_size += len(s) + 5
}
image_file, err := os.Create(prefix + `.image`)
defer image_file.Close()