Skip to content

Instantly share code, notes, and snippets.

View scturtle's full-sized avatar
🐢

scturtle

🐢
View GitHub Profile
@scturtle
scturtle / translate.py
Last active January 8, 2020 08:38
google translate cli
#!/usr/bin/env python
# from pprint import pprint
try:
import urllib2 as request
from urllib import quote
except:
from urllib import request
from urllib.parse import quote
@scturtle
scturtle / bilibili.py
Last active February 3, 2019 16:40
download from bilibili via aria2 rpc
#!/usr/bin/env python3
import re
import os
import hashlib
import requests
import xmlrpc.client
from pprint import pprint
# key & secret from 'you-get'
key = '85eb6835b0a1034e'
@scturtle
scturtle / polling.py
Created June 25, 2015 12:28
telegram bot (long polling)
#!/usr/bin/env python3
import requests
prefix = 'https://api.telegram.org/bot'
key = ''
geturl = prefix + key + '/getUpdates'
sendurl = prefix + key + '/sendMessage'
timeout = 60
@scturtle
scturtle / exthoo.hs
Last active November 1, 2015 02:53
Extend hoogle database
#!/usr/bin/env stack
-- stack --resolver global runghc --package turtle
{-# LANGUAGE OverloadedStrings #-}
import Turtle
import qualified Data.Text as T
parser :: Parser Text
parser = argText "pkg" "Package name"
@scturtle
scturtle / upload-flask.py
Last active November 5, 2015 10:20
Bottle http server with upload support
#!/usr/bin/env python3
import sys
from flask import Flask, request, send_file, render_template_string
from werkzeug.utils import secure_filename
from pathlib import Path
app = Flask(__name__)
BASEPATH = Path(sys.argv[1] if len(sys.argv) > 1 else '.')
TEMPLATE = '''\
<!doctype html>
@scturtle
scturtle / server.py
Last active September 28, 2024 03:46
python socks5 proxy server with asyncio (async/await)
#!/usr/bin/env python3.5
import socket
import asyncio
from struct import pack, unpack
class Client(asyncio.Protocol):
def connection_made(self, transport):
self.transport = transport
self.server_transport = None
@scturtle
scturtle / backup-tg.py
Created October 1, 2015 10:23
backup telegram chat logs with telegram-cli
#!/usr/bin/env python3
import socket
import select
import json
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', 4458))
results = []
saw = set()
offset = 0
@scturtle
scturtle / danmaku.hs
Last active October 30, 2015 09:37
find all xml and convert to ass
#!/usr/bin/env stack
-- stack --resolver global runghc --package turtle
{-# LANGUAGE OverloadedStrings #-}
import Turtle
import Filesystem.Path.CurrentOS (replaceExtension)
main :: IO ()
main = sh $ do
xml <- find (suffix ".xml") "."
open Core.Std
let test_list =
[["language";"architect" ;"first release"];
["Lisp" ;"John McCarthy" ;"1958"];
["C" ;"Dennis Ritchie";"1969"];
["ML" ;"Robin Milner" ;"1973"];
["OCaml" ;"Xavier Leroy" ;"1996"]]
let make_seperator (widths : int list) : string =
@scturtle
scturtle / upload.py
Created November 4, 2015 13:09
upload to Dropbox for backup
#!/usr/bin/env python3
import re
import sys
from pathlib import Path
import dropbox
app_key = ''
app_secret = ''
access_token = ''