Skip to content

Instantly share code, notes, and snippets.

from Crypto import Random
from Crypto.Cipher import AES
from Crypto.Cipher import Salsa20
from Crypto.Cipher import ChaCha20
from Crypto.Cipher import ARC4
from Crypto.Cipher import PKCS1_OAEP
from Crypto.Util import Padding
from Crypto.PublicKey import RSA
import imaplib
import time
import email
import logging
import logging.config
logging_config = dict(
version=1,
formatters={'f': {
'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
}},
import logging
import logging.config
import os
logging_config = dict(
version=1,
disable_existing_loggers=False,
formatters={'f': {
'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
import logging
import logging.config
logging_config = dict(
version=1,
formatters={'f': {
'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
}},
handlers={'h': {
'class': 'logging.StreamHandler',
'formatter': 'f',
@mydreambei-ai
mydreambei-ai / watchdog.go
Last active March 20, 2020 11:20
golang file watchdog
package main
import (
"log"
"strings"
"github.com/fsnotify/fsnotify"
)
type Event fsnotify.Op
@mydreambei-ai
mydreambei-ai / binaryfile.py
Created March 2, 2020 11:49
python write c struct to file
from ctypes import *
import time
import datetime
class Record(Structure):
_fields_ = [
("time", c_double),
("count", c_double)
]
@mydreambei-ai
mydreambei-ai / server.py
Created September 7, 2018 05:16
A simple threadpool using python
import socket
import threading
import queue
HOST = '0.0.0.0'
PORT = 50000
class Worker(threading.Thread):
def __init__(self, queue, **kwargs):
@mydreambei-ai
mydreambei-ai / formidentify.py
Last active June 4, 2018 07:30
page form identify
# -*- coding: utf-8 -*-
from __future__ import print_function
import lxml.html
from collections import OrderedDict
import re
def after_first_check(func):
@mydreambei-ai
mydreambei-ai / search.py
Last active February 6, 2019 13:31
 via search engine or baidu engine spider
from __future__ import print_function
from bs4 import BeautifulSoup as bs
import requests
import logging
from itertools import count
import time
from blinker import signal
from lxml.html.clean import Cleaner
from lxml.html import tostring, fromstring, iterlinks
from selenium import webdriver
@mydreambei-ai
mydreambei-ai / check_prime.py
Last active June 30, 2017 07:38
check less n primes (good, better methods)
import math
def tri_prime(n):
primes = [2]
def is_prime(number):
if number % 2 == 0: return False
for i in range(3, math.floor(number / 2) + 1):
if number % i == 0: