Skip to content

Instantly share code, notes, and snippets.

@edwios
edwios / preprocess_texxt.sh
Created January 8, 2020 04:21
Script to preprocess text into dataset suitable for training with GPT2-Chinese and TF2-Chinese
#!/bin/bash
#
# Script to preprocess text into dataset suitable for training with GPT2-Chinese and TF2-Chinese
#
echo -n "Result file save to [train.txt]:"
read OUTF
if [ "${OUTF}" == "" ]; then
OUTF="train.txt"
fi
if [ -f "${OUTF}" ]; then
@edwios
edwios / TraceSerial.sh
Created January 7, 2020 07:03
Code that put a trace on the serial port and dump both in and out traffic
#!/bin/bash
#
# Following code will put a trace on the serial port and dump both in and out traffic
#
# Method 1, using socat
# Physical device connected to /dev/USB0 and program read/write to /tmp/ttyV0
#
# socat /dev/ttyUSB0,raw,echo=0 SYSTEM:'tee in.txt |socat - "PTY,link=/tmp/ttyV0,raw,echo=0,waitslave" |tee out.txt'
# Method 2, using strace
@edwios
edwios / newscr.md
Last active November 6, 2019 02:15
Test of Net.ReadNetFromONNX()

Markdown test

/*** script shows Dnn.ReadNetFromONNX() is not supported ***
 * Error shown was:
Assets/Scripts/newscr.cs(15,36): error CS0117: 'Net' does not contain a definition for 'ReadNetFromONNX'
***/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
public class changecolor : MonoBehaviour
{
public Color[] colors;
private Vector3 positionxyz;
public Color Rcolor;
void OnTriggerEnter(Collider other)
@edwios
edwios / openvpn_setup.sh
Created March 13, 2019 06:02
Script to setup OpenVPN server and keys
# Create nologin openvpn user
adduser --system --shell /usr/sbin/nologin --no-create-home openvpn
apt install openvpn easy-rsa
apt install iptables-persistent
# Enable IPv4 forwarding
# Optional disable a bunch of IPv6 related stuff
vi /etc/sysctl.d/99-sysctl.conf
sysctl -p
# Create Cert directory
make-cadir /etc/openvpn/certs
@edwios
edwios / VRMSizeFixer.cs
Last active March 12, 2019 02:23
VRM Size Fixer: to fix the size difference of those VRoid models in Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VRMSizeFixer : MonoBehaviour {
public float minSize;//調整後の最小サイズ
public float maxSize;//調整後の最大サイズ
public GameObject VRMModel;//対象のモデル
private Transform transSelf;
private Animator anime;
@edwios
edwios / motherless_dl.sh
Last active February 21, 2019 07:42
Extract video from Motherless
#!/bin/bash
REFR=$1
if [ -z "${REFR}" ]; then
echo -n "Motherless URL?"
read REFR
fi
FN=`basename ${REFR}`.mp4
if [ -e "${FN}" ]; then
FN=`basename ${REFR}`_$$.mp4
fi
# git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose.git
# cd openpose
# mkdir build
# cd build
# cmake -DOpenCV_INCLUDE_DIRS=/home/stli/deeplearning/opencv_3.4/opencv-3.4.0/build/install/include \
-DOpenCV_LIBS_DIR=/home/stli/deeplearning/opencv_3.4/opencv-3.4.0/build/install/lib \
-DCaffe_INCLUDE_DIRS=/opt/movidius/caffe/build/install/include \
-DCaffe_LIBS=/opt/movidius/caffe/build/install/lib/libcaffe.so -DBUILD_CAFFE=OFF ..
# make -j`nproc`
@edwios
edwios / Jigglebone.cs
Created November 27, 2018 05:40
Jiggle bone for Unity
//
// Jiggle Bone (Simple version)
// - by WarpZone
//
// TO USE:
// Simply attach this script to any Transform in your model's hierarchy.
//
// FEATURES:
// - It doesn't matter what the forward normal of your bone is, it just works.
// - Bounce and sway can be configured independently
@edwios
edwios / build-ovpn.sh
Last active March 13, 2019 06:05
Build OpenVPN .ovpn file
#!/bin/bash
#
# Tool to build ovpn file sutable for distribution to client machines.
#
# Install:
# Put inside /etc/openvpn/clients
#
# Usage:
# build-ovpn.sh name_of_ovpn_file
#