Skip to content

Instantly share code, notes, and snippets.

View corydolphin's full-sized avatar

Cory Dolphin corydolphin

View GitHub Profile
@corydolphin
corydolphin / count_github_contributions.py
Created June 22, 2013 16:48
Count Github contributions by a single user to a particular organization.
from github import Github, EmptyRepositoryException
import datetime
import time
import argparse
def main(username, password, organization):
g = Github(username, password, timeout=1)
org = g.get_organization(organization)
file_set = set()
@corydolphin
corydolphin / craigslist.js
Created May 2, 2013 01:17
Parse Craigslist page for description, title, images, location, postTime, using cheerio and requests, Node.js
var cheerio = require('cheerio')
, request = require('request');
var example_url = 'http://boston.craigslist.org/gbs/sub/3779053559.html';
var parsePage = function(url, callback){
request(url, function(err, resp, body) {
if (err){
callback(err);
return

this should be a mention @wcdolphin

@corydolphin
corydolphin / server.bat
Created March 3, 2013 23:55
Create simple HTTP Server as .bat script. Put it somewhere on your path, and simply type ```server [port=8000]``` to spin up a web server.
@ECHO OFF
:: Written by Cory Dolphin (@wcdolphin www.corydolphin.com)
:: Simple bat script to start a simple Python server in the current directory
:: Usage: server [port <default = 8000>]
if "%1" =="" ( :: no parameter, default port
python -m SimpleHTTPServer 8000
) else ( :: use specified port
python -m SimpleHTTPServer %1
@corydolphin
corydolphin / saveFigure.m
Created February 25, 2013 05:30
Saving figures in MATLAB as full size, not cutoff. Gets around issue of cutting off Title, etc. Slightly slow, but it works. Damnit MATLAB graphics library.
function [ output_args ] = saveFigure( handle, fileName )
% saveFigure
% Saves figure specified by `handle` as `fileName` in fullscreen
% as to get around the stupid behavior.
screen_size = get(0, 'ScreenSize');
origSize = get(handle, 'Position'); % grab original on screen size
set(handle, 'Position', [0 0 screen_size(3) screen_size(4) ] ); %set to scren size
set(handle,'PaperPositionMode','auto') %set paper pos for printing
saveas(handle, fileName) % save figure
@corydolphin
corydolphin / subl.bat
Created February 11, 2013 01:01
Simple batch script to make using sublime text on windows even better, allows opening of sublime text in the current directory, and as a parameter. Save somewhere on your path, or add to your path.
@ECHO OFF
:: Written by Cory Dolphin (@wcdolphin www.corydolphin.com)
:: Simple batch script to make using sublime text on windows even better
:: Usage: subl [file <default=current directory>]
set sublime_path=C:\Program Files\Sublime Text 2\sublime_text.exe
if "%1" =="" ( :: no parameter, open current directory
START "" "%sublime_path%" %CD%
@corydolphin
corydolphin / msvc9compiler.py
Last active January 12, 2017 03:57
Support compiling Python extensions on Windows.
"""distutils.msvc9compiler
Contains MSVCCompiler, an implementation of the abstract CCompiler class
for the Microsoft Visual Studio 2008.
The module is compatible with VS 2005-2012. You can find legacy support
for older versions of VS in distutils.msvccompiler.
"""
# Written by Perry Stoll hacked by Cory Dolphin to support VS 2012+
@corydolphin
corydolphin / findVisualStudioVersion.py
Created February 6, 2013 15:48
Find the version of VisualStudio installed on Windows using python
'''
:platform: Windows
:synopsis: Finds the current version of VisualStudio installed, supporting
Visual Studio 2005 to Visual Studio 2012 (and pretend support for 2014,
if versioning conventions continue).
.. moduleauthor:: Cory Dolphin <wcdolphin@gmail.com>
From:http://www.mztools.com/articles/2008/MZ2008003.aspx
To detect which Visual Studio versions (2005, 2008, etc.) are installed on a computer from a setup, you can use the following Windows registry entries (or the ones in the next section):
@corydolphin
corydolphin / FixNature.com.js
Last active December 12, 2015 00:28
Reading textbooks on nature.com sucks. They try and force you to open everything in the same window and every link invokes a JS function. This Gist contains the JS I use in a userscript to improve the readability, and can be found in the chrome store: https://chrome.google.com/webstore/detail/naturecom-readability-imr/caehidepagpmhcgajebpggaldjl…
var myFun = function(){
for(var nl = document.querySelectorAll(".nlsInlineLinksGrey.expand"), i=0; i < nl.length; i++){
nl[i].click();
};
for(var nl = document.querySelectorAll(".nlsInlineLinks.toWrapLongWord"), i=0; i < nl.length; i++){
nl[i].href = "http://www.nature.com/principles/ebooks/sci1210-principles-of-modern-biology-15577452/" + nl[i].href.replace(/[^\d]/g, "");
};
window.addEventListener("keydown", function(event) {
if (!event){event = window.event;}
@corydolphin
corydolphin / dabblet.css
Created December 13, 2012 14:49
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
body {
font-family: Helvetica, Arial, sans-serif;
font-size:90pt;
}