Monday, December 22, 2014

Limit download speed on Mac OSX

1. Use command line:

Create a pipe "1" limited to 500KBytes/s via
sudo ipfw pipe 1 config bw 500KByte/s
If you want to set higher traffic barriers, you can use MByte/s

Guide all network traffic of port 80 through pipe "1" using
sudo ipfw add 1 pipe 1 src-port 80

When you don't need the pipe anymore, remove it from the port using
sudo ipfw delete 1

2. Use GUI tool - Entonnoir

Entonnoir is a free tool which would help you to do the same that above manual method did for you. Once you download and install this free Mac app, things are completely simplified. - See more at: http://pcsplace.com/apple/how-to-limit-download-and-upload-speed-on-mac/#sthash.O7GAZo9q.dpuf

Reference:
http://apple.stackexchange.com/questions/44130/how-can-i-limit-my-download-bandwidth
http://pcsplace.com/apple/how-to-limit-download-and-upload-speed-on-mac/

3. Example:
sudo ipfw pipe 1 config bw 5KByte/s
sudo ipfw add 1 pipe 1 src-port 80
sudo ipfw add 2 pipe 1 src-port 433
sudo ipfw delete 1

Tuesday, December 2, 2014

requirejs throws TypeError

Meet this issue today when using requirejs optimizer r.js:

Tracing dependencies for: myapp
[Error: Error: Parse error using esprima for file: /Users/jimz/Workshop/test.js
TypeError: Cannot read property 'type' of null
    at /Users/jimz/Workshop/test/node_modules/grunt-contrib-requirejs/node_modules/requirejs/bin/r.js:23452:47
]

After jshint, found in define([xxxx]) module, there is a duplicate comma something like
define(['a', 'b', , 'c'], function(a1, b1, c1) {})