Skip to content

Instantly share code, notes, and snippets.

View mikerodrigues's full-sized avatar

Michael Rodrigues mikerodrigues

View GitHub Profile
@mikerodrigues
mikerodrigues / spotify-kill-pulse-client.sh
Created December 16, 2023 05:36 — forked from fatihkaan22/spotify-kill-pulse-client.sh
Kills unused spotify pulseaudio instances
#! /bin/bash
spotifyInstances=()
while read LINE1; read LINE2; do
IFS=':-='
read -ra L1 <<< $LINE1
read -ra L2 <<< $LINE2
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
-- init.lua
------------
-- Altitude for calculating pressure
alt = 50 -- change this to your altitude in meters
-- Sensor Pins
sda, scl = 3, 4 -- leave these unless you're using different pins
print("Set up i2c...")
i2c.setup(0, sda, scl, i2c.SLOW)
require 'eventmachine'
class EMPD
class CallbackConnection < EM::Connection
def receive_data(data)
# TODO - Parse data, run appropriate callbacks
#
puts data
send_data("idle\n")
module Coinbase
module Exchange
class AsyncClientMock
def orderbook(options={})
{ bids: [['250.00', '1.00', 'abc123-abc123'],
['249.99', '0.30', 'efg456-efg456'],
['249.00', '21.0', 'hij789-hij789']
],
asks: [['250.01', '1.00', '123abc-123abc'],
['250.02', '0.50', '456-efg-456efg'],
@mikerodrigues
mikerodrigues / gist:85ad04bd5b272645d54b
Created June 11, 2015 05:56
Watch ISS HD Earth Viewing Experiment from Ustream via VLC on Ubuntu
sudo apt-get install pip vlc livestream
sudo pip install python-librtmp
livestreamer -p vlc http://www.ustream.tv/embed/17074538\?v\=3 best
module Orderbook
class Listener
attr_reader :queue
def initialize
@queue = Queue.new
subscribe
end
private
module Attribute
def attribute(arg)
if arg.is_a? Hash
name, value = arg.first
elsif arg.is_a? String
name = arg
value = nil
end
@mikerodrigues
mikerodrigues / rdhcpd.rb
Last active August 29, 2015 14:07 — forked from telamon/rdhcpd.rb
' Copyright (c) 2007, Tony Ivanov
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Regex = /(?<start>!)?(?<unit_type>(\d|x))?(?<command>[a-zA-Z]{3})\s?(?<value>.*)(?<terminator>[[:cntrl:]]*$)/
string = "!1MVLQSTN\r\n"
I want to capture "\r\n" as 'terminator' but it only captures "\n", leaving "\r" with the 'value' group.
There may be 0 or more control characters that should be caught by 'terminator', so I'd really like 'terminator' to be any control character at the end of the string.
In other words, current situation: