Skip to content

Instantly share code, notes, and snippets.

View abarth500's full-sized avatar

Shohei Yokoyama abarth500

  • Tokyo Metropolitan University
  • Tokyo Japan
View GitHub Profile
@abarth500
abarth500 / encodeGPolyline.php
Created December 14, 2011 15:37
Generate Encoded Polyline Algorithm Format for Google Static Maps API
<?php
//Generate Encoded Polyline Algorithm Format for Google Static Maps API
// http://bit.ly/sw3deL (Japanese)
// http://bit.ly/tnKt4m (English)
function encodeGPolyline($path){
$enc = "";
$old = true;
foreach($path as $latlng){
if($old === true){
@abarth500
abarth500 / Gist.php
Created December 15, 2011 03:21
Gist Extension for MediaWiki
<?php
# GitHubGist MediaWiki extension v.1
# Author: Shohei Yokoyama (Shizuoka Univ. Japan)
#
#-Install
# 1. Save this code as $MediaWikiRoot/extensions/Gist.php
# 2. Append "require_once "$IP/extensions/Gist.php";" to LocalSetting.php
#
#-Usage
# Tag :
@abarth500
abarth500 / echo.js
Created December 15, 2011 03:30
(Server) WebSocket Chat App. using node.js + websoket modute
#!/usr/local/bin/node
var conn = [];
// https://github.com/Worlize/WebSocket-Node/wiki/Documentation
var WebSocketServer = require('websocket').server;
var http = require('http');
var originIsAllowed = function(){return true;}
var server = http.createServer(function(request, response) {
console.log((new Date()) + " Received request for " + request.url);
response.writeHead(404);
response.end();
@abarth500
abarth500 / echo.html
Created December 15, 2011 03:32
(Client) WebSocket Chat App. using node.js + websoket modute
<!doctype html>
<html>
<head>
<title>node-websocket-server test</title>
</head>
<body>
<div><input id="msg" type="textfield"/><a href="#" id="send">Send</a></div>
<div id="log"></div>
<script type="text/javascript">
var host = "foo.bar.com";// Your WebSocket Server
@abarth500
abarth500 / flann-knn-example.cpp
Created January 11, 2012 03:35
1st step of kNN saerch using FLANN
//============================================================================
// Name : flann-knn-example.cpp
// Author : Shohei Yokoyama
// Copyright : Shizuoka University, Japan
// Description : 1st step of your FLANN application.
// Dependency : FLANN http://people.cs.ubc.ca/~mariusm/index.php/FLANN/FLANN
// : Boost http://www.boost.org/
// : (If win) MinGW & MSYS http://www.mingw.org/
// License : NYSL see http://www.kmonos.net/nysl/index.en.html
//============================================================================
@abarth500
abarth500 / gist:2818216
Created May 28, 2012 09:44
Recursive chmod only of file or directory
# for all files
find . -type f -print | xargs chmod 644
# for all firectories
find . -type d -print | xargs chmod 755
@abarth500
abarth500 / gist:2832728
Created May 30, 2012 02:06
canvas1_MouseMove
private void canvas1_MouseMove(object sender, MouseEventArgs e)
{
//マウスが青い四角領域(canvas1)上で動く度に呼び出されるメソッド
double x = e.GetPosition(canvas1).X; //canvas1の左上をゼロとした座標
double y = e.GetPosition(canvas1).Y;
// カンマで区切ったマウスのxy座標を送信
sendMessage(x + "," + y);
}
@abarth500
abarth500 / gist:2832860
Created May 30, 2012 02:16
receiver on JavaScript
//メッセージはココで受信
//チャンネル削除
msg = msg.substring(msg.indexOf(":")+1);
//カンマで分けて配列へ
fields = msg.split(",");
//注:サーバから来たデータは文字列として扱われているため、
//数値を送った場合使用時はparseInt等で数値化する。
if(X > -1){
ctx.strokeStyle = 'rgb(254, 254, 254)';
ctx.beginPath();
@abarth500
abarth500 / gist:2833029
Created May 30, 2012 02:27
canvas1_MouseDown
private void canvas1_MouseDown(object sender, MouseButtonEventArgs e)
{
}
@abarth500
abarth500 / gist:2833489
Created May 30, 2012 03:08
receiver2 on JavaScript
//メッセージはココで受信
//チャンネル削除
msg = msg.substring(msg.indexOf(":")+1);
//カンマで分けて配列へ
var fields = msg.split(",");
//配列最初の要素はコマンド名なので取り出します。
var cmd = fields.shift();
//コマンドに応じて処理を切り替えます。
switch(cmd){
case "mouse":