Skip to content

Instantly share code, notes, and snippets.

View DRBragg's full-sized avatar

Drew Bragg DRBragg

View GitHub Profile
@DRBragg
DRBragg / atom_shortcuts.md
Created July 26, 2017 18:55 — forked from smkopp92/atom_shortcuts.md
A guide for coding efficiency

#Atom Shortcuts Shamelessly stolen borrowed from DRod who shamelessly stole borrowed from Christina

##Settings

Access settings with cmd + ,

###Themes

@DRBragg
DRBragg / capybara cheat sheet
Created July 31, 2017 22:08 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@DRBragg
DRBragg / Editor.vue
Created June 8, 2018 14:56 — forked from stevebauman/Editor.vue
VueJS 2 + Trix Editor V-Model Component
<template>
<div></div>
</template>
<script>
import Trix from 'trix';
export default {
props: ['value'],
@DRBragg
DRBragg / file_uploader.rb
Last active September 27, 2023 06:46
PDF Previews with carrierwave
class ItemUploader < CarrierWave::Uploader::Base
require 'carrierwave/orm/activerecord'
include CarrierWave::RMagick
attr_reader :geometry
# Create thumbnail for images and PDFs
version :thumb, :if => :thumbable? do
process :resize_to_fit => [240, 240], :if => :image?
process :pdf_preview => [240, 240], :if => :pdf?
@DRBragg
DRBragg / deploy.md
Created September 14, 2018 20:38
DO setup for RoR app

Setting up Digital Ocean Server for Deployment

  • Create a droplet
    • Choose Ubuntu as your distribution (16.04.4 x64)
    • Choose the size of your droplet (min 1GB and 1CPU)
    • Choose New York 1 or 3 for your datacenter
    • Optional:
      • Add SSH keys now (can also do this later)
      • Rename the hostname (generally to something that makes sense)
@DRBragg
DRBragg / SITE_NAME
Created February 15, 2019 16:38
nginx config stuffs
# /etc/nginx/sites-enabled/SITE_NAME
server {
server_name SERVER_NAME.com;
passenger_enabled on;
rails_env production;
root /home/deploy/APP_NAME/current/public;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
@DRBragg
DRBragg / rsync.md
Last active June 21, 2019 16:03
rsync log files

ON REMOTE

$ sudo rsync -avz /var/log/nginx/ /home/deploy/nginx/

$ sudo chown -R deploy /home/deploy/nginx

ON LOCAL

$ sudo rsync -avz deploy@://home/deploy/nginx/ /logs/jazz/

@DRBragg
DRBragg / indexes.rb
Created August 15, 2019 16:08
Find Missing Indexes
#Credits: http://tomafro.net/2009/09/quickly-list-missing-foreign-key-indexes
c = ActiveRecord::Base.connection
c.tables.collect do |t|
columns = c.columns(t).collect(&:name).select {|x| x.ends_with?("_id" || x.ends_with("_type"))}
indexed_columns = c.indexes(t).collect(&:columns).flatten.uniq
unindexed = columns - indexed_columns
unless unindexed.empty?
puts "#{t}: #{unindexed.join(", ")}"
@DRBragg
DRBragg / nhl.rb
Last active October 22, 2019 18:16
NHL data for Sports Club Stats
require 'net/http'
require 'json'
TEAMS_URL = 'https://statsapi.web.nhl.com/api/v1/teams'
DATA_URL = 'https://statsapi.web.nhl.com/api/v1/schedule?startDate=2019-10-02&endDate=2020-04-04&expand=schedule.linescore'
def fetch_data(url)
uri = URI(url)
response = Net::HTTP.get(uri)
JSON.parse(response)
@DRBragg
DRBragg / App.vue
Last active May 14, 2020 16:57
SW Content Update (Vue)
// src/App.vue
// I use Vuetify in almost all of my Vue apps so this is how __I__ handle alerting the user to an update.
// Your implementation may change based on your UI
<template>
<!-- normal vue views stuff -->
<v-snackbar bottom right :value="updateExists" :timeout="0" color="primary">
An update is available
<v-btn text @click="refreshApp">
Update