We understand that being able to show potential employers samples of your work may help you to get a job. UW Policy #73 (Intellectual Property) states that (subject to certain exceptions) creative work done at UW by employees or students is owned by the creator, and the owner of a creative work certainly has the right to show it to others. Any code that you did not submit for academic credit, and that was not created in response to an assignment problem (e.g., the result of your own private hobbies), is truly yours, and you may publish it as you see fit. However, for code submitted for academic credit or created in response to an assignment problem, there are two complicating factors.
The first complicating factor is that every student has a responsibility under UW Policy #71 (Section 2a, "Preventing their work from being used by others") to adhere to academic integrity guidelines, and avoid giving away potential assignment solutions to current or future students. Note that academic offenses can be prosecuted even after a course is completed.
The second complicating factor concerns the question of who actually owns assignment solutions. An assignment is a partnership between a student (or group of students) and an instructor. Without the contribution of both parties, the solution would not exist. The instructor supplies the question, a framework for the solution (including rules, guidelines, and possibly some starter code or libraries) and has in mind the general structure of what a correct solution ought to look like. The student fills in the details. Thus, the final outcome of the assignment is co-owned by the instructor and the student.
For these reasons, anything a student does with assignment solutions, including posting them online, requires the consent of the instructor(s) as co-creator(s). Course instructors have the following options:
The instructors' policy for a given offering of a course will be stated in the course outline. Since consent is required, if a policy is not mentioned in the course outline, the default option is that all publishing of solutions is prohibited.
In cases where the instructor permits provided code to be posted, the student must indicate which parts of the solution are the student's own creative work, and which parts were supplied by the instructor. Code supplied by the instructor, if permitted to be posted, must include a copyright notice.
If you wish to share your code with potential employers, and your instructor does not permit you to publicly post your solutions, you may host your code in a private repository, and provide a password to potential employers (for example, on your resume). Note that UW hosts a Git server (git.uwaterloo.ca), on which you may host private code repositories, free of charge, that can be shared with potential employers.