new vs non-new object creation–net-21117 note: The Global Object When a function is called without an owner object, the value of this becomes the global object. In a web browser the global object is the browser window. This example returns the window object as the value of this: standalone Function (notice no new!)

The reason why logs […]

const object, changing attributes Const will only prevent re-assigning It will not prevent modification of the attributes of the object. For example, this will give you an error because you are trying to reassign the variable car to another object.

But if you were to change the attribute of the object, it is valid:

You’d see […]

Installing JSLint in sublime

ref – First, make sure you install the jslint npm package npm install -g jslint Install Package control In your sublime, View > Console. Then copy and paste this into the console and press enter:

Then after that, In Sublime, Tools > Command Palette type “Install” and type enter. You will […]

Logging Cron Job

ref – Getting started with Cron In Terminal: crontab -e. Press i to go into vim’s insert mode. Type your cron job, for example: 30 * * * * /Users/rickytsao/Desktop/run_email_to_admin >> /Users/rickytsao/Desktop/chron-log.txt Press Esc to exit vim’s insert mode. Type ZZ (must be capital letters). You should see the following message: crontab: installing […]


ref – curl http://localhost:6680/results -GET to send a HTTP request Download a Single File The following command will get the content of the URL and display it in the STDOUT (i.e on your terminal). $ curl ryh:Desktop rickytsao$ curl 301 Moved Permanently 301 Moved Permanently nginx/0.8.55 ryh:Desktop rickytsao$ Download file and store […]

self does not hold strong ref to dispatch_async

ref – Examples of non-cycles Using dispatch_async as the example is misleading as self does not hold a strong reference to it so, there is no threat of a retain cycle.

The block retains self, but self doesn’t retain the block. If one or the other is released, no cycle is created and […]

Badminton Events App notes

Sort database by date Sort the database by date db.badmintonEvents.find().sort({“date”:1}); Script to send admin result email curl http://localhost:6680/results -GET send_admin_email_script

to run: ./send_admin_email_script attaching files to gunemail

DB manipuluation mongo show dbs use BadmintonEventsDatabase

db.badmintonEvents.drop() To Drop an Event db.badmintonEvents.remove({“_id” : ObjectId(“5704d3df5b4e17c2a90b558c”)}); db.badmintonEvents.find() When moving over to production change ip and port […]

Mongod Address already in use for socket

Problem Last login: Fri Feb 12 10:54:07 on ttys002 ryh:~ rickytsao$ mongod 2016-02-13T11:07:24.914+0800 E NETWORK [initandlisten] listen(): bind() failed errno:48 Address already in use for socket: 2016-02-13T11:07:24.914+0800 E NETWORK [initandlisten] addr already in use 2016-02-13T11:07:24.941+0800 W – [initandlisten] Detected unclean shutdown – /data/db/mongod.lock is not empty. 2016-02-13T11:07:25.001+0800 I STORAGE [initandlisten] exception in initAndListen: 98 […]