Konstantinovich

Instructor email:  
Office hours: 
Periods 6+7 in room 301. (I get food at the start of 6, so I may be gone for a few minutes)
It helps to let me know you are coming so I am aware when you plan to come because sometimes I have meetings.
CS Dojo: 
A place to hone your skills, and practice with the guidance of caring supportive upperclassmen. 
(Will start soon)  Mon-Thur in 3073:40-4:40pm


Tools and References: 
OSX text editors:   textmate   Brackets

Network Proxy: 
Press the ubuntu start menu circle (top left)
Type: network    and click on the network icon.
click on Network Proxy, switch it to manual then fill in:
HTTP:   149.89.1.30                 3128
HTTPS:   149.89.1.30                3128
(3128 goes in the far right box of each line)

2018-06-11

posted Jun 10, 2018, 7:42 PM by Konstantinovich Samuel

Final Project Exit Survey: (Required for EVERYONE)

2018-06-08

posted Jun 8, 2018, 6:09 AM by Konstantinovich Samuel   [ updated Jun 8, 2018, 7:48 AM ]

Final Project Final Update:

You have presentations today and Monday.
Hand in your prototypes when you present. 



By MONDAY 6am:
Every project must have the following:
  - Name your folder "finalproject" without quotes.  
      ~/public_html/finalproject/
  - In your final project folder: Have an HTML file called   finalproject.html
        ~/public_html/finalproject/finalproject.html
  - This html file must contain:
    * You and your partner's names.
    * A description of what your site is.
    * Brief instructions on how to use your site
    * A list of WORKING features.
    * A link to the starting page of your project.
   -DO NOT EDIT YOUR FINAL PROJECT AFTER MONDAY 6AM.

DO NOT EDIT YOUR WEBSITES 1-6. If there is an error, and you want to get credit for any mistakes the timestamps matter. 
You can email me to look at a lab if you think it was just a tiny fix.  (Not if you did the whole thing at this point)
If you want to fix something, make a COPY of the file, with the name    filename.WORKING.py   



Website Labs 1-6:
Osis01Homepage02Tables03Madlibs04 show data05show data05 random
+ theme
06 pokedex06 with form
max points551066464
207191578551066560
20754380233313000
20844878755666460
20847898255860040
20858564655866360
208635821531066484
208653923551060050
20872753755664064
20873572010000000
208947408551066360
20899472353865020
20901550255966364
209194430551066564
209239581551066464
209246313551066564
20937013955666364
209474253551066464
21134423955866440
21148620433603030
21256693955866264
212995765551060030
213516099451066300
21371010650666460
214182677551066564
214188773551066364
214197659551066564
21424411355860000
21424555755500000
214288953551060000
214324154551066564
21433783443600060
21435639655364400
214372971551066461
21446700355966564
214468092551066564
21449474255500000
214494767451066464
21450960655066080
214510869551060084
214544348551000030
214557951531066580
21457001240064000
214592941401066340
21462394402540050
21464009655365461
214646499551066564
21470496753666170
21471073355866364
214953895551066584
21495504951335460
21500422745766300
215104217551066484
21511438055864250
215130188551066564
215195892551066564
21520267253065450
21521115240300000
215225665551066364
215336603551000060
215347451551066484
21535931630003040
215359670551066564
21558559755966460
215674565551066464
21568360843060030
215683616451066564
21572266154865440
21572346145463000
215733239551066460
21577691503000000
215786757551066564
215807744551066584
21582828655466440
21588103853866460
215950890551066564
21596777955606400
215996893551060040
21608190145000000
216085217451066560
216090803551066564
21610699755860060
216108423551066564
21610852245966470
216283093301066484
21628845655000000
218657526551065360
21957104955865300
220904254551066564
22209584655660000
223280371551066661
23836252953300000
24192286300000000
242187706551066500
242200079551066460
24267556955806560

2018-06-06

posted Jun 6, 2018, 7:23 AM by Konstantinovich Samuel

Tool to help with your py files on marge:

http://marge.stuy.edu/~pbrooks/PythonChecker/PythonChecker.py

2018-06-01 HW

posted Jun 1, 2018, 6:16 AM by Konstantinovich Samuel

Deliverables:

1. Your pokedex lab, must have a way to choose 2 pokemon to compare. This should be a form at the top of your table, that lets you enter 2 numbers(easier), or pokemon names (harder). When you submit it, it would show you those two pokemon compared at the top. 

2. Your prototypes must be updated to include the user tests you are doing this weekend. If you already did a good job on the prototype, then you don't have a lot of work to do. This prototype is 20% of your project grade. 
-Project description
-Data description / sources
-Images/Description of user interaction/forms AND what data they will display
-Project phases (breakdown of tasks) 
   -- Include COMPLETED, and pending phases.
-The Usability test*. (Each person does 1 test)
-THE CHANGES you are making to your design after the usability test.


3. Usability test (
-Design a task for a user to complete that you think is reasonable. 
(e.g. 
    Find the 5 most expensive neighborhoods, in NYC. (on a real estate site)
    Compare the performance of the Mets and the Yankees. (on a sports site)
    Show the graph of age to shoe size. (on a site that has those data points)
)
-Show a paper printout of how your site will look / work, and see how they would interact with it. 
-Ask the person to think out loud when interacting with the site.
-Record the problems they had, and what things seemed clear to them.
-How can you re-design your interface?

2018-05-31

posted May 31, 2018, 5:51 AM by Konstantinovich Samuel   [ updated Jun 6, 2018, 6:47 AM ]


Stuyvesant is forming a partnership with Google to create a project mentorship program that will being next fall. The program will focus on pairing groups of students (1-4) with Google employees who will help them create a substantial software project. 
There will be an info session for this program TODAY (5/31) at 4pm in room 307. The program will be open to rising Juniors and Seniors.


1. Make a folder in the same directory as your py file to hold your images. 
mkdir img

Then change the permissions to 777. This will allow
chmod 777 img

Now you have a folder to store your images, and the following script would work:

#!/usr/bin/python
print "Content-type: text/html\n"

#help you see errors
import cgitb
cgitb.enable()
#these 3 lines are important
#matplotlib allows you to use the graphing tools on a web server
#the Agg line is required to work without a graphical desktop (running on a remote computer)
import matplotlib matplotlib.use("Agg")
import matplotlib.pyplot as plt

def main():
        x=[0,1,2,3,4] 
        y=[0,3,5,9,3]
        plt.plot(x,y) 
        plt.savefig("img/graph.png")

        plt.clf() #clear the figure after saving!

        
        x = [0.1,0.2,0.1,0.3,0.9]
        y = [0.9,0.4,0.2,0.5,0.2]
        plt.scatter(x, y,  alpha=0.5)
        plt.savefig("img/graph2.png")

        print "Done!<br>"
        print "Image?<br>"
        print '<img src="img/graph.png">'
        print "Another Image!<br>"
        print '<img src="img/graph2.png">'
head = '''<!DOCTYPE html> <html> <head> <title>Demo!</title> </head> <body>''' print head #main will print things main() print ''' </body> </html>'''

2018-05-28 Forms!

posted May 28, 2018, 8:11 PM by Konstantinovich Samuel   [ updated May 29, 2018, 8:48 AM ]

More resources for web related python:

New HTML:
Forms are the widgets that you fill out /check off / select, and then submit to a website. 

Here is a sample website with forms:


CGI - Common Gateway Interface
We use CGI so that code (in various languages) can execute and communicate with web browsers.

You have used CGI to make a python program send data to web browsers!

Now we need the web browsers to send data back to the program. (You already print results, but now your results can react to the parameters)


Simple way to get and use form data:

See the following two SEPARATE files working together here: 

1. Create an HTML form on your website. This can be an HTML file or even a py 

2. Create a form handling python program (use the filename that matches the action of the form):

1. HTML FORM:

<!DOCTYPE html>
<html>
<head><title>Forms!</title></head>
<body>

<h2>This is a form</h2>

<form method="GET" action="formhandler.py">

Name:<input type="text" name="yourName" size="20" value="Bob"><br>

Repeat:<input type="text" name="count" size="20" value="0">

Use 'Yo':<input type="checkbox" name="greeting" value="yo"><br>

Pick a poke-meal:
<select name="pokechoice" size="1">
  <option selected>Pika-Stew</option>
  <option>Chared-Charmander</option>
  <option>Bulbasalad</option>
</select>
<br>

<input type="submit" name="button" value="I'm done.">
<input type="submit" name="button" value="I'm confusedx.">

</form>
</body></html>


2. PYTHON FORM HANDLER

#!/usr/bin/python
print "Content-type: text/html\n"

#help you see errors
import cgitb
cgitb.enable()

# We need these library modules to retrieve the user's answers
import cgi

def cgiFieldStorageToDict( fieldStorage ):
   """Get a plain dictionary, rather than the '.value' system used by the cgi module."""
   ans = {}
   for key in fieldStorage.keys():
     ans[ key ] = fieldStorage[ key ].value
   return ans

def main():
    # ask the library function to retrieve all answers and put them
    #   into a dictionary
    form = cgiFieldStorageToDict(cgi.FieldStorage())


    #ONLY FOR DEBUGGING
    #print the form data!
    print form
    print "<br>"

    #lets say you want 2 pieces of information, the name, and the count (number of times to print the name)

    #pick some values that you want as default 
    #(we want to check for -1 later because we REQUIRE this value to be filled in.)
    count = -1
    #try to replace it using the form (if it exists!)
    if "count" in form:
        #the data must be integer formatted!
        count = int(form['count'])


    #pick default value (this won't cause an error if they forget to fill it out)
    name = "Joe"
    #try to replace it
    if "yourName" in form:
        name = form["yourName"]


    #after getting all the info you need, you can now
    #print the body of your html using the variables that
    #you initialized with the form elements.
    if count == -1: #we didn't get the required field
        #ERROR BODY HERE
        print "<h2>error! Did not receive all required form data!</h2>"
    else:
        #GOOD BODY HERE
	print "<h1> Main Site!</h1>"
        for i in range(count):
            print "Hi " + name + "!<br>"

    

head = '''<!DOCTYPE html>
<html>
  <head>
   <title>Demo!</title>
   
  </head>

  <body>'''


print head


main()

print ''' </body> 
</html>'''


1

2018-05-25

posted May 25, 2018, 6:22 AM by Konstantinovich Samuel   [ updated May 25, 2018, 6:47 AM ]

Quiz.

Final Project Idea Feedback + Group remixing.

Everyone Fill this out:

2018-05-24

posted May 24, 2018, 6:08 AM by Konstantinovich Samuel   [ updated May 25, 2018, 6:22 AM ]

Now that your table is done you have 1 more required phase:

Every time you load the page, choose 2 different random pokemon ID's.
Display those two pokemon at the top of your table side by side along with their Types + Attack/Def/HP stats compared in the middle.

Note:
a. (The full table of 300 should be below them)
b. (Any reference to a pokemon larger than 300 should be ignored (replace with a '-' )


Bulbasaur vs Ivysaur

Bulbasaur Stats Ivysaur
Attack 49 62
Defense 49 63
Hitpoints 45 60
Types Grass 
Poison
Grass
Poison



CHALLENGE: Here is the type chart for pokemon. Modify their attack stat based on these multipliers. (Two different multipliers stack multiplicatively and the order doesn't matter)
Attacks types are the rows, target types are the columns
A normal type attacking Rock gets a .5 multiplier. 
A normal type attacking Ghost gets a multiplier of 0
A Fire type attacking Fire gets a .5 multiplier. 
A Fire type attacking Grass or Ice gets a multiplier of 2.
A Fire type attacking something that was hypothetically grass AND ice, would have a 4.0 multiplier. (Stacking the multipliers)

Attacking,Normal,Fire,Water,Electric,Grass,Ice,Fighting,Poison,Ground,Flying,Psychic,Bug,Rock,Ghost,Dragon,Dark,Steel,Fairy
Normal,1,1,1,1,1,1,1,1,1,1,1,1,0.5,0,1,1,0.5,1
Fire,1,0.5,0.5,1,2,2,1,1,1,1,1,2,0.5,1,0.5,1,2,1
Water,1,2,0.5,1,0.5,1,1,1,2,1,1,1,2,1,0.5,1,1,1
Electric,1,1,2,0.5,0.5,1,1,1,0,2,1,1,1,1,0.5,1,1,1
Grass,1,0.5,2,1,0.5,1,1,0.5,2,0.5,1,0.5,2,1,0.5,1,0.5,1
Ice,1,0.5,0.5,1,2,0.5,1,1,2,2,1,1,1,1,2,1,0.5,1
Fighting,2,1,1,1,1,2,1,0.5,1,0.5,0.5,0.5,2,0,1,2,2,0.5
Poison,1,1,1,1,2,1,1,0.5,0.5,1,1,1,0.5,0.5,1,1,0,2
Ground,1,2,1,2,0.5,1,1,2,1,0,1,0.5,2,1,1,1,2,1
Flying,1,1,1,0.5,2,1,2,1,1,1,1,2,0.5,1,1,1,0.5,1
Psychic,1,1,1,1,1,1,2,2,1,1,0.5,1,1,1,1,0,0.5,1
Bug,1,0.5,1,1,2,1,0.5,0.5,1,0.5,2,1,1,0.5,1,2,0.5,0.5
Rock,1,2,1,1,1,2,0.5,1,0.5,2,1,2,1,1,1,1,0.5,1
Ghost,0,1,1,1,1,1,1,1,1,1,2,1,1,2,1,0.5,1,1
Dragon,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,0.5,0
Dark,1,1,1,1,1,1,0.5,1,1,1,2,1,1,2,1,0.5,1,0.5
Steel,1,0.5,0.5,0.5,1,2,1,1,1,1,1,1,2,1,1,1,0.5,2
Fairy,1,0.5,1,1,1,1,2,0.5,1,1,1,1,1,1,2,2,0.5,1

Charmander vs Ivysaur

CharmanderStatsIvysaur
Attack5262
Defense4363
Hitpoints3960
TypesFire (2.0)
Grass(0.5)
Poison(1.0)


Fire is 2.0 vs grass, and 1.0 vs poison, so the product is 2.0
Grass is .5 vs Fire
Poison is .5 vs Fire

2018-05-22

posted May 22, 2018, 6:34 PM by Konstantinovich Samuel   [ updated May 22, 2018, 6:54 PM ]

Summer Opportunities: July 5th - 24th
CSTUY is running its SHIP program for the 5th year, this year it is run out of the Microsoft Offices on 42nd street and 8th ave. 
This is an exploratory program with a relaxed environment where the goal is to try to build cool projects, not worry about tests / quizzes
You can bolster your technical skills and work with other people enthusiastic about CS. 
You will also be mentored by Stuyvesant Juniors that completed AP, while they work on their own cool projects.
Apply here if that sounds appealing:


Look for some interesting Data Sets that are formatted in a way you think you can use:
https://www.sajari.com/public-data
You can work together with classmates to find datasets.

DUE By Friday:
Have a partner.
Hand in a 1-2 paragraph proposal for your website. Explain what data you have access to and what you plan to do with it. 

DUE by Tuesday:
Have a prototype of your website. Include several views of the data, and what you want the user to be able to do (More on this later)

Final Project (Data Project) Requirements:
Part I
Either :
a)Take 2 different data sets and use python to find and display some relationship. 
    (Differences, clustering, correlations, etc)
b)Take a large data set that has a lot of parts to it, and find some trends/differences/correlations when viewing subsets of the data. 
    (e.g. different age groups, geographic locations, or other factors)

Part II(we haven't learned this yet)
Use interactive forms to allow the viewer of the website to select what they would like to see from the data set. 

Work with a partner on the project. Look at your partner's websites before you commit to a partner!

The following students must work alone:
214623944 
208735720 
241922863
214245557




2018-05-22

posted May 22, 2018, 5:53 AM by Konstantinovich Samuel   [ updated May 22, 2018, 6:23 AM ]

Lab + Complete as HW Update your pokelab as follows:
1. make the name of your file:
pokedex.py

2. Include 2 columns in your HTML table:
Evolved From, Evolves Into

ID image name height weight Evolves From Evolves To
001 Bulbasaur 7 69 - Venusaur
002 Venusaur 10     130 Bulbasaur Ivysaur
003 Ivysaur 20     1000 Venusaur -
 

3. Add a Stats column where you get 3 values arranged vertically:

Attack: X
Defense: Y
HitPoints: Z

Use stats.csv which is in the format:
id,type_1,type_2,attack,defense,hp,special_attack,special_defense,speed,ability_1,ability_2,ability_hidden
1,grass,poison,49,49,45,65,65,45,overgrow,NA,chlorophyll
2,grass,poison,62,63,60,80,80,60,overgrow,NA,chlorophyll
3,grass,poison,82,83,80,100,100,80,overgrow,NA,chlorophyll


ID image name height weight stats Evolves From Evolves To
001 Bulbasaur 7 69 Attack: 49
Defense: 49
HitPoints: 45
- Venusaur
 
4. Easy optional part that use stats.csv also: 
Add a type column that can display up to 2 different types (grass + poison for example), and color code the types!
Fire = Red
Water = Blue
Poison = purple
Plant = green
etc.

1-10 of 66