Skip to content

Instantly share code, notes, and snippets.

View chengluyu's full-sized avatar

Luyu Cheng chengluyu

View GitHub Profile
@chengluyu
chengluyu / parody.typ
Created June 20, 2023 15:01
Include chapter numbers in numbering figures and tables.
#let figureCounters = state("thm",
(
"counters": ("heading": ()),
"latest": ()
)
)
#let figureInstances = state("instances", (:))
#let createFigureRenderer(identifier, base, base_level, render) = {
-- Lecture 4
-- Hylomophism
-- Definitions from previous lectures.
data Tree a = Empty | Fork (Tree a) a (Tree a)
-- We can construct a tree form a list.
@chengluyu
chengluyu / script.js
Created April 29, 2021 05:07
Chia Blockchain Force Connection
'use strict';
(function () {
const root = document.querySelectorAll('.MuiPaper-root > .MuiCardContent-root > .MuiBox-root')[2];
const urls = [
'node-eu.chia.net',
'node.chia.net',
'node-apne.chia.net',
'node-or.chia.net'
@chengluyu
chengluyu / rule.json
Created March 23, 2019 13:55
Swap Command and Control When Using Microsoft Remote Desktop
{
"description": "Happy Remote Desktop",
"manipulators": [
{
"from": {
"key_code": "left_command"
},
"to": [
{
"key_code": "left_control"
@chengluyu
chengluyu / database-project.sql
Created July 8, 2018 14:14
Database System Final Project SQL Schema
CREATE TABLE `movies` (
`id` INT NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
`original_title` VARCHAR(255) NOT NULL,
`rating` FLOAT NOT NULL,
`introduction` VARCHAR(255) NOT NULL,
`film_year` INT NOT NULL,
`film_region_id` INT NOT NULL,
`is_tv` BOOLEAN NOT NULL,
`film_company_id` INT NOT NULL,
@chengluyu
chengluyu / exp-2.cpp
Created July 7, 2018 15:31
Computer Graphics Experiment 2
#define STB_IMAGE_IMPLEMENTATION
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <stb_image.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <iostream>
@chengluyu
chengluyu / sutherland-hodgman.py
Created May 11, 2018 16:50
Sutherland Hodgman Algorithm
import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches
class Segment:
def __init__(self, p, q):
self.p = p
self.q = q
@chengluyu
chengluyu / main.js
Created March 23, 2018 11:08
webpack issue #6264 output
! function (e, n) {
for (var r in n) e[r] = n[r]
}(exports, function (e) {
var n = {};
function r(t) {
if (n[t]) return n[t].exports;
var o = n[t] = {
i: t,
l: !1,
@chengluyu
chengluyu / kd-tree.cpp
Created January 18, 2018 15:33
My Naïve Implement of K-d Tree
#include <cassert>
#include <chrono>
#include <iostream>
#include <iterator>
#include <type_traits>
#include <cmath>
#include <vector>
#include <random>
class Timer {
@chengluyu
chengluyu / zzq.py
Created January 11, 2018 14:33
Zhang Ziqi
import numpy as np
import math
def process_number(s):
s = s.replace(',', '')
if s[-1] == '\n':
s = s[:-1]
if s[-1] == '%':
return float(s[:-1]) * 0.01
return float(s)