Skip to content

Instantly share code, notes, and snippets.

View werelax's full-sized avatar

Elías Alonso werelax

View GitHub Profile
@werelax
werelax / MainViewController.m
Created February 13, 2014 17:55
Disable UIWebView Bounce in Phonegap App for iOS (the bad way)
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
// Black base color for background matches the native apps
theWebView.backgroundColor = [UIColor blackColor];
// ADD THIS LINE!
theWebView.scrollView.bounces = NO;
return [super webViewDidFinishLoad:theWebView];
}
@werelax
werelax / build_chicken.sh
Last active August 29, 2015 13:56
Build config for building some schemes for android
NDK_PATH=/Users/elias/bin/android-ndk-r9c
BASE_TOOLCHAIN_DIR=/tmp/achain
ARCH=armeabi
HOST=x86_64-apple-darwing13.0.0
TOOLCHAIN_DIR=/tmp/achain
SYSROOT=${TOOLCHAIN_DIR}/sysroot
TARGET="arm-linux-androideabi"
CFLAGS="-mthumb"
@werelax
werelax / $
Last active August 29, 2015 13:55
Line to build SpiderMonkey with android toolchain (first, open ./configure, search for *-darwing-something and change the "if whatever" for "if false", because this if forces the use of clang by default)
CFLAGS="-mthumb" CXXFLAGS="-mthumb" ./configure --target=arm-linux-androideabi --with-android-ndk=/Users/elias/bin/android-ndk-r9c/ --with-android-toolchain=/tmp/achain/ --disable-shared-js --disable-debug --enable-optimize
@werelax
werelax / server.js
Last active January 3, 2016 00:48
Base Node.js structure for small projects (missing auth routes/controllers)
/* jshint node: true, laxcomma: true */
/* global __dirname */
/* Dependencies */
var express = require("express")
, Q = require("q")
, check = require("validator").check
, auth = require("./simpleauth")
, MongoClient = require("mongodb").MongoClient
@werelax
werelax / AnimatedRegion.js
Last active December 26, 2015 19:29
pageslide.css y regiones custom: Slide y Flip
var AnimatedRegion = Base.Region.extend({
show: function(view, dir) {
this.forward = !dir; // true or false
Base.Region.prototype.show.call(this, view);
},
animationClass: "slide",
open: function(view) {
this.el = this.$el.get(0);
var from = this.currentView,
anim = this.animationClass,
@werelax
werelax / location-distance.js
Created October 26, 2013 16:16
Para el hackaton de tizen
distance: function(coords) {
var barPos = this.get("location"),
R = 6371*1000,
dtr = Math.PI / 180,
lat1 = coords.latitude*dtr, lon1 = coords.longitude*dtr,
lat2 = barPos.latitude*dtr, lon2 = barPos.longitude*dtr,
x = (lon2-lon1) * Math.cos((lat1+lat2)/2),
y = (lat2-lat1),
d = Math.sqrt(x*x + y*y) * R;
@werelax
werelax / gist:6581484
Last active December 23, 2015 04:39
Backbone Router con "pestañas" (secciones en una misma PageView con rutas distintas)
/* Router */
var AppRouter = R.extend(SmartRouter, {
init: function() {
this._super()
this.hottest()
},
routes: {
"": "index",
"latest": "latest",
@werelax
werelax / models.js
Created September 16, 2013 14:22
Quick Collection/Model initialization hack with Solipsist.Factory
/* Collections */
var PostCollection = R.extend(BaseCollection, {
model: Post,
/* DEBUG */
fetch: function(options) {
var PostFactory = Solipsist.Factory({
id: Solipsist.Factory.int_sequence(),
title: "Soy un post",
description: "Soy una descripción de un post",
@werelax
werelax / backbone-R-integration.js
Last active December 23, 2015 04:39
Backbone+R base classes
/* Base classes */
var BaseView = R.extend(Backbone.View, {
init: function() {
return Backbone.View.apply(this, arguments)
},
render: function() {
var model = (this.model || this.collection),
data = model.toJSON(),
html = this.template(data)
@werelax
werelax / snippet.js
Created September 16, 2013 14:19
Backbone.View Mixins
var Votable = {
mixed: function(klass) {
var events = {
"click .js-votes-plus": "plusVote",
"click .js-votes-minus": "minusVote",
},
proto = klass.prototype
proto.events = _.extend({}, events, proto.events)
},
plusVote: function(e) {