Skip to content

Instantly share code, notes, and snippets.

View wildiney's full-sized avatar

Wildiney Di Masi wildiney

View GitHub Profile
@wildiney
wildiney / detect-agent-user.js
Created December 18, 2011 17:46
Detecta Agent User
var useragent = navigator.userAgent;
useragent = useragent.toLowerCase();
if (useragent.indexOf('iphone') != -1 || useragent.indexOf('symbianos') != -1 || useragent.indexOf('ipad') != -1 || useragent.indexOf('ipod') != -1 || useragent.indexOf('android') != -1 || useragent.indexOf('blackberry') != -1 || useragent.indexOf('samsung') != -1 || useragent.indexOf('nokia') != -1 || useragent.indexOf('windows ce') != -1 || useragent.indexOf('sonyericsson') != -1 || useragent.indexOf('webos') != -1 || useragent.indexOf('wap') != -1 || useragent.indexOf('motor') != -1 || useragent.indexOf('symbian') != -1 ) {
document.location = "http://www.fabioandrezo.com.br/portfolio-assinaturas-visuais-mobile.html";
}
@wildiney
wildiney / wp_admin_bar_function.php
Created January 26, 2012 00:47
Wordpress - Barra de admin visivel somente para administradores
<?php
if (!current_user_can('manage_options')) {
add_filter('show_admin_bar', '__return_false');
}
@wildiney
wildiney / checkIframe.js
Created June 14, 2012 12:43
verificar se está dentro de iframe
if(location.href!=parent.location) {
alert("tá dentro do iframe")
} else {
alert("tá fora do iframe")
}
@wildiney
wildiney / apple_ready_icons.html
Created June 14, 2012 14:51
Apple Ready Icons
<link rel="apple-touch-icon-precomposed" href="images/apple-touch-icon.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="images/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="images/apple-touch-icon-114x114.png">
@wildiney
wildiney / wp_check_if_sidebar.php
Created September 21, 2012 13:00
Adiciona uma classe no body caso exista sidebar
<?php
function wpfme_has_sidebar($classes) {
if (is_active_sidebar('sidebar')) {
// add 'class-name' to the $classes array
$classes[] = 'has_sidebar';
}
// return the $classes array
return $classes;
}
add_filter('body_class','wpfme_has_sidebar');
@wildiney
wildiney / verifica_cartao.js
Created October 19, 2012 17:39
Função Javascript para validar cartão de crédito
function checkCard(num){
var msg = Array();
var tipo = null;
if(num.length > 16 || num[0]==0){
msg.push("Número de cartão inválido");
} else {
@wildiney
wildiney / sanitize_database_inputs.php
Created June 1, 2013 00:26
Sanitize database inputs
<?php
function cleanInput($input) {
$search = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments
);
@wildiney
wildiney / calculate_distance_between_two_points.php
Created June 1, 2013 00:27
Calculate distance between two points
<?php
function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) {
$theta = $longitude1 - $longitude2;
$miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));
$miles = acos($miles);
$miles = rad2deg($miles);
$miles = $miles * 60 * 1.1515;
$feet = $miles * 5280;
$yards = $feet / 3;
@wildiney
wildiney / get_all_tweets_of_a_specific_hashtag.php
Created June 1, 2013 00:28
Get all tweets of a specific hashtag
<?php
function getTweets($hash_tag) {
$url = 'http://search.twitter.com/search.atom?q='.urlencode($hash_tag) ;
echo "<p>Connecting to <strong>$url</strong> ...</p>";
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
$xml = curl_exec ($ch);
curl_close ($ch);
@wildiney
wildiney / applying_even-odd_classes.php
Created June 1, 2013 00:30
Applying Even/Odd Classes
<div class="example-class<?php echo ($xyz++%2); ?>">