Skip to content

Instantly share code, notes, and snippets.

View YUChoe's full-sized avatar

Yong-uk Choe YUChoe

View GitHub Profile
#!/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()
{"lastUpload":"2020-08-09T07:23:23.840Z","extensionVersion":"v3.4.3"}
@YUChoe
YUChoe / test2.py
Created August 23, 2019 06:23
MISO coding-test-2
# Test 2
# [email protected]
#
# 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
# [email protected]
#
# 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]
@YUChoe
YUChoe / flask_gunicorn_app.py
Last active June 25, 2018 02:24 — forked from KatiRG/flask_gunicorn_app.py
Running Flask with Gunicorn
# coding: utf-8
# This gist shows how to integrate Flask into a
# custom Gunicorn-WSGI application described
# here: http://docs.gunicorn.org/en/stable/custom.html
from __future__ import unicode_literals
import multiprocessing
import gunicorn.app.base
from gunicorn.six import iteritems
@YUChoe
YUChoe / chkroute.pl
Last active November 14, 2016 02:26
static routing
#!/usr/bin/perl
foreach my $l (split(/\n/, `route -n`)) {
my @ll = split(' ', $l);
$r{$ll[0]} = [$ll[0], $ll[2], $ll[1]];
}
foreach my $l (split(/\n/, `cat /usr/local/shieldone/etc/route/addroute`)) {
@ll = split(' ', $l);
if ( $ll[0] eq $r{$ll[0]}[0]