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 / 1ntro.markdown
Last active January 13, 2020 03:28
Django + git + apache mod_wsgi na Kinghost

#Django + git + apache mod_wsgi na Kinghost

NOTE: Atualmente não é necessário tanto para fazer deploy de aplicações Django na Kinghost.

I hope you like it!

##Início

Talvez você não queira ficar digitando a senha toda vez que usar o ssh, então adicione sua chave pública ao seu host:

@douglasmiranda
douglasmiranda / get-latest-videos.js
Created September 21, 2011 15:05
Get latest videos from Youtube with Jquery (Gdata API)
function show_my_videos(data){
html = ['<ul id="youtube-videos">'];
$(data.feed.entry).each(function(entry){
url = this.link[0].href;
url_thumbnail = this.media$group.media$thumbnail[3].url;
description = this.media$group.media$description.$t;
html.push('<li><a href="'+url+'">');
html.push('<img src="'+url_thumbnail+'" alt="'+description+'">');
html.push('</a></li>');
});
@douglasmiranda
douglasmiranda / mb_substr.php
Created August 24, 2011 20:38
How to get substring from accented words (UTF-8)
<?php
/**
* How to get substring UTF-8 characters
*/
// If you try something like this
$utf_8_characters = 'Sábado';
echo substr($utf_8_characters, 0, 3);
// you get something like "Sá", but not "Sáb"
@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');
});
});
@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 / 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 / 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 / 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 / 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]))