Skip to content

Instantly share code, notes, and snippets.

View RamonGilabert's full-sized avatar

Ramon Gilabert RamonGilabert

View GitHub Profile
@RamonGilabert
RamonGilabert / gist:23938cc1725a40389863
Last active August 29, 2015 14:21
Launch your app when you login
import Cocoa
class LaunchStarter: NSObject {
class func toggleLaunchAtStartup() {
let itemReferences = itemReferencesInLoginItems()
let shouldBeToggled = (itemReferences.existingReference == nil)
if let loginItemsRef = LSSharedFileListCreate( nil, kLSSharedFileListSessionLoginItems.takeRetainedValue(), nil).takeRetainedValue() as LSSharedFileListRef? {
if shouldBeToggled {
if let appUrl : CFURLRef = NSURL.fileURLWithPath(NSBundle.mainBundle().bundlePath) {
set fish_greeting Welcome\x20\x1b\x5b32mRamon!
alias gst='git status'
alias gco='git checkout'
alias gl='git pull'
alias gpom="git pull origin master"
alias gd='git diff | mate'
alias gnb='git branch'
alias gba='git branch -a'
alias gb='git checkout -b'
#!/usr/bin/env xcrun swift
import Foundation
let firstStaticRegex = "\\[.*?\\)\\)"
let secondStaticRegex = "(?<=\\*\\*Merged pull requests:\\*\\*\\s\\s)(.|\\n)*?(?=\\s##)"
let token = "cf14a306ab918d348fdab2b1824bfd79b51b3172"
let publishRelease = "https://api.github.com/repos/"
let editRelease = "https://api.github.com/repos/"
let error = "There was an error, type CTRL+C to exit. 👽"
# As I don't have the sensor light, what I'll do is the same setup without it, then I'll record the first button and second button actions and they will do the following:
# 1. None of the buttons pressed: Red is open.
# 2. Button 1 pressed: Green is open.
# 3. Button 2 pressed: Blue is open.
# The two buttons down will turn off the program.
# Touching one button or another will trigger an action, that one will be registered and will be saved into a file.
import RPi.GPIO as GPIO
@RamonGilabert
RamonGilabert / Node+Linux.js
Last active February 20, 2016 23:12
Talk from the your NodeJS file to the Linux terminal.
// Talk from the your NodeJS file to the Linux terminal.
var sys = require('util');
var exec = require('child_process').exec;
function log(error, stdout, stderr) { console.log(stdout); }
exec('ls', log);
@RamonGilabert
RamonGilabert / bluetooth.sh
Last active October 12, 2023 18:24
Bluetoothctl automation
#!/usr/bin/expect -f
set prompt "#"
set address [lindex $argv 0]
spawn sudo bluetoothctl -a
expect -re $prompt
send "remove $address\r"
sleep 1
expect -re $prompt
@RamonGilabert
RamonGilabert / UIView+Constraint.swift
Last active March 26, 2016 19:34
If you are creating your constraints without any pod, this is a small convenience to not having to set the property every time.
import UIKit
extension UIView {
override public class func initialize() {
struct Static {
static var token: dispatch_once_t = 0
}
dispatch_once(&Static.token) {
#!/bin/sh
USER="pi"
APP_DIR="/home/pi/Desktop/Lights-Berry"
NODE_APP="app.js"
CONFIG_DIR="$APP_DIR"
PID_DIR="$APP_DIR/pid"
PID_FILE="$PID_DIR/app.pid"
LOG_DIR="$APP_DIR/log"
LOG_FILE="$LOG_DIR/app.log"
1. Introduction
Lights comes and belongs to different industries and engineering fields,
considered itself as a component of the new era of the Internet of Things with also
a representation in the paradigm of home automation.
1.1. History the internet of things
There is a starting point to every revolution, the internet of things begins in
the XIX century in Switzerland with a well known concept nowadays, home automation.

Conclusions

It is hard to know where to stop when building something as generic and straight forward into the future as this. After the whole process explained in this document, Lights turned to be a generic open source platform inducted into a product that can control lights from anywhere in the world, but the fact that anybody can edit it and customize it to make it their own, makes this something that cannot be imagined or written down.

From the first wheel invented until this project; lots of years of innovation and inventions have put technology in our day to day lives; more and more people interact with their devices, 9 years ago we could not imagine holding a super computer in our hands while now, we wear it in our wrists. Every day there is a new couple of words together forming a new one, AI, VR, IoT, etc. Disrupting technologies break the market and are the next big thing until a new one appears and, within this world where we live, fast delivered solutions is something engineers, designers and