Skip to content

Instantly share code, notes, and snippets.

View michail-nikolaev's full-sized avatar

Michail Nikolaev michail-nikolaev

  • Belarus\Netherlands
View GitHub Profile
@michail-nikolaev
michail-nikolaev / build.gradle
Created September 9, 2012 22:47
Gradle - base file using Spring
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
@michail-nikolaev
michail-nikolaev / gist:3687820
Created September 9, 2012 22:56
Java - Guava - Memory Cache
private Cache<String, String> cache = CacheBuilder.newBuilder()
.concurrencyLevel(4)
.weakKeys() // check this
.maximumSize(10000)
.expireAfterWrite(10, TimeUnit.MINUTES)
.build();
@michail-nikolaev
michail-nikolaev / latency.txt
Created September 9, 2012 22:58 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@michail-nikolaev
michail-nikolaev / gist:3687870
Created September 9, 2012 23:10
Bash - simple parallel processing of files with markers
#!/bin/bash
#first argument - process number (from 0 to N)
#second argument - number of parallel processed (N)
#./script.sh 0 6
#./script.sh 1 6
#...
#./script.sh 5 6
@michail-nikolaev
michail-nikolaev / gist:3701729
Created September 11, 2012 20:22
PotsgreSQL - global replace punctions via regexp
select regexp_replace(name, '[[:punct:]]', '', 'g') from company where type = 'LIST'
@michail-nikolaev
michail-nikolaev / gist:3706554
Created September 12, 2012 13:21
PostgreSQL - Ubuntu - Install for remote access
apt-get install python-software-properties
add-apt-repository ppa:pitti/postgresql
apt-get update
apt-get install postgresql-9.2
/etc/postgresql/9.2/main
postgresql.conf:
data_directory = '/var/lib/postgresql/9.2/main'
listen_addresses = '*'
@michail-nikolaev
michail-nikolaev / httpd.conf
Created September 13, 2012 13:55
Apache 2 - HTTPS proxy
/etc/apache2/httpd.conf
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
ServerName example.com
<VirtualHost *:443>
ProxyPreserveHost On
ServerName example.com
@michail-nikolaev
michail-nikolaev / checkstyle.xml
Last active October 10, 2015 16:58
IDEA - formatter rules
<?xml version="1.0" encoding="UTF-8"?>
<code_scheme name="Itransition">
<option name="LINE_SEPARATOR" value="&#10;" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="1000" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="1000" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="WRAP_COMMENTS" value="true" />
<XML>
@michail-nikolaev
michail-nikolaev / gist:3754966
Created September 20, 2012 09:46
CDI - inject all beans with Qualifier
@Qualifier @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD }) @Retention(RetentionPolicy.RUNTIME)
public @interface Active {
}
@Active
public class SomeBeanA implements SomeInterface {
}
@Active
public class SomeBeanB implements SomeInterface {
}
@michail-nikolaev
michail-nikolaev / gist:3761054
Created September 21, 2012 11:52
PostgreSQL - info about locks
-- select * from pg_locks
-- select * from pg_stat_activity
select distinct on (locktype,datname,mode,relname,query) locktype,datname,relation,tuple,mode,relname,query from pg_locks as l
join pg_stat_activity as a on (a.datid=l.database and a.pid=l.pid)
join pg_class as c on (c.oid=relation)
where query not like '%pg_stat_activity%'