Programming and more

Entries for the ‘Programming’ Category

Movie information APIs for you

Hello and welcome, I am thinking of creating some website for users to comment on movies. But since there are a lot of movies, there are 2 ways to get all the movie data: Allow the users to insert their favorite movie and all their data, Find some API and collect the information automatically. I […]

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 find how many days are there between dates

I was writting a car rental application for some customer, when i came across this problem. Fortunatelly I found the  solution easier that I thought. You have to love google! So here is the solution: Takes into account leap years and it’s tested and it works great.     function dateDiff($start, $end) { $start_ts = […]

How to configure Notepad++ to automatically close brackets (parenthesis, brackets, quotes etc)

Notepad++ if my new favorite text editor. I use it all the time, especially when I program with php. So what I really need is an auto close brackets feature, this really speed’s up my programming.   So the best way to do that is to download this plugin: http://sourceforge.net/projects/npp-plugins/files/XBrackets%20Lite/ Download unzip and put into […]

Make a POST request with php (No curl or anything else needed)

I found this great post here: http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/ that explains how to make a POST request with php, no curl needed. This is very convinient in many situations. For example I wanted to get the pagerank of some page for some project I am working on. Getting pagerank is hard, you have to know datacenter ips […]

How to get alexa rank with PHP

Ok usefull function for many people. After some googling I give you the easiest way to get the alexa rank: <? $url="toolspot.org"; function getAlexa($url) { $xml = simplexml_load_file(’http://data.alexa.com/data?cli=10&dat=snbamz&url=’.$url); $rank=(int)$xml->SD[1]->POPULARITY->attributes()->TEXT; $web=(string)$xml->SD[1]->POPULARITY->attributes()->URL; return $rank; } echo $url." has Alexa Rank ".getAlexa($url);     function alexaRank($domain) { $remote_url = ‘http://data.alexa.com/data?cli=10&dat=snbamz&url=’.trim($domain); $search_for = ‘<POPULARITY URL’; $part=”; if ($handle = […]

How to import .sql file with php

I am writing an MVC framework with php, and a Content Management System on top of it. As part of that MVC Framework I created an automatic module installer. A part of that installation script is to take an SQL file and import it into the database. Unfortunately this isn’t as easy as it sounds. […]

Disable stopwords in mysql Full text index

Disable stopwords in mysql Full text index if you didn’t know what full text index for mysql is google it. It makes searches for text much faster than using “where text like ‘%keywod1%’ AND text like ‘%keyword2%’. (at least 100 times faster) That trick saved me in a when I had an overloaded server. Anyway, […]

Create a tuple that has only one item, Python

Tuples are lists that are immutable (cannot be changed). To create a tuple with one item you have to use a comma: single = (2,)single = (2,) If you just type single = (2)single = (2) This will give you a variable containing 2

How to sort a list in Python

Sorting a list in Python is very very easy. psychedelics= [] psychedelics.append("lsd") psychedelics.append("dmt") psychedelics.append("thc")   psychedelics.sort()   print psychedelicspsychedelics= [] psychedelics.append("lsd") psychedelics.append("dmt") psychedelics.append("thc") psychedelics.sort() print psychedelics This will sort your list. If you want to return a new list, and never change the old list you can use sorted: psychedelics= [] psychedelics.append("lsd") psychedelics.append("dmt") psychedelics.append("thc")   […]