Skip to content

Instantly share code, notes, and snippets.

View jsstrn's full-sized avatar
🕺
Your best friend

Jesstern Rays jsstrn

🕺
Your best friend
  • Singapore
  • 00:13 (UTC +08:00)
View GitHub Profile
@jsstrn
jsstrn / FirstFactorial.cpp
Last active September 14, 2023 18:56
These are my solutions to the Coderbyte challenges written in C++
#include <iostream>
using namespace std;
int FirstFactorial(int num) {
// set the limit to the number provided
int limit = num;
for (int i = 1; i < limit; ++i) {
num = num * i;
}
return num;
@jsstrn
jsstrn / geometry.py
Created August 25, 2014 11:11
Drawing geometric shapes in Python using Turtle
import turtle
def drawSquare(my_turtle):
my_turtle.color("red")
for i in range(4):
my_turtle.forward(100)
my_turtle.right(90)
def drawSomethingCool(my_turtle):
my_turtle.color("yellow")
@jsstrn
jsstrn / binarySearch.js
Last active November 24, 2021 02:40
A simple binary search algorithm
/*
time: O(log n)
space: O(1)
*/
function binarySearch(value, array) {
let start = 0
let end = array.length
@jsstrn
jsstrn / findDuplicates.js
Last active November 23, 2021 09:30
A simple algorithm to find duplicates in two arrays
/*
time: O(m + n)
space: O(n) // whichever is smaller
arr1 = [ 1, 2, 3, 5, 6, 7 ]
^
arr2 = [ 3, 6, 7, 8, 20 ]
^
arr3 = [ 3, 6, 7 ]
@jsstrn
jsstrn / a.js
Created May 2, 2019 16:27
Write a function that checks if an array has duplicate values
function hasDuplicateValue(array) {
let counter = 0
for (let i = 0; i < array.length; i++) {
for (let j = 0; j < array.length; j++) {
counter++
if (i !== j && array[i] === array[j]) {
return true
}
}
}
@jsstrn
jsstrn / lab-how-the-web-works.md
Last active February 21, 2019 16:21
Lab: How the web works

🌐 Lab: How the web works

IP Address

We've learned that each device connected to a network is assigned an IP address. This includes your mobile phones and computers, and if you have a toaster that's hooked up to the Internet then your toaster, too.

What's the IP address of your computer?

Use ipconfig from your Terminal

class Payment {
constructor() {
this.paymentMethod = ''
}
setPaymentMethod(paymentMethod) {
this.paymentMethod = paymentMethod
}
pay(amount) {
@jsstrn
jsstrn / diceware.json
Last active September 6, 2017 13:44
Diceware Word List
{
"11111" : "a",
"11112" : "a&p",
"11113" : "a's",
"11114" : "aa",
"11115" : "aaa",
"11116" : "aaaa",
"11121" : "aaron",
"11122" : "ab",
"11123" : "aba",
open -a safari https://youtu.be/X2W3aG8uizA
osascript -e 'set volume output volume 100'
@jsstrn
jsstrn / object-calisthenics.md
Last active May 24, 2017 02:47
Object Calisthenics