Skip to content

Instantly share code, notes, and snippets.

View joewright's full-sized avatar
🕶️
🤳 🌭

Joe Wright joewright

🕶️
🤳 🌭
View GitHub Profile
@joewright
joewright / ti-transloadit
Last active August 29, 2015 14:06
Titanium file upload to Transloadit service
var Transloadit = module.exports = {};
var TRANSLOADIT_API = 'http://api2.transloadit.com/assemblies';
var PING_TIMEOUT = 3000;
/*
* @method upload
* requires Object options with the following parameters
* key - your transloadit API key
* notify_url - notification URL (optional)
* template - template ID
* fields - form fields to use with your template

#Leaks ###Setup Standard Ti environment

  • OSX
  • Node
  • Ti SDK
  • alloy/titanium from NPM
  • Xcode/Instruments

Run instruments from Xcode, choose 'Allocations', your device, and the application to test.

@joewright
joewright / serve_it_up.js
Last active December 19, 2018 19:08
Stream mongo query through an express server
var express = require('express');
var mongoose = require('mongoose');
// connect to local db
mongoose.connect('mongodb://127.0.0.1:27017/swag', function(error) {
if (error) {
throw new Error(error);
}
});
// Mongoose Schema definition
@joewright
joewright / gist:13bd2c25e48b9093b76c
Last active August 29, 2015 14:11
Square Progress indicators in Titanium/Alloy

This is one approach to create a square progress indicator with Titanium views. In it, we draw a background view with a border, and use 5 view sections to indicate progress.

I'm including a <Slider> to test progress on the device.

XML

<View id="container">
	<View class="off-border"></View>
	<View id="view1" class="part"></View>
	<View id="view2" class="part"></View>
@joewright
joewright / gist:64291e2f07f4d0db490f
Created March 3, 2015 15:45
Grunt task to bump Testflight build number for Titanium projects
//load tiapp.xml in grunt config
grunt.initConfig({
// This line makes your node configurations available for use
pkg: grunt.file.readJSON('package.json'),
tiapp: require('tiapp.xml').load('./tiapp.xml'),
//...
//...........
grunt.registerTask('buildbump', function() {
console.log('be sure to check that "ios.skipAppIdValidation" is set to true \n\n ti config ios.skipAppIdValidation true\n');
var tiapp = grunt.config.data.tiapp;
@joewright
joewright / example.js
Last active November 18, 2015 13:40
PokitDok API Titanium example
/***
* Ti PD API
*
* App.config -> global config namespace
* we connect to a proxy instead of the API directly
* to avoid storing credentials on the client
*
*
* // Example api request
* api.request({
@joewright
joewright / programmatic gulp task.js
Last active March 25, 2016 19:18
programmatic gulp task
gulp.task('programmatic-configs', function () {
var foldernames = ['some', 'folder', 'names'];
var tasks = foldernames.map(function (fname) {
var taskname = fname + '-build';
gulp.task(taskname, function (done) {
SOME_CONFIG_NAME = fname;
//sequence will run with alternate config...
runSequence('build', done);
});
return taskname;
@joewright
joewright / emoji_author_count.js
Created March 23, 2017 19:23
Slack emoji count by author
var AUTHOR_DOM_QUERY = '.display_flex.align_items_center.break_word.bold';
doIt(AUTHOR_DOM_QUERY);
function doIt(query) {
// lucky for us, slack uses jQuery and lodash
return _.chain($(query).text().split('\n'))
.filter(hasLetters)
.map(trimEm)
.groupBy()
.mapValues('length')
@joewright
joewright / ng-editable-multieselect.html
Created April 19, 2017 20:31
proof of concept for an angular form with an editable multiselect input
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="Demo project">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css"></style>
@joewright
joewright / query-selector-logger.js
Last active February 20, 2018 15:23
log a unique jQuery selector for every element clicked on a page
// requires jQuery https://code.jquery.com/jquery-1.11.3.js
window.events = [];
$('body').click(function(event) {
//use event.target with firefox
var selector = fromHTMLElement(event.toElement || event.target);
window.events.push(selector);
console.log(selector, $(selector));
});
function fromHTMLElement(srcElement) {