Skip to content

Instantly share code, notes, and snippets.

View chengluyu's full-sized avatar

Luyu Cheng chengluyu

View GitHub Profile
@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 / 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 / calculator.c
Created May 7, 2017 16:56
LL(1) Calculator Written in C
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define BUFFER_SIZE 256
int value();
int integer();
int factor();
# coding: utf-8
from requests import request
from bs4 import BeautifulSoup as bs
from pyquery import PyQuery as pq
from time import sleep
import json
import re
import MySQLdb
@chengluyu
chengluyu / guidance.md
Created September 21, 2014 09:43
Guidance to You

A Brief OI Practical Guidance


自由定义数组下标

比如我们要定义一个下标从 -1000 到 1000 (闭区间)的 int 类型数组,我们可以这样写:

int *a = new int[2001] + 1000;
@chengluyu
chengluyu / zoj_3816.cpp
Created September 10, 2014 09:52
ZOJ 3816 by Chen Rui
#include "cstdio"
#include "iostream"
#include "algorithm"
#include "cmath"
#include "cstring"
#include "ctime"
#include "cstdlib"
#include "vector"
#include "queue"
#include "set"
@chengluyu
chengluyu / cf_406d.cpp
Created September 10, 2014 07:59
CodeForces 406D
#include <cstdio>
#include <cstdlib>
#include <vector>
const int N = 100000, TREE_HEIGHT = 17;
struct point {
long long x, y;
int multi(const point &a, const point &b) {
// printf("Multiply a(%d, %d) with b(%d, %d)",
@chengluyu
chengluyu / prime_number_generator.cpp
Created September 9, 2014 13:04
Prime Numbers Generator in Liner Time
#include <iostream>
#include <vector>
const int MAX = 2000000;
bool is_prime[MAX + 1] = { 0 };
std::vector<int> primes;
int main() {
is_prime[2] = true;
@chengluyu
chengluyu / problem_to_solve.md
Last active August 29, 2015 14:05
Problem to solve.
@chengluyu
chengluyu / main.md
Last active August 29, 2015 14:05
Problems to solve.