Skip to main content

Posts

Showing posts from 2018

If and For in Wolfram Mathematica (with examples)

IF Condition in Wolfram Mathematica The syntax is as follows xxxxxxxxxx If [ condition , what to do if true , what to do if false ] Some examples Example 1. Simple command x x = - 3 ; If [ x < 0 , - x , x ] 3 Example 2. If condition in a function abs [ x_ ] := If [ x < 0 , - x , x ] abs /@ { - 3 , 2 , 0 , - 2 } { 3 , 2 , 0 , 2 }   For in Wolfram Mathematica The syntax is as follows For [ start , test , inc , what to do ] Some examples Example 1. Simple Loop xxxxxxxxxx For [ i = 0 , i < 4 , i ++, Print [ i ]] 0 1 2 3 Example 2. Another simple loop For [ i = 10 , i > 0 , i --, Print [ i ]] 10 9 8 7 6 5 4 3 2 1 Example 3. Print list a = { 10 , 3 , 9 , 2 } For [ i = 1 , i < 5 , i ++, Print [ a [[ i ]]]] 10 3 9 2  

How to Easily Generate Big File

I had difficulty in finding any large text file. In Google, some of them suggest to download from wikimedia dump and some of them from gutenberg project. However, the following steps are a lot easier than going to all the menus in either wikimedia or gutenberg. Enter any small text file In the first step, just enter any small text file. For example: $ echo 'arwan ahmad khoiruddin' > mytext.txt Merge the text into big file Next, you can merge the text into big file. Here's how $ cat mytext.txt mytext.txt mytext.txt > merged.txt The content of file merged.txt will be arwan ahmad khoiruddin arwan ahmad khoiruddin arwan ahmad khoiruddin So, if you want to create big file, you can just repeat the cat as many as possible. For example $ cat mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt mytext.txt

Introduction to Wolfram Mathematica

Free-form inputs To compute, press SHIFT + ENTER In[1]:= 3 + 9 SHIFT + ENTER Out[1]:= 12 To suppress output, add ; after the line In[1]:= 3 + 9; SHIFT + ENTER -> no output You can execute multiple lines at once In[1]:= a = 2 b = a + 2 c = b ^ 3 SHIFT + ENTER Out[1]:= 2 Out[2]:= 4 Out[3]:= 64 Starting from now, when we have output, it means that in the end of the previous line, we press SHIFT + ENTER . To get the most recent output, use % In[1]:= 3 + 9 Out[1]:= 12 In[1]:= % + 5 Out[1]:= 17 Basics in Programming Variable A variable starts with letters. If you want, you may add numbers into the variable name. It is much better if you start the variable name with lowercase In[1]:= myVariable123 = 2 Out[1]:= 2 Please notice how I join the two words and the number into a single word. If you put space between the variable name, it will indicate multiplication In[1]:= x = 3; 5 x x Out[1]:= 45 To clear the variab

Push docker container

In this post, I will give you an example for what I do to push a docker container into docker hub. Here I will use my repository in docker hub i.e. arwankhoiruddin/hadoopbuild . You can find it here: https://hub.docker.com/r/arwankhoiruddin/hadoopbuild/ In order to modify it, first I have to login $ docker login Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. Username (arwankhoiruddin): arwankhoiruddin Password: Login Succeeded Then I run the docker image $ docker run -it arwankhoiruddin/hadoopbuild /bin/bash If it is not in my computer, it will download automatically from docker hub. After I finish, I type exit and I can save the changes into the docker hub. Followings are the steps $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 856e2774909