Skip to content

Instantly share code, notes, and snippets.

View mkarliner's full-sized avatar

Michael Karliner mkarliner

View GitHub Profile
package main
import "net/http"
func main() {
panic(http.ListenAndServe(":8080", http.FileServer(http.Dir("."))))
}
// readCapacitivePin
// Input: Arduino pin number
// Output: A number, from 0 to 17 expressing
// how much capacitance is on the pin
// When you touch the pin, or whatever you have
// attached to it, the number will get higher
#include "pins_arduino.h" // Arduino pre-1.0 needs this
uint8_t readCapacitivePin(int pinToMeasure) {
// Variables used to translate from Arduino to AVR pin naming
volatile uint8_t* port;
@mkarliner
mkarliner / aes_crypt.rb
Created March 22, 2013 11:17
Using OpenSSL with Ruby to do AES encryption
# This module for using AES encryption with ruby from
# http://www.brentsowers.com/2007/12/aes-encryption-and-decryption-in-ruby.html
require 'openssl'
require "base64"
module AESCrypt
# Decrypts a block of data (encrypted_data) given an encryption key
# and an initialization vector (iv). Keys, iv's, and the data
# returned are all binary strings. Cipher_type should be
# "AES-256-CBC", "AES-256-ECB", or any of the cipher types