All posts by admin

setting JAVA environment variable

Windows 8

1) First install Java onto your machine

2) You then have to set your environment variable JAVA_HOME to be the location where the bin directory of all the .dlls and .exes are.

Right click the windows icon on the very bottom left. Select System
env_var_1

Click on the Environmental variable button. And look for the JAVA_HOME variable. If its there, edit it. If its not, click on ‘New’, and create the JAVA_HOME variable.

The Variable value is where the location is. What we’re looking for is the location to the bin folder where all the .exe and .dll are. Hence, after you install Java, its usually somewhere in C://Program Files/Java/JRE_x.xx.xx/.

In our case, if you start from the C directory, find Program Files, then find Java. In my case, I found it at C:\Program Files (x86)\Java\jre1.8.0_73

Thus, you just paste that into the environment variable.

env_var_3

3) you then have to add the directory location of the PATH variable. When you see it, click edit, and then go to the end of the string. Then type in:

;C:\Program Files (x86)\Java\jre1.8.0_73

notice the semi-colon. this is to separate this entry from the other entries.

env_var_4

APN server notes

To insert device

db.deviceCollection.insert({ “device_id” : “f0bafec6 be2a9e1a c31c9cb0 8c6589df 0bc1a7c4 ac9d7767 e63b7656 07c62145”, “bundle_id” : “com.rtsao.localapn”, “description” : “yes” })

How to use events app

The registration

events_1

Go to the url that’s set for your app.

Give an email so that the app can send your registration information.

Your email should arrive in a few minutes.

events_2

The email contains everything about the event, including the time, date, location, and maps of how to get there.

All you need to do is click on the “click here” to finish your registration so that the app can confirm you.

Once you click on the link, you will be brought to a page where it will tell you that you have finished registration and there’s nothing else to do.

The reminder

There will be an email reminder sent to you a few hours before the event.

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 Cody Lindley is because the ‘this’ inside the function references the window global object. Hence when we attach the attribute name to this, it attaches name to the window object. the ‘this’ has nothing to do with the object Person.

new Object

Now, when we use new Object, we create an object on the heap, and this in our function refers to that object. IT IS NOT connected to the (global or window) object anymore

Hence, when we log cody.name, it works because cody is that object in the heap. The this in the function, refers to cody.

We assign name attribute to the object cody.

Also, take note that the this properties are public because there is no closure. If we create a closure (by creating inner functions), then the properties attached to this will then be private.

Another example:

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 honda, white

http://stackoverflow.com/questions/30314457/how-to-make-function-parameter-constant-in-javascript

Another example:

However, bear in mind that const in ES6 notation does not make the variable immutable.

is a completely valid program and a will become [1, 2, 3]. const will only prevent you from reassigning a, so that you can’t do a = [] or a = {} or whatever once const a = [1, 2]; already defined (in that particular scope).

Read Only Variable

ref – http://stackoverflow.com/questions/2821509/can-you-use-constant-variables-in-javascript

if you’re looking for a read-only variable, you simulate that with something like

and then use it like

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 t hen see a menu popup with all the packages.

Look for SublimeLinter-jslint

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 new crontab. You can verify the crontab file by using crontab -l.
Logging Cron jobs


30 * * * * /Users/rickytsao/Desktop/run_email_to_admin >> /Users/rickytsao/Desktop/chron-log.txt

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 in file

To store the output in a file, you an redirect it as shown below. This will also display some additional download statistics.

$ curl http://www.centos.org > centos-org.html