2017. 12. 25.

Argument list too long

파일 갯수가 많아서 파일 리스팅이 되지 않을 때
Argument list too long

  1. ls -U  를 사용
  2. ls -f

2017. 7. 2.

android bluetooth permission ( in manifest)

< ?xml version="1.0" encoding="utf-8"?>
< manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="mypackage">
...
< uses-permission android:name="android.permission.BLUETOOTH" />
< uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

< application ...
...>

2017. 4. 26.

bash cat multiple files contents in to single line without newlines


cat filename | tr "\n" "" > new_filename
echo "append line " >> new_filename

** by this command -->  tr "\n" ""
    It can remove newline. 


2017. 4. 9.

현미경으로 본 벚꽃 (microscope: cherry blossoms,pistil,pollen)- 显微镜

벚꽃잎 암술 (cherry flower pistil)


벚꽃잎 (cherryblossoms)



벚꽃가루(pollen)

꽃가루 - crop image: pollen)

수술(stamen)

수술 확대( stamen crop image)

microscope: Olympus CH,   ( with iphone 5s) 



2017. 4. 3.

Making anaconda python3 environment

# check installed module ;체크 인스톨 모듈
conda search python

# check environment ;환경확인
conda info --envs

#If env which you want exists, 
    linux$ source activate {envname}
    window$> activate {envname}

#cehck version :버전확인
   python --version

#없으면 생성 
  conda create --name py3. python=3

2017. 3. 31.

python3에서 sqlite3의 한글이 들어간 text field의 처리

sqlite3에서 필드가 text type일 때, 한글이 들어가 있지 않으면, 타입이 스트링이고, 들어가 있는 경우는 bytes가 된다. 그래서, json text를 가져와서 처리 하려고 하는 경우, json.loads는 str 타입만 받아 드리기 때문에 꺼내온 데이터의 타입을 체크하고, str 타입이 아니면 변환이 필요 하다.

def get_str( obj ):
    final_str = ""
    if type(obj) is bytes:
        final_str = obj.decode()
    else:
        final_str = obj

# select  obj from my_table. -- obj is text type.
sql = 'select obj from my_table'
sql_conn.execute( sql)
row = sql_conn.fetchone()
obj = row[0]
obj_json = json.loads( get_str( obj))

dht11 humidity temperature sensor

Method 1:

homepage에서 dht lib을 다운로드 받아서 ARDUINO LIB에 추가 

#include <dht.h> 추가
dht DHT;
#define DHT11_PIN 4
int chk = DHT.read11(DHT11_PIN); 
double h = DHT.humidity;
double t = DHT.temperature;
delay(1000);

Method 2:
#아래링크는 라이브러리가 다름 (문법도 다름)

2017. 3. 21.

python2 default encoding config

python2에서 한글 문제가 발생할때.. 기본 인코딩을 utf-8로 바꾸는 방법은 아래와 같다. 


import sys
reload(sys). # to use setdefaultencoding
sys.setdefaultencoding('utf-8')

2017. 3. 14.

Remove grep line of search result

ps aux |grep myprocess

-> It returns results include grep line. You can add more command to remove grep line

ps aux | grep myprocess | grep -v grep. 

-v option is reverse result. 

You will get the result which you want ~

2017. 1. 8.

how to send silent push notification in ios by firebase

I am using firebase of google.
I could develop push notification by firebase SDK.  but when I implemented silent-notification(in background state app), I found it is not easy. I googled many pages and I found solution finally.
For another firebase users,  I  am posting on my blog.

* background notification  payload spec.

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1

(example)

  1. {
  2. "aps" : {
  3. "content-available" : 1
  4. },
  5. "acme1" : "bar",
  6. "acme2" : 42
  7. }
   - you must add key and value ( "content-available': 1 ) on payload to send data for apns  but problem is that you cannot send that key by firebase-console although you add that-key on custorm-data section. Actually this value  exist outside of 'aps" key.  I found  firebase document, this document says " using . It is not useless in firebase console. 

* using API

I can success by using firebase api 

curl -X POST --header "Authorization: key=<apiauthkey>" \
    --Header "Content-Type: application/json" \
    https://fcm.googleapis.com/fcm/send \
    -d@

## payload.json  file 
{
    "to" : "",
    "priority": "normal",
    "content_available": true,
    "notification" : {
      "body" : "this is message",
      "title" : "notification Title",
      "link": "http://localhost"
    }
}
you can find "content-available:  key.  firebase sever convert  this key to 'content-available:1' 
Below message is  a converted  ''payload" as  "apns"  style ( You can verify in xcode debugging)

   "aps" : {
         "alert": {
                      "title": ...
                      "body": ...
          },
          "content-available": 1
   },
   "gcm.message.link": ...  
}
  # remark , Other fields are not included in 'alert' or 'aps' fields except 'title' and 'body'.  
  you must work more to send to apns  extra datas.
So, you make payload as below to send extra datas.
{
    "to" : "",
    "priority": "normal",
    "content_available": true,
    "notification" : {
      "body" : "this is message",
      "title" : "notification Title"
    },
    "data": {
          "link": ....
     }
}

you must implement code about notification processing code.
( That is not simple also.)

If you find something wrong or others, please comment ~