Skip to content

Instantly share code, notes, and snippets.

View YUChoe's full-sized avatar

Yong-uk Choe YUChoe

View GitHub Profile
{"lastUpload":"2020-08-09T07:23:23.840Z","extensionVersion":"v3.4.3"}
#!/usr/bin/python
exclide_keys = ['Ethernet Channel Bonding Driver', 'Primary Slave', 'Up Delay (ms)',
'Down Delay (ms)', 'Slave queue ID', 'Duplex', 'Speed', 'Link Failure Count',
'Bonding Mode', 'MII Polling Interval (ms)']
def print_bond_status(dev):
md = {}
d = {}
with open("/proc/net/bonding/{}".format(dev)) as fp:
@YUChoe
YUChoe / loadbalancer
Last active May 7, 2020 00:31
ipvs start/stop
#!/bin/bash
usage ()
{
if [ -e $1 ]; then
echo "Usage: $0 {start|stop|status|restart}"
exit
fi
}
@YUChoe
YUChoe / source_backup.py
Created April 27, 2020 02:27
backup script
#!/usr/bin/python
import os
import time
host_name = 'SBC1'
bak_dir = '/home/backup/'
fn = '{}-{}.tar.xz'.format(host_name, time.strftime("%Y%m%d_%H%M"))
def log(s):
@YUChoe
YUChoe / remount.py
Created December 9, 2019 03:09
python 2.4 remount external usb
#!/usr/bin/python
import os
import time
def get_cmd_output(cmd):
tmp_fn = "/tmp/mnt_check.tmp"
os.system('%s > %s' % (cmd, tmp_fn))
fp = open(tmp_fn, 'r')
out = fp.read()
@YUChoe
YUChoe / logstash_main.conf
Last active August 26, 2019 05:28
logstash_main.conf
input {
file {
path => ["/var/log/network.log"]
sincedb_path => "/var/log/logstash"
start_position => "end"
type => "syslog"
tags => [ "netsyslog" ]
}
}
@YUChoe
YUChoe / l-temp.json
Created October 29, 2014 01:06
logstash-template1
{
"title": "Logstash Search",
"services": {
"query": {
"list": {
"0": {
"query": "*",
"alias": "",
"color": "#7EB26D",
"id": 0,
@YUChoe
YUChoe / test2.py
Created August 23, 2019 06:23
MISO coding-test-2
# Test 2
# yonguk.choe@gmail.com
#
# Write a command-line program that prints out the sum of two non-negative integers as input arguments.
# Input and output arguments are UTF-8 encoded Korean characters only listed as '일이삼사오육칠팔구' and '십백천만억조'.
# The less you use ifs, the higher you get scored.
# Google Korean Numbering System if you are not familiar with.
#
# Expected result:
# $ python3.6 test2.py 오백삼십조칠천팔백구십만천오백삼십구 삼조사천이만삼천구
@YUChoe
YUChoe / test1.py
Created August 23, 2019 06:22
MISO coding-test-1
# Test 1
# yonguk.choe@gmail.com
#
# Write a command-line program that prints out the sum of two non-negative integers as input arguments.
# You must not use any built-in BigInteger library or convert the inputs to integer directly.
#
# Expected result:
# $ python3.6 test1.py 123123111242342342003004400442255523 225244004004004234234234412312399999
# 123123111242342342003004400442255523 + 225244004004004234234234412312399999 = 348367115246346576237238812754655522
import os
import time
start_timestamp = 1550587841
for serial in os.listdir('.'):
for fn in os.listdir(serial):
ctime = os.stat(os.path.join(serial, fn)).st_ctime
if ctime > start_timestamp:
date_in_filename = fn.split('_')[0]