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 / gist:4214574
Created December 5, 2012 10:30
Simple Example for Handling Multi-touch Event on JavaScript
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://extjs-public.googlecode.com/svn/extjs-4.x/release/resources/css/ext-all.css" />
<script type="text/javascript" src="http://extjs-public.googlecode.com/svn/extjs-4.x/include/ext-all.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
var touchInf = {};
Ext.getDom("panel").addEventListener("touchstart",function(e){
for(var c = 0; c < e.changedTouches.length; c++){
@abarth500
abarth500 / gist:bea5bd5ce8fa910a06f13cd5c99e855d
Created December 20, 2019 02:07
Overpass Turboで指定した範囲内の道を得るクエリ
// https://overpass-turbo.eu/
// 上記のURLに行ってこのコードをペーストし、地図でBBOXを指定し、実行する。
[out:json];
way["highway"]({{bbox}});
foreach((._;>;);out;);
@abarth500
abarth500 / encodeGPolyline.js
Created May 30, 2012 15:17
Generate Encoded Polyline Algorithm Format for Google Static Maps API (JavaScript)
//Generate Encoded Polyline Algorithm Format for Google Static Maps API
// http://bit.ly/sw3deL (Japanese)
// http://bit.ly/tnKt4m (English)
function encodeGPolyline(path){
var enc = "";
var old = true;
for(c in path){
var latlng = path[c];
if(old === true){
const int ledPin = 7;
const int speakerPin = 9;
void setup() {
pinMode(2, INPUT_PULLUP);
pinMode(7, OUTPUT);
pinMode(9, OUTPUT);
attachInterrupt(0, speaker, FALLING);
}
@abarth500
abarth500 / index.html
Created January 24, 2019 06:51
Blockly workspace.js with XML file loading
Promise.all(
["workspace.xml", "toolbox.xml"].map(async file => {
return fetch(file).then(
(res) => {
return res.text();
}
);
})
).then((xmls) => {
xmls.forEach((xml) => {
@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 / lcs.js
Last active January 17, 2018 08:32 — forked from greduan/lcs.js
LCS algorithm in JS. Prettified version of what can be found here: https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_subsequence#JavaScript
// prettified version of what can be found here:
// https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_subsequence#JavaScript
function LCS(a, b) {
var m = a.length,
n = b.length,
C = [],
i,
j;
for (i = 0; i <= m; i++) C.push([0]);
//Parameter K
var k = 30;
//need async and flickr lib
// npm install async
// npm install flickrapi
/* Internal Arguments for the algorithm A
var c = {};
var n = 0;
@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();
sudo vim /root/credentials_nas.txt
#書き込む内容は下のcredentials_nas.txtを参照せよ
#作成終わったらパーミッションをrootのみに限定する
sudo chown root:toot /root/credentials_nas.txt
sudo chmod 600 /root/credentials_nas.txt