Tagged: howto Toggle Comment Threads | Keyboard Shortcuts

  • diegor 6:40 pm on April 2, 2014 Permalink | Reply
    Tags: , howto   

    HOWTO: move a commit to another branch using GIT 

    #> git log #Get the commit_ID that you want to move
    #> git checkout [right_branch]
    #> git cherry-pick [commit_ID]

     
  • diegor 6:10 pm on March 13, 2014 Permalink | Reply
    Tags: awk, howto, sed   

    HOWTO: print the nth line of a file 

    #> awk 'NR==1524' file.txt # print the 1524th line of the file using awk
    #> sed -n '1244p' file.txt # print the 1244th line of the file using sed
    

     
  • diegor 10:27 am on March 12, 2014 Permalink | Reply
    Tags: howto, less,   

    HOWTO: jump to a specific portion of a huge file with less 

    #> less +56g hugefile.txt # it goes to the 56th line
    #> less +56p hugefile.txt # it goes into the 56% of the file
    #> less +56P hugefile.txt # it goes to the line containing the 56th byte
    

     
  • diegor 10:47 am on February 18, 2014 Permalink | Reply
    Tags: howto,   

    HOWTO: drop all tables in MySQL 

    Unfortunately MySQL doesn’t have any command to drop all tables or to truncate the database. It has just DROP TABLE and DROP DATABASE.

    A solution to drop all the tables without dropping the database could be playing with some pipe, grep and mysql/mysqldump client. Here the result:

    #> mysqldump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data [DATABASE] | grep ^DROP | mysql -u[USERNAME] -p[PASSWORD] [DATABASE]

    Source

     
  • diegor 6:09 pm on February 12, 2014 Permalink | Reply
    Tags: howto,   

    HOWTO: remove ^M characters at end of lines in vi/vim 

    Open the file with vim, then type:

    :%s/^V^M//g
    

    ^V (CONTROL-V) is used to escape control characters.

     
  • diegor 3:04 pm on February 6, 2014 Permalink | Reply
    Tags: howto, mongo,   

    HOWTO: print more than 20 documents in MongoDB’s shell 

    #> mongo
    MongoDB shell version: 2.4.5
    connecting to: test
    > DBQuery.shellBatchSize = 100
    100
    > // Starting from now .find() will print out 100 documents each time
    

     
  • diegor 3:21 pm on February 5, 2014 Permalink | Reply
    Tags: , howto,   

    HOWTO: use vim as default editor for git 

    Pick your favorite from the following ones:

    #> export GIT_EDITOR=vim
    #> git config --global core.editor "vim"
    #> export VISUAL=vim
    #> export EDITOR=vim
    

    Git will respect this order.

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel