Skip to content

Instantly share code, notes, and snippets.

View BlogBlocks's full-sized avatar

Jack Northrup BlogBlocks

View GitHub Profile
@BlogBlocks
BlogBlocks / FACTOR.py
Created July 18, 2018 03:24
get and list factors for a number my numpy reshape tool
#!/usr/local/bin/python
base = int(input('Find Factors of: '))
FACTORS = []
for i in range(1,base+1):
if base %i == 0:
FACTORS.append(i)
print 'Possible Factors: {} = {}'.format(base, FACTORS)
for factor in FACTORS:
print factor,'x',base/factor
@BlogBlocks
BlogBlocks / nocomma.py
Created July 18, 2018 02:50
printing or using a list without tailing comma / final comma / comma at end
#!/user/local/bin
# filename: nocomma.py
namesinalist = "jack,myra,Darwin,Daryl,Christine"
namesinalist = namesinalist.split(",")
print "----with final comma--------------------"
for name in namesinalist:
#with final comma
print name+',',
text = """
@BlogBlocks
BlogBlocks / numpySplitNPloy.py
Last active July 15, 2018 06:30
Splits a numpy single column array into two columns (odd,even)then graphs each column separately on the same plot
import numpy as np
import matplotlib.pyplot as plt
"""
Divides a single column of a numpy array
in odd and even rows. Then graphs the odd
rows and the even rows seperatley
"""
# Numpy array - single column
sc = np.load("s-Numy-plot.npy")
# Odd numbers of the single column
@BlogBlocks
BlogBlocks / FindSymLinks.py
Created July 15, 2018 02:28
Finds the source of SymLinks
@BlogBlocks
BlogBlocks / genCDF.py
Created July 11, 2018 08:26
modeled after CFG generators, but much more simple to understand
import random
def main():
a = "A,The"
b = "dog,cat,little kid,elephant,mouse,ugly neighbor kid,princess,clown,chimp,priest"
c = "ran,cried,ate,made noise,jumped,slept,stepped on a spider"
d = "and said `hello` to the gerbil,and then ate the fish,with the turtle"
e = "without stopping,and called for his mother,along side his friend "
f = "didn't get to go to the zoo for crying., had to go home to eat.\
,loved to eat pizza for breakfast.,just like a little piggy - cried all the way home"
@BlogBlocks
BlogBlocks / ngram.ipynb
Created July 7, 2018 08:05
Notebook create ngrams and stores in sqlite3 db
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BlogBlocks
BlogBlocks / remove_output.py
Created July 7, 2018 06:50 — forked from damianavila/remove_output.py
Remove output from IPython notebook from the command line (dev version 1.0)
"""
Usage: python remove_output.py notebook.ipynb [ > without_output.ipynb ]
Modified from remove_output by Minrk
"""
import sys
import io
import os
from IPython.nbformat.current import read, write
@BlogBlocks
BlogBlocks / filters.py
Created July 2, 2018 09:45
no filter named tojson modify jinja2 / filters,py
This is the error I got:
def join_path(self, template, parent):
\n in template()
\nTemplateAssertionError: no filter named 'tojson'\n
I tried different versions of jinja2, but the error remained.
ref:
https://github.com/pallets/jinja/pull/456/commits/7b4393dc86f17d67e1711cd9aa02ff40366519b4
@BlogBlocks
BlogBlocks / WHATZUP
Last active June 5, 2018 00:56
An easy to use memory program create this file in you home directory. Give it proper execute permission with chmod +x. Create a sym-link to it in one of your bin directories.
#!/usr/local/bin/python
import sys
import sqlite3
conn = sqlite3.connect("WHATZUP.db")
c = conn.cursor()
if len(sys.argv) < 3:
print "\n*****************************************"
print "Not enough options were passed."
print "WHATZUP requires 2 arguments. the first -H , -R , -I , -D or -S .\nThe second can be a period."
print "If wanting to read all entries use -R . (use the period)"
@BlogBlocks
BlogBlocks / ngram.py
Created May 21, 2018 09:49 — forked from pebreo/ngram.py
An n-gram generator in Python (newbie program)
from collections import Counter
from random import choice
import re
class Cup:
""" A class defining a cup that will hold the words that we will pull out """
def __init__(self):
self.next_word = Counter() # will keep track of how many times a word appears in a cup