Skip to content

Instantly share code, notes, and snippets.

View mbstacy's full-sized avatar

Mark Stacy mbstacy

  • Harvard University
  • Boston, MA
  • 22:25 (UTC -05:00)
View GitHub Profile

gitPushAdminEnforcement

gitPushAdminEnforcement uses Github API to turn off admin enforcement, run git push, and re-enable admin enforcement.

Installation:

  1. pip install PyGithub
  2. Copy gitPushAdminEnforcement in a bin directory (eg: ~/.local/bin)
  3. Add bin directory to PATH variable
  4. chmod +x ~/.local/bin/gitPushAdminEnforcement
#!/usr/bin/env python
import os
import sys
def rename(path):
for f in os.listdir(path):
flist=f.split('-')
if len(flist) >2:
os.rename(f,"{0}.zip".format("-".join(flist[:-1])))
import pandas as pd
import json
data =open("/Users/mstacy/Downloads/oessgpn.json","r").read()
dflist=json.loads(data)['results']
df =pd.DataFrame(dflist)
result = pd.concat([df, df['created_by'].apply(pd.Series)], axis=1).drop('created_by', axis=1)
#endpoints
endps=pd.DataFrame([x for x in result.endpoints])
endps.columns=['end1','end2']
endps.apply(pd.Series)
@mbstacy
mbstacy / secret_key_generator.py
Created December 23, 2015 22:20
Generate random secret key
import os, string
import binascii
key = binascii.hexlify(os.urandom(24)).decode("utf-8")
#Random upper case letters
for i in range(1,15):
char = random.choice(string.ascii_lowercase)
key = "".join(c.upper() if c in var else c for i, c in enumerate(key))
@mbstacy
mbstacy / OWS_Water_Usage_Oil_Gas.ipynb
Created November 3, 2014 17:39
OWS - Oil and Gas water usage grouped by year and fluid type
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbstacy
mbstacy / Pandas_groupby_mesonet
Created August 6, 2014 18:42
Pandas IO and Group By Weather Data Statisitcs
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@mbstacy
mbstacy / get-data-example.py
Last active August 29, 2015 14:04
US Army Corps of Engineers - Monthly Data into pandas
{
"metadata": {
"name": "Pandas Fixed Width"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@mbstacy
mbstacy / ok_mesonet.py
Last active August 29, 2015 13:57
Oklahoma Mesonet Pandas DataFrame
#!/Users//anaconda/bin/python
"""
Python main module requires the correct python path.(see above).
Args sites startdate enddate
sites: string - comma sperated sites
startdate: YYY-MM-DD
enddate: YYYY-MM-DD
example:
Single site:
./ok_mesonet.py adax 2014-01-01 2014-02-01
% This program is modified by XIA XU from the programm written by Tao Xu to study the inverse problem of
% a one/two/three C pool model using MCMC with initial C pool size
% 06/25/2013-Windows version
clear all;
close all;
format long e;
% random seed is the clock, clock is used because the time we start something is relatively random