Thursday, December 15, 2011

cd command

Few most useful b commands
cd - # move back to the previous directory
cd ~ # move into your home directory
cd .. # move up one directory

Wednesday, December 14, 2011

Umask

umask is a set of setting default permissions for files or directories that you create on your system.
umask tells the system what permissions to remove from the normal default setting.
umask value can be a three or four digit value.

Global umask value can be change in /etc/bashrc (default value is 0022 or 022).
The extra 0 at the beginning just means that the number is in octal format.
umask can be set temporary using umask command

Example:
umask 077 (Owner - read, write and execute, Group - No Permissions, Others - No Permissions)

How to calculate umasks?
The octal umasks are calculated using bitwise AND of the unary complement of the argument using bitwise NOT. The octal notations are as follows:
Ocatal Value | Permission
0 - read, write and execute
1 - read, write
2 - read, execute
3 - read only
4 - write and execute
5 - write only
6 - execute only
7 - no permissions

Note: Directories must be executable (X) in order to browse them.

Tuesday, December 13, 2011

Scraping

LXML is useful Python library for scraping. Here is an example of scraping script

pip install requests
pip install lxml

#! /usr/bin/python
import requests
import lxml
from lxml import html

r = requests.get('https://www.google.com/')
tree = lxml.html.fromstring(r.content)
elements = tree.get_element_by_id("prm")
for el in elements:
print el.text_content()

Note: It works with Python 2.6.1 (did not work with Python 4). LXML specs

Tuesday, November 22, 2011

Studio 60


The show reminds me of Saturday Night Live. Good show, actors and plot. Another great show written by Aaron Sorkin.

Monday, November 21, 2011

MAC Screenshot Command


  1. command+shift+3 // Full Screenshot

  2. command+shift+4 // Crosshair to allow selection of screenshot area

  3. command+shif+4(then spacebar) // Camera to capture specific screen object. Similar to Digital Camera

Chelsea Piers GYM (Pier 60)

Almost 3 years ago I stopped going to GYM and slowly gained weight. After some consideration I choose Chelsea Piers that is located 15 min walk from my work. I am planning to go to the gym at least 3 times per week (morning hours before work).

The gym would cost me $55 per paycheck.

I woke up at 5:45AM today and exercise for 45 minutes. I feel better and refreshed.

Tuesday, November 1, 2011

Import CSV file into MYSQL


LOAD DATA INFILE 'myfile' INTO TABLE table FIELDS TERMINATED BY ',';

Saturday, October 29, 2011

Usage of cat command

cat command functionality:
1. create
2. view
3. join files

cat is short for catenate (to join things together, end-to-end)
- Create file
cat > file1
enter text
more text
# press Enter, CTRL-d to exit

- View file(s)
cat -n filename # will number all lines
cat -b filename # will number all non-blank lines

cat -t filename # all tabs to be shown as ^I
cat -s filename # remove extra blank lines. 1 blank line is allowed.
cat -A filename # combine -t & -s options together

- Join Files
cat test1 test2 # join both files and show output in stdout
cat test1 test2 > test # Join both files and add to stdout

Tuesday, October 25, 2011

Bash Shortcuts


GNU Readline Library enable to edit the command line shortcuts. Readline uses emacs key binding. It means a lot of CTRL/ALT keys.

  1. Ctrl+C # Interrupt to exit, terminate the command

  2. Ctrl+D # disconnect from shell

  3. Ctrl+Z # suspend the process, suspend/stop the command

  4. Ctrl+l # clear screen

  5. Ctrl+s # stops the output to the screen

  6. Ctrl+q # allow output to the screen
    (If previously stopped using Ctrl+s)

  7. !! - run last command

  8. Ctrl+r # search the history backwards

  9. Ctrl+g # escape from history searching mode

  10. Ctrl+a # go to start of the command line

  11. Ctrl+e # go to end of the command line

  12. Ctrl+f # move forward one character (identical to VIM)

  13. Ctrl+b # move backward one character (identical to VIM)

  14. Ctrl+p # previous command in history

  15. Ctrl+n # next command in history


kill processes that match grep pattern

