Skip to content

Instantly share code, notes, and snippets.

@peteroid
peteroid / UDPNetworkManager.cs
Last active January 4, 2017 00:34
UDP Network Manager for connect to Arduino and receive the sensor data
using UnityEngine;
using System.Collections.Generic;
using System;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Linq;
@peteroid
peteroid / curl.sh
Created November 13, 2016 11:46
curl for the json show the data of the google link shortener
#!/bin/bash
curl 'https://goo.gl/api/analytics' --data 'security_token&url=http%3A%2F%2Fgoo.gl%2FBKGdcm' --compressed
@peteroid
peteroid / error-report.js
Created January 6, 2017 10:01 — forked from tianjianchn/error-report.js
Error report util with fabric/crashlytics in react-native
/*global __DEV__*/
import StackTrace from 'stacktrace-js';
const Fabric = require('react-native-fabric');
const { Crashlytics } = Fabric;
//call this to start capturing any no-handled errors
exports.init = function(captrueOnDebugMode){
if (__DEV__ && !captrueOnDebugMode) {
return;
# fix vi editor issue on mac
git config --global core.editor "vim"
@peteroid
peteroid / node-and-npm-in-30-seconds.sh
Last active January 23, 2017 16:27 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl -L https://www.npmjs.org/install.sh | sh
@peteroid
peteroid / login.curl.sh
Created January 26, 2017 20:23
CLI for HKU auth
#!/bin/bash
# config and clean up the script
FILE_PREFIX="login.res"
# rm ./$FILE_PREFIX*
# abort the script if any error occur
set -e
echo "Welcome to HKU Auth CLI v0.1"
@peteroid
peteroid / standard.sh
Last active March 21, 2017 10:58
Self standard for Shell
# based on POSIX
# POSIX in a nutshell: http://stackoverflow.com/questions/1780599/i-never-really-understood-what-is-posix
# $(cmd) > `cmd`
# ref: http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html#tag_23_02_06_03
# check root
if [[ $EUID -ne 0 ]]; then
echo "Please grant permission!"
fi
# install nvm for node and npm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
# reload nvm
export NVM_DIR="/home/ec2-user/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
# install node 7
nvm install 7
# as root
sudo -s
# get certbot
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
# since AMI supports is experimental, need to add --debug flag
./certbot-auto --debug
@peteroid
peteroid / centos-certbot-nginx-selinux.sh
Last active May 24, 2017 17:48
Setup Nginx with Certbot on Centos with some extras about SELinux
## as root!
sudo -s
# Cannot resolve host: mirrorlist blah blah
# need to add a standard nameserver, like Google DNS to /etc/resolv.conf
cat "nameserver 8.8.8.8" >> /etc/resolv.conf
# git is not installed
yum install git