Skip to content

Instantly share code, notes, and snippets.

View slopeofhope81's full-sized avatar

Steve Lim slopeofhope81

View GitHub Profile
@slopeofhope81
slopeofhope81 / environments-on-heroku.md
Created May 24, 2021 17:04 — forked from katlandreth/environments-on-heroku.md
Create Staging and Production apps on Heroku with corrisponding git branches

##Set-up

  • create a heroku account
  • install the heroku toolbelt: https://toolbelt.heroku.com/
  • log into heroku via the commandline with heroku login and enter your credentials.
  • add your AWS (or other) keys to the heroku environment (I did this from the webapp -from your apps list, click on your appname, then Settings > Reveal Config Vars and add your config variables)

##Create your app

  • in your terminal, cd to your app on your local machine
# See https://github.com/justin808/justin808-dotfiles/blob/master/home/.pryrc
# Using these pry gems
# Essentials
# gem "pry"
# gem "pry-rails"
# gem "pry-byebug"
# gem "pry-doc"
# gem "pry-rescue"
# If you like this one:
@slopeofhope81
slopeofhope81 / delayed_job_threads.rb
Created July 13, 2020 13:17 — forked from drush/delayed_job_threads.rb
Run Delayed Job Worker as a Thread in Web Process
# Only run in server process, not console or rake tasks
if !Rails.const_defined?('Console') && !($0 =~ /rake$/) && !Rails.env.test?
Rails.application.config.after_initialize do
(1..2).each do |thread_id|
Thread.new {
Thread.current[:thread_name] = "DJ Web Worker Thread #{thread_id}"
ActiveRecord::Base.connection_pool.with_connection do |conn|
dj = Delayed::Worker.new
Rails.logger.warn "Starting #{Thread.current[:thread_name]}"
@slopeofhope81
slopeofhope81 / spreadsheet_job.rb
Created May 27, 2020 14:12 — forked from willsza/spreadsheet_job.rb
Job Rails to generate excel reports with Axlsx
require 'axlsx'
class SpreadsheetJob < ApplicationJob
queue_as :reports
def perform(*args)
@timestamp = args[0]['timestamp']
create_report
create_spreadsheet
@slopeofhope81
slopeofhope81 / image-arraybuffer.js
Created May 15, 2020 13:56 — forked from candycode/image-arraybuffer.js
Create a jpg image from ArrayBuffer data
// Simulate a call to Dropbox or other service that can
// return an image as an ArrayBuffer.
var xhr = new XMLHttpRequest();
// Use JSFiddle logo as a sample image to avoid complicating
// this example with cross-domain issues.
xhr.open( "GET", "http://fiddle.jshell.net/img/logo.png", true );
// Ask for the result as an ArrayBuffer.
xhr.responseType = "arraybuffer";
@slopeofhope81
slopeofhope81 / capybara-selenium-webdriver-slow-speed.md
Created May 10, 2020 22:49 — forked from scmx/capybara-selenium-webdriver-slow-speed.md
Capybara Selenium WebDriver running at a lower speed using sleep command #capybara #selenium #rails #

Capybara Selenium WebDriver running at a lower speed using sleep command

Ever wanted to run your integration/end-to-end test suite at a lower speed so that you better could observe what's happening and perhaps make a recording of it?

Here's a a technique I've been using when writing tests with Capybara Selenium WebDriver.

Put this in test/test_helper.rb or maybe something like spec/support/capybara.rb.

@slopeofhope81
slopeofhope81 / settings.rb
Created April 2, 2020 12:22 — forked from justinweiss/settings.rb
Simple settings for Rails
require 'yaml'
require 'erb'
require 'ostruct'
class Settings < OpenStruct
# Settings.new(:google_analytics)
def initialize(config_file_base_name)
super(YAML.load(ERB.new(File.read(Rails.root.join("config", "#{config_file_base_name}.yml"))).result)[Rails.env])
end
@slopeofhope81
slopeofhope81 / settings.rb
Created April 2, 2020 12:22 — forked from justinweiss/settings.rb
Simple settings for Rails
require 'yaml'
require 'erb'
require 'ostruct'
class Settings < OpenStruct
# Settings.new(:google_analytics)
def initialize(config_file_base_name)
super(YAML.load(ERB.new(File.read(Rails.root.join("config", "#{config_file_base_name}.yml"))).result)[Rails.env])
end
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
@slopeofhope81
slopeofhope81 / FixCommandForMacKeyboard.md
Created December 12, 2019 12:52 — forked from digiter/FixCommandForMacKeyboard.md
Map Command Key to Control For ubuntu + mac keyboard

For each machine running xmodmap will give you the mapping and keycode, take a look first then write the script. I use ubuntu and mac keyboard. The below maps both left and right control and super.

Create an .Xmodmap file in your Linux home directory, with the following contents, then execute xmodmap .Xmodmap

clear control
clear mod4

keycode 37 = Super_L
keycode 105 = Super_R