Skip to content

Instantly share code, notes, and snippets.

View jackmakiyama's full-sized avatar

Jack Makiyama jackmakiyama

View GitHub Profile
@jackmakiyama
jackmakiyama / .zshrc
Created September 23, 2020 19:18 — forked from dimitardanailov/.zshrc
My personal zsh and tmux configurations
# Path to your oh-my-zsh installation.
export ZSH=/Users/dimitar.danailov/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
# ZSH_THEME="robbyrussell"
ZSH_THEME="agnoster"
@jackmakiyama
jackmakiyama / docker_aliases.sh
Created August 26, 2020 01:50
PHP Docker Aliases
#!/bin/sh
# PHP7
alias php7d='docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.0-cli php'
# Composer
alias composerd='docker run -it --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp composer'
@jackmakiyama
jackmakiyama / custom-respect-validation-rules.md
Created May 28, 2018 15:59 — forked from augustohp/custom-respect-validation-rules.md
How to create custom Respect\Validation rules.

Custom rules on Respect/Validation

You may not know that [the most awesome validation engine for PHP][1] out there is [Respect/Validation][2]. If you do, this is tailored for you!

All rules on [Respect/Validation][2] are meant to be used together, composing a more complex validation rule that is closer to the domain of your application than the existing ones, let's try an example:

@jackmakiyama
jackmakiyama / MY_Security.php
Created September 19, 2017 16:33 — forked from CMCDragonkai/MY_Security.php
PHP: Codeigniter CSRF functionality does not support putting the CSRF token in the HTTP headers for the purposes of the double submit cookie method. It also only runs the CSRF check on POST and not on PUT or DELETE. This drop in MY_Security.php makes sure CSRF runs on POST, PUT or DELETE and checks the HTTP headers for X-XSRF-TOKEN recommended b…
<?php
class MY_Security extends CI_Security{
//overriding the normal csrf_verify, this gets automatically called in the Input library's constructor
//verifying on POST and PUT and DELETE
public function csrf_verify(){
$request_method = strtoupper($_SERVER['REQUEST_METHOD']);

Lidando com Exceptions no Respect\Rest

Bem vindo! Esse é o primeiro-git-post de uma nova funcionalidade em um componente do Respect:

Suponha que você seja louco o suficiente para arquitetar uma API de Olá Mundo que randomicamente dispare Exceptions. Com o Respect/Rest isso ficaria assim:

<?php
$router = new Respect\Rest\Router;
@jackmakiyama
jackmakiyama / User.php
Created November 5, 2015 02:16 — forked from Ocramius/User.php
Doctrine 2 ManyToMany - the correct way
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity()
* @ORM\Table(name="user")
*/
class User
@jackmakiyama
jackmakiyama / User.php
Created November 5, 2015 02:15 — forked from Ocramius/User.php
Doctrine 2 @OneToMany @manytoone example
<?php
namespace HelloWorld;
use InvalidArgumentException;
/**
* This class is somewhere in your library
* @Entity
* @Table(name="users")
*/
@jackmakiyama
jackmakiyama / php-server
Created October 21, 2015 19:33
Run PHP built-in web server with no need of a router file.
#!/usr/bin/env php
<?php
/**
* Usage: php-server [ OPTIONS ] [ DOCUMENT_ROOT ]
*
* When not defined, DOCUMENT_ROOT is the current directory.
*
* -a, --application Defines the application file (default "index.php")
* -b, --background When defined runs server in background
* -h, --host Defines the host of the HTTP web server (default "127.0.0.1")
<?php
return [
// http://www.cidades.ibge.gov.br/download/mapa_e_municipios.php?uf=ac (Thu May 14 16:30:15 BRT 2015)
'AC' => [
1200013 => 'Acrelândia',
1200054 => 'Assis Brasil',
1200104 => 'Brasiléia',
1200138 => 'Bujari',
1200179 => 'Capixaba',
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name