Skip to content

Instantly share code, notes, and snippets.

View avogel3's full-sized avatar

Andrew Vogel avogel3

View GitHub Profile
@avogel3
avogel3 / switch_scraper.rb
Created May 5, 2022 03:51
Get a list of mechanical keyboard switches by scraping KeyBumps
# Full Credit to Keybumps for putting together this list
#
# This script assumes you have ruby and the bundler gem installed
#
# ruby switch_scraper.rb
#
# Will write a switches.json file that is an array of switches
# with attributes model,feel,actuation,pre-travel,total-travel,mount
require 'bundler/inline'
@avogel3
avogel3 / keybindings.json
Last active June 16, 2020 15:21
VSCode Keybindings Rails
// Place your key bindings in this file to override the defaults
// TODO: Only in spec files, open terminal if one not open?
// NOTE: [ctrl+t] Run the currently focused rspec test file when the editor languageId is ruby
// NOTE: [ctrl+y] Run the rspec test file on the current line number under the cursor
[
{
@avogel3
avogel3 / list_devices.sh
Created June 10, 2019 20:07
List all devices on your network
# brew install nmap (if you're on OSX)
nmap --script smb-os-discovery -p 445 192.168.1.0/24
@avogel3
avogel3 / thumbs.sh
Last active January 29, 2019 16:43
Create thumbnails for every video file (mp4) in a directory (OSX, ffmpeg)
mkdir -p thumbs && ls *.mp4 | sed -e 's/\.mp4$//' | xargs -I '{}' -t ffmpeg -i '{}.mp4' -ss 00:00:01.000 -vframes 1 'thumbs/{}_thumb.png' && open thumbs
@avogel3
avogel3 / README.md
Last active January 15, 2019 16:38
Component Generator for React Native(using React Navigation & Flow)

React Native Gen Component Script

Example Usage

$ chmod +x gem_component.sh # First make sure the script is executable
$ ./gen_component.sh Home

Which will create the following files:

@avogel3
avogel3 / prawn2s3.rb
Last active August 9, 2022 17:38
Uploading Prawn Generated PDFs to S3 in Rails using Paperclip
# Ran into an issue recently where I wanted to use our custom prawn class to generate a PDF, then upload it to Amazon S3 using paperclip.
# Let 'OurCustomPdf' be our prawn class.
# Let the variable '@user' be our our model, has_many :documents
# Let 'Document' be our paperclip model, belongs_to :user
pdf = OurCustomPdf.new(@user, "pdf")
upload = @user.documents.new
upload.attachment = StringIO.new(pdf.render)
upload.save!