Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Richardson ben-gy

View GitHub Profile
View gist:85fd60ab599d02e501c3f857583dc18b
GIT
remote: https://github.com/ben-gy/flexbox_rb.git
revision: 980eaaafda86bb34cd9deeda6b9655f9d101b1cc
specs:
flexbox_rb (0.5)
railties (>= 3.2.6)
GIT
remote: https://github.com/ben-gy/slack-notify.git
revision: 04001abc1676e6e50872d605a84e77342c9c1ec6
@ben-gy
ben-gy / gist:346fa29ab4495c2f49f95196f3942616
Created Sep 19, 2020
Latest Gemfile for autoprefixer issue
View gist:346fa29ab4495c2f49f95196f3942616
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails'
# Use pg as the database for Active Record
gem 'pg'
# Use Puma as the app server
@ben-gy
ben-gy / Gemfile.rb
Created Apr 23, 2019
This is a copy of the gemfile for a social network that I'm building
View Gemfile.rb
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.0'
# ++ Back-end infrastructure
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails'
# Use pg as the database for Active Record
@ben-gy
ben-gy / setup.md
Last active Apr 23, 2019
How I usually setup a new Rails app
View setup.md

New repo setup

Read the documentation and install each of the following gems after initialising a new rails application. I have provided some initialiser snippets from one of my Rails 5.2 projects with configuration that I'd like to be setup, but please read the documentation to verify the snippets are still constructed correctly based on current gem versions today.

  • install pg (remove sqlite)
  • install paper_trail
  • install act_as_paranoid
  • install rack-attack
class Rack::Attack
View PG Install Fix
An error occurred while installing pg (0.21.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.21.0' --source 'https://rubygems.org/'` succeeds before bundling.
### Use the command below to fix the error above after having installed postgres.app
sudo ARCHFLAGS="-arch x86_64" gem install pg -v '0.21.0' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/10/bin/pg_config
View gist:fdf167de093bde938324a2d7ffff43a7
import string
import requests
from bs4 import BeautifulSoup
import json
import glob
from multiprocessing import Pool
import sys
API_KEY = None # your api key here
CRUNCHBASE_COMPANY_API = "http://api.crunchbase.com/v/1/company/%s.js?api_key=%s"
View latest_gemfile_31_dec_2016.md

My Gemfile (working version)

I try and keep a very verbose Rails Gemfile so any new developers working on my startup can very quickly understand what gems are installed, why they're installed, and the value they add to the project.

I also use my Gemfile as a bit of a todo list when I find smarter or faster gems, or just new cool things that I want to try out. I thought I'd release a copy of what it looks like if you're interested.

source 'https://rubygems.org'
ruby '2.3.1'
View gist:2c66cbd88fe0a0eb52c6914f48eb9717
meta[name="mobile-web-app-capable" content="yes"]
meta[name="apple-mobile-web-app-capable" content="yes"]
meta[name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"]
meta[http-equiv="X-UA-Compatible" content="IE=edge"]
meta[name="apple-mobile-web-app-status-bar-style" content="black"]
meta[name="format-detection" content="telephone=no"]
View backup_script.md
  1. Open terminal
  2. Drop the folder where you want to keep the script in the terminal window
  3. Type "touch backup_script" and hit enter

Now, every time you want to run a backup, open your terminal and drop the script into the window and hit enter.

nb// the folder locations are hardcoded and it's not automatic (run it manually each day)

#!/bin/bash
@ben-gy
ben-gy / gist:633bacb1be7255b217a5
Created Feb 10, 2016
Programming challenge freighter ship
View gist:633bacb1be7255b217a5
You have been hired by a late 18th century naval shipping company who transport large quantities of gold.
They company has multiple ships, all capable of carry different amounts of gold.
The current shipping coordinator, known only as the Seawolf, has realised that their current shipping methods are inefficient and wishes to have a system to reduce the required trips for a given weight of gold.
Your task is to create a system that for a given set of ships, can transport a quantity of gold with the fewest possible trips. Each ship may only carry it's exact quantity. The company has multiple of each ship class.
For instance, with the following ship classes: