Skip to content

Instantly share code, notes, and snippets.

View yunpengn's full-sized avatar
:octocat:
Coding

Yunpeng Niu yunpengn

:octocat:
Coding
View GitHub Profile
@yunpengn
yunpengn / q131.py
Last active September 20, 2021 15:39
Some Python exercises
import datetime
# Defines the increment.
delta = datetime.timedelta(days=1)
# Reads the number of test cases and all inputs.
n = int(input())
ranges = [input() for _ in range(n)]
# Iterates over every test case
@yunpengn
yunpengn / README.md
Last active September 24, 2021 14:24
CVE-2020-16303 use-after-free vulnerability in Artifex Software GhostScript v9.50

Setup Instructions

  • Download GhostScript GhostPDL v9.50 from their GitHub release.
    • Need to download both the official build and the source code.
    • Official build (without fix): wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs950/ghostscript-9.50-linux-x86_64.tgz.
    • Official build (with fix): wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs951/ghostscript-9.51-linux-x86_64.tgz.
  • Compile from source code in the following steps:
    • Get the source code git clone git@github.com:ArtifexSoftware/ghostpdl.git.
    • Change to the correct version git checkout b5bc53eb7.
  • Make sure you have installed gcc, make and autoconf.

Keybase proof

I hereby claim:

  • I am yunpengn on github.
  • I am yunpengn (https://keybase.io/yunpengn) on keybase.
  • I have a public key ASBJiMvGJsXgV08486FElJZ3uwEx6XVtoa8j9umVMggk2Qo

To claim this, I am signing this object:

@yunpengn
yunpengn / papertrail.md
Last active March 15, 2020 05:13
Instructions for setting up Papertrail client on Linux

Follow the steps below:

  • Download the latest remote_syslog2 client.
  • Unzip the file by tar -xvzf remote_syslog_linux_amd64.tar.gz.
  • Modify the configuration inside example_config.yml. It should be ideally something similar as:
files:
  - path: app.log
 tag: app_name
@yunpengn
yunpengn / imdb_setup_ftp.sh
Last active February 6, 2020 10:33
A simple script to setup IMDb movie database
printf "Program starts at %s.\n" "$(date)"
printf "Going to clean and create new folder ...\n"
rm -rf imdb-datasets-ftp/ imdb-queries/
mkdir imdb-datasets-ftp/
printf "Going to download datasets from FTP server ...\n"
wget http://homepages.cwi.nl/~boncz/job/imdb.tgz
tar -xvzf imdb.tgz -C imdb-datasets-ftp/
rm -f imdb.tgz
@yunpengn
yunpengn / dss.ri
Last active February 18, 2024 21:35
How to generate dataset using TPC-H
-- Sccsid: @(#)dss.ri 2.1.8.1
-- TPC-H Benchmark Version 8.0
-- For table REGION
ALTER TABLE REGION
ADD PRIMARY KEY (R_REGIONKEY);
-- For table NATION
ALTER TABLE NATION
ADD PRIMARY KEY (N_NATIONKEY);
@yunpengn
yunpengn / README.md
Last active February 29, 2024 17:26
A step-by-step guide to install PostgreSQL on Ubuntu without sudo privilege

Install PostgreSQL on Ubuntu without sudo

Being the most advanced open-source relational database, many of us need to install PostgreSQL for some purposes. However, sometimes you may not have sudo privilege on an Ubuntu server. Then, how should you install PostgreSQL in this case?

Compile from source!

Next, we will show a step-by-step guide on how to install PostgreSQL on Ubuntu by compiling it from source.

PostgreSQL Compilation & Installation

@yunpengn
yunpengn / run_calcite.sh
Last active January 12, 2020 14:06
A simple Bash script to run Calcite & SQLidate
# Validates input.
if [[ "$1" == "" ]]; then
printf "Please specify the number of nodes.\n"
exit
fi
# Pulls the latest changes.
printf "Going to pull the latest changes ...\n"
cd /temp/yunpengn/calcite
git pull
@yunpengn
yunpengn / download.js
Created June 9, 2019 07:18
A useful script to download online course videos
// Imports the required libraries.
const https = require('https');
const fs = require('fs');
// Defines some constants.
const COURSE_HOMEPAGE = '<CHANGE_IT_HERE>';
// Parses the given JSON file regarding URLs.
const url_json = require('./restricted_files.json');
const url_list = url_json.data.getRestrictedFiles.urls;
@yunpengn
yunpengn / main.js
Last active September 27, 2018 16:08
To teach JavaScript without the dot operator (this is supported by Common.js & Node.js)!
require("./utils.js");
// `add` is inserted into global frame. Do not need `utils.add` anymore!
add(1, 2);