Skip to content

Instantly share code, notes, and snippets.

@bazub
bazub / gist:4247344
Created December 9, 2012 22:49
Pseudo-code for searching for end-point of ship
Get Start_point(x,y)
if x-3 >=1
mark endpoint (x-3,y) //north
if x+3 <=10
mark endpoint (x+3,y) //south
if y-3 >=1
mark endpoint (x,y-3) //west
if y+3 <=10
mark endpoint (x,y+3) //east
update map
@bazub
bazub / stars.php
Created November 7, 2012 14:46
Star rating system using PHP/HTML/CSS
<html>
<style type="text/css">
.starRate {position:relative; margin:20px; overflow:hidden; zoom:1;}
.starRate ul {width:160px; margin:0; padding:0;}
.starRate li {display:inline; list-style:none;}
.starRate a, .starRate b {background:url(star_rate.gif) left top repeat-x;}
.starRate a {float:right; margin:0 80px 0 -144px; width:80px; height:16px; background-position:left 16px; color:#000; text-decoration:none;}
.starRate a:hover {background-position:left -32px;}
.starRate b {position:absolute; z-index:-1; width:80px; height:16px; background-position:left -16px;}
.starRate div b {left:0px; bottom:0px; background-position:left top;}
@bazub
bazub / gist:3877971
Created October 12, 2012 08:17
Grayscale/Binary images using PIL
im=Image.open("1.jpg")
#im=im.rotate(1)
im.save("e.jpg")
im2=im.convert("L")
im2.save("b.jpg")
threshold = 100
im = im2.point(lambda p: p > threshold and 255)
im.save("d.jpg")
img="d.jpg"
result = tesseract.ProcessPagesWrapper(img,api)
@bazub
bazub / gist:3877955
Created October 12, 2012 08:14
Initialize the Tessaract API
api = tesseract.TessBaseAPI()
api.SetOutputName("outputName");
api.Init(".","eng",tesseract.OEM_DEFAULT)
api.SetPageSegMode(tesseract.PSM_AUTO)
@bazub
bazub / gist:3877920
Created October 12, 2012 08:09
Includes
import tesseract
from PIL import Image
@bazub
bazub / gist:3756143
Created September 20, 2012 14:05
Button that opens the Database
def golog():
os.system("notepad.exe "+"C:/Users/Bogdan/git/GPS2PC/GPS2PC/log.txt")
butWHIB=Button(root,text="Where have I been?",command=golog)
butWHIB.grid(row=5,column=0,columnspan=2,sticky=N+S+E+W)
@bazub
bazub / gist:3756136
Created September 20, 2012 14:04
Button that takes the user to Google Maps
butG2S=Button(root, text="Go to Maps", command=gomaps)
butG2S.grid(row=3,column=0,columnspan=2, sticky=N+S+E+W)
@bazub
bazub / gist:3756128
Created September 20, 2012 14:03
Button linked to the function that "translates" GPGGA
butGC=Button(root, text="Get coordinates", command=getcoord)
butGC.grid(row=1,column=0, sticky=N+S+E+W)
var=StringVar()
lab =Label(root, bg='white',width=50,height=2,textvariable=var,justify=CENTER)
lab.grid(row=1, column=1,sticky=N+S+E)
lab2=Label(root)
lab2.grid(row=2,column=0)
@bazub
bazub / gist:3756115
Created September 20, 2012 14:02
Adding an Image
photo=PhotoImage(file="worldlg.gif")
ca=Canvas(root)
ca.create_image(200,123,image=photo)
ca.grid(row=0,column=0,columnspan=2,sticky=N+S+E+W)
@bazub
bazub / gist:3756109
Created September 20, 2012 14:01
Main window
root=Tk()
root.geometry("420x420+400+100")
root.title("Where am I? by Bazub")
root.bind("<Escape>", lambda e: e.widget.quit())
root.resizable(FALSE,FALSE)
root.mainloop()