Skip to content

Instantly share code, notes, and snippets.

View KensakuKOMATSU's full-sized avatar

Kensaku KOMATSU KensakuKOMATSU

View GitHub Profile
@KensakuKOMATSU
KensakuKOMATSU / gist:2880524
Created June 6, 2012 07:51
three.js sample
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Three.js チュートリアル1</title>
<script src="/javascripts/Three.js"></script>
<style>
body {
background: #333;
@KensakuKOMATSU
KensakuKOMATSU / gist:2941295
Created June 16, 2012 13:07
express-2.5.10 + node-0.7.11 + node-spcy-1.2.0
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, fs = require('fs')
, spdy = require('node-spdy')
var options = {
@KensakuKOMATSU
KensakuKOMATSU / tcp_server.js
Created September 28, 2012 11:32
chrome packaged apps v2 (tcp server)
/**
* manifest.json(server)
*/
{
"manifest_version": 2,
"name": "tcp socket server sample",
"description": "try tcp socket server coding!!",
"version": "0.1",
"minimum_chrome_version": "24",
var xhr = new XMLHttpRequest();
xhr.open("get", "http://m.youtube.com/watch?ajax=1&layout=mobile&tsp=1&utcoffset=540&v=Dbydyibcfi8&preq=");
// xhr.setRequestHeader("User-Agent", "Mozilla/5.0(iPad; U; CPU OS 4_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F191 Safari/6533.18.5")
xhr.onload = function(e) {
console.log(JSON.parse(e.target.responseText.slice(4)).content.video.fmt_stream_map[1].url);
// window.open(JSON.parse(e.target.responseText.slice(4)).content.video.fmt_stream_map[1].url);
}
xhr.send();
@KensakuKOMATSU
KensakuKOMATSU / gist:4152953
Created November 27, 2012 07:32
ws-remocon の bookmarklet
/**
* A remote controller code for Google presentation.
*
* At the preview mode, when you execute below code as a bookmarklet, you can move
* slides next and previous by your handy smartphone.
* This code works with WebSocket application published in https://github.com/KensakuKOMATSU/ws-remocon.
* So, url for websocket server should be changed, depends on your environment.
*/
(function(){
var ws = new WebSocket('ws://localhost:3000');
@KensakuKOMATSU
KensakuKOMATSU / chat.html
Created April 13, 2013 09:03
Peer.jsのチャットサンプルコード(UTF-8対応版w)
<!doctype html>
<html>
<head>
<script type="text/javascript" src="./lib/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="./lib/peer.js"></script>
</head>
<body>
<form id="connect">
<strong>connect to broker</strong><br>
@KensakuKOMATSU
KensakuKOMATSU / sample.html
Created May 9, 2013 10:49
行き過ぎたobject 指向的な書き方
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="./lib/jquery-1.9.1.min.js"></script>
</head>
<body>
<div class="input"></div>
<div class="output"></div>
</body>
@KensakuKOMATSU
KensakuKOMATSU / test.html
Created May 31, 2013 08:23
peer.js in avstream
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script src="peer.js"></script>
<video id="local"></video>
<video id="remote"></video>
<button id="start0">start as 0(caller)</button>
@KensakuKOMATSU
KensakuKOMATSU / uploadimage.js
Created July 29, 2013 00:27
(File System APIの)imgファイルをxhr2でサーバーにuploadするスクリプト
$("<canvas>").appendTo("body");
var canvas = $("canvas")[0]
, ctx = canvas.getContext('2d')
canvas.width = 640, canvas.height = 480;
for(var i = 0, l = ent.length; i < l; i++) {
var imgURL = ent[i];
var img = new Image();
@KensakuKOMATSU
KensakuKOMATSU / fileupload.js
Created July 29, 2013 00:31
node.js(express)で、base64でエンコードされたファイルを保存する
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser({uploadDir:'./uploads'}));
app.use(express.methodOverride());
app.use(allowCrossDomain);
app.use(app.router);