Skip to content

Instantly share code, notes, and snippets.

View bensie's full-sized avatar

James Miller bensie

View GitHub Profile
@bensie
bensie / imagemagick.bash
Last active November 20, 2023 10:13
ImageMagick Static Binaries for AWS Lambda
#!/usr/bin/env bash
# Must be run on an Amazon Linux AMI that matches AWS Lambda's runtime which can be found at:
# https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html
#
# As of May 21, 2019, this is:
# Amazon Linux AMI 2018.03.0 (ami-0756fbca465a59a30)
#
# You need to prepend PATH with the folder containing these binaries in your Lambda function
# to ensure these newer binaries are used.
@bensie
bensie / birthday.sql
Created February 23, 2009 19:00
Get upcoming birthdays with SQL (discarding the year)
SELECT users.`firstname` AS first,
users.`lastname` AS last,
user_details.`birthday` AS birthday
FROM users
LEFT OUTER JOIN user_details ON user_details.user_id = users.id
WHERE
STR_TO_DATE(DATE_FORMAT(birthday,'%m-%d'),'%m-%d') >= STR_TO_DATE(DATE_FORMAT(now(),'%m-%d'),'%m-%d')
AND
STR_TO_DATE(DATE_FORMAT(birthday,'%m-%d'),'%m-%d') < STR_TO_DATE(DATE_FORMAT(now()+INTERVAL 7 DAY,'%m-%d'),'%m-%d');
@bensie
bensie / base.rb
Created December 6, 2012 17:53
Sinatra API Helpers
require "sinatra/base"
require "sinatra/namespace"
require "multi_json"
require "api/authentication"
require "api/error_handling"
require "api/pagination"
module Api
class Base < ::Sinatra::Base
States must be sent as their full capitalized name or in their 2-letter abbreviation,
those from the following list are valid:
'AL' => 'Alabama',
'AK' => 'Alaska',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DE' => 'Delaware',
@bensie
bensie / datastore.yml
Created June 15, 2021 19:22
CloudFormation - Generic DynamoDB table schema
AWSTemplateFormatVersion: "2010-09-09"
Resources:
Table:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: PK
AttributeType: S
- AttributeName: SK
AttributeType: S
@bensie
bensie / gist:55208
Created January 30, 2009 18:58
Configure Postfix to handle all email for a domain/subdomain and forward to a rails app
/etc/postfix/main.cf:
mydestination = localhost.localdomain, localhost, list.domain.com
virtual_maps = hash:/etc/postfix/virtual
alias_maps = hash:/etc/aliases
/etc/postfix/virtual:
@list.domain.com rails_mailer
/etc/aliases:
rails_mailer: "|/path/to/app/lib/mail_handler.rb http://www.example.com/emails 298cc9dceb1f3cac91fef8b42be624c07843fc8e"
@bensie
bensie / Gemfile
Created August 10, 2011 20:09
savon ntlm
source "http://rubygems.org"
gem 'httpi', :git => 'git://github.com/bensie/httpi.git', :branch => 'ntlm'
gem 'savon'
@bensie
bensie / crash.log
Last active January 1, 2016 19:38
Packer crash with 0.5.0
2013/12/30 17:45:48 Packer Version: 0.5.0 ccaf00c29e16752ffab552a1f04999590062b48a
2013/12/30 17:45:48 Packer Target OS/Arch: darwin amd64
2013/12/30 17:45:48 Built with Go Version: go1.2
2013/12/30 17:45:48 Detected home directory from env var: /Users/james
2013/12/30 17:45:48 Attempting to open config file: /Users/james/.packerconfig
2013/12/30 17:45:48 File doesn't exist, but doesn't need to. Ignoring.
2013/12/30 17:45:48 Packer config: &{PluginMinPort:0 PluginMaxPort:0 Builders:map[amazon-ebs:packer-builder-amazon-ebs amazon-chroot:packer-builder-amazon-chroot docker:packer-builder-docker googlecompute:packer-builder-googlecompute virtualbox-iso:packer-builder-virtualbox-iso vmware-iso:packer-builder-vmware-iso amazon-instance:packer-builder-amazon-instance digitalocean:packer-builder-digitalocean openstack:packer-builder-openstack qemu:packer-builder-qemu virtualbox-ovf:packer-builder-virtualbox-ovf vmware-vmx:packer-builder-vmware-vmx] Commands:map[build:packer-command-build fix:packer-command-fix insp
This file has been truncated, but you can view the full file.
0.000059 main(2): ALWAYS INCLUDE THE FOLLOWING LINES WHEN SENDING DEBUG MESSAGES TO THE MAILING LIST:
0.000095 main(2): gphoto2 2.5.2
0.000105 main(2): gphoto2 has been compiled with the following options:
0.000111 main(2): + gcc (C compiler used)
0.000115 main(2): + popt (mandatory, for handling command-line parameters)
0.000120 main(2): + exif (for displaying EXIF information)
0.000125 main(2): + no cdk (for accessing configuration options)
0.000129 main(2): + no aa (for displaying live previews)
0.000134 main(2): + jpeg (for displaying live previews in JPEG format)
0.000138 main(2): + no readline (for easy navigation in the shell)
NSData *jpeg = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer] ;
CGImageSourceRef source ;
source = CGImageSourceCreateWithData((CFDataRef)jpeg, NULL);
//get all the metadata in the image
NSDictionary *metadata = (NSDictionary *) CGImageSourceCopyPropertiesAtIndex(source,0,NULL);
//make the metadata dictionary mutable so we can add properties to it
NSMutableDictionary *metadataAsMutable = [[metadata mutableCopy]autorelease];