Skip to content

Instantly share code, notes, and snippets.

View mguinada's full-sized avatar

Miguel Guinada mguinada

  • BeBanjo
  • Lisbon, Portugal
View GitHub Profile
@mguinada
mguinada / calva.md
Created January 22, 2022 17:28 — forked from 30atm/calva.md
Calva shortcuts for visual studio code

In VSCode, the default key binding for ctrl+, points to the settings menu. The number of times people access settings windows is far more less than the number of times s-expressions are executed. I modified calva key bindings to use ctrl+, (ctrl+oem_comma) instead of ctrl+alt+c. I also remapped the workbench settings keybinding to ctrl+, g so that it is still accessible. I left the Paredit settings unmodified. However, they are included in the below gist for reference. All the when clause of "when": "editorTextFocus && editorLangId == 'clojure'" so that their scope is limited to clojure only.

@mguinada
mguinada / hue.js
Created February 19, 2021 19:34 — forked from jamesbulpin/hue.js
Service to control Philips Hue lights in response to MQTT messages
require('es6-promise').polyfill();
var hue = require("node-hue-api"),
HueApi = hue.HueApi,
lightState = hue.lightState;
var mqtt = require('mqtt');
var schedule = require('node-schedule');
// Exit once an hour to force a re-read of the Hue lights list
var j = schedule.scheduleJob(new Date((new Date()).getTime()+3600000), function() {
console.log("[" + new Date() + "] " + "Exiting after pre-set delay.");
@mguinada
mguinada / gist:bd2df384b3bbf2a97a10f16a7a107cd3
Created October 31, 2020 20:46 — forked from rks/gist:2577339
Wrapping exceptions in Ruby
class CustomError < StandardError
def initialize(e = nil)
super e
set_backtrace e.backtrace if e
end
end
def run
r = Runner.new
r.fail
See question on stack overflow: http://stackoverflow.com/questions/28595636/rails-4-how-to-give-alias-names-to-includes-and-joins-in-active-record-que
- Model Student and model Teacher are both STI models with super class model User
- Model Story is a STI model with super class model Task
- includes() and joins(), both fails
Rails alias naming convention (includes() and joins())
- One model as parameter
- is base model (includes(:users))
@mguinada
mguinada / rails_webpacker_bootstrap_expose_jquery.md
Created May 10, 2019 10:26 — forked from andyyou/rails_webpacker_bootstrap_expose_jquery.md
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collects all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
@mguinada
mguinada / gist:0d2ab29084b61aada0b6e7f61dafc446
Created February 28, 2018 11:29 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@mguinada
mguinada / README.md
Created December 16, 2017 18:13 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@mguinada
mguinada / clj_spec_playground.clj
Created July 7, 2017 09:38 — forked from ghoseb/clj_spec_playground.clj
Examples of Clojure's new clojure.spec library
(ns clj-spec-playground
(:require [clojure.string :as str]
[clojure.spec :as s]
[clojure.test.check.generators :as gen]))
;;; examples of clojure.spec being used like a gradual/dependently typed system.
(defn make-user
"Create a map of inputs after splitting name."
([name email]
@mguinada
mguinada / set-game.clj
Created May 10, 2017 09:18 — forked from cgrand/set-game.clj
the SET game in clojure.spec
;; the SET game in clojure.spec
;; inspired by https://github.com/jgrodziski/set-game
(require '[clojure.spec :as s])
(s/def ::shape #{:oval :diamond :squiggle})
(s/def ::color #{:red :purple :green})
(s/def ::value #{1 2 3})
(s/def ::shading #{:solid :striped :outline})
(s/def ::card (s/keys :req [::shape ::color ::value ::shading]))