Skip to content

Instantly share code, notes, and snippets.

@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) {
/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: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;
@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 / .zshrc
Created January 27, 2026 10:27 — forked from bashbunni/.zshrc
CLI Pomodoro for Linux (zsh)
# study stream aliases
# Requires https://github.com/caarlos0/timer to be installed. spd-say should ship with your distro
declare -A pomo_options
pomo_options["work"]="45"
pomo_options["break"]="10"
pomodoro () {
if [ -n "$1" -a -n "${pomo_options["$1"]}" ]; then
val=$1