Skip to content

Instantly share code, notes, and snippets.

View douglasmiranda's full-sized avatar
👽

Douglas Miranda douglasmiranda

👽
  • Earth, Brazil
View GitHub Profile
@douglasmiranda
douglasmiranda / remove-www-in-url.conf
Created July 5, 2011 17:05
Remove www in url (.htaccess snnipet)
#Paste in your .htaccess file, and the requests www.yoursite.com will be redirected to http://yoursite.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^yoursite.com$ [NC]
RewriteRule ^(.*)$ http://yoursite.com/$1 [L,R=301]
@douglasmiranda
douglasmiranda / parse_int.php
Created June 30, 2011 15:44
PaseInt PHP equivalent to the Javascript
<?php
/**
* Just a parse int function, like the parseInt(string) from Javascript
*/
// If your PHP version is < 5.2, this is the solution:
function parse_int($string) {
$size_of_string = strlen($string);
for ($i = 0; $i < $size_of_string; $i++) {
if (is_numeric($string[$i]))
@douglasmiranda
douglasmiranda / mb_convert_case.php
Created June 28, 2011 16:06
[PHP strtolower, strtoupper, mb_convert_case] - Fix problems with accentuation / Corrigindo problemas de acentuação
<html>
<head>
<title>Using mb_convert_case</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
// PHP still have problems with unicode, so Multi Byte functions solve part of this problem.
// For more information: http://www.php.net/manual/en/ref.mbstring.php
@douglasmiranda
douglasmiranda / mod_rewrite
Created June 28, 2011 14:26
Enable mod_rewrite apache (I always forget)
a2enmod rewrite
@douglasmiranda
douglasmiranda / last_tweet.js
Created June 23, 2011 18:28
Get the last tweet. (Requires the Jquery library)
$(document).ready(function(){
$.getJSON("http://twitter.com/statuses/user_timeline/YOUR_TWITTER_USERNAME.json?callback=?", function(data) {
$("#last-tweet").html(data[0].text);
});
});