how to align controls left, center and right

<mx:Grid width="100%" >
     <mx:GridRow width="100%" >
          <mx:GridItem horizontalAlign="left"  width="33%" >
               <s:Label text="Left" />
          </mx:GridItem>

          <mx:GridItem horizontalAlign="center"  width="33%" >
               <s:Label text="center" />
          </mx:GridItem>

          <mx:GridItem horizontalAlign="right"  width="34%" >
               <s:Label text="Right" />
          </mx:GridItem>
     </mx:GridRow>

</mx:Grid>

source

reset

/*###################################################*/
/*##################  RESET  ########################*/
/*###################################################*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
	margin: 0;
	padding: 0;
	border: 0;
	outline: 0;
	font-size: 100%;
	vertical-align: baseline;
	background: transparent;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}

:focus {
	outline: 0;
}

ins {
	text-decoration: none;
}
del {
	text-decoration: line-through;
}

table {
	border-collapse: collapse;
	border-spacing: 0;
}

source

HTML5 boilerplate with comments

<!doctype html>
<html lang="en" class="no-js">
<head>
  <meta charset="utf-8">

  <!-- <a href="http://www.phpied.com/conditional-comments-block-downloads/">www.phpied.com/conditional-comments-block-downloads/</a> -->
  <!--[if IE]><![endif]-->

  <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame 
       Remove this if you use the .htaccess -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <title></title>
  <meta name="description" content="">
  <meta name="author" content="">

  <!--  Mobile Viewport Fix
        j.mp/mobileviewport & davidbcalhoun.com/2010/viewport-metatag 
  device-width : Occupy full width of the screen in its current orientation
  initial-scale = 1.0 retains dimensions instead of zooming out if page height > device height
  maximum-scale = 1.0 retains dimensions instead of zooming in if page width < device width
  -->
  <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">


  <!-- Place favicon.ico and apple-touch-icon.png in the root of your domain and delete these references -->
  <link rel="shortcut icon" href="/favicon.ico">
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">


  <!-- CSS : implied media="all" -->
  <link rel="stylesheet" href="css/style.css?v=1">

  <!-- For the less-enabled mobile browsers like Opera Mini -->
  <link rel="stylesheet" media="handheld" href="css/handheld.css?v=1">

 
  <!-- All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects -->
  <script src="js/modernizr-1.5.min.js"></script>

</head>

<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->

<!--[if lt IE 7 ]> <body class="ie6"> <![endif]-->
<!--[if IE 7 ]>    <body class="ie7"> <![endif]-->
<!--[if IE 8 ]>    <body class="ie8"> <![endif]-->
<!--[if IE 9 ]>    <body class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <body> <!--<![endif]-->

  <div id="container">
    <header>

    </header>
    
    <div id="main">

    </div>
    
    <footer>

    </footer>
  </div> <!--! end of #container -->


  <!-- Javascript at the bottom for fast page loading -->

  <!-- Grab Google CDN's jQuery. fall back to local if necessary -->
  <script src="<a href="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>" >http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script></a>
  <script>!window.jQuery && document.write('<script src="js/jquery-1.4.2.min.js"></script>')</script>


  <script src="js/plugins.js?v=1"></script>
  <script src="js/script.js?v=1"></script>

  <!--[if lt IE 7 ]>
    <script src="js/dd_belatedpng.js?v=1"></script>
  <![endif]-->


  <!-- yui profiler and profileviewer - remove for production -->
  <script src="js/profiling/yahoo-profiling.min.js?v=1"></script>
  <script src="js/profiling/config.js?v=1"></script>
  <!-- end profiling code -->


  <!-- asynchronous google analytics: mathiasbynens.be/notes/async-analytics-snippet 
       change the UA-XXXXX-X to be your site's ID -->
  <script>
   var _gaq = [['_setAccount', 'UA-XXXXX-X'], ['_trackPageview']];
   (function(d, t) {
    var g = d.createElement(t),
        s = d.getElementsByTagName(t)[0];
    g.async = true;
    g.src = '//www.google-analytics.com/ga.js';
    s.parentNode.insertBefore(g, s);
   })(document, 'script');
  </script>
  
</body>
</html>

source

Fun.py: Short a url from command line, using fun.ly service

#!/ usr/bin/env python
#
#   fun.py
#   short a url using <a href="http://fun.ly" >http://fun.ly</a> shortener service.
#   ksaver (at identi.ca)
#   Public Domain Code.

import urllib
import urllib2
import sys

from BeautifulSoup import BeautifulSoup as cooksoup

def shorten(longurl):
    uagent    = 'Opera/9.80 (X11; FreeBSD 8.1-RELEASE i386; U; en)
    Presto/2.6.30 Version/10.62'
    headers   = {'User-Agent': uagent}
    shortener = '<a href="http://fun.ly/'" >http://fun.ly/'</a>
    webparams = {'funly': longurl}
    encparams = urllib.urlencode(webparams)
    urlreqst  = urllib2.Request(shortener, encparams, headers)
    htmlpage  = urllib2.urlopen(urlreqst).read()
    soup      = cooksoup(htmlpage)
    shorturl  = soup.findAll('p')[1].text
    return shorturl

def main(argv):
    if len(argv) > 1:
        shorturl = shorten(argv[1])
    else:
        longurl  = raw_input("Give me a URL: ")
        shorturl = shorten(longurl)
        
    print "%s" % shorturl
    
if __name__ == '__main__':
    main(sys.argv)

source

Check if Variable Exists

if(myVar == "" || myVar == undefined){
//It has no value OR doesn't exist at all
...
} else {
...
}

source

Rewrite underscores to hyphens for SEO URL

Options  FollowSymLinks
RewriteEngine On
RewriteBase /
 
RewriteRule !.(html|php)$ - [S=6]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5-$6-$7 [E=underscores:Yes]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5-$6 [E=underscores:Yes]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=underscores:Yes]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=underscores:Yes]
RewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=underscores:Yes]
RewriteRule ^([^_]*)_(.*)$ $1-$2 [E=underscores:Yes]
 
RewriteCond %{ENV:underscores} ^Yes$
RewriteRule (.*) <a href="http://www.askapache.com/$1" >http://www.askapache.com/$1</a> [R=301,L]

source

Obtener ID de un video de Youtube

/<a href="http://(?:youtu.be/|(?:[a-z]{2,3}.)?youtube.com/watch(?:?|#!)v=)([w-]{11}).*/gi

