Skip to content

Instantly share code, notes, and snippets.

View Black-Milk's full-sized avatar
🐇
turtles all the way down…

Edwin M. Black-Milk

🐇
turtles all the way down…
View GitHub Profile
@gf3
gf3 / gist:328089
Created March 10, 2010 17:06
iTerm Colours
Black: 0, 0, 0
Red: 229, 34, 34
Green: 166, 227, 45
Yellow: 252, 149, 30
Blue: 196, 141, 255
Magenta: 250, 37, 115
Cyan: 103, 217, 240
White: 242, 242, 242
@cgoldberg
cgoldberg / timer.py
Created June 16, 2012 23:06
Python Timer Class - Context Manager for Timing Code Blocks
#!/usr/bin/env python
#
# Python Timer Class - Context Manager for Timing Code Blocks
# Corey Goldberg - 2012
#
from timeit import default_timer
@mjbommar
mjbommar / r_oracle_jdbc_example1.R
Created November 22, 2012 15:36
Example of connecting to an Oracle database using R and RJDBC
# Set JAVA_HOME, set max. memory, and load rJava library
Sys.setenv(JAVA_HOME='/path/to/java_home')
options(java.parameters="-Xmx2g")
library(rJava)
# Output Java version
.jinit()
print(.jcall("java/lang/System", "S", "getProperty", "java.version"))
# Load RJDBC library
@joyrexus
joyrexus / README.md
Last active October 23, 2019 23:32
Partition a list into N chunks of nearly equal size.

UPDATE: Use the method in this gist instead.

List Partitioning

We want to partition a list into N chunks where we use every item in the original list and the resulting chunks differ in size by at most one element.

We devised a chunk method for this, admittedly kinda hackish ... but it works.

Intercepts HTTPs Traffic with Python & mitmproxy

Introduction

Modern applications usually make use of back-end API servers to provide their services. With a non-transparent HTTPs proxy, which intercepts the communication between clients and servers (aka the man-in-the-middle scheme), you can easily manipulate both API requests and responses.

This manual helps you create your own proxy with Python and mitmproxy/libmproxy. Mitmproxy ships with both a standalone command-line tool (mitmproxy) and a Python library (libmproxy).

@Black-Milk
Black-Milk / python 2.7(Anaconda).sublime-build
Created March 5, 2014 05:08
Replace //anaconda/bin/python2.7 with the actual path of your anaconda python distribution and you should be good to go.
{
"cmd": ["//anaconda/bin/python2.7", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
@Black-Milk
Black-Milk / python 3(Anaconda).sublime-build
Created March 5, 2014 05:14
Python 3.3 Anaconda build file for sublime text 3. Be sure to replace //anaconda/envs/py3k/bin/python3.3 with the actual path including the python 3 unix executable provided by your Anaconda distribution (assuming you've already installed it...).
{
"cmd": ["//anaconda/envs/py3k/bin/python3.3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
@Black-Milk
Black-Milk / Perl.sublime-build
Created March 5, 2014 05:18
This is a build file for PERL. Be sure to have perl installed on your system. If you're using a distribution provided by a third party, make sure to have it's directory appended to your PATH.
{
"cmd": ["perl", "-w", "$file"],
"file_regex": ".* at (.*) line ([0-9]*)",
"selector": "source.perl"
}
@Black-Milk
Black-Milk / Main.sublime-menu
Last active October 22, 2018 11:51
Sublime REPL settings for Anaconda distribution of Python. Included are REPL settings for python and ipython running under python 2.7 and python 3.3. Be sure to provide the appropriate path to your Anaconda Python 2.7 and Python 3.3 executables within the lines that start with "cmd" .
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
@samklr
samklr / ipython-nbserver.py
Last active March 26, 2020 21:52
Install Ipython Notebook on a VM and Launch it as a server in a Cloud Platform. Here, in Google Compute Engine.
##### Install a lot of stuff first #####
$sudo apt-get update
##install python
$ wget http://09c8d0b2229f813c1b93-c95ac804525aac4b6dba79b00b39d1d3.r79.cf1.rackcdn.com/Anaconda-2.0.1-Linux-x86_64.sh
$ sudo bash anaconda........sh
##install necessary libs
$ sudo apt-get install -y python-matplotlib python-tornado ipython ipython-notebook python-setuptools python-pip