new vs non-new object creation

http://code.tutsplus.com/tutorials/fully-understanding-the-codethiscode-keyword–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 window.name logs […]

const object, changing attributes

http://stackoverflow.com/questions/30314457/how-to-make-function-parameter-constant-in-javascript 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 – https://github.com/devdoc/SublimeLinter-jslint https://www.npmjs.com/package/nodelint First, make sure you install the jslint npm package npm install -g jslint Install Package control https://packagecontrol.io/installation 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 – http://stackoverflow.com/questions/4811738/cron-job-log-how-to-log http://stackoverflow.com/questions/15395479/why-ive-got-no-crontab-entry-on-os-x-when-using-vim 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 […]

cURL

ref – http://makandracards.com/makandra/1145-how-to-send-http-requests-using-curl 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 http://www.centos.org ryh:Desktop rickytsao$ curl http://www.centos.org 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 – https://digitalleaves.com/blog/2015/05/demystifying-retain-cycles-in-arc/ 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: 0.0.0.0:27017 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 […]