Skip to content

Instantly share code, notes, and snippets.

James Miller bensie

Block or report user

Report or block bensie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bensie
bensie / imagemagick.bash
Last active Jan 23, 2020
ImageMagick Static Binaries for AWS Lambda
View imagemagick.bash
#!/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 / routes.rb
Last active Aug 29, 2015
Rails Authentication
View routes.rb
Rails.application.routes.draw do
scope module: "api" do
constraints subdomain: "api" do
match "/", to: "root#options", via: [:options]
match "*unmatched", to: "root#options", via: [:options]
resource :me, only: [:show, :update], controller: "me"
post "/me/access_tokens", to: "access_tokens#create"
delete "/me/access_tokens", to: "access_tokens#destroy"
@bensie
bensie / uploader.go
Created Jan 7, 2015
Quick and dirty golang file uploader
View uploader.go
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func uploadHandler(w http.ResponseWriter, r *http.Request) {
View keybase.md

Keybase proof

I hereby claim:

  • I am bensie on github.
  • I am bensie (https://keybase.io/bensie) on keybase.
  • I have a public key whose fingerprint is B720 6EF1 71C0 466C 38BF 65AC C5AB 1889 61E6 14A1

To claim this, I am signing this object:

View gist:e9b5cd8a16fe1d40210f
sudo apt-get install openjdk-7-jre-headless -y
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.2.2.deb
sudo dpkg -i elasticsearch-1.2.2.deb
sudo service elasticsearch start
@bensie
bensie / api.rb
Created Mar 11, 2014
Accept multipart upload with Sinatra
View api.rb
post "/shots" do
if params[:photo] && params[:photo].is_a?(Hash)
class UploadedFile < OpenStruct; end
paperclip = UploadedFile.new(
tempfile: params[:photo][:tempfile],
path: params[:photo][:tempfile].path,
original_filename: params[:photo][:filename],
content_type: params[:photo][:type],
head: params[:photo][:head]
)
View api_macros.rb
require "json"
module ApiMacros
def json(content)
JSON.pretty_generate content
end
def decode_json(content)
JSON.parse content, symbolize_names: true
@bensie
bensie / crash.log
Last active Jan 1, 2016
Packer crash with 0.5.0
View crash.log
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
View gist:6789485
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)
View copyexif.m
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];
You can’t perform that action at this time.