Useful duckduckgo searches for developers

DuckDuckGo.com is a web search engine. The superior value of DuckDuckGo comes from its ability of doing specialized searches. For non-specialized searches it uses Bing as the generic web search backend. In this blog post I describe how you can optimize your web and software development workflow with DuckDuckGo and its specialized searches.

Bing is almost on par with Google for English search results. However, it still leaves much improvement for non-English search results like ones with my native language Finnish. Thus, one cannot use DuckDuckGo for your everyday searches, like for shopping in Finland. You still need to go to Google for those. To work around this issue I have dual search engine configuration in my Firefox.

  • If I want to search from Google I type the search on the address bar (left side).
  • If I want a specialized search I type into the DuckDuckGo search box. (right side) You can install it for your browser from a button on the bottom right corner of duckduckgo.com.
  • Please note that this setup does not work with Safari which cannot do address bar searches.  Chrome also lacks the search box widget out of the box. There is something called Search Box for Chrome, but I have not tried to configure it for DuckDuckGo on Chrome (I use Chrome only as the web development browser).

1. Specialized searches

DuckDuckGo provides something called !bang syntax. You start your search query with a bang (!) and a keyword. In this case DuckDuckGo performs a special search, not a generic web search. Usually this means DuckDuckGo uses a site specific search engine skipping the web search altogether. Here are example queries which you will find very useful.

!mdn iframe – Search term iframe on Mozilla Developer Network. Useful for all HTML, CSS and Javascript related searches. MDN is the most hiqh quality information source for all web development related matters. Using this search skips low quality sites like w3schools.com. Also works: !javascript and !css.

Example what happens when you search !mdn iframe in duckduckgo.com search box

!python socket – Search “socket” on docs.python.org for Python documentation. (no one remembers Python APIs)

!pypi vvv – Search a package named vvv on pypi.python.org (a validation and linting integration for your software development projects)

!jq offset – Search offset function in jQuery documentation

!gh sevabot – Search Github for projects called “sevabot” (It’s a very handy Skype bot with HTTP interface)

!so video canvas – Search stackoverflow.com questions related to “video” and “canvas” (how to draw HTML5 video frames on <canvas>)

!php open – Try to figure out how to open a file in PHP (there are always open positions in non-PHP related software development jobs if you feel your life is misery)

!man zsh – UNIX manual page for zsh command. (check also our tuned ZSH configuration)

!ubuntuforums zsh – Search ubuntuforums.com for threads related to ZSH

!yt wesibussi – Search YouTube videos called “wesibussi” (I was young and it was fun)

As you can see, you can also copy-paste the DuckDuckGo.com search link in chat (IRC) easily for less experienced peers to educate them how to do power searches.

For the full bang queries list see the official duckduckgo.com source. You will find useful pointers for other programming languages (Perl, Ruby, Java, C#, etc).

 

 

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

Five ZSH tricks to optimize your shell workflow

Below on the video I’ll demonstrate five handy tricks you can do with zsh shell. zsh is a powerful command line shell for UNIX operating systems (Linux, Ubuntu, OSX, etc.) Newcomer shell users may find these tips helpful.

You want to use zsh because it make you type less, find command faster and ultimately make you more productive when working with UNIX and servers.

The tips are based on our tuned ztanesh shell scripts which you may wan to install too 🙂

1) Navigate around on the file system using zsh “menu select” tab completion. Writing a path to the command line equals to cd‘ing that directory in zsh. What we do here is that we open the tab completion in the current folder using the dot slash notation and then find our way to the target folder. The menu select constructs the path for us. Instructions how to set up zsh’s menu select for this.

2) Back to the previous folder where you were: cd –. Handy when you jump around in the directory tree when working. You can type only cd to go to the home folder. .. (even without cd) takes you one level higher, … two lever higher and so on.

3) Move a file using the menu select completion as shown in the first trick. You can open menu completion for any command or target.

4) zsh has superior tab completion compared to other shells: here I autocomplete an SSH host and use the menu selector to choose it from the list. zsh can also complete scp copy remote filenames. Other example is kill command where the tab completion allows you to choose the target process in a menu.

