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
blueprint:
name: Presence and illuminance controlled lighting
description: >-
Turns on selected lights or switches when presence is detected and
illuminance is below the configured threshold.
The automation only takes control when ALL selected entities are currently
off. If any selected entity is already on, the automation assumes it was
turned on manually and leaves it alone.
@csrui
csrui / sonoff_detached_lights.yaml
Last active August 17, 2026 11:59
Home Assistant Blueprint: Sonoff Detached Lights
blueprint:
name: Sonoff detached button controls a light
description: >
Toggle a light from a physical button on a detached Sonoff M5.
Uses the Sonoff Action sensor rather than the relay entity.
domain: automation
author: Rui
input:
action_sensor:
@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 antocontreras/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",