Skip to content

Instantly share code, notes, and snippets.

View jkotchoff's full-sized avatar
💭
1's and 0's

Jason Kotchoff jkotchoff

💭
1's and 0's
View GitHub Profile
@jkotchoff
jkotchoff / generate_twitter_bearer_token.rb
Last active April 27, 2023 23:10
Send Tweets to the Twitter API with an OAuth1 token
# Generate and use an oauth2 bearer token for the Twitter API in Ruby
#
# For Application-Only authentication to the twitter API, a 'bearer token'
# is required to authenticate agains their endpoints for rate limiting
# purposes.
#
# This script generates a bearer token by posting to twitter and then it
# uses that token to poll their API.
#
# Note, the base 64 encoded consumer credentials for the bearer token needs
@jkotchoff
jkotchoff / emailed_zip_file_extractor.rb
Created November 29, 2016 00:23
Rails example of how to connect to the Gmail API using Ruby and download a Zip File attachment and then unzip contents from the zip archive
class EmailedZipFileExtractor
# This class downloads an email from gmail and extracts a file out of a .zip attachment
require 'google/apis/gmail_v1'
require 'googleauth'
require 'zip'
# These credentials come from creating an OAuth Web Application client ID
# in the Google developer console
#
@jkotchoff
jkotchoff / appc.js
Last active November 12, 2017 01:29
This Titanium code can be used in an appcelerator project (with Hyperloop enabled) to determine if an iOS advertisement was the cause of the current installation
module.exports = {
hyperloop: {
ios: {
xcodebuild: {
frameworks: [
'iAd'
]
}
}
}
@jkotchoff
jkotchoff / bitrise.yml
Created April 12, 2020 04:45
Bitrise CI slack workflow
...
workflows:
primary:
steps:
- [email protected]:
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
- [email protected]: {}
- [email protected]:
inputs:
- content: |-
@jkotchoff
jkotchoff / 1-oauth2_tweet_from_ruby.md
Last active July 3, 2023 10:54
Twitter v2 Oauth2 send tweet from Ruby on Rails
@jkotchoff
jkotchoff / pdf_extractor.rb
Last active April 24, 2025 04:28
Extract structured data in JSON from a PDF using an LLM (like Claude) via the AWS SDK with Bedrock
# Query an LLM like Claude using AWS Bedrock to extract structured data from a PDF
#
# https://community.aws/content/2i4v2vZRb9YgL2RxkawPiF8f0lZ/using-document-chat-with-the-amazon-bedrock-converse-api?lang=en#read-a-document-and-add-it-to-a-message
# https://community.aws/content/2hWA16FSt2bIzKs0Z1fgJBwu589/generating-json-with-the-amazon-bedrock-converse-api
class PdfExtractor
require 'aws-sdk-bedrockruntime'
require 'json'
# https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html
CLAUDE_3_5_HAIKU_MODEL_ID = 'anthropic.claude-3-5-haiku-20241022-v1:0'