Skip to content

Instantly share code, notes, and snippets.

View sharpred's full-sized avatar

Paul Ryan sharpred

View GitHub Profile
@sharpred
sharpred / getContact
Created November 5, 2014 11:54
getContactByType
if (Alloy.CFG.theme === "meinetui") {
$.requestFN = "getContactByType";
Alloy.Globals.Api[$.requestFN]({
//can be 'general', 'mein-service', 'mein-service-excursions'
type : 'mein-service-excursions',
//excursionsId is ignored unless mein-service-excursions is used, in which case it is mandatory
excursionId: '1212'
}, $.successCallback, $.failedCallback);
}
@sharpred
sharpred / deepHas.js
Created February 24, 2015 09:30
deep nested property
function propDeep(target, path, rtn) {
"use strict";
try {
target = target || {};
var result = eval("target." + path);
} catch(e) {
return false;
}
if (result) {
return rtn ? result : true;
@sharpred
sharpred / saveamovie.js
Created June 8, 2015 08:10
save a movie
var movie = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'mymovie.mov');
var thumb = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'mymoviethumb.jpg');
Titanium.Media.showCamera({
success : function(event) {
var video = event.media;
if (movie.exists()) {
movie.deleteFile();
}
movie.write(video);
@sharpred
sharpred / compatible-screens.xml
Created June 3, 2016 12:27
how to set your android app to exclude tablet size screens including nexus 6p / 5x / galaxy 6+7 edge
<compatible-screens>
<screen android:screenSize="small" android:screenDensity="ldpi" />
<screen android:screenSize="small" android:screenDensity="mdpi" />
<screen android:screenSize="small" android:screenDensity="hdpi" />
<screen android:screenSize="small" android:screenDensity="xhdpi" />
<screen android:screenSize="small" android:screenDensity="420" />
<screen android:screenSize="small" android:screenDensity="480" />
<screen android:screenSize="small" android:screenDensity="560" />
<screen android:screenSize="small" android:screenDensity="640" />
<screen android:screenSize="normal" android:screenDensity="ldpi" />
@sharpred
sharpred / killLV.sh
Created June 14, 2016 13:40
kill liveview
#!/usr/bin/env bash
ps -e | grep liveview | awk '/titanium/ {print $1}' | xargs kill
@sharpred
sharpred / tiappgrunt.js
Last active November 3, 2016 20:24
tiapp grunt example
/*
* set up a grunt config variable and create a couple of jobs to
* build and teardown your temp folder.
* the done/async stuff may be OTT but do no harm
*
* tasks/file1.js
*/
module.exports = function (grunt) {
grunt.config.set('tempfolder', process.cwd() + "/yourtempfolderhere");
@sharpred
sharpred / add_bundle.rb
Created January 25, 2017 11:36
use cocoapods xcodeproj gem to add a file to your xcode project from the command line
require 'xcodeproj'
project_path = "./platforms/ios/helloWorld.xcodeproj"
project = Xcodeproj::Project.open(project_path)
#add the bundle as a reference
bundle_path = "../../includes/OTABundle.bundle"
bundleRef = project.new_file(bundle_path);
@sharpred
sharpred / lookup.js
Created January 26, 2017 12:47
use of ramda fantasy Maybe for deep inspection of an object property
/*
* use of ramda fantasy Maybe for deep inspection of an object property
* see https://github.com/ramda/ramda-fantasy/blob/master/docs/Maybe.md
* for more info
*/
const R = require("ramda");
const M = require("ramda-fantasy").Maybe;
const Just = M.Just;
const Nothing = M.Nothing;
const response = {
@sharpred
sharpred / webtask1.js
Last active February 20, 2017 16:12
run webtask code with token claims
return function (context, cb) {
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: context.secrets.ACCESS_KEY,
secretAccessKey: context.secrets.SECRET_KEY,
region: 'eu-west-1'
});
var sns = new AWS.SNS();
@sharpred
sharpred / checkrReport.js
Last active May 19, 2017 09:56
checkr webtask
/*
* set a webtask called checkrKey for your API key
*/
module.exports = function (ctx, request, response) {
var request = require("request");
var authKey = 'Basic ' + ctx.secrets.checkrKey;
var url = 'https://api.checkr.com/v1/reports/' + ctx.data.id;
var options = {
method: 'POST',
url: url,