Skip to content

Instantly share code, notes, and snippets.

@misza222
misza222 / digital_read_serial.c
Created March 1, 2014 17:33
Arduino DigitalReadSerial
/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the serial monitor
This example code is in the public domain.
*/
// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;
// the setup routine runs once when you press reset:
Parsing recipes: 100% |#############################################################| Time: 00:00:55
Parsing of 885 .bb files complete (0 cached, 885 parsed). 1227 targets, 44 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.20.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "Ubuntu-12.04"
TARGET_SYS = "i586-poky-linux"
MACHINE = "clanton"
@misza222
misza222 / digital_read_serial.py
Created March 3, 2014 11:58
Digital Read Serial - Intel Galileo example in python
# This is a simple example of interacting with digital input of Intel Galileo board
# See http://arduino.cc/en/Tutorial/DigitalReadSerial
# and http://www.itsudo.com/galileo/2014/03/01/reading-digital-input-from-galileo-via-sysfs.html
import os
import time
button_gpio = 17 # maps to digital PIN5 on the board
# Export gpio port so we can interact with it
@misza222
misza222 / drive_led_with_button.js
Created March 3, 2014 17:23
Driving LED on Intel Galileo with push button
var fs = require('fs');
var button_gpio = 17; // maps to digital PIN5 on the board
var led_gpio = 27; // maps to digital PIN7
var fileOptions = {encoding: 'ascii'};
var exportGpio = function(gpio_nr) {
fs.writeFile('/sys/class/gpio/export', gpio_nr, fileOptions, function (err) {
if (err) { console.log("Couldn't export %d, probably already exported.", gpio_nr); }

Turn on/off a LED from a web page

VIDEO

module Rack
# Redirects to correct domain
class RedirectToDomain
HOST = 'example.com'
def initialize(app)
@app = app
end
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html' http-equiv='Content-Type' />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="util.js"></script>
<script type="text/javascript">
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
var field1 = $("input[name='field1']");
var field2 = $("input[name='field2']");
field2.attr('maxlength', field1.attr('maxlength'));
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(:default, Rails.env) if defined?(Bundler)
module MyApp
class Application < Rails::Application
config.encoding = "utf-8"
class ShopRoutesConstraint
def self.matches?(request)
! ADMIN_DOMAIN_NAMES.include?(request.host)
end
end
class AdminRoutesConstraint
def self.matches?(request)
ADMIN_DOMAIN_NAMES.include?(request.host)
end