This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| map('F', 'af'); | |
| map('gt', 'R'); | |
| map('gT', 'E'); | |
| map('<Ctrl-n>', 'R'); | |
| map('<Ctrl-p>', 'E'); | |
| mapkey('H', '#4Go back in history', function() { history.go(-1); }, {repeatIgnore: true}); | |
| mapkey('L', '#4Go forward in history', function() { history.go(1); }, {repeatIgnore: true}); | |
| map('d', 'x'); | |
| map('u', 'X'); | |
| map('I', '<Alt-s>'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import json | |
| import xmlrpc.client | |
| import requests | |
| from requests.utils import cookiejar_from_dict | |
| def get_aria2(speed_limit=None): | |
| aria2 = xmlrpc.client.ServerProxy('http://127.0.0.1:6800/rpc').aria2 | |
| while 1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![feature(step_by, iter_arith)] | |
| fn main() { | |
| let n = 100000000; | |
| let mut isprime = vec![true; n]; | |
| isprime[0] = false; | |
| isprime[1] = false; | |
| for i in (4..n).step_by(2) { | |
| isprime[i] = false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pprint import pprint | |
| import os | |
| import requests | |
| import webbrowser | |
| class Weibo: | |
| def login(self): | |
| if os.path.exists('weibo.token'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://support.twitter.com/articles/20172128?lang=en#video-formats | |
| # https://trac.ffmpeg.org/wiki/Encode/H.264 | |
| # gif to mp4 for twitter | |
| ffmpeg -i in.gif -pix_fmt yuv420p -vf crop="floor(in_w/2)*2:floor(in_h/2)*2" out.mp4 | |
| # extract part of video (-t duration) | |
| ffmpeg -i in.mp4 -ss 00:00:00.000 -to 00:00:15.000 -vcodec copy -acodec copy part.mp4 | |
| # convert to mp4 for twitter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| from collections import deque | |
| from select import select | |
| from concurrent.futures import ThreadPoolExecutor as Pool | |
| def fib(n): | |
| if n <= 2: | |
| return 1 | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import System.Environment | |
| import qualified Data.IntSet as S | |
| queens :: Int -> Int | |
| queens n = queens' 0 S.empty S.empty S.empty | |
| where queens' i cols diag1 diag2 = | |
| if i == n then 1 | |
| else sum [queens' (i+1) (S.insert j cols) | |
| (S.insert (j+i) diag1) | |
| (S.insert (j-i) diag2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from gevent import monkey | |
| monkey.patch_all() | |
| import bottle | |
| class SSLWebServer(bottle.ServerAdapter): | |
| def run(self, handler): | |
| from gevent.pywsgi import WSGIServer | |
| srv = WSGIServer((self.host, self.port), handler, | |
| certfile='/etc/letsencrypt/live/XXX/fullchain.pem', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import re | |
| import sys | |
| from pathlib import Path | |
| import dropbox | |
| app_key = '' | |
| app_secret = '' | |
| access_token = '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 = |