Skip to content

Instantly share code, notes, and snippets.

@shanelau
shanelau / upyun.js
Created January 20, 2016 03:26
count files count for upyun 。文件目录数据统计
/**
* Created by liuxing on 16/1/20.
*/
var UPYUN = require('upyun');
var upyun = new UPYUN('', '', '');
var initDir = '/u/1';
function getCount(){
@shanelau
shanelau / compress.js
Created January 16, 2016 05:32
image compress for javascript 这是一个基于canvas,应用在移动端的前端图片压缩的JS
/*!
* compress.js
* @version 1.0
* @author 刘兴
*
* 这是一个基于canvas,应用在移动端的前端图片压缩的JS,其修正了上传时图片倒转等问题。
* Date: 2014-07-02
*/
(function (window) {
@shanelau
shanelau / block.js
Created December 28, 2015 01:26
contentFor block helper for hbs
var express = require('express'),
exphbs = require('express3-handlebars'),
app = express(),
hbs;
hbs = exphbs.create({
helpers: {
block: function (name) {
var blocks = this._blocks,
@shanelau
shanelau / index
Created March 11, 2015 08:43
filter emoji 表情图标过滤
var src = 'ABC 🍇';
src = src.replace(/([\uE000-\uF8FF]|\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDDFF])/g, '');
console.log(src);
@shanelau
shanelau / update-nodejs
Created March 4, 2015 03:01
update nodejs
node有一个模块叫n(这名字可够短的。。。),是专门用来管理node.js的版本的。
首先安装n模块:
```
npm install -g n
```
第二步:
升级node.js到最新稳定版?
```
n stable
@shanelau
shanelau / 0_reuse_code.js
Last active August 29, 2015 14:14
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
@shanelau
shanelau / generate_slug
Last active August 29, 2015 14:11
不重复 url 生成
/**
* Copyright (c) 2014 Meizu bigertech, All rights reserved.
* http://www.bigertech.com/
* @author liuxing
* @date 15/3/19
* @description
*
*/
var unidecode = require('unidecode');
@shanelau
shanelau / nginx.conf
Last active August 29, 2015 14:10
nginx 配置
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@shanelau
shanelau / weixin_share.javascript
Created December 4, 2014 06:18
微信分享到朋友圈,或者发送给朋友
var imgUrl =
'http://www.bigertech.com/content/images/2014/Dec/wallhaven-34414-1.jpg';
var lineLink = 'http://www.bigertech.com';
var descContent = "这是笔戈科技的博客"; // 小于 100个字
var shareTitle = '分享标题'; // 小于 30个字
var appid = '';
function shareFriend() {
WeixinJSBridge.invoke('sendAppMessage', {
"appid": appid,
@shanelau
shanelau / index.javascript
Created December 4, 2014 02:43
ember model fixture data
import DS from 'ember-data';
var Article = DS.Model.extend({
title: DS.attr(),
body: DS.attr(),
comments: DS.hasMany('comment',{async:true})
});
Article.reopenClass({
FIXTURES: [