This file contains 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 randint(*args): return 10 | |
guess = 10 |
This file contains 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
ssh-keygen -f ~/.ssh/id_rsa -t rsa -N '' | |
cat ~/.ssh/id_rsa.pub |
This file contains 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
after="http://mirrors.ustc.edu.cn/ubuntu/" | |
origin_src="http://us.archive.ubuntu.com/ubuntu/" | |
origin_scr="http://security.ubuntu.com/ubuntu" | |
sudo sed -i "s;$origin_src;$after;g" /etc/apt/sources.list | |
sudo sed -i "s;$origin_scr;$after;g" /etc/apt/sources.list | |
sudo apt-get update |
This file contains 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
defaults write com.apple.dock ResetLaunchPad -bool true;killall Dock |
This file contains 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
''' | |
digital_root(16) | |
=> 1 + 6 | |
=> 7 | |
digital_root(942) | |
=> 9 + 4 + 2 | |
=> 15 ... | |
=> 1 + 5 | |
=> 6 |
This file contains 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 whatCentury(year): | |
# code must go here | |
digit_year = int(year) | |
digit_century = (digit_year-1)/100 + 1 | |
a = {1:'st',2:'nd',3:'rd'} | |
if digit_century < 11 or digit_century > 20: | |
return str(digit_century)+a.get(digit_century % 10,'th') | |
return str(digit_century)+'th' |
This file contains 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 -*- | |
import smtplib | |
def send_email_over_smtp(to_email,email_content,login_user='no-reply@genscript.com',email_cc=None): | |
try: | |
smtpserver = smtplib.SMTP('10.168.2.119',timeout=60) | |
smtpserver.ehlo() | |
if email_cc: | |
header = 'To:' + to_email + '\n' +'CC:'+email_cc +'\n' + 'From: ' + login_user + '\n' + 'Subject:CR Notification\n' |
This file contains 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 -*- | |
__author__ = 'alex' | |
from lxml.html import parse | |
def parse_html(html_address,xpath_expression): | |
page = parse(html_address) | |
for href in page.xpath(xpath_expression): | |
print href |
This file contains 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
#!/usr/bin/python | |
import MySQLdb | |
db = MySQLdb.connect(host="localhost", # your host, usually localhost | |
user="john", # your username | |
passwd="megajonhy", # your password | |
db="jonhydb") # name of the data base | |
# you must create a Cursor object. It will let | |
# you execute all the queries you need |
This file contains 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 smtplib | |
def send_email_over_smtps(to_email,login_user,login_pwd): | |
smtpserver = smtplib.SMTP("10.168.2.120",587) | |
smtpserver.ehlo() | |
smtpserver.starttls() | |
smtpserver.ehlo | |
smtpserver.login(login_user, login_pwd) | |
header = 'To:' + to_email + '\n' + 'From: ' + login_user + '\n' + 'Subject:testing \n' | |
print header |