Skip to content

Instantly share code, notes, and snippets.

View simpleapples's full-sized avatar
👁️
👁

Zhiya simpleapples

👁️
👁
  • TikTok
  • London, United Kingdom
View GitHub Profile
import os
import aiohttp
import json
import base64
import asyncio
import uvloop
START_ID = 1000
END_ID = 1020
@simpleapples
simpleapples / token_bucket.py
Last active March 14, 2018 06:51
令牌桶实现
import time
class TokenBucket(object):
def __init__(self, rate, capacity):
self._rate = rate
self._capacity = capacity
self._current_amount = 0
self._last_consume_time = int(time.time())
@simpleapples
simpleapples / get_wallpapers.py
Last active March 19, 2018 15:42
获取win10锁屏壁纸
import os, shutil
from datetime import datetime
def main():
save_folder = dir_path = os.path.dirname(
os.path.realpath(__file__)) + '\wallpapers'
wallpaper_folder = os.getenv('LOCALAPPDATA') + (
'\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy'
'\LocalState\Assets')
@simpleapples
simpleapples / gist:2326e154971d60d9b4760a11786d3977
Created January 23, 2018 08:34
scan ports in local network
import socket
from concurrent.futures import ThreadPoolExecutor
MAX_WORKERS = 40
PORT = 80
IP_ADDR = "192.168.1.[HOST_ADDR]"
def detect_port(ip):
import requests
from bs4 import BeautifulSoup
SESSION_ID = ''
FILE_PATH = ''
def get_stu_info(page):
base_url = 'http://www.nextsecond.cn/fellow'
# device_id, sid, uid 需要自己先抓包获取到
# game_mode 1是无尽模式 2是限时模式
import hashlib
import hmac
import base64
import requests
def data_to_string(data):
@simpleapples
simpleapples / gist:494445ccf6e3a6ca7c60
Created September 19, 2014 08:58
兼容iOS7和iOS8的推送注册代码
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
if (IS_OS_8_OR_LATER) {
[[UIApplication sharedApplication] registerForRemoteNotifications];
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
} else {
[application registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];