Skip to content

Instantly share code, notes, and snippets.

View chengluyu's full-sized avatar

Luyu Cheng chengluyu

View GitHub Profile
@chengluyu
chengluyu / photoshop-change-text-and-export.js
Last active August 22, 2023 10:11
Photoshop Batch Process - Change Text and Export
// This script works well with Photoshop CC 2017
// Adopted from stackoverflow.com/questions/14571008/photoshop-scripting-changing-text-of-a-text-layer
Array.prototype.forEach = function (fn) {
for (var i = 0; i < this.length; i++) {
fn(this[i], i);
}
};
var doc;
@chengluyu
chengluyu / ssd-dft.cpp
Last active November 5, 2020 21:38
Fast template match using DFT.
#include <cstdint>
#include <iostream>
#include <opencv2/opencv.hpp>
#define TEST_FILE(x) "../" x
template <typename Num>
inline Num sq(Num x) { return x * x; }
cv::Mat convolveDFT(const cv::Mat &image, const cv::Mat &stencil) {
@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)
@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 / 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 / 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 / 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 / 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 / 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 / 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'