private variables are declared with the var keyword inside the object, and
can only be accessed by private functions and privileged methods.
private functions are declared inline inside the object’s constructor (or
alternatively may be defined via var functionName=function(){...}) and may
only be called by privileged methods (including the object’s constructor).
privileged methods are declared with this.methodName=function(){...} and
may invoked by code external to the object.
public properties are declared with this.variableName and may be
read/written from outside the object.
public methods are defined by Classname.prototype.methodName =
function(){...} and may be called from outside the object.
prototype properties are defined by Classname.prototype.propertyName = someValue
static properties are defined by Classname.propertyName = someValue
#3. Inheritance
a.Inheritance object
#4. Notes
Keyword this, within a function, this refers to object which call the
function.
This project is a project for hackday in Cogini company in 2014
1. Identify the page mode
2. Declare css selector, relative variables
3. Declare function to make a click action to DOM node
4. Make those function become interactive
5. Reference
I must say thank to Tran Xuan Truong, Quan Bao Thien To. When I write this bunch
of code I don’t know much about javascript. In addition, regarding Conkeror
technical issues, I gained help from Tran Xuan Truong who is a master in Conkeror
Web browser and he is one who has a big love in programming. Thank you, I will
remember the hackday.
Right now, It’s April 14, 2015. I note this memory to remember a day of doing new
things, learning new things and of course, because it’s a memorial hackday.
Even though, currently, the haivl.com has been collapsed,but this project still
work with haivainoi.com
Problem: Apache Web Server announces that Forbidden Error, given that developers configure Allow and Deny directory with no mistake
Reason: A lack of Indexes for files in directory.
Solution: Add option Indexes in directory tag <Directory>
Example: The following configuration causes forbidden error
Problems: Cannot load the fonts of bootstrap
Reason: In Rails, all assets are loaded from host:port/assets not
host:port/fontsSolution: Replace the source url in @font-face, from ../fonts/ to
/assets
There is no need to descript more about the project, the main role of this
project named music-api is to provide a web service for developers to exploit
indirectly the song’s information coming from any online source such as ZingMp3,
Nhaccuatui.
This project is an open source software, developers contribute and developer my
project. This time, this is only two online source ZingMp3 and Nhaccuatui,
however, the number source will be increased regarding developers’ demand.
The song information includes name, singers, lyrics, song's page and
inparticular song's source for downloading.
Why does it work ?
Fundamentally, this service send a request to music oridinary servers, after receiving responses, it analyze the response (inspect elements selectively). After finished analysis, it send json object which inlcluding all song’s information. Currently, the web service is deployed at USA by heroku, Because of IP filter applying by VNG(ZingMp3), there are some songs which you cannot search. I have tested by using VPN locating in the USA, the result is limited.
Good news is that Nhaccuatui is very generous, they allow foreign IP to access all song, meanwhile, you can exploit from more songs.
Request should be sent to http://silverlink.herokuapp.com/api, and server
will return a result in JSON object
there are three parameters to query:
– source: the source of music (zing mp3 = 1, nhaccuatui = 2) - this is compulsory
– keyword: the keyword - this is compulsory
– number: the expect number of song - this is optional. The maximum number of
song user can query from ZingMP3 is 60, and 111 for Nhaccuatui
Local variable: defined inside a method, the usage of local variable in only
inside a method. Prefix of local variable is _ or [a-z].
Instance variable: instance variable is available accross methods and object,
meanwhile, instance variable change from object to object. Prefix of instance
variable is @. Instance variable is not shared among its descedants.
Class variable: it belongs to a class and is a characteristic of this class.
Prefix is @@. Class variable is share among its descedants(childs).
Global variable: class varaible is not across class, however, global variable
does. The prefix of global variable is $.
Constant variable: it’s similar to class variable but it’s constant. Constant
varaibles should be in upper case for all letters.
#2. Commenting
Using =begin and =end
Using #
#3. Method
#4. Block
Block must be named after a name of a method (or a function), other while,
it does not work. Usage: In a method, there might be an chunk of code which is
used many time within the method, the point is that, this chunk of code is not
worth making a new function or maybe programmers don’t want to make a function
on that chunk (they cannot think a name for that).
It’s also possible to insert parameters into a block. However, if a function has parameters, I don’t know but there is a error and
cannot use block with function which have parameters.
#5. Class
Class structure
Initial method
Getters and setters
#6. Access control: Public, Private, Protected
Public method: is called by anyone. By default, all methods excepting
initialize method are public methods.
Private method: only class methods can access private methods
Protected method: is called by class method and its subclass method.
’<’ is used to indicate inheretent from class to class
Method overriding: change existing method (parent class) to new method
(child class)
Method overloading: Unlike java, ruby is using dynamic typed language, as a
results, it’s impossible to using overriding if depending on variable types. On
the other hand, it uses number of parameters to differentiate methods.
8. Loop
a. While loop
b. For loop
#9. Symbols
a. What is this
Symbols in ruby are immutable. Besides this point, it’s a string. It’s able to print put the value of a symbol in term of string or integer
b. Implementation
Automatic make new method based on the symbols
This is a remember note to learn python, more or less, it’s writen for me -the author to rememeber main issues of python.
1. Scope and Namespace
The output is:
Explaination:
Local variable always is always used inside local scope. In the example, local variable
spam has value is local spam, when do_local() invoked, spam only created inside a
function, it has no use outside.
Non local variable has been declared and it affect within scope_test and only within scope_test.
Global variable only used in global scope.
In Python, a function can exist inside a function, in the example above, do_local insides scope_test.
Functions make its own scope.
##2. Class
Notes:
Class variables shared by all instances, kind is class variable.
Instance variables shared by each instance,name is instance variable.
Function can be define outside class.
3. Inheritence
Call baseclass method, base class must be in global scope: