Skip to content

Instantly share code, notes, and snippets.

@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
@ii0
ii0 / functional_style.py
Created January 17, 2019 09:13 — forked from serge-sans-paille/functional_style.py
Python - functional style!
import ast
import sys
import shutil
import unparse
import unittest
import doctest
import StringIO
import os
from copy import deepcopy
@ii0
ii0 / sprintf.ino
Created January 17, 2019 07:32 — forked from philippbosch/sprintf.ino
sprintf() in Arduino code
unsigned int i = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
char buffer[50];
sprintf(buffer, "the current value is %d", i++);
Serial.println(buffer);
@ii0
ii0 / web-servers.md
Created January 16, 2019 13:17 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
(from : https://simplifiedthinking.co.uk/2015/10/03/install-mqtt-server/ )
Installing Brew
The Mosquitto MQTT Server can be easily installed using Homebrew. If it’s not installed on your system already, then a quick visit to the homepage will give you all you need to get going. Homebrew is an OS X Package Manager for installing and updating non-Mac OS X utilities that are more commonly found in other variants of Linux. To install the basic package manager run the following command.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing Mosquitto MQTT
@ii0
ii0 / bookmarklet_cookiesInWindow.js
Created December 27, 2018 01:52 — forked from netsi1964/bookmarklet_cookiesInWindow.js
Bookmarklet:Open window with cookie information
!function(){var t="Click to read information about this cookie",e="Cookies found on "+document.location.host,o="<style>body{font-family: monospace ;}</style><h1>"+e+"</h1><table><thead><tr><td>Name</td><td>Value</td></tr></thead><tbody>",a=document.cookie||"",a=a.split(";"),i="";[].forEach.call(a,function(e){var o=e.split("=");try{na=o[0].replace(/\s/gi,""),va=o[1].replace(/\s/gi,""),i+='<tr><td><a href="http://google.com/?q='+na+'" target="_blank" title="'+t+'">'+na+"</a></td><td>"+va+"</td></tr>"}catch(a){}}),0===i.length?alert("No cookies found"):(i+="</tbody></table>",w=window.open(""),setTimeout(function(){w.document.title=e},1e3),w.document.write(o+i+'<h2>Original</h2><textarea style="width: 100%; height: 100px;">'+document.cookie+"</textarea>"))}();
@ii0
ii0 / python-selenium-open-tab.md
Created December 21, 2018 01:43 — forked from lrhache/python-selenium-open-tab.md
Python Selenium - Open new tab / focus tab / close tab

On a recent project, I ran into an issue with Python Selenium webdriver. There's no easy way to open a new tab, grab whatever you need and return to original window opener.

Here's a couple people who ran into the same complication:

So, after many minutes (read about an hour) of searching, I decided to do find a quick solution to this problem.

@ii0
ii0 / aiohttp-example.py
Created September 28, 2018 06:52 — forked from Den1al/aiohttp-example.py
concurrent http requests with aiohttp
# author: @Daniel_Abeles
# date: 18/12/2017
import asyncio
from aiohttp import ClientSession
from timeit import default_timer
import async_timeout
async def fetch_all(urls: list):