Skip to content

Instantly share code, notes, and snippets.

View vivirenremoto's full-sized avatar
🍗

vivirenremoto vivirenremoto

🍗
View GitHub Profile
@vivirenremoto
vivirenremoto / gist:5052719
Last active December 14, 2015 07:48
Detecta el dispositivo móvil y redirige a su versión correspondiente con un sólo código QR
<?php
$user_agent = $_SERVER['HTTP_USER_AGENT'];
switch( true ){
case preg_match('/iphone|ipad/si',$user_agent):
$url = 'https://itunes.apple.com/us/app/whatsapp-messenger/id310633997?mt=8';
break;
case stristr($user_agent, 'android'):
$url = 'http://www.bedca.net/bdpub/procquery.php';
$xml = '<?xml version="1.0" encoding="utf-8"?><foodquery><type level="3e"/><selection><atribute name="r_id"/><atribute name="citation"/></selection><condition><cond1><atribute1 name="citation"/></cond1><relation type="NOTEQUAL"/><cond3>null</cond3></condition><order ordtype="ASC"><atribute3 name="r_id"/></order></foodquery>';
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $xml
)));
$xml = simplexml_load_string( file_get_contents($url, false, $context) );
@vivirenremoto
vivirenremoto / gist:5456608
Created April 25, 2013 00:09
firefox os manifest.webapp example
{
"name": "Hello world",
"description": "Hello world app",
"launch_path": "/app/index.html",
"icons": {
"128": "http://domain.com/app/app128.png"
},
"developer": {
"name": "Your name",
"url": "http://domain.com"
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>
http://betabeers.com/forum/cuantos-enlaces-maximo-permite-un-sitemapsxml-145/
</loc>
<priority>0.1</priority>
<changefreq>monthly</changefreq>
<lastmod>2013-05-13</lastmod>
</url>
<url>
@vivirenremoto
vivirenremoto / gist:5637310
Created May 23, 2013 16:17
programar email dentro de 2 dias
<?php
// buscar eventos dentro de 2 dias en la base de datos
$date = date('Y-m-d',strtotime("+2 days"));
$consulta_sql = "SELECT titulo, mensaje, email FROM eventos WHERE date LIKE '" . $date . "%'";
$eventos = $db->queryAll($consulta_sql);
// si hay eventos enviamos un email al organizador
if( $eventos ){
foreach( $eventos as $evento ){
@vivirenremoto
vivirenremoto / gist:5720812
Last active December 18, 2015 03:49
Total users in your data base
<?php
$total = $db->queryOne("SELECT COUNT(*) FROM Users");
echo $total;
?>
@vivirenremoto
vivirenremoto / gist:5720828
Last active December 18, 2015 03:49
Total firefox os app downloads
<?php
// your firefox os apps submissions here https://marketplace.firefox.com/developers/submissions
$app_name = 'betajobs';
$url = 'https://marketplace.firefox.com/app/'.$app_name.'/statistics/installs-month-20120601-'.date('Ymd').'.json';
$dates = json_decode( file_get_contents( $url ) );
$total = 0;
if( $dates ){
@vivirenremoto
vivirenremoto / gist:5720845
Last active December 18, 2015 03:49
Get total mails sent last month on mailjet
<?php
// Public Api class, get it here https://es.mailjet.com/docs/api
require 'class.mailjet.php';
// Get your mailjet API keys here https://es.mailjet.com/account/api_keys
$apiKey = '';
$secretKey = '';
$mj = new Mailjet($apiKey, $secretKey);
$mj->debug = 0;
@vivirenremoto
vivirenremoto / gist:5735353
Created June 8, 2013 14:35
appannie app downloads
<?php
// http://appannie.zendesk.com/categories/20082753-Analytics-API
$username = '[email protected]';
$password = '';
$account_id = 123;
$app_id = 123;
$start_date = '2012-01-01';
$ch = curl_init("https://api.appannie.com/v1/accounts/".$account_id."/apps/".$app_id."/sales?start_date=".$start_date."&end_date=".date("Y-m-d"));
@vivirenremoto
vivirenremoto / gist:6191967
Created August 9, 2013 08:12
seguir usuarios twitter
<?php
// descarga las clases necesarias
// https://github.com/abraham/twitteroauth/tree/master/twitteroauth
require BASE_PATH . 'class/OAuth.php';
require BASE_PATH . 'class/twitteroauth.php';
// crea una app en twitter y copia tus keys
// https://dev.twitter.com/
define('TWITTER_CONSUMER_KEY','');