Skip to content

Instantly share code, notes, and snippets.

@mveinot
mveinot / sendLCDcommand.pl
Created November 28, 2015 14:31
Send commands to a connected LCD over serial
#!/usr/bin/perl -w
use strict;
use warnings;
chomp(my $status = `osascript -e 'tell application "iTunes" to player state as string'`);
if ($status eq 'playing')
{
chomp(my $artist = `osascript -e 'tell application "iTunes" to artist of current track as string'`);
@mveinot
mveinot / iTunesLCD.cpp
Created November 28, 2015 14:28
Monitor serial for commands
#include <LiquidCrystal.h>
// tell the library which pins the LCD is connected on
LiquidCrystal lcd(12,11,10,5,4,3,2);
void setup()
{
// initialize the serial port to 9600 baud (it's fast enough)
Serial.begin(9600);
// initialize the lcd to 16 columns, 2 rows
@mveinot
mveinot / gist:c194d9cbc366144ed62d
Last active August 29, 2015 14:23
Look for a specified USB device
#!/bin/bash
# Specify the product ID of your device
DEVICE="0x2838"
# the command to list USB devices
USB_DEVICE_CMD="system_profiler SPUSBDataType"
# get the list and filter for the device we're looking for
DEVICE_PRESENT=`$USB_DEVICE_CMD | grep $DEVICE | cut -f2 -d':'`
function highlightSearchTerms(sword) {
$$('body').map(Element.extend).first().descendants().each(function (el) {
if (el.nodeType == Node.ELEMENT_NODE && el.tagName != 'TEXTAREA' && el.tagName != 'INPUT' && el.tagName != 'SCRIPT') {
$A(el.childNodes).each(function (onlyChild) {
var pos = onlyChild.textContent.indexOf(sword);
if (onlyChild.nodeType == Node.TEXT_NODE && pos >= 0) {
//console.log(onlyChild);
var spannode = document.createElement('span');
spannode.className = 'highlight';
var middlebit = onlyChild.splitText(pos);
<?php
$address = isset($_GET['address'])?$_GET['address']:null;
header("Access-Control-Allow-Origin: *");
header("Content-type: application/json");
function get_w1_address($address)
{
$bus_addr = substr($address,0,2).'-';
@mveinot
mveinot / gist:5670452
Created May 29, 2013 13:59
Example I2C code on Arduino
// This is the I2C Master
#include <Wire.h>
#define LED_PIN 13
byte x = 0;
void setup()
{
Wire.begin(); // Start I2C Bus as Master