Skip to content

Instantly share code, notes, and snippets.

View malachaifrazier's full-sized avatar
🏠
Working from home

Malachai malachaifrazier

🏠
Working from home
View GitHub Profile
@malachaifrazier
malachaifrazier / add_index_for_searchable_fields_in_developers.rb
Last active May 18, 2022 18:45
AddIndexForSearchableFieldsInDevelopers
class AddIndexForSearchableFieldsInDevelopers < ActiveRecord::Migration[7.0]
def up
execute <<-SQL
ALTER TABLE developers
ADD COLUMN textsearchable_index_col tsvector
GENERATED ALWAYS AS (to_tsvector('simple', coalesce(hero, '') || ' ' || coalesce(bio, ''))) STORED;
SQL
add_index :developers, :textsearchable_index_col, using: :gin, name: :textsearchable_index
end
@malachaifrazier
malachaifrazier / bin-setup-fail-console-output.rb
Created May 18, 2022 17:04
`bin/setup` failed on fresh install
➜ railsdevs.com git:(local) bin/setup
== Installing dependencies ==
https://github.com/Shopify/erb-lint.git is not yet checked out. Run `bundle install` first.
Bundler 2.3.12 is running, but your lockfile was generated with 2.3.4. Installing Bundler 2.3.4 and restarting using that version.
Fetching gem metadata from https://rubygems.org/.
Fetching bundler 2.3.4
Installing bundler 2.3.4
Fetching gem metadata from https://rubygems.org/.........
Fetching https://github.com/Shopify/erb-lint.git
Fetching https://github.com/pay-rails/pay.git
@malachaifrazier
malachaifrazier / uscities.csv
Created January 20, 2020 23:15 — forked from kcsluis/uscities.csv
US Cities
We can't make this file beautiful and searchable because it's too large.
"city","city_ascii","state_id","state_name","county_fips","county_name","lat","lng","population","population_proper","density","source","incorporated","timezone","zips","id"
"Prairie Ridge","Prairie Ridge","WA","Washington","53053","Pierce","47.1443","-122.1408","","","1349.8","polygon","False","America/Los_Angeles","98360 98391","1840037882"
"Edison","Edison","WA","Washington","53057","Skagit","48.5602","-122.4311","","","127.4","polygon","False","America/Los_Angeles","98232","1840017314"
"Packwood","Packwood","WA","Washington","53041","Lewis","46.6085","-121.6702","","","213.9","polygon","False","America/Los_Angeles","98361","1840025265"
"Wautauga Beach","Wautauga Beach","WA","Washington","53035","Kitsap","47.5862","-122.5482","","","261.7","point","False","America/Los_Angeles","98366","1840037725"
"Harper","Harper","WA","Washington","53035","Kitsap","47.5207","-122.5196","","","342.1","point","False","America/Los_Angeles","98366","1840037659"
"Telma","Telma","WA","Washington","53007","Chelan","47.8432","-1
require 'nokogiri'
require 'zlib'
require 'open-uri'
require 'net/http'
require 'net/https'
=begin
To get up and running on local:
git clone [email protected]:mphteam/list-hub.git
change directories to list-hub (cd list-hub)
@malachaifrazier
malachaifrazier / README.md
Created November 7, 2019 22:48 — forked from bazzel/README.md
Rails 6 and Bootstrap 4

This blogpost shows how to setup Rails 6 with Bootstrap 4.

This snippet shows a somehow different and less customized approach.

$ rails new rails6-bootstrap4
$ bundle --binstubs
$ yarn add bootstrap jquery popper.js
@malachaifrazier
malachaifrazier / rails_new.md
Created November 7, 2019 19:17 — forked from patwey/rails_new.md
Steps for creating a new rails app with a Postgres database, Haml, RSpec and FactoryGirl

Steps

  1. Create app, skipping TestUnit and specifying a Postgres db: $ rails new app_name -T --database=postgresql

  2. Update the Gemfile: Gemfile:

    gem 'haml'
    gem 'haml-rails'

Setup Work

  • Make a list of competitive/alternative services: See competitors.md file
  • Set up Google News alerts for "side project marketing" and "startup marketing".
  • Make list of blogs, subscribe to RSS feeds in Feedbin:
    • Startup marketing blogs
    • Side project blogs
    • Small business marketing blogs
    • Chicago small business/startup bloggers
  • Come up with a name and domain name
@malachaifrazier
malachaifrazier / docker-destroy-all.sh
Created May 23, 2019 21:08 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@malachaifrazier
malachaifrazier / log
Created May 21, 2019 08:35
Failed docker-up
➜ dev-setup git:(first-setup) ✗ docker-compose up
Recreating dev-setup_db_1 ... done
Recreating dev-setup_api_1 ... done
Recreating dev-setup_rails_1 ... done
Attaching to dev-setup_db_1, dev-setup_api_1, dev-setup_rails_1
db_1 | LOG: skipping missing configuration file "/pgdata/data/postgresql.auto.conf"
api_1 | [gin] Listening on port 3030
db_1 | postgres: could not find the database system
db_1 | Expected to find it in the directory "/pgdata/data",
db_1 | but could not open file "/pgdata/data/global/pg_control": No such file or directory
@malachaifrazier
malachaifrazier / elasticsearch17.rb
Created May 1, 2019 04:59 — forked from rohitjangid/elasticsearch17.rb
Installing Elastic Search 1.7 via homebrew
# in the terminal run brew install elasticsearch1.7.rb
class Elasticsearch17 < Formula
desc "Distributed search & analytics engine"
homepage "https://www.elastic.co/products/elasticsearch"
url "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.6.tar.gz"
sha256 "78affc30353730ec245dad1f17de242a4ad12cf808eaa87dd878e1ca10ed77df"
revision 1
bottle :unneeded