Skip to content

Instantly share code, notes, and snippets.

View falexandre's full-sized avatar
😎

Fábio Luis Alexandre falexandre

😎
View GitHub Profile
@falexandre
falexandre / publica-fanpage-v4.php
Last active September 3, 2015 19:55 — forked from dpasqua/publica-fanpage-v4.php
Exemplo de script de publicação na fanpage, facebook, usando PHP SDK v4.0.x ! Instale o SDK v4 através do composer. Mais detalhes de como instalar o SDK via composer pode ser obtido em: http://www.douglaspasqua.com/2015/05/24/criando-aplicativos-facebook-sdk-v4-em-php/
<?php
session_start(); // Sessao do php deve estar ativa
// datetimezone
date_default_timezone_set('America/Sao_Paulo');
// autoloader gerado pelo composer
require_once "vendor/autoload.php";
// configurar APP_ID e SECRET
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
@falexandre
falexandre / snippet.js
Last active August 29, 2015 14:23 — forked from necolas/snippet.js
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@falexandre
falexandre / cep.php
Last active August 29, 2015 14:21 — forked from guisehn/cep.php
<?php
function cep_dados($cep)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.buscacep.correios.com.br/servicos/dnec/consultaLogradouroAction.do');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
daAyx
-----
A [Pen](http://codepen.io/anon/pen/daAyx) by [Captain Anonymous](http://codepen.io/anon) on [CodePen](http://codepen.io/).
[License](http://codepen.io/anon/pen/daAyx/license).
function CalcRadiusDistance(lat1, lon1, lat2, lon2) {
var RADIUSMILES = 3961,
RADIUSKILOMETERS = 6373,
latR1 = this.deg2rad(lat1),
lonR1 = this.deg2rad(lon1),
latR2 = this.deg2rad(lat2),
lonR2 = this.deg2rad(lon2),
latDifference = latR2 - latR1,
lonDifference = lonR2 - lonR1,
a = Math.pow(Math.sin(latDifference / 2), 2) + Math.cos(latR1) * Math.cos(latR2) * Math.pow(Math.sin(lonDifference / 2), 2),
// add the filter to your application module
angular.module('yourAppName', ['filters']);
/**
* Truncate Filter
* @Param string
* @Param int, default = 10
* @Param string, default = "..."
* @return string
*/
<?php
function indent_json ($json)
{
$result = '';
$pos = 0;
$strLen = strlen($json);
$indentStr = "\t";
$newLine = "\n";
$prevChar = '';
// Declares an object
var layout = {};
// Mount function
layout.mount = function (origin, data)
{
// Receives HTML content
#!/bin/bash
echo "Installing meld..."
apt-get install meld -y -qq
echo "Meld [OK]"
echo "Creating meld custom script..."
rm ~/.config/git_meld_diff.sh
touch ~/.config/git_meld_diff.sh
echo "#!/bin/bash" >> ~/.config/git_meld_diff.sh