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 / gemspec.sh
Last active September 15, 2023 21:55 — forked from smileart/gemspec.sh
gemspec cli tools
# deps and their versions in gemspec
cat name.gemspec | ag -o '(?<=dependency).*(?<=[<>=]\s)(?>\d+\.?\d+)' | tr -d "',><=~"
# deps and their version on RubyGems
cat british.gemspec | ag -o '(?<=dependency).*(?<=[<>=]\s)(?>\d+\.?\d+)' | tr -d "',><=~" | awk '{ print $1 }' | xargs gem info -r | ag '\(\d+\.\d+\.\d+\)'
# gemspec and current remote versions side-by-side
paste <(cat $(ls | ag gemspec) | ag -o '(?<=dependency).*(?<=[<>=]\s)(?>\d+\.?\d+)' | tr -d "',><=~") <(cat $(ls | ag gemspec) | ag -o '(?<=dependency).*(?<=[<>=]\s)(?>\d+\.?\d+)' | tr -d "',><=~" | awk '{ print $1 }' | xargs gem info -r | ag -o '(?<=\()(\d+\.\d+\.\d+)(?!>\))')
@collindonnell
collindonnell / multichat.rb
Created July 15, 2023 02:42
Simple Ruby TCP multi-user chat room
#!/usr/bin/env ruby
# frozen_string_literal: true
require "socket"
class Connection
def initialize(client:, server:)
@client = client
@server = server
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
@andrewmcodes
andrewmcodes / README.md
Created December 16, 2021 04:03
Rebase Feature Branch Against Main

Starting on the feature branch:

git checkout main
git pull
git checkout -
git pull --rebase origin main
git push -f
require 'nokogiri'
require 'zlib'
require 'open-uri'
require 'net/http'
require 'net/https'
=begin
To get up and running on local:
git clone git@bitbucket.org:mphteam/list-hub.git
change directories to list-hub (cd list-hub)
@smileart
smileart / gemspec.sh
Last active September 15, 2023 21:50
gemspec cli tools
# deps and their versions in gemspec
cat name.gemspec | ack -o '(?<=dependency).*(?<=[<>=]\s)(?>\d+\.?\d+)' | tr -d "',><=~"
# deps and their version on RubyGems
cat british.gemspec | ack -o '(?<=dependency).*(?<=[<>=]\s)(?>\d+\.?\d+)' | tr -d "',><=~" | awk '{ print $1 }' | xargs gem info -r | ack '\(\d+\.\d+\.\d+\)'
# gemspec and current remote versions side-by-side
paste <(cat $(ls | ack gemspec) | ack -o '(?<=dependency).*(?<=[<>=]\s)(?>\d+\.?\d+)' | tr -d "',><=~") <(cat $(ls | ack gemspec) | ack -o '(?<=dependency).*(?<=[<>=]\s)(?>\d+\.?\d+)' | tr -d "',><=~" | awk '{ print $1 }' | xargs gem info -r | ack -o '(?<=\()(\d+\.\d+\.\d+)(?!>\))')
@kcsluis
kcsluis / uscities.csv
Created August 9, 2019 18:00
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
@bazzel
bazzel / README.md
Last active May 26, 2021 04:20
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 expose-loader
@CodyFitzpatrick
CodyFitzpatrick / seeds_with_sql_import.rb
Last active November 14, 2022 11:17
Ruby on Rails - Import Data via SQL in seeds.rb
# Creation of other records in Ruby above ...
connection = ActiveRecord::Base.connection
sql = File.read('db/import.sql') # Change path and filename as necessary
statements = sql.split(/;$/)
statements.pop
ActiveRecord::Base.transaction do
statements.each do |statement|
# This file was generated by the `rails generate rspec:install` command.
# Conventionally, all specs live under a `spec` directory, which RSpec adds to
# the `$LOAD_PATH`. The generated `.rspec` file contains `--require spec_helper`
# which will cause this file to always be loaded, without a need to explicitly
# require it in any files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, consider making