Skip to content

Instantly share code, notes, and snippets.

@josuecau
josuecau / .htaccess
Created Nov 4, 2011
Simple PHP routing
View .htaccess
RewriteEngine On
#RewriteBase /path/to/dir/
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# add trailing slash
RewriteRule ^.*[^/]$ $0/ [L,R=301]
RewriteRule ^.*$ index.php [NC,L]
@josuecau
josuecau / .gitignore
Created Dec 14, 2011 — forked from redoPop/.gitignore
Template .gitignore file for WordPress projects
View .gitignore
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@josuecau
josuecau / observer-design-pattern.php
Last active Jul 11, 2017
Observer design pattern implementation in PHP
View observer-design-pattern.php
<?php
class UserList implements SplSubject
{
private $_observers;
private $_users = array();
public function __construct()
{
$this->_observers = new SplObjectStorage();
@josuecau
josuecau / recursive-search-replace-osx.sh
Last active Oct 8, 2018
Recursive search & replace on Mac OS X
View recursive-search-replace-osx.sh
# search & replace with backup
find . -name "*.php" -print | xargs sed -i.bak 's/foo/bar/g'
# delete backup files
find . -name '*.bak' | xargs rm
@josuecau
josuecau / .vimrc
Last active Oct 12, 2015
My Vim configuration file
View .vimrc
" Use vim, no vi defaults
set nocompatible
" Include pathogen
call pathogen#infect()
call pathogen#helptags()
" Enable filetype plugins
filetype plugin on
filetype indent on
@josuecau
josuecau / php-server.php
Created Nov 30, 2012
PHP $_SERVER global variable: server and execution environment information
View php-server.php
<?php $title = 'PHP $_SERVER global variable: server and execution environment information'; ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title><?php echo $title; ?></title>
<style>
html { font-size : 100%; }
body { font-family : Monaco, "Andale Mono", "Courier New", Courier, monospace; font-size : 0.8em; color : #333; padding : 10px; }
h1 { font-size : 21px; }
@josuecau
josuecau / .zshrc
Created Jun 5, 2013
My zsh configuration file
View .zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.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="agnoster"
# Example aliases
@josuecau
josuecau / .gvimrc
Created Jun 5, 2013
My Vim configuration file for the GUI
View .gvimrc
" Set the font in the GUI
set guifont=Menlo\ for\ Powerline:h14
" Hide Gvim / MacVim top toolbar
set guioptions-=T
" Reload the files edited
set guioptions+=c
" Make a copy of the file and overwrite the original one
@josuecau
josuecau / rm-osx-forks.sh
Last active Dec 20, 2015
Remove OSX resource forks ._ files
View rm-osx-forks.sh
find . -name ._\* -exec rm -f {} \;
@josuecau
josuecau / .gitignore
Created Jul 30, 2013
Global .gitignore
View .gitignore
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db