Skip to content

Instantly share code, notes, and snippets.

@mattlanham
mattlanham / x-editable angularjs directive
Last active May 19, 2016 07:55
Really simple directive for http://vitalets.github.io/x-editable/, created this because i wanted to use the popover, and not the inline version provided by the existing angularJS directive. It's really simple to use, just add 'editable' to your modules, then use like: <h2 ng-model="form.name" editable></h2> you can also pass through options i.e.…
(function() {
"use strict";
angular.module("editableModule", ['ng']).directive("editable", function($timeout) {
return {
restrict: "AE",
scope: true,
require:"ngModel",
link: function(scope, element, attrs, ngModel) {
element.editable({
@mattlanham
mattlanham / gist:6233976
Created August 14, 2013 18:26
Working version of findZoomRegion, alloying you to pass an array of points and find the best region lat/lng for the mapview in Appcelerator Titanium
function findZoomRegion(points) {
var nbPtToShow = points.length-1;
var tmpDeltatLat = 0, tmpDeltatLong = 0, maxDeltatLat = 0, maxDeltatLong = 0, centerLat = 0, centerLong = 0;
for(var i = 0; i <= Math.floor(points.length / 2); i++) {
for(var j = nbPtToShow; j >= Math.floor(points.length / 2); j--) {
if(j != i) {
tmpDeltatLat = Math.abs(Math.abs(points[i].latitude) - Math.abs(points[j].latitude));
if(tmpDeltatLat > maxDeltatLat) {
maxDeltatLat = tmpDeltatLat;
/m/register
curl --include \
--request POST \
"http://realrider.swanify.com/m/register" \
-d "forename=Matthew" \
-d "surname=Lanham" \
-d "email=mattplanys34@swanify.com" \
-d "dob=12/12/1985" \
-d "password=password" \
@mattlanham
mattlanham / gist:3293052
Created August 8, 2012 07:17
Quick example of use
// Put this in app.js
Ti.Facebook.appid = 'xxxxxxxxxxxxx';
// Add a login button somewhere and put the following code inside it
Parse.FacebookUtils.init({});
Parse.FacebookUtils.logIn(['publish_stream', 'email', 'read_friendlists', 'publish_actions'], {
success: function(user) {
######### account.php in /models
<?php
class Account extends Eloquent {
public function user()
{
return $this->belongs_to('User');
}
object(Fuel\Core\Request_Curl)#10 (10) {
["preserve_resource":protected]=>
NULL
["resource":protected]=>
string(40) "http://platform2/generic/index.json?id=1"
["params":protected]=>
array(0) {
}
["default_params":protected]=>
array(0) {
<?php
namespace Orm;
class Observer_Accountid extends Observer
{
/**
* @var string property to set the timestamp on
*/
public static $property = 'account_id';
// No point applying an account id, unless we can tell the URL (this wont work for everything)
if(array_key_exists('SERVER_NAME', $_SERVER))
{
// Get the table name
$table_name = call_user_func($this->model.'::table');
// Load config
$locked_tables = \Config::get('settings.protected_models');
// Check if it's a protected modal
javascript:$('#mw-sopaOverlay').remove();$('#content, #mw-head,#mw-panel').css('display','block');void(0);
var port = 12345;
var serverUrl = "http://pushapi.eval.blackberry.com";
var appId = "XXXXX";
var max = 100;
var wakeUpPage = "push.htm";
function openBISPushListener() {
try {
var ops = {port : port, appId : appId, serverUrl : serverUrl, wakeUpPage : 'push.htm', maxQueueCap : max};