Skip to content

Instantly share code, notes, and snippets.

View debugtalk's full-sized avatar
🎯
Focusing

debugtalk debugtalk

🎯
Focusing
View GitHub Profile
@debugtalk
debugtalk / comparision.py
Created October 18, 2017 07:02 — forked from dmahugh/comparision.py
comparison of asynchronous HTTP requests (aiohttp/asyncio) and traditional sequential requests (with Requests library)
"""Comparison of fetching web pages sequentially vs. asynchronously
Requirements: Python 3.5+, Requests, aiohttp, cchardet
For a walkthrough see this blog post:
http://mahugh.com/2017/05/23/http-requests-asyncio-aiohttp-vs-requests/
"""
import asyncio
from timeit import default_timer
@debugtalk
debugtalk / README.md
Created October 18, 2017 06:24 — forked from shvechikov/README.md
Concurrent HTTP Requests with Python3 and asyncio

Concurrent HTTP Requests with Python3 and asyncio

http://geekgirl.io/concurrent-http-requests-with-python3-and-asyncio/

My friend who is a data scientist had wipped up a script that made lots (over 27K) of queries to the Google Places API. The problem was that it was synchronous and thus took over 2.5 hours to complete.

Given that I'm currently attending Hacker School and get to spend all day working on any coding problems that interests me, I decided to go about trying to optimise it.

I'm new to Python so had to do a bit of groundwork first to determine which course of action was best.

@debugtalk
debugtalk / cx_oracle_install_instructions.md
Last active April 4, 2019 07:02 — forked from thom-nic/cx_oracle_instructions.md
Installing CX Oracle for Python with pip & Mac OS X. Update on 2017.03.06

Download cx_Oracle for Python/ Mac OSX

Download the following files from Oracle

  • instantclient-basic-$VERSION-macosx-x64.zip
  • instantclient-sdk-$VERSION-macosx-x64.zip

Prepare works

Edit ~/.zshrc or ~/.bashrc, add following:

@debugtalk
debugtalk / 0_reuse_code.js
Created August 5, 2016 03:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

本文对Android设备CPU的状态查看方法和锁频(lock frequency)方法进行详细介绍。这有什么用?作为测试工程师,你值得了解。

CPU频率

首先说下CPU的频率。我们都知道,CPU的工作频率越高,运算就越快,但能耗也更高。然而很多时候,设备并不需要那么高的计算性能,这个时候,我们就希望能降低CPU的工作频率,追求较低的能耗,以此实现更长的待机时间。

基于此需求,当前电子设备的CPU都会存在多个工作频率,并能根据实际场景进行CPU频率的自动切换,以此达到平衡计算性能与能耗的目的。

锁频的用途

import signal,functools #下面会用到的两个库
class TimeoutError(Exception): pass #定义一个Exception,后面超时抛出
def timeout(seconds, error_message = 'Function call timed out'):
def decorated(func):
def _handle_timeout(signum, frame):
raise TimeoutError(error_message)
def wrapper(*args, **kwargs):
signal.signal(signal.SIGALRM, _handle_timeout)
signal.alarm(seconds)