Author Archives: vijiboy

About vijiboy

A technical geek, love to learn and share tips and tricks in technology

Configure Cntlm proxy and test if it works

Life behind (NTLM) proxy can be irritating especially if you use command line tools to access web e.g., pip, git, emacs etc. CNTLM a very useful tool can help, although configuring it for using password hashes confuses many. Following steps will quickly help you setup cntlm and use it.

It is required to generate hashes for your password as its unsafe to save your password in a text file. You will also require to re-generate hashes periodically if your password changes as part of corporate policy. Steps below shall help you if you want to configure cntlm for the first time or later on a password change.

Step 1: Generate your hashes using cntlm -H

Cntlm generates hashes (32 digit Hex numbers) for your password using -H and additionally  username and domain name options as shown below.
Ensure if cntlm is not already running (as a service) e.g. > net stop cntlm

> cntlm -H -u username -d domainname

Enter your password when it prompts and cntlm will dump all the hashes (NTLMv2, NT, LM) on the console screen.

Note if your config file (cntlm.ini) already contains username and domain name you need not provide username and domain name e.g. > cntlm -H
Use the generated hashes on screen in your cntlm.ini.

Step 2: Update your cntlm.ini

  1. Paste the hashes generated earlier from command line.
  2. Provide your username and domain if not done already.
  3. Put the proxy server address and port if not done already.
  4. By default cntlm will listen on localhost at port 3128. This can be left unmodified if you are not already using that port.

Step 3: Test your configuration using cntlm -M url

Test if cntlm works by accessing a website url to check if your settings (cntlm.ini) works.
Note: stop the cntlm service if its already running:  > net stop cntlm

> cntlm -M http://google.com

It will start the cntlm using your updated config file (cntlm.ini) and test if access to url succeeds. Cntlm will exit after dumping the result, type of authentication (NTLMv2/NT/LM) and password hash used.
If you see a OK in the result cntlm is working. You could start the cntlm as a service running in background.

> net start cntlm

Step 4: Use Cntlm proxy with tools and Environment variables:

Once cntlm is running, you can use cntlm proxy with tools by configuring their proxy option (Command line tools e.g. >pip install  –proxy=localhost:3128)
Note that, some tools can directly use the environment variables if you set http_proxy and https_proxy to point to localhost:3128 or the ‘listen’ port mentioned in your cntlm.ini.

Advertisements

FFMPEG command line examples for audio-video capture

Here, keeping some ffmpeg commands handy as I tend to forget if I don’t use them quite often. (please pardon me if links dont work)

To list the audio-video devices connected to the system:

ffmpeg -list_devices true -f dshow -i dummy

>ffmpeg -list_devices true -f dshow -i dummy

ffmpeg -list_devices true -f dshow -i dummy

ffmpeg version N-82966-g6993bb4 Copyright (c) 2000-2016 the FFmpeg developers

built with gcc 5.4.0 (GCC)

configuration: –disable-static –enable-shared –enable-gpl
–enable-version3 –enable-dxva2 –enable-libmfx –enable-nvenc
–enable-avisynth –enable-bzlib –enable-fontconfig –enable-frei0r
–enable-gnutls –enable-iconv –enable-libass –enable-libbluray
–enable-libbs2b –enable-libcaca –enable-libfreetype –enable-libgme
–enable-libgsm –enable-libilbc –enable-libmodplug –enable-libmp3lame
–enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libopenh264
–enable-libopenjpeg –enable-libopus –enable-librtmp –enable-libsnappy
–enable-libsoxr –enable-libspeex –enable-libtheora –enable-libtwolame
–enable-libvidstab –enable-libvo-amrwbenc –enable-libvorbis
–enable-libvpx –enable-libwavpack –enable-libwebp –enable-libx264
–enable-libx265 –enable-libxavs –enable-libxvid –enable-libzimg
–enable-lzma –enable-decklink –enable-zlib

libavutil 55. 43.100 / 55. 43.100

libavcodec 57. 70.100 / 57. 70.100

libavformat 57. 61.100 / 57. 61.100

libavdevice 57. 2.100 / 57. 2.100

