https://www.gravatar.com/avatar/f819a092b23cb25a09f87436f68df217?s=240&d=mp

Ang Gao

Software Engineer @ TripAdvisor, CS Ph.D @ University College Cork

JavaScript Note Five

Chapter Six: The Secret Life of Objects Methods are simply properties that hold function values There is a method similar to apply, called call. It also calls the function it is a method of but takes its arguments normally, rather than as an array. Like apply and bind, call can be passed a specific this value. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 var fn = function(arg1, arg2) { var str = "<p>aap " + this.

JavaScript Note Four

Chapter Five: Higher-order functions Functions that operate on other functions, either by taking them as arguments or by returning them, are called higher-order functions. Higher-order functions allow us to abstract over actions, not just values. 1 2 3 4 5 function transparentWrapping(f) { return function() { return f.apply(null, arguments); }; } The function it returns passes all of the given arguments, and only those arguments, to f.

JavaScript Note Three

Chapter Four: Data Structures- Objects and Arrays Properties that contain functions are generally called methods of the value they belong to. Some methods that array objects have 1 2 3 4 5 6 7 8 9 10 11 var mack = []; mack.push("Mack"); mack.push("the", "Knife"); console.log(mack); // → ["Mack", "the", "Knife"] console.log(mack.join(" ")); // → Mack the Knife console.log(mack.pop()); // → Knife console.log(mack); // → ["Mack", "the"] Adding and removing things at the start of an array are called unshift and shift.

Install Sqoop on Ubuntu 14.04 and Hadoop 2.6.0

Followings steps are for: Ubuntu 14.04 LTS, Hadoop-2.6.0 For Hadoop 2.6.0 Installation on Ubuntu 14.04 Scoop Installation 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 wget http://apache.proserve.nl/sqoop/1.4.6/sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz tar -xzvf sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz mv sqoop-1.4.6.bin__hadoop-2.0.4-alpha sqoop-1.4.6 sudo vim /etc/profile SQOOP_HOME=/home/anggao/sqoop-1.4.6 export SQOOP_HOME export PATH=$PATH:$SQOOP_HOME/bin source /etc/profile # obtain JDBC driver cd $SQOOP_HOME/lib wget https://jdbc.postgresql.org/download/postgresql-9.4-1201.jdbc4.jar sqoop version Scoop examples 1 2 3 4 5 6 7 8 9 # transfer data from PostgreSQL to HDFS sqoop import --connect jdbc:postgresql://localhost:5432/dev-db --table tableName --username userName --password randomPassword hadoop fs -cat department/part-m-00000 # transfer data from PostgreSQL to Hive sqoop import --connect jdbc:postgresql://localhost:5432/dev-db --username userName --password randomPassword --table tableName --hive-import -m 1 # transfer data from Hive to PostgreSQL sqoop export --connect jdbc:postgresql://localhost:5432/dev-db --username userName --password randomPassword --table postgreTableName --export-dir /user/hive/warehouse/hiveTableName --input-fields-terminated-by '\0x001'

Install Hive on Ubuntu 14.04 and Hadoop 2.6.0

Followings steps are for: Ubuntu 14.04 LTS, Hadoop-2.6.0 For Hadoop 2.6.0 Installation on Ubuntu 14.04 Download and unpack Hive 1 2 wget http://mirror.tcpdiag.net/apache/hive/stable/apache-hive-1.2.0-bin.tar.gz tar -xzvf apache-hive-1.2.0-bin.tar.gz Configure environment variables 1 2 3 4 5 6 7 sudo vim /etc/profile HIVE_HOME=/home/anggao/hive-1.2.0 export HIVE_HOME export PATH=$PATH:$HIVE_HOME/bin source /etc/profile Create folders in Hadoop file system 1 2 3 4 hadoop fs -mkdir /tmp hadoop fs -mkdir /user/hive/warehouse hadoop fs -chmod g+w /tmp hadoop fs -chmod g+w /user/hive/warehouse Hive CLI 1 2 3 4 5 # Notice there is an issue with Hive 1.

Install PostgreSQL on OSX using brew

Install PostgreSQL using brew If you don’t have homebrew, install it first. Then simply run the command: 1 brew install postgres Initialize PostgreSQL 1 initdb ~/pg-data Start PostgreSQL service 1 postgres -D ~/pg-data Create a user 1 2 # If you wish to create a user without a password just take the --pwprompt off the command.