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
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
import sched, time | |
from threading import Thread, Timer | |
import subprocess | |
s = sched.scheduler(time.time, time.sleep) | |
class Job(Thread): |
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
#!/usr/bin/env python | |
#-*-coding: UTF-8-*- | |
'''未婚妻问题 | |
关于女神选择白马王子的最佳方案和常数e的关系 | |
see http://www.guokr.com/article/6768/ | |
''' | |
import random | |
import math |
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 htmlHead(){ | |
println("""<html lang="en">""") | |
println("<body>") | |
} | |
def htmlTail(){ | |
println("</body>") | |
println("</html>") | |
} |
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
#append the "actionsfile wall.action" to the config | |
#and save this file as wall.action into the same dir as config file | |
#restart the privoxy to see if these configuration actived | |
{{alias}} | |
direct = +forward-override{forward .} | |
ssh = +forward-override{forward-socks5 127.0.0.1:7070 .} | |
default = direct | |
#gappproxy = +forward-override{forward localhost | |
{default} |
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 java.lang.management.* | |
import javax.management.ObjectName | |
import javax.management.remote.JMXConnector | |
import javax.management.remote.JMXConnectorFactory as JmxFactory | |
import javax.management.remote.JMXServiceURL as JmxUrl | |
def callJmx(String jmxUrl, String beanName, String operator, Object args, String userName=null, String password=null) { | |
def jmxEnv = null | |
if (userName != null && password != null) { | |
jmxEnv = [(JMXConnector.CREDENTIALS): (String[])[userName, 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
import socket | |
hostname, sld, tld, port = 'www', 'integralist', 'co.uk', 80 | |
target = '{}.{}.{}'.format(hostname, sld, tld) | |
# create an ipv4 (AF_INET) socket object using the tcp protocol (SOCK_STREAM) | |
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
# connect the client | |
# client.connect((target, port)) |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import pprint | |
class Node: | |
def __init__(self, id, count): | |
self.id = id | |
self.count = count |
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
#!/bin/bash | |
####### RSYNC AUTO BACKUP TO USB DEVICE V0.5 ########## | |
####### Developed by Carlo Pietrobattista ########### | |
### CONFIG VARS ##################################### | |
LOCK_FILE="/tmp/rsync-usb.pid" # the lock file name | |
MOUNT_DEV="/dev/sdh1" # mount device | |
MOUNT_PATH="/mnt/autobackup-usb" # mount point | |
BACKUP_DIR="/home/*" # backup directory | |
RSYNC_LOG_FILE="/var/log/rsync/usb_backup.log" # rsync log file | |
##################################################### |