This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jshintCli = require('./node_modules/grunt-contrib-jshint/node_modules/jshint/src/cli/cli'); | |
// ... | |
grunt.initConfig({ | |
"jshint-report": { | |
options: { | |
outDir: 'build-reports' | |
}, | |
all: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kr.ne.outsider | |
object p001 extends App { | |
val source = 1 until 1000 | |
val result = source.filter(x => x % 3 ==0 || x % 5 == 0).sum | |
println(result) //233168 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kr.ne.outsider | |
object p002 extends App { | |
var cache:Map[Int, Int] = Map() | |
def fibonacci(x: Int): Int = { | |
cache.get(x) match { | |
case Some(t) => t | |
case _ => { | |
x match { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 사용자 추가 | |
$ sudo adduser USERNAME | |
# sudoers에 사용자 추가 ( outsider ALL=(ALL:ALL) ALL ) | |
$ visudo -f /etc/sudoers | |
# 기본 우분투용 의존성설치 | |
$ sudo apt-get install build-essential libssl-dev libev-dev | |
$ sudo apt-get install libpcre3 libpcre3-dev zlib1g zlib1g-dev | |
# add-apt-repository 사용 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PostgreSql (homebrew로 설치) | |
$ initdb /usr/local/var/postgres -E utf8 | |
## to Start | |
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start | |
## 상태확인 | |
$ pg_ctl -D /usr/local/var/postgres status | |
## stop | |
pg_ctl -D /usr/local/var/postgres stop -s -m fast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user outsider; | |
worker_processes 4; | |
#error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
#pid logs/nginx.pid; | |
events { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://github.com/mperham/sidekiq/commit/c1127165f8157807e7855c60f9849d20fb9fec24?utm_source=buffer&utm_medium=twitter&utm_campaign=Buffer&utm_content=buffer0a96b | |
def self.(╯°□°)╯︵┻━┻ | |
puts "Calm down, bro" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorize(n: Int, divider:Int = 2, accum:List[Int] = Nil):List[Int] = { | |
n match { | |
case a if a == 1 => accum | |
case a if a == 2 => n :: accum | |
case b if b % divider == 0 => factorize(b / divider, divider, divider :: accum) | |
case _ => factorize(n, divider + 1, accum) | |
} | |
} | |
def getMap(l:List[Int]) = l.groupBy(_.toString).mapValues(_.length) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val size = 100 | |
def sumOfPow(size:Int) = (1 to size).map( math.pow(_, 2) ).sum.toInt | |
def powOfSum(size:Int) = math.pow((1 to size).sum, 2).toInt | |
val result = powOfSum(size) - sumOfPow(size) | |
println(result) // 25164150 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.language.implicitConversions | |
import scala.language.postfixOps | |
class Prime(val i: Int) { | |
def isPrime = { | |
if (i <= 1) false | |
else if (i == 2) true | |
else { !(2 to (i-1)).exists(i % _ == 0)} | |
} | |
} |