Win·dows

 

Noun.
A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can’t stand one bit of competition.

From Code Fairy

 

The Code Fairy is a fictional spirit said to eat semicolons and curly braces from computer source code.
It is well known that the Windows code fairy has the largest wings but cannot fly. The Apple code fairy has the most beautiful wings but they are so small that everyone believes they don’t exist. The Linux code fairy looks different depending on who kissed it last. The UNIX code fairy looks like grumpy and old. The SCO-Linux code fairy looks like a lawyer and pursues anyone who kisses the Linux code fairy.
The Code Fairy is an example of folklore mythology which non-programmers know is fiction, but which is sometimes presented by computer programmers as fact, as a way of explaning how a computer program stops working after compiling it, without altering the source code.

-But they do exist!

Top 10 Signs You’ve Purchased A Bad iPhone 4

 

If you can see this, then you might need a Flash Player upgrade or you need to install Flash Player if it's missing. Get Flash Player from Adobe.

Hitler finds out about Opera 10.60

 

If you can see this, then you might need a Flash Player upgrade or you need to install Flash Player if it's missing. Get Flash Player from Adobe.

yet, i use the nightly builds of Chrome and they ROCK

Full Steve Jobs D8 Interview

 

Definitely worth watching.

Tracking outgoing links with Google Analytics new async code

 

After half an hour of looking on the damm documentation on Google Analytics Async code… screw it… did’t find some useful info about how tot track outgoing links so i stumble (not like stumbleupon) on this piece of code:

onload = function(){
var tracker = 'UA-XXXXXXX-X'; // change this
var domain = 'yourwebsite.tld'; // change this
var code = "var _gaq = _gaq||[];_gaq.push(['_setAccount', '" + tracker + "'],['_setDomainName', '" + domain + "'],['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);})();";
	var newScript = document.createElement('script');
	newScript.type = 'text/javascript';
	newScript.innerHTML = code;
	document.body.insertBefore(newScript, document.body.firstChild);
	var allA = document.getElementsByTagName('a');
	var domainRegex = new RegExp ( "http:\/\/" + domain.replace(".","\\.") , "i");
	if ( typeof(allA) != "undefined") {
		for (i = 0; i < allA.length; i++) {
			var newAttr = null;
			var newAttrText = null;
			var oldAttr = null;
			var href = allA[i].href;
			if (!href.match(domainRegex)) {
				newAttrText = href.replace(/http:\/\//i,"");
				if (newAttrText.length > 0) {
					if (allA[i].getAttribute("onclick") != null) {
						oldAttr = allA[i].getAttribute("onclick") + ";";
					}
					newAttr = document.createAttribute("onclick");
					if (oldAttr == null) newAttr.nodeValue = "_gaq.push(['_trackPageview', 'out/" + newAttrText + "'])";
					else newAttr.nodeValue = oldAttr + "_gaq.push(['_trackPageview', 'out/" + newAttrText + "'])";
					allA[i].setAttributeNode(newAttr);
				}
			}
		}
	}
}

basically it will dynamically add some code to all of your link in HTML

You will find the results in Google Analytics:

Found it at this nice fellow.

Clean up and url like WordPress does

 

So if you have a problem in making on the fly URL’s for your app, here is a small function for helping you with that.

function clean_url($str) {
	$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $str);
	$clean = strtolower(trim($clean, '-'));
	$clean = preg_replace("/[\/_|+ -]+/", '-', $clean);

	return $clean;
}

Here is a small demo:

thi$ i$ and URL made on the fly with șome șpecîal chars like % and # and @ that they don't need to apear ok?

will return:

thi-i-and-url-made-on-the-fly-with-ome-pecal-chars-like-and-and-that-they-dont-need-to-apear-ok

Like it?

Automatic WordPress installer via php and exec

 

So the thing is i am tired to log into shell, to wget the latest wordpress zip, unzip it and then login via SFTP and move some folders… to much hassle.
So after 20 minutes of work and trying to figure why the mv command is not moving my folders and just the files i did it :’)

The script just get’s the latest version of WordPress and unzip it in the folder that you put the script:

$local = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/'));
exec("wget wordpress.org/latest.zip");
exec("unzip latest.zip");
exec("mv $local/wordpress/*.* $local/");
exec("mv $local/wordpress/wp-includes $local/");
exec("mv $local/wordpress/wp-admin $local/");
exec("mv $local/wordpress/wp-content $local/");
exec("rm -rf wordpress"); /*useles folder :') */
exec("rm w.php"); /* security shit */
$link = substr($_SERVER["REQUEST_URI"], 0, strrpos($_SERVER["REQUEST_URI"], '/'));
echo "done. <a href=\"$link\">Go to the blog</a>. kthxbye"; /* commodity shit */

If you wan’t this to work you need to have access to the exec command and don’t have Romanian hosting :)

new toys revealed at Google I/O

 


Google I/O is the annual Google developer conference full of geeky stuff. This year i found some nice tools that i think they will be cool to see and implement :’)

