Skip to content

Instantly share code, notes, and snippets.

View happyincent's full-sized avatar

Vincent Chen happyincent

View GitHub Profile
# Makefile
CC := gcc
CXX := g++
CFLAGS := -g -Wall -o3 -std=gnu99
CXXFLAGS := -g -Wall -o3 -std=c++11
LDFLAGS := -g
# LDLIBS := -pthread
TGT := xxx #(e.g. xxx.cpp in SRC)
EXT := .cpp
:: Author: DDL
:: Date: Aug. 20, 2018
@ECHO off
SETLOCAL enableDelayedExpansion
chcp 65001
SET "IP_Addr=140.116.0.0"
SET "Sub_Mask=255.255.255.224"
SET "D_Gate=140.116.0.0"
@happyincent
happyincent / docker-compose.yml
Created December 5, 2018 16:45
Enable the GPU within a docker container running on an NVIDIA Jetson TX2. ref: https://git.io/fp1ZW
version: '3'
services:
test:
container_name: test-tensorflow
image: ubuntu:test-tensorflow
build: .
restart: always
command: sh -c "ldconfig /usr/local/cuda/lib64/ /usr/lib/aarch64-linux-gnu/tegra/ && tail -f /dev/null"
volumes:
@happyincent
happyincent / autossh.service
Last active January 27, 2019 14:04
An autossh tunnel service
[Unit]
Description=An autossh tunnel service
After=network-online.target
[Service]
# -M 0 -> no monitoring
# -N -> Just open the connection and do nothing (not interactive)
# ServerAliveInterval, ServerAliveCountMax -> check per interval, reconnect if (fail > Max)
# ExitOnForwardFailure -> make sure forwardings have succeeded
@happyincent
happyincent / teamviewer.md
Last active February 1, 2024 20:22
Install TeamViewer without a connected monitor (Xubuntu 16.04 & 18.04)

Install

wget https://download.teamviewer.com/download/linux/teamviewer_amd64.deb
sudo apt update -y
sudo apt install gdebi -y
sudo gdebi teamviewer_amd64.deb

sudo teamviewer passwd PASSWORD_TO_BE_CHANGED
sudo teamviewer daemon enable
teamviewer info
@happyincent
happyincent / docker-bake.hcl
Last active October 9, 2019 15:59
A bake definition file example. https://github.com/docker/buildx
group "default" {
targets = ["autossh", "ffmpeg", "edge"]
}
target "autossh" {
context = "./autossh"
dockerfile = "Dockerfile"
platforms = [
"linux/amd64",
"linux/arm64",
"linux/arm/v7"
@happyincent
happyincent / test.yml
Created June 10, 2019 14:23
Mount Arduino Serial, Use Host network in Docker Swarm
version: '3'
networks:
docker_host:
external:
name: 'host'
services:
docker-parent:
image: docker:latest
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
Get-AppxPackage -AllUsers | where-object {
$_.name -notlike "*Store*" -And
$_.name -notlike "*Calculator*" -And
$_.name -notlike "*ScreenSketch*"
} | Remove-AppxPackage
Write-Host -NoNewLine 'Press any key to continue...';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
@happyincent
happyincent / encode.py
Last active September 24, 2020 08:28
encode.py (https://file.io)
#! python3
import base64, binascii, json, urllib.request
s1 = 'Hello, World!'
code = base64.b64encode(binascii.hexlify(s1[::-1].encode('utf-8'))).decode('utf-8')
s2 = bytes.fromhex(base64.b64decode(code).decode('utf-8')).decode('utf-8')[::-1]
assert s1 == s2
link = json.loads(urllib.request.urlopen("https://file.io", data='text={}'.format(code).encode('utf-8')).read())['link']
link = base64.b64encode(link.encode('utf-8')).decode('utf-8')
@happyincent
happyincent / plates.js
Last active June 22, 2021 04:11
車牌號碼吉凶判斷
// Ref1: https://www.mvdis.gov.tw/m3-emv-plate/webpickno/queryPickNo
// Ref2: http://tanzih.blogspot.com/2013/09/4-80-80-yw-6675-6675-80-83.html
// Step0: Fill the form and Reset storage in `Ref1`
localStorage.removeItem("plates")
// Step1: Keep running until ERROR (final page)
localStorage.setItem(
"plates",
JSON.stringify(