This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Typeable | |
import Prelude hiding (catch, readFile) | |
import Control.Exception hiding (finally) | |
import System.Environment | |
import System.IO hiding (readFile) | |
readFile :: FilePath -> IO String | |
readFile fileName = | |
bracket (openFile fileName ReadMode) hClose (\handle -> do | |
contents <- hGetContents handle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
instance Functor (Either a) where | |
fmap f (Right x) = Right (f x) | |
fmap f (Left x) = Left x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sequence' :: Monad m => [m a] -> m [a] | |
sequence' [] = return [] | |
sequence' (x:xs) = do | |
value <- x | |
values <- sequence' xs | |
return (value : values) | |
forM' :: Monad m => [a] -> (a -> m b) -> m [b] | |
forM' xs f = sequence' $ map f xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Bridge.h> | |
#include <YunServer.h> | |
#include <YunClient.h> | |
// Yun server | |
YunServer server; | |
void setup() { | |
// Join i2c bus (address optional for master) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
// Motor pins | |
int speed_motor1 = 6; | |
int speed_motor2 = 5; | |
int direction_motor1 = 7; | |
int direction_motor2 = 8; | |
// Sensor pins | |
int distance_sensor = A0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM resin/rpi-raspbian | |
MAINTAINER Justin Lin <[email protected]> | |
# Basic tools | |
RUN apt-get -qq update && \ | |
apt-get -qqy install wget && \ | |
apt-get -qqy install vim && \ | |
apt-get -qqy install unzip && \ | |
apt-get -qqy install git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Oracle Java 8 Dockerfile | |
# | |
# https://github.com/dockerfile/java | |
# https://github.com/dockerfile/java/tree/master/oracle-java8 | |
# | |
# origin: https://github.com/dockerfile/java/blob/master/oracle-java8/Dockerfile | |
# modified by: Wei Lin | |
# date: 2015/9/2 | |
# Pull base image. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sshd | |
# VERSION: 0.0.2 | |
# origin: | |
# MAINTAINER Sven Dowideit <[email protected]> | |
# https://docs.docker.com/examples/running_ssh_service/ | |
# | |
# modified by: Wei Lin | |
# date: 2015/9/2 | |
# Pull base image. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM armv7/armhf-ubuntu:14.04 | |
MAINTAINER Justin Lin <[email protected]> | |
ENV TERM linux | |
# Basic tools | |
RUN apt-get -qq update && \ | |
apt-get -qqy install wget && \ | |
apt-get -qqy install vim && \ | |
apt-get -qqy install unzip && \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <LiquidCrystal_I2C.h> | |
#include <DHT.h> | |
#define MG_PIN (0) //define which analog input channel you are going to use | |
#define DC_GAIN (8.5) //define the DC gain of amplifier | |
#define READ_SAMPLE_INTERVAL (50) //define how many samples you are going to take in normal operation | |
#define READ_SAMPLE_TIMES (5) //define the time interval(in milisecond) between each samples in | |
//normal operation | |