Skip to content

Instantly share code, notes, and snippets.

View mattapperson's full-sized avatar
🏠
Working from home

Matt Apperson mattapperson

🏠
Working from home
View GitHub Profile
const testStrings = [
" I don't want to take it.",
" I don't want to take...",
" I don't want to take away.",
" I don't want to take away",
" I don't want to take away from",
" I don't want to take away from",
" I don't want to take away from the",
" I don't want to take away from the",
" I don't want to take away from the truth!",
let dailyText = await loadText()
if (config.runsInWidget) {
let widget = createWidget(dailyText)
Script.setWidget(widget)
Script.complete()
} else {
Safari.open(dailyText.url.replace('/wol/','jwpub://' ))
}
function myFunction(buttonEl, rowID) {
// ... do something with rowID
}
<button onclick="myFunction(this, 'rowID')">
// Another closure
function myFunction(rowID) {

Automocking thoughts

Allow users to create mocks using 2 APIs... Consumers or providors could write mocks using these tools...

// This block only runs if recording live
await ifLiveBlock(async () => {
  await new Promise(resolve => {
    const pipe = spawn("mongod", ["--dbpath=<LOCATION>", "--port", "1223"]);
@mattapperson
mattapperson / rancher-deploy.js
Last active October 14, 2015 19:13
rancher-deploy - A quick script I wrote to deploy services to rancher in one command... will finish it up and deploy via NPM soon...
#!/usr/bin/env node
process.env.RANCHER_URL = '<your project URL here>';
process.env.RANCHER_ACCESS_KEY = '<your access key here>';
process.env.RANCHER_SECRET_KEY = '<your secret key here>';
var spawn = require('child_process').spawn;
var exec = require('child_process').exec;
var path = require('path');
var fs = require('fs')
@mattapperson
mattapperson / implantation.m
Last active August 29, 2015 14:07
Get a Dictionary of native values to return to Titanium
// Where response is an instance of NativeCustomClass
NSDictionary *event = [self dictionaryValues:response fromClass:[NativeCustomClass class]];
@mattapperson
mattapperson / Instructions
Last active August 29, 2015 14:05
CommonJS Controllers for alloy
In your Alloy project, add the alloy.jmk file to the app folder and create a directory called template, in the template directory, add the component.js file. Then simply start building your alloy apps with commonjs style controller.
Want to require in another controller? simply access it like this:
var otherController = require('otherController').class;
Events are now namespaced to the `C` variable for views.
find-up() {
local path=$(pwd)
while [[ "$path" != "" && ! -e "$path/$1" ]]; do
path=${path%/*}
done
if [ "$path" != "" ]
then
echo "$path"
fi
}
<Alloy>
<Window class="container" id="editWindow">
<View layout="vertical">
<!-- Reuse same fields from addbook (ex: Require type="view" src="rss" id="rssTab") -->
<Label class="label">Title:</Label>
<TextField id="titleInput" hintText="Title..."/>
<Label class="label">Author:</Label>
<TextField id="authorInput" hintText="Author..."/>
<Button id="cancelButton" title="Cancel" onClick="cancelUpdate"/>
<Button id="saveButton" title="Save" onClick="updateBook"/>
@mattapperson
mattapperson / Shell step 1
Created May 11, 2014 20:22
Jenkins iOS for Titanium mobile
cd ~/Desktop/ticonf2014testappdemo/alloytest
titanium clean
titanium build --platform=iphone --test &
sleep 30
killall "iPhone Simulator"
export PATH="/Users/andrewmcelroy/.rbenv/shims:/Applications/Postgres.app/Contents/MacOS/bin:/Users/andrewmcelroy/bin:/usr/local/bin:/Users/andrewmcelroy/.rbenv/bin:/Users/andrewmcelroy/android/tools:/Users/andrewmcelroy/android/:/Users/andrewmcelroy/android//tools:/Users/andrewmcelroy/android/platform-tools/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/andrewmcelroy/.ec2/bin"
echo | titanium calabash --platform=iphone