Skip to content

Instantly share code, notes, and snippets.

View outsideris's full-sized avatar

Outsider outsideris

View GitHub Profile
@outsideris
outsideris / gist:5402097
Created April 17, 2013 06:00
jslint-report_in_grunt.js
var jshintCli = require('./node_modules/grunt-contrib-jshint/node_modules/jshint/src/cli/cli');
// ...
grunt.initConfig({
"jshint-report": {
options: {
outDir: 'build-reports'
},
all: {
@outsideris
outsideris / p001.scala
Last active December 16, 2015 11:09
euler for PiS study
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
}
@outsideris
outsideris / p002.scala
Last active December 16, 2015 11:09
euler for PiS Study
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 {
@outsideris
outsideris / ubuntu-setting.sh
Last active December 16, 2015 13:59
Ubuntu setting & troubleshutting
# 사용자 추가
$ 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 사용
@outsideris
outsideris / osx.sh
Created April 23, 2013 17:58
OSX Setting command
# 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
@outsideris
outsideris / nginx.conf
Created April 24, 2013 02:55
nginx setting skeleton
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 {
// 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
@outsideris
outsideris / p005.scala
Created May 18, 2013 13:22
euler problem 5
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)
@outsideris
outsideris / p006.scala
Created May 18, 2013 13:22
euler problem 6
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
@outsideris
outsideris / p007.scala
Created June 1, 2013 17:38
euler problem 7
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)}
}
}