Skip to content

Instantly share code, notes, and snippets.

View tshi0912's full-sized avatar

Tao Shi tshi0912

View GitHub Profile
@tshi0912
tshi0912 / gist:9f7a8a35a29af861417c
Created February 16, 2016 06:53
node-gyp rebuild issue
> node-gyp rebuild
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 404 status code downloading tarball
gyp ERR! stack at Request.<anonymous> (/usr/local/lib/node_modules/cnpm/node_modules/pangyp/lib/install.js:251:14)
gyp ERR! stack at emitOne (events.js:82:20)
gyp ERR! stack at Request.emit (events.js:169:7)
gyp ERR! stack at Request.onRequestResponse (/usr/local/lib/node_modules/cnpm/node_modules/pangyp/node_modules/request/request.js:1255:10)
gyp ERR! stack at emitOne (events.js:77:13)
var getScript = function (url) {
var deferred = $.Deferred();
var el = document.createElement('script');
var head = document.head || jQuery("head")[0] || document.documentElement;
el.async = true;
el.onerror = function () {
deferred.reject();
};
// Attach handlers for all browsers
el.onload = el.onreadystatechange = function( _, isAbort ) {
@tshi0912
tshi0912 / pom.xml
Last active August 29, 2015 14:23 — forked from JamieMason/pom.xml
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>GROUP NAME HERE</groupId>
<artifactId>PROJECT-KEY</artifactId>
<version>1.0-SNAPSHOT</version>
<name>PROJECT NAME</name>
<properties>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.javascript.lcov.reportPath>target/lcov.info</sonar.javascript.lcov.reportPath>
@tshi0912
tshi0912 / pinghei.css
Last active August 29, 2015 14:06
Fonts for Apple Site
@font-face {
font-family:'PingHei';
font-style:normal;
font-weight:200;
src:url("/v/fonts/b/pinghei/pinghei_light.eot?") format("eot"), url("/v/fonts/b/pinghei/pinghei_light.woff") format("woff"), url("/v/fonts/b/pinghei/pinghei_light.ttf") format("truetype");
/* Copyright (c) 2000-2008, Changzhou SinoType Technology Co., Ltd. All rights reserved. */
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Plupload - Getting Started</title>
<script type="text/javascript" src="js/plupload.full.min.js"></script>
</head>
// api/controllers/AuthController.js
var passport = require('passport');
var AuthController = {
login: function (req,res)
{
res.view();
},
// for demo: http://jsbin.com/jeqesisa/7/edit
// for detailed comments, see my SO answer here http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional/21915381#21915381
/* a helper to execute an IF statement with any expression
USAGE:
-- Yes you NEED to properly escape the string literals, or just alternate single and double quotes
-- to access any global function or property you should use window.functionName() instead of just functionName()
-- this example assumes you passed this context to your handlebars template( {name: 'Sam', age: '20' } ), notice age is a string, just for so I can demo parseInt later
<p>
{{#xif " this.name == 'Sam' && this.age === '12' " }}
@tshi0912
tshi0912 / handlebar-fix.js
Created June 30, 2014 13:52
Handlebars get template via ajax
/** A helper function to handlebars
*
* @param name Template name
* @returns {*} The promise object with template function as the parameter of done callback
*/
Handlebars.getTemplate = function(name) {
if (Handlebars.templates === undefined){
Handlebars.templates = {};
}
if (Handlebars.templates[name] === undefined) {
@tshi0912
tshi0912 / queryStringToJSON.js
Last active December 22, 2015 00:08
QueryString to JSON object
function queryStringToJSON(){
var pairs = location.search.slice(1).split('&');
var result = {};
pairs.forEach(function(pair){
pair = pair.split('=');
result[pair[0]]=decodeURIComponent(pair[1] || '');
});
return JSON.parse(JSON.stringify(result));
}
@tshi0912
tshi0912 / JavaMailSender.java
Last active October 7, 2015 08:27
Use spring java mail facilitator to send mail
getMailSender().send(new MimeMessagePreparator(){
public void prepare(MimeMessage message) throws Exception {
MimeMessageHelper helper = new MimeMessageHelper(message, getMailEncoding());
helper.setFrom(from);
helper.setTo(to);
if(cc!=null && cc.length > 0){
helper.setCc(cc);
}
if(bcc!=null && bcc.length > 0){