Skip to content

Instantly share code, notes, and snippets.

View kcy1019's full-sized avatar
💤

Changyoung Koh kcy1019

💤
View GitHub Profile
@kcy1019
kcy1019 / build-protobuf-cpp-extension.sh
Last active January 19, 2024 09:42
Build protobuf cpp extension for Python (x86_64 / amd64, aarch64 / arm64)
ARCH_CANON=$(uname -m | sed 's/arm64/aarch64/g' | sed 's/amd64/x86_64/g') && \
ARCH_ALT=$(uname -m | sed 's/aarch64/arm64/g' | sed 's/x86_64/amd64/g') && \
ARCH_PROTO=$(echo "${ARCH_CANON}" | sed 's/aarch64/aarch_64/g') && \
apt update && \
apt install -y build-essential git vim curl unzip --no-install-recommends && \
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v25.2/protoc-25.2-linux-${ARCH_PROTO}.zip && \
unzip protoc-25.2-linux-${ARCH_PROTO}.zip && \
git clone https://github.com/protocolbuffers/protobuf --single-branch --branch=v25.2 && \
curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-${ARCH_ALT} > bazel && \
chmod u+x bazel && \
@kcy1019
kcy1019 / slackmojis_to_slack.sh
Last active June 24, 2021 23:18
Slack Emoji Uploader for slackmojis.com
#!/bin/bash
[[ $# -lt 1 ]] && { echo "Usage: $0 <emoji-keyword>"; exit -1; }
command -v jq >/dev/null 2>&1 || { echo "Install jq first (mac: brew install jq)."; exit -1; }
[[ ! -f "db.json" ]] && { curl -L "https://slackmojis.com/emojis.json" > db.json; }
emojis="$(jq -c 'map(select(.name | contains("'$1'"))) | map({"name": .name, "url": .image_url | split("?") | .[0]})' < db.json)"
echo ${emojis}
[[ ! -d "downloads-$1" ]] && {
mkdir -p "downloads-$1"
@kcy1019
kcy1019 / install-cuda-cudnn.sh
Last active April 19, 2021 01:07
CUDA + CUDNN for Ubuntu LTS
#!/bin/bash
. /etc/lsb-release
OS_VERSION="$(echo "${DISTRIB_RELEASE}" | tr -d '.')"
CUDA_VERSION="10.1"
CUDA_VERSION_MINOR="10.1.105-418.87.00"
CUDNN_VERSION="v7.6.3"
@kcy1019
kcy1019 / coffee.jpg
Last active March 15, 2022 06:24
Coffee
coffee.jpg
@kcy1019
kcy1019 / Ghistory.vim
Created August 20, 2018 01:52
Git history of the selection (vim, no dependency)
command -range Ghistory :!git log -L <line1>,<line2>:%
@kcy1019
kcy1019 / find_modified.sh
Created June 1, 2017 02:52
Compare two directories(specifically; two different versions) and print modified files
#!/bin/bash
if [ $# -lt 2 ];
then
echo "Usage: ./$0 MODIFIED-OGL-DIRECTORY ORIGINAL-OGL-DIRECTORY [option]";
echo " option: {BOTH(default), LEFT, FULL}";
echo " BOTH: show files existing in both directories only"
echo " LEFT: show files existing in modified directory only"
echo " FULL: BOTH | LEFT (show full diff)"
exit;
@kcy1019
kcy1019 / pintos_env.sh
Last active May 30, 2018 12:44
Setup Pintos Environment (for ubuntu 14.04) Raw
#!/bin/bash
# **Untested** Guide for Ubuntu 14.04
# by lucent(http://lucent.me ; gkcy1019@gmail.com)
sudo apt-get -y install build-essential configure-debian xorg-dev libncurses-dev
sudo apt-get -y install xorg x11-common
# Patched version of bochs ; CAUTION: this is NOT a permanent link(since it's my private server).
wget --no-check-certificate http://lucent.me/cs330/bochs-2.2.6.tar.gz
@kcy1019
kcy1019 / K.cc
Last active December 27, 2017 06:27
2016 ACM-ICPC Asia Daejeon Regional Problem K. Rounding
#include<queue>
#include<cstdio>
#include<cassert>
#include<cstring>
#include<algorithm>
using namespace std;
#define ALL(X) X.begin(),X.end()
template<int MAXN = 50000, int INF = 1 << 30>
struct MaxFlow {
@kcy1019
kcy1019 / CVE-2013-6955.py
Created August 4, 2015 06:48
Synology DiskStation Remote Code Execution Exploit (CVE-2013-6955)
#!/usr/bin/env python
#-*-coding: utf-8-*-
"""
CVE-2013-6955 Vulnerability Exploit
Usage:
python CVE-2013-6955.py [HOST] [COMMAND] | nc [HOST] [PORT]
e.g.
python CVE-2013-6955.py 1.2.3.4 'echo `date +"%Y-%m-%d %H:%M:%S"`' | nc 1.2.3.4 5000
"""
import sys
@kcy1019
kcy1019 / mp3 renamer
Last active October 18, 2020 14:56
node mp3 renamer
const fs = require('fs')
const mt = require('jsmediatags');
const filter = function(l, f) {
const r = [];
for (let i = 0 ; i < l.length; i++)
if (f(l[i])) r.push(l[i]);
return r;
};