Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
echo ">>> Starting Install Script"
# Update
sudo apt-get update
# Install MySQL without prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
@yang-wei
yang-wei / getUnix_ts.php
Created May 14, 2014 14:26
Get the FTW Unix TimeStamp of any format of time easily
<?php
// use DateTime object to turn any format of date & time into standard form
//Example1
$date = DateTime::createFromFormat('m/d/y @ h:ia', '04/04/2014 @ 3.13pm')->getTimestamp();
//Example2
$date = DateTime::createFromFormat('YmdHis', '20130312000000')->getTimestamp();
@yang-wei
yang-wei / worldcup2014db.json
Last active August 29, 2015 14:02
World Cup 2014 Data
[
{
"event": {
"key": "world.2014",
"title": "World Cup 2014"
},
"round": {
"pos": 1,
"title": "Matchday 1",
"start_at": "2014\/06\/12",
@yang-wei
yang-wei / vagrantLivereload
Created August 29, 2014 17:10
set grunt-este-watch livereload to work in host browser when using vagrant to host server
esteWatch:
options:
dirs: [
'<%= app_path %>/**/' # Set all directories here
]
livereload:
enabled: true
extensions: ['html', 'css', 'php', 'twig'] # File extensions to be watched
port: 8888 # set vagrant forwarded_port number, default is 35729
@yang-wei
yang-wei / jsbin.nadojahaheka.js
Last active August 29, 2015 14:06
Using lodash debounce in ng-repeat
(function(){
/* Todo: fix performance */
angular.module('app', [])
.controller('mainCtrl', function($scope){
$scope.countries = [
{ country: 'Japan', language: 'Japanese' },
{ country: 'Korea', language: 'Korean' },
{ country: 'North Korea', language: 'Korean'},
{ country: 'China', language: 'Chinese'},
{ country: 'Hong Kong', language: 'Cantonese'},
ORG 8000H ; 開始番地
LD SP, 0D000H ; D000番地の内容をSPに転送
LD HL, 0 ; HLに0を転送
LD B, 2 ; BOOO番地の内容を足す回数
LOOP: PUSH BC ; 残りの繰り返す回数をスタックに記憶
CALL KEISAN ; KEISANへ分岐
DEC B ; レジスタBの値から1を引いて、残りの回数
JP NZ, LOOP ; 残りの回数が0かどうか
JP KAKUNO ; 残りの回数が0なら、KAKUNOへ分岐
KEISAN: POP DE ; 残りの回数をスタック上に転送 
ORG 7000H ;プログラム開始番地
KURIKAE: LD C,30H ;SWO-7のI/Oアドレス指定
IN A, (C) ;SWO-7からデータの入力
OUT (11H), A ;入力データをLEDに出力
CP AA ;奇数スイッチがON
JP Z,OWARI ;Yes -> サブルーチンを終了
JP KURIKAE ;No -> データ入力を繰り返す
OWARI: NOP ;ブレークポイントの位置
END ;
ORG 7000H ; プログラムの開始番地
;メインプログラム
MAIN: LD BC,(8F14H) ; 音の長さを設定
CALL OTODASU ; OTODASUへ分岐する
CALL FUYASU ; FUYASUへ分岐する
JP MAIN ; 新しい長さおよび高さで鳴らす
;WAITサブルーチン
WAIT: CPD ; 待ち時間(音の高さ)を減らす
JP PE,WAIT ; 待ち時間(音の高さ)が0になるまでWAITを繰り返す
RET ; 0になると、サブルーチンから戻る
ORG 8000H ; プログラム開始番地
LD A, 0A000H ; 入力値をAレジスタに転送
ADD A,8000H ; Aレジスタの内容に80Hを加算
SRA A ; Aレジスタを算術右シフト演算
SLA A ; Aレジスタを算術左シフト演算
SCF ; キャリーの補数を1にする
ADC A,07H ; Aレジスタに07Hおよびキャリーフラグの値を加算
AND 00F0H ; Aレジスタを00F0Hとの AND論理積
SET 7,A ; Aレジスタのビット7を1にする
RES 1,A ; Aレジスタのビット1を0にする
@yang-wei
yang-wei / minimal
Created April 13, 2015 02:07
Minimal vim setting
execute pathogen#infect()
syntax on
filetype plugin indent on
set nocompatible " Be iMproved
set tabstop=2
set expandtab
set softtabstop=2
set shiftwidth=2
set smarttab