Skip to content

Instantly share code, notes, and snippets.

@iantearle
iantearle / BootstrapResponsiveImages.js
Last active Jul 29, 2016
Bootstrap responsive images script to fetch the appropriate sized image based on the breakpoint and column width.
View BootstrapResponsiveImages.js
function findBootstrapEnvironment() {
var envs = ['xs', 'sm', 'md', 'lg'];
var $el = $('<div>');
$el.appendTo($('body'));
for (var i = envs.length - 1; i >= 0; i--) {
var env = envs[i];
$el.addClass('hidden-'+env);
@iantearle
iantearle / jquery.exists.js
Created Jun 18, 2014
jQuery exists function
View jquery.exists.js
jQuery.fn.exists = function(fn) {
if(this.length>0) {
var f = arguments[0];
arguments[0] = function(e) {
f(e);
}
fn.apply( this, arguments );
return fn ? this.bind(name, fn) : this.trigger(name);
} else {
return this.length>0;
@iantearle
iantearle / Routes.php
Created May 28, 2014
PHP Routes Class
View Routes.php
<?php
/**
* Routes class.
* Copyright Ian Tearle (c) 2014
*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
View bootstrap-recaptcha.html
<div id="recaptcha_widget" style="display:none">
<div class="form-group">
<label class="control-label col-sm-3">reCAPTCHA</label>
<div class="col-sm-8">
<a id="recaptcha_image" href="#" class="thumbnail"></a>
<div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div>
</div>
</div>
<div class="form-group">
@iantearle
iantearle / home.js
Created Dec 28, 2013
Alloy Tableview not popluating
View home.js
require('tiparse');
if(OS_ANDROID) {
var countly = require("ly.count");
countly.countInit();
} else if(OS_IOS) {
var RichText = require('com.obscure.RichText'),
uTils = require('uTils'),
countly = require('count.ly');
countly.start();
@iantearle
iantearle / PLSqliteDatabase.h
Created Oct 2, 2013
Extending the Plausible Database in Titanium to allow for SQLite distance function.
View PLSqliteDatabase.h
/*
* Copyright (c) 2008 Plausible Labs Cooperative, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
@iantearle
iantearle / recommends.row.js
Last active Dec 23, 2015
This for some reason throws : "'undefined' is not a function (evaluating 'data.push(recommendRow.getView())')";
View recommends.row.js
<Alloy>
<TableViewRow id="row" class="row" className="recommends">
<Label id="message">
</TableViewRow>
</Alloy>
@iantearle
iantearle / strings.xml
Created Sep 10, 2013
In order to start a string definition with a preceding space in Appcelerator i18n strings.xml file you need to escape the space. Bare in mind however you cannot add the javascript space character \s but simply \ will work.
View strings.xml
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="start_with_space">\ I have a space before me.</string>
</resources>
@iantearle
iantearle / alloy.js
Created Sep 9, 2013
BasicGeo where its not starting location services on iOS7 with v0.86
View alloy.js
var geo = require('bencoding.basicgeo');
Alloy.Globals.geoCurrent = geo.createCurrentGeolocation();
Alloy.Globals.geoCoder = geo.createGeocoder();
Alloy.Globals.helpers = geo.createHelpers();
@iantearle
iantearle / app.js
Created Jun 11, 2013
Testing out my Appcelerator Titanium app on iOS7 and I appear to have an issue with the remote back up flag.
View app.js
var doNotBackUp = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory);
doNotBackUp.remoteBackup = false;
You can’t perform that action at this time.