Skip to content

Instantly share code, notes, and snippets.

View kylejlin's full-sized avatar

Kyle Lin kylejlin

  • Cupertino, California
View GitHub Profile
@kylejlin
kylejlin / three-clone-gltf.js
Created December 15, 2023 02:51 — forked from cdata/three-clone-gltf.js
A quick hack to clone a Three.js GLTF scene without re-loading or re-parsing the source.
// Originally from
// https://gist.github.com/cdata/f2d7a6ccdec071839bc1954c32595e87
const cloneGltf = (gltf) => {
const clone = {
animations: gltf.animations,
scene: gltf.scene.clone(true)
};
const skinnedMeshes = {};

4 Proposals to Improve Touch-football

1: Abolish touch-rule (QB sneaks)

Problem:

Currently, a teammate may touch the ball, and the quarterback may rush for yards. This rule is abused on too many plays, and makes the game much less fun.

Solution:

Until possession of the ball changes, neither the quarterback or defense can cross the line of scrimmage.

2: Exclude offside members on kickoffs

function invertColors(img) {
var canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
var data = ctx.getImageData(0, 0, img.width, img.height).data;
class Listy extends Array {
constructor() {
super(arguments);
}
customContains(item) {
return this.indexOf(item) > -1;
}
}
@kylejlin
kylejlin / tok-qs-p4.js
Last active December 12, 2016 01:31
Dev TODO: Everything.
(function(qsc) {
var StateCodes = {
EXEC: 0, // Main execution state
WORD: 1, // /[a-zA-Z\$_][a-zA-Z0-9\$_]*/
NUMBER: 2, // A sequence of digits, optionally preceded by 0x 0b or 0o
SPACE_TAB: 3, // Space or tab
PUNC_SEQ: 4, // A sequence of punctuation excluding (){}[]
LP: 5, // Left paren (
RP: 6, // Right paren )
LS: 7, // Left square bracket [
<!DOCTYPE html>
<html>
<head>
<script>
function fbLoad(){
// Initialize Firebase
var config = {
apiKey: "AIzaSyD-jLTzShaImxMkJfJQJKfE8UJZzq5KSZ0",
authDomain: "test-65a9a.firebaseapp.com",
databaseURL: "https://test-65a9a.firebaseio.com",
{ "person": [ { "id" : 1, "firstName" : "Lokesh" }, { "id" : 2, "firstName" : "bryant" } { "id" : 3, "firstName" : "kobe" } ] }
@kylejlin
kylejlin / pseudo-github.thTheme.xml
Last active October 3, 2016 05:54
A Sublime Text Theme made to resemble Github's syntax highlighting. To use, remove the ".xml", so it is "pseudo-github.thTheme". The theme is not perfect yet, and doesn't perfectly imitate Github.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
Name: Github
Author: Kyle Lin
License: MIT
-->
<plist version="1.0">
@kylejlin
kylejlin / lorem-ipsum.js
Last active July 16, 2016 21:17
Random text to demo Github's syntax highlighting.
/* The GitHub Theme for Ace does not look anything like GitHub. I can't find the colors used for the syntax highlighting
on any docs so I created this sampler and I will use the Chrome Element Inspector to find the colors.
*/
function noop() {
}
var MyObject = {
CONSTANT: 9,
/**
* Copyright (c) 2016 Kyle Lin
* This is a script to download an n by n image file of a rectangle.
*/
/**
* Downloads an image of a filled rectangle.
* @param {number} width The width of the rectangle.
* @param {number} height The height of the rectangle.
* @param {(string|CanvasGradient|CanvasPattern)} fillStyle The fill style of the rectangle.