Skip to content

Instantly share code, notes, and snippets.

@A
A / for.js
Last active December 26, 2015 19:48
Test foreach loops by 10KK interations
/**
* Test foreach loops by 10KK interations:
*
* Chrome 30.0.1599.101
* f1: 7775 ms
* f2: 22541 ms
* f3: 20917 ms
*
* Node v0.10.17
* f1: 8440 ms
@A
A / clinch.js
Created November 5, 2013 19:18
'use strict';
/**
* Module dependencies.
*/
var config = require('../lib/util').config;
var log = require('../lib/util').log(module);
var util = require('util');
var fs = require('fs');
var Clinch = require('clinch');
Available tasks
lvrld Alias for "livereload-start", "connect", "regarde" tasks.
main Alias for "clean:dst", "copy:main", "clean:ignore",
"concat:main", "ect", "less:browser" tasks.
browser Alias for "main", "lvrld" tasks.
phonegap Alias for "clean:dst", "copy:main", "clean:ignore",
"concat:main", "less:phonegap", "ect" tasks.
deploy Alias for "main", "rsync:deploy" tasks.
default Alias for "browser" task.
rsync Performs rsync tasks. *
@A
A / grunt.log
Created November 15, 2013 12:06
➜ jpr grunt build
Running "clean:dist" (clean) task
Cleaning public_html/.htaccess...OK
Cleaning public_html/css...OK
Cleaning public_html/favicon.ico...OK
Cleaning public_html/fonts...OK
Cleaning public_html/js...OK
Cleaning public_html/robots.txt...OK
Running "useminPrepare:html" (useminPrepare) task
@A
A / fuck-you.js
Created November 23, 2013 18:35
Happy debugging suckers
Array.prototype.__defineGetter__('0', function () {return false});
undefined = !undefined
@A
A / js-rus.md
Last active December 29, 2015 04:59
JavaScript Ссылки для изучения
@A
A / for.js
Created November 27, 2013 18:28
exports.get = function(req, res){
User.find(null, 'email -_id', function(err, users) {
if (err) return res.json(500, err);
var retobj = {};
var keys = Object.keys(users);
var i = keys.length;
while (i--) retobj[i] = users[keys[i]] && users[keys[i]].email;
@A
A / express-basicauth.js
Created November 29, 2013 07:59
Use `username:password` string for auth.
var express = require('express');
var credentials = "admin:password";
var basicAuthMw = express.basicAuth.apply(null, credentials.split(':'));
@A
A / express-routes-params.js
Created November 30, 2013 14:21
Routes also have the .param method to allow for easier resource loading in this case we will make sure all our routes load the post
// vendor
var express = require('express');
var router = new express.Router();
// routes also have the .param method to allow for easier resource loading
// in this case we will make sure all our routes load the post
router.param('post_id', function(req, res, next, post_id) {
// simulate loading a post
setTimeout(function() {
@A
A / js-method-wrapper.js
Last active December 29, 2015 19:59
JS Functions wrappers.
/**
* Abstract
*/
var obj = {
wrapped: function(a,b) {
console.log('this:', this);
console.log('a:', a);
console.log('b:', b);
}
}