I open about 20 copies of the same file. I used the command below to kill them.
kill -9 `ps auwwwx | grep "vim /tmp/continuous_migration.log" | awk '{print $2}' | xargs

Sunday, October 23, 2011

diff


diff from_file to_file
diff from_dir to_dir

diff useful lags
-B (Ignore changes whose lines are all blank.)
-b (Ignore changes in the amount of white space)
-y (side by side ouput comparison)

useful alias:
diff -Bb alias

Saturday, October 22, 2011

Changing Linux Login Shell


Ways to change Linux shell
1. chsh (change login shell)
2. edit /etc/password
3. exec in .login file

Sunday, October 16, 2011

Defiance movie


My sister recommend the movie. She watched during her flight from Israel. Great movie.
Very sensitive. It remind my grandparents story about world word two. They had very difficult life and survived Nazi occupation of former Soviet Union. A lot of members of my parents dies during the war. My father uncle was killed in Latvia in 1944 as a soldier. My father grandfather was killed in Ghetto in 1943...
Most of the jewish familes have similar story to Bielski brothers'.

I purchased the movie in Amazon Instant Video. For more information about the movie, here is link on Wikipedia

Also, 15 years ago my grandmother Klara died. She was only 67 years old...

Saturday, September 10, 2011

Yankees Stadium

I went to Yankees game last Sunday. It was my first time in Yankees Stadium (new stadium). Roma invited me to the game with two of his coworkers (Eva from Germany) and Japanesse girl. Yankees won the game against Toronto (9-3).
The games was kind of boring... but stadium is great. Overall it was good experience and I like it. Here are some pictures from the game.






Friday, September 2, 2011

Database Optimization

Indexing can dramarically improve performance of MySQL database. Indexing is the most important tool for speeding up your queries.

Facts, Tips & Terms:
- Database is a set of tables. Table is a set of rows and columns
- Full Table scan (slow) - examine each row in the table
- Data rows kept in a data file and index values are kept in a index file
- MySQL indexes speed up searches for rows matching terms of a WHERE clause. It also improve performance of MIN(), MAX()
and ORDER By operations.
- Index columns that you search for, not columns you select
- Declare columns to be NOT NULL - fater processing and less storage.
- Disadvantages of Indexing
a). Slow inserts, deletes and updates (need to update data and index files)
b). Index file takes up the disk space

- How to choose indexes:
b). Use short indexes (int is better than varchar). A smaller index involves less disk I/O, so it can be compared more quickly.
a). Index should be uniue (spread of values in a column). So index work best for columns with unique values.
c). Indexes are used for
<, >, <=, =>, =

Wednesday, August 31, 2011

Irene (hurricane)

New York was hut by hurricane Irene last weekend. My apartment located in Zone A (mandatory evacuation).. I did not evacuate.
Public transportation was shutdown for the weekend first time.







New York was hit by hurricane last week. My apartment was located in Zone A (mandatory evacuation). I did not evacuate ... The building was not flooded. Here some picture of flooding Sheepsheadbay/Manhattan Beach area. Mayor Mike Bloomberg shut down public transportation.














drush

Helpful Drush Commands:

  1. drush fra - feature # Revert all

  2. drush fu $module # update the code

  3. drush dis $module # disable module

  4. drush en $module # enable module

  5. drush cc menu # clear cache for menu

  6. drush cc all # clear all cache

  7. drush sm # show modules The official full name of the command is pm-list which is confusing so just ignore it

  8. drush scr test.php # running a Drupal script

  9. drush php-script test.php # run a Drupal Script

  10. drush php-eval 'global $user; print_r($user)' # executing code

Tuesday, August 23, 2011

SSH Login Without Password

Server A (Local Server)
Server B (Remote Server)

Server A:
1. ssh-keygen -t rsa // generate a key using ssh-keygen
// More Secure: ssh-keygen -t rsa -b 4096
2. scp id_rsa.pub myname@SERVERB:/home/myname/

SERVER B:
1. ssh-keygen -t rsa
2. cp id_rsa.pub .ssh/authorized_keys2
3. chmod 700 ../.ssh
4. chmod 640 .ssh/authorized_keys2

Troubleshooting MySQL Slow Queries with Tcpdumps

Great article by Sean Hull - Troubleshooting MySQL Slow Queries with Tcpdumps

Monday, August 22, 2011

VIM (tutorial 1)

I - insert at the begin of line
A - append to end of line
o/O - open a new line after/before the current
v/V - Visual mode to select text
Shift+R - replace text
C - change remaining part of line
r - replace one character
~ - changes case
J - joins lines
Ctrl+A - increment a number
Ctrl+B - decrement a number
. - repeat last command (a simple macro)
= indent line

Thursday, August 18, 2011

Thursday, August 11, 2011

Git on RHEL/CENTOS

Git is not available in RHEL repository. Use the following commands to install it.

rpm -ivh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

yum install git

Wednesday, August 10, 2011

wget utlity on MAC

By default wget utility is not included in MAC. So I decided to install it through 'port'

sudo port install wget
---> Computing dependencies for wget
---> Fetching archive for wget
---> Fetching wget
---> Attempting to fetch wget-1.12.tar.gz from ftp://ftp.gnu.org/gnu/wget
---> Verifying checksum(s) for wget
---> Extracting wget
---> Applying patches to wget
---> Configuring wget
---> Building wget
---> Staging wget into destroot
---> Installing wget @1.12_3+ssl
---> Activating wget @1.12_3+ssl
To customize wget, you can copy wgetrc.sample to wgetrc
in /opt/local/etc and then make changes.
---> Cleaning wget

Skirt Steak

I made barbecure at "Ford Street balcony" (aka my apartment). I inivted few friends and relatives to my place. We decided to make skirt steak.
It is really good choice for barbecue because:

  1. delicious

  2. healthy

  3. fast



Skirt Steak price is about $10 per lb. For more information read on wikipedia
here

Old Craton Aqueduct & Groton Gorge Park (hiking)

I hiked Old Craton Aqueduct path from Ossining Train Station to New Craton Dam that is located in Groton Gorge Park.
It was my third time exploring this area, few years back went with Ignat. I really enjoyed the hike before. So on 8/6/2011 I decided to explore the area again in my first date with Alina.

We drove from NYC to Ossining Station and park there. August is not great idea for hiking but it was not so hot. We hiked for about 15 miles both ways and enjoyed the hike.












Tuesday, August 2, 2011

Tesla motors

There is "Tesla Motors" store on West 25th street between 9th & 10th street. The store is located on my way from subway station to work. I am very interested in electrical cars and see huge future in them. It is good for environment, country, people and etc.
I would consider to buy one of the cars in near future.

See some pictures that I took from my iPhone 4.








Victor's Birthday

Sunday July 31, 2011 after soccer game in Garritsen beach we meet at Victor's house to celebrate his 45th birthday... There were 6 people in the birthday celebration. I had good time and have a chance to know some people better.

One show that I like to watch is House MD. Accidently I find out that Lisa Edelstein that plays Cuddy on the show is related to Lesha. Small world.

The Starett-Lehigh Building

The Starett-Lehigh Building located at 601 West 26th Street, New York New York 10001.
Martha Stewart Living Omnemedia office located here. The building is huge and has very interesting history.
For more information click here






Sunday, July 24, 2011

Air Conditioners



Bought and Installed 2 LG (8,000 BTU) air conditioners on second floor.
Past few days were very hot (more than 100 degrees).

Cold Air is heavier than hot air. Therefore, cold air moves down and hot air moves up. Second floor of my apartment is like a sauna.

Horrible Boses (movie)


I just watched "Horrible Boses" movie in Sheapsheadbay theather with Marina. B+ movie.

Thursday, July 14, 2011

Friday, July 8, 2011

Cycling (iPhone pics)




Job change

I accepted offer from MarthaStewart... I gave my current employer almost 3 weeks notice. Going to work in the NYC. Ready to hit ground with new employeer.

Monday, June 27, 2011

Outliers (Malcom Gladwell)


It is good book that is full with interesting facts and good thinking. The most interesting book for 2011.