Skip to content

Instantly share code, notes, and snippets.

View michaelaguiar's full-sized avatar
🎯
Focusing

Michael Aguiar michaelaguiar

🎯
Focusing
View GitHub Profile
@michaelaguiar
michaelaguiar / fb_like.php
Created October 4, 2011 22:48
Facebook API - Detect if a user like's the app's page
<?php
// Get Signed Request
$signed_request = $_REQUEST['signed_request'];
// Parse Signed Request
function parsePageSignedRequest() {
if(isset($_REQUEST['signed_request'])) {
$encoded_sig = null;
$payload = null;
list($encoded_sig, $payload) = explode('.', $_REQUEST['signed_request'], 2);
@michaelaguiar
michaelaguiar / distance.sql
Created October 5, 2011 00:22
SQL - Calculate Distance
SELECT *,(((acos(sin((".$latitude."*pi()/180)) * sin((`Latitude`*pi()/180))+cos((".$latitude."*pi()/180)) * cos((`Latitude`*pi()/180)) * cos(((".$longitude."- `Longitude`)*pi()/180))))*180/pi())*60*1.1515) as distance FROM `TABLE` HAVING distance <= ".$distance;
@michaelaguiar
michaelaguiar / email.php
Last active July 28, 2020 20:54
PHP - Send Email
<?php
// Configuration
$myEmail = 'YOUR EMAIL HERE';
$error = '';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
@michaelaguiar
michaelaguiar / MCAPI.class.php
Created October 7, 2011 21:20
PHP - MailChimp Class API
<?php
class MCAPI {
var $version = "1.3";
var $errorMessage;
var $errorCode;
/**
* Cache the information on the API location on the server
*/
var $apiUrl;
@michaelaguiar
michaelaguiar / twitter.php
Created October 8, 2011 21:44
PHP - Display most recent twitter post
<?php
// Your twitter username.
$username = "twitter user name";
// Prefix - Display something before the tweet
$prefix = "";
// Suffix - Display something after the tweet
$suffix = "";
@michaelaguiar
michaelaguiar / wp_twitter.php
Created October 8, 2011 22:57
PHP - Wordpress Twitter Widget
<?php
/*
Plugin Name: Twitter Widget
Plugin URI: http://labs.aliasproject.com/wp_twitter_widget
Description: A simple widget for Wordpress that displays the most recent tweet of a twitter account
Author: Michael Aguiar
Version: 1.0
Author URI: http://cv.michaelaguiar.com
*/
@michaelaguiar
michaelaguiar / encrypt.php
Last active February 27, 2017 10:22
Encryption
<?php
class Encryption {
var $skey = 'UNIQUE KEY';
public function safe_b64encode($string)
{
$data = base64_encode($string);
$data = str_replace(array('+','/','='),array('-','_',''),$data);
return $data;
}
@michaelaguiar
michaelaguiar / confirm.js
Created November 10, 2011 18:34
Javascript Confirm Method
$('SELECTOR').click(function(e) {
e.preventDefault();
if(confirm("MESSAGE TO DISPLAY TO USER") === true) {
window.location.href = $(this).attr('href');
} else {
// User Cancelled
}
});
@michaelaguiar
michaelaguiar / phpini_path.sh
Created November 19, 2011 00:21
Output the path to php.ini
php -i | grep php.ini
@michaelaguiar
michaelaguiar / README.md
Created November 22, 2011 17:41
Device Detection

DEVICE DETECTION

Usage

Add the following to the top of your root file:

require_once('device_detect.php');

device_detect(false,false,false,false,false,false,false,'MOBILE URL or false if none','DESKTOP URL or false if none');