Skip to content

Instantly share code, notes, and snippets.

@fabianofa
fabianofa / gist:5889805
Last active July 1, 2016 04:39
CodeIgniter .htaccess alternative code to remove index.php from URL
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
@fabianofa
fabianofa / gist:5906597
Last active December 19, 2015 05:49
Since adding Pagetabs to Pages is kind of messy, use this code into a HTML simple file. It will allow you to just paste Facebook App ID and Redirect URI then open a pop up with the dialog. Pure and simple use of values on inputs, nothing new or awesome here, just useful.
<!DOCTYPE html:
<html lang="en">
<head>
<title>My Add to Page Dialog Page</title>
</head>
<body>
<div id='fb-root'></div>
<p> Facebook App ID: <input type="text" id="appid" style="width: 350px"> </p>
<p> Redirect URI: <input type="text" id="appuri" style="width: 350px"> </p>
@fabianofa
fabianofa / doskeys
Last active November 16, 2018 00:59
Here is a list of DOSKEY commands I use in Windows to make my workflow better and yet using Microsoft Command Line. This commands should be saved into a .cmd file and manually altering Windows registry keys, set Command Line to autorun it.
# To manually alter the autorun parameter, create a REG_SZ - String Value, named Autorun. As value the absolute path to file, into:
# [HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
# Command list:
# 1 - createrep: Creates a directory and initialize a bare git repository into it
# 2 - sass: Runs sass --watch command on filename, creating same filename converted to css. Alternatively, filename can be absolute or relative paths
# 3 - sass: Runs sass --watch command on filename, creating converted css named by the second filename. Alternatively, filenames can be absolute or relative paths
# --------- BEGIN -------
@fabianofa
fabianofa / gist:8860987
Created February 7, 2014 11:21
PNG merge with alpha using GD
<?php
/**
* PNG ALPHA CHANNEL SUPPORT for imagecopymerge();
* by Sina Salek
*
* Bugfix by Ralph Voigt (bug which causes it
* to work only for $src_x = $src_y = 0.
* Also, inverting opacity is not necessary.)
* 08-JAN-2011
*
@fabianofa
fabianofa / Wordpress post category listing
Created September 7, 2014 01:55
Return either an array with all categories name from a post or a formatted string that bay be echoed.
function get_categories_name($post_id, $formated = false, $separator = " + "){
$categories = wp_get_post_categories($post_id);
$categories_name = array();
$formatted_string = "";
foreach ($categories as $category){
array_push($categories_name, get_category($category)->name);
}
if (!$formated)
@fabianofa
fabianofa / etc:init.d:memcached
Last active February 3, 2016 12:23
Running multiple instances of memcached installed via Yum or RPM on CentOS 6.x
#!/bin/bash
#
# Init file for memcached
#
# Written by Dag Wieërs <[email protected]>
#
# chkconfig: - 80 12
# description: Distributed memory caching daemon
#
# processname: memcached
@fabianofa
fabianofa / randomLatitudeLongitude.php
Created August 25, 2016 18:33
Gera valor de latitude e longitude até uma determinada distância de um ponto inicial.
<?php
$randomCoordinated = function($x0, $y0, $radius){
$randomFloat = function($min = 0, $max = 1) {
return $min + mt_rand() / mt_getrandmax() * ($max - $min);
};
// Convert radius from meters to degrees
$radiusInDegrees = $radius / 111000;
@fabianofa
fabianofa / gist:c25ddff393b7a98eff039090932ac884
Created November 29, 2016 14:02
Solving rsync on path and vboxsf not found for Vagrant on Windows
// on Vagrantfile:
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
// then:
vagrant plugin install vagrant-vbguest
@fabianofa
fabianofa / gist:98b989c739a5290b8d8f8d64ee781211
Created March 6, 2017 10:55
Instalando extensão em ambiente linux com php já compilado
If you already have php installed (from repository for example), you can compile only the PDO_OCI from PHP source (you need the instantclient installed)
Download the PHP source with same version that you have installed;
Unzip;
Change to directory php-YOUR-VERSION/ext/pdo_oci
Inside the pdo_oci folder, run these commands:
$ git clone https://github.com/php/php-src.git
$ cd php-src
Na 10, aonde ficam os repositórios, para os projetos que envolvem Santa Catarina foi adicionada a configuração de atualização automática do repositório depois de cada push. A configuração fica no diretório respectivo, em `/Development/repos/<diretorio>.git/hooks`. O arquivo se chama `post-receive`. Caso nunca tenha sido alterada a configuração, o arquivo vai se chamar `post-receive.sample`. Caso seja preciso configurar:
* Acessa o diretório do repositório na 10 via terminal. Ex: `$ cd /Development/repos/SadeApplicationPMSC.git`
* Acessa o diretório `hooks`
* `$ mv post-receive.sample post-receive`
* `$ vim post-receive`
* Na próxima linha abaixo dos comentários cola a linha alterando o nome do repositório corretamente: `cd /Development/repos/SadeApplicationPMSC.git && git update-server-info`
* `:wq`
Após o próximo push, quando for necessário realizar pull em ambiente que clonou via HTTP não será mais necessário previamente acessar a 10 e atualizar o repositório via `git update-server-info`.