Skip to content

Instantly share code, notes, and snippets.

@laclefyoshi
laclefyoshi / gist:727799
Created December 4, 2010 01:07
Arduino code using aJson, Matrix and Ethernet
/**
Copyright: (c) SAEKI Yoshiyasu
License : MIT-style license
<http://www.opensource.org/licenses/mit-license.php>
last updated: 2010/12/03
**/
#include <SPI.h>
#include <Ethernet.h>
#include <aJSON.h>
@laclefyoshi
laclefyoshi / pyinotify.txt
Created December 11, 2010 06:25
using pyinotify
$ python -m pyinotify TARGET_DIR
## ls
<event dir="True" mask="0x40000020" maskname="IN_OPEN|IN_ISDIR" name="" path="TARGET_DIR" pathname="/home/saeki/TARGET_DIR" wd="1">
<event dir="True" mask="0x40000010" maskname="IN_CLOSE_NOWRITE|IN_ISDIR" name="" path="TARGET_DIR" pathname="/home/saeki/TARGET_DIR" wd="1">
## touch test1
<event dir="False" mask="0x100" maskname="IN_CREATE" name="test1" path="TARGET_DIR" pathname="/home/saeki/TARGET_DIR/test1" wd="1">
<event dir="False" mask="0x20" maskname="IN_OPEN" name="test1" path="TARGET_DIR" pathname="/home/saeki/TARGET_DIR/test1" wd="1">
<event dir="False" mask="0x4" maskname="IN_ATTRIB" name="test1" path="TARGET_DIR" pathname="/home/saeki/TARGET_DIR/test1" wd="1">
@laclefyoshi
laclefyoshi / pyinotify_test.py
Created December 11, 2010 05:54
script using pyinotify
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright : (c) SAEKI Yoshiyasu
# License : MIT-style license
# <http://www.opensource.org/licenses/mit-license.php>
# last updated: 2010/12/11
import pyinotify
@laclefyoshi
laclefyoshi / gist:754682
Created December 25, 2010 04:29
Arduino code for controlling GLCD through Serial port
/**
Copyright: (c) SAEKI Yoshiyasu
License : MIT-style license
<http://www.opensource.org/licenses/mit-license.php>
last updated: 2010/12/24
**/
#include <ks0108.h>
int inByte = 0;
@laclefyoshi
laclefyoshi / sketch_websocket.py
Created December 25, 2010 04:32
WebSocket server for communicating Web browser and Arduino
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright : (c) SAEKI Yoshiyasu
# License : MIT-style license
# <http://www.opensource.org/licenses/mit-license.php>
# last updated: 2010/12/24
import tornado.httpserver
import tornado.ioloop
import tornado.web
@laclefyoshi
laclefyoshi / sketch.html
Created December 25, 2010 04:34
Web page for drawing a picture and sending the drawing data to WebSocket server
<!DOCTYPE html>
<html lang="jp" xml:lang="jp">
<head>
<meta charset="utf-8">
<title>Sketch</title>
<style>
body{
margin: 0px; padding: 0px;
}
canvas {
@laclefyoshi
laclefyoshi / googleearth.py
Created January 1, 2011 08:12
Controlling Google Earth for Mac
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright : (c) SAEKI Yoshiyasu
# License : MIT-style license
# <http://www.opensource.org/licenses/mit-license.php>
# last updated: 2011/01/01
import subprocess
import time
@laclefyoshi
laclefyoshi / gist:800363
Created January 28, 2011 15:12
Arduino Metro
#include <Metro.h>
#define LedPin1 10
#define LedPin2 9
Metro ledMetro1 = Metro(1000);
Metro ledMetro2 = Metro(2000);
void setup() {
pinMode(LedPin1, OUTPUT);
@laclefyoshi
laclefyoshi / gist:800391
Created January 28, 2011 15:30
Arduino protothread
#include <pt.h>
#define LedPin1 12
#define LedPin2 11
static struct pt pt1, pt2;
static int protothread1(struct pt *pt) {
static unsigned long timestamp = 0;
PT_BEGIN(pt);
@laclefyoshi
laclefyoshi / gist:800403
Created January 28, 2011 15:35
Arduino protothread + Metro
#include <pt.h>
#include <Metro.h>
#define LedPin1 12
#define LedPin2 11
#define LedPin3 10
#define LedPin4 9
static struct pt pt1, pt2;