Local Continuous Integration Setup With Git Post-Commit Hook Script Local Continuous Integration Setup With Git Post-Commit Hook Script
  • Home
  • Posts
  • Home
  • Posts

Scripts

Local Continuous Integration Setup With Git Post-Commit Hook Script

I have lots unit tests, but I don’t have a Continuous Integration server setup, and I sometimes forget my tests are there.

I know. Bad me. I was up late last night getting some failing unit tests to pass again, after forgetting I even had unit tests. Ugh. This would have been much easier if I knew I’d broken a test when I broke it; as it was, I had to go back and try to remember what I was working on when they broke!

So, to stop that happening in the future, I fiddled around with my local repository and whipped up a script that automatically runs tests in the background, on a separate temporary cloned version of the repository.

If build or tests fail, I get a nice little Notification Center message which I can click to see a report and build log. Then I can fix it and amend the commit as necessary.

It’s a script that’s invoked by a Post-Commit git hook, and it’s run in the background using nohup so it doesn’t make me wait and mess with my workflow. It just all happens transparently in the background.

Here’s how I did it.

Read More

Beautifying code with Alfred

Here’s an Alfred workflow which will perform some prettifying code alignments in the currently-selected text when a hotkey is pressed. It works on instance and struct members, assignments and hey, maybe other things.

Yay, prettier code!

Perform Code Alignment.alfredworkflow

Here’s a video of it in action:

Read More

An iTunes Connect screenshot management workflow

Ugh – iTunes Connect is really annoying to use when it comes to screenshots. There’re some third party tools out there, but it was still too hands-on for my workflow.

So I wrote a little script that does the stuff I want. I have a Sketch document that exports all the screenshots, and the script updates the iTunes Connect metadata XML appropriately.

In case it’s useful to anyone else:

Sketch
Sketch Template

Mate php
Script

Usage:

  1. Work on screenshots

  2. Setup:

    alias iTMSTransporter="/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/MacOS/itms/bin/iTMSTransporter"

  3. Grab latest ITMS data:

    iTMSTransporter -m lookupMetadata -u [email protected] -p password -vendor_id APPVENDORID -destination YourApp.itmsp

  4. Open up the metadata.xml and remove the fields you don’t want to change – this is probably going to be the currently-live
    version, and maybe the product info at the bottom.

  5. Export all the screenshots into the itmsp package folder

  6. Run this tool (update_itmsp_screenshots.php YourApp.itmsp)

  7. Check that everything looks okay

  8. Verify

    iTMSTransporter -m verify -u [email protected] -p password -f YourApp.itmsp

  9. Upload

    iTMSTransporter -m upload -u [email protected] -p password -f YourApp.itmsp

Read More

Searching iOS header files with Xcode

I’m often having to grep through various iOS frameworks in search of error codes that appear (“What the bloody hell does -10867 mean?”). This can be a bit annoying – especially while working with Core Audio – so I put together an Alfred workflow that does it for me.

Here it is – type “hs” (short for “header search”) then the text you want to search for, and it’ll give you matching results. Hit enter to open that file:line combination in Sublime Text, or edit the action script to work with the editor of your choice.

Search Xcode Header Files.alfredworkflow

Screen Shot 2013 04 01 at 11 54 24

Read More

Encrypting and decrypting text with Alfred 2

Here’s a couple of Alfred 2 workflows that implement encryption and decryption via AES256, useful for doing things like sharing passwords.

Select some text (or copy it to the clipboard), and hit the encryption hotkey, and you’ll be prompted for a password; the encrypted contents will be copied to the clipboard.

Then when the recipient has the encrypted text, select or copy it, hit the decryption hotkey, and the original password will be requested. Then, the original text will be displayed and copied to the clipboard.

Encrypt.alfredworkflow

Decrypt.alfredworkflow

Screen Shot 2013 03 25 at 12 51 50

Screen Shot 2013 03 25 at 12 52 14

Read More

I ♥ Alfred: Code execution extensions

ExtensionI’m a really big fan of Alfred, and lately I’ve found it really useful for running tiny little snippets of code — whether it’s to quickly URL decode a string, or remind myself of how C integer-to-float conversion behaves, I find myself using these little extensions I put together quite frequently.

Here’re two workflows I use to run PHP code (one which just executes it and shows the result in Growl, and one which copies the result to the clipboard), and a workflow that runs a snippet of C code. Of course, it wouldn’t take much to make workflows for many other languages, too.

