This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'bundler/setup' | |
| require 'dotenv' | |
| require 'sinatra' | |
| require 'sinatra/streaming' | |
| require 'json' | |
| require 'typhoeus' | |
| set :server, 'thin' # not sure if puma also has streaming nowadays? | |
| Dotenv.load |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This script automatically generates a pop for the talon zoom mouse every n seconds, | |
| # then another one 2 seconds later. For when you want to do a ton of clicking actions | |
| # without getting jaw cramp. If you don't want to click, just look away within 2 seconds. | |
| from talon import Context, Module, actions, app, cron, ctrl, imgui, noise, settings, ui | |
| from talon_plugins import eye_mouse, eye_zoom_mouse, speech | |
| from talon_plugins.eye_mouse import config, toggle_camera_overlay, toggle_control | |
| # Put the following at the bottom of talon/resources/talon_plugins/eye_zoom_mouse.py | |
| # (you will need to reapply this after every talon update) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # demo: https://www.youtube.com/watch?v=MZ3M0ePA5U4&feature=youtu.be | |
| # this depends on the imitone software to convert whistling into midi | |
| require "rtmidi" | |
| midiin = RtMidi::In.new | |
| MATCHERS = { | |
| [0..2, 3..5] => "Page_Up", | |
| [3..5, 0..2] => "Page_Down", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'parser/current' | |
| require 'rexml/document' | |
| class XMLAST | |
| include REXML | |
| attr_reader :doc | |
| def initialize sexp | |
| @doc = Document.new "<root></root>" | |
| @sexp = sexp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| irb> xml.xpath('*/send/hash/pair[sym[symbol-val/@value="placeholder"]]/str') | |
| => [s(:str, "placeholder text")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| irb> require 'parser/current' | |
| irb> require 'rexml/document' | |
| irb> snippet = 'f.text_field :attr, placeholder: "placeholder text"' | |
| irb> exp = Parser::CurrentRuby.parse(snippet) | |
| irb> xml = XMLAST.new(exp) | |
| irb> xml.doc.write(STDOUT, 2) | |
| <root> | |
| <send> | |
| <send> | |
| <nilclass-val /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Controller | |
| BANKS = %w{wmii chromium thunderbird misc vim} | |
| DIRECTIONS = [nil, 'left', 'down', 'right', nil, nil, 'up'] | |
| def process bank_index, value | |
| bank = BANKS[bank_index] | |
| puts "bank #{bank || bank_index}, value #{value}" | |
| begin | |
| puts send(:"#{bank}_bank", value) || 'command not found' |