Skip to content

Instantly share code, notes, and snippets.

View kyreeves's full-sized avatar

Kyle Reeves kyreeves

View GitHub Profile
@kyreeves
kyreeves / photoshop-change-text-and-export.js
Created March 1, 2023 22:33 — forked from chengluyu/photoshop-change-text-and-export.js
Photoshop Batch Process - Change Text and Export
// This script works well with Photoshop CC 2017
// Adopted from stackoverflow.com/questions/14571008/photoshop-scripting-changing-text-of-a-text-layer
Array.prototype.forEach = function (fn) {
for (var i = 0; i < this.length; i++) {
fn(this[i], i);
}
};
var doc;
@kyreeves
kyreeves / create_document.rb
Created January 4, 2023 18:08 — forked from sulmanweb/create_document.rb
ActiveStorage file uploading in GraphQL API in Rails
# app/graphql/types/objects/document_type.rb
module Mutations
class CreateDocument < BaseMutation
description "creates a document for the user in the system"
argument :doc, ApolloUploadServer::Upload, required: true
field :document, Types::Objects::DocumentType, null: false
@kyreeves
kyreeves / 01-safe-download.rb
Created May 8, 2022 04:58 — forked from janko/01-safe-download.rb
A safe way in Ruby to download a file to disk using open-uri (with/without comments)
require "open-uri"
require "net/http"
Error = Class.new(StandardError)
DOWNLOAD_ERRORS = [
SocketError,
OpenURI::HTTPError,
RuntimeError,
URI::InvalidURIError,
@kyreeves
kyreeves / bucket_sync_service.rb
Last active May 26, 2020 21:32
ruby class to copy objects from one aws s3 bucket to another
require "aws-sdk-s3"
class BucketSyncService
attr_reader :from_bucket, :to_bucket, :logger
attr_accessor :debug
def initialize(from_bucket, to_bucket)
@from_bucket = bucket_from_credentials(from_bucket)
@to_bucket = bucket_from_credentials(to_bucket)
end
:first-child i === 0
:last-child i === arr.length - 1
:only-child arr.length === 1
:nth-child(even) i % 2
:nth-child(odd) !(i % 2)
:nth-child(n) i === n - 1
:nth-last-child(n) i === arr.length - n
#!/bin/bash
set -e
RELEASES_URL=https://johnvansickle.com/ffmpeg/releases/
RELEASE_TYPE=64bit
RELEASE_VERSION=3.4.0
UNTARRED_NAME="ffmpeg-${RELEASE_VERSION}-${RELEASE_TYPE}-static"
TAR_NAME="ffmpeg-release-${RELEASE_TYPE}-static.tar"
@kyreeves
kyreeves / active_record_uniqueness_exceptions.rb
Last active December 29, 2018 01:09
Active record patch that rescues ActiveRecord::RecordNotUnique exceptions and adds errors on save, and raises on save!
# Adapted from
# https://gist.github.com/bf4/5594532#file-validations-rb-L5
# https://speakerdeck.com/erniemiller/an-intervention-for-activerecord?slide=117
# Per https://github.com/rails/rails/blob/5-1-stable/activerecord/lib/active_record/validations/uniqueness.rb#L140-L147
# Using this validation method in conjunction with
# {ActiveRecord::Base#save}[rdoc-ref:Persistence#save]
# does not guarantee the absence of duplicate record insertions,
module ActiveRecordUniquenessExceptions
# @example error message
#
@kyreeves
kyreeves / mounts3.doc
Created September 19, 2018 16:31 — forked from larryrutledge/mounts3.doc
Mount AWS S3 as a volume
brew cask install osxfuse (requires a reboot after installation completes)
brew install s3fs
create a password file:
echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ~/.passwd-s3fs
chmod 600 ~/.passwd-s3fs
(replace ACCESS_KEY_ID and SECRET_ACCESS_KEY with the actual AWS values)
(password file should only contain a single line with the two values separated by a colon)
create a local folder to serve as mount point - this will be the folder name you reference to access the S3 bucket.