Alfred 2 workflows

Now with live results! Hit enter to copy result to clipboard.

Run C Code.alfredworkflow

Run PHP Code.alfredworkflow

Older, Alfred 1 extensions:

Execute PHP Code.alfredextension

Execute PHP Code, Copy Result.alfredextension

Run C code.alfredextension

Screen Shot 2013 03 25 at 11 25 11

Read More

Uploading to TestFlight with a few keystrokes, using Alfred

TestFlight IconHere’s a cute little Alfred extension I put together today that uploads a file to a TestFlight team for you, after prompting for build notes.

You’ll wanna edit the extension to put in your API key and Team ID, then just select a file in Alfred, type ‘testflight’ (or an abbreviation thereof) and enter, then enter a build summary, and off it goes. Result will appear in Growl.

Upload to TestFlight.alfredextension

Screen Shot 2012 03 22 at 22 10 00

Read More

Supporting WordPress shortcodes and captions in MarsEdit preview

I noticed that WordPress these days uses a shortcode to define image captions, of the form:

[caption id="" align="aligncenter" width="630" caption="Image title goes here"]<img src="http://domain.com/imgpath/../image.jpg" width="630" height="420" />[/caption]

I’ve recently redone our blog template at Technomadics, and while setting up the new preview template in MarsEdit, thought I’d take a stab at implementing support for captions, too, via some javascript in the template.

I was successful! Here’s how I did it:

Added the following to the “head” section:

 
var prior_content;
function watch_for_changes() {
  var check = function() {
    var elt = document.getElementById('content');
    if ( elt.innerHTML != prior_content ) {
       elt.innerHTML = apply_filters(elt.innerHTML);
       prior_content = elt.innerHTML;
    }
    setTimeout(check, 100);
  };
  setTimeout(check, 100);
}
 
function apply_shortcode(source, name, callback) {
   return source.replace(new RegExp('\[' + name + '\s*([^\]]*)\]((.|[sn])*?)\[/' + name + '\]', 'g'),
                         function(match, paramString, content) {
                           params = new Object();
                           reg = /([a-z]+)="((:?="[^"]+"|[^"])*)"/gi;
                           while ( (match = reg.exec(paramString)) != null ) {
                             params[match[1]] = match[2];
                           }
                           return callback(params, content);
                         });
}
 
function apply_filters(html) {
  html = apply_shortcode(html, "caption", function(args, content) {
     return '<div>' + content +
             '<p class="wp-caption-text">' + args.caption + '</p></div>';
  });
 
  return html;
}

var prior_content; function watch_for_changes() { var check = function() { var elt = document.getElementById('content'); if ( elt.innerHTML != prior_content ) { elt.innerHTML = apply_filters(elt.innerHTML); prior_content = elt.innerHTML; } setTimeout(check, 100); }; setTimeout(check, 100); } function apply_shortcode(source, name, callback) { return source.replace(new RegExp('\[' + name + '\s*([^\]]*)\]((.|[sn])*?)\[/' + name + '\]', 'g'), function(match, paramString, content) { params = new Object(); reg = /([a-z]+)="((:?="[^"]+"|[^"])*)"/gi; while ( (match = reg.exec(paramString)) != null ) { params[match[1]] = match[2]; } return callback(params, content); }); } function apply_filters(html) { html = apply_shortcode(html, "caption", function(args, content) { return '<div>' + content + '<p class="wp-caption-text">' + args.caption + '</p></div>'; }); return html; }

…changed to ‘body’ tag to…

 

…And wrapped a div around the main “#body#, #extended#” content with an id of content:

<div id="content">
#body#
#extended#
</div>

<div id="content"> #body# #extended# </div>

Basically, it polls the content area for changes, and when triggered, runs it though a filter. The above is extensible, and by adding additional “apply_shortcode” calls from “apply_filters“, more shortcodes can be simulated.

Read More

Hi! I'm Michael Tyson, and I run A Tasty Pixel from our home in the hills of Melbourne, Australia. I occasionally write on a variety of technology and software development topics. I've also spent 3.5-years travelling around Europe in a motorhome.

I make Loopy, the live-looper for iOS, Audiobus, the app-to-app audio platform, and Samplebot, a sampler and sequencer app for iOS.

Follow me on Twitter.

Posts pagination

1 2 … 4 »
© 2021 A Tasty Pixel.