Wednesday, April 27, 2011

momentum

successful people are constantly hustling and do more than the expectations of others
momentum
they are successful people and constantly work hard in school no procrastination
momentum
they are the winners, the successful people they are not the people trying to party or be cool
momentum
they are cooler than those people, they will change the world some day be famous be those guys at their own game
momentum
donald trump ttalks about it all the time
momentum
stay focus keep momentum keep it going
talk positive to yourself
you can overcome unconcisous negativeity by cosntantly thinking positive and never letting go of that positive feeling.
so what are you doing sitting here and writing this blog go get 'em
momentum

Saturday, April 23, 2011

Assignment 10

Okay so I had trouble with this assignment last week.
I have a lot of code written up so I DONT want to rewrite everything
my plan of action is to start with one class and review the code.
at each method I will debug it so it's smart to run with the string representation method first.

oh god this has been tought:

so you have to attach vertex objects to add to functions only IF the vertex's have been created
dont send strings or labels else you will FUCK up i think
though you could find the object with the label right?
what is the label?
could you find it with the data name?


oh man i feel like this is going to blow up in my face

i have noticed how big of a difference the "()" makes when working with methods, lists, and objects!, and properties!!!!!!



definantly start learning how to work with the methods you write rather than trying to access the objects data directly
USE THE METHODS TO ACCESS DATA


yea the () things really fuck me up!


so writing your udnciton and debugging in main at the same time REALLY HELPs

Friday, April 22, 2011

Assignment 8

Okay so im working on assignment 8 and i have to ponder

what does the init function in circular list, what should that do.
should it create a ciruclar list with the solider's already in it. OR should it be empty and I append the soliders in the main function definition.

I think i will have the list initialized to none and then have only one attribute which is the pointer to the first node "think self.first=None" then pass an argument

do I need any other attributes?

what happens when i assign a variable an object and then do:
while variable != none

i mean wouldn't python get confused because it does not know which attribute you are referring to (confused between variable.data and variable.next ???)


im having a problem with traversing a circular linked list
I can't seem to find an implementation that completes the last link before the jump to the new link while starting with the first link. because when i do then i can't start
starting from one and stopping when you reach back to one are very different prcesses
you basically need a .next that is not attached to a node that will be traversed otherwise it will kill the operation and that node will not be visited

Wednesday, April 13, 2011

classes

when defining classes
we use the paramer self in much of the methods to refer to the name of whatever object we create using the class

ergo:

class Student(object):
def getScore(self):
....

s=Student(Omar, 4)

s.getScore()

in the method def getScore(self) self is bounded to whatever object is create which in this case is "s"


why can't you do s.getScore() cause wouldnt it know that s is a part of class Student and therefore when I do s.getScore it knows and i wont have to write self as a parameter?
seems redundant

so when I do s.getscore it knows getscore is a method of object "s"



cool notes:

so i dont' have to write self, i can actually write object or any other word in there so long as im consistent and i write SOMETHING. Cause when I dont it says the method takes no arguments and one given


some other things: you can set default paramters in normal functions that dont exist inside of a class but you can't set instance variabales in normal functions that dont exist inside a class

i played around with classes alot to see how it works and doesn't work when i change certain things

and in normal functions you can write jobersih and the program works so long as it doesn't call that line in the code:

however when writing classes you can't do that python will get mad even if the code or function is not called

there's a lot of pointer passing that goes on in python, that's why you need self, cause it passes arguments like that (dont ask me why). all that i can extrapolate is that when you do:
s1=Omar()
s1 is really self
and so
def runner(self,parameter="None")
s1.runner() means that s1 is self, calling the function runner (though instnatieing it should link the two) passing a paramter of nothing.

Tuesday, April 12, 2011

Working in Files

So files has been a tricky spot for me

i think because im not comfortable with having code grab things off of a screen.

cause how does it know when it "sees" the letter "A" in a file that it is actually A?
And how does it keep track of what line it's in?


according to Mitra's instructions:
if the file is small and can be read in as a single string then you can do this:

infile= open("sample.txt", "r")
filecontent=infile.read()


however if the file is too large to fit in memory then you will have to read the file line by line
that command is readline()

to read remaining lines the command is readlines()

the simplest way to read a line line by lines would be to:

for line in openfile:
#process the line
line=line.rstrip("\n") #strips the newline character at the end
...
infile.close()


ahhhh okay!!!!
file=openfile.read() #reads the whole file in
file=openfile.readline() #reads one line and
file=openfile.readlines() #reads everything in the file and puts it in a list with each element being a line


#what's the advantage of this( readlines() )? it's the same
# as the for line in openfile
#it's different by sticking each line as an element in a list



