2018. 11. 27.

batch replace string in files by command line

batch replace string in files by command line
sed -i — ‘s/want_str/rep_str/g’ file_patterns

ex) -i — ‘s/abc/123/g’ *.txt




November 27, 2018 at 01:06PM

2018. 11. 10.

Listing wifi at command line in Mac OS X

Listing wifi at command line in Mac OS X
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s

Or

cd /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources 
./airport -s 


November 10, 2018 at 04:16PM

2018. 10. 31.

Passing all arguments to other functions

Passing all arguments to other functions

using $@

ex)  run.sh
    # instead  
   oher_command $1 $2 ...
    # with
    other_command $@ 

!! That’s all.


October 31, 2018 at 12:30PM

2018. 9. 22.

Upload string to S3 with boto3 python

Upload string to S3 with boto3 python
# this code sometimes occurs error.  Body parameter is byte or file handle.
body_string = “abc..."
s3.client.Object(bucketname, key).put(Body= body_string) 

# using encode method. 
s3.client.Object(bucketname, key).put(Body=body_string.encode()) 


September 21, 2018 at 04:06PM

2018. 9. 5.

Write custom log in python

Write custom log in python
base_record = dict(
    name=‘module.sub’, levelname=‘error’, levelno=logging.ERROR, 
level=logging.ERROR,
funcName=‘callername’, lineno=0, args=(), exe_info=None)

record = logging.makeLogRecord(dict(base_record, msg=“some messages”))
logger.handle(record) # write log



September 05, 2018 at 11:10AM