Skip to content

Instantly share code, notes, and snippets.

View StoneMoe's full-sized avatar

Lake Chan StoneMoe

View GitHub Profile
@StoneMoe
StoneMoe / MoveCamera.cs
Created April 6, 2016 23:56 — forked from JISyed/MoveCamera.cs
Camera movement script in Unity3D. Supports rotating, panning, and zooming. Attach to the main camera. Tutorial explaining code: http://jibransyed.wordpress.com/2013/02/22/rotating-panning-and-zooming-a-camera-in-unity/
// Credit to damien_oconnell from http://forum.unity3d.com/threads/39513-Click-drag-camera-movement
// for using the mouse displacement for calculating the amount of camera movement and panning code.
using UnityEngine;
using System.Collections;
public class MoveCamera : MonoBehaviour
{
//
// VARIABLES
@StoneMoe
StoneMoe / gulpfile.js
Created April 7, 2016 20:46
Sample gulpfile from weui
var path = require('path');
var fs = require('fs');
var yargs = require('yargs').argv;
var gulp = require('gulp');
var less = require('gulp-less');
var header = require('gulp-header');
var tap = require('gulp-tap');
var nano = require('gulp-cssnano');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
# Use Plain Text Mode as Default in TextEdit
defaults write com.apple.TextEdit RichText -int 0
# TimeMachine backup per 30 min. (Broken)
# sudo defaults write /System/Library/Launch Daemons/com.apple.backupd-auto StartInterval -int 1800
# use this if SSD
sudo pmset -a sms 0
# Finder option
defaults write NSGlobalDomain AppleShowAllExtensions -bool true # Show All Extensions in Finder
# 1. Create Disk Image
# ref:
# FileSystem type: https://support.apple.com/en-us/HT202784
cd Desktop
hdiutil create -size 512g -fs "Journaled HFS+" -volname "TimeMachine" -type SPARSEBUNDLE -nospotlight -verbose volume_nas_timemachine.sparsebundle
# 2. Move the Disk Image File to Windows SMB Share Folder
# 3. Mount the Disk Image through Network
# 4. Enable Time Machine Not Support Network Volumes
defaults write com.apple.systempreferences TMShowUnsupportdNetworkVolumes 1
# 5. Add Volume to Time Machine

Repair TimeMachine Backup

  1. Mount timemachine volume from Finder.
  2. Unlock Target Machine's Backup sparsebundle.
    sudo chflags -R nouchg /Volumes/{TimeMachine Volume Name}/{Target Machine's Name}.sparsebundle
  3. Attach sparsebundle then Listing Backup Volume.
    hdiutil attach -nomount -noverify -noautofsck /Volumes/{TimeMachine Volume Name}/{Target Machine's Name}.sparsebundle
  4. Repair backup volume.
    fsck_hfs -drfy /dev/disk2s2
  5. Detach backup sparsebundle.
@StoneMoe
StoneMoe / bash_telegram_bot_sendmsg.sh
Last active May 15, 2016 09:11
Linux login telegram bot alert
echo "Welcome, "$(whoami)
login_notice_id="" # admin's telegram id
login_notice_username=$(whoami)
login_notice_token="" # telegram bot token
curl --silent --data "chat_id=${login_notice_id}&text=${login_notice_username}&parse_mode=HTML&disable_web_page_preview=true" -o /dev/null https://api.telegram.org/bot$(login_notice_token)/sendMessage
printf "\n"
@StoneMoe
StoneMoe / package.json
Last active May 17, 2016 12:17
My gulp workflow packages
{
"name": "general-gulp",
"version": "0.0.0",
"description": "StoneMoe's front-end workflow",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "StoneMoe",
"devDependencies": {
@StoneMoe
StoneMoe / gulpfile.js
Created May 17, 2016 12:18
My gulp workflow file
var gulp = require('gulp');
var browserSync = require('browser-sync');
var less = require('gulp-less');
var autoprefixer = require('gulp-autoprefixer');
var minifyCSS = require('gulp-minify-css');
var notify = require('gulp-notify');
var gutil = require('gulp-util');
var cp = require('child_process');
var path = require('path');
var uglify = require('gulp-uglify');
@StoneMoe
StoneMoe / mongodb.gist
Created August 3, 2016 14:56
Mongodb manage commands gist
# Mongodb get collection key names
mr = db.runCommand({
"mapreduce" : "input_collection_name_here",
"map" : function() {
for (var key in this) { emit(key, null); }
},
"reduce" : function(key, stuff) { return null; },
"out": "input_collection_name_here" + "_keys"
});
@StoneMoe
StoneMoe / git_autodeploy.sh
Last active June 4, 2017 20:50
Setup wizard for auto deploy your latest code via git
#!/usr/bin/env bash
# Tested on Debian 8.3
echo "============================================="
echo "Git auto deploy setup wizard"
echo "This script will create a auto-deploy project"
echo "============================================="
echo "Input a unique name for this project"
printf "This will also be directory name:"