Skip to content

Instantly share code, notes, and snippets.

View y3nr1ng's full-sized avatar

Liu, Yen-Ting y3nr1ng

View GitHub Profile
@y3nr1ng
y3nr1ng / README.md
Last active March 28, 2024 16:20
Remove text-based PDF watermark
  1. Install the pdftk for the PDF stream, and bbe to do binary replacement (sed for binaries).

    brew install pdftk-java bbe
  2. Decompress the PDF.

    pdftk infile.pdf output uncompressed.pdf uncompress
@y3nr1ng
y3nr1ng / NvmlWrapper.cs
Created November 24, 2023 07:03 — forked from bpmooch/NvmlWrapper.cs
Thin NVML Wrapper for C#
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace NvmlWrapper
{
/// <summary>
/// Nvml return codes
/// </summary>
public enum nvmlReturn_t
@y3nr1ng
y3nr1ng / config
Created March 20, 2022 22:44
Sample SSH config for Cloudflare Argo tunnel
Host *.trycloudflare.*
Hostname %h
# This setup is originally used to connect Google Colab machine.
User root
Port 22
IdentityFile ~/.ssh/colab/id_ecdsa
# NOTE https://github.com/PowerShell/Win32-OpenSSH/issues/1185
# this limits to WIN-only connection, files are shared across WSL2 and host.
@y3nr1ng
y3nr1ng / startx
Created October 23, 2021 22:43
This is the emulated startx script for VcXsrv on WSL2, it will spawn the VcXsrv client and connect to it.
#!/usr/bin/env bash
# get host address
HOST=$(ip address show dev eth0 | awk -F '[ /]+' '/inet / { print $3 }')
# start the server
powershell.exe -Command '& "C:\Program Files\VcXsrv\vcxsrv.exe" -multiwindow -nowgl'
# configure xhost
WSLENV="$WSLENV:DISPLAY"
@y3nr1ng
y3nr1ng / msvc2019.xml
Last active July 15, 2021 05:36
Modified MATLAB compiler configuration to support Build Tools for Visual Studio 2019. Both MSVC and MSVCPP are needed for every MATLAB internals to work.
<?xml version="1.0" encoding="UTF-8" ?>
<config
Name="Microsoft Visual C++ 2019 (C)"
ShortName="MSVC160"
Manufacturer="Microsoft"
Version="16.0"
Language="C"
Priority="A"
Location="$VCROOT\" >
<Details
@y3nr1ng
y3nr1ng / activate-dptrp1
Last active October 17, 2020 06:34
Script collection for Linux DPT-RP1 access
#! /usr/bin/env python
# This is used for automatically setup DPT-RP1 to usb-network, before python
# package dptrp1 starts.
import serial
with serial.Serial('/dev/ttyACM0', 115200) as tty:
# Activate CDC/ECM mode
tty.write(b"\x01\x00\x00\x01\x00\x00\x00\x01\x01\x04")
@y3nr1ng
y3nr1ng / commands.txt
Created March 10, 2019 03:29
Parallel Duplicate
# all operations work under SOURCE
cd SOURCE
# list files
rsync -avzm --stats --safe-links --ignore-existing --dry-run --human-readable \
SOURCE DESTINATION > FILE_LIST
# rsync files
cat FILE_LIST | parallel --will-cite -j NUM_THREADS \
rsync -avzm --relative --stats --safe-links --ignore-existing --human-readable {} \
@y3nr1ng
y3nr1ng / brain-dl.py
Last active February 24, 2019 16:35
Google Drive CLI parallel downloader
import io
import logging
from multiprocessing import Pool
import os
from functools import partial
import random
import re
import sched
import signal
import time
@y3nr1ng
y3nr1ng / concat.py
Created December 17, 2018 06:16
Concat spectrum from different sensors.
"""
Concat spectrum from different sensors.
"""
from io import StringIO
import logging
import click
import coloredlogs
import numpy as np
import pandas as pd
@y3nr1ng
y3nr1ng / kmean.cpp
Created February 4, 2018 15:38
Simple K-mean implementation.
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <cmath>
#define DATASET_FILENAME "iris.data"