Skip to content

Instantly share code, notes, and snippets.

View csrui's full-sized avatar
🏠
Working from home

Rui Sardinha csrui

🏠
Working from home
View GitHub Profile
@eberfreitas
eberfreitas / sluggable.php
Created March 19, 2010 19:46
My Sluggable Behaviour for CakePHP based on Mariano Iglesias' behaviour
<?php
App::import('Inflector');
class SluggableBehavior extends ModelBehavior {
private $_settings = array();
function setup(&$model, $settings = array()) {
$default = array(
@corsonr
corsonr / gist:6138666
Created August 2, 2013 09:31
WooCommerce - List products by attribute (multiple values), ex: [woo_products_by_attributes attribute="colour" values="red,black" per_page="5"]
<?php
/**
* Plugin Name: WooCommerce - List Products by Attributes
* Plugin URI: http://www.remicorson.com/list-woocommerce-products-by-attributes/
* Description: List WooCommerce products by attributes using a shortcode, ex: [woo_products_by_attributes attribute="colour" values="red,black" per_page="5"]
* Version: 1.0
* Author: Remi Corson
* Author URI: http://remicorson.com
* Requires at least: 3.5
* Tested up to: 3.5
@csrui
csrui / typeahead-extended.js
Created August 7, 2013 10:46
Twitter Bootstrap customizations
/*
Extended Bootstrap Typeahead
Based on an answer on stackexchange.com
http://stackoverflow.com/a/14959406/1065537
*/
/* Enhances the autocomplete function */
$('.autocomplete').typeahead({
source: function (query, process) {
return $.ajax({
@csrui
csrui / GeoBehavior.php
Last active December 20, 2015 18:09
CakePHP - Lib to handle spatial data
<?php
/**
* GeoBehavior handles a set of operations generaly needed when working with coordinates
*
* @source https://gist.github.com/csrui/6173911
* @url http://book.cakephp.org/2.0/en/Models/behaviors.html
**/
class GeoBehavior extends ModelBehavior {
public $settings = array();
@jamesmrobinson
jamesmrobinson / functions.php
Last active May 14, 2017 03:06
WordPress functions.php file with various cleanup, security, performance and helper functions. Obviously requires customisation as per theme needs.
<?php
function im_setup() {
// ++++++++++++++++ REGISTER THEME OBJECTS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// Register and enqueue Javascript
function im_js() {
// Modernizr
@csrui
csrui / gulpfile.js
Created April 11, 2014 16:27
Generic gulpfile for CakePHP apps. Compiles and minifies sass. Minifies and lints javascript. Generates documentation with yuidoc
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
var yuidoc = require("gulp-yuidoc");
@csrui
csrui / package.json
Created April 14, 2014 11:44
Dependencies for the gulpfile.js
{
"devDependencies": {
"gulp": "~3.6.0",
"gulp-rename": "~1.2.0",
"gulp-concat": "~2.2.0",
"gulp-minify-css": "~0.3.1",
"gulp-uglify": "~0.2.1",
"gulp-sass": "~0.7.1",
"gulp-chmod": "~0.2.0",
"gulp-notify": "~1.2.5",
@tobi-pb
tobi-pb / migrate.sh
Last active March 3, 2023 23:34
Upgrade MAMP to Mysql 5.6
#!/bin/sh
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.24-osx10.9-x86_64.tar.gz
tar xfvz mysql-5.6*
echo "stopping mamp"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld
echo "creating backup"
@helderco
helderco / db-open
Created October 6, 2015 14:51
Script to open a mysql database in Sequel Pro from a service in docker-compose.
#!/bin/bash
set -e
show_help() {
cat << EOF
Usage: ${0##*/} [-u USER] [-p PASS] [-P PORT] [-H HOST] [DATABASE]
${0##*/} -h
Open a standard connection in Sequel PRO.
@pascalbaljet
pascalbaljet / imagick-3.4.0-PHP7-forge.sh
Last active November 26, 2020 09:10
Install Imagick 3.4.0 on PHP 7.0 server (Laravel Forge)
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz