Skip to content

Instantly share code, notes, and snippets.

View map_view.js
function mapview(_args) {
var win = Titanium.UI.createWindow({
title:_args.title
});
var isAndroid = false;
var MapModule = Titanium.Map;
var MapType = MapModule.STANDARD_TYPE;
if (Titanium.Platform.name == 'android') {
isAndroid = true;
@mogya
mogya / geoutils.rb
Last active Dec 25, 2015
緯度経度を表す多様なフォーマットを全部受け入れて任意のフォーマットで出力する試み
View geoutils.rb
require 'active_support/core_ext/hash'
module GeoUtils
extend self
# 様々な緯度経度フォーマットのデータを入出力する関数
# 入力: 以下の5パターンの引数が想定されている
# lat lng FORMAT 数値二つ
# "lat" "lng" FORMAT 文字列二つ
# "lat,lng" FORMAT カンマ区切りの文字列一つ
# [lat,lng] FORMAT 配列
@mogya
mogya / ng.php
Last active Dec 23, 2015
文字列がひらがなを含むかどうかのチェック:駄目な例 see: http://blog.mogya.com/2013/09/php-preg-match-mb-ereg.html
View ng.php
<?php
$output = '';
$comment = 'あいうえお';
if (isset($_POST['comment'])){
$comment = $_POST['comment'];
if (preg_match("/[あ-ん]/", $comment))
{
$outputs = Array();
$outputs[] = 'MATCH';
$outputs[] = 'ret:'.preg_match("/[あ-ん]/", $comment, $match,PREG_OFFSET_CAPTURE);
@mogya
mogya / gist:5598977
Last active Dec 17, 2015
send array as POST data on TitaniumMobile.
View gist:5598977
var paramstr = '';
for (var key in params) {
if (params[key] instanceof Array){
for (var i = 0; i < params[key].length; i++) {
paramstr = paramstr+key+'[]='+params[key][i]+'&';
}
}else{
paramstr = paramstr+key+'='+params[key]+'&';
}
}
@mogya
mogya / AppModel.php
Last active Dec 17, 2015
custom find type to get result hash without model name.
View AppModel.php
<?php
App::uses('Model', 'Model');
class AppModel extends Model {
public $findMethods = array('noModelName' => true);
protected function _findNoModelName($state, $query, $results = array()) {
if ($state == 'before') {
return $query;
} elseif ($state == 'after') {
$modelNameKey = $this->name.'.';
$resultsNoModelName = array();
@mogya
mogya / gist:5517324
Last active Dec 16, 2015
javascript argument check benchmarks.
View gist:5517324
LOOP = 10000000;
var start, end;
// logging
function log(msg){
return console.log(msg);
}
function checkStrTernary(arg){
start = new Date();
@mogya
mogya / CakeFacebook.php
Created Apr 17, 2013
Facebook class using cakePHP session. based on Facebook PHP SDK (v.3.2.2) https://github.com/facebook/facebook-php-sdk
View CakeFacebook.php
<?php
/**
* Copyright 2013 mogya.
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@mogya
mogya / FacebookController.php
Last active Dec 16, 2015
CakePHP controller for facebook login with Facebook PHP SDK (v.3.2.2)
View FacebookController.php
<?php
App::import('Vendor', 'facebook/facebook');
class FacebookController extends AppController{
protected $facebook = NULL;
function beforeFilter(){
$this->facebook = new Facebook(array(
'appId' => Configure::read('facebook.appid'),
'secret' => Configure::read('facebook.secret'),
));
@mogya
mogya / facebook_login.php
Last active Dec 16, 2015
facebook login with Facebook PHP SDK (v.3.2.2)
View facebook_login.php
<?
include_once("facebook/facebook.php"); //include facebook SDK
function myurl(){
if ( isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on' ){
$protocol = 'https://';
}else{
$protocol = 'http://';
}
return $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
@mogya
mogya / test.html
Created Apr 8, 2013
run sms application automatically and close myself on iOS.
View test.html
<html>
<head>
<title>start application automatically and kill myself.</title>
<script type="text/javascript">
function init(){
var iframe = document.createElement('iframe');
iframe.src = "sms:///";
document.body.appendChild(iframe);
window.opener = window;
You can’t perform that action at this time.