Skip to content

Instantly share code, notes, and snippets.

@josuecau
josuecau / .htaccess
Created November 4, 2011 07:16
Simple PHP routing
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 December 14, 2011 09:17 — forked from redoPop/.gitignore
Template .gitignore file for WordPress projects
# 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 July 11, 2017 04:45
Observer design pattern implementation in 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 October 8, 2018 20:10
Recursive search & replace on Mac OS X
# 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 October 12, 2015 15:18
My Vim configuration file
" 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 November 30, 2012 20:46
PHP $_SERVER global variable: server and execution environment information
<?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 June 5, 2013 06:15
My zsh configuration file
# 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 June 5, 2013 06:21
My Vim configuration file for the GUI
" 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 December 20, 2015 04:18
Remove OSX resource forks ._ files
find . -name ._\* -exec rm -f {} \;
@josuecau
josuecau / .gitignore
Created July 30, 2013 08:18
Global .gitignore
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db