Skip to content

Instantly share code, notes, and snippets.

View taojy123's full-sized avatar

taojy123 taojy123

View GitHub Profile
@taojy123
taojy123 / rc4.js
Last active May 20, 2024 05:20
rc4 对称加密,使用 python 和 js 实现
function rc4(data, key) {
var box = Array(256)
for (var i = 0; i < 256; i++) {
box[i] = i
}
var x = 0
for (var i = 0; i < 256; i++) {
x = (x + box[i] + key.charCodeAt(i % key.length)) % 256
@taojy123
taojy123 / pynput.demo.py
Created April 16, 2019 08:32
pynput demo sctipt
# Python2.7
# pip intall pynput
from pynput import mouse
from pynput import keyboard
from pynput.mouse import Button
from pynput.keyboard import Key, KeyCode
import time
@taojy123
taojy123 / lunar.py
Created January 11, 2019 10:25
python 农历
# lunar.py
# 2015/02/27 罗兵
import datetime
class Lunar(object):
#******************************************************************************
# 下面为阴历计算所需的数据,为节省存储空间,所以采用下面比较变态的存储方法.
#******************************************************************************
#数组g_lunar_month_day存入阴历1901年到2050年每年中的月天数信息,
#阴历每月只能是29或30天,一年用12(或13)个二进制位表示,对应位为1表30天,否则为29天
@taojy123
taojy123 / GuessNums.html
Last active December 8, 2020 02:38
2018年在前往欧洲的飞机上编写
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>四数推理</title>
<style>
* {
font-size: 30px;
font-family: monospace;
}
@taojy123
taojy123 / cmd.py
Created October 25, 2018 03:14
python 执行命令行 获取结果
# ============ python2 ====================
import commands
commands.getoutput("ls")
commands.getstatus("ls")  
status, output = commands.getstatusoutput("ls")  
# ============ python3 ====================
from subprocess import Popen, PIPE
@taojy123
taojy123 / float.py
Last active August 1, 2018 06:45
python 浮点精度示例
assert 0.1 + 0.2 == 0.30000000000000004
assert 0.3 - 0.2 == 0.09999999999999998
assert 5.06 * 100 == 505.99999999999994
import os
import requests
import BeautifulSoup
root_url = 'http://index-of.es/'
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'
}
@taojy123
taojy123 / kmodes.py
Last active March 26, 2018 06:58
K-modes
#!python2
#coding=utf8
import random
class Man(object):
def __init__(self, name, values):
self.name = name
include world
include image
# 这些是我预先上传的数字图片,在开始先下载下来几个
# 也可以不写这几行,这样在运行的过程中用到是会下载
im_2 = image-url('http://taojy123.cn:2048/2.png')
im_4 = image-url('http://taojy123.cn:2048/4.png')
im_8 = image-url('http://taojy123.cn:2048/8.png')
@taojy123
taojy123 / mutex.py
Created November 10, 2017 03:04
线程锁装饰器
import thread
import time
lock = thread.allocate_lock()
def mutex(func):