Skip to content

Instantly share code, notes, and snippets.

View BlogBlocks's full-sized avatar

Jack Northrup BlogBlocks

View GitHub Profile
import sqlite3
import os.path
from os import listdir, getcwd
from IPython.core.display import Image
def get_picture_list(rel_path):
abs_path = os.path.join(os.getcwd(),rel_path)
print 'abs_path =', abs_path
dir_files = os.listdir(abs_path)
return dir_files
import os
from time import sleep
import sqlite3
import os, requests, sys, json
import GISTkey
username=GISTkey.gistkey()[0]
password=GISTkey.gistkey()[1]
database ="GISTstore/gist.db"
conn = sqlite3.connect(database)
c = conn.cursor()
# USE:
#import GISTkey
#username=GISTkey.gistkey()[0]
#password=GISTkey.gistkey()[1]
def gistkey():
username='username'
password="password"
GistAPI = (username, password)
return GistAPI
#!/usr/bin/python
#USE: python SimpleGistPost.py FileToPost.py
import os, requests, sys, json
import GISTkey
from time import sleep
username=GISTkey.gistkey()[0]
password=GISTkey.gistkey()[1]
filename = os.path.basename(sys.argv[1])
content=open(filename, 'r').read()
r = requests.post('https://api.github.com/gists',json.dumps({'files':{filename:{"content":content}}}),auth=requests.auth.HTTPBasicAuth(username, password))
@BlogBlocks
BlogBlocks / Pmp3.py
Last active July 18, 2018 03:51
play music while "Jupytering"
import pyglet
def exit_callback(dt):
pyglet.app.exit()
return
def pmp3(mp3File):
music = pyglet.media.load(mp3File)
music.play()
pyglet.clock.schedule_once(exit_callback , music.duration)
pyglet.app.run()
return
# USAGE example:
# import UnCamel
# x = "TimeToUncamelCaseTextUsingFunctions"
# UnCamel.uncamel(x)
def uncamel(x):
return reduce(lambda a,b: a + ((b.upper() == b and (len(a) and a[-1].upper() != a[-1]))
and (' ' + b) or b), x, '')
def uncam(x):
import re
return re.sub("([a-z])([A-Z])","\g<1> \g<2>",x)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BlogBlocks
BlogBlocks / dir2file.py
Last active July 18, 2018 03:47
ists all file in a directory and copies the list to a file this will provide the full path to the MP3/ directory
"""
USAGE:
import dir2file
PATH = "MP3/"
mfile = "GISTstore/muz.list"
dir2file.mkFile(mfile, PATH)
lists all file in a directory and copies the list to a file
@BlogBlocks
BlogBlocks / ViewRows.py
Last active July 18, 2018 03:40
View sqlite3 rows
import sqlite3
"""
import ViewRows
database = "runit.db"
Start = 10
NumToView= 15
ViewRows.viewrows(database,NumToView,Start)
"""
def viewrows(database,NumToView,Start):
@BlogBlocks
BlogBlocks / runit.py
Last active July 18, 2018 03:39
Before I learned about NLTK and ngrams.This file does strange stuff. It will find a random sentence then store the first word of that sentence, then it will randomly search text for that word, then record the following word. The words are recorded in a file and in a sqlite database. Basically it builds a collection of words that follow words. On…
"""
This file does strange stuff. It will find a random sentence then store the first
word of that sentence, then it will randomly search text for that word, then record
the following word.
The words are recorded in a file and in a sqlite database. Basically it builds a collection
of words that follow words.
One goal is to find the most common two, three and four word combinations
"""