Skip to content

Instantly share code, notes, and snippets.

:shipit:
Wow, github such social now

Ivan Muratov binakot

:shipit:
Wow, github such social now
Block or report user

Report or block binakot

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@binakot
binakot / macos-java-switch.bash
Created May 23, 2019
Aliases for different java version on MacOS
View macos-java-switch.bash
$ touch ~/.bash_profile
$ nano ~/.bash_profile
alias j12="export JAVA_HOME=`/usr/libexec/java_home -v 12`; java -version"
alias j11="export JAVA_HOME=`/usr/libexec/java_home -v 11`; java -version"
alias j10="export JAVA_HOME=`/usr/libexec/java_home -v 10`; java -version"
alias j9="export JAVA_HOME=`/usr/libexec/java_home -v 9`; java -version"
alias j8="export JAVA_HOME=`/usr/libexec/java_home -v 1.8`; java -version"
alias j7="export JAVA_HOME=`/usr/libexec/java_home -v 1.7`; java -version"
View docker-compose.yml
version: '3.4'
services:
db:
image: postgres:10
restart: always
environment:
- POSTGRES_DB=monaba
- POSTGRES_USER=monaba
- POSTGRES_PASSWORD=monaba
@binakot
binakot / a-virgil-security-tasks-highload2018.py
Last active Nov 12, 2018
The tasks by Virgil Security on HighLoad++ 2018 in Moscow. https://quest.virgilsecurity.com
View a-virgil-security-tasks-highload2018.py
import subprocess
import time
from itertools import product
from string import ascii_lowercase
def brute_force(assumption):
result = subprocess.run(['passw0rd',
'--cfg',
'passw0rd.yml',
@binakot
binakot / AsyncWriteFile.cs
Last active Jan 29, 2018
.NET 3.5 Async Write File. Read & Write 1 GB file in async mode with elapsed time metrics.
View AsyncWriteFile.cs
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
namespace AsyncReadWriteApplication
{
public static class Program
{
public static void Main()
@binakot
binakot / docker-stats.sh
Last active Nov 28, 2017
Docker stats with container names. Working on Linux and Windows.
View docker-stats.sh
$ docker stats --format "table {{.Container}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}"
@binakot
binakot / logstash.conf
Last active Jun 23, 2018
Logstash configuration file for Docker Swarm + Spring Cloud + Netflix OSS. Using Logback JSON Encoder in Spring Boot applications. Docker container -> Docker unix socket -> Logspout -> Logstash.
View logstash.conf
input {
# The default protocol is UDP.
udp {
port => 5000
codec => json {
charset => "UTF-8"
}
}
# But it is possible to change to TCP by adding +tcp after the logstash protocol when starting your container.
@binakot
binakot / ProviderExtendsConsumerSuper.java
Last active Aug 26, 2016
PECS (provider - extends, consumer - super)
View ProviderExtendsConsumerSuper.java
// If a parameterized type represents a T provider, use <? extends T>
// If it represents a T consumer, use <? super T>.
public static <T> T max(Collection<? extends T> col, Comparator<? super T> comp) { }
View DoNotReturnInFinallyBlock.java
public class Test {
public static void main(String[] args) {
try {
doSomething();
System.out.println("Don't program like this!");
} catch (RuntimeException e) {
System.out.println("Got it.");
}
}
View ThreadSafeCachingByThreadLocal.java
public final class DateAdapter extends XmlAdapter<String, Date> {
private static final ThreadLocal<DateFormat> THREAD_CACHE = new ThreadLocal<DateFormat> ();
@Override
public String marshal(Date value) throws Exception {
return getFormat().format(value);
}
@Override
You can’t perform that action at this time.