Skip to content

Instantly share code, notes, and snippets.

View patrickmaciel's full-sized avatar
🙏
Jesus is coming!

Patrick Maciel patrickmaciel

🙏
Jesus is coming!
View GitHub Profile
@patrickmaciel
patrickmaciel / filters.php
Created November 20, 2014 11:23
Laravel 4.2 filter for query log
<?php
if (Config::get('app.debug')) {
Event::listen('illuminate.query', function($query, $bindings, $time, $name) {
$data = compact('bindings', 'time', 'name');
// Format binding data for sql insertion
foreach ($bindings as $i => $binding) {
if ($binding instanceof \DateTime) {
$bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
@patrickmaciel
patrickmaciel / filters.php
Created November 20, 2014 11:24
Laravel 4.2 filters for: missing route/page and exception
<?php
// 404
App::missing(function($exception)
{
if (!Config::get('app.debug')) {
return Response::view('errors.missing', array(), 404);
}
});
@patrickmaciel
patrickmaciel / limit_paginate_example.php
Created November 20, 2014 16:38
Limit Paginator in Laravel 4.2
<?php
// The current page you're looking at, defaults to the first page.
$page = empty($inputs['page']) ? 1 : $inputs['page'];
// Number of records to display per page.
$per_page = 20;
// Total number of records to use for generating pages. This is now dynamic, so for anyone interested in anything beyond page 10, it will dynamically show 9 more pages if you click on page 10, until the end of the table.
$total = empty($inputs['quantidade']) ? 50 : $inputs['quantidade'];
$total = ($total - $per_page) + ($page * $per_page);
// Get the number of records per page, starting at the page number minus 1. Imagine you're looking at page 1, then it should skip 0 records.
$contatos = $contatos->take($per_page)
<?php
class Cidades extends Seeder {
public function run()
{
DB::select(DB::raw("INSERT INTO `cidade` (`id`, `nome`, `estado_id`, `created_at`, `updated_at`) VALUES
(1, 'Afonso Cláudio', 8, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP ),
(2, 'Água Doce do Norte', 8, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP ),
(3, 'Águia Branca', 8, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP ),
@patrickmaciel
patrickmaciel / Cask
Last active August 29, 2015 14:10
My Cask file (emacs dependencies)
(source gnu)
(source melpa)
(depends-on "cask")
(depends-on "color-theme-sanityinc-tomorrow")
(depends-on "expand-region")
(depends-on "ace-jump-mode")
(depends-on "auto-complete")
(depends-on "flx-ido")
(depends-on "yasnippet")
@patrickmaciel
patrickmaciel / .emacs
Last active August 29, 2015 14:10
my old init.el (.emacs on windows) configuration file
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'load-path "~/emacs-packages/")
(load "~/emacs-packages/workaround-mumamo-buffer-file-name-warnings.el")
(load "~/emacs-packages/nxhtml/autostart.el")
;; smooth-scrolling
(require 'smooth-scrolling)
@patrickmaciel
patrickmaciel / README.md
Last active August 29, 2015 14:13 — forked from denji/README.md

OS X Preferences


#Disable window animations
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false

#Enable repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false
@patrickmaciel
patrickmaciel / mac-brew-php56
Last active August 29, 2015 14:16
Install php 5.6 in mac os yosemite with php-fpm and nginx
brew tap homebrew/dupes && \
brew tap homebrew/versions && \
brew tap homebrew/dupes && \
brew reinstall php56 \
--with-fpm \
--without-apache \
--with-mysql \
--with-intl \
--with-mcrypt \
--with-postgresql \