Skip to content

Instantly share code, notes, and snippets.

View nicholsonjf's full-sized avatar

James Nicholson nicholsonjf

View GitHub Profile
@nicholsonjf
nicholsonjf / implementation-and-comparison-of-navigation-algorithms.ipynb
Created March 1, 2023 04:21
Implementation and Comparison of Navigation Algorithms.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#! /bin/sh
##
# Loops through all the objects in the current directory. If the object is a git repo it
# performs a "git pull --rebase" and "git checkout master".
#
# To use as a shell command:
#
# OSX:
# Place this file in /usr/local/bin
@nicholsonjf
nicholsonjf / mailman-faculty-parsing.py
Last active April 29, 2020 20:33
Mailman Faculty Parsing
import re, csv
reg = re.compile('(?<=Name: )(?P<faculty_name>.+)(?= HUID).+(?<=NETID: )(?P<faculty_3x3>.+)(?= EPPN)')
with open('grouper-export/groupExportAll_SPHFaculty.csv') as fdata:
freader = csv.reader(fdata)
with open('faculty-filenames.csv', 'w') as ffile:
fieldnames = ['faculty_name', 'faculty_3x3', 'filename']
writer = csv.DictWriter(ffile, fieldnames=fieldnames)
writer.writeheader()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nicholsonjf
nicholsonjf / euler104.py
Last active August 29, 2015 13:58
Project Euler #104 notes
# Below function returns the index of the first number in the
# fibonacci sequence where first nine digits contain integers 1-9
def first_nine():
a, b, indexb = 1, 1, 2
nine = set('123456789')
b_first_nine = set(str(b)[:9])
while (nine <= b_first_nine) == False:
a, b, indexb = b, b + a, indexb + 1
@nicholsonjf
nicholsonjf / backup_postgres
Created March 8, 2014 03:38
Backup Postgres database (Windows 7)
Most of what I learned came from here: http://www.postgresql.org/docs/9.1/static/app-pgdump.html
The goal is to backup my application database into a single .sql file and store that on a network drive, so if my machine craps out I can get a new machine, reinstall Postgres and restore my database.
Here's the steps to do that on Windows 7:
Step 1: cd into Postgres bin directory so you can run pg_dump.exe
$ cd \Program Files\PostgreSQL\9.3\bin
@nicholsonjf
nicholsonjf / git-remote-mirror
Created March 8, 2014 03:20
Add a remote mirror on a network drive from a local Git repository (Windows)
This stackoverflow question was a huge help: http://stackoverflow.com/questions/1887364/git-clone-to-external-drive-for-backup
If you use Git on you development machine, it's good to keep a remote backup in case your dev machine fails.
Step 1: Create the empty bare repo on your network drive
$ mkdir O:/myrepo_backup
$ cd O:/myrepo_backup
$ git init --bare
@nicholsonjf
nicholsonjf / easy_install_behind_proxy
Created March 7, 2014 23:44
Use Python easy_install on Windows 7 Behind an Enterprise Web Proxy
This article was a huge help: http://evadeflow.com/2010/09/easy_install-through-a-proxy-server/
Basically, what I learned is that you need to set both the http_proxy and https_proxy for setuptools easy_install to work.
It's worth mentioning I'm using this version of Python 2.7 on Windows 7 64-bit: http://www.activestate.com/activepython
From the Windows command prompt, I first set the two environment variables:
c:\> set http_proxy=<user>:<password>@<proxy_ip_address>:<port>
@nicholsonjf
nicholsonjf / GroupGetMembers
Created August 1, 2013 23:31
Perl script that prints the members of an Active Directory group in one column (as opposed to three columns like the command prompt NET command). Makes it easier to copy and paste the output.
# Provides warnings and error messages for debugging etc.
use strict;
# Importing the Win32::Netadmin module and one of its functions GroupGetMembers
use Win32::NetAdmin qw (GroupGetMembers);
# Syntax of GroupGetMembers function
# GroupGetMembers(server, groupName, userArrayRef)
# Fills userArrayRef with the members of groupName.
@nicholsonjf
nicholsonjf / Bachelor Party
Last active December 19, 2015 14:48
I'm planning a friend's bachelor party. 16 people are invited. To RSVP and come, the price is $150. If you can't come but still want the t-shirt we designed for the bachelor party, it's $35. This Python function calculates what the return is depending on how many people RSVP and how many only buy the shirt.
def steve(x,y):
"""where x is buyers of shirts and y is number of RSVPs"""
js = x * 35
rsvp = y * 150
total = jt + rsvp
print "Money from shirts: $" + str(js)
print "Money from RSVPs: $" + str(rsvp)
print "Total: $" + str(total)
steve(7,9)