Skip to content

Instantly share code, notes, and snippets.

View not-for-me's full-sized avatar
☺️
Fun coding time!

Woojin.joe not-for-me

☺️
Fun coding time!
View GitHub Profile
@not-for-me
not-for-me / tail_rec_exp.c
Last active November 4, 2015 03:26
tail recursion version: two's exponential function
int _twoExponential(int exponent, int acc) {
if ( exponent == 0 ) {
return acc;
}
acc *= 2;
return _twoExponential(--exponent, acc);
}
int exponential(int num) {
@not-for-me
not-for-me / EqualTest.java
Created December 28, 2015 08:14
In Java, 'equals' and '==' test code
public class EqualTest{
public static void main(String []args){
new EqualTest().test();
}
private void test() {
Dummy obj1 = new Dummy(1, 10.0);
Dummy obj2 = new Dummy(2, 20.0);
Dummy obj3 = new Dummy(1, 10.0);
System.out.println("obj1 == obj2: " + (obj1 == obj2) + " / obj1.equals(obj2): " + obj1.equals(obj2) );
@not-for-me
not-for-me / Equaltest.scala
Created December 28, 2015 08:26
In Scala, '==' is equals with 'equals()'. Try to execute below code sniff on the repl.
case class Dummy(a: Int, b: Double)
val obj1 = Dummy(1, 10.0)
val obj2 = Dummy(2, 20.0)
val obj3 = Dummy(1, 10.0)
obj1 == obj2
obj1 equals obj2
obj1 == obj3
@not-for-me
not-for-me / CaseClass.scala
Last active December 28, 2015 08:49
Scala의 케이스 클래스 특징~
// 스칼라의 문법인 케이스 클래스와 패턴 매칭 코드로 살펴보기
// regular, non-encapsulated data structures 가 필요할 때 케이스 클래스 사용
// Programming In Scala 15장 예제 코드로 구성 됨
abstract class Expr
case class Var(name: String) extends Expr
case class Number(num: Double) extends Expr
case class UnOp(operator: String, arg: Expr) extends Expr
case class BinOp(operator: String, left: Expr, right: Expr) extends Expr
@not-for-me
not-for-me / install.sh
Created February 24, 2017 01:37 — forked from mshick/install.sh
Installing Node.js with Homebrew and nvm
# Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install nvm
brew install nvm
# Export nvm environment
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
@not-for-me
not-for-me / LookAndSay.kt
Last active June 22, 2017 08:48
Simple LookAndSay Algorithm
// 0 is the first line from the lookAndSay result.
fun ant(line: Int): String {
var resultString = "1"
var lineCounter = line
while (lineCounter-- > 0) {
var tempBuffer = StringBuilder()
var curCompareChar = resultString[0]
var curCnt = 1
for (idx in 1..resultString.length - 1) {
@not-for-me
not-for-me / .bashrc
Created February 20, 2018 02:21 — forked from vsouza/.bashrc
Golang 1.5 setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
@not-for-me
not-for-me / reuse_agent.sh
Created July 9, 2018 06:35 — forked from MarkRose/reuse_agent.sh
Reuse existing ssh-agent or start a new one
# Reuse an existing ssh-agent on login, or create a new one. Append this to your .bashrc
# I have no idea who the author of the original concept was for reusing agents. This
# version also handles the case where the agent exists but has no keys.
GOT_AGENT=0
for FILE in $(find /tmp/ssh-* -type s -user ${LOGNAME} -name "agent.[0-9]*" 2>/dev/null)
do
SOCK_PID=${FILE##*.}