Skip to content

Instantly share code, notes, and snippets.

View yagitoshiro's full-sized avatar

yagi_ yagitoshiro

View GitHub Profile
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: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
@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){
# '60s
1960 Joan Baez
1961 Judy Collins
1962 Peter, Paul and Mary
1962 Sylvie Vartan
1963 Elis Regina
@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;
@yagitoshiro
yagitoshiro / my appcelerator backtrace
Created January 20, 2011 19:55
my appcelerator backtrace
0 CoreFoundation 0x0234457c __exceptionPreprocess + 156
1 libobjc.A.dylib 0x02498313 objc_exception_throw + 44
2 CoreFoundation 0x0233a1bc -[__NSArrayI objectAtIndex:] + 236
3 MyApp 0x0010719b -[InnerScrollView viewForZoomingInScrollView:] + 66
4 UIKit 0x008c75a0 -[UIScrollView _getDelegateZoomView] + 117
5 UIKit 0x008c9d75 -[UIScrollView _centerContentIfNecessary] + 36
6 UIKit 0x008c8aea -[UIScrollView layoutSubviews] + 72
7 QuartzCore 0x019e8c6a -[CALayer layoutSublayers] + 181
8 QuartzCore 0x019eafec CALayerLayoutIfNeeded + 220
9 QuartzCore 0x01990400 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
@yagitoshiro
yagitoshiro / gist:1130949
Created August 7, 2011 23:55
simple sqlite script(excerpt) for titanium mobile
// Before proceeding, you must create sqlite database "test.db" in Resources directory.
Ti.Database.install('test.db', 'tests'),
function insert(data){
var sql = "INSERT INTO samples (id, title, sample) VALUES (?, ?, ?)";
try{
this.db.execute(sql, data.id, data.title, data.sample);
}catch(e){
Ti.API.info('insert error:' + sql);
}
@yagitoshiro
yagitoshiro / gist:1228967
Created September 20, 2011 12:25
coffee script sample testing...
//app.js
(function() {
var person, syrup;
syrup = require('syrup');
syrup.include('/model/entity');
syrup.include('/model/person');
person = new MYAPP.Model.Person('Coffee syrup');
person.sayHello();
}).call(this);
@yagitoshiro
yagitoshiro / gist:1247519
Created September 28, 2011 09:54
Titanium Mobile (Android) sample -- save file to sdcard and register to photo gallery.
save_button.addEventListener('click', ()->
if Ti.Filesystem.isExternalStoragePresent
save_image = Ti.Filesystem.getFile(path).read()
new_path = Titanium.Filesystem.externalStorageDirectory + Date.now().toString() + ".png"
f = Ti.Filesystem.getFile(new_path)
result = f.write(save_image)
unless result
return null
@yagitoshiro
yagitoshiro / app.js
Created June 21, 2012 04:34 — forked from ryugoo/app.js
WebView "Event to fire more than once" fix (removeEventListener)
// Global Background Color
Ti.UI.setBackgroundColor("#000000");
// Namespace
var APP = {};
// Running
(function () {
// Window
var win = Ti.UI.createWindow({