libavfilter 6. 68.100 / 6. 68.100

libswscale 4. 3.101 / 4. 3.101

libswresample 2. 4.100 / 2. 4.100

libpostproc 54. 2.100 / 54. 2.100

[dshow @ 00000000004832a0] DirectShow video devices (some may be both video
and audio devices)

[dshow @ 00000000004832a0] “Logitech HD Pro Webcam C920”

[dshow @ 00000000004832a0] Alternative name
“@device_pnp_\\?\usb#vid_046d&pid_082d&mi_00#7&10c84974&0&0000#{65e8773d-8f56-
11d0-a3b9-00a0c9223196}\{bbefb6c7-2fc4-4139-bb8b-a58bba724083}”

[dshow @ 00000000004832a0] DirectShow audio devices

[dshow @ 00000000004832a0] “Microphone (HD Pro Webcam C920)”

[dshow @ 00000000004832a0] Alternative name
“@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\Microphone (HD Pro Webcam
C920)”

dummy: Immediate exit requested

To query specific (audio) device:

ffmpeg -list_options true -f dshow -i audio="Microphone (HD Pro Webcam C920)"

>ffmpeg -list_options true -f dshow -i audio=”Microphone (HD Pro Webcam C920)”

ffmpeg -list_options true -f dshow -i audio=”Microphone (HD Pro Webcam C920)”

ffmpeg version N-82966-g6993bb4 Copyright (c) 2000-2016 the FFmpeg developers

built with gcc 5.4.0 (GCC)

configuration: –disable-static –enable-shared –enable-gpl
–enable-version3 –enable-dxva2 –enable-libmfx –enable-nvenc
–enable-avisynth –enable-bzlib –enable-fontconfig –enable-frei0r
–enable-gnutls –enable-iconv –enable-libass –enable-libbluray
–enable-libbs2b –enable-libcaca –enable-libfreetype –enable-libgme
–enable-libgsm –enable-libilbc –enable-libmodplug –enable-libmp3lame
–enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libopenh264
–enable-libopenjpeg –enable-libopus –enable-librtmp –enable-libsnappy
–enable-libsoxr –enable-libspeex –enable-libtheora –enable-libtwolame
–enable-libvidstab –enable-libvo-amrwbenc –enable-libvorbis
–enable-libvpx –enable-libwavpack –enable-libwebp –enable-libx264
–enable-libx265 –enable-libxavs –enable-libxvid –enable-libzimg
–enable-lzma –enable-decklink –enable-zlib

libavutil 55. 43.100 / 55. 43.100

libavcodec 57. 70.100 / 57. 70.100

libavformat 57. 61.100 / 57. 61.100

libavdevice 57. 2.100 / 57. 2.100

libavfilter 6. 68.100 / 6. 68.100

libswscale 4. 3.101 / 4. 3.101

libswresample 2. 4.100 / 2. 4.100

libpostproc 54. 2.100 / 54. 2.100

[dshow @ 00000000005933c0] DirectShow audio only device options (from audio
devices)

[dshow @ 00000000005933c0] Pin “Capture” (alternative pin name “Capture”)

[dshow @ 00000000005933c0] min ch=1 bits=8 rate= 11025 max ch=2 bits=16 rate=
44100

Last message repeated 22 times

audio=Microphone (HD Pro Webcam C920): Immediate exit requested

To record audio from the mic (without encoding):

ffmpeg -f dshow -i audio="Microphone (HD Pro Webcam C920)" -vn -sn -acodec copy DTMFToneSample2.wav

>ffmpeg -f dshow -i audio=”Microphone (HD Pro Webcam C920)” -vn -sn -acodec
copy DTMFToneSample2.wav

ffmpeg -f dshow -i audio=”Microphone (HD Pro Webcam C920)” -vn -sn -acodec
copy DTMFToneSample2.wav

ffmpeg version N-82966-g6993bb4 Copyright (c) 2000-2016 the FFmpeg developers

built with gcc 5.4.0 (GCC)

