Skip to content

Instantly share code, notes, and snippets.

View JustinSDK's full-sized avatar
👨‍👩‍👧
Working from home

Justin Lin JustinSDK

👨‍👩‍👧
Working from home
View GitHub Profile
@JustinSDK
JustinSDK / Finally.hs
Last active August 29, 2015 14:15
〈Haskell Tutorial(23)Exception 的 catch 與 handle〉的解答
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
@JustinSDK
JustinSDK / EitherFunctor.hs
Created February 15, 2015 00:55
〈Haskell Tutorial(25)可映射盒中物行為的 Functor〉的解答
instance Functor (Either a) where
fmap f (Right x) = Right (f x)
fmap f (Left x) = Left x
@JustinSDK
JustinSDK / ForM.hs
Created February 26, 2015 09:40
〈Haskell Tutorial(31)do 區塊與 <- 綁定〉的習題解答
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
@JustinSDK
JustinSDK / yun.ino
Created July 22, 2015 03:03
Arduino Yún 加 Motoduino 的網路小車(一)
#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)
@JustinSDK
JustinSDK / motoduino.ino
Created July 22, 2015 03:04
Arduino Yún 加 Motoduino 的網路小車(二)
#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;
@JustinSDK
JustinSDK / Dockerfile
Last active September 5, 2015 07:37
Dockerfile for caterpillar/rpi-gradle
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
@JustinSDK
JustinSDK / Dockerfile_for_Oracle-Java8_with_Ubuntu_on_RPi2.dockerfile
Last active September 2, 2015 22:55 — forked from Wei1234c/Oracle-Java8.armv7.dockerfile
Dockerfile for Oracle-Java8 with Ubuntu on RPi2
# 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.
@JustinSDK
JustinSDK / Dockerfile_for_SSHD_with_Ubuntu_on_RPi2.dockerfile
Last active September 2, 2015 23:36 — forked from Wei1234c/SSHD.armv7.dockerfile
Dockerfile for SSHD with Ubuntu on RPi2
# 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.
@JustinSDK
JustinSDK / Dockerfile
Last active September 5, 2015 07:36
Dockerfile for caterpillar/rpi-dev-java
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 && \
@JustinSDK
JustinSDK / co2_tempature_humdity.ino
Last active September 30, 2015 06:24
自製 CO2、溫溼度感應器
#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