Skip to content

Instantly share code, notes, and snippets.

@ii0
ii0 / rateLimitDecorator.py
Created April 15, 2019 02:56 — forked from gregburek/rateLimitDecorator.py
Rate limiting function calls with Python Decorators
import time
def RateLimited(maxPerSecond):
minInterval = 1.0 / float(maxPerSecond)
def decorate(func):
lastTimeCalled = [0.0]
def rateLimitedFunction(*args,**kargs):
elapsed = time.clock() - lastTimeCalled[0]
leftToWait = minInterval - elapsed
if leftToWait>0:
@ii0
ii0 / install_mosh_centos7.sh
Created April 14, 2019 11:12 — forked from pythoninthegrass/install_mosh_centos7.sh
Install mosh on CentOS 7
#!/usr/bin/env bash
# SOURCE: https://eligiblestore.com/blog/2017/05/02/how-to-install-mosh-on-centos/
# ensure running as root
if [[ "$(id -u)" != "0" ]]; then
exec sudo "$0" "$@"
fi
# install mosh
yum install -y epel-release
@ii0
ii0 / docker-compose-stats.sh
Created April 2, 2019 01:36 — forked from petermodzelewski/docker-compose-stats.sh
Stats of running containers started by docker-compose in docker 1.5
sudo docker-compose ps | grep Up | awk '{print $1}' | tr "\\n" " " | xargs --no-run-if-empty sudo docker stats
@ii0
ii0 / gist:7f4cd0d3e044a8d4fbe9941b4efa4754
Created March 26, 2019 13:37 — forked from gllist/gist:3668037
PhantomJS: Ajax response capture through console.log
var page = require('webpage').create();
page.open('http://www.website.com/', function (status) {
if (status === 'success') {
captureAjaxResponsesToConsole();
}
});
function captureAjaxResponsesToConsole() {
// logs ajax response contents to console so sublime's onConsoleMessage can use the contents
@ii0
ii0 / curl.md
Created March 21, 2019 09:29 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

# create sdk folder
export ANDROID_HOME=/opt/android-sdk-linux
sudo mkdir -p $ANDROID_HOME
# install openjdk
sudo apt-get install openjdk-8-jdk
# download android sdk
cd $ANDROID_HOME
sudo wget https://dl.google.com/android/repository/tools_r25.2.3-linux.zip
@ii0
ii0 / release-android-debuggable.md
Created February 25, 2019 02:37 — forked from nstarke/release-android-debuggable.md
How to make a Release Android App debuggable

How to make a Release Android App debuggable

Let's say you want to access the application shared preferences in /data/data/com.mypackage.
You could try to run adb shell and then run-as com.mypackage ( or adb shell run-as com.mypackge ls /data/data/com.mypackage/shared_prefs), but on a production release app downloaded from an app store you're most likely to see:

run-as: Package 'com.mypackage' is not debuggable
@ii0
ii0 / intercept.js
Created February 13, 2019 04:48 — forked from suprememoocow/intercept.js
AJAX timing interceptor: this class intercepts all AJAX calls and records the time taken for the HTTP request to complete. These timings are posted back to the server in batches, if there are any to send, about every two seconds. Tested in Firefox, Chrome
(function(XHR) {
"use strict";
var stats = [];
var timeoutId = null;
var open = XHR.prototype.open;
var send = XHR.prototype.send;
@ii0
ii0 / PCMusicViaWechat.py
Created January 31, 2019 05:36 — forked from littlecodersh/PCMusicViaWechat.py
Demo of controlling music player through wechat.
#coding=utf8
import os
import itchat
from NetEaseMusicApi import interact_select_song
# 第三方包通过该命令安装:pip install itchat, NetEaseMusicApi
HELP_MSG = u'''\
欢迎使用微信网易云音乐
帮助: 显示帮助
@ii0
ii0 / build-python-rpm.sh
Created January 27, 2019 04:35 — forked from enaeseth/build-python-rpm.sh
Build Python 3 on RHEL 5 or CentOS 5
#!/bin/bash
# Requires fpm (path configurable via $FPM) and a working
# build environment.
set -e
version=$1
vendor=$2