Skip to content

Instantly share code, notes, and snippets.

@jlawton
jlawton / carthage-graph.pl
Created October 24, 2017 05:38
Resolved Carthage dependency grapher
#!/usr/bin/env perl -w
use strict;
use Text::ParseWords qw(quotewords);
# Returns [DependencyName]
sub parseCartfile {
open(my $fh, '<', $_[0]) or die "Cannot open file $_[0]";
my @entries = ();
while (my $line = <$fh>) {
@jlawton
jlawton / semver
Created October 3, 2017 18:01
Basic script to help manage semantic versions
#!/usr/bin/env perl -w
use strict;
use List::Util qw(any);
use File::Basename qw(basename);
sub main {
# We require 3 arguments
if ($#ARGV != 2) {
usage();
@jlawton
jlawton / gh
Last active November 6, 2017 07:05
Basic Open in GitHub from the command line
#!/usr/bin/env perl -w
use Getopt::Long;
sub main {
my $format = undef;
GetOptions('format=s', \$format);
if ($#ARGV > 0) {
quit("Usage: $0 [-f <format>] [<directory>]");
// Copyright (c) 2014 James Lawton
#import <Foundation/Foundation.h>
/**
* A mutable array that keeps itself sorted, according to a comparator.
* This has similar guarantees to NSMutableArray. It is not thread safe.
* Don't mutate this while enumerating.
*/
@interface JALSortedArray : NSObject <NSFastEnumeration, NSCopying>
@jlawton
jlawton / blur-and-darken.m
Last active July 17, 2018 19:23
CIFilter Blur
// Fix for https://github.com/bryanjclark/ios-darken-image-with-cifilter
-(instancetype)darkened:(CGFloat)alpha andBlurredImage:(CGFloat)radius blendModeFilterName:(NSString *)blendModeFilterName {
CIImage *inputImage = [[CIImage alloc] initWithImage:self];
CIContext *context = [CIContext contextWithOptions:nil];
//First, create some darkness
CIFilter* blackGenerator = [CIFilter filterWithName:@"CIConstantColorGenerator"];