Skip to content

Instantly share code, notes, and snippets.

View nephilim's full-sized avatar

Dongwook Lee nephilim

View GitHub Profile
scala> case class Person(name:String, isMale: Boolean, children: Person*)
defined class Person
scala> val outsider = Person("Junghoon Byun", true)
outsider: Person = Person(Junghoon Byun,true,WrappedArray())
// 우선 cons 연산자 비슷한 놈을 만들었습니다.
// 이름은 co-ons(코-온스)라 했습니다. :)
// ex) List(1,1,1,2,3) == 1 ~: List(2,3)
object ~: {
def unapply(list:List[Int]):Option[(Int, List[Int])] = {
list match {
case Nil => None;
case x::xs => Some((x, xs.dropWhile( _ == x )));
}
}
@nephilim
nephilim / gist:794997
Created January 25, 2011 14:44
Q: 다음 init 코드의 문제점은 무엇일까요?
-(id) init
{
if([self initWithFile:@"data.txt"]) {
// ...
}
return self;
}
@nephilim
nephilim / ReadWriteLockTest.java
Created April 5, 2011 02:13
concurrency - ReadWriteLock
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import junit.framework.TestCase;
public class BasicConcurrentTest extends TestCase {
public void testReadWriteLock() throws Exception {
final Counter c = new Counter();
Thread write1 = new Thread() {
@nephilim
nephilim / LatchConditionTest.java
Created April 5, 2011 05:47
concurrency - Conditional Latch
public class LatchConditionTest extends TestCase {
public void testCodition() throws Exception {
final LatchCondition c = new LatchCondition();
Thread thread1 = new Thread() {
@Override
public void run() {
c.waitTillChange();
}
};
@nephilim
nephilim / SemaphoreTest.java
Created April 5, 2011 09:45
Semaphore Test
import java.util.Random;
import java.util.concurrent.Semaphore;
import junit.framework.TestCase;
public class SemaphoreTest extends TestCase
{
public void testSemaphore() throws Exception {
Runnable limitedCall = new Runnable() {
@nephilim
nephilim / tos3-ch06.m03.markdown
Created June 17, 2011 04:53
토비의스프링3 6장 4절~5절

6.4

  • 수동 프록시

    • JDK Proxy
      • Proxy.newProxyInstance()
      • new로는 생성 안됨-> 기존의 getBean()으로는 안됨
    • 결론: FactoryBean을 이용해 빈 생성 제어에 관여해야함
  • ProxyFactoryBean

    • ex: TxProxiedParcelDelivertServiceFactoryBean
@nephilim
nephilim / la-o-dan-s3-noti.markdown
Created July 9, 2011 07:00
라오단 3기 시작 공지

새로운 시즌의 스터디를 시작하며

첫 모임을 다음 주 토요일(7월 16일)에 할 예정입니다. 새로운 시작에 앞서 몇 가지 내용을 공유합니다.

2시즌

이전 시즌에 대한 내용을 요약하면 다음과 같습니다

@nephilim
nephilim / scala-competition-spec.scala
Created May 13, 2012 05:29
ScalaTest Spec for 20120513 Lasdan Competition
package pis.chap22.multimap
import org.junit.runner.RunWith
import org.scalatest.Spec
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class LasMultiMapSpec extends Spec {
describe("정의한 LasDan MultiMap의 기본 동작을 확인한다") {
it ("기본 동작") {
@nephilim
nephilim / memoization-with-anonymous-func.js
Last active December 13, 2015 18:09
Created to demonstrate one of possible problems with a sample code in chapter four of the book Javascript Patterns. For more information, refer to an example on page 92 of the book.
var func = function() {
if ( !func.cache ) {
console.log("cache initialized @" + new Date());
func.cache = "complex result";
}
return func.cache;
};
var func2 = func;