Skip to content

Instantly share code, notes, and snippets.

View lymanlai's full-sized avatar
👀

Lyman Lai lymanlai

👀
  • On The Moon Now ;) Way to the Mars!!
View GitHub Profile
@lymanlai
lymanlai / jQuery plugin pattern+1
Created November 14, 2012 13:56
jQuery plugin pattern+1
<!doctype html>
<html lang="en">
<head>
<title>JavaScript Patterns</title>
<meta charset="utf-8">
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
/*!
data:text/html,
<style type="text/css">
#e {
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
font-size:16px;
}
<snippet>
<content><![CDATA[
// ${1} Resource
Route::get('${1}s', array('as' => '${1}s', 'uses' => '${1}s@index'));
Route::get('${1}s/(:any)', array('as' => '${1}', 'uses' => '${1}s@show'));
Route::get('${1}s/new', array('as' => 'new_${1}', 'uses' => '${1}s@new'));
Route::get('${1}s/(:any)edit', array('as' => 'edit_${1}', 'uses' => '${1}s@edit'));
Route::post('${1}s', '${1}s@create');
Route::put('${1}s/(:any)', '${1}s@update');
Route::delete('${1}s/(:any)', '${1}s@destroy');
# https://github.com/SachaG/Telescope
########################
# it should be
sudo apt-get install git npm
curl https://install.meteor.com | /bin/sh
sudo npm install -g meteorite
# Prompt (Debian)
source /usr/local/bin/git-completion.sh
# Prompt (OS X + homebrew)
source /usr/local/etc/bash_completion.d/git-completion.bash
PS1="\[\033[31;38m\]\w\[\033[1;31m\]\$(__git_ps1)\[\033[00m\] "
export GIT_PS1_SHOWDIRTYSTATE=1
@lymanlai
lymanlai / async
Created September 28, 2013 18:55
async
async.waterfall([
getDbHandle,
function(args, cb){
connection = args.connection;
args = {
connection: connection,
email: req.body.email
};
cb(null, args);

Using Yeoman and Jade

Getting started

  • Make sure you have yo installed: npm install -g yo
  • Run: yo webapp
  • Install grunt-contrib-jade: npm install grunt-contrib-jade --save-dev

Customization

@lymanlai
lymanlai / Waterfall
Created December 16, 2013 09:30
Waterfall
function Waterfall(tasks, cb) {
async.waterfall(tasks, function(err, result){
var statusHash = {
not_validate: 403,
user_not_login: 401,
permission_deny: 401
};
if (!result) {
@lymanlai
lymanlai / mysqldump-cron.sh
Last active February 10, 2020 13:17
this script will mysqldump your db daily, weekly and monthly. and it will only keep three of them, while doing the fourth backup, it will delete the first one first.
#!/bin/bash
#author Lyman Lai
#date 2013-12-30
#source http://002.yaha.me/item/22728a58-c967-46d5-93eb-2649d684a9aa/
MYSQL_USER="yourname"
MYSQL_HOST="localhost"
MYSQL_PASSWORD="yourpassword"
MYSQL_BIN="$(which mysql)"
<div ng-controller="MyController" >
<span ng-bind-html-unsafe="myData.textf()"></span>
</div>
<div ng-switch on="myData.switch">
<div ng-switch-when="1">Shown when switch is 1</div>
<div ng-switch-when="2">Shown when switch is 2</div>
<div ng-switch-default>Shown when switch is anything else than 1 and 2</div>
</div>