Skip to content

Instantly share code, notes, and snippets.

View usunyu's full-sized avatar
☀️
Hello, World!

Yu Sun usunyu

☀️
Hello, World!
View GitHub Profile
@usunyu
usunyu / mergeVideoAudio.sh
Created April 22, 2016 07:35
Bash script to merge video source and audio source using ffmpeg
ffmpeg -i videoplayback.mp4 -i videoplayback.m4a -c:v copy -c:a copy output.mp4
@usunyu
usunyu / compileFFmpegLibx264.sh
Created April 24, 2016 01:16
Quickly compile FFmpeg with libx264 (x264, H.264)
./configure --enable-gpl --enable-libx264
make
make install
@usunyu
usunyu / getimage.py
Created August 13, 2016 06:47
Search and download content from web
import json
import os
import time
import requests
from PIL import Image
from StringIO import StringIO
from requests.exceptions import ConnectionError
def go(query, folder, path):
"""Download full size images from Google image search.
@usunyu
usunyu / gbk-unzip.py
Created October 24, 2016 09:42
解决unzip中文乱码问题
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# unzip-gbk.py
import os
import sys
import zipfile
print "Processing File " + sys.argv[1]
<!DOCTYPE html><html lang="zh-TW" data-cast-api-enabled="true"><head><style name="www-roboto">@font-face{font-family:'Roboto';font-style:normal;font-weight:400;src:local('Roboto Regular'),local('Roboto-Regular'),url(//fonts.gstatic.com/s/roboto/v15/zN7GBFwfMP4uA6AR0HCoLQ.ttf)format('truetype');}@font-face{font-family:'Roboto';font-style:normal;font-weight:500;src:local('Roboto Medium'),local('Roboto-Medium'),url(//fonts.gstatic.com/s/roboto/v15/RxZJdnzeo3R5zSexge8UUaCWcynf_cDxXwCLxiixG1c.ttf)format('truetype');}@font-face{font-family:'Roboto';font-style:italic;font-weight:400;src:local('Roboto Italic'),local('Roboto-Italic'),url(//fonts.gstatic.com/s/roboto/v15/W4wDsBUluyw0tK3tykhXEfesZW2xOQ-xsNqO47m55DA.ttf)format('truetype');}@font-face{font-family:'Roboto';font-style:italic;font-weight:500;src:local('Roboto Medium Italic'),local('Roboto-MediumItalic'),url(//fonts.gstatic.com/s/roboto/v15/OLffGBTaF0XFOW1gnuHF0Z0EAVxt0G0biEntp43Qt6E.ttf)format('truetype');}</style><script name="www-roboto">if (document.fonts
@usunyu
usunyu / autosub.py
Last active January 8, 2019 19:34
Translate video by autosub
autosub -o sub.srt -S ja -D ja video.mp4
@usunyu
usunyu / kraken_stream.py
Created October 30, 2021 03:11
Kraken websockets
from enum import Enum
import asyncio
import traceback
import websockets
import json
from abc import ABC, abstractmethod
from typing import Callable, Optional, List, TypedDict, AsyncIterable
class ExchangeType(Enum):
@usunyu
usunyu / kraken_checksum.py
Created November 3, 2021 23:45
Test kraken checksum correct
import binascii
from typing import List
init_snapshot = [320, {'as': [['62897.60000', '0.01481511', '1635981951.315958'], ['62900.00000', '0.03655383', '1635981951.270923'], ['62901.00000', '0.10600000', '1635981957.809459'], ['62903.80000', '0.10153441', '1635981957.924943'], ['62903.90000', '0.20000000', '1635981957.279708'], ['62904.00000', '0.10000000', '1635981955.920214'], ['62904.30000', '2.38498770', '1635981957.302002'], ['62907.60000', '0.20000000', '1635981957.301579'], ['62907.70000', '0.07000000', '1635981939.498124'], ['62908.10000', '0.15000000', '1635981956.360163']], 'bs': [['62897.50000', '0.79779400', '1635981956.465532'], ['62897.30000', '0.00781897', '1635981953.699042'], ['62896.60000', '2.38497341', '1635981957.579632'], ['62895.30000', '0.27695880', '1635981951.920146'], ['62895.00000', '0.10696037', '1635981935.899765'], ['62891.20000', '0.10000000', '1635981957.233156'], ['62891.10000', '3.97485953', '1635981953.262620'], ['62889.40000', '0.15866845', '1635981931.292536'], ['62888.9
@usunyu
usunyu / kraken_checksum2.py
Created November 4, 2021 20:56
Test kraken checksum correct
import binascii
init_snapshot = [320, {'as': [['61414.70000', '0.15802523', '1636057937.821577'], ['61414.80000', '0.10000000', '1636057937.771221'], ['61416.60000', '0.03057629', '1636057930.909345'], ['61421.30000', '0.10000000', '1636057937.322859'], ['61421.40000', '0.40479201', '1636057930.059247'], ['61422.00000', '4.07165344', '1636057937.769963'], ['61424.30000', '0.66105226', '1636057937.056049'], ['61424.50000', '0.28430974', '1636057930.086022'], ['61426.10000', '0.65420000', '1636057937.786911'], ['61426.20000', '0.25000000', '1636057935.236143']], 'bs': [['61412.40000', '0.09300000', '1636057936.791658'], ['61406.30000', '0.10000000', '1636057934.212321'], ['61406.20000', '0.07000000', '1636057931.333046'], ['61405.00000', '1.19933331', '1636057924.376252'], ['61403.60000', '2.31557100', '1636057911.328986'], ['61403.00000', '0.16039285', '1636057936.252989'], ['61401.20000', '0.00428000', '1636057893.611698'], ['61400.00000', '0.07000000', '1636057931.083644'], ['61398.20000', '0.14658400', '16