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
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"github.com/prometheus/procfs" | |
) |
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 tailf.py thefile | |
equals linux shell order : tail -f thefile | |
""" | |
import time | |
def trackline(thefile): | |
thefile.seek(0, 2) | |
while True: | |
line = thefile.readline() |
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 os | |
from nameko.rpc import rpc | |
from nameko.cli import run | |
rabbit_config = { | |
'AMQP_URI': os.environ['AMQP_URI'], | |
'rpc_exchange': 'smstaskrpc', | |
'max_workers': 20, | |
'parent_calls_tracked': 10, |
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
# encoding=utf8 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf-8') | |
import requests | |
STATION_TRAIN_CODE = 'G1952' | |
TRAIN_DATE = '2017-01-17' | |
subject = u'火车票余票提醒' |
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
# encoding=utf8 | |
import commands | |
import time | |
base_url = "http://www.omgbeaupeep.com/comics/mangas/The%20Walking%20Dead/001%20-%20The%20Walking%20Dead%20001/The-Walking-Dead-Comic-00{pic}.jpg" | |
for i in range(9,53): | |
image_url = base_url.replace('{pic}',str(i)) | |
order = 'wget %s ' % image_url | |
print order | |
res = commands.getstatusoutput(order) | |
# print res |
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 os | |
import smtplib | |
from email.mime.application import MIMEApplication | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
from email.utils import COMMASPACE, formatdate | |
def send_mail(send_from, send_to, subject, text, files, | |
smtpserver, sender_username, sender_password): | |
assert isinstance(send_to, list) |
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 csv | |
f = codecs.open('dfdf.csv' , 'w', 'utf_8_sig') | |
writer = csv.writer(f) | |
writer.writerow(['fdfd']) |
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 exchange(a_index,b_index,thelist): | |
temp = thelist[a_index] | |
thelist[a_index] = thelist[b_index] | |
thelist[b_index] = temp | |
print 'exchanged:',thelist[a_index],thelist[b_index] | |
return thelist | |
def insertorder(thelist): | |
for index,num in enumerate(thelist): | |
if index == 0: |
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 selectorder(thelist): | |
for index,num in enumerate(thelist): | |
minnum = num | |
minnum_index = index | |
for index2,num2 in enumerate(thelist[index+1:]): | |
if num2 < minnum: | |
minnum = num2 | |
minnum_index = index + index2 + 1 | |
thelist[index] = minnum |
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
class Solution(object): | |
def findMedianSortedArrays(self, nums1, nums2): | |
""" | |
:type nums1: List[int] | |
:type nums2: List[int] | |
:rtype: float | |
""" | |
nums = nums1 + nums2 | |
nums = sorted(nums) | |
total = len(nums) |
NewerOlder