Skip to content

Instantly share code, notes, and snippets.

View m-lh's full-sized avatar
👀
萌新练级中

长恨安歌 m-lh

👀
萌新练级中
View GitHub Profile
@m-lh
m-lh / lcs.py
Created June 19, 2017 14:08
python 实现 最长公共子序列
#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 []
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()
@m-lh
m-lh / lc412-slow.py
Last active June 19, 2017 14:22
实现leetcode412题
# coding=utf-8
"""
TRIE树py实现
运行速度有点慢啊,用时1000ms,打败10%,估计是`to_bit`和`to_num`耗时了,
改成bit的移位操作应该可以优化,有待于profile考证
~~时间复杂度是O(nlog(m)),m是n的最大位数~~
时间复杂度是O(n),bit位32写死在程序里面了
@m-lh
m-lh / lc303.py
Created June 19, 2017 14:25
leetcode303
from pprint import pprint
import cProfile
import random
class NumArray(object):
def __init__(self, nums):
"""
:type nums: List[int]
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]}
@m-lh
m-lh / qwe.py
Created June 19, 2017 14:27
瞎写系列::从注册的地方看到底哪个账户注册了
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',
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
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()
@m-lh
m-lh / tensorflow_self_check.py
Created August 23, 2017 09:32 — forked from mrry/tensorflow_self_check.py
TensorFlow on Windows self-check
# 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,
@m-lh
m-lh / how-to-install-latest-gcc-on-ubuntu-lts.txt
Created September 13, 2019 04:42 — forked from application2000/how-to-install-latest-gcc-on-ubuntu-lts.txt
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04)
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 && \