Programming and more

Entries for January, 2013

How to install git on centos with yum

# Add the repository rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm   # Install the latest version of git yum install –enablerepo=webtatic git-all# Add the repository rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm # Install the latest version of git yum install –enablerepo=webtatic git-all Clean, simple and it works!

How to make google analytics work with jquery mobile site

Google analytics doesn’t work with jquery mobile websites. Luckily, I found the way to make this work. Basically you have to break the code into 2 parts:     <script> var _gaq = _gaq || []; _gaq.push([’_setAccount’, ‘UA-xxxxxx-xx’]);   (function() { var ga = document.createElement(’script’); ga.type = ‘text/javascript’; ga.async = true; ga.src = (’https:’ == […]

How to filter a string and keep only numbers with java

Just run this code:   str = str.replaceAll("[^0-9]+","");str = str.replaceAll("[^0-9]+",""); This means: replace everything that is not number with empty string (“”)

How to see what programs use the most memory in linux

You have to run:   ps aux | sort -nk +4ps aux | sort -nk +4 That will print you a list of all the running applications and it wil sort them by the 4th column (memory) The same can be applied for CPU, Virual memory etc. Just change the -nk +4 value to +3 […]

Programmatically Build forms with PHP

I needed a way to programmatically build forms with php so that I can easily print them in any template, so that when I change template I don’t have to copy paste and fix forms all over again. So to solve this I needed some php code to automatically build forms. For me there are […]

jQuery Mobile 1.2.0 – How to disable the ajax loading and effects (and show adsense on jquery mobile!)

I had this problem, I wanted to add adsense advertisments to one of my mobile sites, but you can’t see the ads if the page loads with ajax. So I needed to disable it. The first solution was this: <script language="javascript">   $.mobile.ajaxLinksEnabled = false;   </script><script language="javascript"> $.mobile.ajaxLinksEnabled = false; </script> But after updating […]

How to add expires headers on css, javascript and image files

I tried many things I found googling but nothing work, until I saw this: Assuming you are using apache, what you must do is go to you public_html folder, create a file .htaccess and paste in it:     <FilesMatch "\.(ico|pdf|flv|jpe?g|png|gif|js|css|swf)$"> ExpiresActive On ExpiresDefault "access plus 1 year" </FilesMatch> <FilesMatch "\.(ico|pdf|flv|jpe?g|png|gif|js|css|swf)$"> ExpiresActive On ExpiresDefault "access […]

How to install apache mod_expires In directadmin DA centos linux

cd /usr/local/directadmin/custombuild mkdir -p custom/ap2 cp configure/ap2/configure.apache custom/ap2/configure.apache vi custom/ap2/configure.apachecd /usr/local/directadmin/custombuild mkdir -p custom/ap2 cp configure/ap2/configure.apache custom/ap2/configure.apache vi custom/ap2/configure.apache add: –enable-expires so it looks like this: #!/bin/sh "./configure" \ "–prefix=/etc/httpd" \ "–exec-prefix=/etc/httpd" \ "–bindir=/usr/bin" \ "–sbindir=/usr/sbin" \ "–sysconfdir=/etc/httpd/conf" \ "–enable-so" \ "–enable-dav" \ "–enable-dav-fs" \ "–enable-dav-lock" \ "–enable-suexec" \ "–enable-deflate" \ "–enable-unique-id" \ "–with-suexec-caller=apache" \ […]

Create Easy charts with php/javascript/flash

I was looking yesterday for a way to create a simple chart (Dates and values). I wanted some library to include into the MVC-CMS I created so that I can use everytime I want something. Open Flash Chart I knew Open Flash Chart from before. http://teethgrinder.co.uk/open-flash-chart-2/ You can see it in action here: http://www.radiotower.gr/station_details.php?id=12028. Looks pretty […]

jquery jQueryUI autocomplete – how to submit form on selection

jQueryUI Autocomplete http://jqueryui.com/autocomplete/ is a excelent tool to create ajax/javascript google suggest style automplete forms. You can see an example in the site radiotower.gr List changes when the user types something. It’s really cool and easy to implement. I was faced with one problem though. I wanted to automatically submit the form when the user […]