Skip to content

Instantly share code, notes, and snippets.

View kosso's full-sized avatar

Kosso kosso

View GitHub Profile
// Kosso imageAsCropped
// added to TiBlob.m
// requires 4 arguments : x, y, width, height
- (id)imageAsCropped:(id)args
{
[self ensureImageLoaded];
if (image!=nil)
{
ENSURE_ARG_COUNT(args,4);
<?php
// perfect for using as an upload php script for the dnd-file-upload scripts by pangratz
// found at https://github.com/pangratz/dnd-file-upload
class File_Streamer{
private $_fileName;
private $_contentLength;
private $_destination;
public function __construct(){
// modified version of https://github.com/pangratz/dnd-file-upload by pangratz
// modified by : kosso
// date : 06 November 2010
// added some options for:
// allowMultiple
// allowedExtensions
// maximumFileSize
// also added dragEnter and dragLeave functions to enable change of appearance of the dropzone
@kosso
kosso / background_demo.js
Created March 12, 2011 17:55
Background Service notification for Titanium
/* Kosso : March 12th 2011
This the only way I managed to do this without the app crashing on resume.
Done slightly differently to the KS example, since they unregister the service and
do not use a setInterval timer.
*/
//############ in app.js :
// test for iOS 4+
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
#ifdef USE_TI_UIDASHBOARDVIEW
#import "TiUIDashboardView.h"
#import "TiUtils.h"
@kosso
kosso / share_facebook.js
Created May 13, 2011 19:36
Posting to Facebook with Titanium
// You need to have already logged the user in and obtained the access_token
// To get an access_token which never expires, you need to ask for the 'offline_access' permission too.
// May 2011 : @Kosso
function postToFacebook(fb_access_token,title,link_url,image_url,caption,description){
if(Titanium.Facebook.loggedIn===false && Ti.Facebook.uid===null){
alert('You are logged in to Facebook to send the post.');
@kosso
kosso / gist:980017
Created May 19, 2011 01:58
Workaround for Twitter OAuth in Ti
var url_string = null;
function findUrl(s){
// Parses the callback url including oauth_token and oauth_verifier from the webView error message. (The url occurs twice in the long message)
var hlink = /(ht|f)tp:\/\/([^ \,\;\:\!\)\(\"\'\<\>\f\n\r\t\v])+/g;
return (s.replace (hlink, function ($0,$1,$2) { s = $0.substring(0,$0.length);
while (s.length>0 && s.charAt(s.length-1)=='.')
@kosso
kosso / gist:980999
Created May 19, 2011 15:17
Convert a new Titanium url filesystem app property to the old path
var applicationDataDirectoryPath = Ti.Filesystem.applicationDataDirectory.slice(0,Ti.Filesystem.applicationDataDirectory.length - 1).replace('file://localhost','').replace(/%20/g,' ');
// Drops the trailing slash
// Removes file://localhost
// Replace %20 with a space
@kosso
kosso / gist:981250
Created May 19, 2011 17:11
Titanium sample: Multiple selection types in a window form
// Appcelerator Titanium (JS) code to produce multiple selection type data entry in a single window.
// via @CJ_Reed
// and Dan Tamas : http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video
var win = Titanium.UI.currentWindow;
// build custom tableView data/layout
@kosso
kosso / LICENSE.txt
Created May 23, 2011 01:56 — forked from jed/LICENSE.txt
linkify @mentions and #hashtags in a tweet
Copyright (c) 2011 Jed Schmidt, http://jed.is
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions: