As easy as 1, 2, 3!
Updated:
- Aug, 08, 2022 update
config
docs for npm 8+ - Jul 27, 2021 add private scopes
- Jul 22, 2021 add dist tags
- Jun 20, 2021 update for
--access=public
- Sep 07, 2020 update docs for
npm version
#!/bin/sh | |
# | |
# Shell script that configures gnome-terminal to use solarized theme | |
# colors. Written for Ubuntu 11.10, untested on anything else. | |
# | |
# Solarized theme: http://ethanschoonover.com/solarized | |
# | |
# Adapted from these sources: | |
# https://gist.github.com/1280177 | |
# http://xorcode.com/guides/solarized-vim-eclipse-ubuntu/ |
#!/bin/bash | |
# Git post checkout hook. | |
# Reminds you of South migration changes when switching branches. | |
# Can be useful when you are when you are testing out a branch from | |
# someone else that requires migrations. | |
# Put the file in .git/hooks/post-checkout | |
PREVIOUS_HEAD=$1 | |
NEW_HEAD=$2 |
brew update | |
brew versions FORMULA | |
cd `brew --prefix` | |
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions" | |
brew install FORMULA | |
brew switch FORMULA VERSION | |
git checkout -- Library/Formula/FORMULA.rb # reset formula | |
## Example: Using Subversion 1.6.17 | |
# |
FileMerge (opendiff) can really come in handy when you need to visually compare merging conflicts. Other times it's just a nice visual way to review your days work.
The following method works by creating a simple bash script (git-diff-cmd.sh) that sets us up with the proper command line arguments for Git to pass off files to FileMerge.
public final class Integer | |
{ | |
public static int bitCount(int i) | |
{ | |
// HD, Figure 5-2 | |
i = i - ((i >>> 1) & 0x55555555); | |
i = (i & 0x33333333) + ((i >>> 2) & 0x33333333); | |
i = (i + (i >>> 4)) & 0x0f0f0f0f; | |
i = i + (i >>> 8); | |
i = i + (i >>> 16); |
var express = require('express'), | |
httpProxy = require('http-proxy'), | |
app = express(); | |
var proxy = new httpProxy.RoutingProxy(); | |
function apiProxy(host, port) { | |
return function(req, res, next) { | |
if(req.url.match(new RegExp('^\/api\/'))) { | |
proxy.proxyRequest(req, res, {host: host, port: port}); |
Creating npm packages which extend the functionality of Express apps has become a major thing we've been doing. There are several approaches we can take, from messing with the Express object prototypes, to creating a function in which an express app is passed in. After trying the former, I'm now a fan of the latter.
Extending the Express object prototypes has issues. The running Node.js process may have multiple versions of express
, and in order to extend the prototypes you need to require('express')
. This means that you might get a different express
module instance than the one the main app is created from.
Both approaches suffer from extending something more than once. Similar to how there may be multiple version of express
in the running Node.js process, there can also be multiple copies of the extension modules. If the app developer needs to rely on a different version of an Express ext
# A simple Makefile alternative to using Grunt for your static asset compilation | |
# | |
## Usage | |
# | |
# $ npm install | |
# | |
# And then you can run various commands: | |
# | |
# $ make # compile files that need compiling | |
# $ make clean all # remove target files and recompile from scratch |
String::NewSymbol
is recommended by v8 docs for wrapping string data that represent commonly used keys. The reason is for lookups to be faster (https://bugs.webkit.org/show_bug.cgi?id=104082#c0). But in testing this is actually usually a deoptimization because creating new symbols is slower than strings. This is confirmed by this Node.js core commit Remove v8::String::NewSymbol() entirely
: https://github.com/joyent/node/commit/f674b09f40d22915e15b6968aafc5d25ac8178a2. More details: https://bugs.webkit.org/show_bug.cgi?id=94574#c10
can be done in node.js like nodejs/node-v0.x-archive#4201 (comment)