Skip to content

Instantly share code, notes, and snippets.

View zo0m's full-sized avatar

Igor Kalashnikov zo0m

  • Full Stack Developer
  • Odessa
View GitHub Profile
@zo0m
zo0m / index.js
Created August 17, 2014 09:25
Titanium Appcelerator search drop down
var win = $.index;
Alloy.Globals.ActiveWindow = win;
//for dropdown hints
Alloy.Globals.CurrentDropDown = null;
Alloy.Globals.removeCurrentDropDown = function() {
Alloy.Globals.ActiveWindow.remove(Alloy.Globals.CurrentDropDown);
Alloy.Globals.CurrentDropDown = null;
};
String.prototype.printf = function (obj) {
var useArguments = false;
var _arguments = arguments;
var i = -1;
if (typeof _arguments[0] == "string" || typeof _arguments[0] == "number") {
useArguments = true;
}
if (obj instanceof Array || useArguments) {
return this.replace(/\%([s,d])/g,
function (placeholder) {
@zo0m
zo0m / customGUIManager.js
Last active September 18, 2015 21:12
Titanium UI Factory example
/**
* Inside controller :
*
* var customGUIManager = new CustomGUIManager($);
*
* customGUIManager.createLabel('sampleUIClassName', 'SampleText', { left : '15dp'}),
*
*/
@zo0m
zo0m / app.js
Last active September 18, 2015 10:44 — forked from dawsontoth/app.js
/**
* The following snippet will ask the user to rate your app the second time they launch it.
* It lets the user rate it now, "Remind Me Later" or never rate the app.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
win.addEventListener('open', checkReminderToRate);
win.add(Ti.UI.createLabel({ text: 'This is a simple app that will remind you to rate it.' }));
win.open();
function checkReminderToRate() {
@zo0m
zo0m / ZEAnimator.js
Last active August 29, 2015 14:20
Appcelerator Titanium iOS animation issue workaround
var version = '2.3';
exports.animate = function (item, paramName, paramCurrentValue, paramTargetValue, duration, timeout) {
Ti.API.debug("ZEAnimator[" + version + "]#animate: " + item.apiName + "[" + item.id + "]." + paramName + '(' + item[paramName] + '): ' + paramCurrentValue + ' --> ' + paramTargetValue + " (d:" + duration + ', t:' + timeout + ')');
if (
(item[paramName] === paramTargetValue)
|| (
!isNaN(parseInt(item[paramName]))
&& !isNaN(parseInt(paramTargetValue))
&& parseInt(item[paramName]) === parseInt(paramTargetValue)
@zo0m
zo0m / Gruntfule.js
Last active January 14, 2018 18:27
Gruntfile for sharing: start Grunt look , raw version --- TODO: remove reduntant tasks
module.exports = function(grunt) {
grunt.initConfig({
sync: {
main: {
files: [{
cwd : 'app',
src: [
'**', /* Include everything */
],
dest: '/Users/admin/Documents/Appcelerator_Studio_Workspace/gevar/app'
@zo0m
zo0m / jquery2devconsole
Created July 18, 2015 13:00
add jquery to dev console
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type.
jQuery.noConflict();
@zo0m
zo0m / photo.coffee
Last active November 13, 2015 21:54
Upload Photo to ACS (Appcelerator Cloud Services) Angular Service ( POST file via $resource)
class PhotoService
constructor : ($resource, ACS_API_KEY, Session, $q)->
@instance = $resource 'https://api.cloud.appcelerator.com/v1/photos/:methodName'
,
key: ACS_API_KEY
_session_id: ->
Session.sessionId
,
create:
method: 'POST'
@zo0m
zo0m / controllers__card.coffee
Last active February 19, 2016 23:34
Simple Appecelerator Titanium IOS / Android Mobile Application
args = arguments or [{}]
args = args[0]
humanizeDuration = (eventDuration)->
eventMDuration = Alloy.Globals.Moment.duration(eventDuration, 'seconds');
eventDurationString = ""
if eventMDuration.days() > 0
eventDurationString += " " + Alloy.Globals.Moment.duration(eventMDuration.days(), 'days').humanize()
if eventMDuration.hours() > 0
eventDurationString += " " + Alloy.Globals.Moment.duration(eventMDuration.hours(), 'hours').humanize()
@zo0m
zo0m / abstract.coffee
Last active November 21, 2015 22:07
abstract service ACS
class AbstractService
constructor: (@cloud)->
defaultSearchCondition: (searchCondition = {})->
searchCondition.response_json_depth or= 3
searchCondition
buildArrowQueryString: (methodName)=> "/v1/#{@apiName}/#{methodName}.json"
getObjectsFromResponse: (response)=> response?.response?[@apiName] or []