Skip to content

Instantly share code, notes, and snippets.

@ohjongin
ohjongin / env.js
Last active September 5, 2022 04:40
Set environment variables programtically
const hostname = 'sso.sisoul.kr'
// const env = require('env.json');
const env = {
"sso.sisoul.kr": {
"node_env": "production",
"api_server": "https://api.sisoul.kr"
},
"sso.dev.sisoul.kr": {
"node_env": "development",
"api_server": "https://api.dev.sisoul.kr"

Keybase proof

I hereby claim:

  • I am ohjongin on github.
  • I am ji5 (https://keybase.io/ji5) on keybase.
  • I have a public key ASC3gWMsPjY16gZdvOCl2TLeMF8nr_UdC44E9L4uxnLLfQo

To claim this, I am signing this object:

@ohjongin
ohjongin / objectKeysToLowerCase.js
Created September 11, 2018 07:34
Turn all the keys of an object to lower case
/** @summary objectKeysToLowerCase( input, deep, filter )
* returns a new object with all own keys converted to lower case.
* The copy can be shallow (default) or deep.
*
* Circular references is supported during deep copy and the output will have
* the same structure.
*
* By default only objects that have Object as constructor is copied.
* It can be changed with the "filter"-function.
*
/**
* (1)Get tweets by search keyword and (2)Stemming(Korean), (3)save to mysql finally
*/
var Promise = require('bluebird');
var TwitterKoreanText = require('twtkrjs');
var twitterKoreanText = new TwitterKoreanText({
stemmer: true, // (optional default: true)
normalizer: true, // (optional default: true)
@ohjongin
ohjongin / HangulUnicodeConverter.java
Created August 1, 2014 08:46
유니코드 vs. 한글코드로 상호 변환
// from: http://www.senun.com/Left/Programming/Java/Jsp/jsp_syntax_hangul.htm
// 유니코드를 한글코드로 변환
protected String uni2ksc (String Unicodestr) throws UnsupportedEncodingException {
return new String (Unicodestr.getBytes("8859_1"),"KSC5601");
}
// 한글코드를 유니코드로 변환
protected String ksc2uni(String str) throws UnsupportedEncodingException {
return new String( str.getBytes("KSC5601"), "8859_1");
@ohjongin
ohjongin / ActionBarSearchView.java
Created August 1, 2014 07:57
ActionBarActivity에서 SearchView 사용하기
@SuppressLint("NewApi")
public class ContactsActivity extends ActionBarActivity implements View.OnClickListener, AdapterView.OnItemClickListener, SearchView.OnQueryTextListener, SearchView.OnCloseListener {
@SuppressLint("NewApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.contacts, menu);
@ohjongin
ohjongin / Log.java
Last active January 2, 2016 08:29
Android용 Log class를 대체해서 사용 가능한 Log class로 Log 출력시 class 이름 및 줄번호가 같이 출력됨
/*
Copyright (C) 2013-2014. Jongin Oh
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@ohjongin
ohjongin / getUserProfileInfo.java
Created December 16, 2013 12:41
Get google account profile information
public static boolean hasPermission(Context context, String permission) {
int res = context.checkCallingOrSelfPermission(permission);
return (res == PackageManager.PERMISSION_GRANTED);
}
@SuppressLint("NewApi")
public static String getUserDisplayName(Context context) {
if (Build.VERSION.SDK_INT < 14) return "";
if (!hasPermission(context, "android.permission.READ_PROFILE")) return "";
@ohjongin
ohjongin / IsPhoneNumber.java
Created October 1, 2013 07:48
For API level 8 or above : Validation for a cell number in Android http://stackoverflow.com/questions/5958665/validation-for-a-cell-number-in-android
public boolean isPhoneNumber(String number) {
if (number == null || TextUtils.isEmpty(number)) {
return false;
}
// return Pattern.matches(PHONE_NUMBER_PATTERN, number.replace("-", ""));
return android.util.Patterns.PHONE.matcher(number).matches();
}
@ohjongin
ohjongin / EnableComponent.java
Created August 23, 2013 06:07
Android Quick Tip: Enabling and Disabling BroadcastReceivers at Runtime http://www.grokkingandroid.com/enabling-and-disabling-broadcastreceivers/
PackageManager pm = getPackageManager();
ComponentName newComposer = new ComponentName(getApplicationContext(), ComposerActivity.class);
pm.setComponentEnabledSetting(
newComposer,
is_new_composer ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
ComponentName oldComposer = new ComponentName(getApplicationContext(), SendSMSActivity.class);
pm.setComponentEnabledSetting(