Skip to content

Instantly share code, notes, and snippets.

View ebongzzang's full-sized avatar

Sangbong Lee ebongzzang

View GitHub Profile
@ebongzzang
ebongzzang / list.py
Created October 4, 2018 02:12
nested list comprehesion, flatten and create dict from tuple list
subland_dict = {
'hi':['hi1','hi2','hi3'],
'hello': ['hello1', 'hello2', 'hello3']
}
res = [[(y,k) for y in v] for k, v in subland_dict.items()]
# [[('hi1', 'hi'), ('hi2', 'hi'), ('hi3', 'hi')], [('hello1', 'hello'), ('hello2', 'hello'), ('hello3', 'hello')]]
merged = dict(list(itertools.chain.from_iterable(res)))
# {'hi1': 'hi', 'hi2': 'hi', 'hi3': 'hi', 'hello1': 'hello', 'hello2': 'hello', 'hello3': 'hello'}
@ebongzzang
ebongzzang / README-Template.md
Created August 9, 2018 08:22 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@ebongzzang
ebongzzang / Solution.scala
Created August 9, 2018 05:26
climbing the leaderboard
object Solution {
// Complete the climbingLeaderboard function below.
def climbingLeaderboard(scores: Array[Int], alice: Array[Int]) = {
val score2 = scores.distinct
val length = score2.length-1
var j = length
for(i:Int <- alice) yield {
val cond = score2.search[Int](i)(Ordering[Int].reverse) match {
@ebongzzang
ebongzzang / Solution.scala
Created August 9, 2018 05:26
climbing the leaderboard
object Solution {
// Complete the climbingLeaderboard function below.
def climbingLeaderboard(scores: Array[Int], alice: Array[Int]) = {
val score2 = scores.distinct
val length = score2.length-1
var j = length
for(i:Int <- alice) yield {
val cond = score2.search[Int](i)(Ordering[Int].reverse) match {
@ebongzzang
ebongzzang / main2.groovy
Created August 7, 2018 07:02
kakao_Recruitment_5
def main2() {
// def reader = new Scanner(System.in)
// String str1 = reader.next()
// String str2 = reader.next()
//
// println(str1, str2)
def characters = 'FRANCE'.trim().toCharArray()
def characters2 = 'french'.trim().toCharArray()
@ebongzzang
ebongzzang / build.gradle
Created July 25, 2018 07:05
submit spark-job to livy as gradle task
task submitLivy(type: Exec, dependsOn: shadowJar ) {
def targetUrl = 'http://localhost:8998/batches'
def sparkOption = file("livy.json").getText("utf-8")
def curlComm = ['curl', '-X', 'POST', '-H', 'Content-Type: application/json', targetUrl, '-d', sparkOption]
doLast {
ProcessBuilder builder = new ProcessBuilder(curlComm)
println builder.command()
Process process = builder.start()
@ebongzzang
ebongzzang / hanoi.groovy
Created July 5, 2018 04:29
Tower of hanoi In groovy
def main() {
def reader = new Scanner(System.in)
int a = reader.nextInt()
BigInteger count = (2 ** a) -1
println(count)
boolean canPrint = a <= 20
def hanoiTower
hanoiTower = { int num, int from, int to, int aux ->
@ebongzzang
ebongzzang / recursion.groovy
Created July 4, 2018 06:32
groovy recursive closure
def main() {
def input = 192
def gcd
gcd = { int val, int remainder ->
if(remainder ==0){
return val
}
@ebongzzang
ebongzzang / lua-csv.lua
Created June 25, 2018 09:00
wrc lua script with csv
local csv = require("csv")
local f = csv.open("device-table2.csv", {['header'] = true})
local columns = {"id", "free_storage_in_byte", "used_storage_in_byte"}
local parameters = {}
local counter = 0
for fields in f:lines() do
perRowCondition = {}
for index, value in pairs(fields) do
for _,v in pairs(columns) do
@ContextConfiguration
@DataJpaTest
class DbunitWithGenesisTest extends Specification {
private static Logger log = LoggerFactory.getLogger(DbunitWithGenesisTest.class)
def hi = 1L..10L
// testEntityManager는 persistence context 테스트 목적으로 사용된다.
// 즉, 실제 데이터베이스에 적용할수는 없다
@Autowired