Skip to content

Instantly share code, notes, and snippets.

@hagun
hagun / MeaningOfThis.java
Last active February 2, 2017 08:09
anonymous class
public class MeaningOfThis {
public final int value = 4;
public void doIt() {
int value = 6;
Runnable r = new Runnable() {
public final int value = 5;
public void run() {
int value = 10;
System.out.println(this.value);
}
@hagun
hagun / db.java
Created November 19, 2015 02:32
삼항연산자
public class Db {
public static void main(String[] args) {
Object a = (true ? new Integer(1) : new Double(1.0));
System.out.println(a);
if (a instanceof Integer) {
System.out.println("Integer");
} else if (a instanceof Double) {
System.out.println("Double");
}
@hagun
hagun / gist:3dcb059da0018330ce19
Created November 17, 2015 08:37
에라토스테네스의 체
public void prime() {
long startAt = System.currentTimeMillis();
long max = 100000L;
SortedSet<Long> arr = new TreeSet<>();
for (long i = 2 ; i < max ; i++) {
arr.add(new Long(i));
}
long last = 0L;
do {
@hagun
hagun / gist:6506776
Created September 10, 2013 08:57
stdin을 읽어서 tcp socket으로 전송. python버전
#!/usr/bin/python
import sys
import socket
HOST = '192.168.161.117'
PORT = 4333
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
for line in sys.stdin:
@hagun
hagun / gist:6506214
Last active December 22, 2015 17:29
stdin에서 line을 읽어서 netcat으로 원격지에 tcp 전송 첫번째 parameter를 이용해서 log format을 수정
#!/bin/bash
while read LINE; do
echo "$1:{${LINE}}" | nc 192.168.161.117 3333
done
# Analyze text: "the <b>quick</b> bröwn <img src="fox"/> &quot;jumped&quot;"
curl -XPUT 'http://127.0.0.1:9200/foo/' -d '
{
"index" : {
"analysis" : {
"analyzer" : {
"test_1" : {
"char_filter" : [
"html_strip"