heroku run rails console --app APPNAME
heroku run rake db:migrate --app APPNAME
| // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ | |
| // © planetroast | |
| //@version=4 | |
| study("JMC Indicators") | |
| // ----------------------------------------------------------------------------- | |
| // Indicator # 1 (aka 'JMC') | |
| // ----------------------------------------------------------------------------- | |
| // Note that the value of this number can vary wildly depnding on which chart |
| class CompetitionEntry < ActiveRecord::Base | |
| belongs_to :competition | |
| belongs_to :user | |
| has_many :team_members | |
| has_many :competition_entry_images | |
| enum status: %i(semi_finals finals) | |
| scope :all_finals, ->{ where(status: statuses.values_at(*%i(semi_finals finals))) } |
| class Profile < ApplicationRecord | |
| mount_uploader :avatar, AvatarUploader | |
| geocoded_by :postcode | |
| after_validation :geocode | |
| has_many :profile_services | |
| has_many :services, :through => :profile_services | |
| has_many :testimonials | |
| belongs_to :user |
| class JentriesController < ApplicationController | |
| def index | |
| @jentries = Jentry.all | |
| end | |
| def show | |
| @jentry = Jentry.find_by(:jentry_timestamp => params[:id]) | |
| end |
| # FileGrabber | |
| # Designed for downloading, unzipping, saving, and tidying of affiliate window product feeds. | |
| # ------------------------------------------------------------------------------------------- | |
| # Usage: @foo = FileGrabber.new(url: "product-feed-url") | |
| # Optional agrs: | |
| # folder_name (sets the name of the folder which contains the downloaded files) | |
| # folder_path (sets where to store the downloaded files) | |
| # trim (how many downloads do you want to keep saved? The rest will be deleted) | |
| class FileGrabber |
| # Assorted | |
| # ------------------------------------ | |
| # Linux alias commands for general use. | |
| alias sites='cd ~/sites/' # opens the sites folder | |
| alias sb='cd ~/sandbox/' # opens the sandbox folder | |
| alias folder='nemo .' # opens the current directory in nemo file browser | |
| alias xt='exit' # closes the terminal | |
| alias sen='sensors' # shows cpu and gpu temps | |
| alias ..='cd ../' # change directory to parent |
| # Rails Affiliate Window Scaffold | |
| # -------------------------------------------------------------------------------------- | |
| # Purpose: For creating all the columns needed for Affiliate Window product feeds. | |
| # Usage: Paste everything below into your terminal then rake db:migrate. | |
| # Note: The backslashes allow the Linux terminal to run multi line commands. | |
| rails g scaffold Product \ | |
| aw_deep_link:string \ | |
| product_name:string \ | |
| aw_product_id:bigint \ |
| # Password Generator | |
| # Class name: Originally I had named my class 'PasswordGenerator' and found this was causing a 'not a class' error. Changing the name of the class to 'GeneratePassword' fixed the problem. | |
| # Boolean checking: When writing the validations for the arguements I wanted to check if that data passed in was a boolean. I was surprised to discover that you can't use: foo.is_a?(Boolean) in the same way that foo.is_a?(Integer) works. Found a neat way around it: !!foo == foo which converts the value to a boolean then checks it against itself. | |
| class GeneratePassword | |
| def initialize(length, uppercase, lowercase, number, special) | |
| @length = length | |
| @uppercase = uppercase | |
| @lowercase = lowercase |