Skip to content

Instantly share code, notes, and snippets.

View johnpauljanecek's full-sized avatar

John Paul Janecek johnpauljanecek

View GitHub Profile
@johnpauljanecek
johnpauljanecek / Basic Monkey Patching.js
Last active July 17, 2022 08:12
Monkey Patching Javascript
(function () {
/*
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function
createElement(tagName)
createElement(tagName, options)
https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement
*/
console.log("monkey patch start");
var old_CreateElement = Document.prototype.createElement
function new_CreateElement() {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
class FunctionMeta(type):
class RpcWrapper(object):
def __init__(self,name):
self.name = name
def __call__(self):
print(self.name)
def __new__(cls, clsname, superclasses,attributedict):
print("clsname: ", clsname)
print("superclasses: ", superclasses)
# Enable compression, to make data link quicker.
# Put or append this file in /system/etc/ppp directory
# http://forum.xda-developers.com/showthread.php?t=1800351
# Mohammad Bahathir Hashim (bahathir@gmail.com)
# GPL
# 2013
crtscts
vj
bsdcomp
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johnpauljanecek
johnpauljanecek / digitalocean_config.py
Created July 23, 2015 22:57
digitalocean_config.py - setupup digitalocean droplets to use python plumbum
from plumbum import SshMachine
from plumbum import local
from plumbum.cmd import sudo
from plumbum.cmd import grep, wc, cat, head
import os,subprocess,digitalocean,shutil,glob,os.path,plumbum
import servers.secret as secret
from servers.common import sshDir,create_ssh_dir
#http://www.robotgoblin.co.uk/blog/2012/07/24/managing-multiple-ssh-keys/
def read_hosts():
@johnpauljanecek
johnpauljanecek / common.py
Created July 23, 2015 22:55
common.py - file needed by digital_oceanconfig.py
import os,subprocess,plumbum
import servers.secret as secret
sshDir = "%s/.ssh" % os.environ['HOME']
def create_ssh_dir():
if not os.path.exists(sshDir):
os.mkdir(sshDir)
def install_pip2(ssh):
@johnpauljanecek
johnpauljanecek / ipython_helpers.py
Created July 23, 2015 22:46
ipython_helpers.py functions to display python dictionaries as tables in ipython notebook.
def dicts_to_html(dicts,keys = None):
from IPython.display import HTML
if not keys :
keys = dicts[0].keys()
rows = ["<table>"]
header = ["<tr>"]
for key in keys :
header.append("<th>"+key+"</th>")
header.append("</tr>")
rows.append("".join(header))
@johnpauljanecek
johnpauljanecek / Ajax KickStarter Scraping Example.ipynb
Created June 24, 2015 01:49
Ajax Kickstarter Scraping Example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johnpauljanecek
johnpauljanecek / gist:39c1ab450f3d188af548
Created June 1, 2015 05:35
Inject javascript into python selenium
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [