This file contains 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 re | |
import requests | |
URL = 'http://musicmini.baidu.com/app/link/getLinks.php?linkType=1&isLogin=1&isHq=1&songId={}' | |
ALBUM = 'http://music.baidu.com/album/{}' | |
def get_song(sid): | |
data = requests.get(URL.format(sid)).json()[0] | |
flac, mp3, mp3kbps = None, None, 0 | |
for f in data['file_list']: |
This file contains 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
package main | |
/* | |
import "fmt" | |
import "time" | |
*/ | |
var MAX int = 1e7 | |
// const MAX = 1e8 |
This file contains 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
// ==UserScript== | |
// @name PE days | |
// @namespace scturtle | |
// @include http://projecteuler.net/* | |
// @include https://projecteuler.net/* | |
// @version 1 | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js | |
// @grant none | |
// ==/UserScript== |
This file contains 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 re | |
import json | |
import requests | |
URL_TO_SAVE = ('https://feedly.com/v3/streams/contents?' | |
'streamId=user%2F{}%2Ftag%2Fglobal.saved&count=100') | |
HEADERS = dict(l.strip().split(': ') for l in open('headers.txt').readlines() | |
if len(l.strip())) | |
USERID = re.search(r'"feedlyId":"([^"]+)"', HEADERS['Cookie']).group(1) |
This file contains 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 os | |
import sys | |
import re | |
import hashlib | |
import csv | |
import time | |
import locale | |
import getopt |
This file contains 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 numpy as np | |
class Simplex: | |
def __init__(self): | |
self.eps = 1e-9 | |
self.DEBUG = 0 |
This file contains 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
plain = r'foo' | |
anchor = r'k$' | |
ranges = r'^[a-f]*$' | |
backrefs = r'(...).*\1' | |
abba = (r'^(?!' # don't ( | |
r'.*(.)(.)\2\1.*' # parttern like abba | |
r'$)') # ) select | |
plan = r'^(.)(.).*\2\1$' |
This file contains 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 __future__ import print_function | |
from collections import namedtuple | |
class Node(object): | |
__slots__ = 'key left right parent'.split() | |
def __init__(self, key=None, left=None, right=None, parent=None): | |
self.key = key | |
self.left = left |
This file contains 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
// ==UserScript== | |
// @name hackerrank download solutions | |
// @namespace scturtle | |
// @include https://www.hackerrank.com/* | |
// @version 0.3 | |
// @grant none | |
// ==/UserScript== | |
var url = document.location.toString(); | |
function hr() { | |
var challenge_name = /challenges\/([\w\-]*)+/.exec(url) [1]; |
This file contains 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
def suffixArray(s): | |
n = len(s) | |
rkd = {c: i for i, c in enumerate(sorted(set(s)))} | |
rank = [rkd[c] for c in s] | |
k = 1 | |
while k <= n: | |
xy = [(rank[i], (rank[i+k] if i+k < n else -1)) for i in xrange(n)] | |
rkd = {c: i for i, c in enumerate(sorted(set(xy)))} | |
rank = [rkd[c] for c in xy] | |
k *= 2 |