Skip to content

Instantly share code, notes, and snippets.

var _hasOwn = Object.prototype.hasOwnProperty;
var _toString = Object.prototype.toString;
var _hasGOPD = typeof Object.getOwnPropertyDescriptor === 'function';
var _hasDP = typeof Object.defineProperty === 'function';
function _getOwnPropertyDescriptor(obj, prop) {
if ( _hasGOPD ) {
return Object.getOwnPropertyDescriptor(obj, prop)
}
else {
The licenses in the npm-registry from their package.json, from the latest version of each module
23.11.2013
[ { key: 'undefined', value: 27785 },
{ key: 'MIT', value: 20811 },
{ key: 'BSD', value: 5240 },
{ key: 'BSD-2-Clause', value: 621 },
{ key: 'Apache 2.0', value: 263 },
{ key: 'GPL', value: 233 },

Array.prototype.concat и UInt32

У массива в javascript есть замечательный метод .concat. Как и следует из названия, он объединяет два (или более) массива в один. Если в качестве аргумента передан массив, в результрующий массив попадут его значения; если не массив, то сам аргумент. Если кратко, то вот этот кусок кода:

[1, 2, 3].concat(4, [5, 6], [7]); // [1,2,3,4,5,6,7]

А что будет, если длина получившегося массива будет равна или превышать 232? Чтобы ответить на этот вопрос обратимся к спецификации. А написано там следующее:

dscacheutil -flushcache

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

/*globals DOMImplementation, ActiveXObject */
if (!DOMImplementation.prototype.createDocument) {
(function () {
'use strict';
var i, docObj, docObjType,
docObjs = [
'MSXML6.DOMDocument', 'MSXML5.DOMDocument', 'MSXML4.DOMDocument',
'MSXML3.DOMDocument', 'MSXML2.DOMDocument.5.0', 'MSXML2.DOMDocument.4.0',
/**
* performance-timing.js: Polyfill for performance.timing object
* For greatest accuracy, this needs to be run as soon as possible in the page, preferably inline.
* The values returned are necessarily not absolutely accurate, but are close enough for general purposes.
* @author ShirtlessKirk. Copyright (c) 2014.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
(function (window) {
'use strict';
require "try-catch"
try {
function()
error('oops')
end,
catch {
function(error)
print('caught error: ' .. error)
@monolithed
monolithed / es2015-callable.js
Last active August 29, 2015 14:26 — forked from DmitrySoshnikov/es2015-callable.js
es2015-callable.js
/**
* Callable objects in ES2015.
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT Style License
*/
class Callable extends Function {
constructor() {
super('(' + Callable.prototype.__call__ + ')();');
return this.bind(this);
@monolithed
monolithed / gist:7a0ffc4e94ffc62dee84
Last active September 11, 2015 11:31 — forked from yano3/gist:1378948
git commit --amend --reset-author
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author