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
| These commands are based on a askubuntu answer http://askubuntu.com/a/581497 | |
| To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below. | |
| USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING. | |
| ABSOLUTELY NO WARRANTY. | |
| If you are still reading let's carry on with the code. | |
| sudo apt-get update && \ | |
| sudo apt-get install build-essential software-properties-common -y && \ | |
| sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ |
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
| # Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, |
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
| url = "http://www.chinanews.com/gn/2017/05-18/8227552.shtml" | |
| pair = "http://www.chinanews.com/gn/2017/05-19/8228314.shtml" | |
| ##url='http://www.cnblogs.com/bluescorpio/archive/2010/05/31/1748503.html' | |
| ##pair='http://www.cnblogs.com/bluescorpio/p/5211409.html' | |
| import requests | |
| import bs4 | |
| import copy | |
| import webbrowser | |
| s=requests.session() |
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
| url = "http://www.chinanews.com/gn/2017/05-18/8227552.shtml" | |
| pair = "http://www.chinanews.com/gn/2017/05-19/8228314.shtml" | |
| ##url='http://www.cnblogs.com/bluescorpio/archive/2010/05/31/1748503.html' | |
| ##pair='http://www.cnblogs.com/bluescorpio/p/5211409.html' | |
| import requests | |
| #import bs4 | |
| from lxml import html | |
| import copy | |
| import webbrowser |
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 requests | |
| import string | |
| from itertools import product | |
| url = 'https://github.com/signup_check/username' | |
| data = b'value=m-mmm&authenticity_token=UEibfyLaqA5qO%2BH5ISLFc4HsVbS3JMtllC3UWvu3aB4nSrsPFoFhcrpS8wW1yKaxw1nl7eaKD2XFKhlE%2BQv%2BHQ%3D%3D' | |
| header = {'Accept': '*/*', | |
| 'Accept-Language': 'zh-CN', | |
| 'Cache-Control': 'no-cache', | |
| 'Connection': 'Keep-Alive', |
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
| class Solution(object): | |
| def findSubsequences(self, nums): | |
| """ | |
| :type nums: List[int] | |
| :rtype: List[List[int]] | |
| """ | |
| res = set() | |
| for num in nums: | |
| res_t = {(num,)} | |
| res_t1 = {k+(num,) for k in res if num>=k[-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
| from pprint import pprint | |
| import cProfile | |
| import random | |
| class NumArray(object): | |
| def __init__(self, nums): | |
| """ | |
| :type nums: List[int] |
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
| # coding=utf-8 | |
| """ | |
| TRIE树py实现 | |
| 运行速度有点慢啊,用时1000ms,打败10%,估计是`to_bit`和`to_num`耗时了, | |
| 改成bit的移位操作应该可以优化,有待于profile考证 | |
| ~~时间复杂度是O(nlog(m)),m是n的最大位数~~ | |
| 时间复杂度是O(n),bit位32写死在程序里面了 |
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 OpenGL.GL import * | |
| from OpenGL.GLU import * | |
| from OpenGL.GLUT import * | |
| import time | |
| def drawFunc(*a): | |
| time.sleep(0.0000001) | |
| glClear(GL_COLOR_BUFFER_BIT) | |
| glRotatef(1, 0, 1, 0) | |
| glutWireTeapot(0.5) | |
| glFlush() |
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
| #lcs | |
| from functools import lru_cache | |
| a=(1,2,4,5) | |
| b=(1,2,3,5) | |
| def lcs(a, b): | |
| print("lcs(%s, %s)"%(a, b)) | |
| if len(a)==0 or len(b)==0: | |
| return [] |