Skip to content

Instantly share code, notes, and snippets.

View nycomp's full-sized avatar

nyjc.computing nycomp

  • Singapore
View GitHub Profile
@nycomp
nycomp / Wordle.md
Last active October 23, 2024 05:40
Complete the code to make a wordle game!

A Simple Wordle Game

This wordle game ... doesn't quite work yet! The code in main.py is fine, but none of the functions or classes in the wordle module have been implemented ...

To make it work, complete the tasks below.

Task 1: guess validation

  1. Implement wordle.is_five_letters() and wordle.is_valid_word()
    • This checks if the user's input is a valid guess.
@nycomp
nycomp / Battleships.md
Last active April 17, 2025 04:10
Instructions for a game of Battleships

J1 Group Project - Battleships

Instructions

Create one repl per group by forking this repl.

Add your group members to this repl by clicking Invite in the upper right hand corner of the repl window. They should show up as collaborators on the repl.

Your task

@nycomp
nycomp / Maze.md
Created October 23, 2024 05:46
Instructions for a Maze game

2024 J1 Group Project - Maze

Instructions

Create one repl per group by forking this repl.

Add your group members to this repl by clicking Invite in the upper right hand corner of the repl window. They should show up as collaborators on the repl.

Your task

@nycomp
nycomp / HTML-CSS-Intro.md
Created October 23, 2024 05:48
Template files for creating a Github Page

Reference guide (Google Slides): 4e Creating a portfolio in Github Pages (HTML & CSS)

Your task

  1. Create a portfolio page in Github Pages
  2. Paste your Github profile link in Lesson Schedule, under the Profile tab.

Example portfolio pages

  • Dan Vine (based on Bootstrap Resume template)
@nycomp
nycomp / Create An Asymmetric Key Pair.py
Created October 23, 2024 06:07
Create your own public-private key pair using the cryptography module.
"""Creating an Asymmetric Key Pair
<IN SYLLABUS>
Anybody can create a public-private key pair!
A key pair comprises two parts. Typically, one part is kept secret (the private
key) while the other part is published publicly to enable anybody to access it
(the public key).
Either key can be used to encrypt; the encrypted message can only be decrypted
using the other key.
This kind of encryption is known as *asymmetric encryption*, vs symmetric
@nycomp
nycomp / Get a Digital Certificate.py
Created October 23, 2024 06:11
Request a free digital certificate from LetsEncrypt.
"""Let's get our very own digital certificate!
We could create a self-signed certificate, which means there is no
cert authority (CA), but that wouldn't be trustworthy. It's only useful for
sending encrypted data between machines we own (since we trust our own cert).
Unfortunately, most cert authorities (CA) charge a fee for a certificate (and
the service of verifying it, and making your public key available).
There is one that doesn't: [LetsEncrypt](https://letsencrypt.org/). Let's
request a certificate from them.
LetsEncrypt uses the Automatic Certificate Management Environment (ACME)
protocol to automate the process, which is nice because it means we can write
@nycomp
nycomp / Create A Digital Signature.py
Created October 23, 2024 06:15
Digitally sign your messages using a digital certificate.
"""Creating a Digital Signature
<IN SYLLABUS>
A digital signature verifies the authenticity of a digital message.
## Creating a digital signature
1. The message is hashed (using a cryptographic hash function).
2. The message hash is encrypted with the sender’s private key to produce a digital signature.
## Sending a digitally signed message
@nycomp
nycomp / SocketEcho.md
Last active April 7, 2025 02:42
Write client code to connect to a server, send data to it, and receive data from it. The server code is provided.

Socket Programming

Socket programming allows developers to build these kinds of network applications by using programming languages like Python, C, or Java to create, connect, and manage sockets. A network socket is an endpoint for sending or receiving data across a computer network, and it forms the foundation of communication in the TCP/IP stack. When two devices want to communicate, each creates a socket—one to listen for incoming connections (server) and one to initiate the connection (client).

Each socket is defined by a combination of an IP address and a port number. Using sockets, programs can send and receive streams of data over the internet or a local network, whether it's for browsing the web, sending emails, or chatting in real time.

Instructions

  1. Write client code in client().
  2. Your client should:
@nycomp
nycomp / GuessMyNumber.md
Last active April 28, 2025 03:41
Write client code to connect to a server and play an interactive number-guessing game.

This exercise contains the following files:

  • GuessMyNumber.md: This file
  • protocol.md: A description of the communication protocol used for GuessMyNumber, a number-guessing game
  • guessing.py: Module with functions used to implement a number-guessing game. Used by server.py, not needed for client code
  • server.py: The server implementation.

Your task

In main.py, write the client code within the client() function to interact with the server successfully and enable the user to play GuessMyNumber.

@nycomp
nycomp / CSV-and-JSON.md
Last active October 28, 2024 01:33
Learn how to use CSV and JSON for serialisation and deserialisation

Modules for importing and exporting data

The process of converting an object to text data is known as serialisation.
The process of converting text data to an object is known as deserialisation.

In Python, we can manually serialise or deserialise data using IOStream objects.
The simplest way to get an IOStream object is to use the built-in open() function.

>>> f = open('test.txt', 'w')

>>> type(f)