configuration: –disable-static –enable-shared –enable-gpl
–enable-version3 –enable-dxva2 –enable-libmfx –enable-nvenc
–enable-avisynth –enable-bzlib –enable-fontconfig –enable-frei0r
–enable-gnutls –enable-iconv –enable-libass –enable-libbluray
–enable-libbs2b –enable-libcaca –enable-libfreetype –enable-libgme
–enable-libgsm –enable-libilbc –enable-libmodplug –enable-libmp3lame
–enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libopenh264
–enable-libopenjpeg –enable-libopus –enable-librtmp –enable-libsnappy
–enable-libsoxr –enable-libspeex –enable-libtheora –enable-libtwolame
–enable-libvidstab –enable-libvo-amrwbenc –enable-libvorbis
–enable-libvpx –enable-libwavpack –enable-libwebp –enable-libx264
–enable-libx265 –enable-libxavs –enable-libxvid –enable-libzimg
–enable-lzma –enable-decklink –enable-zlib

libavutil 55. 43.100 / 55. 43.100

libavcodec 57. 70.100 / 57. 70.100

libavformat 57. 61.100 / 57. 61.100

libavdevice 57. 2.100 / 57. 2.100

libavfilter 6. 68.100 / 6. 68.100

libswscale 4. 3.101 / 4. 3.101

libswresample 2. 4.100 / 2. 4.100

libpostproc 54. 2.100 / 54. 2.100

Guessed Channel Layout for Input Stream #0.0 : stereo

Input #0, dshow, from ‘audio=Microphone (HD Pro Webcam C920)’:

Duration: N/A, start: 664890.821000, bitrate: 1411 kb/s

Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s

Output #0, wav, to ‘DTMFToneSample2.wav’:

Metadata:

ISFT : Lavf57.61.100

Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo,
s16, 1411 kb/s

Stream mapping:

Stream #0:0 -> #0:0 (copy)

Press [q] to stop, [?] for help

size= 1550kB time=00:00:08.53 bitrate=1489.0kbits/s speed= 1x q

size= 1550kB time=00:00:08.53 bitrate=1489.0kbits/s speed=0.992x

video:0kB audio:1550kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.004913%

To be continued…

Making the move finally, shifted from Windows to GNU/Linux to Emacs, once and for all!

The Migration:

Shifted to Ubuntu 14 (GNU/Linux), 64-bit – Single Boot from Windows 7 32-bit.

This will not be a temporary shift but a total migration. I have come to stay forever in these great tools which I have come to appreciate over these 5-6 years – Emacs, Vim, Shell, Grep, Find, other GNU/Linux tools. Yeah please say GNU/Linux instead of just Linux.

I can live without Microsoft Windows applications and their mouse affection. Though I will miss  “Age Of Empires” game the most. But thats the reason to look forward to buying a gaming console 😉

Emacs and the one keyboard hack you need: Swap Ctrl and Alt

First thing after coming here: Installed Emacs and Changed the keyboard layout using XKB. Yeah seriously it was for this keyboard hack / remap that now I get that smiling feeling inside of Emacs and fly through the myriad chord key-combinations with great ease.

If you ever think of Emacs do not forget to do this one thing: Swap Ctrl and Alt. Then use palm and thumb to press Ctrl and Alt.

Questions ? Read this excellent article by Xah Lee which saved my life inside Emacs –  http://ergoemacs.org/emacs/swap_CapsLock_Ctrl.html . You will get a lot of keyboard and other tips on his site.

I am so used to this Ctrl-Alt swap that it comes naturally now and I feel like a Superman inside Emacs! Really back in those early days of Emacs, the keyboards must have been with symmetrical Ctrl, Alts and at swapped positions.

By the way there are more mappings I have in mind: 1. Caps Lock shall be an Extra Esc. and 2. Two Shifts at once shall be Caps Lock.

XKB is the new guy in the town

While AutoHotKey would help quickly map the keyboard on windows, I could use the similar AutoKey on Ubuntu. However this time thought of doing it the ‘right way’ – made new friend, meet –  The XKB ! (X Keyboard Extension).

