Skip to content

Instantly share code, notes, and snippets.

View javarouka's full-sized avatar
🎯
Focusing

Yi, Hangehee javarouka

🎯
Focusing
View GitHub Profile
function forFn(n) {
if(n === 0) return 1;
var a = 1;
for(var i = 0; i<n; i++) a = a * 2
return a
}
function recursiveFn(n, m) {
if(!m) return factRecursive(n, 1)
if(n === 0) return m;
@javarouka
javarouka / fibo.kt
Created March 26, 2019 08:38
Kotlin fiobnachi
fun fiboRecursive(v:Int): Int =
if(v <= 2) 1
else fiboRecursive(v-1) + fiboRecursive(v-2)
fun fiboLoop(v:Int): Int {
if(v <= 2) return 1
var result = 0
var prev1 = 1
var prev2 = 1
@javarouka
javarouka / gen.kt
Created March 26, 2019 02:10
generics
// Java
interface Source<T> {
T next();
}
void demo(Source<String> strs) {
Source<? extends Object> objects = strs;
}
// @Kotlin
import java.util.ArrayList;
import java.util.List;
public class Test {
static class Creature {}
static class Animal extends Creature {}
static class Person extends Animal {}
static class Singer extends Person {}
static class GirlGroup extends Singer {}
@javarouka
javarouka / SingletonTestLayholder.java
Created December 14, 2017 02:38
Singleton - Layholder
package io.javarouka.gist.pattern;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SingletonLayholder {
static {
log.debug("SingletonLayholder initialized");
}
/*eslint no-console:0 */
import React from 'react';
const DEFAULT_STYLE = 'font-weight:bold; color:';
const PREV_STATE_STYLE = `${DEFAULT_STYLE}gray`;
const ACTION_STYLE = `${DEFAULT_STYLE}blue`;
const NEXT_STATE_STYLE = `${DEFAULT_STYLE}green`;
const showLog = (message, params, styles) => console.log(`%c${message}`, styles, params);
@javarouka
javarouka / foucs.js
Last active July 19, 2017 06:27
forAsdf
class SomeContainer extends Component {
state = { value: '' };
changeText = (e) => this.setState({
value: e.target.value
});
componentDidMount() {
this.props.findOrder({ orderId: 100012134 });
const Test = (_ => {
const weakMap = new WeakMap();
return class {
constructor() {
weakMap.set(this, _=> console.log('test'))
}
doMethod() {
weakMap.get(this)();
}
};
class Diff extends React.Component {
constructor(props) {
super(props);
this.name = "HaHa!"
}
handleArrow = () => {
console.log(this.name);
};
@javarouka
javarouka / routeMap.js
Created June 6, 2017 15:44
dynamic-route with react-router 4.x
import { injectReducer } from 'store/createRootReducer'
const appendReducer = (store, key, reducerModule) => {
const reducer = reducerModule.default || reducerModule;
injectReducer(store, { key, reducer });
};
// TODO: 계층형 라우팅 추가 필요
export const routes = [
{