Skip to content

Instantly share code, notes, and snippets.

View johnpauljanecek's full-sized avatar

John Paul Janecek johnpauljanecek

View GitHub Profile
@johnpauljanecek
johnpauljanecek / epc_python.el
Created March 2, 2015 01:30
Client file to be used to communicate with ipython
(require 'epc)
(defvar py-epc nil)
(defun py-epc:connect (port)
(interactive "nEnter py-epc port : ")
(setq py-epc (epc:start-epc-debug port))
)
(defun py-epc:run-cell-region (start end)
(interactive "r")
@johnpauljanecek
johnpauljanecek / epc_server.py
Created March 2, 2015 01:33
ipython extension used with epc-python.el
"""
epc_server.py
"""
from epc.server import EPCServer
from epc.server import ThreadingEPCServer
import threading
__version__ = "0.1"
def load_ipython_extension(ipython):
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": [
@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 / 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 / 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 / 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():
# 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
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)