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
function(sprite, spriteContainer) {
// All of the mouse event sequences look like this:
// seq([ {pageX: 22, pageY: 3423, offsetX: 14, offsetY: 22} ,,, ])
var spriteMouseDowns = Observable.fromEvent(sprite, "mousedown"),
spriteContainerMouseMoves = Observable.fromEvent(spriteContainer, "mousemove"),
spriteContainerMouseUps = Observable.fromEvent(spriteContainer, "mouseup"),
// Create a sequence that looks like this:
// seq([ {pageX: 22, pageY:4080 },,,{pageX: 24, pageY: 4082},,, ])
spriteMouseDrags =
// For every mouse down event on the sprite...
function(sprite, spriteContainer) {
var spriteMouseDowns = Observable.fromEvent(sprite, "mousedown"),
spriteContainerMouseMoves = Observable.fromEvent(spriteContainer, "mousemove"),
spriteContainerMouseUps = Observable.fromEvent(spriteContainer, "mouseup"),
spriteMouseDrags =
// For every mouse down event on the sprite...
spriteMouseDowns.
flatMap(function() {
return spriteContainerMouseMoves;
}).takeUntil(spriteContainerMouseUps);
@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 / 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)
@Wei1234c
Wei1234c / SSHD.armv7.dockerfile
Last active September 4, 2015 02:01
Dockerfile for SSHD with Ubuntu on RPi2
# sshd
# VERSION: 0.0.2
# origin:
# MAINTAINER Sven Dowideit <SvenDowideit@docker.com>
# https://docs.docker.com/examples/running_ssh_service/
#
# modified by: Wei Lin
# date: 2015/9/2
# Pull base image.
@Wei1234c
Wei1234c / Oracle-Java8.armv7.dockerfile
Last active September 4, 2015 02:55
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
Last active September 5, 2015 07:36
Dockerfile for caterpillar/rpi-dev-java
FROM armv7/armhf-ubuntu:14.04
MAINTAINER Justin Lin <caterpillar@openhome.cc>
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 / Dockerfile
Last active September 5, 2015 07:37
Dockerfile for caterpillar/rpi-gradle
FROM resin/rpi-raspbian
MAINTAINER Justin Lin <caterpillar@openhome.cc>
# 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 / gossip-0.1.js.md
Last active December 12, 2015 03:18
The Example of "JavaScript Essence: Writing a Utility Library"

The Example of JavaScript Essence: Writing a Utility Library

(function(global) {
    var XD = {
        trim: function(text) {
            return (text || '').replace( /^(\s|\u00A0)+|(\s|\u00A0)+$/g, '');
        },
        isArray: function(obj) {
            return Object.prototype.toString.call(obj) === '[object Array]';
@JustinSDK
JustinSDK / gossip-0.3.js.md
Last active December 14, 2015 01:49
The Example of "JavaScript Essence: Writing an Event Library"