Skip to content

Instantly share code, notes, and snippets.

View ziwon's full-sized avatar
🗿
?!

Yeongpil Y. ziwon

🗿
?!
View GitHub Profile
@ziwon
ziwon / TreeQueryAdapter.java
Created November 25, 2012 10:29
TreeQueryAdapter for ExpandableList using ORMLite's Mapper
package com.xpirator.db;
import java.sql.SQLException;
import com.j256.ormlite.android.AndroidCompiledStatement;
import com.j256.ormlite.android.AndroidDatabaseResults;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.StatementBuilder;
@ziwon
ziwon / grokDir.rb
Last active December 16, 2015 10:19
Running Grok pattern on log files in some directory
#!/usr/bin/env ruby
###############################################
#
# grokDir.rb
#
# Version 0.1
#
# > ruby grokDir.rb -d "c:/Logs/**/*.log" -p "%{DATESTAMP:timestamp}"
#
###############################################
@ziwon
ziwon / .tmux.conf
Last active June 8, 2021 02:21
tmux configuration with powerline, solarized color scheme & other useful plugins
# change prefix key
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# 'v' key for selection
bind-key -t vi-copy 'v' begin-selection
# base index
set -g base-index 1
@ziwon
ziwon / gist:7400704
Created November 10, 2013 16:54
How to build a chain to manage all subsequent tasks? If we have a set of N tasks in some cases, then we should call `then(fn)` N -1 times, right?
TaskBuilder.prototype.falldown = function(func, handler) {
var self = this;
Q.fcall(func).then(function(cb) {
return function(next) {
cb(function(fn, args) {
fn(args, next);
});
};
}).then(function(cb) {
@ziwon
ziwon / gist:7652757
Last active December 29, 2015 09:49
Functor, Applicative Functor and Monad
// A => B
trait Functor[F[_]] {
def fmap[A, B](f: A => B): F[A] => F[B]
}
// F[A => B]
trait Applicative[F[_]] extends Functor[F] {
def pure[A](a: A): F[A]
def apply[A, B](f: F[A => B]): F[A] => F[B]
}
@ziwon
ziwon / >:>.scala
Last active December 29, 2015 12:48
A Note on Capturing type constraints with evidence parameters
// 7.3.2 Capturing type constraints from Joshua's "Scala in Depth"
scala> def pop[A, C <: Seq[A]](col : C) = col.head
scala> pop(List(1, 2))
// error: inferred type arguments [Nothing,List[Int]] do not conform to method pop's type parameter bounds [A,C <: Seq[A]]
// pop(List(1, 2))
// ^
scala> def pop[C, A](col : C)(implicit ev: C <:< Seq[A]) = col.head
scala> pop(List(1, 2))
@ziwon
ziwon / typelevel.scala
Created December 4, 2013 12:34
Heterogeneous typed list로 살펴보는 타입레벨 프로그래밍
// 7.4.1 Heterogeneous typed list
/*
Scala는 오버로딩과 오버라이딩 다형성을 안 좋아함.
오버로딩은 파라미터의 타입이 런타임시에 지워져 버림
오버라이딩은 상속을 해야한다는 제한 있음.
Scala는 타입 생성자를 이용한 다형성을 좋아함.
*/
sealed trait HList {}
@ziwon
ziwon / tree.sh
Created September 21, 2015 05:10
Binary Tree in Scala
#!/bin/sh
exec scala -savecompiled "$0" "$@"
# Output
# --------------------------------------------------------
# Node(1,Node(2,Leaf(4),Leaf(5)),Node(3,Leaf(6),Leaf(7)))
# ========================================================
# size 7
# height 3
# leafCount 4
@ziwon
ziwon / tshark.sh
Created December 27, 2015 17:11
ssl decoding with tshark
sudo tshark -o "ssl.desegment_ssl_records: TRUE" \
-o "ssl.desegment_ssl_application_data: TRUE" \
-o "ssl.keys_list:192.168.0.1,443,http,your.key.pem" \
-o "ssl.debug_file:ssldebug.log" \
-f "tcp port 443" \
-R "ssl" \
-V -x
@ziwon
ziwon / phabricator.conf
Created January 4, 2017 08:18
Nginx Configuration for Phabricator
upstream php-phabricator-handler {
server unix:/run/php/php7.0-fpm.sock;
}
server {
listen 80;
server_name proj.felixlab.io;
return 301 https://$host$request_uri;
}