Skip to content

Instantly share code, notes, and snippets.

View zhyq0826's full-sized avatar

三月沙 zhyq0826

View GitHub Profile
@zhyq0826
zhyq0826 / remove-element-from-list.py
Last active September 4, 2016 08:34
python 移除list 中的某个元素
import random
def slice_remove(s, item):
sorted(s)
start = s.index(item)
length = s.count(item)
a = s[0:start]
b = s[start+length:]
a.extend(b)
@zhyq0826
zhyq0826 / singletion_with_new.py
Created September 4, 2016 08:28
使用 __new__ 创建单例模式
class Singleton(object):
_instance = None
def __new__(cls, *args, **kswargs):
if cls._instance is None:
cls._instance = super(Singleton, cls).__new__(cls, *args, **kswargs)
return cls._instance
class SingletonParent(object):
_instance = {}
@zhyq0826
zhyq0826 / redis_lock.py
Last active August 18, 2016 10:07
python code for redis lock
import time
import redis
import logging
logger = logging.getLogger('service.redis_lock')
CONN = redis.Redis(host='localhost')
def acquire_lock(lockname, identifier, wait_time=20, timeout=15):
end = time.time() + wait_time

前端工程師面試問題集

@版本 2.0.0

譯注:此翻譯版,主要給不能流利的讀英文的人看,相關專有名詞還是保留原文。翻譯不好地方請協助pull request.

此repository包含了一些前端開發的面試問題,來審查一個有潛力的面試者。這並不是建議你對同一個面試者問上所有的問 (那會花費好幾小時)。從列表中挑幾個題目,應該就夠幫助你審查面試者是否擁有你需要的技能。

Rebecca MurpheyBaseline For Front-End Developers 也是一篇很棒且值得讀的文章在你開始面試之前。

@zhyq0826
zhyq0826 / flippant demo
Created July 31, 2013 03:51
flippan js demo
<html>
<head>
<title>Testing.</title>
<link href="http://bootstrap.my.com/assets/css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="flippant.css">
<style type="text/css">
.container { margin-top: 2em; }
h1 span {
animation: flipper 3s ease-in 4s infinite;
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from functools import partial
from unittest import TestCase, main
from quixote.errors import QueryError
from validators import validate, ValidateError
# 1. Make sure you have nginx sub module compiled in
# nginx -V 2>&1 | grep --color=always '\-\-with\-http_sub_module'
# 2. add two directives below at HTTP level
# nginx.conf
http {
# ......
sub_filter '</head>' '<style type="text/css">html{ filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
@zhyq0826
zhyq0826 / gist:27ed09fd419b78bfcfba
Created October 31, 2015 07:10 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@zhyq0826
zhyq0826 / Future_illustrate
Last active August 29, 2015 14:27 — forked from davidbirdsong/Future_illustrate
use ioloop.IOLoop.instance().add_future to create a callback for a completed Future object
from concurrent.futures import ThreadPoolExecutor
from tornado.concurrent import run_on_executor, Future
from tornado import httpclient,ioloop,web,gen
import request
import sys
httpclient.AsyncHTTPClient.configure('tornado.curl_httpclient.CurlAsyncHTTPClient', max_clients=10)
# TODO: remove
class Foo(Exception): pass
def dot():