Skip to content

Instantly share code, notes, and snippets.

@1yx
1yx / express_error_json.js
Created April 18, 2016 03:48
JSON stringify an Error in Express
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
function err2JSON (err) {
var obj = JSON.parse(
JSON.stringify(err, Object.getOwnPropertyNames(err))
@1yx
1yx / InstallStaffOnLinux.md
Last active August 27, 2016 06:58
install staff on Linux

CentOS 6

the_silver_search

$ sudo yum install -y pcre-devel

$ sudo yum install xz-devel

$ cd /usr/local/src
@1yx
1yx / .eslintrc
Created January 18, 2016 05:57 — forked from ghostwords/.eslintrc
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"arrowFunctions": false, // enable arrow functions
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"classes": false, // enable classes
"defaultParams": false, // enable default function parameters
"destructuring": false, // enable destructuring
@1yx
1yx / readLocation.js
Last active September 26, 2023 01:32
read qq location list file in js, special thanks https://www.v2ex.com/t/32786
var parseString = require('xml2js').parseString;
var fs = require('fs');
var _ = require('underscore');
require.extensions['.xml'] = function (module, filename) {
module.exports = fs.readFileSync(filename, 'utf8');
};
var zh = require("./LocList-zh.xml");
var en = require("./LocList-en.xml");
@1yx
1yx / leancloud.extension.js
Created November 30, 2015 10:02
扩展leancloud js sdk 中的一些方法
var AV = require('avoscloud-sdk').AV;
AV.Query.prototype.findAll = function () {
var self = this,
data = [];
self._limit = 1000;
self._order = 'createdAt';
return loop(avpromise(0), function (skip) {
self._skip = skip;
@1yx
1yx / gist:9bd91b60006d5f0d9968
Last active April 4, 2018 04:48
squirrel color scheme with dracula-theme(github.com/zenorocha/dracula-theme).
We couldn’t find that file to show.