Skip to content

Instantly share code, notes, and snippets.

@rodurma
rodurma / MeuComando.php
Last active August 29, 2015 14:20
Exemplo de Command em Laravel + Queue + Delay
<?php namespace App\Commands;
use App\Commands\Command;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Bus\SelfHandling;
use Illuminate\Contracts\Queue\ShouldBeQueued;
@rodurma
rodurma / 0_reuse_code.js
Last active August 29, 2015 14:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@rodurma
rodurma / User.php
Created June 16, 2015 19:57
Trabalhando com timezones no Laravel usando mutators
public function getCreatedAtAttribute($value)
{
$timezone = Auth::check() ? Auth::user()->timezone : Config::get('app.timezone');
return Carbon::parse($value)->timezone($timezone);
}
@rodurma
rodurma / 301-redirect.php
Created July 22, 2015 12:50
Redirecionamento 301 para um outro domínio
<?
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.meusite.com.br");
?>
@rodurma
rodurma / Post-2.php
Last active August 29, 2015 14:25
Recuperando o ID usando Eloquent do Laravel
<?php
class Post extends Eloquent
{
public $incrementing = false;
}
@rodurma
rodurma / gist:c66ee2e0f57ebf7cba9d
Last active August 31, 2015 22:54 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@rodurma
rodurma / supervisor-worker.conf
Created September 12, 2015 03:58
Configurando o supervisor com mais de um processo
[program:name]
command=php /path/file/artisan queue:work --daemon --env=production --queue=default
autostart=true
autorestart=true
user=forge
redirect_stderr=true
stdout_logfile=/path/logs/log_supervisord_name.log
numprocs=5
process_name=%(program_name)s_%(process_num)s
@rodurma
rodurma / router.php
Created October 20, 2015 23:31 — forked from tamagokun/router.php
Run a Wordpress site via PHP's built-in web server
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
chdir($root);
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
set_include_path(get_include_path().':'.__DIR__);
if(file_exists($root.$path))
{
if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')
$path = rtrim($path,'/').'/index.php';
@rodurma
rodurma / Table with fixed header and sidebar.markdown
Created January 8, 2016 19:44
Table with fixed header and sidebar
<?php
// Neste caso o usuário definiu que a rota base para categoria é "categoria"
// podendo criar links do tipo /categoria/categoria-1 ou /categoria/categoria-2
// No caso da base da rota tag é "tag" e segue o mesmo exemplo da categoria
//
// Mas o usuário poderia definir que a base da rota categoria poderia ser "c"
// Neste caso o laravel criaria rotas assim
// - /c/categoria-1
// - /c/categoria-2