Skip to content

Instantly share code, notes, and snippets.

View kopiro's full-sized avatar

Flavio Maria De Stefano kopiro

View GitHub Profile
@lastguest
lastguest / call_closure.php
Last active August 29, 2015 13:57
Javascript like scope heritage
<?php
function foobarbaz(){
// Extract environment object to local scope (not mandatory, you can access the parent scope via $this. Ex. $this->foo )
extract((array)$this);
var_dump($foo, $bar, $baz);
}
@kopiro
kopiro / ti-aliases.sh
Last active August 29, 2015 14:00
Titanium CLI Aliases
# Titanium aliases
alias ti-is-dev="if [ -e devtiapp.xml ]; then cp tiapp.xml tiapp.xml.copy; rm tiapp.xml; ln -svf devtiapp.xml tiapp.xml; fi"
alias ti-is-prod="if [ -e prodtiapp.xml ]; then cp tiapp.xml tiapp.xml.copy; rm tiapp.xml; ln -svf prodtiapp.xml tiapp.xml; fi"
# iOS
alias ti-ios="ti-is-dev && ti build -p ios --sim-64bit -I 7.1"
alias ti-ios-device="ti-is-dev && ti build -p ios -T device -I 7.1 --device-id all"
alias ti-ios-test="ti-is-dev && ti clean && ti build -p ios -T dist-adhoc -I 7.1"
alias ti-ios-install="ideviceinstaller --install dist/*.ipa"
# Android
alias ti-android="ti-is-dev && ti build -p android"
@jaraen
jaraen / gist:1626498
Created January 17, 2012 12:31
Shadow property in TiUIView.m
-(void)setShadow_:(id)args
{
if(args != nil)
{
self.layer.masksToBounds = NO;
if ([args objectForKey:@"shadowOffset"] != nil) {
CGPoint p = [TiUtils pointValue: [args objectForKey:@"shadowOffset"]];
CGSize shadowOffset = {p.x,p.y};
@euforic
euforic / ti.socket.io.js
Created June 5, 2012 17:02
Socket.io-client Titanium
/*! Socket.IO.js build:0.9.6, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
/**
* Originally Ported to titanium by Jordi Domenech <jordi@iamyellow.net>
* source: https://github.com/iamyellow/socket.io-client
*/
this.io = {};
module.exports = this.io;
/**
@FokkeZB
FokkeZB / LAZY.md
Last active December 16, 2015 21:39
Lazy exporting expensive properties

If you have a CommonJS module that exposes properties that are expensive to create (e.g. other CommonJS modules or some external resource), you can load them lazy using Object.defineProperty().

@import UIKit;
@import AVFoundation;
@class _UISiriWaveyView;
@protocol _UISiriWaveyViewDelegate <NSObject>
- (CGFloat)audioLevelForWaveyView:(_UISiriWaveyView *)waveyView;
@end
typedef NS_ENUM(NSInteger, _UISiriWaveyViewMode) {
@FokkeZB
FokkeZB / pushDisabled.js
Created July 10, 2013 14:21
Titaniums Ti.Network methods and properties give little information about the current status of push notifications. This is pretty much as far as it goes.
if (Ti.Network.remoteNotificationsEnabled) {
Ti.API.info('User has enabled push');
} else if (Ti.Network.remoteDeviceUUID === null) {
Ti.API.info('User has never enabled push');
} else {
Ti.API.info('User has manually disabled push');
}
@ararog
ararog / helpers.js
Last active December 30, 2015 00:29
Javascript version of Days360 excel function.
function days360(initialDate, currentDate) {
var dateA = initialDate;
var dateB = currentDate;
var dayA = dateA.getDate();
var dayB = dateB.getDate();
(function($) {
var supportedServices = {
'weibo': 'http://service.weibo.com/share/share.php?title={{title}}&url={{url}}&pic={{pic}}',
'douban': 'http://shuo.douban.com/!service/share?name={{title}}&href={{url}}&image={{pic}}',
'kaixin': 'http://www.kaixin001.com/repaste/bshare.php?rtitle={{title}}&rurl={{url}}',
'netease': 'http://t.163.com/article/user/checkLogin.do?info={{title}}',
'qq_t': 'http://v.t.qq.com/share/share.php?title={{title}}&url={{url}}&pic={{pic}}',
'qq_zone': 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?title={{title}}&url={{url}}&pics={{pic}}',
'renren': 'http://share.renren.com/share/buttonshare.do?title={{title}}&link={{url}}',
'sohu': 'http://t.sohu.com/third/post.jsp?title={{title}}&url={{url}}&content=utf-8',
@yomybaby
yomybaby / TiUIWindowProxy.m
Last active August 3, 2016 18:23
iOS hidesBarsOnSwipe on Titanium
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2016 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.
*
* WARNING: This is generated code. Modify at your own risk and without support.
*/
#ifdef USE_TI_UIWINDOW