################
  1. use readlines() when you want a list with each element in the list being the line of the text
  2. use readline() when you want only one line and python remembers the second line is next
  3. use the for loop (for line in openfile (see above)) to work line by line in an iterative fashion
  4. use openfile.read() when you want the entire file as one string

Saturday, April 9, 2011

Web Core-Technologies

alright so im beginning to learn about publishing on the web using core technolgies:
seems there are 7 core technologies:
1. XHTML is a mark up language. it has some control tags and content.
control tags used by browser to render the document on the web page. my question, how do control tags help render documents on the clinet monitor?
you can write the control tags by hand, or you can also use xhtml editors like MSFT FrontPage and Dreamweaver . the W3C has provided spcification for this language
2. Cascading Style Sheets
so CSS specifies how content is to be displayed. The trend in web design has been to seperate content from rendering instructions.
seperate content from rendering instructions...this is CSS
3.XML
stands for eXtensible Markup language. so i can create my own control tags. xml you can have any number of control tags, the tags can be used to describe content of the doc for humans and machines.
4. JavaScript
is a scripting language. used to write scripts that run on the client side.
ususally used in forms, they do the client side verification of data you enter in those forms. the scripts can also be used with CSS to produce dynamic effects. these are called Dynamic HTML
5. Java
is an object oriented language that is used for writing applets


Current Trends in Web Programming
Rich User Experience:
most wbe applications are not as responsive as desktop applications because they run on the server side.
AJAX has solved with problem. It stands for Asynchronous JavaScript and XML. SO! it means that small data can be transfered between client and server without web page having to be loaded

Web Server: is a software program that provides documents to browsers. Apache is widely used in this regard=68% of the market share.
A web browser inititates a request with a server, by sending it the URL of the document it wants...the server searches for it and restrives the document (but where does it search for it, in a database?)

so the internet has many layers.
i think important to me is TCP and Application Layer
in the application layer you have: SMTP and HTTP

so you have SMTP stands for simple mail transfer protocol
does the POP
and the IMAP
HTTP (hyper text transfer protocol)
transfers web pages from server to the client

A browser is an HTTP client for HTTP servers (listens on port 80)
http is the protocol for transfering files through TCP/IP sockets

so URL's are
universal resource locators, used to identify documents in the internet
they have the following patter:

scheme:object-address

in the case of HTTP:

//fully qualified domain name/path to document

Domain Names

okay so Overview of the internet chapter on Mitra's website was a wee bit confusing. I think seeing it in action would help me understand better

so there is HTTP, Domain names, IP address, DNS

Are URL's IP addresses which DNS serves up?

internet uses all the protocols
the web refers to http
i guess that's the most important thought. no one uses email anymore

most requests on the internet are for existing documents, but some requests are for program execution

browsers always inititate,
servers always react, although sometimes servers require responses and recall that facebook chat has the client wait and when the server gets a message can push to the client

Tips and Tricks

So I've learned that in control statements:
if nodeA and nodeB are equal to 4
then this statement:
if nodeA and nodeB == 4
doesn't work you to write it like this:
if nodeA == 4 and nodeB ==4:
...

working on homework on a saturday makes me feel really good. its quiet too

"He needs to stop always seeing things for what they are, and learn to occasionally look at things for what they could be."
--some successful guy


sets are pretty useful in making comparisons:


Union: combines two sets and takes out all the duplicates
(think of build a super car from two different cars you're looking at feature wise)

Intersection: what are the common things between two sets and leaves out the differences
(think okay this honda and this toyota both have a cd player, they both have etc)

Symettric difference: what are the differences and only the difference between two car models

difference of two sets: how does one car excel in it's features over another car i.e. what does it have that the other car doesnt (not thinking about what the other car has and this car doesnt, kinda like playing to your strengths. I'm a differece of two sets kinda thinker...got to play to your strengths


less than or equal to in python is >= NOT =>


sometimes i feel that python is like an automatic machine gun in the way the language is so advanced.
i haven't learned C but maybe that would be like a manual transmission car the way it's older and yet gives you more control over the language. (i.e. in C you don't have garbage collection)


sometimes i feel like to catch tough errors you just have to write certain sections of code from scratch again


assignment finished

Computer Science

It's been a while since my last post.
Just to update you on my life, I've recently got super interested in Computer Science, the reasons why I'll save for another blog later.

I'm creating this blog to share with the world what I've been learning, and a good way for me to remember the material (they say you remember 95% of what you teach).

A big focus for me will be on learning web development: Javascript, HTML, XML, XHTML, serverside code, client side code, apache, MySQL.
To be honest I don't have a fucking idea what any of these technologies are or how they work together but I want to learn. And I want to learn them because I'd like to make a social network or an ordering reservation system.

Let me say one thing, the failure of other people motivates me. Where others could not push forth is the motivation I need to not only make it past that point but to beat and shatter so much forth in that direction.