Skip to content

Instantly share code, notes, and snippets.

View salanki's full-sized avatar

Peter Salanki salanki

View GitHub Profile
@salanki
salanki / todo.scpt
Created July 15, 2013 12:20
Automatically add TODOs to Inbox of Things from iMessages beginning with "TODO:"
using terms from application "Messages"
on message received theMessage from theBuddy for theChat
set buddyId to id of theBuddy as text
if (makelower(theMessage) begins with "todo:") then
set trim1 to trim_line(theMessage, "todo:", 0)
set trim2 to trim_line(trim1, " ", 0)
tell application "Things 2"
set newToDo to make new to do ¬
with properties {name:trim2, notes:"From: " & buddyId}
@salanki
salanki / mac2ip.scala
Created July 6, 2011 21:58
Mac2IP implementation
package com.proceranetworks.psm.leasepoller
package twpoller
import java.net.InetAddress
import java.nio.ByteBuffer
object ByteBufferImplicits {
implicit def byteBuffer2PimpedByteBuffer(buffer: ByteBuffer): PimpedByteBuffer = new PimpedByteBuffer(buffer)
}
class PimpedByteBuffer(buffer: ByteBuffer) {
def union[A](a: Set[A], b: Set[A]) {
var c = b
for(item <- a) {
c += item
}
c
}
OR:
@salanki
salanki / CiscoNACAppliance.scala
Created February 9, 2011 00:42
Beginning of API implementation for the Cisco NAC Appliance in Scala. Should be easily usable from Java, depends on dispatch-http.
package cisconacpoller
import scala.util.matching.Regex
trait Response
case class FailResponse(reason: String) extends Response
object NoSuchUserFailure extends FailResponse("No logged in user matches the criteria")
object InvalidCredentialsFailure extends FailResponse("Username or password is incorrect")