Skip to content

Instantly share code, notes, and snippets.

View gsw945's full-sized avatar
🙏
buddha-like coding

玖亖伍 gsw945

🙏
buddha-like coding
View GitHub Profile
@gsw945
gsw945 / requests-print-debug.py
Created December 18, 2018 03:05
requests show debug info
# https://stackoverflow.com/questions/10588644/how-can-i-see-the-entire-http-request-thats-being-sent-by-my-python-application
import requests
import logging
# These two lines enable debugging at httplib level (requests->urllib3->http.client)
# You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
# The only thing missing will be the response.body which is not logged.
try:
import http.client as http_client
except ImportError:
@gsw945
gsw945 / win-docker-cli.cmd
Created March 10, 2019 15:10
Kitematic 's "Docker CLI" via cmd
@echo off
rem PowerShell 中查看所有环境变量的方法
rem (gci env:*).GetEnumerator() | Sort-Object Name | Out-String
if not defined DOCKER_TOOLBOX_INSTALL_PATH (
rem DOCKER_TOOLBOX_INSTALL_PATH 为 docker.exe 和 docker-machine.exe 所在文件夹
echo 环境变量 DOCKER_TOOLBOX_INSTALL_PATH 不存在
echo 按任意键 退出
pause > nul
@gsw945
gsw945 / multi-threading-download-demo.py
Created March 11, 2019 10:52
concurrency requests demo
# -*- coding: utf-8 -*-
import time
import logging
import threading
from multiprocessing.dummy import Pool as ThreadPool
from multiprocessing import Manager
try:
from http.client import RemoteDisconnected
except ImportError:
from httplib import BadStatusLine as RemoteDisconnected
@gsw945
gsw945 / search-in-files.py
Last active March 14, 2019 03:01
python filter text files in folder(path match glob rule and content contains specified substring)
import os
import re
import glob
import traceback
import chardet
# import threading
from multiprocessing.dummy import Pool as ThreadPool
from operator import is_not
from functools import partial
@gsw945
gsw945 / pip-install.cmd
Created March 14, 2019 07:51
pip install package via douban mirror
@echo off
chcp 65001
set args=%*
set pipi=pip install -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
if [%~1]==[] goto :show_help
if [%args%]==[-h] (
call %pipi% --help
@gsw945
gsw945 / scheduler-client-demo.py
Created April 2, 2019 04:18
apscheduler rpyc server and client demos
from time import sleep
import rpyc
conn = rpyc.connect('localhost', 12345)
job = conn.root.api_test_job(args=['Hello, World'])
sleep(2)
conn.root.remove_job(job.id)
@gsw945
gsw945 / biqugeso_crawl.py
Last active May 29, 2019 05:50
笔趣阁-《弃少归来张恒》 爬虫
# -*- coding: utf-8 -*-
import re
import json
import scrapy
from scrapy.crawler import CrawlerProcess
class BiqugesoSpider(scrapy.Spider):
# custom_settings = {}
@gsw945
gsw945 / MirrorMigrationTool.cs
Created July 19, 2019 06:06 — forked from SoftwareGuy/MirrorMigrationTool.cs
Converts old UNET code into modern Mirror Networking code
// Mirror Network Migration Tool
// Written by M. Coburn (@coburn64 on Twitter/SoftwareGuy on Github)
// This file is part of Mirror Networking by Coburn64, Lymdun, vis2k and Paul (goldbug).
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
@gsw945
gsw945 / client.js
Created October 16, 2019 03:30 — forked from hagino3000/client.js
WebSocket with binary data
var socket = null;
function bootstrap() {
// 適当な図形を描画
var c = document.getElementById('mycanvas');
var ctx = c.getContext('2d');
ctx.globalalpha = 0.3;
for(var i=0; i<1000; i++) {
ctx.beginPath();
@gsw945
gsw945 / ffmpeg.md
Created December 5, 2019 05:11 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz: