Skip to content

Instantly share code, notes, and snippets.

View Benhgift's full-sized avatar

Ben Gift Benhgift

View GitHub Profile
@Benhgift
Benhgift / open_ag_files.py
Created June 14, 2019 19:30
agg <pattern> will open the files it finds
#!/usr/bin/env python3
from subprocess import getoutput
import os
import re
import fire
def main(*ag_args):
ag_args = ' '.join(ag_args)
print_matches(ag_args)
@Benhgift
Benhgift / open_git_changed_files.py
Last active November 21, 2018 03:32
open some changed files on branch, compared to master
#!/usr/bin/env python3
from subprocess import getoutput
import os
import re
def main():
files = get_files()
if not files[0]: return error()
nums = file_nums_to_open(files)
@Benhgift
Benhgift / remove_most_branches.py
Last active November 21, 2018 02:46
remove all git branches except for the few you want
#!/usr/bin/env python3
from subprocess import getoutput
import re
def main():
branches_dict = branches()
save_nums = input('type branch numbers to NOT delete, seperated by spaces\n')
save_nums = map(int, re.findall(r'\d+', save_nums))
for num in save_nums:
@Benhgift
Benhgift / map_solver.py
Last active October 27, 2016 03:04
map_solver
from clint.textui import colored
from time import sleep
sleep_time = .2
array = [
[2, 1, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 0],
[0, 1, 1, 1, 0, 0],
[0, 1, 0, 0, 0, 1],
from clint.textui import colored
from time import sleep
from random import randint
def s(divisor=1):
sleep(.5*divisor)
def get_diff_elems(list1, list2):
def coding_challenge_specific_io(challenge_function):
with open('input') as in_data:
with open('output', 'w') as out_data:
in_lines = [x.strip() for x in in_data.readlines()[1:]]
in_data = parse_input_data(in_lines)
challenge_complete_lines = [challenge_function(data) for data in in_data]
out_lines = ['Case #{}: {}\n'.format(i+1, line) for i, line in enumerate(challenge_complete_lines)]
out_data.writelines(out_lines)
import sqlite3 as sq
import numpy as np
from scipy.interpolate import spline
from matplotlib import pylab
def insert_data(c):
c.execute('create table if not exists sleep (hours_slept INT)')
print("How much sleep did ya get")
user_input = input()
@Benhgift
Benhgift / gist.cpp
Created May 18, 2012 01:52
gist-cleaner
//returns 3 if divisible by 3, 5 if divisible by 5, and 0 if neither and 10 if both
int fizz_buzz(int num) {
if((num % 3 == 0) && (num % 5 == 0))
return 10;
else if(num % 3 != 0) {
if(num % 5 != 0)
return 0;
else
return 5;
}