Skip to content

Instantly share code, notes, and snippets.

View Krewn's full-sized avatar

Kevin Nelson Krewn

View GitHub Profile
@Krewn
Krewn / helloWorld.js
Created December 18, 2016 14:50
This is one way to work inheritance in js. Data variables are separated from functional ones by calls to prototype.
a = function(){
this.v1 = "Hello";
this.v2 = "World";
}
a.prototype.print=function(){
alert(this.v1.concat(this.v2))
}
b = function(){
a.call(this);
@Krewn
Krewn / doodlin.py
Created September 1, 2016 20:18
This script draws some triangles.
# . .____
# -:/ .\
# :/ ..\
# ( ## ##.)
# :\ | ./ kpie314@gmail.com
# -:\ __./ Kevin Nelson
# --:\ ./ (c)2016
# .:. ++
# Doodle Utilities.
@Krewn
Krewn / fractions.py
Created August 11, 2016 15:41
Define a fraction class with the ability to handle string fraction representations as well as floating point inputs and create fractions with whole numerators and denominators.
"""
_____ ____ ____ __ ______ ____ ___ ____ _____ ____ __ __
| || \ / T / ] Tl j/ \ | \ / ___/ | \| T T
| __j| D )Y o | / /| | | TY Y| _ Y( \_ | o ) | |
| l_ | / | |/ / l_j l_j | || O || | | \__ T | _/| ~ |
| _] | \ | _ / \_ | | | || || | | / \ | __ | | l___, |
| T | . Y| | \ | | | j ll !| | | \ || T| | | !
l__j l__j\_jl__j__j\____j l__j |____j\___/ l__j__j \___jl__jl__j l____/
Kevin Nelson -- kpie314@gmail.com -- (c) 2016
@Krewn
Krewn / kgsc.py
Last active April 2, 2017 22:16
Krewn Google Spell Check: W/ Mechanize Browser Emulation and BeautifulSoup.
import mechanize
import BeautifulSoup
def chill():
return
def googleSpellCheck(word , supervised = False):
ret = word
chrome = mechanize.Browser()
chrome.set_handle_robots(False)
@Krewn
Krewn / VectorCharacters.py
Created June 12, 2016 23:04
In case you are allergic to bitmaps...
import Image, ImageDraw
#Characters are fixed font drawn on a 2x4 grid where y = 3 is the text line bottm.
characters = {'1':[[(0,1),(1,0),(1,3)],[(0,3),(2,3)]],'2':[[(0,1),(1,0),(2,1),(0,3),(2,3)]],'3':[[(0,1),(1,0),(2,1),(1,1.5),(2,2),(1,3),(0,2)]],'4':[[(0,0),(0,1.5),(2,1.5)],[(2,0),(2,3)]],'5':[[(2,0),(0,0),(0,1,),(1,1),(2,1.75),(2,2.25),(1,3),(0,3)]],'6':[[(1,0),(0,1),(0,3),(2,3),(2,2),(0,2)]],'7':[[(0,0),(2,0),(1,3)]],'8':[[(0,0),(2,0),(2,1),(1.5,1.5),(2,2.5),(2,3),(0,3),(0,2),(0.5,1.5),(0,0.5),(0,0)],[(0.5,1.5),(1.5,1.5)]],'9':[[(0,3),(2,2),(2,0),(0,0),(0,1),(2,1)]],'0':[[(0,0),(0,3),(2,3),(2,0),(0,0),(2,3)]],'a':[[(1.5,3),(1.5,1),(0,1),(0,3),(1.5,3),(2,3)]],'b':[[(0,0),(0,3),(2,3),(2,2),(0,2)]],'c':[[(2,1),(1,1),(0,1.5),(0,2.5),(1,3),(2,3)]],'d':[[(2,0),(2,3),(0,3),(0,2),(2,2)]],'e':[[(2,3),(0,3),(0,1),(2,1),(2,2),(0,2)]],'f':[[(1,3),(1,0),(2,0)],[(0,1.5),(2,1.5)]],'g':[[(2,3),(0,3),(0,1),(2,1),(2,4),(1,4)]],'h':[[(0,3),(0,0)],[(0,2),(2,2),(2,3)]],'i':[[(1,3),(1,1.5)],[(0.75,1.25),(1.25,0.75)]],'j':[
# given n Points in spherical cords where m is constant find a new point p
# the best meeting place.
# The Ovbious aproach :: Take the mean of the longitudes and the mean of the laditudes.
# This means that if you have 3 people in new york and 2 in sanfransisco you end up meeting
# in the middle of the country.
# The less ovbious aproach:
@Krewn
Krewn / index.py
Created March 26, 2016 02:10
Python file to provide apache index files in browsing support on github.io
# WARNING RUNNING THIS FILE WILL OVERIDE EXISTING index.html FILE IN CWD
import os
class indexer:
path = "~"
username = "" # !!! Enter your github username in the provided quotes.
site = "http://"+username+".github.io"
proj = "" # !!! Enter your repository name in provided quotes.
prod = []
@Krewn
Krewn / FleschKincaid.py
Created January 3, 2016 04:54
Scores a given piece of text based on the Flesch Kincaid Reading Test.
def syllables(s):# int(string)
v = ["a","e","i","o","u","y"]
c = 0
for k in s.lower():
if(k in v and not b):
c+=1
b = True
else:
b = False
@Krewn
Krewn / bookMark.py
Created July 11, 2015 18:02
Takes 2 arguments, a name and a link then creates an HTML document locally which redirects to a given link for Icon based book marking.
import sys
name = sys.argv[1]
link = sys.argv[2]
op=''
op+='<!DOCTYPE html>\n'
op+='<html>\n'
op+='<head>\n'
op+='<meta http-equiv="Refresh" content="0;'+link+'">\n'
op+='</head>\n'