Skip to content

Instantly share code, notes, and snippets.

@alexkafer
alexkafer / DMXSender.py
Last active September 18, 2022 22:30
A script to send DMX packets using an Enttec DMXUSB PRO for use with the Tesla Works Light Show. Based off data from https://www.enttec.com/docs/dmx_usb_pro_api_spec.pdf and implementation from https://github.com/teslaworksumn/enttec-usb-dmx-pro
import serial
import time
import sys
# Create a new instance of the serial
ser = serial.Serial()
# Set the COM Port the DMX Pro is listening on
ser.port = '/dev/tty.usbserial-EN175330'
@alexkafer
alexkafer / JSONOutput.gs
Created September 26, 2016 22:34
Simple Google Script service that responds to get requests and outputs the data from a Google Sheet
function doGet() {
var spreadsheet = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/1hN_tx5IVVGJHbEhdKWgBowHwgeVTEQbl9h046ZJNyiE/edit#gid=0');
var sheet = spreadsheet.getSheets()[0];
var values = sheet.getSheetValues(1,1, sheet.getLastRow(), 9);
var finalOutput = {
fixtures: []
};
for (var y = 0; y < values.length; y++) {
@alexkafer
alexkafer / LongRunning.swift
Created August 15, 2016 12:57
A simple swift timer program that runs in Xcode Playground
import UIKit
class MyClass {
func startTimer() {
NSTimer.scheduledTimerWithTimeInterval(2, target: self, selector: #selector(MyClass.onTimer(_:)), userInfo: nil, repeats: false)
}
@objc func onTimer(timer:NSTimer!) {
print("Timer here")
@alexkafer
alexkafer / makePhoneCall(phoneNumber: String) .swift
Last active January 31, 2022 21:40
Simple function to prompt a phone call on iOS in Swift
func makePhoneCall(phoneNumber: String) {
if let phoneURL = NSURL(string: ("tel://" + phoneNumber!)) {
let alert = UIAlertController(title: ("Call " + phoneNumber! + "?"), message: nil, preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Call", style: .Default, handler: { (action) in
UIApplication.sharedApplication().openURL(phoneURL)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)