Random order:

AdSense for Ajax
Google Storage a big hit for Amazon S3
An API for predicting stuff – Prediction API
BigQuery – a DB in the cloud like Amazon RDS but only running on BigTable and Google’s infrastructure and not tons of cheap servers like Amazon does

Cool no!

Heart JSON, Fuck XML

 

Yea so i got a friend called SaltwaterC that has a friend called Json (it reads Jason) and i have met him… a lightweight dude, that can make your life easier.

Here is an simple example:

{
    "created_at": "Tue May 11 11:50:14 +0000 2010",
    "in_reply_to_screen_name": null,
    "favorited": false,
    "truncated": false,
    "source": "<a href=\"http://destroytwitter.com/\" rel=\"nofollow\">DestroyTwitter</a>",
    "in_reply_to_status_id": null,
    "place": null,
    "contributors": null,
    "user": {
        "notifications": false,
        "profile_background_tile": false,
        "profile_sidebar_fill_color": "1A1B1F",
        "description": "Anticrist Superstar Programmer, Head editor @ w2.ro, Pro Drinker, slaker and typo expert.",
        "lang": "en",
        "verified": false,
        "created_at": "Thu Jun 19 15:17:28 +0000 2008",
        "profile_sidebar_border_color": "1A1B1F",
        "profile_image_url": "http://a3.twimg.com/profile_images/842271117/ochelari_normal.jpg",
        "following": true,
        "followers_count": 1017,
        "screen_name": "necenzurat",
        "statuses_count": 9385,
        "profile_background_color": "000000",
        "url": "http://w2.ro",
        "time_zone": "Bucharest",
        "friends_count": 454,
        "contributors_enabled": false,
        "profile_text_color": "666666",
        "protected": false,
        "location": "Bucharest, Romania",
        "favourites_count": 15,
        "name": "Costin M.",
        "profile_background_image_url": "http://a3.twimg.com/profile_background_images/81980881/twtbg.png",
        "profile_link_color": "1e8f89",
        "id": 15169998,
        "geo_enabled": true,
        "utc_offset": 7200
    },
    "coordinates": null,
    "in_reply_to_user_id": null,
    "id": 13784107904,
    "geo": null,
    "text": "WikiLeaks has probably produced more scoops in its short life than the Washington Post has in the past 30 years http://p.ly/ad4rb"
}

And now Mr. XML

<?xml version="1.0" encoding="UTF-8"?>
<status>
  <created_at>Tue May 11 11:50:14 +0000 2010</created_at>
  <id>13784107904</id>
  <text>WikiLeaks has probably produced more scoops in its short life than the Washington Post has in the past 30 years http://p.ly/ad4rb</text>
  <source>&lt;a href="http://destroytwitter.com/" rel="nofollow"&gt;DestroyTwitter&lt;/a&gt;</source>
  <truncated>false</truncated>
  <in_reply_to_status_id/>
  <in_reply_to_user_id/>
  <favorited>false</favorited>
  <in_reply_to_screen_name/>
  <user>
    <id>15169998</id>
    <name>Costin M.</name>
    <screen_name>necenzurat</screen_name>
    <location>Bucharest, Romania</location>
    <description>Anticrist Superstar Programmer, Head editor @ w2.ro, Pro Drinker, slaker and typo expert.</description>
    <profile_image_url>http://a3.twimg.com/profile_images/842271117/
ochelari_normal.jpg</profile_image_url>
    <url>http://w2.ro</url>
    <protected>false</protected>
    <followers_count>1017</followers_count>
    <profile_background_color>000000</profile_background_color>
    <profile_text_color>666666</profile_text_color>
    <profile_link_color>1e8f89</profile_link_color>
    <profile_sidebar_fill_color>1A1B1F</profile_sidebar_fill_color>
    <profile_sidebar_border_color>1A1B1F</profile_sidebar_border_color>
    <friends_count>454</friends_count>
    <created_at>Thu Jun 19 15:17:28 +0000 2008</created_at>
    <favourites_count>15</favourites_count>
    <utc_offset>7200</utc_offset>
    <time_zone>Bucharest</time_zone>
    <profile_background_image_url>http://a3.twimg.com/profile_background_images/
81980881/twtbg.png</profile_background_image_url>
    <profile_background_tile>false</profile_background_tile>
    <notifications>false</notifications>
    <geo_enabled>true</geo_enabled>
    <verified>false</verified>
    <following>false</following>
    <statuses_count>9385</statuses_count>
    <lang>en</lang>
    <contributors_enabled>false</contributors_enabled>
  </user>
  <geo/>
  <coordinates/>
  <place/>
  <contributors/>
</status>

First of all:
JSON can be parser is one freaking like

$json = json_decode($file, true);

and the XML… well i don’t want to get into details

Second: the upper examples are in size:
JSON – 1,37 KB (1.406 bytes)
XML – 2,04 KB (2.090 bytes)
and yes, when you are doing an import of 15.000 products from XML every thing counts.