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
@csrui
csrui / notify-rollbar.sh
Created October 7, 2019 14:14
Notify Rollbar of a new deployment
#!/bin/bash
# Used to notify rollbar of a new deployment
#
# Usage: ./deploy-notify.sh rollbar_token environment_name
set -e
(
@csrui
csrui / fcg-partial.php
Last active September 19, 2019 22:59
Load partials not needing globals. Just pass arguments to the functions.
<?php
/**
* @wordpress-plugin
* Plugin Name: FCG Partials.
* Description: Do not depend on globals to pass variables to template parts.
* Version: 1.0.0
* Author: Gulbenkian
* Author URI: https://github.com/gulbenkian/
* License: GPL-2.0+
*/
@csrui
csrui / .editorconfig
Last active November 18, 2018 01:05
Composer Recipes for WordPress
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
@csrui
csrui / script.js
Created February 2, 2018 11:22
Get full URL using current script
var plgPath = function(){
var path = null, currentScript = null;
var scripts = document.getElementsByTagName("script");
for(var i in scripts){
if(scripts[i].src.indexOf("script.js") >= 0){
currentScript = scripts[i];
break;
}
}
path = currentScript.src.substring(0, currentScript.src.lastIndexOf("/") + 1);
@csrui
csrui / migrate.sh
Last active August 29, 2015 14:24 — forked from rigobertocontreras/migrate.sh
Migrate MAMP MySQL to v5.6.23 (OSX)
#!/bin/sh
curl "http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.23-osx10.9-x86_64.tar.gz" -L -o "mysql-5.6.23-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"
function update_git_repo() {
GIT_DIR=$1
GIT_REMOTE=$2
GIT_BRANCH=${3:-master}
if [ ! -d $GIT_DIR ]; then
CURRENT_SHA=""
git clone --depth 1 $GIT_REMOTE $GIT_DIR -b $GIT_BRANCH
else
CURRENT_REMOTE=$(cd $GIT_DIR && git config --get remote.origin.url || true)
@csrui
csrui / cakephp.xml
Created April 14, 2014 16:38
Sublime Editor 3 - Snippets for CakePHP
<snippet>
<content><![CDATA[
$this->Html->link(__('${1:Link name}'), array('controller' => '${2:Controller}', 'action' => '${3:action}'))
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>link</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
</snippet>
@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",
@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 / jquery.tognsort.js
Created January 22, 2014 12:31
work in progress - Grabs a <select> a replaces it by a clickable ul/li for better formatting
(function( $ ) {
var $main_select = {};
$.fn.tognsort = function( options ) {
var options = $.extend({}, $.fn.tognsort.defaults, options );
$main_select = this;