Skip to content

Instantly share code, notes, and snippets.

View codemilli's full-sized avatar
😇
Hooked on React Hooks

codemilli codemilli

😇
Hooked on React Hooks
  • Zemilli Design Studio
  • Seoul, South Korea
  • X @codemilli
View GitHub Profile
@codemilli
codemilli / gist:9db0c48f7d7fa0d18baa
Created January 23, 2016 01:29
how I write modules
My thoughts on writing tiny reusable modules that each do just one
thing. These notes were adapted from an email I recently sent.
***
If some component is reusable enough to be a module then the
maintenance gains are really worth the overhead of making a new
project with separate tests and docs. Splitting out a reusable
component might take 5 or 10 minutes to set up all the package
overhead but it's much easier to test and document a piece that is
import React from 'react';
class Test extends React.Component {
/**
* Test 의 생성자
* @constructs
* @param {Test.propTypes} props
*/
constructor(props) {
import React from 'react';
/**
* Define React Component $class$
*/
class $class$ extends React.Component {
/**
* Constructor for $class$
* @constructs
@codemilli
codemilli / network.java
Last active January 30, 2016 12:17
Get json data over network in Java
public JSONObject GET (String url) {
JSONObject json;
try {
URL target = new URL(url);
HttpURLConnection urlcon = (HttpURLConnection) target.openConnection();
InputStream in = new BufferedInputStream(urlcon.getInputStream());
BufferedReader streamReader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
StringBuilder responseStrBuilder = new StringBuilder();
String inputStr;
while ((inputStr = streamReader.readLine()) != null)
@codemilli
codemilli / RestApi.java
Created January 30, 2016 12:26
Async Task with JSON Api request
private class RestApi extends AsyncTask<String, Void, JSONObject> {
@Override
protected JSONObject doInBackground(String... params) {
return this.GET(params[0]);
}
@Override
protected void onPostExecute(JSONObject jsonObject) {
super.onPostExecute(jsonObject);
this.onReceived(jsonObject);
// test1.js
var name = 'hckrmoon';
module.exports = name;
var isActive = $('body').hasClass('active');
if (isActive) {
$('p').show();
}
// Application 의 state 를 View 에 저정하고 있다.
@codemilli
codemilli / deep-compare.js
Last active February 11, 2016 15:34
compare two object in javascript
const a = { blah: 1 };
const b = { blah: 1 };
const c = a;
const d = { blah: 2 };
const deepCompare = (obj1, obj2) => {
// 첫번째 오브젝트의 프로퍼티를 순회합니다.
for (var p in obj1) {
// 두 오브젝트 모두 가지고 있지 않는 프로퍼티이면 두 오브젝트는 같다고 할 수 없습니다.
if (obj1.hasOwnProperty(p) !== obj2.hasOwnProperty(p)) return false;
@codemilli
codemilli / replaceNotEdit.js
Created February 11, 2016 16:48
The way of replacing an object not editing with ES6
/*
* Declare Object
*/
let profile = {
name: 'yunmi',
age: '26',
nickname: 'pinky'
};
/*
@codemilli
codemilli / purefunction.js
Created February 11, 2016 17:37
pure function 을 이용한 state 값 대체
var state = {
name: 'jooyoung Moon'
};
var reduce = function reduce(state) {
return _.extends({}, state, {
name: 'hckrmoon'
});
};