It took some time to wrap my mind around it, but managed due to the awesome ask-ubuntu community.
Thanks to this step by step answer – https://askubuntu.com/a/885047/776635, after being contended with detailed XKB articles refferred by Xah Lee, I could quickly follow it.

Earlier I would use ‘xmodmap’ and ‘xev’ for this purpose but seems after Ubuntu 13, ‘xkb’ took over ‘xmodmap’ to maintain the system level Keyboard map and layout. I see XKB is the only way to do it cleanly i.e. effecting it throughout the system and not just for one terminal session.

Mastering Emacs

Where is my Vim? Yes I am still using Evil inside Emacs. But have recently started reading my copy of ‘Mastering Emacs‘ by Mickey Peterson. His blog reads authoritatively and his point which appeals me most is “To best learn Emacs is to learn how to ask and get help from Emacs itself”.  It was fun to watch Mickey’s interview with Sacha. I am sure I will have mastered the art of learning emacs by working through the book. Hope I will get out of Evil one day. Evil or not both ways I stand benefited.

Bye Bye Windows

Loving it here in Linux (Ah no! the GNU/Linux) and never going back ever again 🙂
Looking forward for years and years of fun. May the force of these great tools be with me and the community forever !

Avoid plastic water bottle, all plastics have adverse effects. How to tell which plastic is relatively safe ?

water-bottles-00474-2-favorites-630

Plastics are inevitable

Whatever exposure levels are prescribed by these Food Safety Authorities on plastic chemicals, we cannot base our lives or the next generations’ on them. While they suggest that there could be stable plastics which could be made but then it will mean disruption of the big plastic industry.

We cannot expect the plastic industry to just stop whatever they are doing and start making plastics which are really stable and have ‘NO’ side effect water bottle – just plain water in and plain water out !

My favorite water bottle

For wanting a cool and sturdy water bottle I saved the time of researching and went ahead with the well considered wirecutter reviews. Searching for the ‘Best Water Bottle’ on Wirecutter I found one sleek and BPA Free plastic water bottle with cool one handed operation.

Thus I soon ordered on Amazon and got the Thermos Intak Hydration Bottle made of Eastman Tritan copolyester which is a BPA free plastic. Though I like its ruggedness and usability after doing a bit of research on plastics, BPA and its health effects I was saddened that I have to part with this adorable water bottle and have to look for the metal/glass ones due to plastics adverse effects on health. Have provided excerpts of what I found on this important subject:

Note that I still consider and recommend wirecutter and sweethome reviews which are well researched and exhaustively tested for usability.

Excerpts and Links you must read:

How to tell which plastic is (relatively) safe ?

Look for the recycling triangle icon which can help you indicate the plastic resin type and thus toxicity of its chemical. The Resin Identification Code 2, 4 and 5 are “relatively” safe and as shown:

This code, used to facilitate recycling, is found in almost all the plastics, be it for packing processed foods and drinks (your Toothpaste, Coca-Cola/Pepsi, Packaged water, Juice drinks, Tomato/Mayonnaise Sauce, etc) Or plastic bottles, containers and wraps bought for home use.220px-import_canned_foods_in_kobe

So next time at the mall look for this shape on the plastic you buy. Plastics with the resin code 2, 4 and 5 are relatively safe; yet studies have shown them to be toxins with adverse effects. Want to know what relatively safe means, read this page on various plastic types and their toxicity – How can I tell what type of plastic is safe ?

Is BPA-Free safer ? May Not.

US Food and Drug Administration (FDA or USFDA) and European Food Safety Authority (EFSA), initially had a safer stand on BPA for current exposure levels but have started to show negative remarks on BPA. US FDA banned it from baby products and containers while EU (European Union), giving BPA a SVHC status (Substance of Very High Concern) is on the verge of restricting the restricting the chemicals import. Refer BPA on Wikipedia, especially the adverse health effects

According to these independent tests conducted on BPA-Free plastics in this paper: Plastic Bottles containing BPA-Free chemicals (Copolyester, Other Polycarbonates producing BPS, BPF, etc) sometimes have more estrogenic activity (EA) than BPA plastics, producing adverse health effects especially at low doses in younger people and kids.

