Skip to content

Instantly share code, notes, and snippets.

@raulriera
raulriera / gist:bca6201e25e1d78fd17f
Created November 28, 2014 14:15
Derived data dance
echo "(•_•)"
echo "<) )╯ $USER starts"
echo " / \ "
echo ""
echo "\(•_•) "
echo " ( (> the derived data"
echo " / \ "
echo ""
echo " (•_•) "
echo "<) )> dance"
- (void)tableViewEnabled:(BOOL)enabled withBlock:(void (^)(void))block
{
if (enabled) {
[self transitionView:^{
self.tableView.alpha = 1;
_minMaxNightsHeightConstraint.constant = 0;
[_minMaxStayLabel resetStyle];
_minMaxStayLabel.text = @"";
class AddBruteForceSecurityToUsers < ActiveRecord::Migration
def change
add_column :users, :failed_login_count, :integer, :default => 0
end
end
@raulriera
raulriera / NappUI.js
Created July 12, 2013 14:21 — forked from viezel/NappUI.js
Missing the function statement
// We need to add the following proxies to our project before Napp UI works.
// This is due to some limitations of the Titanium Module SDK
// Please run this after you require the
exports.initNappUI = function() {
require('dk.napp.ui'); // require the module
// window and tabs
var win1 = Ti.UI.createWindow();
@raulriera
raulriera / NappUIHack.js
Created July 12, 2013 14:03
Including this file in your project will solve the problem.
// If you remove code for any of the APIs except TiUIView (Available for module uses),
// then compile for iOS device will fail.
// Like, if i remove
// var PickerV = Ti.UI.createPicker();
// from the below code, then build for iOS device will fail, as you have used that in your module, and xcode will report as undefined symbol for TiUIPicker.
var NappUI = require('dk.napp.ui');
var win1 = Ti.UI.createWindow({
@raulriera
raulriera / slideIn.js
Last active December 18, 2015 06:59
Extending the animation.js Alloy builtins
/**
* @method slideIn
* Makes the specified view appear using a "slide-in" animation, it will automatically
* detect where the view is offscreen and bring it into the user's vison.
* @param {Titanium.UI.View} view View to animate.
* @param {Number} duration Fade duration in milliseconds.
* @param {function()} [finishCallback] Callback function, invoked after the popIn completes.
*/
exports.slideIn = function (view, duration, finishCallback) {
@raulriera
raulriera / IsTablet.js
Created January 26, 2013 01:09
Detect tablets on Titanium
var isTablet = osname === 'ipad' || (osname === 'android' && Titanium.Platform.Android.physicalSizeCategory > 2);
@raulriera
raulriera / HorizontalTableView.js
Created January 24, 2013 12:37
Horizontal TableView for Titanium Appcelerator. This still needs some android love, trying to use an inverted tableview made the table impossible to scroll (on android)
function HorizontalTableView(options) {
// defaults params
var options = options || {};
options.width = options.width || Titanium.Platform.displayCaps.platformWidth;
options.height = options.height || Titanium.Platform.displayCaps.platformHeight;
var isAndroid = Ti.Platform.osname === 'android';
// On iOS we can do this, on Android there is some weird scrolling problems
@raulriera
raulriera / gist:4579638
Last active December 11, 2015 09:28
Since android doesn't support opening the market from web views. This seems like a pretty good hack. Idea from http://stackoverflow.com/questions/3583264/support-for-other-protocols-in-android-webview
webView.addEventListener("load", function(e){
if (e.url != null && e.url.indexOf("market://") != -1) {
// Open the URL from the device
Titanium.Platform.openURL(e.url);
// Reset the URL to the initial one
webView.url = url; // url is set somewhere in your code
}
});
@raulriera
raulriera / ImageHelper.js
Created October 3, 2012 02:04
Load iPhone5 retina graphics
// I am pretty sure there is a sexier approach, but this works nicely
var isPhone5 = Ti.Platform.displayCaps.platformHeight == 568;
parse568hImages = function(imagePath) {
if (isPhone5){
// Do this because the filename could contain dots
imagePath = imagePath.replace(".png","-568h@2x.png");
imagePath = imagePath.replace(".jpg","-568h@2x.jpg");
imagePath = imagePath.replace(".jpeg","-568h@2x.jpeg");
}