Skip to main content

Posts

interesting perl regexes

Few perl regexes for reference and worth noting. How do i remove consecutive pair of characters? ``` laptop:~/Perl2$ cat test.txt this is a test file ffor cchecking ddouble cchars. laptop:~/Perl2$ cat test.txt|perl -pane 's/(.)\g1/$1/g' this is a test file for checking double chars. ``` Here , the (.) is used to capture the character and the \g1 is used to find if the stored value is the same as the one immediately following it. And then we replace that with $1 How do i find matching/nesting anything? To find something between two single characters, a pattern like /x([^x]*)x/ will get the intervening bits in $1. For multiple ones, then something more like /alpha(.*?)omega/ would be needed.

linux disown!

nohup or disown nohup if you haven't started the job yet and want to run it in the background. disown if its already running... so Ctrl + z to detach, bg to background and then disown (jobid) to make it run in the background!

skype sound issues with ubuntu 13.10

Skype on my ubuntu 13.10 had issues with sound and I was not able to make or receive calls. The pulse audio would just give out a blaring sound when i started the skype app or when i tried to make or receive calls. Fiddling with the sound settings got nowhere, so i started googling and the below update fixed this issue! ==== sudo sed -i 's/^Exec=.*/Exec=env PULSE_LATENCY_MSEC=30 skype %U/' /usr/share/applications/skype.desktop ==== thanks webupd8.org!

virtualbox ubuntu and getting the image to work!

problems 1. network access! not a fix yet.. I had to add two interfaces one NAT and one HOST only 2. keyboard layout dpkg-reconfigure console-setup # this works across reboots! console-data is just for the session 3. fixing eth1/2 numbers to have eth0/1 Modify the entries in /etc/udev/rules.d/70-persistent-cd.rules and reboot OR sudo udevadm trigger

best educational experiences..

The best educational experiences are when we work hard for it, when we apply ourselves and think over solutions/possibilities and try to infer things if we are not sure. In college, there were friends with whom we discussed topics, debated possible approaches to problems. Today, I attend interviews! What better ways to know your weaknesses, strengths and different perspectives on technology or implementation!

ubuntu 12, dns and some releated stuff..

In ubuntu 12.04 dig and nslookup work differently, dig and nslookup are dns server checking tools and they connect directly to DNS servers, but the internal applications like puppet do not work like dig / nslookup they use a different linux /unix function (gethostname) which can be executed using "getent ahosts", you can also verify if your entry is working by executing the below mentioned commands. getent ahosts => will list all host output using gethostname()

back to perlistan..

Well, I just realized i have lost touch and almost forgotten whatever little programming/scripting i knew and did. Visiting back my perl lessons and trying to script something up on ubuntu with perl and dancer! Just noting the steps here as ive been setting this on multiple machines due to vm crashes or whatever.. Installed sudo aptitude install apache2 libapache2-mod-perl2 modify the default conf to the below: <VirtualHost *:80>         ServerAdmin webmaster@localhost         DocumentRoot /var/www         SetEnv DANCER_ENVIRONMENT "development" <Directory /var/www>         AllowOverride None         Order allow,deny         Allow from all </Directory> <Location />         SetHandler perl-script         PerlHandler Plack::Handler::Apache2         PerlSetVar psg...