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.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){
@abarth500
abarth500 / gist:2850913
Created June 1, 2012 10:04
Direction of two points
<?php
function getDirection($point1,$point2){
$lat1 = $point1->lat;
$lng1 = $point1->lng;
$lat2 = $point1->lat;
$lng2 = $point1->lng;
$Y = cos($lat2) * sin($lng2 - $lng1);
$X = cos($lat1) * sin($lat2) - sin($lat1) * cos($lat2) * cos($lng2 - $lng1);
$a = atan2($Y, $X);
if($a <0){
@abarth500
abarth500 / gist:2850927
Created June 1, 2012 10:07
Distance between two points
function getDistance(point1,point2){
var my = ((point1.lat + point2.lat) / 2.0) * Math.PI / 180.0;
var dy = (point1.lat - point2.lat) * Math.PI / 180.0;
var dx = (point1.lng - point2.lng) * Math.PI / 180.0;
var w = Math.sqrt(1.0 - 0.0066943799901975 * Math.pow(Math.sin(my),2));
return Math.sqrt(Math.pow(dy * 6335439.32729246 / Math.pow(w,3),2)
+ Math.pow(dx * 6378137.000 * Math.cos(my) / w,2));
}
@abarth500
abarth500 / gist:2922538
Created June 13, 2012 07:32
Google API (読み上げ)
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>TM Labo: Google API - 読み上げ機能(非公式API)</title>
<style>
/* 等幅にしておく */
* {
font-family: monospace;
}
@abarth500
abarth500 / gist:2940546
Created June 16, 2012 08:41
06/16のプログラム
<html>
<head>
<script type="text/javascript" src="ext-core.js"></script>
<script>
var Cell = function(){
this.status = false;
this.numAlive = 0;
}
Cell.prototype.getNext = function(){
@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++){
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 256
@abarth500
abarth500 / gist:5418601
Last active December 16, 2015 10:18
[情報科学科実験I] 最新のソフトウェアへバージョンアップする
sudo yum update
@abarth500
abarth500 / gist:5418611
Last active December 16, 2015 10:18
[情報科学科実験I] ユーザを追加する
#ユーザを追加する
sudo useradd yokoyama
#ユーザにパスワードを付与する
sudo passwd yokoyama
#ここで(パスワードを二回入力する)
#ユーザがsudo出来るようにする
sudo usermod -G wheel -a yokoyama
@abarth500
abarth500 / gist:5418875
Last active December 16, 2015 10:19
[情報科学科実験I] ネットワークの設定
#ファイアウォールでWebサーバへの接続を許可する
sudo firewall-cmd --add-service=http
sudo firewall-cmd --permanent --add-service=http
#SELinuxを無効にする
sudo setenforce 0
#次回立ち上げ時もSELinuxを無効にする
sudo vi /etc/sysconfig/selinux
#ここからはviエディタでの作業になります。