Skip to content

Instantly share code, notes, and snippets.

View hedcler's full-sized avatar

Hedcler Morais hedcler

View GitHub Profile
@hedcler
hedcler / helpers.php
Created April 18, 2012 17:23
Remove caracteres acentuados com PHP
<?php
function tirarAcento($string){
$comAcento = array('à','á','â','ã','ä','å','ç','è','é','ê','ë','ì','í','î','ï','ñ','ò','ó','ô','õ','ö','ù','ü','ú','ÿ','À','Á','Â','Ã','Ä','Å','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ñ','Ò','Ó','Ô','Õ','Ö','O','Ù','Ü','Ú','Ÿ','ª','º','+','*',"\"", "\\", "/");
$semAcento = array('a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','n','o','o','o','o','o','u','u','u','y','A','A','A','A','A','A','C','E','E','E','E','I','I','I','I','N','O','O','O','O','O','O','U','U','U','Y','a','o','+','','','','');
$novaString = str_replace($comAcento, $semAcento, $string);
return $novaString;
}
?>
@hedcler
hedcler / fql_multiquery.txt
Created May 4, 2012 18:43
Facebook FQL Multiquery para pegar fotos de um usuário
GRAPH API /fql ?q= {
"albuns":"SELECT aid FROM album WHERE owner = USER_ID",
"photos":"SELECT src_big FROM photo WHERE aid IN (SELECT aid FROM #albuns)"
}
@hedcler
hedcler / gist:3144416
Created July 19, 2012 14:43 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@hedcler
hedcler / pageIsLiked.php
Created July 20, 2012 19:03
Verify if user like my Facebook FãPage
<?php
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
if (empty($data["page"]["liked"])) {
echo "You are not a fan!";
} else {
echo "Welcome back fan!";
}
@hedcler
hedcler / get_images_src_from_html.php
Created July 27, 2012 19:25
Get first image from content
<?php
$HTML = "";
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $HTML, $matches);
$first_img = $matches [1] [0];
?>
@hedcler
hedcler / map.js
Created July 27, 2012 22:31
Re-maps a number from one range to another. In the example above, the number '25' is converted from a value in the range 0..100 into a value that ranges from the left edge (0) to the right edge (width) of the screen. Numbers outside the range are not cla
var map = function(value, istart, istop, ostart, ostop) {
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart))
};
@hedcler
hedcler / gist:3343731
Created August 13, 2012 20:01
Adicionando aba no Facebook
https://www.facebook.com/dialog/pagetab?app_id=XXXXXXXXX&display=popup&next=HTTPURL
@hedcler
hedcler / list_collaborators.php
Created September 27, 2012 21:21
Wordpress_Listar_Autores
<?
function list_collaborators() {
global $wpdb;
$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");
foreach($authors as $author) {
$author_name = get_the_author_meta('display_name', $author->ID);
echo "<li>" .
"<a href=\"".get_author_posts_url( $author->ID, $author_name ). "\">" .
$author_name .

This uses Twitter Bootstrap classes for CodeIgniter pagination.

Drop this file into application/config.

@hedcler
hedcler / gist:e8284f6ffa819eb7f48a
Created July 18, 2014 23:34
Funções para calcular intervalo de tempo
<?php
function truncate($value) {
$parts = explode('.',$value);
return $parts{0};
}
function sum_the_time($time1, $time2) {
$seconds = 0;