Skip to content

Instantly share code, notes, and snippets.

View abada's full-sized avatar

Abdulatif Henno abada

View GitHub Profile
@abada
abada / Rater.js
Last active August 29, 2015 14:11
Rate : Rate Your App Titanium Module
//-- usage
/*
$.index.addEventListener("open", function(e) {
var rater = require('rater');
rater.initMe(Titanium.App.name,Titanium.App.id);
});*/
/*
* Our Rater CommonJS Module
*/
@abada
abada / RandomPassword.php
Last active August 29, 2015 14:12
Generating a random password in php
<?php
function randomPassword() {
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
$pass = array(); //remember to declare $pass as an array
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $alphaLength);
$pass[] = $alphabet[$n];
}
return implode($pass); //turn the array into a string
@abada
abada / ArdTiShare.js
Created January 22, 2015 20:08
Titanium Android Social Share
var intent = Ti.Android.createIntent({
action : Ti.Android.ACTION_SEND
});
var title = options.text + " " + "-" + " " + options.url;
intent.putExtra(Ti.Android.EXTRA_TEXT, title);
//intent.putExtra(Ti.Android.EXTRA_TEXT, options.text);
/*if (options.image) {
@abada
abada / Share.js
Created February 16, 2015 09:57
Share data from titanium app to mentioned native app only
function shareToFB(){
try{
var intFB = Ti.Android.createIntent({
action: Ti.Android.ACTION_SEND,
packageName: "com.facebook.katana",
className: "com.facebook.katana.ShareLinkActivity",
flags: 0x30000000,
type: "text/plain"
});
intFB.putExtra( Ti.Android.EXTRA_TEXT, "http://www.google.com"); //facebook only supports LINKS(!!!)
@abada
abada / Tinsetedjson.js
Created February 21, 2015 23:23
Ti Nested json array with tableviews
var tableView = Ti.UI.createView({
width:200,
height:44,
backgroundColor :'#FFFFFF',
top :200,
});
var listView = Ti.UI.createView({
width:200,
height:44,
backgroundColor:'white',
@abada
abada / BootReceiver.java
Last active October 8, 2017 02:37
Android module to run service or activity on startup after reboot the device
package com.betait.is7a;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* Author: abada
* You can contact to me with [email protected]
*/
@abada
abada / 64-bit
Last active August 29, 2015 14:16
To update an existing iOS module and make it 64-bit compatible follow these steps
Module Builds
To update an existing iOS module and make it 64-bit compatible follow these steps:
Open the module’s Xcode project.
You should have at least one warning asking you to update the project to the “recommended settings”, do that.
Change all architectures to $(ARCHS_STANDARD).
Set the deployment target to at least iOS 6.0.
That’s it. Build the module normally with this Release and it should now be 64-bit compatible. To verify, run the following command:
var win = Ti.currentWindow;
var imageCollection = [
'http://example.com/images/1.jpg',
'http://example.com/images/2.jpg',
'http://example.com/images/3.jpg',
'http://example.com/images/4.jpg',
'http://example.com/images/5.jpg',
'http://example.com/images/6.jpg'
];
var scrollGallery = Ti.UI.createScrollableView({

Implementing Appcelerator Titanium Models/Collections for Cloud Services without all the extra files

It is a PITA working with Appecelerator Alloy Models and Collection because you need to create these template files for everything, even of you are not using them. This is a "HACK" that I came up with after a few hours that appears to address the issue.

I am certain that there might be a cleaner way, which would require deeper understand of the underpinnings of Alloy, maybe someone can make a suggestion, maybe it will come to me later.

###Notes This code is using a ACS Sync Adapter customize for cloud services with promises integration

https://github.com/aaronksaunders/Appcelerator-Cloud-Services-Sync-Adapter

@abada
abada / app.js
Last active August 29, 2015 14:18 — forked from skypanther/app.js
var Utils = {
/* modified version of https://gist.github.com/1243697
* adds detection of file extension rather than hard-coding .jpg as in the original
*/
_getExtension: function(fn) {
// from http://stackoverflow.com/a/680982/292947
var re = /(?:\.([^.]+))?$/;
var tmpext = re.exec(fn)[1];
return (tmpext) ? tmpext : '';
},