Best Programming Fonts & Source Code Pro

As a programmer we want our code to tell us quickly about itself. Using the right fonts really goes a long way to help. Programmer would ideally want fonts which stay crispy clear when scaled down to smaller sizes, have monospace type and avoid ambiguity in some potentially confusing characters as below.

Personally I have liked and been using Consolas and DejaVu Sans Mono. Lucida Sans Unicode and Courier New are other fonts which I appreciate for my programming life.

Just today as I was out for a change and found out this impressive looking font made with programmers in mind – Source Code Pro.

Source code Pro

“An open source programming font released by Adobe, made with the intent of maximizing usability and avoiding common design flaws in monospaced fonts.” … from slant.co.

Read the announcement blog by Paul D. Hunt, the font creator, for more details. Its open sourced by Abode and you can download it from github.

As for a programming font it does not matter to me if this font lacks italic. Although will take some time to get used to its more horizontal space and rounded shape compared to Consolas and few other fonts in this category.

Looks wonderful in dark colored schemes. Loving it in Vim dark color schemes such as lucius, solarized(dark), molokai, zenburn, etc. Thanks Adobe for open sourcing this font!

This page from slant.co ranks other very good fonts as well.

Migrating to Emacs, carrying my 4 years of Vim with me !

The benefit of using a powerful text editor is not of the savings in time you get but the chance for your tools to talk with your mind. Which is an enormous experience once you start feeling it 🙂

Sharing my experience in using Vim and Emacs.

Humble Beginnings with Vim:

I learned Vim and recommend every new comer to use VimTutor.bat to learn vim after learning to touch-type. You know touch typing right ? I learned and used Vim for 4 years for most of my text needs – code search, search and replace code, emails, documentation and wiki.

Ever since I was hooked up to Vim, have enjoyed it every bit of it ! Most of the time I would force shut my mouth so as not to scare my colleagues out of my surprise and enjoyable moments. Vim gave back me some life by removing monotonous text editing.

Every passing minute, hour and day has been a spiralling increase of productivity. I also taught and advertised it too those few colleagues who could touch-type.

I will say a tool is powerful only when it starts to get out of our way and gets the job done. We start to realise what communicating with speed of thought means. Vim fits this principle completely. And surely there is so much more to learn and the hunger just refuses to go away !

The IDE dilemma, look elsewhere:

So I was happy vimming, learning more, enjoying more when one fine day I demanded it to be my IDE for (no) .NET application development. Not that I wanted a glossy looking gray box but features we miss like – code completion (intellisense), project browsing, git/svn integration, class view, function/method/class i.e. search the symbol, integrated debug and build environment. I was using Vim 7.4 at that time and due to the lack of multi-threaded or inter-process architecture in Vim thought that it was a bit limiting for me to do all of this in Vim.

I knew the only other place I could look and demand was emacs and I looked into it.I really agree with the common poke at emacs as “An Operating System which lacks an editor” Or the famously funny name ‘Escape Meta Alt Contol Shift’ !

There’s Emacs but:

Convinced that emacs had the power to provide me what I wanted I had to now leave my adorable Vim text editing language (you should not call it keybindings, its a text programming language) I feared about this but still went ahead to give it a try and planned comeback to Vim if I failed.

After going through the emacs tutorial for first time, I experienced the chords pain quickly (chords means pressing multiple keys with multiple fingers at the same time – the dreaded ‘Escape Meta Alt Control Shift’ name is dedicated to this) .

I got the pain quickly because of my already weak finger and muscles connected all the way till my elbow. I carried this pain for a while and continued to adopt and learn more about Emacs.

Org-mode from google tech-talk was good to watch just for fun.

I found other emacs variants and some cool like neoVim. Even if neoVim sounds interesting and is becoming stable (as I heard from the above Evil youtube video,) and even if emacs lisp is due for a major over haul which is not coming soon, I am willing to keep with emacs and join the 30+ years of evolution and stability. (emacs and vi both were born roughly around 1975)

Some videos of Rick Dillon helped me. Blogs of Xah Lee helped me to swap Ctrl and Alt and removing the caps lock. The pain got lesser.

Through out all this the hand-finger elbow pain was always there and I missed power of text editing in vim. Emacs had too much power and customisation available but lacked a decent text editing behavior by default.

Enter the Dragon: Evil-Mode

Because Emacs was extremely customisable and I was already using Vim keybindings in Chrome browser, Visual Studio; I thought somebody must have implemented vim keybindings for Emacs and I googled. Lo and Behold I found Evil.

Evil Mode Video on Youtube https://www.youtube.com/watch?v=JWD1Fpdd4Pc really clicked with me and I was charged up.

Finding evil mode was one such great moment for me as I could use my favorite vim style editing and still be in emacs. Then I never looked back and have happily shifted to Emacs since then.

The IDE dilemma is still to be solved but seeing CEDET and OmniSharp (intellisense) server for C# code completion I am convinced that I will be able to use those features of IDE for which many people fall in the trap.

Fast Forward 1 year:

Evil and Org are the 2 things I can’t live without in Emacs and use them all the time. Mailman, gnus, Calculator and many more.I look forward for many years with Emacs and Vim bindings … 🙂

How to make attractive Resume / bio-data / CV

Don’t ask a format from me, really there is no such universally good resume format.
If you can convey best things about yourself in quick and easy manner, consider that a elegant and attractive resume. No amount of graphics, tables, details will help when it comes to your resume.

The only thing attractive about your resume is if you can convey important information to the employer in seconds. Obviously we are not talking about arts or media industry, which may require exquisite graphics/art but that too is sweeter if kept short and relevant. Employers love if you save their time in selection process, wear their shoes and you will know 🙂

Remember, resume is your chance to be called for an interview. Yes its just that – quoted from the great parachute book of job searching: “What Color Is Your Parachute?” by Richard N. Bolles. Spare some time and read that book, it will mature your thought process about employee – employer relationship

Now, making the resume attractive (relevant) will also mean that you know the employer and the said job profile and then you highlight those relevant parts of your career which makes you unique and potential to the current opportunity. Most of times it just means to do simple modification to the existing resume. Even if you don’t have a resume like starting on a career or updating one, be sure to consider these important points:

Resume Content:

I would not a provide a sample word or pdf document but a draft layout for resume could look like this: (Note that these are nothing but questions I expect answers of each candidate)

  • Contact: Your Name, email and phone number – in clear large or bold font.
  • Accomplishments / Summary: short bulleted points answering what have you done/achieved which makes you relevant to us. This is your highlights.
  • Technologies: keywords of what languages, frameworks, technologies used and which are relevant to us. (You could ignore this section if its too small at the start of your career)
  • Work Experience: In descending order – Employment history and projects done in each employment period. In projects, description should be brief, technical and should highlight your contribution. Contribution again should be brief and highlight your technical / soft skills. You could also use conversational style description which makes it more interesting and personal. Like instead of table you tell a story in almost similar word count. e.g This project required me to port the xyz framework from A platform to B platform, where I got good hands on experience on tools like p, q and r.
  • Education / Courses: Include relevant courses and master / degree grades. Avoid all earlier grades example School, Primary, Secondary if possible.
  • Links to Online Profile: You may include links to your LinkedIn profile, StackOverflow, WordPress (blogging), Google+, CodeChef profile, etc and (not social profile like facebook) not taking much space (e.g. use icons/usernames and hyperlinks). Even if you don’t include good employers will find out this.

Formatting Tips:

  • No grammatical or spelling mistakes. No incorrect data. Correct Captilization for technology terms e.g. “ASP.NET”, iPhone, DirectShow.
  • Font size between 10 – 13, avoid bold, italics, multiple font types. Avoid too many boxes – robotic looks. Avoid too much graphics more than what is enough to convey points quickly and intuitively.
  • Don’t include all projects just for the sake of it instead discuss extra projects and hobby projects at the time of interview (which you maintain in another big work journal of yours).
  • You can avoid references and be willing to provide these on actual request by the employer.
  • Resume should be short at most 1 or 2 pages and always remember that the employer decides on your resume in 10-20 seconds.

 

All the Best!