npm has a feature where you can ask it to install packages from the cache, where cache-min forces npm to avoid installing packages younger than that value:
npm --cache-min 9999999 install <package-name>
This works, but I’m never going to remember that syntax, so I added an alias to my .bashrc file:
alias npmoffline="npm --cache-min 9999999 "
So now when I’m offline on a plane and want to install a package that I’ve already installed in the past (and so I know is in the cache), I can write this:
npmoffline install <package-I-already-installed>
and it will pull the contents from my cache.
If it doesn’t work you can also list the contents of the cache with
npm cache ls
and see what packages and versions have been cached. Perhaps you can also grep it, to discard the packages you’re not interested in, e.g. the following will only list entries related to node-firefox:
npm cache ls | grep node-firefox
For the project I’m working on I’m building web components that sometimes require other components to build their UI. For example, the theremin-ui uses the slider. So they will try to load and register the component before creating instances of it. It worked fine when there was only one level of dependencies, but then I put all of the components on the same document, to let the user choose an instrument from the collection of Web Audio instruments, and I got an error from the browser complaining about… something:
NotSupportedError: Operation is not supported
I traced it down to the register() call, and I figured that I was registering an element twice. So I made safeRegisterElement, a one-function module I’m using now instead of directly calling document.registerElement:
var safeRegisterElement = require('safe-register-element');
// safeRegisterElement(type, prototype);
All my custom element modules have a register method that uses safeRegisterElement internally (this lets you register the element with whatever name you want to use).
In npm: https://www.npmjs.com/package/safe-register-element
And sources: https://github.com/sole/safe-register-element
I just realised that the Web Components polyfills not only are in npm so you can install them like this:
npm install --save webcomponents-lite
but they also have a well formed package.json with a main entry.
So if you’re writing your front-end code with Browserify and want to load the polyfill without adding an additional script tag, you can do this:
and this pulls the polyfill into the scope.
NICE! Thanks, Addy
PS I guess this should also work with webpack, if you’re so inclined.
I’m doing some research and playing with this new-ish API which is available in Firefox OS on rooted phones with Certified apps etc etc. Guillaume wrote a post on the Hacks blog–read it if you’re interested in what can be accomplished.
The very first thing you need to do is to enable Wi-Fi direct on the device. This involves running some commands as root, via adb. Justin made a gist which worked with Flame phones, but it didn’t work with a Nexus 4, because of the way the /system partition is mounted on those phones.
A (more?) fail-proof way should be this:
adb shell "mount -o rw,remount /system"
adb shell "stop b2g"
adb shell "echo \"ro.moz.wifi.p2p_supported=1\" >> /system/build.prop"
adb shell "mount -o ro,remount /system"
this will add a line to the /system/build.prop file and reboot the device.
Once it’s rebooted, the result of navigator.mozWifiP2pManager.enabled should be true, which is GOOD NEWS!
Remember that you need to run that code in
- a certified app
- request the wifi-manage permission in the manifest
So essentially your manifest.webapp MUST contain the following fields in addition to the rest of fields you usually have:
"wifi-manage": "for wi-fi direct"
I have a little pet project that I’m using to learn Hapi.js.
Today I wanted to add authentication and since this is, as I said, a tiny little mini project, I want to only allow specific users (actually, just me) to log in, and not everyone+dog using bell or something of that sort. So I thought I’d go for hapi-auth-basic.
So here it is, roughly based off this post of using Bcrypt with mongoose.