Skip to content

Instantly share code, notes, and snippets.

View fchikwekwe's full-sized avatar
🏝️

Faith Chikwekwe fchikwekwe

🏝️
View GitHub Profile
@fchikwekwe
fchikwekwe / NumberWizardRandom
Created February 1, 2018 05:16
Learn to Code by Making Games -- Random version of Number Wizard Game
using UnityEngine;
using System.Collections;
public class NumberWizardRandom : MonoBehaviour {
// Use this for initialization
int max;
int min;
int guess;
@fchikwekwe
fchikwekwe / canvas-selfie.js
Last active April 29, 2019 18:46
This is a small snippet showing one way to capture the canvas context and use it to save an image. It is an example for my blog post on base64 image encoding.
var video = document.querySelector('video'),
image = document.querySelector('#selfie-image'),
// Get the exact size of the video element.
width = video.videoWidth,
height = video.videoHeight,
// Context object for working with the canvas.
context = hidden_canvas.getContext('2d');
@fchikwekwe
fchikwekwe / base64-image.js
Created April 29, 2019 18:50
An example of how to save a canvas image as a base64 URL for modularity.
// Get an image dataURL from the canvas.
var imageDataURL = hidden_canvas.toDataURL('image/png');
// Set the dataURL as source of an image element, showing the captured photo.
image.setAttribute('src', imageDataURL);
# this dictionary only has one entry
example_dictionary = {"key": "value"}
# this dictionary has multiple entries
another_dictionary = {
"first_key": "cool_value",
"second_key": "awesome_value",
"lots_of_keys": "cool_value"
}
list1 = [1, 2, 3]
list2 = [2, 3, 4] # different
# luckily the keys are unique here
dictionary = {
# list1 = [1, 2, 3]
list1: "a_value",
# list 2 = [2, 3, 4]
list2: "another_value"
}
list2.insert(0, 1) # inserting number 1 at index 0
list2.pop() # removing the last value
list1 = [1, 2, 3]
list2 = [1, 2, 3]
# oh no! which value will we get?
dictionary = {
# list1 = [1, 2, 3]
list1: "a_value",
# list 2 = [1, 2, 3]
list2.insert(0, 1) # inserting number 1 at index 0
list2.pop() # removing the last value
list1 = [1, 2, 3]
list2 = [1, 2, 3]
# oh no! which value will we get?
dictionary = {
# list1 = [1, 2, 3]
list1: "a_value",
# list 2 = [1, 2, 3]
all_students_stuff = {
"bob": ["backpack", "sneakers", "hat"],
"elena": ["gloves", "hair brush", "cleats"],
"piper": ["backpack", "sneakers", "hat"]
}
all_students_stuff = {
"bob": {
"clothing": ["sneakers", "hat"],
"storage": ["backpack"],
"food": ["apple sauce", "sandwich"]
},
"marie": {
"clothing": ["gloves", "cleats"],
"hair stuff": ["hair brush"]
},
for name in name_list: # we go over every name in the list
name = name.title() # we change every name
counter += 1 # each time, we add 1 more to the counter