Skip to content

Instantly share code, notes, and snippets.

View kosso's full-sized avatar

Kosso kosso

View GitHub Profile
@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 / 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:
@kosso
kosso / LICENSE.txt
Created May 23, 2011 01:59 — forked from jed/LICENSE.txt
calculate # of ms/seconds/minutes/hours/days in the past
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:
@kosso
kosso / gist:1059705
Created July 2, 2011 03:16
Google PlusBar..
/*
The code for the bookmarklet:
You create bookmarklets with a href javascript: links.
If you don't know how to do this, simply copy/paste one you might already have in your toolbar and
then edit the url properies with this long line below:
*/
javascript:(function(){var%20included%20=%20false,openbar%20=%20false,src%20=%20"http://YOUR_DOMAIN/YOUR_SCRIPT.JS";var%20isIncluded%20=%20(function(){var%20scripts%20=%20document.getElementsByTagName('script');for(var%20i=0;i<scripts.length;i++){if(scripts[i].src%20==%20src){bar_toggle();%20return%20true;}}return%20false;})();if(isIncluded){%20%20}else{if(included){return%20false;}included%20=%20true;var%20head%20=%20document.getElementsByTagName("head")[0]%20||%20document.documentElement,script%20=%20document.createElement("script");script.type%20=%20"text/javascript";script.async%20=%20true;script.src%20=%20src;head.insertBefore(%20script,%20head.firstChild%20);}})();
@kosso
kosso / ContentqueryModule.java
Created August 17, 2011 19:14
An attempt at building a Titanium Android module to assist media intents ..
/**
com.kosso.contentquery
A Titanium Android module to try and get the actual path of a contenUri returned from a RECORD_SOUND_ACTION Intent Activity.
by Kosso. (so far! ;p )
**/
package com.kosso.contentquery;
@kosso
kosso / rec.js
Created August 17, 2011 19:16
Ti JS code to test the mediaquery module
// Kosso : 2012
// mediaquery module code is here : https://gist.github.com/1153138
var win = Ti.UI.currentWindow;
// const value grabbed from
// http://developer.android.com/reference/android/provider/MediaStore.Audio.Media.html#RECORD_SOUND_ACTION
var RECORD_SOUND_ACTION = "android.provider.MediaStore.RECORD_SOUND";
@kosso
kosso / MediaqueryModule.java
Created August 18, 2011 02:15
A Titanium module for Android to get the full path of an audio or video contentUri
/**
MediaQuery Module for Appclerator Titanium : Android
Author : Kosso
Date : August 18, 2011
Updated : August 07, 2012 - Fixes and changes for newer Ti SDK since this was written.
More info re changes/porting : https://wiki.appcelerator.org/display/guides/Android+Module+Porting+Guide+for+1.8.0.1
Description :
@kosso
kosso / uri.js
Created April 25, 2012 19:27 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@kosso
kosso / app.js
Created July 16, 2012 11:52
titanium tiws module example
// ****************************************************************************************************************
// ****************************************************************************************************************
// test value can be 'raw' | 'socket.io' | 'nowjs'
var test = 'raw',
// ****************************************************************************************************************
// ****************************************************************************************************************
// REMEMBER to change this with your data