Skip to content

Instantly share code, notes, and snippets.

View amicojeko's full-sized avatar

Stefano Guglielmetti amicojeko

View GitHub Profile
@amicojeko
amicojeko / MCP230xx.nut
Last active December 19, 2015 09:49 — forked from marcboon/MCP230xx.nut
// Base class for MCP23008 and MCP23017 family of I2C i/o expanders
class MCP230xx {
BASE_ADDR = 0x20
i2cPort = null
i2cAddr = null
regs = null
constructor(i2cPort, deviceAddr) {
this.i2cPort = i2cPort
this.i2cAddr = (BASE_ADDR + deviceAddr) << 1
@amicojeko
amicojeko / designer.html
Last active August 29, 2015 14:07
designer
<link rel="import" href="../chart-js/chart-js.html">
<link rel="import" href="../yt-video/yt-search-video.html">
<link rel="import" href="../smoothie-chart/smoothie-chart.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
# -*- ~/.tmux.conf -*-
#
# - jeko@jeko.net -
#
set -g mode-mouse on
set -g monitor-activity on
set -g utf8 on
set -g mouse-select-pane on
set -g mouse-select-window on
set -g mouse-resize-pane on
@amicojeko
amicojeko / gist:26b6848df19c277cee0b
Last active August 29, 2015 14:24
Broken Module Prepend in Ruby
module ExtraMessageLogging
def do_something
super
puts "Prepend from #{self.class.name}"
end
end
module AnotherExtraMessageLogging
def do_something
super
module HiddenLogger
def inject_log(method_name)
instance_exec(method_name) do |method_name|
def method_name_with_logging
method_name_without_logging
puts "Sarcazzo: #{@foo}"
end
// Changes the RGB/HEX temporarily to a HSL-Value, modifies that value
// and changes it back to RGB/HEX.
function changeHue(rgb, degree) {
var hsl = rgbToHSL(rgb);
hsl.h += degree;
if (hsl.h > 360) {
hsl.h -= 360;
}
else if (hsl.h < 0) {
@amicojeko
amicojeko / jekobot.js
Last active March 22, 2016 15:57
JekoBot typewriter edition
// easy win @ http://10fastfingers.com/typing-test
setInterval( function(){
$('#inputfield').val($(".highlight").html());
$('#inputfield').trigger(
jQuery.Event('keyup', {which: 32})
);
}, 100);
@amicojeko
amicojeko / nested_form_controller.js
Last active January 5, 2024 04:35
Stimulus nested form (cocoon alternative)
// Visit The Stimulus Handbook for more details
// https://stimulusjs.org/handbook/introduction
//
// This example controller works with specially annotated HTML like:
//
// <h4>Tasks</h4>
// <div data-controller="nested-form">
// <template data-target="nested-form.template">
// <%= form.fields_for :tasks, Task.new, child_index: 'NEW_RECORD' do |task| %>
// <%= render "task_fields", form: task %>
@amicojeko
amicojeko / rgbLed.ino
Created November 28, 2020 18:07
RGB Led effects experiment
int redPin = 9;
int greenPin = 10;
int bluePin = 11;
int buttonPin = 2;
int buttonState = 0;
int lastButtonState = 0;
char cmdBuffer[2];
int counter = 0;
@amicojeko
amicojeko / clipboard.rb
Last active February 2, 2021 08:57
Copy to clipboard with Ruby
# Windows and WSL
def clip_copy(input)
str = input.to_s
IO.popen('clip.exe', 'w') { |f| f << str }
str
end
# Mac