Skip to content

Instantly share code, notes, and snippets.

View oroce's full-sized avatar

Róbert Oroszi oroce

  • Budapest, Hungary
View GitHub Profile
@oroce
oroce / gist:1035546
Created June 20, 2011 12:40
parameter validation
my %fields = (
name => {
required => 1,
test => qr!\w+!,
nope => "Name field is required, it shouldn't be empty!"
},
bplace => {
required => 1,
test => qr!\w+!,
nope => "Birth place field is required, it shouldn't be empty!"
@oroce
oroce / gist:1043498
Created June 23, 2011 20:05
opera repaint bug workaround
$( window ).focus( function(){
this.document.body.style.zIndex -= 1;
})
@oroce
oroce / gist:1097327
Created July 21, 2011 14:40
sqlite db connection
/*
this file is in Resources/tabs/search.js
and the sqlite file is in Resources/db/imenetrend_new.sqlite
the database is called as "main"
*/
var db = Ti.Database.install( "../db/imenetrend_new.sqlite", "main" ),
letters = ( letters||"" ) + "%";
var rows = db.execute( "SELECT * FROM stations WHERE station_deaccent LIKE ? LIMIT 50", letters );
@oroce
oroce / gist:1097358
Created July 21, 2011 14:53
listing tables in appcelerator app
var db = Ti.Database.install( "../db/imenetrend_new.sqlite", "main" ),
_rows = db.execute( "select * from sqlite_master" );
while( _rows.isValidRow() ){
Ti.API.info( "TableName: " + _rows.fieldByName( "name" ) + " - " + _rows.fieldByName( "tbl_name" ) + " - " + _rows.fieldByName( "sql" ) );
_rows.next();
}
/*
it shows:
@oroce
oroce / gist:1104010
Created July 25, 2011 12:16
sven droplist
$(document).ready(function () {
$("#droplist").dropList({
style: "green",
width: 220,
target: "self",
speed: 500
})
$("#droplist").siblings(".dropList-box").trigger("click");
$(".color").click(function (e) {
e.preventDefault();
@oroce
oroce / app.js
Created August 1, 2011 06:26 — forked from kwhinnery/app.js
Faking Long Touch on Android in Titanium Mobile
//The table view row just has to have a full height view in order
//to trigger the TableView touchstart
function LongTouchTableViewRow(_title) {
var row = Ti.UI.createTableViewRow({
height:50
});
var v = Ti.UI.createView({
height:50
});
@oroce
oroce / _for iOS users
Created November 2, 2011 18:20
Appcelerator share to native facebook, twitter
This gist is only for Android.
If you would like launch native apps
on iPhone, iPad, you can find information about it in Appcelerator Docs:
-https://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Platform.canOpenURL-method.html
-https://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Platform.openURL-method.html
More info about iOS URL Schemes: http://handleopenurl.com/
@oroce
oroce / simple-with-close-event.js
Created November 23, 2011 14:55
open jQuery Mobile Dialog from javascript with close event
//unfortunately the jQuery mobile team removed option, to attaching custom event handler,
//so i'm just overriding close event, and using jQuery Widget Library _trigger method
$.mobile.dialog.prototype._close = $.mobile.dialog.prototype.close;
$.mobile.dialog.prototype.close = function(){
var args = Array.prototype.slice.call( arguments, 0 );
this._trigger( "close" );
this._close.apply( this, args );
};
@oroce
oroce / is-online.js
Created November 23, 2011 22:24
ideas to check browser is online
/*
@dependencies
jQuery
*/
(function( window, $, undefined ){
var support = {
onLine: undefined === typeof window.navigator.onLine,
applicationCache: !!window.applicationCache
},
app = {
@oroce
oroce / backbone-model-collection.js
Created November 24, 2011 22:41
An idea (it means: i haven't tested yet) how to use Backbone.sync with appcelerator (Ti.Database)
var Model = Backbone.Model.extend({
defaults:{
title: "",
content: "",
crDate: new Date(),
isDone: false,
dueDate: null
},
validate: function( attrs ){
var errors = [];