Skip to content

Instantly share code, notes, and snippets.

@zeayes
zeayes / tax.py
Created October 16, 2018 07:06
新旧版个税计算
# -*- coding: utf-8 -*-
import sys
# 旧版个税表
# 应税工资,税率,速算扣除额度,最少缴税额度
old_table = [
(3500, 0.03, 0, 0), #
(5000, 0.1, 105, 45),
(8000, 0.2, 555, 345),
@zeayes
zeayes / mysqlbinlog_parse.go
Last active April 17, 2018 15:02
parse mysql binlog
package main
import (
"encoding/binary"
"io"
"os"
)
const (
UNKNOWN_EVENT = 0
ffmpeg -i k0605l5edvo.mp4 -i watermark.png -filter_complex "[0:v]crop=150:50:iw-160:20,boxblur=10[fg];[0:v][fg]overlay=W-160:20[v];[v][1]overlay=W-160:20[out]" -map "[out]" -map 0:a -c:v libx264 -c:a copy -movflags +faststart -y derpdogblur.mp4
import requests
from BeautifulSoup import BeautifulSoup
url = 'https://www.nbbu.nl/lid/fbcompany-vof-h-o-d-n-afwascompany/'
response = requests.get(url)
soup = BeautifulSoup(response.content)
company = soup.find(attrs={'class': 'member type-member inner-wrapper'})
name = company.contents[3].text
number = company.contents[-3].strip()
# -*- coding: utf-8 -*-
import time
import logging
from tornado import gen
from collections import deque
class PoolExhaustedError(Exception):
pass
@zeayes
zeayes / pre-commit
Created October 12, 2016 08:37
python git pre-commit hook
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
@zeayes
zeayes / beautiful_idiomatic_python.md
Created October 11, 2016 23:43 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
DELIMITER $$
DROP PROCEDURE IF EXISTS p1 $$
CREATE PROCEDURE p1 (name CHAR(250))
BEGIN
SET @tablename = CONCAT('table_', name);
SET @d = CONCAT('DROP TABLE IF EXISTS ', @tablename);
PREPARE dm FROM @d;
EXECUTE dm;
SET @c = CONCAT('CREATE TABLE ', @tablename, '(`id` INT PRIMARY KEY)');
PREPARE cm FROM @c;
var gulp = require('gulp');
var path = require('path');
var clean = require('gulp-clean')
var concat = require('gulp-concat');
var sass = require('gulp-ruby-sass');
var htmlmin = require('gulp-htmlmin');
var cleancss = require('gulp-clean-css');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
#parent{
width:400px;
height: 200px;
background-color: #ccc;
position: absolute;
top: 50%;
left: 50%;
margin: -100px 0 0 -200px;
}
#child1 {