Skip to content

Instantly share code, notes, and snippets.

View SMaguina's full-sized avatar

Sylvia Maguiña SMaguina

View GitHub Profile
@SMaguina
SMaguina / Ques.sql
Last active August 29, 2015 14:27
SQL Drill
#1. How many copies of the book titled The Lost Tribe are owned by the library branch whose name is "Sharpstown"?
USE SQLAssignment
GO
SELECT Title, No_Of_Copies, BranchName
FROM [BOOK_COPIES] AS BC
INNER JOIN [LIBRARY_BRANCH] AS LB ON BC.BranchId = LB.BranchId
INNER JOIN [BOOK] AS BK ON BC.BookId = BK.BookID
WHERE Title = 'The Lost Tribe'
@SMaguina
SMaguina / webcrawler.py
Created September 19, 2015 17:23
Web Scrapping with BeautifulSoup
from bs4 import BeautifulSoup
import urllib2
webpage = urllib2.urlopen("http://inadaybooks.com/justiceleague")
# converts "urlopen" object into BeautifulSoup
soup = BeautifulSoup(webpage, "html.parser")
# finds the first instance of a div that has the id "container"
divContainer = soup.find("div", {"id":"container"})
@SMaguina
SMaguina / simpson_info_database.py
Last active October 9, 2015 06:12
CRUD Database Tables in Python 2
import sqlite3
conn = sqlite3.connect('simpsons.db')
# create table named SIMPSON_INFO
conn.execute("CREATE TABLE SIMPSON_INFO( ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, GENDER TEXT, AGE INT, OCCUPATION TEXT );")
conn.execute("INSERT INTO SIMPSON_INFO (NAME, GENDER, AGE, OCCUPATION) VALUES ('Bart Simpson', 'Male', 10, 'Student')");
conn.execute("INSERT INTO SIMPSON_INFO (NAME, GENDER, AGE, OCCUPATION) VALUES ('Homer Simpson', 'Male', 40, 'Nuclear Plant')");
@SMaguina
SMaguina / database.py
Last active September 20, 2015 00:33
Program initializing user inputs and CRUD database data with Python 2
import sqlite3
conn = sqlite3.connect('simpsons.db')
def createTable():
conn.execute("CREATE TABLE if not exists SIMPSON_INFO( \
ID INTEGER PRIMARY KEY AUTOINCREMENT, \
NAME TEXT, \
GENDER TEXT, \
AGE INT, \
@SMaguina
SMaguina / gui.py
Created September 24, 2015 05:41
WxPython GUI-1
import wx
class Frame(wx.Frame):
def __init__(self, title):
wx.Frame.__init__(self, None,\
title=title, size=(300,250))
panel = wx.Panel(self)
button = wx.Button(panel,label="Exit",size=(100,40),pos=(100,100))
# Bind button event to the function self.exit
button.Bind(wx.EVT_BUTTON, self.exit)
@SMaguina
SMaguina / characterprogram.py
Created September 25, 2015 00:53
wxPython Character GUI
import wx, db_program
class Frame(wx.Frame):
def __init__(self, title):
wx.Frame.__init__(self, None,\
title=title, size=(800,600))
panel = wx.Panel(self)
# Creating the menu bar
menuBar = wx.MenuBar()
@SMaguina
SMaguina / clock.py
Created September 27, 2015 22:47
Clock Python Program to Calculate Time Lived Based on Age
print("Let's see how long you have lived in days, minutes and seconds.")
name = input("name: ")
print("now enter your age")
age = int(input("age: "))
days = age * 365
minutes = age * 525948
seconds = age * 31556926
print(name, "has been alive for", days,"days", minutes, "minutes and", seconds, "seconds! Wow!")
@SMaguina
SMaguina / applegame.py
Created September 29, 2015 01:02
Apple Game Program Python 2
import time
global gold
global apples
apples = 0
gold = 0
def start():
print ("Hello and welcome!")
name = raw_input("What's your name:")
print ("Welcome, "+name+"!")
@SMaguina
SMaguina / wxpython.py
Last active September 30, 2015 00:31
WxPython GUI-User Inputs and Font Text/Color
import wx
class Frame(wx.Frame):
def __init__(self, title):
wx.Frame.__init__(self, None, title=title, size=(300,250))
panel = wx.Panel(self)
menuBar = wx.MenuBar()
fileButton = wx.Menu()
@SMaguina
SMaguina / filetransfer.py
Last active October 7, 2015 04:49
UI for File Transfer project - Python 2.7 - IDLE
import wx
class Frame(wx.Frame):
def __init__(self, title):
wx.Frame.__init__(self, None, title=title, size=(300,250))
panel = wx.Panel(self)
menuBar = wx.MenuBar()
fileButton = wx.Menu()