This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM centos:centos7 | |
| MAINTAINER Gary Lee <garywlee@gmail.com> | |
| # Install ssh server. | |
| RUN yum install -y which openssh-clients openssh-server | |
| RUN ssh-keygen -f /etc/ssh/ssh_host_rsa_key | |
| RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key | |
| RUN sed -i '/pam_loginuid.so/c session optional pam_loginuid.so' /etc/pam.d/sshd | |
| # Set root's password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!python | |
| import glob | |
| for fn in glob.glob('*.txt'): | |
| with open(fn, 'r') as fd: | |
| for ln, content in enumerate(fd): | |
| print '%s:%d> %s' % (fn, ln, content), | |
| print '\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import msvcrt | |
| round = 0 | |
| while True: | |
| if msvcrt.kbhit(): | |
| if msvcrt.getch() in ('q', 'Q'): | |
| print "Quit" | |
| break | |
| print "Current round: %d" % round | |
| round += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| """ | |
| Plot spectrum of given signal. | |
| """ | |
| from numpy import sin, linspace, pi | |
| from pylab import plot, show, title, xlabel, ylabel, subplot | |
| from scipy import fft, arange | |
| def plot_spectrum(y, freq_sampling): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!python | |
| # coding: utf-8 | |
| import os | |
| import re | |
| import os.path as path | |
| import glob | |
| import codecs | |
| src_folder = 'xxx' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import os | |
| from subprocess import CalledProcessError, check_output | |
| def cmd(cmd_arg): | |
| """Execute shell command in Perl-like manner.""" | |
| ctx = globals().copy() | |
| ctx.update(sys._getframe(1).f_locals) | |
| for ln in check_output(cmd_arg.format(**ctx), shell=True).split(os.linesep): | |
| yield ln |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fmt(spec): | |
| """Format string with caller's variable scope.""" | |
| return spec.format(**sys._getframe(1).f_locals) | |
| # fmt() can be also written in lambda form. | |
| # fmt = lambda s: s.format(**sys._getframe(1).f_locals) | |
| a = 10 | |
| b = 20 | |
| c = 30 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!python | |
| # coding: utf-8 | |
| """Generate content according to INI and template.""" | |
| import sys | |
| import os | |
| import codecs | |
| from argparse import ArgumentParser | |
| from ConfigParser import ConfigParser | |
| from collections import OrderedDict |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!python | |
| # coding: utf-8 | |
| """Generate content according to YAML and template.""" | |
| import sys | |
| import os | |
| import codecs | |
| import yaml | |
| from argparse import ArgumentParser | |
| from mako.template import Template |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from bokeh.plotting import figure, output_file, vplot, show | |
| import numpy as np | |
| import random | |
| n = 1024 | |
| a = 1.0 | |
| sample_period = 0.001 | |
| t = np.linspace(0, n * sample_period, n) | |
| dt = t[1] - t[0] | |
| data = np.abs(np.sin(t * 2 * np.pi) * a) |