" >http://(?:youtu.be/|(?:[a-z]{2,3}.)?youtube.com/watch(?:?|#!)v=)([w-]{11}).*/gi
source

Validação de CPF

//CPFFFFFFFF
function validaCPF($cpf)
{		
// Verifica se nenhuma das sequências abaixo foi digitada, caso seja, retorna falso
if (strlen($cpf) != 11 || $cpf == '00000000000' || $cpf == '11111111111' || $cpf == '22222222222' || $cpf == '33333333333' || $cpf == '44444444444' || $cpf == '55555555555' || $cpf == '66666666666' || $cpf == '77777777777' || $cpf == '88888888888' || $cpf == '99999999999')
{
return false;
}
else
{   // Calcula os números para verificar se o CPF é verdadeiro
for ($t = 9; $t < 11; $t++) {
for ($d = 0, $c = 0; $c < $t; $c++) {
$d += $cpf{$c} * (($t + 1) - $c);
}

$d = ((10 * $d) % 11) % 10;

if ($cpf{$c} != $d) {
return false;
}
}

return true;
}
}


//Para usar

$valid = validaCPF("".$_GET['cpf']."");

if($valida==true){  }

source

Geolocation

<html>
<head>

<script type="text/javascript">

if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(successFunction, errorFunction);
  } else {
  alert('Geolocation Not Support');
}

function successFunction(position) {
        var lat = position.coords.latitude;
        var long = position.coords.longitude;
		alert('Latitude:'+lat+' Longitude:'+long);
		document.write (lat);
		document.write (long);
}

function errorFunction(position) {
  alert('Error!');
}


</script>

</head>
<body>

</body>
</html>

source

Gradient Background Class

/**
 *
 * Gradient Background
 * 
 * usage: var myBg =new GradientBackground(100,100,0xffffff,0x000000,4,1);

 * params: width, height, top color, bottom color, corner radius, alpha 

 * 
 * @author Chuckanucka 
 * @version1.0
 
 **/
 
package com.chuck.effects{

	// import needed classes 
	import flash.display.MovieClip;
	import flash.display.Graphics;
	import flash.display.GradientType;
	import flash.display.SpreadMethod;
	import flash.geom.*;


	public class GradientBackground extends MovieClip {

		public function GradientBackground(bgWidth:Number,bgHeight:Number,topColor:Number=0xffffff,bottomColor:Number=0x000000,cornerRadius:Number=0,bgAlpha:Number=1) {
			// gradient defaults 
			var gradType:String=GradientType.LINEAR;
			var gradAlphas:Array=[1,1];
			var gradRatios:Array=[0,255];
			var sprMethod:String=SpreadMethod.PAD;
			var gradColors:Array;

			gradColors=[topColor,bottomColor];
			var gradMatrix:Matrix=new Matrix  ;
			gradMatrix.createGradientBox(bgWidth,bgHeight,Math.PI/180*90,0,0);
			var newBg:MovieClip=new MovieClip  ;
			var newGraphic:Graphics=newBg.graphics;   
			newGraphic.beginGradientFill(gradType,gradColors,gradAlphas,gradRatios,gradMatrix,sprMethod);
			newGraphic.drawRoundRect(0,0,bgWidth,bgHeight,cornerRadius);
			newBg.alpha = bgAlpha
			addChild(newBg);
		}
	}
}

source