tldr is manpage for the impatients

I just found this nice open source project tldr. What it does it to provide you a manpage with common usage of the command line rather than the full list of all complicated options. Please go to github to find out yourself.

Leave a comment

WebSocket command line program

Chrome Developer Toolkit can be used to debug WebSocket but not binary stream. wscat is a command line tool can help you with it. To install it:

npm install -g ws
npm install -g wscat

Leave a comment

Using own chef server with Azure chef-extension

I love to use Chef to manage my deployment. Azure has a nice Chef Linux extension can be used to deploy Azure VM instances with given Chef roles. However, when I use with my own Chef server, I was getting errors of SSL verification. The problem lies in the certification of our Chef server is self-signed. We have to turn off SSL verification from our Chef client. To do this, you need to add “ssl_verify_mode :verify_none” to “client_rb” in your settings. This is how you can do it in your Azure template:

      
    "properties": {
        "publisher": "Chef.Bootstrap.WindowsAzure",
        "type": "LinuxChefClient",
        "typeHandlerVersion": "1210.12",
        "settings": {
          "client_rb": "ssl_verify_mode :verify_none\n",
          "bootstrap_options": {
            "chef_node_name": "[concat(parameters('slaveChefNodeName'),copyIndex())]",
            "chef_server_url": "[parameters('chefServerUrl')]",
            "validation_client_name": "[parameters('chefValidationClientName')]"
          },
          "runlist": "[parameters('runlist')]"
        },
        "protectedSettings": {
          "validation_key": "[parameters('chefValidationKey')]"
        }
      }
    }

Leave a comment

tmate is your mate when your terminal is behind firewall

Sometimes we need to access our terminals from outside, unfortunately, my machine is not on external network. I tried many solutions, reverse ssh, teamviewer, vnc and so on. The solution works best for me is tmate. Give it a try and you will love it.

Leave a comment

named parameters for bash function

function myFunc {
  while [[ $# -gt 0 ]]; do local "$1"; shift; done
  #require paramName
}
myFunc paramName=paramValue

Now you can have named parameters for your bash functions, it made my library more useful since the script will be more readable. For compulsory parameters, you should check if it has been set or not. Some people do “local $*” instead of the while loop, but it will not work with parameters like paramName=”value with space”.

, ,

Leave a comment

font Source Code Pro for your vim

Adobe has released Source Code Pro, a open source programming font. I switched it with vim, and I am loving it. I use 14pt and Light. Give it a try!

,

Leave a comment

bash vi line editing mode

bash:

set -o vi

If you use vim you will love this. This enables vi mode for bash. It means you can use b, w to navigate backward and forward on words, f, F to find characters. Definitely helps with command line editing.

, ,

Leave a comment

git: delete remote branch

git push origin :branch_name

, ,

Leave a comment

Python strptime and number of week in the year

from datetime import datetime
d = datetime(2012, 4, 10, 0, 0, 0)
d_str = d.strftime('%Y%W')
# d_str = '201215'
dw = datetime.strptime(d_str, '%Y%W')
# dw = datetime.datetime(2012, 1, 1, 0, 0) <----- WHY?

# to make %W work, you have to use it together with %w
dw = datetime.strptime(d_str+' 0', '%Y%W %w')
# dw = datetime.datetime(2012, 4, 15, 0, 0)

Leave a comment

Sequel Pro – ultimate sql gui interface

Recently I’ve been using mysql at work, one of my colleague suggested Sequel Pro. It is a nice gui application for mysql mainly. There are plans to support sqlite but not done yet. I strongly recommend you checking it out if you have to deal with mysql.

Leave a comment