Skip to content

Instantly share code, notes, and snippets.

View dirtyhenry's full-sized avatar

Mick F dirtyhenry

View GitHub Profile
@dirtyhenry
dirtyhenry / Xcode4TestFlightintegration.sh
Created May 30, 2012 12:46 — forked from incanus/Xcode4TestFlightintegration.sh
Xcode 4 scheme Archive step Post-script for automatic TestFlight build uploading. See the blog post here: http://developmentseed.org/blog/2011/sep/02/automating-development-uploads-testflight-xcode
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
API_TOKEN=<TestFlight API token here>
TEAM_TOKEN=<TestFlight team token here>
SIGNING_IDENTITY="iPhone Distribution: Development Seed"
PROVISIONING_PROFILE="${HOME}/Library/MobileDevice/Provisioning Profiles/MapBox Ad Hoc.mobileprovision"
#LOG="/tmp/testflight.log"
@dirtyhenry
dirtyhenry / arc4random_test
Created January 4, 2013 16:54
arc4random vs arc4random_uniform distribution in iOS
NSMutableArray *stats1 = [NSMutableArray arrayWithObjects:[NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], nil];
NSMutableArray *stats2 = [NSMutableArray arrayWithObjects:[NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], [NSNumber numberWithInteger:0], nil];
NSInteger nbSamples = 1000;
for (NSInteger i = 0; i < nbSamples; i++) {
NSInteger new = (arc4random() % 10);
if (new >= 0 && new <= 9) {
NSNumber *prev = [stats1 objectAtIndex:new];
NSNumber *newNumb
@dirtyhenry
dirtyhenry / poc-openssl-aes.rb
Last active June 5, 2018 11:48
Encryption interoperability demo between Ruby and OpenSSL
require 'openssl'
require 'base64'
# Read the dummy file
data = File.read("test.txt")
# Create an encrypter
cipher = OpenSSL::Cipher::AES.new(256, :CBC)
cipher.encrypt
key = cipher.random_key
@dirtyhenry
dirtyhenry / poc-jaccard.rb
Last active December 17, 2015 13:09
Proof of concept of the jaccard gem for String comparisons, including benchmark for a set of 100 names (fake band names generated by http://www.bandnamemaker.com/ with an exception for "The Strokes"). Type names on the standard input and find out the closest match.
require 'jaccard'
require 'benchmark'
artists = [
"The Strokes",
"Brilliant herb",
"Sparse refuge",
"Shrieking dagger",
"Twelve Haunted Homes",
"Wise crypt",
@dirtyhenry
dirtyhenry / simplest-s3-upload.rb
Created June 4, 2013 11:55
This is the Ruby code I use to test/validate S3 access policies.
require 'fog'
connection = Fog::Storage.new({
:provider => 'AWS',
:aws_access_key_id => 'access_key_id',
:aws_secret_access_key => 'secret_acces_key'
})
directory = connection.directories.get('bucket_name')
@dirtyhenry
dirtyhenry / Gabriel.java
Created June 18, 2013 09:57
Weird code with Java loop optimization at runtime
package com.com.com;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
public class Gabriel {
private final static Logger LOG = Logger.getLogger(Gabriel.class);
@dirtyhenry
dirtyhenry / agile-jira-workflow.xml
Created July 23, 2013 14:28
Agile JIRA Workflow Definition
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow PUBLIC "-//OpenSymphony Group//DTD OSWorkflow 2.8//EN" "http://www.opensymphony.com/osworkflow/workflow_2_8.dtd">
<workflow>
<meta name="jira.update.author.key">mick</meta>
<meta name="jira.description">Agile JIRA Workflow Definition</meta>
<meta name="jira.updated.date">1374589472735</meta>
<initial-actions>
<action id="1" name="Create">
<validators>
<validator name="" type="class">
@dirtyhenry
dirtyhenry / S3permission
Last active December 23, 2015 18:29
This is the permission you need to set with Amazon AWS S3 to provide full access to a "mybucket" bucket and read-access only to all your buckets.
{
"Statement": [
{
"Effect": "Allow",
"Action": "S3:*",
"Resource": "arn:aws:s3:::mybucket/*",
"Condition": {}
},
{
"Effect": "Allow",
@dirtyhenry
dirtyhenry / bootstragram-dark.terminal
Created October 28, 2013 13:54
My Terminal configurations
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGHyBYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKUHCBEVHFUkbnVsbNQJCgsMDQ4PEFdOU1doaXRlXE5TQ29sb3JTcGFjZV8QEk5T
Q3VzdG9tQ29sb3JTcGFjZVYkY2xhc3NCMAAQA4ACgATSEgwTFFROU0lEEAKAA9IWFxgZ
WiRjbGFzc25hbWVYJGNsYXNzZXNcTlNDb2xvclNwYWNlohobXE5TQ29sb3JTcGFjZVhO
@dirtyhenry
dirtyhenry / gist:7547064
Created November 19, 2013 15:27
iOS code that: 1/ validates an email found in a UITextField 2/ check chances of spelling mistakes
- (NSArray *)allMyContacts {
// cf. http://stackoverflow.com/questions/12083643/how-do-i-correctly-use-abaddressbookcreatewithoptions-method-in-ios-6
CFErrorRef error = nil;
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &error);
__block BOOL accessGranted = NO;
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
accessGranted = granted;