Updates from March, 2011 Toggle Comment Threads | Keyboard Shortcuts

  • diegor 12:19 pm on September 15, 2012 Permalink | Reply
    Tags:   

    HOWTO: linux terminal cheat sheet 

    Without spending too many words, here you go the image to set as background for your desktop :)

    PS: most of them work also in OSX

     
  • diegor 10:12 am on July 18, 2012 Permalink | Reply
    Tags: ,   

    HOWTO: backup a MYSQL database 

    Backup a database is simple as to dump it. From a Unix shell:

    #> mysqldump --opt -uUSER -pDBPASSWD -hHOSTNAME DBNAME > DUMPED_TEXTFILE

    Ok, now you can dump it following this post. :)

     
  • diegor 5:29 pm on July 17, 2012 Permalink | Reply
    Tags: ,   

    HOWTO: dump data into MYSQL 

    From a Unix shell:

    #>  -hHOSTNAME -uUSER -pDBPASSWD DBNAME < DUMPED_TEXTFILE

    Simple eh :)

     
  • diegor 1:50 pm on June 8, 2012 Permalink | Reply
    Tags:   

    HOWTO: Terminal’s tips in OSX 

    Another useful and quick post about tips from OSX Terminal that let you to save a lot of time. So just open a Terminal and try them.

    • “open .” opens the current folder. “open file.png” opens the image file.png. You can “open” whatever you want.
    • “pbcopy” and “pbpaste”  copy/paste to/from the clipboard
    • “python -m SimpleHTTPServer 8000″ starts a webserver (using python)
    • “say Hello there” says “hello there”, really! :)
    • “!!” runs the last command
    • “mdfind” is Spotlight from command line
    • “ctrl-a” and “ctrl-e” go to the beginning/end of the line
    • “cd”, do you really need an explanation?
    • “/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &” your screen saver as you desktop wallpaper – useless
    • “emacs -batch -l dunnet” is a text-based game :)
    • “top -o vsize” or “top -o cpu” tell you who is eating your memory/CPU?
    • “SetFile file -a V” makes files invisible
    • “diskutil” manages disks and images
    • “hdiutil burn /path/to/iso” burns an ISO to a CD/DVD
    • “/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -s” scans WIFI networks
    • “atl + mouse drag” is the rectangular selection
    • “afplay ~/path/to/file.mp3″ plays an mp3 file
    • “sudo /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder” opens Finder with root permissions (pay attention!!!)
    • “cat somefile.txt | say” literally says the content of somefile.txt
    • “history|awk ‘{print $2}’|awk ‘BEGIN {FS=”|”} {print $1}’|sort|uniq -c|sort -r” gives you the numbered list of most recent commands
    • “sudo softwareupdate -i -a” launches the software update
    • “ctrl + R” startes a reverse search of your commands

    Do you have other useful tips? Post them in the comment! :)

    Source and other tips, here.

     
  • diegor 11:02 am on May 23, 2012 Permalink | Reply
    Tags:   

    HOWTO: Firefox, fix profile in use 

    If you use Firefox and sometime you can have a strange error that prevents its execute:

    “Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system” (on OS X: “A copy of Firefox is already open. Only one copy of Firefox can be opened at a time“).

    A window like the one below will appear:

    No worries, the solution is pretty simple. It’s enough to delete these files:

    • Linux: ~/.mozilla/firefox/.parentlock and ~/.mozilla/firefox/lock
    • OSX: ~/Library/Mozilla/.parentlock
    • Windows: %APPDATA%\Mozilla\parent.lock

    Once deleted those files, launch again Firefox and it should work. If not, drop me a comment.

    PS: Stefano, diegor has come back :)

     
  • diegor 6:06 pm on July 29, 2011 Permalink | Reply
    Tags:   

    HOWTO: rename all files in lowercase 

    Pretty simple.

    1. If you don’t have a *NIX operating system, please skip this post.
    2. Create a script with this content:
      #!/bin/sh
      for f in *; do
      g=`expr "xxx$f" : 'xxx\(.*\)' | tr '[A-Z]' '[a-z]'`
      mv -n "$f" "$g"
      done

      and call it “rename.sh”

    3. Give it execution permissions, typing:
      chmod u+x rename.sh
    4. Execute the script from the directory where you have your files to rename
    If you have two files, “Foo” and “foo“, you’ll be notified and no files will be overwritten. So, don’t worry about that, you won’t lose any information. To be sure, try it with a few files in “/tmp” directory.
    Question? Suggestion? Comment! :)

     

     
    • Luca De Vitis 6:26 pm on July 29, 2011 Permalink | Reply

      ls -1 | while read file ; do mv -nv “${file}” “$(echo “${file}” | tr ‘[A-Z]‘ ‘[a-z]‘)” ; done

      • diegor 6:53 pm on July 30, 2011 Permalink | Reply

        Hi Luca, thanks for the trick.
        I tried but it doen’t work.. I have this:

        “namefile not overwritten”

        It works only if I drop “-n” option from mv command (too risky!!)

  • diegor 1:00 pm on March 11, 2011 Permalink | Reply
    Tags:   

    HOWTO: make vim show ending line spaces as characters 

    When you edit a file with vim, it’s useful understand where the line ends especially if there are spaces at the end of the line. Instead checking all lines, you can highlight white spaces. How?

    1. Open Vim from Terminal
    2. type
      :set list
    3. You see an output like the one below
    4. If you want see each space as character, type this command
      :set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
    5. The output should look like below

    Very simple and useful tip! :)

    If you have any doubt, advice or something else, comment this post! :)

    Source: Stackoverflow

     
    • proudlygeek 1:43 pm on March 11, 2011 Permalink | Reply

      Vim is my favourite text editor, i use it pretty anywhere :-)

      I’ll share a useful trick for commenting multiple lines of code:

      1) SHIFT-V to select multiple lines;
      2) Type “:s/^/#”

      Where “^” indicates the beginning of a line and “#” the comment symbol of your choice.

      To decomment a block of code:

      1) Shift-V
      2) Type “:s/^#//”

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

Switch to our mobile site

%d bloggers like this: