Tuesday, October 15, 2013
android, apps can't connect to internet, except browser
The reason I found out was that I came across a wifi connection sometime that blocked my phone apps from connecting to internet. After that, even if I use data connection via sim, I was not able to use internet based apps.
The solution is:
go to
Settings->Wireless and Networks ->Mobile Networks-> Access point names
Now, right click and select 'Reset to default'.
That's it, now I was able to connect these apps to internet.
Monday, September 16, 2013
Ubuntu: wifi(wireless) connection fails?
So, how to overcome this error and make your ubuntu laptop connect to wifi ?
While connecting to wifi, if you observe the syslog closely, you will find that target router keeps cancelling connection request with the reason ' unable to get local issuer certificate...'.
What is happening in the background is, the wireless service on ubuntu, eduroam, is forcing CA certification validation, from your client PC also. Usually your laptops are not CA certified, isn't it?.
So open your target wifi config file
sudo vim /etc/NetworkManager/system-connections/<wifi i want to connect to>
change 'system-ca-cert=true' to 'system-ca-cert=false'.
I hope it should start working for you now !.
Otherwise, go back to syslog and see what's messed up!.
Friday, August 30, 2013
boost your Linux running laptop's power savings - PowerTop, laptop-mode-tools
Anyways, there are couple outstanding utilities out there to help you balance the power usage on your laptops(these utils work for desktops also, but relatively these are more helpful in tuning your laptops ).
PowerTOP
===============
How to Install:
------------------------
sudo apt-get install powertop
How to run:
------------------------
:~$ sudo powertop
the output is an interactive window that looks like below,
Sunday, August 25, 2013
add virtualbox guest to network domain
1. create a bridged adapter for the guest, using virtualbox settings window.
2. This will create an adapter on the guest that will have the IP picked from ntework domain in which your host exists. That means The IP will be looking similar to the host IP, that can be pinged from a different PC.
3. Now, go to your guest OS, Start-> My computer-> right click -> Properties
enable telnet on non default port, allow root login
Wednesday, August 14, 2013
subtitle and video synchronization in vlc player
By knowing how much is the lag between video and the subtitle, we can sync these two, to play it proper.
to know the lag, play the video, try to listen to most commonly recognizable word. Not down the time stamp at that moment. Now, you have to find out at what timestamp actually that word being played from the subtitle file. Either you open the file with a word processor and see around that time or while playing the video itself you will know what time the subtitle was/is being played.
For example, In my video, I hear a sound 'Hey Macho' that i can clearly recognize. I note that it is played at 4 min 11 sec. From the file, the subtitle 'Hey Macho' is being played at 4 min 5 sec. So the lag is around 6 seconds.
To overcome this lag, on your VLC player, go to Tools->Track synchronization
Tuesday, July 16, 2013
count number of blank lines in a file using grep
To count number of blank lines in a file, we use following grep expression.
$grep -c '^$' filename
=> this will try to extract lines starting and ending with nothing in between.
Saturday, July 13, 2013
how to debug bash shell script
In your shell script, you can add
set -x
at the top of the script, this will make bash to print each command line it parse in your shell script, plus the result of the command as well.
Doing this permanently enable tracing, until you remove it or put "set +x" which is the default.
If you just want to see how it goes once, you can run your script "myscript.sh", try
$ bash -x myscript.sh
output looks like
+ var1=hi
+ var2='how are you'
++ paste hi how are you
paste: hi: No such file or directory
+ var3=
+ echo
Upgrade Java Runtime (JRE) on Debin/Ubuntu
Firefox, by default blocks java based on the version you have installed. It means it doesn't allow you to run any java application using these security-issue-ridden java versions.
But, not the same with other browsers or your OS. You got to update it immediately.
NOTE: openjdk jre is also similar to oracle java, hence you can expect same issues with open jdk too. Until you get an update on openjdk, I suggest you use oracle java, well it is not too complex to install oracle java as it looks like on the surface.
Here is how to be done: (OS: Ubuntu)
- Download latest java from oracle site http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html
- if you are using 32 bit linux(most likely intel, x86 arch), choose the right file to download(rpm type for redhat based, .gz for debian based)
- untar using command 'sudo tar -xzvf jre-7u25-linux-x64.tar.gz -C /usr/java/
- To enable this java on Firefox, create soft link for a lib libnpjp2.so from your java directory to firefox plugin directory. It looks something like this: "sudo ln -s /usr/java/jre1.7.0_25/lib/amd64/libnpjp2.so /usr/lib/firefox/plugins/"
- to verfiy, restart firefox, go to "about:plugins" in address bar, see if you have following information: "
Java Plug-in 1.7.0_25
- File: libnpjp2.so
- Path: /usr/java/jre1.7.0_25/lib/amd64/libnpjp2.so "
- that's it, you are upgraded!
- For google-chrome, you don't have to do anything if you have untarred the jre under /usr/java. To verify, restart your chrome, go to
- chrome://plugins/
- Look for
-
Name: Java Plug-in 1.7.0_25 Description: Java plug-in for NPAPI-based browsers. Version: Location: /usr/java/jre1.7.0_25/lib/amd64/libnpjp2.so
(don't forget to remove older versions of java)
Saturday, July 6, 2013
convert images to pdf
to convert one or multiple images to pdf file, use the command
$convert scan_*.jpg scanned_docs.pdf
convert command comes with package imagemagick
Monday, June 17, 2013
code complexity tool pmccabe
The best algorithm to do the same is cyclomatic complexity. (http://en.wikipedia.org/wiki/Cyclomatic_complexity)
One of the utility implementing this algorithm is pmccabe.
This ain't any IDE also! A simple CLI utility.
install:
sudo apt-get install pmccabe
usage:
<username>@<hostname>:~~$ find ./ -name *.c | xargs pmccabe | sort -nr | head -10
49 49 116 361 134 <file>(362):<function>
The first column indicates the complexity score of each of the functions mentioned.
The wiki suggests that the complexity score should be kept below 10, and in inevitable cases, it can go upto 15.
vlc player, enable en queue(add to playlist) on right click
- On the vlc player, go to tools->preferences
- click on 'interface' (default) on the left menu, on the right, click on 'instances'
- check both 'allow only one instance' and 'enqueue when in one instance mode'
Tuesday, June 11, 2013
blogger can't import wordpress posts!
- I went my wordpress dashboard->settings->export
- exported an xml file (selected all as an option, to include posts, tags comments etc)
- Then I created a blogger, went to settings->other->import blog
- my xml files was just in Kbs, nevertheless, the blogger went on taking hours to import
- What I noticed is that it was stuck on first post itself to import. Then I learnt that to import from wordpress to blogger, a conversion is needed.
- So, go to wordpress to blogger convertor and get your xml file converted.
- Try repeating step #3.
- It should work!
linux: search grep all man pages
There is a fine utility to do so, called apropos.
For example, I want to know all commands that operate on pdf files, like conversion from pdf to something else and vice versa, I will run
uid@host:~/apropos pdf
acroread (1) - Adobe PDF Viewer for viewing PDF files on X Window System.
dvipdf (1) - Convert TeX DVI file to PDF using ghostscript and dvips
evince-thumbnailer (1) - create png thumbnails from PostScript and PDF documents
fix-qdf (1) - repair PDF files in QDF form after editing
foomatic-ppdfile (1) - Generate a PPD file for a given printer/driver combo
ghostscript (1) - Ghostscript (PostScript and PDF language interpreter and previewer)
gs (1) - Ghostscript (PostScript and PDF language interpreter and previewer)
gsnd (1) - Run ghostscript (PostScript and PDF engine) without display
pdf2dsc (1) - generate a PostScript page list of a PDF document
pdf2ps (1) - Ghostscript PDF to PostScript translator
pdffonts (1) - Portable Document Format (PDF) font analyzer (version 3.00)
pdfimages (1) - Portable Document Format (PDF) image extractor (version 3.00)
pdfinfo (1) - Portable Document Format (PDF) document information extractor (version 3.00)
pdfopt (1) - Ghostscript PDF Optimizer
pdfseparate (1) - Portable Document Format (PDF) page extractor
pdftocairo (1) - Portable Document Format (PDF) to PNG/JPEG/PDF/PS/EPS/SVG using cairo
pdftohtml (1) - program to convert PDF files into HTML, XML and PNG images
pdftoppm (1) - Portable Document Format (PDF) to Portable Pixmap (PPM) converter (version 3.00)
pdftops (1) - Portable Document Format (PDF) to PostScript converter (version 3.00)
pdftotext (1) - Portable Document Format (PDF) to text converter (version 3.00)
pdfunite (1) - Portable Document Format (PDF) page merger
ps2ascii (1) - Ghostscript translator from PostScript or PDF to ASCII
ps2pdf (1) - Convert PostScript to PDF using ghostscript
ps2pdf12 (1) - Convert PostScript to PDF 1.2 (Acrobat 3-and-later compatible) using ghostscript
ps2pdf13 (1) - Convert PostScript to PDF 1.3 (Acrobat 4-and-later compatible) using ghostscript
ps2pdf14 (1) - Convert PostScript to PDF 1.4 (Acrobat 5-and-later compatible) using ghostscript
ps2pdfwr (1) - Convert PostScript to PDF without specifying CompatibilityLevel, using ghostscript
qpdf (1) - PDF transformation software
run "man apropos" for extra features with it.
Sunday, June 9, 2013
ssh login without password
Generate ssh key for your host pc
=> $ssh-keygen<enter>
Copy the key generated to remote pc to where you wish to login via ssh.
=>ssh-copy-id -i ~/.ssh/id_rsa.pub <userid>@<remote ip>
that's it! you should be able to login without prompting for password.
virtualbox arch linux access via ssh
to access virtualbox guest via ssh from your host,
- on host do modprobe on following modules - vboxdrv, vboxnetadp, vboxnetflt
- If any of the modules not found, you should have installed linux-headers and virtualbox-host-dkms before on your host.
- keep your guest shutdown
- open virtualbox GUI
- go to file->preferences->network
- add a host-only network , this will add interface called vboxnet0 on your host.
- once added vboxnet0, on the same window, click edit , which will show you default ip settings (start ip, netmask, gateway etc)that you can make use of , to set ip manually/dynamically. If you plan to ssh to guest later, you probably want to disable dhcp server, as the ip keeps changing if dhcp is enabled. on the 2nd tab in the edit window, uncheck dhcp server.
- Now, go to individual guest settings on virtualbox gui
- go to network option
- You should already be seeing a NAT adapter being added. Add adapter2 as host-only network adapter.
- chose vboxnet0 as the interface.
- click ok and exit.
- start your guest.
- when you do ifconfig -a, you will observe that one more network interface is added to the existing list. if you did not find., perform step #1 and #2 on guest also.(reboot if necessary).
- you can assign a static ip like on any other linux host, for example, "ifconfig eth1 192.168.56.99 netmask 255.255.255.0 up".
- To make it work across reboot, you may need prepare a file called /etc/network/interfaces. google for format of the file.
- If you are using arch-linux, you will have to add file called /etc/systemd/system/network.service. Look for the format of this file in wiki.archlinux/networking
- usually the commands used are /usr/bin/ip addr .. etc. I installed net-tools and and added ifconfig command as in #15. Keep in mind that you wil lhave to provide full binary path for ifconfig.
- once added, you need to enable it. perform "systemctl enable network". This will enable the service across reboot.
- if this fails, perform "systemctl status network.service" to check what's going wrong.
On a technical explanation side, virtualbox provides 3 types of networking facilities to guests.
- NAT(default). With this, any network packets from the guest is treated as a packet pumped from any process(virtualbox here) by host. Advantage is you don't need any tweaking to get this work, by default you will get IPs in the range 10.x.x.x... You will be able to access any network that your host is able to acess. Disadvantage is that the guest itself as a physical machine, is not accessible to external world(even to the host).
- host-only adapter: here, you will need to create an interface on host(vboxnet0). Need to load a driver vboxnetflt, that will acts as netowork filter to seprate out guest interface from host interface. virtualbox will internally create a router between guest and host, which makes host to see guest as a different machine all toghether(you can ssh to guest from host). advantage as well as disadvantage is that, guest will be visible only to host and other VMs but not to the external world as the IP is obtained form dhcp server of the host.
- bridged adapter: this will expose the guest as a remote PC to the external world also. Ip is obtained from the same dhcp server from which host is getting it.
- internal network: Only to connect VMs on the same host.
- bridged ad
Monday, June 3, 2013
Shell script: IF file/string operators
Shell script: IF file/string operators
bash Shell script: IF statement file/string operators
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
Shell script: IF file/string operators
comment multiple lines in vim
- keep the cursor on the first letter of first line to comment
- in command mode, press ctrl + v
- move cursor down until last line to comment
- press I (you may not see vim going to insert mode, don't worry, you will see cursor moving to first line)
- press # (you may not see # inserted yet, don't worry)
- press Escape ( you should see lines commented out, otherwise, press escape two times)
Wednesday, May 29, 2013
"For example, I...
"For example, I was taught in college that one ought to figure out a program completely on paper before even going near a computer. I found that I did not program this way. I found that I liked to program sitting in front of a computer, not a piece of paper. Worse still, instead of patiently writing out a complete program and assuring myself it was correct, I tended to just spew out code that was hopelessly broken, and gradually beat it into shape. Debugging, I was taught, was a kind of final pass where you caught typos and oversights. The way I worked, it seemed like programming consisted of debugging.
For a long time I felt bad about this, just as I once felt bad that I didn't hold my pencil the way they taught me to in elementary school. If I had only looked over at the other makers, the painters or the architects, I would have realized that there was a name for what I was doing: sketching. As far as I can tell, the way they taught me to program in college was all wrong. You should figure out programs as you're writing them, just as writers and painters and architects do. "
"Universities and research labs force hackers to be scientists, and companies force them to be engineers"
- Paul Graham
"For example, I...
"For example, I was taught in college that one ought to figure out a program
completely on paper before even going near a computer. I found that I did not
program this way. I found that I liked to program sitting in front of a computer,
not a piece of paper. Worse still, instead of patiently writing out a complete
program and assuring myself it was correct, I tended to just spew out code that
was hopelessly broken, and gradually beat it into shape. Debugging, I was
taught, was a kind of final pass where you caught typos and oversights. The way
I worked, it seemed like programming consisted of debugging.
For a long time I felt bad about this, just as I once felt bad that I didn't hold my
pencil the way they taught me to in elementary school. If I had only looked over
at the other makers, the painters or the architects, I would have realized that
there was a name for what I was doing: sketching. As far as I can tell, the way
they taught me to program in college was all wrong. You should figure out
programs as you're writing them, just as writers and painters and architects do.
"
- Paul Graham
Monday, May 27, 2013
Ubuntu: youtube downloader
To download youtube videos or any embedded videos from websites,
- Install firfox if you don't have it on your system.
- open firefox web browser
- go to Tools->Add Ons
- search for video downloadHelper
- the "video downloadHelper" add on will appear in search results.
- install the add on.
- restart the firefox.
- open youtube.
- click on some video.
- to the left of address bar in firefox, you will see one animated bubbles playing, which means the particular website has an embedded video to download.
- click on it and download the video.
- DONE.