Skip to content

Instantly share code, notes, and snippets.

View lauslim12's full-sized avatar
🌀
Available

Nicholas lauslim12

🌀
Available
View GitHub Profile
@lauslim12
lauslim12 / basic-oop.rb
Created October 7, 2018 02:01
Basic object oriented programming for practice.
class Account
attr_reader :name
attr_reader :balance
def initialize(name, balance=100)
@name = name
@balance = balance
end
public
def display_balance(pin_number)
@lauslim12
lauslim12 / snake.html
Created October 9, 2018 05:30
Simple snake game
<!-- Lets make a simple snake game -->
<canvas id="canvas" width="450" height="450"></canvas>
<!-- Jquery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
//Canvas stuff
var canvas = $("#canvas")[0];
@lauslim12
lauslim12 / gcd.rb
Last active October 10, 2018 05:23
Finding the greatest common divisor + Bézout's identity. I use Ruby's built in function.
def gcd(a, b)
return a if b == 0
return b if a == 0
a.gcd(b)
end
def bezout(a, b)
return 1, 0 if b == 0
q, r = a.divmod b
s, t = bezout(b, r)
@lauslim12
lauslim12 / balapkura.py
Created December 7, 2018 04:04
Simple game script for turtle races. Compiler used is from http://jumpto.cc/python-new.
#!/bin/python3
from turtle import*
from random import randint
speed(100)
penup()
goto(-140, 140)
for step in range(15):
@lauslim12
lauslim12 / christtree.rb
Last active December 18, 2018 10:54
Simple christmas tree with Ruby.
# n here is the 'row', or the whitespace.
# height is the height of the tree.
def tree(height)
height.times do |n|
print ' ' * (height - n)
puts "\033[32m*\033[0m" * (2 * n + 1)
end
4.times do
puts '#####'.center(41)
@lauslim12
lauslim12 / color.txt
Created December 18, 2018 10:54
3/4 bit coloring in terminals. I use this in Ruby.
puts "\033[1mForeground Colors...\033[0m\n"
puts " \033[30mBlack (30)\033[0m\n"
puts " \033[31mRed (31)\033[0m\n"
puts " \033[32mGreen (32)\033[0m\n"
puts " \033[33mYellow (33)\033[0m\n"
puts " \033[34mBlue (34)\033[0m\n"
puts " \033[35mMagenta (35)\033[0m\n"
puts " \033[36mCyan (36)\033[0m\n"
puts " \033[37mWhite (37)\033[0m\n"
puts ''
@lauslim12
lauslim12 / 25dec2018.py
Created December 25, 2018 02:32
Green christmas tree coded in Python. I made this less than 10 mins, so excuse any mistakes.
#!/bin/python3
import turtle
# initialization
tree = turtle.Turtle()
tree.color("green")
tree.begin_fill
tree.speed(30)
tree.penup()
@lauslim12
lauslim12 / newyear2019fireworks.py
Last active March 9, 2019 11:37
Simple fireworks with wishes for new year of 2019.
#!/bin/python3
# first setups
import turtle
name = "Nicholas"
# initialization
scrn = turtle.Screen()
scrn.bgcolor("#000")
scrn.title("New Year 2019!")
@lauslim12
lauslim12 / type_confusion.php
Created March 19, 2020 12:58
Practice for type confusion.
<?php
/*
* Exploit the type confusion by first sending a random number, then tamper with the get so
* the parameter will become like '?angka[]=yournumber' (add an array notation in the 'angka variable').
*/
?>
<!DOCTYPE HTML>
<html>
<head>
@lauslim12
lauslim12 / group.js
Created December 29, 2020 08:08
An algorithm to equally distribute students to the number of available teachers.
/**
* Group.js
* An algorithm to equally distribute students to the number of available teachers.
* Complexity is O(n).
*
* @input Arrays of teachers and students.
* @output Array of objects of grouped students and teachers.
*
* Run in Node (CommonJS)
* How to run: Clone or copy the gist, then do node ./group.js