Skip to content

Instantly share code, notes, and snippets.

Avatar
👽
Writing code from another galaxy.

Douglas Miranda douglasmiranda

👽
Writing code from another galaxy.
View GitHub Profile
@douglasmiranda
douglasmiranda / last_tweet.js
Created Jun 23, 2011
Get the last tweet. (Requires the Jquery library)
View last_tweet.js
$(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 Jun 28, 2011
Enable mod_rewrite apache (I always forget)
View mod_rewrite
a2enmod rewrite
@douglasmiranda
douglasmiranda / mb_convert_case.php
Created Jun 28, 2011
[PHP strtolower, strtoupper, mb_convert_case] - Fix problems with accentuation / Corrigindo problemas de acentuação
View mb_convert_case.php
<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 Jun 30, 2011
PaseInt PHP equivalent to the Javascript
View parse_int.php
<?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 Jul 5, 2011
Remove www in url (.htaccess snnipet)
View remove-www-in-url.conf
#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 Jul 11, 2011
Animate hover effect on links (CSS -webkit-transition)
View hover-effect-webkit-transition.css
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 Jul 14, 2011
Simple string reverse (Python)
View string-reverse.py
string = 'my test'
string = string[::-1]
print string #tset ym
@douglasmiranda
douglasmiranda / url-rewrite.conf
Created Jul 21, 2011
Apache Url Rewrite (using in Zend Framework)
View url-rewrite.conf
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 Jul 26, 2011
Comparison operations. Python & Erlang //Useful for beginners, like me :)
View operators_python_erlang.txt
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 Aug 2, 2011
Make a tr clickable with the existing link in td
View make_tr_clickable.js
$('table a').each(function(){
$(this).parent().parent().click(function(){
location.href = $(this).find('a').attr('href');
});
});
You can’t perform that action at this time.