Skip to content

Instantly share code, notes, and snippets.

View boxmein's full-sized avatar

Johannes Kadak boxmein

View GitHub Profile
@boxmein
boxmein / mitm-error.py
Created February 5, 2020 14:29
MITMProxy script that fakes HTTP endpoint error
#!/usr/bin/env python3
# Install mitmdump & mitmproxy with `brew install mitmproxy`
# run with: mitmdump -s mitm-error.py
# fire requests: curl --proxy localhost:8080 https://test.example.com/test
# set up your system proxy or configure your browser to use the proxy localhost:8080
import sys
import re
import json
from mitmproxy import http, proxy, options
@boxmein
boxmein / google-api-stresstester.js
Created January 8, 2020 15:18
This function appends a single row to Google Sheets and repeats itself every 100 milliseconds.
const googleapis = require('googleapis');
// Setup:
// (Maybe it's possible to get Client ID, Client Secret, Spreadsheet ID from OAuth Playground? See the link:)
// https://developers.google.com/oauthplayground/
//
// Otherwise:
// 1. Go to Google Cloud Platform Console > (create a project if needed) > APIs & Services > Library.
// Look for "Sheets" and enable the API.
// 2. Go to GCP Console > APIs & Services > OAuth consent screen. EDIT APP and set it to Internal,
@boxmein
boxmein / index.html
Created February 20, 2019 08:05
AngularJS 1.5 code to get an "optional callback argument" in components
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.10/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-app="app">
<app-x></app-x>
@boxmein
boxmein / TextClassifier.ipynb
Created September 25, 2018 15:31
Text classification experiment + notes - SVM + Naive Bayes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@boxmein
boxmein / script.bash
Last active May 28, 2018 19:52
Merge data from one mixpanel project into another
#!/bin/bash
# This shell script can automatically merge two Mixpanel projects.
# Takes events from project A and puts it in project B.
# Depends on:
# curl
# jq
# base64
@boxmein
boxmein / FindModbus.cmake
Created April 3, 2018 16:52
Find Modbus in your file system with CMake
# - Find Modbus library
# Find the Modbus headers and libraries.
#
# MODBUS_INCLUDE_DIRS - where to find modbus.h
# MODBUS_LIBRARIES - List of libraries when using modbus.
# MODBUS_FOUND - True if modbus library found.
#
# Based on Findquatlib.cmake, Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
@boxmein
boxmein / lopp.html
Created February 25, 2018 21:07
Script to parse Startup Estonia data and output a HTML file.
</body>
</html>
@boxmein
boxmein / start_webpack.sh
Created January 24, 2018 16:29
Number parsing bug
#!/bin/bash
~> webpack --env.numerical 5 --env.commitId 12180e3
# outputs { numerical: 5, commitId: 12180000 }
~> webpack --env.numerical 5 --env.commitId "12180e3" [255]
# outputs { numerical: 5, commitId: 12180000 }
~> webpack --env.numerical 5 --env.commitId "12180e3" --env.TEST_STRING test [255]
# { numerical: 5, commitId: 12180000, TEST_STRING: 'test' }
@boxmein
boxmein / converter.js
Last active February 7, 2017 21:17
Convert Node.js buffers from equals representation to Unicode
const convert = x => x.split(" ").map(e => e.split("=")[1].replace(/, /g, "")).map(e => String.fromCharCode(parseInt(e))).join("");
// Usage:
convert("0=65, 1=66, 2=66, 3=65"); // "ABBA"
@boxmein
boxmein / Key.js
Created February 1, 2017 15:02
A list of Protractor.js key constants
// Protractor keys
// Extracted from https://github.com/SeleniumHQ/selenium/blob/d943ee2950e25a2f4a3492058107cfd005d6f7fd/javascript/node/selenium-webdriver/lib/input.js#L44
const Key = {
NULL: '\uE000',
CANCEL: '\uE001', // ^break
HELP: '\uE002',
BACK_SPACE: '\uE003',
TAB: '\uE004',
CLEAR: '\uE005',
RETURN: '\uE006',