Skip to content

Instantly share code, notes, and snippets.

@xodhx4
xodhx4 / evenArr.scala
Last active August 2, 2019 15:52
[Scala functional Example] Examples of scala code that doing map, reduce, and filter #example #scala
/*filter
//Filter array by their index using collect
//EX) Get part of array that its index is even
*/
// arr is List[Int]
val evenArr = arr
.zipWithIndex
.collect {
case (vali, ind) if (ind%2==1) => vali
@xodhx4
xodhx4 / MapExample.scala
Last active May 17, 2018 17:13
Map(dictionary) initialize and pattern matching example
// initialize scala mutable map
var book = collection.mutable.Map[String,String]()
book += ("Key" => "Value")
// initialize scala immutable map
val book2 = Map("Tap" -> "name")
def printtuple(str: String, bookmap: collection.mutable.Map[String,String]) {
// Get scala Map value from Key
val number = bookmap.get(str)
number match {
@xodhx4
xodhx4 / test_list_empty.py
Created April 22, 2018 05:18
how to test list is empty
a = list()
# test list is empty
if not a:
print('list is empty')
@xodhx4
xodhx4 / myLogger.py
Last active August 2, 2019 15:48
[python logger] 스트림과 파일 로그를 동시에 생성하기 위한 python logger 세팅 #python #logger
'''my.log 파일과 스트림 로그를 생성하기 위한 파일입니다.'''
# https://stackoverflow.com/questions/7173033/duplicate-log-output-when-using-python-logging-module
import logging
loggers = dict()
def getMyLogger(name='basic'):
global loggers
# 로깅 기본 포멧 설정
@xodhx4
xodhx4 / docker.sh
Last active August 2, 2019 15:43
[docker 자동 설치 script] #docker #install
curl -fsSL https://get.docker.com/ | sudo sh
@xodhx4
xodhx4 / dockerfile
Last active August 2, 2019 15:44
[dockerfile 프록시 설정] #docker #proxy
ENV http_proxy "http://168.219.61.252:8080"
ENV https_proxy "http://168.219.61.252:8080"
@xodhx4
xodhx4 / pytest-cov.sh
Created September 18, 2019 17:36
[pytest] pytest usage #test #python #pytest
#pip install pytest-cov
pytest --cov-report term --cov=myproj tests/
@xodhx4
xodhx4 / readFile.java
Last active February 18, 2020 13:43
[In java, make file to Inputstream] For ps, make Filestream as Inputstream #Inputstream #Filestream
class FileReader {
public static void main(String[] argc) {
InputStream inputStream = FileReader.class.getClass().getResourceAsStream("/RootFromResourceFile/b1018.txt");
// inputStream = System.in
Scanner scanner = new Scanner(inputStream);
}
}
@xodhx4
xodhx4 / twoDimArray.java
Last active February 18, 2020 13:36
[이차원 배열 생성 및 initialize] 자바에서 이차원 배열을 생성하고 새로운 값을 할당한다 #array
public static void readAll(InputStream inputStream) {
Scanner scanner = new Scanner(inputStream);
char[][] map = new char[N][];
for (int i=0; i<N; i++) {
map[i] = scanner.nextLine().toCharArray();
}
}
@xodhx4
xodhx4 / createAndAdd.java
Created February 18, 2020 13:43
[ArrayList 사용법] 기본적인 ArrayList의 사용법 #ArrayList #add #get #sort
public static void addArrayList() {
ArrayList<Integer> lists = new ArrayList<>();
for (int i =0; i<9; i++) {
lists.add(i);
}
for (int i =0; i<9; i++) {
lists.get(i);
}
}