Skip to content

Instantly share code, notes, and snippets.

View vivirenremoto's full-sized avatar
🍗

vivirenremoto vivirenremoto

🍗
View GitHub Profile
@vivirenremoto
vivirenremoto / class_db.php
Created August 25, 2011 02:47
mysql php class
<?php
class DB{
private $link;
function __construct( $config ){
extract( $config );
$this->link = mysqli_connect( $host, $user, $pass, $name, $port ) OR die( mysqli_connect_errno() );
}
@vivirenremoto
vivirenremoto / class_cache.php
Created August 25, 2011 02:49
cache php class
<?php
class Cache{
public $path;
public $content;
public $life = 3600; // 1 hour
public $cache_path = 'cache/';
function get( $id ){
$this->id = $id;
@vivirenremoto
vivirenremoto / gist:1169863
Created August 25, 2011 02:51
Search images from google
function searchItemsGoogleImages($search, $limit = 'small'){
// $limit (large = 8 results, small 4 results)
$url = 'http://www.google.com/uds/GimageSearch?lstkp=0&rsz=' . $limit . '&hl=es&source=gsc&gss=.com&sig=fd25df5f26208aec5fddcae8457d8888&q=' . urlencode( $search ) . '&gl=www.google.com&qid=1253a7f078d655e6e&key=notsupplied&v=1.0';
$data = file_get_contents( $url );
$json = json_decode( $data );
return $json->responseData->results;
}
@vivirenremoto
vivirenremoto / gist:1169870
Created August 25, 2011 02:52
Send emails via smtp with sendgrid.com
<?php
// sendgrid.com is a cheap service to send emails
// swift mailer class is required, you can download it in swiftmailer.org
require 'class/swift/swift_required.php';
class Mailer{
var $author;
var $from;
@vivirenremoto
vivirenremoto / gist:1169873
Created August 25, 2011 02:53
Inverse geolocation by ip with maxmind and google maps api
<?php
// maxmind geolitecity class is required, you can download it in http://www.maxmind.com/app/geolitecity
// define variables
$google_maps_key = '';
// import geoipcity class
require 'class/maxmind/geoipcity.inc';
@vivirenremoto
vivirenremoto / gist:1169875
Created August 25, 2011 02:54
get avatars from gravatar, facebook, twitter
function getPhotoFacebook( $fb_id ){
return 'http://graph.facebook.com/' . $fb_id . '/picture';
}
function getPhotoGravatar( $email ){
return 'http://www.gravatar.com/avatar/' . md5( $email ) . '?s=50';
}
function getPhotoTwitter( $nick ){
return 'http://api.twitter.com/1/users/profile_image/' . $nick . '.json';
@vivirenremoto
vivirenremoto / gist:1169877
Created August 25, 2011 02:54
Search results in google
function searchItemsGoogle( $search, $limit = 'large' ){
// $limit (large = 8 results, small 4 results)
$url = 'http://www.google.com/uds/GwebSearch?lstkp=0&rsz=' . $limit . '&hl=es&source=gsc&gss=.com&sig=fd25df5f26208aec5fddcae8457d8888&q=' . urlencode( $search ) . '&gl=www.google.com&qid=1253a7f078d655e6e&key=notsupplied&v=1.0';
$data = file_get_contents( $url );
$json = json_decode( $data );
return $json->responseData->results;
}
@vivirenremoto
vivirenremoto / gist:1257505
Created October 2, 2011 14:33
piedra, papel, tijeras con voz html5
<!DOCTYPE html>
<html>
<head>
<title>¡piedra, papel, tijeras con voz con html5!</title>
<meta charset="utf-8"/>
</head>
<body>
<style>
*{font-family:arial;font-size:20px;text-align:center}
@vivirenremoto
vivirenremoto / gist:1730750
Created February 3, 2012 15:30
cron bufferapp rss updates
<?php
// CONFIG
$access_token = '';
$profile_ids = '';
$limit = 1;
$urls = array(
'http://feeds.feedburner.com/betabeersjobs',
@vivirenremoto
vivirenremoto / gist:2412517
Created April 18, 2012 09:56
script concurso betabeers
<?php
$names = "Ivan Garcia Villar
Alejandro Perezpaya
Asier Arranz Jimenez
Sergio Fernandez
Nestor Palao Pinedo
Jose Maria Martin
Raymond Albaladejo
Jose Antonio Lambiris Ruiz