Skip to content

Instantly share code, notes, and snippets.

Avatar
🍪
clicking

Ruyi Li RuyiLi

🍪
clicking
View GitHub Profile
@RuyiLi
RuyiLi / d1p1.jl
Last active Jan 21, 2020
AOC 2018 Solutions For Google Code-In
View d1p1.jl
# Author: weCryOpen (Ruyi Li)
function d1p1(file)
open(file) do f
total = 0
for line in eachline(f)
# Iterate through each line in the file
# Convert it to an integer,
n = parse(Int, line)
# and add it to the total.
@RuyiLi
RuyiLi / main.jl
Last active Jan 21, 2020
Calculating the value of Pi in Julia - Google Code-In
View main.jl
# Author: Ruyi Li (weCryOpen)
function mypi(n::Int)::Float
total_sum::Float = 0
for i = 1:n
total_sum += 1 / (i * i)
end
(total_sum * 6) ^ 0.5
end
@RuyiLi
RuyiLi / index.html
Created Dec 9, 2019
Soldier simulator application for my Math Extended Essay.
View index.html
<canvas></canvas>
<button onclick="josephus()"> Start </button>
<button onclick="eliminate()"> Kill </button>
<script>
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
const SIZE = 640;
canvas.width = canvas.height = SIZE;
View keybase.md

Keybase proof

I hereby claim:

  • I am ruyili on github.
  • I am wecryopen (https://keybase.io/wecryopen) on keybase.
  • I have a public key ASBErN8SGkckrb14D073PzIuuJUwbAoEmXSnAFQKiNEYFgo

To claim this, I am signing this object:

View goosegen.js
g=a=>`:goose-${a}:`;[g('top'),...Array(+prompt('Length of goose neck:')).fill(g('middle')),g('bottom')].join`\n`
@RuyiLi
RuyiLi / index.html
Created Sep 4, 2019
argebe - A fun and unique browser game smaller than 3kb (uncompressed, without comments)
View index.html
<canvas style="position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);"></canvas>
<script>
/*
w - The width of the canvas in pixels.
h - The height of the canvas in pixels.
s - The size of the character in pixels.
c - The canvas element.
t - The graphics context.
u - The available colors.
q - The player's current colors.
@RuyiLi
RuyiLi / assignments3.md
Last active Aug 7, 2019
Big Assignments
View assignments3.md

Make sure to use styles!

Choice 1 - Rock Paper Scissors Poker

Rules of the game:

Each player draws five cards (either rock, paper, or scissors) from an unlimited deck. Both players will pick one card, and if one player's cards beat the other (rock beats scissors, paper beats rock, scissors beats paper) then that player wins. If there is a tie (e.g. both play rock) then whoever has more of the chosen card in the hand wins. If they both have the same amount, it is counted as a tie.

As an extra challenge, modify the game so that there are 5 rounds, with a point being awarded each time a player wins. At the end of the five rounds, print the status of the game (either a win, tie, or a loss).

View assignments2.md

Assignment 1 - Age

Create an input with type="date". When a button is pressed, the program should write "You are $(age) years old" into a paragraph element. Replace $(age) with the number of years since the date entered.

Use the MDN Docs for the Date object to complete this assignment: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

You can get a date object from the input by doing new Date(input.value).

Assignment 2 - Move a Square

@RuyiLi
RuyiLi / assignments.md
Last active Aug 5, 2019
Lesson 6 Assignment
View assignments.md

For all assignments, make sure to clearly label your local and global variables. Use functions to make your code more easy-to understand.

Assigment 1 - Shopping Cart

Create an application with an input field and a submit field. When the submit button is pressed, the text in the input should be added to a "shopping cart" (an unordered list). This is similar to your wishlist application. Try not to just copy code from the wishlist project, as there's literally no point in cheating on this.

Assignment 2 - Color a Square

Create 5 buttons labelled "red", "blue", "green", "white", and "black". When pressed, the background of a div element

@RuyiLi
RuyiLi / .eslintrc.json
Last active Jul 1, 2019
my eslint and ts config
View .eslintrc.json
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"parser": "@typescript-eslint/parser",
"plugins": [