Skip to content

Instantly share code, notes, and snippets.

@lygaret
lygaret / index.js
Last active January 18, 2023 17:26
ES6 Quasi-Literal for JSX
define(function(require) {
var React = require('react');
var paramRegex = /__(\d)+/;
var parser = new DOMParser();
var errorDoc = parser.parseFromString('INVALID', 'text/xml');
var errorNs = errorDoc.getElementsByTagName("parsererror")[0].namespaceURI;
// turns the array of string parts into a DOM
// throws if the result is an invalid XML document.
@branneman
branneman / better-nodejs-require-paths.md
Last active April 8, 2024 00:22
Better local require() paths for Node.js

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:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@hgfischer
hgfischer / benchmark+go+nginx.md
Last active April 11, 2024 22:09
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@robertkowalski
robertkowalski / npm-registry-licenses.txt
Created November 23, 2013 22:31
The licenses in the npm-registry from their package.json, from the latest version of each module 23.11.2013
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 },
/**
* Watcher leaks for jQuery
* RubaXa <trash@rubaxa.org>
* MIT Licensed.
*
* API:
* $.leaks.get();
* $.leaks.watch();
* $.leaks.unwatch();
* $.leaks.remove();
@brettz9
brettz9 / DOMImplementation.prototype.createDocument.js
Created December 13, 2012 05:52
IE8 Shim for DOMImplementation.prototype.createDocument (does not support doctype argument nor wrap the resulting document to support all DOM methods and properties; mostly for loading XML)
/*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',
@monolithed
monolithed / range.js
Last active October 7, 2015 12:08
Range function
/*
* Range
* @author: Alexander Guinness
* @version: 1.0
* @license: MIT
* @date: 7/20/12 9:28 PM
*/
function range (from, to, step) {
var array = [];
@Calvein
Calvein / Custom.css
Created March 23, 2012 20:24
Solarized Dark Skin for the Chrome DevTools
body#-webkit-web-inspector #main{background-color:#002b36!important}body#-webkit-web-inspector #main .panel.network,body#-webkit-web-inspector #main .panel.timeline,body#-webkit-web-inspector #main .panel.profiles,body#-webkit-web-inspector #main .panel.audits,body#-webkit-web-inspector #main .panel.extension{background-color:#fff!important}body#-webkit-web-inspector #console-messages a:hover,body#-webkit-web-inspector #console-messages .console-formatted-function,body#-webkit-web-inspector #console-messages .console-formatted-object{color:#93a1a1!important}body#-webkit-web-inspector #console-prompt,body#-webkit-web-inspector #console-messages a,body#-webkit-web-inspector #console-messages .console-message,body#-webkit-web-inspector #console-messages .console-group-messages .section .header .title{color:#839496!important}body#-webkit-web-inspector #console-messages .console-formatted-null,body#-webkit-web-inspector #console-messages .console-formatted-undefined{color:#657b83!important}body#-webkit-web-inspect
@emanuelez
emanuelez / git_speed.md
Last active March 17, 2024 19:03
Git Speed

How Fast is Git?

The web is full of benchmarks showing the supernatural speed of Git even with very big repositories, but unfortunately they use the wrong variable. Size is not important, but the number of files in the repository really is!

Why is that? Well, that's because Git works in a very different way compared to Synergy. You don't have to checkout a file in order to edit it; Git will do that for you automatically. But at what price?

The price is that for every Git operation that requires to know which files changed (git status, git commmit, etc etc) an lstat() call will be executed for every single file

Wow! So how does that perform on a fairly large repository? Let's find out! For this example I will use an example project, which has 19384 files in 1326 folders.

@micho
micho / nginx.conf
Last active September 29, 2023 16:38 — forked from unixcharles/nginx.conf
nginx config for http/https proxy to localhost:3000
First, install nginx for mac with "brew install nginx".
Then follow homebrew's instructions to know where the config file is.
1. To use https you will need a self-signed certificate: https://devcenter.heroku.com/articles/ssl-certificate-self
2. Copy it somewhere (use full path in the example below for server.* files)
3. sudo nginx -s reload
4. Access https://localhost/
Edit /usr/local/etc/nginx/nginx.conf: