Skip to content

Instantly share code, notes, and snippets.

@JoaoVagner
JoaoVagner / mongo.php
Created February 25, 2013 18:53
FUELPHP Mongo TASK backup
<?php
namespace Fuel\Tasks;
class Mongo {
public function run() {
$file = \Fuel\Core\Config::load('db');
$env = $file['mongo']['default']['hostname'];
exec('cd fuel/app/backup/ && mongodump --journal --host ' . $env . ' --port 27017 && tar -zcvf backup_'.date('Y-m-d-h-m-s').'.tar.gz dump && rm -rf dump;');
@JoaoVagner
JoaoVagner / compressor.sh
Created February 25, 2013 21:32
Compressor using YUI Compressor
#!/bin/bash
# The files to ignore are already minified.
css_files_to_ignore=(
"jquery.colorbox-min.css"
);
js_files_to_ignore=(
"jquery.colorbox-min.js"
@JoaoVagner
JoaoVagner / compressor.sh
Created March 21, 2013 18:54
A quem possa interessar, um compressor e minificador de JS e CSS usando Yui Compressor
#!/bin/bash
limpa() {
echo -e "\nDeleting existing minified files..."
find ../js -name \*.min.js -exec rm {} \;
find ../css -name \*.min.css -exec rm {} \;
}
comprime_js() {
echo -e "\nComprimindo e minificando o JavaScript..."
@JoaoVagner
JoaoVagner / gist:5438842
Created April 22, 2013 21:48
TASK Fuelphp que procura endereços sem geo localização, requisita o google maps, e salva os daods
<?php
namespace Fuel\Tasks;
class Geo {
public static function run() {
$mongo = \Fuel\Core\Mongo_Db::instance();
$process = $mongo->get_where('companies', array('address.geo' => array('$exists' => false)));
echo "STARTING Process \n";
@JoaoVagner
JoaoVagner / gist:5452452
Created April 24, 2013 14:17
geoNear MongoDB + Monga
public function getByLatLng($lat, $lng, $range = 5000 /* KM */, $earthRadius = 6378 /* Unit Earth Radius */) {
\Config::load('db');
$mongoConf = \Config::get('mongo');
$monga = \Monga::connection('mongodb://' . $mongoConf['default']['hostname'] . ':27017');
$database = $monga->database($mongoConf['default']['database']);
$nameCache = 'company_get_by_' . $lat . '_' . $lng;
try {
<?php
Class API extends \CI_Model {
public $auth = array(
'appID' => 'web-based',
'secret' => 'secret'
);
public $permission;
public $urlAPI;
@JoaoVagner
JoaoVagner / .bash_profile
Created August 21, 2013 18:41
Update ALL Projects
alias git_core="cd ~/projects/00K_CORE && git pull"
alias git_api="cd ~/projects/00K_API && git pull"
alias git_docs="cd ~/projects/00k_docs && git pull"
alias git_interface="cd ~/projects/00K_INTERFACE && git pull"
alias git_web_commom="cd ~/projects/web/00k_zend_library/00k_common_library && git pull"
alias git_web_api="cd ~/projects/web/00k_zend_library/00k_api_library && git pull"
alias git_web_interface="cd ~/projects/web/00k_zend_library/00k_interface_library/ && git pull"
# Update all repos OOK
alias git_all="git_core; git_api; git_docs; git_interface; git_web_commom; git_web_api; git_web_interface"
@JoaoVagner
JoaoVagner / gist:6308403
Created August 22, 2013 15:05
utf_encode array_walk_recursive
$utf = function ($value, $key) use (& $array) {
utf8_encode($array);
};
array_walk_recursive($allArray, $utf);
@JoaoVagner
JoaoVagner / gist:6381205
Created August 29, 2013 17:51
product agrupado
{
group: [
{
id: "1280",
nome: "Saia Spoiler Para-choque Golf 95 96 97 GL GLX Mexicano",
imagem: null,
descricao: null,
valor: null,
peso: null,
loja_id: null,
{"group":[{"id":"1280","nome":"Saia Spoiler Para-choque Golf 95 96 97 GL GLX Mexicano","imagem":null,"descricao":null,"valor":null,"peso":null,"loja_id":null,"id_prod":null,"quantidade":null,"frete":null,"frete_gratis":null,"desconto":null,"id_kit":null,"outros_dados":null,"itens":"0","id_produto_grupo":"176","childs":[{"id":"357","nome":"Lado Direito Passageiro","descricao":"Saia Spoiler Spolle Para-choque Golf 95 96 97 Gl GLX Mexicano Lado Direito Passageiro Larga","valor_original":"49.90","valor_venda":"41.90","foto":null,"loja_id":"100","peso":"350"},{"id":"358","nome":"Lado Esquerdo Motorista","descricao":"Saia Spoiler Spolle Para-choque Golf 95 96 97 Gl GLX Mexicano Lado Esquerdo Motorista","valor_original":"49.90","valor_venda":"41.90","foto":null,"loja_id":"100","peso":"350"},{"id":"358","nome":"Lado Esquerdo Motorista","descricao":"Saia Spoiler Spolle Para-choque Golf 95 96 97 Gl GLX Mexicano Lado Esquerdo Motorista","valor_original":"49.90","valor_venda":"41.90","foto":null,"loja_id":"100","peso":"