5) CTRL+R for the history search. Type CTRL + R and few letters of any of your previous commands and CTRL+R again to find it up (incremental search with history-incremental-pattern-search-backward). No need to navigate through the long backlog using up arrow. I don’t know how I managed to live 15 years without getting this to my muscle memory.

Also on the video you can see how the terminal tab colorization by the current (ssh‘ed) server works.

For more useful keybindings on OSX / iTerm 2, see how to bind ALT + arrow to move between words and fn + arrow to move to the beginning and the end of the line.

More tips welcome. Especially I am interested in

  • Fuzzy / partial string match for the history earch (Sublime Text 2 CTRL+T style go to anywhere)
  • Menu select for the history search

 

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

Recommended way for sudo-free installation of Python software with virtualenv

When installing Python software, sudo easy_install and sudo pip are something you should do very seldom. sudo means you are messing with your operating system files. easy_install means that it is easy to install, but impossible to uninstall. You most likely step on the toes your operating system package manager and make your Python installation damaged – damaged in a way you cannot reliably use OS package manager to install or upgrade the software in the future. There is also a high chance that two software depends on the different version of a library X and easy_install will happily overwrite anything with different version in your system.

Even though being badly broken, still plenty of Python software documentation recommends sudo easy_install as an installation method.

virtualenv is a Python tool for creating an isolated Python environment for a normal user. They are isolated in a sense, that only the software you install there will see and mess with the environment. When you are running virtualenv’ed python, pip and easy_install can freely pull in any libraries from pypi without the worry that you break some other software on your computer.

Here is a recipe for installing virtualenv’ed Python software which should across UNIXes and Windows. It will totally run as your normal user privileges, no sudo or admin needed. Only an installed Python interpreter and a working python command are the requirements.

So fire up your console, go the folder where you wish to perform the installation and type the following (some commenting added to explain the process):

# First create the folder where you wish to install the software
# with mkdir command. Then go to this folder with cd command.

# Windows users: Please manually download virtualenv.py
# to the target folder  ith your web browser. UNIX users
# can use curl command line downloader as below.

# Note: Don't rely on operating system virtualenv command.
# It might be hassle to instruct virtualenv package installation
# due to distribution flavours.
# Old Ubuntus ship really old virtualenv.py and it has not worked
# on all cases.
# Github virtualenv.py is the msot reliable method.
curl -L -o virtualenv.py https://raw.github.com/pypa/virtualenv/master/virtualenv.py

# Create a virtualenv environment
# where the software and its dependencies
# will be pulled from PyPi. In our case
# we call the created virtualenv folder "venv"
python virtualenv.py venv

# Activate the virtualenv environment.
# This will set your PATH environment
# variable so that following "python"
# command executes from under the virtualenv,
# not from your global system setup.
#

# Windows equivalent: .\venv\Scripts\activate
. venv/bin/activate

# Now when virtualenv is activated,
# pip and easy_install will install any software
# under this virtualenv environment, not on your operating system files
pip install YOUR_PACKAGE_NAME_ON_PYPI.PYTHON.ORG

# Usually, if you install Python command line software,
# new launcher scripts get created in venv/bin
# folder. When venv environment is active,
# this folder takes precedence in PATH environment
# variable. Meaning, when you have virtualenv activated
# you can simply type in the installed command name
# without full path to execute it.

And again with a real life example:

curl -L -o virtualenv.py https://raw.github.com/pypa/virtualenv/master/virtualenv.py
python virtualenv.py vvv-venv
. vvv-venv/bin/activate
pip install vvv

I have tested this recipe with vvv and Skype sevabot and have found it working. However, I wish to get some feedback and ideas how this could be further enhanced, so please send in your ideas.

Some notes

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

Python: Programming is fun again

OH on #sublimetext

<xxx> btw, I learnt Python just to costumize ST - and I'm glad I did
...
<xxx> back in school today, we had to use Java again
...
<xxx> and I was like "how the fuck do I do that in Java? 
      Is it even able to? In Python I would just ..."

And some more fun goodies, as it will be Friday soon

It’s the feeling that you can accomplish more by doing less.

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+