Skip to content

Instantly share code, notes, and snippets.

Sunghyouk Bae debop

Block or report user

Report or block debop

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
View AvroSerializer.kt
open class AvroSerializer @JvmOverloads constructor(val codecFactory: CodecFactory = CodecFactory.snappyCodec()) {
/**
* Avro instance 를 직렬화하여 byte array 로 변환합니다.
*/
fun <T : SpecificRecordBase> writeAvroObject(graph: T?): ByteArray {
return graph?.let {
val sdw = SpecificDatumWriter<T>(graph.schema)
val dfw = DataFileWriter(sdw).setCodec(codecFactory)
@debop
debop / package.scala
Created Feb 5, 2017
Port apply, let method in Kotlin Standard library to Scala
View package.scala
/** 모든 수형에 대해 builder 패턴을 제공하기 위해 사용 : Kotlin 의 apply method 와 같다 */
implicit class AnyRefExtension[T <: AnyRef](underlying: T) {
def build(builder: T => T): T = builder(underlying)
def let(procedure: T => Unit): Unit = procedure(underlying)
}
/** 모든 Option 에 대해 Kotlin 의 let 과 같은 기능을 제공한다 */
implicit class OptionExteions[T](underlying: Option[T]) {
def let(procedure: T => Unit): Unit = underlying foreach { procedure }
}
@debop
debop / Products.kt
Created Sep 4, 2016
Product in Kotlin ported from Scala
View Products.kt
interface Product {
val productArity: Int
fun elements(index: Int): Any?
fun toList(): List<*> = productIterator().toList()
fun productIterator(): Iterator<*> = object : Iterator<Any?> {
var currIndex = 0
override fun hasNext(): Boolean = currIndex < productArity
override fun next(): Any? = elements(currIndex++)
@debop
debop / Tuples.kt
Created Sep 4, 2016
Tuples in Kotlin ported from Scala
View Tuples.kt
data class Tuple1<out T1 : Any>(override val first: T1) : Product1<T1>, Serializable {
override fun toString(): String {
return "($first)"
}
}
data class Tuple2<out T1 : Any, out T2 : Any>(
override val first: T1,
override val second: T2) : Product2<T1, T2>, Serializable {
@debop
debop / ParallelIterates.kt
Created Jul 26, 2016
Kotlin 과 EclipseCollection 으로 구현한 병렬 처리 루틴
View ParallelIterates.kt
/*
* Copyright (c) 2016. Sunghyouk Bae <sunghyouk.bae@gmail.com>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@debop
debop / package.scala
Created Jan 18, 2016
Scala Implicit methods for Java 8 Functions
View package.scala
package kesti4j
import java.util.function._
/**
* @author sunghyouk.bae@gmail.com
*/
package object core {
object Implicits {
@debop
debop / GsCollectionsFunSuite.scala
Created Jan 17, 2016
using gs-collections with scala lambda expression.
View GsCollectionsFunSuite.scala
class GsCollectionsFunSuite extends AbstractCoreFunSuite {
test("FastList collection") {
val fastlist = FastList.newListWith[Int](1, 2, 3, 4, 5)
val collected: FastList[Int] = fastlist.collect(new Function[Int, Int] {
override def valueOf(obj: Int): Int = obj * obj
})
collected should contain allOf(1, 4, 9, 16, 25)
@debop
debop / GsCollections.scala
Created Jan 17, 2016
scala implicit methods for gs-collection interface function
View GsCollections.scala
package kesti4s.core.collections
import com.gs.collections.api.block.function._
import com.gs.collections.api.block.function.primitive._
import com.gs.collections.api.block.predicate._
import com.gs.collections.api.block.predicate.primitive._
import com.gs.collections.api.block.procedure._
import com.gs.collections.api.block.procedure.primitive._
/**
View EntityBase.java
package kr.hconnect.data.model;
import com.google.common.base.Objects;
import kr.hconnect.core.tools.HashTool;
import lombok.Getter;
import lombok.Setter;
/**
* Hibernate, JPA 의 모든 엔티티의 기본 클래스입니다.
*
View EntityBase.java
package kr.hconnect.data.model;
import com.google.common.base.Objects;
import kr.hconnect.core.tools.HashTool;
import lombok.Getter;
import lombok.Setter;
/**
* Hibernate, JPA 의 모든 엔티티의 기본 클래스입니다.
*
You can’t perform that action at this time.