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 / 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);
});
});
@douglasmiranda
douglasmiranda / mod_rewrite
Created June 28, 2011 14:26
Enable mod_rewrite apache (I always forget)
a2enmod rewrite
@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 / 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 / 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 / hover-effect-webkit-transition.css
Created July 11, 2011 16:25
Animate hover effect on links (CSS -webkit-transition)
a {
color:green;
-webkit-transition-property: color;
-webkit-transition-duration: 0.5s;
-webkit-transition-timing-function: linear;
}
a:hover {
color: red;
}
@douglasmiranda
douglasmiranda / string-reverse.py
Created July 14, 2011 21:43
Simple string reverse (Python)
string = 'my test'
string = string[::-1]
print string #tset ym
@douglasmiranda
douglasmiranda / url-rewrite.conf
Created July 21, 2011 04:50
Apache Url Rewrite (using in Zend Framework)
RewriteEngine on
# rules
RewriteRule !\.(js|ico|txt|gif|jpg|png|css|rar|zip|jpeg|swf|xml|robots\.txt)$ index.php
@douglasmiranda
douglasmiranda / operators_python_erlang.txt
Created July 26, 2011 01:47
Comparison operations. Python & Erlang //Useful for beginners, like me :)
Python Erlang Description Erlang Example
--------+--------+-----------------------+----------------
< < strictly less than
--------+--------+-----------------------+----------------
<= =< less than or equal
--------+--------+-----------------------+----------------
> > strictly greater than
--------+--------+-----------------------+----------------
>= >= greater than or equal
--------+--------+-----------------------+----------------
@douglasmiranda
douglasmiranda / make_tr_clickable.js
Created August 2, 2011 22:31
Make a tr clickable with the existing link in td
$('table a').each(function(){
$(this).parent().parent().click(function(){
location.href = $(this).find('a').attr('href');
});
});