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 / 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 / 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 / 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 / unirest_oauth.js
Created January 14, 2014 10:42
OAuth requests with library Unirest.io
var Request = unirest.get('https://api.twitter.com/oauth/request_token');
Request.oauth({
callback: 'http://mysite.com/callback/'
, consumer_key: 'CONSUMER_KEY'
, consumer_secret: 'CONSUMER_SECRET'
}).end(function (response) {
var access_token = response.body;
Request = unirest.post('https://api.twitter.com/oauth/access_token');
@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;
@csrui
csrui / LanguageComponent.php
Created January 8, 2014 11:37
Handle language changing in CakePHP
<?php
App::uses('Component', 'Controller');
class LanguageComponent extends Component {
public function initialize(Controller $controller) {
$this->autoSelectLanguage($controller);
@csrui
csrui / BootstrapFormHelper.php
Created January 8, 2014 11:20
Formats CakePHP form elements with Bootstrap classes
<?php
/**
* Formats form elements for Bootstrap v3
*
* Add to AppController.php
*
* public $helpers = array(
* 'Form' => array('className' => 'BootstrapForm')
* );