16 Pages

story04

Course: LIB 113, Fall 2009
School: Harvard
Rating:
 
 
 
 
 

Word Count: 3327

Document Preview

CSCI-E113: Class 4 Strings, CGI, Structs 0. Introduction Last week we continued to extend our HTML and shell skills as we improved our train schedule web site. On the C end of the course, we looked at arrays in general and strings in particular. We saw how to write programs that worked with arrays of strings. This week we continue to improve our website and extend our C skills. The...

Register Now

Unformatted Document Excerpt

Coursehero >> Massachusetts >> Harvard >> LIB 113

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
CSCI-E113: Class 4 Strings, CGI, Structs 0. Introduction Last week we continued to extend our HTML and shell skills as we improved our train schedule web site. On the C end of the course, we looked at arrays in general and strings in particular. We saw how to write programs that worked with arrays of strings. This week we continue to improve our website and extend our C skills. The outline for tonight's class is: 1. Quick review of the big picture 2. Strings can be dangerous 3. HTML and CGI scripts: select, case, generating HTML 4. A Bigger Project: trip planner 5. structs -- the basics 6. structs -- arrays to model train runs 1. Quick Review The big picture for C/Unix/CGI programs is: user --> html form --> CGI connector --> shell script --> tools 2. Strings Can Be Dangerous Most of the data flowing through this sequence of connec- tions is plain text. C programs store text in strings -- arrays of characters terminated by a nul character. Working with strings in C is not as easy as it is in other languages. There are two main types of problems. String Operations Require Functions The first problem new C programmers face with strings is that simple assignment, comparison, and concatenation opera- tors do not work with strings.For example: char s[10], t[10], u[10]; s = "abc"; t = s; u = "xyz"; if ( s == t )... t = u + s; do not work. Some do not compile, and some compile but do not do what you want. Last Update: 11/14/0-9November 14, 2005 page 1 class 4: strings, cgi, structs Strings are arrays, and loading, comparing, or append- ing arrays require looping through elements. These func- tions are performed with the functions: strcpy(dest, src) strcmp(str1, str2) strcat(dest, newstr) Read the man page onthese functions for details. We explore the program called string-ops.c to see how these operations work and how the functions work. String Overruns The most common C programming error is probably unchecked bufferoverflows. These bugs cause programs to crash and allow computervandals to break into computer systems. Understanding why they occur and how to prevent them is an essential skill. We explore two example programs: memdemo1.c #include <stdio.h> /* * memdemo - show how array over-runs are easy * variables are allocated on the stack in order of request */ main() { char c; int i; char a[6]; char b[6]; while(1){ printf("c=%c i=%d a=%s b=%s a[-6]=%c b[10]=%c\n", c, i, a, b, a[-6], b[10]); printf("enter a: "); scanf("%s", a); printf("c=%c i=%d a=%s b=%s a[-6]=%c b[10]=%c\n", c, i, a, b, a[-6], b[10]); printf("enter b: "); scanf("%s", b); printf("c=%c i=%d a=%s b=%s a[-6]=%c b[10]=%c\n", c, i, a, b, a[-6], b[10]); printf("enter i: "); scanf("%d", &i); } } Notice that this function contains four variables, two of them char arrays. What happens to these variables if we enter more characters than the length of the array?Data from one string appears in other variables! What is going on? Last Update: 11/14/0-9November 14, 2005 page 2 class 4: strings, cgi, structs Local variables are stored in memory on the stack. When a function begins, space needed for the variables is allocated on the stack by moving the stack pointer down the correct amount. When the function ends, the stack pointer moves back up, effectively deallocating the local variables, although leaving their contents unchanged. Most C compilers allocate variables in the order requested. Therefore the six chars for a appear above the six chars for b. If we put too many characters in b, they run overinto a. If we put enough extra characters into b, they run all the way into c and i and maybe farther. memdemo2.c: #include <stdio.h> /* * memdemo2.c -- show how variables in functions can affect * variables in calling functions */ main() { char a[10] = "abc"; printf("before function call: a is %s\n", a); f(); printf("after function call: a is %s\n", a); } f() { char b[3]; int i; int c; printf("in f, please enter string for b: "); for(i=0; (c=getchar())!='\n'; i++) b[i] = c; b[i] = ' '; printf("in f, b is now %s\n",b); } What about functions and variables? Can overruns in a func- tion affectmemory in the calling function?Yes. memdemo2.c shows this. Preventing Overruns Only you can prevent buffer overruns. Always check indexes as you load arrays.Never assume the size will be 'large enough' and never assume the source of data will know how much space is available. Last Update: 11/14/0-9November 14, 2005 page 3 class 4: strings, cgi, structs 3. HTML and CGI scripts: select, checkboxes, case, generating HTML We now return to our train schedule website. As we did last time, we list some improvements to make, and then we learn new techniques that allow us to make the improvements. We now have three CGI programs, one to find times of trains through a station, one to print a schedule, and one to print the names of stations.We continue toimprove this site. This week we add the following: 1. Nicer Reports -- use HTML on the response page 2. Easier Input -- User selects a station from a list 3. Better Integration -- include hyperlinks on response page 3.1. Nicer Reports -- use HTML on response We start with trainsched2.cgi. This pagereturns the schedule for a specified train number.The output is simple and clear: a list of times and stations in the right order. But the plain text format is boring. We can change this to send back html text with tags to set the color, drawhor- izontal lines, and make sure each stop is on its own line. #!/bin/sh # # trainsched3.cgi # connector for getting train schedule # v3:added html format # v2:this one uses and if then else to capitalize or not # eval `./qryparse` TITLE="Schedule for Train $trainnumber" # announce countent type echo "Content-type: text/html" echo "" # start of html, include title and body start echo "<html> <head><title>$TITLE</title></head> <body bgcolor='darkblue' text='white'> <B>$TITLE</B> <hr> " # content here if test "$caps" = "y" then ./trainsched2 $trainnumber | ./capitalize | sed 's/$/<br>/' Last Update: 11/14/0-9November 14, 2005 page 4 class 4: strings, cgi, structs else ./trainsched2 $trainnumber | sed 's/$/<br>/' fi # footer and end echo "<hr>" echo "<small>Generated by <i>$0</i> on `date`</small>" echo "</body></html>" The new techniques here include: a. Setting a variable TITLE to be used later in the script b. The sed command to put a new tag at the end of each line The only complicated item is the sed command. Sed is a "stream editor". It is designed tobe used in pipelines to modify text as it flows through the pipeline. A common use of sed is for text replacement. The syntax: s/original/replacement/ is the substitute command. The symbol $ stands for end of line. Running the Program from the Browser Command Line Before we move on, look carefully at the location line in the browser.This line contains the name of the computer, the name of the program, and the variables as name=value pairs. We do not have to use a browser form to fill in those values. Instead, we can type the values directly into the little window and run the program. The browser simply prepares that string and sendsthe string to the remote machine. We could send that string without using an html form. Remember this fact. It is very important. Nicer Output 2 -- Improve train-times We now look at the train-times page. The user enters a sta- tion name, and the program lists all the stops at that sta- tion. There are two problems -- input and output. For input, the user has to know the correct spelling of the sta- tion. It would be nicer to allow the user to pick a station from a list. On the output side, it would be nicer to list just theuse- ful information: train number, time, station. We know how to do that from our work with trainsched. We spruce up the shell script so it looks like: #!/bin/sh # # train-times3 # purpose: list train times for a station # usage: train-times3 stationname direction [day] Last Update: 11/14/0-9November 14, 2005 page 5 class 4: strings, cgi, structs #where: direction is "i" or "o", day is "m-f" or "sa" or "su" # # 1st - check there are two arguments or more if test $# -lt 2 then echo "usage: train-times3 station direction [day]" exit 1 fi STATION=$1 DIR=$2 grep "stn=$STATION" sched | grep "dir=$DIR" | grep "day=$3" | cut -d";" -f1,4,5 | ./semi2tab3 -t | sort -k2n and then we spruce up the cgi so it wraps the data inhtml tags: #!/bin/sh # train-times3.cgi # processing script for train-times3.html # this one produces html eval `./qryparse` # announce type echo "Content-type: text/html" echo "" # build up some strings for response case $dir in i) DIR="Inbound" ;; o) DIR="Outbound" ;; esac TITLE="$DIR Trains through $station" # generate html echo "<html><head><title>$TITLE</title></head> <body bgcolor='darkblue' text='white'> <b>$TITLE</b> <hr/>" | ./capitalize ./train-times3 "$station" "$dir" "$when" | ./capitalize | sed 's/$/<br>/' ./footer "$0" echo "</body></html>" This example uses the following tools: a) sed -- to add the <br> tag to end of each line b) case -- part of the sh language c) continuation -- if | is the last char, the pipeline continues d) footer - a short script to append a footer to the page Last Update: 11/14/0-9November 14, 2005 page 6 class 4: strings, cgi, structs The case control structure is like switch in C. It compares a string to a set of patterns. If the string matches a pattern, the code associated with that pattern is executed. Thecode for a pattern can contain any number of comamnds. The end of the code is marked with ;; . The case control structure works well with radio buttons on a webpage. The user picks one of several items, and the script can take different action based on the choice. 3.2. Easier Input -- Select a station from a list We now modify the formfor train-times so the user can selecta station from a list rather than have to type the name. To do this, we replace the textinput area with a <select> input control. A select has the format: <select name='NAME'> <option value='V1'>Str1 <option value='V2'>Str2 ... </select> The 'value' attribute the of option items is not required. If omitted, the value of the selection is the string. We replace the text input with a select, and to demonstrate the use of the value attribute, we change the when choice to use a select. The result is: <html> <!-- version 3.2 of the train-times html form version 3.2 allows user to select station from a list --> <body> Find train times for a station <p> <form action="train-times3.cgi" method="get"> Station: <select name='station'> <option>abington <option>anderson/woburn <option>andover ... <option>wyoming hill <option>yawkey </select> <br> Direction: <input type='radio' name='dir' value='i'>Inbound <input type='radio' name='dir' value='o'>Outbound <br> Day: <select name='when'> <option value='m-f'>Weekday <option value='sa'>Saturday <option value='su'>Sunday </select> <br> <input type="submit"> </form> Last Update: 11/14/0-9November 14, 2005 page 7 class 4: strings, cgi, structs <body></html> 3.3. Better Integration -- include hyperlinkson response page This page is certainly looking better. But, the page is cumbersome touse. We pick a station and get a list of trains. To see the schedule for that page, we then need to go tothe trainsched.html page to enter the train number. It would be nicer if we could enter the trainnumberfrom the result page, oreven better, just click on the train number. For our first attempt, we put the form to request a schedule on the result from the train time searcher. This is train- times3.2.cgi: #!/bin/sh # train-times3.2.cgi # processing script for train-times3.html # # This one produces html AND includes the form for trainsched.html # as part of the form. eval `./qryparse` # announce type echo "Content-type: text/html" echo "" # build up some strings for response case $dir in i) DIR="Inbound" ;; o) DIR="Outbound" ;; esac TITLE="$DIR Trains through $station" # generate html echo "<html><head><title>$TITLE</title></head> <body bgcolor='darkblue' text='white'> <b>$TITLE</b> <hr/>" | ./capitalize ./train-times3 "$station" "$dir" "$when" | ./capitalize | sed 's/$/<br>/' # add form to request train schedule echo " <form action='trainsched3.cgi'> Train number please? <input type='text' name='trainnumber' size='10'> <p> Last Update: 11/14/0-9November 14, 2005 page 8 class 4: strings, cgi, structs Capitalize Names: <input type='radio' name='caps' value='y'>Yes <input type='radio' name='caps' value='n'>No <p> <input type='submit'> </form>" ./footer "$0" echo "</body></html>" This works better than the old method, but it is still not the best solution. Think about how to make the train numbers clickable links that call up the schedule directly. 4. A Bigger Project: A trip Planner Our site is now looking better, and allows users to search for trains to places they want to visit. A more powerful feature would be the trip planner. The user would select a starting station andan ending station, and the program would figure out which trains to take to get from one place to another. We shall solve this problem over several weeks. We start with an htmlpage that allows the user to select two sta- tions and a cgi program and script that tells the user if the two stations are on the same line. Here is the form: <html> <head><title>Trip Planner Version 1</title></head> <body> <center>Trip Planner Version 1</center> <form action='trip_plan1.cgi'> Starting station: <select name='startstn'> <option>abington <option>anderson/woburn ... <option>wyoming hill <option>yawkey </select> Ending station: <select name='endstn'> <option>abington <option>anderson/woburn ... <option>wyoming hill <option>yawkey </select> <input type='submit' value='find trains'> </form> Last Update: 11/14/0-9November 14, 2005 page 9 class 4: strings, cgi, structs </center> </body> </html> and here is the processing script: #!/bin/sh # # trip_plan1 -- first version of trip planner # Allow user to specify starting station and ending station # if both are on same line, then list trains that go from Start to End # if both are not on same line, then say we cannot do that now # eval `./qryparse` echo "Content-type: text/plain" echo "" if test "$startstn" = "$endstn" then echo "$startstn is the same as $endstn" exit 0 fi ./lines_through "$startstn" | sort > lines1.tmp ./lines_through "$endstn" | sort > lines2.tmp COMMON=`comm -12 lines1.tmp lines2.tmp` if test -z "$COMMON" then echo "$startstn and $endstn are on different lines" else echo "$startstn and $endstn are on $COMMON" fi STARTLINES=`./lines_through "$START"` ENDLINES=`./lines_through "$END"` rm lines1.tmp lines2.tmp There is not a simple solution to a general trip planner. To figure out how to get from one place to another, we need some way to store and process a train line and figure out when trains get to which stops. There are no standard unix tools to manage this, so we shall have to write some new C code.Our new C code will need to record train trips. A train trip is a sequence of stops. A stop is a station, a time, a train number. Therefore we need a way to create a way to store a sequence of stops. C has a data type perfect for representing a stop: the struct. 5. Structs - the basics Say we wanted to record a train trip in a C program. A trip is a sequence of stops. Our datafile records for each stop a a train number, a direction, a time, a station, a day, and Last Update: 11/14/0-9November 14, 2005 page 10 class 4: strings, cgi, structs a line. Say we wanted to record for each stop the sta- tion, the direction, the train number, and the time. C pro- vides the struct asa way to store several values in one container. We can define a new data type called a struct tstop by writing this code: struct tstop { char station[SLEN]; /* name of station */ char dir; /* direction 'i' or 'o' */ char tnum[NLEN]; /* the train number */ int hr, min; /* stop time */ }; This defines what a struct tstop looks like. This is a blueprint, not a house. To instantiate actual variables, we write: struct tstop s1,s2; /* create trainstops */ And we can work with the members of these structs using: strcpy(s1.station, "salem"); s1.dir = 'o'; s1.hr = 9; s1.min = 40; Operations on Structs The three basic operations one may perform on structs are: access Use the dotoperator to select members in a struct. Inthe examples above, we see how to refer to a string, a char, and ints.The name of the struct is on the left, and the name of the member is on the right. assign Structs, unlike arrays, may be copied with the = operator. Thus, s2 = s1, will copy the entire struct. No special function is needed. functions Structs are passed to functions by value and may be returned by value. See structdemo1.c for details: #include <stdio.h> /* structdemo1.c -- show basic struct operations */ #define SLEN 100 #define NLEN 10 /* type declaration -- a blueprint, not a house */ struct tstop { char station[SLEN]; char dir; char tnum[NLEN]; int hr, min; }; Last Update: 11/14/0-9November 14, 2005 page 11 class 4: strings, cgi, structs main() { struct tstop s1, s2; /* two houses */ strcpy(s1.station, "salem"); s1.dir = 'o'; s1.hr = 9; s1.min = 45; strcpy(s1.tnum, "114"); show_stop("struct s1:\n", s1); s2 = s1; show_stop("struct s2:\n", s2); } /* * print stop info */ show_stop(char msg[], struct tstop s) { printf("%s", msg); printf("TR=%s;dir=%c;TI=%02d:%02d;stn=%s\n", s.tnum, s.dir, s.hr, s.min, s.station); } 6. structs -- arrays to model train runs A train trip is a sequence of stops. We model that with an array of stops: struct tstop trip[NUM_STOPS]; Each element in this array is of the form trip[i] and is a structtstop. The name ofthe station, for example, is trip[i].station . We now write a program to read datafrom the user, build an array, then print the array. #include <stdio.h> /* readtrip.c * shows: how to use an array of structs * use: reads in one train trip worth of stops */ #define MAXSTOPS 100 #define LINELEN 200 #define SLEN 40 #define NLEN 10 #define YES 1 #define NO 0 struct tstop { char station[SLEN]; char dir; char tnum[NLEN]; int hr, min; }; Last Update: 11/14/0-9November 14, 2005 page 12 class 4: strings, cgi, structs main() { struct tstop trip[MAXSTOPS]; int n = 0; while( n<MAXSTOPS && read_in_stop(trip, n) == YES ) n++; show_stops(trip, n); } /* * prompt user for items, load the struct at pos * Return NO for no more data, YES for more */ int read_in_stop(struct tstop a[], int pos) { char line[LINELEN]; int hh, mm; if ( getline("station:", line, LINELEN) == NO ) return NO; strcpy(a[pos].station, line); if ( getline("direction: ", line, LINELEN) == NO ) return NO; a[pos].dir = line[0]; if ( getline("number: ", line, LINELEN) == NO ) return NO; strcpy(a[pos].tnum, line); if ( getline("time (hh:mm): ", line, LINELEN) == NO) return NO; if ( 2 == sscanf(line,"%d:%d", &hh, &mm) ){ a[pos].hr = hh; a[pos].min = mm; } return YES; } int getline(char prompt[], char buf[], int len) { printf("%s", prompt); if ( fgets(buf, len, stdin) == NULL ) return NO; buf[strlen(buf)-1] = ' '; return YES; } /* * list all the stops recorded in the array of structs */ show_stops(struct tstop trip[], int len) Last Update: 11/14/0-9November 14, 2005 page 13 class 4: strings, cgi, structs { int i; struct tstop s; for(i=0; i<len; i++){ printf("Stop %d: ", i); s = trip[i]; printf("TR=%s;dir=%c;TI=%02d:%02d;stn=%s\n", s.tnum, s.dir, s.hr, s.min, s.station); } } Last Update: 11/14/0-9November 14, 2005 page 14
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Harvard - LIB - 113
CSCI-E113: Class 2 Starting C1m0. Introduction0mLast week we saw that Unix programming is based on combiningtools into scripts and pipelines. HTML forms and connectorprograms allows people to use these Unix programs over t
Harvard - LIB - 113
csci-e113lecture 2 samples page 1_: trainsched :#!/bin/sh# trainsched# usage: trainsched train## action: finds all entries for that TR and selects time and stn cols#if test $# != 1thenecho &quot;usage: trainsched trainnum&quot;
Harvard - LIB - 113
CSCI-E113 Student Information Sheet Please complete and hand in at lecture Name: _ Email address: _ Phone: _Programming Background/Courses: _Have You Registered?YES I PLAN TO I PROBABLY WILL I PROBABLY W
Harvard - LIB - 05
CSCI-E113 Lecture 5 Outline_ Topics: Arrays, Pointers, Functions Approach: Introduce Pointers, Explore their use Main Ideas: Quick Review - Forms, Connector, Scripts, Tools in C Focus tonight on memory usage in C
Harvard - LIB - 113
CSCI-E113 Lecture 5 Outline_ Topics: Arrays, Pointers, Functions Approach: Introduce Pointers, Explore their use Main Ideas: Quick Review - Forms, Connector, Scripts, Tools in C Focus tonight on memory usage in C
Harvard - LIB - 113
C Coding StyleE113 Style Requirements Homework submitted to csci-e113 will be graded on func- tion, design, and readability. An program that imple- ments an excellent algorithm but is unreadable islike an ex
Harvard - LIB - 113
csci-e113 class 119 sep 20041. WelcomeWelcome to csci-e113, Introto C/Unix/CGIprogramming.Tonight's class will introduce you to the topics, goals, andmethods of the course.The outline is:a. brief summary of course
Harvard - LIB - 113
CSCI-E113 Lecture 4 Outline_ Topic:Strings, CGI, and Structs Approach:Explore Basics, Improve Website Overview and Intro: We have seen four levels of code: form, script, tools, connector Today focus on C data struc
Harvard - LIB - 113
Assignment 0 Not to be Turned InCSCI-E113_This assignment is just a suggestion for you to follow to getcomfortable using the Unix system. Do not turn in this work, butdo report any questions or problems you have as you work thro
Harvard - LIB - 113
THE BIG PICTURE Fall 2002CSCI-E113_&lt;html&gt; &lt;head&gt;&lt;title&gt;csci-e113 syllabus&lt;/title&gt; &lt;/head&gt;&lt;body bgcolor=white&gt;&lt;table width=&quot;100%&quot; border=0 bgcolor=linen cellspacing=0 cellpad-ding=3&gt;&lt;tr&gt; &lt;td align=left width='25%'&gt; &lt;fon
Harvard - LIB - 113
COURSE DESCRIPTIONFall 2003CSCI-E113DATELECTUREREADINGSECTIONHOMEWORKSep 17Overview Unix/C and the web Sample Program The structure of C programs Functions and filters Arrays and Strings Arrays and Strings More Loops Generating HTML
Harvard - LIB - 113
THE BIG PICTUREFall 2002CSCI-E113&lt;html&gt; &lt;head&gt;&lt;title&gt;csci-e113 syllabus&lt;/title&gt; &lt;/head&gt; &lt;body bgcolor=white&gt; &lt;table width=&quot;100%&quot; border=0 bgcolor=linen cellspacing=0 cellpadding=3&gt; &lt;tr&gt; &lt;td align=left width='25%'&gt; &lt;font color='#902830' size=-1&gt;
Harvard - LIB - 113
COURSE DESCRIPTION Fall 2003CSCI-E113__ DATE LECTUREREADING SECTION HOMEWORK_ Sep 17 Overview Unix/C and the web Sample ProgramCR:Ch 3,4,9K:Ch 2,3,4 Using Unix File
Harvard - LIB - 113
GRADING STANDARDSFall 2000CSCI-E113GRADING Homework assignments are graded on a 100 point scale. The 100 points are divided between Function (70 points) and Design (30 points). In software engineering, getting a program that works is only part
Harvard - LIB - 113
Assignment 2: An HTML Table Generator Introduction Our train schedule page produces html reports with nice colors and fonts, but the columns do not line up, and the spacing is too dense. We need a new tool to present schedule data in clear, attractiv
Harvard - LIB - 113
Assignment 2: Extra Credit Introduction The &lt;attributes&gt; section of input to tt2ht allows the user to specify attributes to include in &lt;td&gt; tags for different columns in the output. That way, one column could be right justified, another column could
Harvard - LIB - 113
An Introduction to the UNIX ShellS. R. BourneABSTRACT The shell is a command programming language that provides an interface to the UNIX operating system. Its features include control-flow primitives, parameter passing, variables and string substi
Harvard - LIB - 113
Assignment 4: Symbol Table1. IntroductionIn this assignment you will write a sixth implementation ofthe storage system used by the word frequency program shownin lecture. The main part of the program and shell scriptsto feed
Harvard - LIB - 113
CSCI-E113 Finite State Machines_0. Introduction: Processing TextA lot of Unix programming involves working with text.Unix text processing programs read data in, do somethingwith the data, and write data out. Text files
Harvard - LIB - 113
WELCOME TO vi - NOTE: SET YOUR SCREEN to 80 COLUMNS and 25 ROWSPLEASE NOTE: If at any time it looks as though something terriblehas happened, just type the sequence of characters: q !That is a colon, the letter q, and an exclamati
Harvard - LIB - 113
FINDING THE SOURCE OF A SEGFAULT-1. Compile your program with debugging symbols: % gcc -g -o myprog myprog.c 2. Tell the shell to keep core files: % unlimit coredumpsize - or - % ulimit -c unlimited 3. Run the pro
Harvard - LIB - 113
Assignment 2: Extra CreditIntroductionThe &lt;attributes&gt; section of input to tt2ht allows theuserto specify attributes to include in &lt;td&gt; tags for differentcolumns in the output.That way, one column could be rightjustified, anot
Harvard - TT - 113
Assignment 2: Extra CreditIntroductionThe &lt;attributes&gt; section of input to tt2ht allows theuserto specify attributes to include in &lt;td&gt; tags for differentcolumns in the output.That way, one column could be rightjustified, anot
Harvard - LIB - 113
Assignment 2: An HTML Table GeneratorIntroductionOur train schedule page produces html reports withnicecolorsand fonts, but the columns do not line up, and thespacing is toodense. We need a new tool to presentschedu
Harvard - LIB - 113
CHAPTER 9 On the Early History and Impact of Unix Tools to Build the Tools for a New Millenium &quot;When the barbarian, advancing step by step, had discovered the native metals, and
Harvard - CSCIE - 50
/ RPS.javaimport java.util.*;/* * Game of rock/paper/scissors to demo methods and returns * Demo for CSCI E-50a and CSCI E-50b, 2006 * * @author Jan Jackson * @version 1.0 */public class RPS{ /* final variables for lookup an
Harvard - CSCIE - 50
From jjackson@fas.harvard.edu Wed Feb 20 16:32:46 2008Date: Wed, 20 Feb 2008 16:32:39 -0500 (EST)From: Jan Jackson &lt;jjackson@fas.harvard.edu&gt;To: undisclosed-recipients: ;Subject: Section infoHi All, Just a few items regarding sections, ho
Harvard - CSCIE - 50
From jjackson@fas.harvard.edu Sun Feb 10 16:16:41 2008Date: Sun, 10 Feb 2008 16:16:40 -0500 (EST)From: Jan Jackson &lt;jjackson@fas.harvard.edu&gt;To: undisclosed-recipients: ;Subject: Thursday sectionHi, First of all, welcome to the Thursday s
Harvard - CSCIE - 50
/ NumberGuesser.java/* * This program plays a number guessing game. The program will select a * random number, and ask the user to guess it. Upon success, the total * number of guesses will be displayed. A graphical user interface has
Harvard - CSCIE - 50
/ NumGuessGUI.java/* * This program plays a number guessing game. The program will select a * random number, and ask the user to guess it. Upon success, the total * number of guesses will be displayed. A graphical user interface has *
Harvard - CSCIE - 50
/ NumGuess.java/* * This program plays a number guessing game with the user, in which the user * tries to guess a randomly selected value. Upon success, the number of guesses * is displayed. * * @author Jan Jackson */import java.u
Harvard - CSCIE - 50
import java.io.*;import java.util.*;public class FileCopy{ public static void doCopy( String [] data ) {try{ File f = new File( data [0] ); Scanner input = new Scanner( f ); PrintWriter output = new PrintWriter
Harvard - CSCIE - 50
This is a test file.It is used to demonstratefile input and output operations,to show students how it can be done with files.
Harvard - CSCIE - 50
This is a test file.It is used to demonstratefile input and output operations,to show students how it can be done with files. Second iteration: This is a test file.It is used to demonstratefile input and output operations,to show students
Harvard - CSCIE - 50
/ Circle.javapublic class Circle extends Shape{ protected double radius; public Circle() {super();radius = 1; } public Circle( double x, double y, double r ) {super( x, y );radius = r &gt; 0 ? r : 1; / ternary ope
Harvard - CSCIE - 50
/ Shape.javapublic abstract class Shape{ protected double x, y; public Shape() {/ x = y = 0;this( 0, 0 ); } public Shape( double x, double y ) {this.x = x;this.y = y; } public String toString() {re
Harvard - WEEK - 06
Alex Liebmanliebman@fas.harvard.eduSummary: The Strategic Setting of Choices: Signaling, Commitment, and Negotiation in International Politics. (Chapter 3 of Strategic Choice and International Relations). Abstract: This chapter is about how the s
Harvard - WEEK - 12
Edward Cunninghameac4@mit.eduEmanuel Adler, The Emergence of Cooperation: National Epistemic Communities and the International Evolution of the Idea of Nuclear Arms Control, IO, 46:1, Winter 1992. Causal Argument An American intellectual innovati
Harvard - WEEK - 06
Susan Hamiltonshamilt@fas.harvard.eduSchelling, Thomas C. 1966. Arms and Influence. New Haven: Yale University Press Chapters 2, 3. Abstract These chapters and this book overall constitute Schelling's attempt to lay out the basic principles of &quot;t
Harvard - WEEK - 08
Democracies at War by Dan Reiter and Allan C. StamNote from Ben: Only chapters 2, 6, and 7 as well as the endnotes and the bibliography are included on this website. The figures and tables for these chapters can be found starting on page 103 of thi
Harvard - WEEK - 07
Sam Goldman Response paper #1 15 March 2004 Three Arguments on Causation in 1914 Discussions of international politics are plagued by the conflation of three logically distinct questions: why is there war; why is there variation between war and peace
Harvard - WEEK - 08
Erin Simpson To: Re:esimpson@fas.harvard.eduGov 2710 James Fearon, &quot;Domestic Political Audiences and the Escalation of International Disputes,&quot; American Political Science Review 88, no. 3 (Sept. 1994), pp. 577-592Related Articles: every IR arti
Harvard - WEEK - 10
B. Goodrichgoodrich@fas.harvard.eduSummary of: James D. Fearon, Bargaining, Enforcement, and International Cooperation, International Organization, Vol. 52, No. 2. (Spring, 1998), pp. 269-305. Authors abstract: Neoliberals and their neorealist cr
Harvard - WEEK - 12
Erin M Simpsonesimpson@fas.harvard.eduTo: Gov 2710 Date: 4 May 2004 Re: Judith Goldstein and Robert Keohane, eds, Ideas and Foreign Policy: Beliefs, Institutions, and Political Change (Cornell University Press, 1993), Chapters 1, 4, 5, 6. Chapter
Harvard - WEEK - 06
Sara SieversSara Sieverssievers@fas.harvard.edusesievers@yahoo.comDavid A. Baldwin, &quot;Power Analysis and World Politics,&quot; World Politics 31 (January 1979), pp. 161-194.Summary: Baldwin's key contribution is describing the failure in the power
Harvard - WEEK - 11
Sam Goldmanswgoldm@fas.harvard.eduLisa L. Martin, &quot;Interests, Power, and Multilateralism,&quot; International Organization 46:4 (Autumn 1992), pp. 765-92. General Summary Assuming that they are rational and self-interested (although not necessarily un
Harvard - WEEK - 12
Sam Goldmanswgoldm@fas.havard.eduAlexander Wendt, Social Theory of International Politics, Cambridge: Cambridge University Press, 1999. Chapters 6 and 7 We learned in the previous assignment that &quot;anarchy is what states make of it&quot;. Now Wendt sep
Harvard - WEEK - 09
Paul Bodnarbodnar@fas.harvard.eduIR Field Seminar, Week 9 Sophie Meunier. What Single Voice? European Institutions and EU-U.S. Trade Negotiations, International Organization 54:1 (Winter 2000), pp. 103-135. Summary Investigates whether variation
Harvard - WEEK - 07
Alex Liebman Notes for Robert Gilpin, War and Change in World Politics March 16, 2004liebman@fas.harvard.eduIntroduction: The basic question: &quot;How and under what circumstances does change take place at the level of international relations?&quot; (2).
Harvard - WEEK - 11
Dean Kaodeankao@mit.eduTo: Gov 2710 Re: Abram Chayes and Antonia Handler Chayes, &quot;On Compliance,&quot; International Organization 47:2 (Spring 1993), pp.175-205 Central Claim: When nations enter into international agreements of high political salience
Harvard - WEEK - 09
Erin Simpson 7 April 2004 Gov 2710-Response Paper #3 Week 9 Erik Voeten creates a model of major power negotiation under the confines of something like the UN Security Council (UNSC). Voeten's primary finding is that by credibly revealing outside (no
Harvard - WEEK - 04
Edward Cunninghameac4@mit.eduHelen Milner, Interests, Institutions, and Information, Chapters 3+4 (Princeton, New Jersey: Princeton University Press, 1997)Chapter 3 Causal Argument Question: What are the conditions under which and in what ways d
Harvard - WEEK - 10
Paul Bodnarbodnar@fas.harvard.eduIR Field Seminar, Week 10 Andrew Moravcsik, &quot;Negotiating the Single European Act: National Interests and Conventional Statecraft in the European Community,&quot; International Organization 4:1 (Winter 1991), 19-56 Summ
Harvard - WEEK - 10
B. Goodrichgoodrich@fas.harvard.eduSummary of: Kenneth A. Oye, ed., Cooperation Under Anarchy (Princeton University Press, 1986), (also available in World Politics 38:1 (October 1985). Chapters by Oye, (Downs, Rocke and Siverson), Conybeare, and
Harvard - WEEK - 02
Structure or Attribute? Theory and Approach for Understanding International Politics Gov.2710 Field Seminar on International Relations Professors Andrew Moravcsik andAllan Stam February 10, 2004 Tatsuya NishidaA. Introduction Theories of internatio
Harvard - WEEK - 06
Erin Simpsonesimpson@fas.harvard.eduRe: Stephen D. Krasner, &quot;State Power and the Structure of International Trade,&quot; World Politics vol. 28, no. 3 (April 1976), pp. 317-347.Related topics: hegemonic stability theory; international trading struct
Harvard - WEEK - 08
Siddharth Mohandasmohandas@fas.harvard.eduBear F. Braumoeller, &quot;Deadly Doves: Liberal Nationalism and the Democratic Peace in the Soviet Successor States,&quot; International Studies Quarterly, vol. 41 #3 (1997), pp. 375-402. Overview A major strain o
Harvard - WEEK - 04
750-Word Reaction note Sara Sievers Week 4 After having read some of this material in great detail, Im sorry to say the work that jumped out as most interesting to me was neither of the two articles I actually wrote up, although it would have been ni
Harvard - WEEK - 08
Democracies at War by Dan Reiter and Allan C. Stam Note from Ben: Only chapters 2, 6, and 7 as well as the endnotes and the bibliography are included on this website. The figures and tables for these chapters can be found starting on page 103 of this
Harvard - WEEK - 10
Alex Liebmanliebman@fas.harvard.eduSummary for Robert Axelrod The Evolution of Cooperation, Chapters 1-4 A-tisket a-tasket, I go TIT FOR TAT with anybody whos talkin this shit, that shit - Eminem Abstract: The basic question is: Under what condit
Harvard - WEEK - 06
Sam Goldmanswgoldm@fas.harvard.eduMearsheimer, John J. 2001. The Tragedy of Great Power Politics. New York: Norton. Chapters 3 and 4. In these chapters Mearsheimer presents a definition of power appropriate to offensive realism. Power is &quot;based o