Skip to content

Instantly share code, notes, and snippets.

@freestrings
freestrings / docker_mysql_setting.txt
Created January 12, 2018 06:34
docker mysql host -> container
select @password:=PASSWORD('root');
GRANT USAGE ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B';
create database testa;
GRANT ALL PRIVILEGES ON `testa`.* TO 'root'@'%';
flush privileges;
SET general_log = 1;
@freestrings
freestrings / add_rust_path.sh
Created March 26, 2017 15:32
Cargo 패키지 시스템 - Cargo로 프로젝트 생성부터 배포까지
echo "source $HOME/.cargo/env" >> ~/.bash_profile
source ~/.bash_profile
package fs.lock;
import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.IntStream;
public class LockingOfByteBufferAllocation {
@freestrings
freestrings / SimpleKafkaBufferPool.java
Last active September 20, 2022 05:32
#Kafka Producer는 buffer.memory 설정만큼 메모리를 사용해 메시지를 보낸다. 어떻게 메모리를 제한하고 쓰레드를 처리하는지 BufferPool을 간단히 재구현해 살펴봄..
package fs.memory;
import java.nio.ByteBuffer;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.IntStream;
package fs;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
// https://www.ibm.com/developerworks/linux/library/j-zerocopy/
package sendfile;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
public class TraditionalClient {
public class TestCurlProcess {
public static void main(String... args) throws Exception {
System.out.println("'-f' option exit code : " + execute("curl -f http://www.404.site")); // 6
System.out.println("no option exit code : " + execute("curl http://www.404.site")); // 6
System.out.println("-f option exit code : " + execute("curl -f http://localhost/force_error.php")); // 22
System.out.println("no option exit code : " + execute("curl http://localhost/force_error.php")); // 0
}
private static Integer execute(String cmd) throws Exception {
public class Dummy {
private String name;
@HelloWorld
public String getName() {
return this.name;
}
public static void main(String... args) {
@freestrings
freestrings / gist:bae24951f33746af4a80
Created May 19, 2015 02:15
[bookmark] redis-benchmark
redis-benchmark -n 1000000 -r 100000000 -h localhost -q -c 100 -p 6379
@freestrings
freestrings / Convariant.java
Last active December 25, 2015 08:29
In Scala, arrays are not covariant.
package freestrings.playground
public class ConvariantInjava {
class A {
}
class B extends A {
}