Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / iwct-patches.md
Last active January 31, 2020 09:08
IWCT for iOS

IWCT (Unity-IBM) Patches

There are a number of fatal exceptions that will throw when IWCT is compiled under iOS. Followings are the changes required for IWCT to work on the iOS.

Patch InstantPreview.cs

Path: /Assets/GoogleVR/Scripts/InstantPreview/Internal/InstantPreview.cs


private static void RunCommand(string fileName, string arguments, out string output, out string errors)
@edwios
edwios / .gitignore
Created April 9, 2020 07:45
GitIgnore file for Cocoon
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
@edwios
edwios / ARObjectHitDetect.cs
Last active April 14, 2020 05:52
Example to how to place a game object in AR mobile
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
[RequireComponent(typeof(ARRaycastManager))]
public class ARObjectHitDetect : MonoBehaviour
{
sudo apt-get update
sudo apt-get install libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev -y
wget www.kernel.org/pub/linux/bluetooth/bluez-5.50.tar.xz
tar xvf bluez-5.50.tar.xz && cd bluez-5.50
./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-experimental
make -j4
sudo make install
sudo reboot
bluetoothctl -v
person
bicycle
car
motorcycle
airplane
bus
train
truck
boat
traffic light
@edwios
edwios / mbpbattmgr.sh
Created May 31, 2021 08:35
Script to optimise MBP battery life
#!/bin/bash
sleeptime=60
BatteryAlert(){
percentage=$(pmset -g batt | egrep "([0-9]+\%).*" -o | cut -f1 -d';' | sed 's/%//' | bc)
charging=`pmset -g batt | egrep "([0-9]+\%).*" -o | cut -f2 -d';' | tr -d ' \n'`
alertlevel=10
chargelevel=75
prefchargelevel=85
@edwios
edwios / Server.py
Last active June 25, 2021 09:56 — forked from kristoferjoseph/Server.py
A simper python http server can handle mime type properly
# -*- coding: utf-8 -*-
#test on python 3.4 ,python of lower version has different module organization.
import http.server
from http.server import HTTPServer, BaseHTTPRequestHandler
import socketserver
PORT = 8080
Handler = http.server.SimpleHTTPRequestHandler
@edwios
edwios / iOS Backup to Ext HD.md
Created April 4, 2022 09:35
iOS Backup to Ext HD

To summarise the above:

  1. Very important, go to System Preferences -> Security. Click on the Privacy tab and choose Full Disk Access. Click 🔒 at the lower left hand corner to unlock. Then √ the Terminal.app.
  2. In Finder, choose from the menu Go -> Go to folder, then paste the following line: ~/Library/Application Support/MobileSync
  3. You should then see a folder called Backup. Copy this folder to the external hard disk.
  4. Optional: Create a folder called Backup somewhere else on your external harddisk.
  5. Open Terminal app then type: sudo -s When asked, type your Mac login password.