Skip to content

Instantly share code, notes, and snippets.

View FokkeZB's full-sized avatar
*️⃣
Zappin'

Fokke Zandbergen FokkeZB

*️⃣
Zappin'
View GitHub Profile
@FokkeZB
FokkeZB / share.js
Last active April 1, 2016 14:29
A simple example of using Android intents to share texts, URLs and files like you could do using 0x82's ShareKit module (https://marketplace.appcelerator.com/apps/741) or any other similar module (TiSocial: https://github.com/viezel/TiSocial.Framework) for iOS.
function share(options) {
if (OS_ANDROID) {
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_SEND
});
intent.putExtra(Ti.Android.EXTRA_SUBJECT, options.title);
@FokkeZB
FokkeZB / index.js
Last active August 29, 2018 14:44
Passing through event listeners to widget view elements in Titanium Alloy.
function doClick(e) {
alert('Clicked!');
}
// Remove the event listener like this:
// $.myWidget.off("click", doClick);
$.index.open();
@FokkeZB
FokkeZB / index.tss
Last active January 16, 2023 09:35
Who said you can't do padding in Titanium (Alloy)?
"#wrapper": {
// Set wrapper to adjust it's size to it's contents
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
// Set stuff like borders and backgrounds on the wrapper
backgroundColor: "red"
}
@FokkeZB
FokkeZB / things.scpt
Last active February 24, 2018 02:01
AppleScript to create a task in Things to help you follow up on stuff you've asked people
using terms from application "Mail"
on perform mail action with messages theMessages
tell application "Mail"
repeat with eachMessage in theMessages
set theSubject to subject of eachMessage
set theMessageId to message id of eachMessage
set theRecipientName to name of first to recipient of eachMessage
set toDoName to theRecipientName & ": " & theSubject
set toDoContent to "[url=message:%3C" & ¬
theMessageId & ¬
@FokkeZB
FokkeZB / viewport.html
Created March 20, 2013 21:23
The ultimate responsive viewport meta-tag. Most docs tell you to use with=device-width and user-scalable=no only. But when you change the orientation of your iPad or iPhone from portrait to landscape, you'll notice the websites scales up. By adding minimum-scale=1.0 and maximum-scale=1.0 you fix this problem.
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
@FokkeZB
FokkeZB / animateToAnchor.js
Created April 1, 2013 18:05
Use jQuery to slowly scroll to anchors instead of browsers default non-animated fashion.
$('a[href^="#"]').click(function (e) {
e.preventDefault();
$('html, body').animate({
scrollTop: $('a[name="'+$(this).attr('href').substr(1)+'"]').offset().top
}, 500);
});
@FokkeZB
FokkeZB / app.js
Last active August 28, 2018 18:30
Embedding a YouTube video in Titanium
var win = Ti.UI.createWindow();
var webView = Ti.UI.createWebView({
url: 'http://www.youtube.com/embed/' + myVideoID + '?autoplay=1&autohide=1&cc_load_policy=0&color=white&controls=0&fs=0&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0',
enableZoomControls: false,
scalesPageToFit: false,
scrollsToTop: false,
showScrollbars: false
});
@FokkeZB
FokkeZB / query.sql
Created April 12, 2013 15:05
Get SQLite table definition using SqliteQuery (http://www.software-by-mabe.com//software/freeware.html) or a similar tool.
SELECT sql FROM sqlite_master WHERE tbl_name = 'YOUR_TABLE_NAME' AND type = 'table';
@FokkeZB
FokkeZB / singletap.js
Created April 16, 2013 07:38
Snippet from Blain Hamon on how to prevent Titanium from queing up multiple tap events
function handleOnce(funct) {
var flag = false;
return function(e) {
if (flag) return;
flag = true;
setTimeout(function() {
flag = false;
}, 0);
funct(e);
@FokkeZB
FokkeZB / app.js
Created April 19, 2013 08:17
How to decide what window to open first in Titanium Alloy. You can remove all markup from the index.xml view (the file itself must be there!) and then create another controller based on your logic.
/* /Resources/app.js - Generated by Alloy, here to understand the flow */
var Alloy = require("alloy"), _ = Alloy._, Backbone = Alloy.Backbone;
Alloy.createController("index");