Skip to content

Instantly share code, notes, and snippets.

View yagitoshiro's full-sized avatar

yagi_ yagitoshiro

View GitHub Profile
//ブラウザ全体でWebsocketを落としたらどうなるか試験するときに使う
// https://stackoverflow.com/a/31526291/5518615
var WebSocket2 = WebSocket;
WebSocket = function(addy) {
var ws;
if (!this.blocked) {
console.log('WS: Not blocked, allowing.');
ws = new WebSocket2(addy);
this.open_sockets.push(ws);
@yagitoshiro
yagitoshiro / line_bot.js
Last active April 14, 2017 23:20
LINE API v2
/*
Usage: yarn add request
```
var linebot = require('./line_bot');
var LineBot = bot.new({
channelSecret: <YOUR CHANNEL SECRET>,
channelAccessToken: <YOUR CHANNEL ACCESS TOKEN>
});
```
@yagitoshiro
yagitoshiro / TiDomParser.js
Last active January 17, 2018 11:30
Slightly modified com.hamasyou.XML.TiDomParser
//Usage:
//var xml2json = require('TiDomParser');
//xml2json(Ti.XML.parseString(xmlString));
//original: http://hamasyou.com/blog/2010/09/15/titanium-xml2json-xml-json/
/**
* @author hamasyou
* Copyright (C) 2010 hamasyou, INC. All Rights Reserved.
*
@yagitoshiro
yagitoshiro / gist:572ca78198094a0c4bbe
Last active August 29, 2015 14:22
緯度経度から二点間距離の計算をざっくり
private double deg2rad(double deg) {
return (deg * Math.PI / 180.0);
}
private double rad2deg(double rad) {
return (rad * 180.0 / Math.PI);
}
@Kroll.method
public Double calcDistance(double lat1, double lon1, double lat2, double lon2, String unit){
double theta = lon1 - lon2;
# '60s
1960 Joan Baez
1961 Judy Collins
1962 Peter, Paul and Mary
1962 Sylvie Vartan
1963 Elis Regina
@yagitoshiro
yagitoshiro / gist:d6e0e17e9566801c8eaf
Last active August 29, 2015 14:19
Google Play Servicesの最新版が入っているか確認する
if(Ti.Platform.osname == 'android'){
var MapModule = require('ti.map');
var rc = MapModule.isGooglePlayServicesAvailable();
if(rc != MapModule.SUCCESS){
var dialog = Ti.UI.createAlertDialog({
title: 'ご利用の前に',
message: '本アプリを快適にご利用頂くために必要なアプリがあります。インストールしますか?',
buttonNames: ['インストールする', '今回はキャンセルする']
});
dialog.addEventListener('click', function(e){
@yagitoshiro
yagitoshiro / gist:85e6bfdd5e469841814f
Created December 28, 2014 04:20
ActiveResourceでLoopbackを使う
#app/models/concerns/loopback.rb
module Loopback
extend ActiveSupport::Concern
included do
class << self
def element_path(id, prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}/#{id}#{query_string(query_options)}"
end
var win = Ti.UI.createWindow({backgroundColor: '#FFFFFF', tabBarHidden:true, title: '素敵な右側'});
var detailNav = Ti.UI.iOS.createNavigationWindow({window:win});
var masterWindow = Ti.UI.createWindow({backgroundColor:'#FFFFFF', tabBarHidden:true, title:'ナイス左側'});
var rows = [];
for( var i = 0; i < 5; i++ ){
rows.push(Ti.UI.createTableViewRow({
title: "title " + (i+1),
hasChild: true
}));
@yagitoshiro
yagitoshiro / gist:7538879
Created November 19, 2013 01:48
tableView + tableViewRows + scrollableView
var rows = [];
var table = Ti.UI.createTableView({top: 20});
for(var i = 0; i < 2; i++){
var row = Ti.UI.createTableViewRow({
id: row + i.toString(), title: i.toString(), height: 110
});
rows.push(row);
}
var views = [];
views.push(Ti.UI.createImageView({height: 100, width: Ti.UI.SIZE, image:'images/black-cat.jpg'}));
@yagitoshiro
yagitoshiro / gist:7247327
Created October 31, 2013 10:13
support: tiapp.xml
<sdk-version>3.1.1.GA</sdk-version>
<modules>
<module platform="iphone">com.ti.calendar.permission</module>
</modules>