Skip to content

Instantly share code, notes, and snippets.

@ghostlyman
ghostlyman / proxyfile
Created October 21, 2017 15:40 — forked from Latias94/proxyfile
shadowsock 配置
# 这是本地监听的HTTP代理的端口地址。
# SpechtLite还会自动启用一个位于port+1的SOCKS5代理服务器。
# 选择大于1024的未被占用的端口即可。
port: 9090
# 下面定义adapter,即远程代理服务器的信息。每个adapter代表一个远程代理服务器。
adapter:
# 在定义规则的时候,我们使用id来引用当前定义的adapter。
# 程序自动定义了一个id为direct的adapter,使用这个adapter将会不走代理直接连接目标服务器。因此自定义id不能为direct。
# - id: adapter1
# # 类型为HTTP代理服务器.
@ghostlyman
ghostlyman / daemon.py
Created July 22, 2017 11:00 — forked from marazmiki/daemon.py
Python daemon example
#!/usr/bin/env python
# coding: utf-8
import argparse
import os
import sys
import time
import atexit
import logging
import signal
@ghostlyman
ghostlyman / WechatSmartWish.py
Created July 5, 2017 05:39 — forked from littlecodersh/WechatSmartWish.py
Demo of sending smart wishes through wechat.
#coding=utf8
import itchat, time
SINCERE_WISH = u'祝%s新年快乐!'
REAL_SINCERE_WISH = u'祝%s新年快乐!!'
def send_wishes():
friendList = itchat.get_friends(update=True)[1:]
for friend in friendList:
# 如果不是演示目的,把下面的方法改为itchat.send即可
@ghostlyman
ghostlyman / main.py
Created July 5, 2017 05:38 — forked from littlecodersh/main.py
Main script behind itchat robot
#coding=utf8
import itchat
# tuling plugin can be get here:
# https://github.com/littlecodersh/EasierLife/tree/master/Plugins/Tuling
from tuling import get_response
@itchat.msg_register('Text')
def text_reply(msg):
if u'作者' in msg['Text'] or u'主人' in msg['Text']:
return u'你可以在这里了解他:https://github.com/littlecodersh'
#!/usr/bin/env python
#Filename: Python_Course02_Q01_permutation.py
#This script is used to list the permutation of numbers.
def L(elements):
if len(elements) <= 1:
yield elements
else:
for perm in L(elements[1:]):
for i in range(len(elements)):
#!/usr/bin/env python
#Filename: Python_Course01_Q03_List.py
#This Script is used to filter those duplicate elements in a list.
list1 = [1,3,5,1,2,3,5,2,3,4,5]
list2 = []
for i in list1:
if i not in list2:
list2.append(i)
#!/usr/bin/env python
#Filename: Python_Course01_Q04_Prime_checker.py
#This script is used to check the prime number.
list1 = [1,3,54,6,4,3,5,6,4,34,332]
x = 0
for num in list1:
if num > 1:
for i in range(2,num):
if (num % i) == 0:
#!/usr/bin/env python
#Filename: Python_Course01_Q02_Gambling.py
#This script is used for gambling an integer within 3 times.
print('Hi, you have 3 times to guess the integer')
INTEGER = 68
for i in range(3):
i = int(input('Please enter an integer: '))
if i > INTEGER:
print('Please guess a small one.')