Skip to content

Instantly share code, notes, and snippets.

@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):
@ii0
ii0 / redis.lua
Created August 24, 2018 03:52 — forked from moonbingbing/redis.lua
local redis_c = require "resty.redis"
local ok, new_tab = pcall(require, "table.new")
if not ok or type(new_tab) ~= "function" then
new_tab = function (narr, nrec) return {} end
end
local _M = new_tab(0, 155)
user nginx;
worker_processes 2;
error_log logs/error.log;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
-- a quick LUA access script for nginx to check IP addresses against an
-- `ip_blacklist` set in Redis, and if a match is found send a HTTP 403.
--
-- allows for a common blacklist to be shared between a bunch of nginx
-- web servers using a remote redis instance. lookups are cached for a
-- configurable period of time.
--
-- block an ip:
-- redis-cli SADD ip_blacklist 10.1.1.1
-- remove an ip: