Skip to content

Instantly share code, notes, and snippets.

View thiskevinwang's full-sized avatar

Kevin Wang thiskevinwang

View GitHub Profile
@thiskevinwang
thiskevinwang / Tic-Tac-Toe-4.jsx
Created February 6, 2019 22:16
Solution to Task #4
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
function Square(props) {
return (
<button className="square" onClick={props.onClick}>
{props.value}
</button>
);
// condensed preview
class Game extends React.Component {
constructor(props) {
super(props);
this.state = {
history: [
{
squares: Array(9).fill(null)
}
@thiskevinwang
thiskevinwang / Tic-Tac-Toe-5a.jsx
Created February 6, 2019 23:15
Square Component
function Square(props) {
return (
<button
className={"square " + (props.isWinning ? "square--winning" : null)}
onClick={props.onClick}
>
{props.value}
</button>
);
}
@thiskevinwang
thiskevinwang / Tic-Tac-Toe-5b.jsx
Created February 6, 2019 23:22
Board Component
class Board extends React.Component {
renderSquare(i) {
return (
<Square
isWinning={this.props.winningSquares.includes(i)}
key={"square " + i}
value={this.props.squares[i]}
onClick={() => this.props.onClick(i)}
/>
);
@thiskevinwang
thiskevinwang / Tic-Tac-Toe-5.jsx
Last active February 7, 2019 01:24
Solution to Task #5
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
function Square(props) {
return (
<button
className={"square " + (props.isWinning ? "square--winning" : null)}
onClick={props.onClick}
>
// inside Game component's render() call
let status;
if (winner) {
status = "Winner: " + winner.player + " @ " + winner.line;
} else if (!current.squares.includes(null)) {
status = "draw";
} else {
status = "Next player: " + (this.state.xIsNext ? "X" : "O");
}
@thiskevinwang
thiskevinwang / Tic-Tac-Toe-6.jsx
Last active June 8, 2024 03:19
Solution to Task #6 (ALL TASKS)
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
function Square(props) {
return (
<button
className={"square " + (props.isWinning ? "square--winning" : null)}
onClick={props.onClick}
>
@thiskevinwang
thiskevinwang / .rust_snippets.md
Last active July 3, 2020 23:29
Rust Snippets!

created: [2020-05-31]

TODO

  • Version control gists?
  • Modify gists from CLI or IDE

Leetcode

@thiskevinwang
thiskevinwang / exchanging_messages.rs
Created October 22, 2020 03:03
lowlvl.org / tcp-ip-fundamentals / exchanging-messages
// ----------------------------------------------------------
// https://lowlvl.org/tcp-ip-fundamentals/exchanging-messages
// ----------------------------------------------------------
// Write your code here.
let socket = UdpSocket::bind("10.0.0.1:1000").expect("couldn't bind to address");
// SEND TO NAME SERVER
socket
.send_to(b"Alice", "1.2.3.4:53")
{"requestedUrl":"https://thekevinwang.com/","finalUrl":"https://thekevinwang.com/","lighthouseVersion":"9.0.0","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/95.0.4638.69 Safari/537.36","fetchTime":"2021-11-20T19:53:59.857Z","environment":{"networkUserAgent":"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4695.0 Mobile Safari/537.36 Chrome-Lighthouse","hostUserAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/95.0.4638.69 Safari/537.36","benchmarkIndex":1147.5},"runWarnings":[],"configSettings":{"emulatedFormFactor":"mobile","formFactor":"mobile","locale":"en-US","onlyCategories":["performance","accessibility","best-practices","seo"],"channel":"lr"},"audits":{"dom-size":{"id":"dom-size","title":"Avoids an excessive DOM size","description":"A large DOM will increase memory usage, cause longer [style calculations](https://developers.google.com/web/fundamentals/performa