Skip to content

Instantly share code, notes, and snippets.

View mosluce's full-sized avatar

mosluce mosluce

View GitHub Profile
function parseQuery(json) {
var q = "";
var first = true;
for (var key in json) {
if(json[key]=="" || json[key]==null) continue;
if (first) {
first = false;
q += (key + "=" + json[key]);
} else {
@mosluce
mosluce / 0_reuse_code.js
Created November 25, 2013 06:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
function throttle( fn, time ) { var t = 0; return function() { var args = arguments, ctx = this; clearTimeout(t); t = setTimeout( function() { fn.apply( ctx, args ); }, time ); }; }
using UnityEngine;
using System.Collections;
public class UnityChanController : MonoBehaviour
{
public CharacterController ctrl;
Animator animator;
// Use this for initialization
using UnityEngine;
using System.Collections;
public class UnityChanController : MonoBehaviour
{
public float gravity = 9.8f;
public float jumpSpeed = 1.0f;
public CharacterController ctrl;
#!/bin/bash
if [ $# -eq 0 ] ; then
echo "input app name, plz"
exit 0
fi
#echo $1
home="/home/mosluce"
#!/usr/bin/env bash
export GIT_WORK_TREE=$HOME/apps/{app_name}
echo "--> Checking out..."
git checkout -f
docker-compose start {app_name}
@mosluce
mosluce / mongoose-setup-module.js
Last active November 8, 2016 15:57
mongoose best practice template for node.js
//npm install --save mongoose
//npm install --save mongoose-timestamp
//npm install --save bluebird
"use strict";
var Promise = require('bluebird');
var mongoose = require('mongoose'), timestamps = require('mongoose-timestamp');
var path = require('path'), fs = require('fs');
const url = process.env.MONGO_URL || 'mongodb://localhost/test';
//npm install --save bluebird
var Promise = require('bluebird');
Check.updataPartly = function(foodName, partly, numBig, numSamll, callback){
//打開資料庫
mongodb.open(function(err,db){
if (err) {
return callback(err);
}
var i = 0;
Check.updataPartly = function(foodName, partly, numBig, numSamll, callback){
//打開資料庫
mongodb.open(function(err,db){
if (err) {
return callback(err);
}
//讀取checks的集合
db.collection('checks',function(err,collection){