Skip to content

Instantly share code, notes, and snippets.

View covard's full-sized avatar
💾

Curtis Ovard covard

💾
  • Salt Lake City, Utah
View GitHub Profile
@covard
covard / ruby_file_modes.md
Last active May 3, 2022 16:30
Ruby file open modes

File Open Modes

Mode |  Meaning
-----+--------------------------------------------------------
"r"  |  Read-only, starts at beginning of file  (default mode).
-----+--------------------------------------------------------
"r+" |  Read-write, starts at beginning of file.
-----+--------------------------------------------------------
"w"  |  Write-only, truncates existing file
@covard
covard / homebrew_node_version.md
Last active February 8, 2022 17:32
homebrew changing versions of node

Because node gets updated when updating homebrew or installing a brew, and it can cause issues with yarn. One example of the error at the bottom.

Node version 10 works with this issue of node-sass 17 and 16 had issues.

$ node -v
$ brew unlink node
$ brew install node@10
$ brew link --overwrite node@10
@covard
covard / base64_info.md
Last active May 19, 2022 16:28
Base64 Info - file, ruby, open, modes

Base64 Info

Encode PDF and Write PDF

base64_data = Base64.encode64(File.open('/Users/covard/Documents/dummy.pdf').read)

file = File.open('/Users/covard/Desktop/test.pdf', 'wb')

file.write(Base64.decode64(base64_data))
@covard
covard / list_running_commands_clean.md
Created December 2, 2021 15:47
Clean output of ps command

PS Command

DarkLord™ - 🔥 ~ 🔥 $ ps -A | ag [f]irefox | awk '{print $1 " "  $4}'
80258 /Applications/Firefox.app/Contents/MacOS/firefox
80280 /Applications/Firefox.app/Contents/MacOS/plugin-container.app/Contents/MacOS/plugin-container
80295 /Applications/Firefox.app/Contents/MacOS/plugin-container.app/Contents/MacOS/plugin-container
80305 /Applications/Firefox.app/Contents/MacOS/plugin-container.app/Contents/MacOS/plugin-container
80306 /Applications/Firefox.app/Contents/MacOS/plugin-container.app/Contents/MacOS/plugin-container
@covard
covard / rails_mysql_json.md
Last active December 13, 2022 18:28
Rails MySQL query json column

Rails, MySQL, and JSON


Query a JSON attribute / column

Given a model named Preference and that model has a json column named settings.

example data

@covard
covard / vim_vi_tips.md
Created June 4, 2021 16:52
VIM/VI Tips

VIM Tips

Pasting into VIM/VI

before pasting

:set paste
@covard
covard / sidekiq_info.md
Last active January 24, 2022 22:13
General sidekiq info

Sidekiq


Retries

Get Error Message

retries = Sidekiq::RetrySet.new
@covard
covard / mysql_ssl_install_issue.md
Last active May 6, 2021 20:25
This is how to fix issue with installing mysql, with some issue with openssl. Thanks to https://github.com/spenhappenin for finding a way around. Credit where credit is due.

MySQL Gem Install error

If this error keeps happening and will not install by manually installing gem install mysql2. Try the fix below.

An error occurred while installing mysql2 (0.5.1) , and bundler cannot continue.

Fix

@covard
covard / grep.md
Created April 2, 2021 18:09
Grep Helpers

Grep

How to grep for text in a dir

$ grep -Ril "was not sent an invitation" /Users/me/src/cool_app/app/
@covard
covard / ruby_array_group.md
Last active March 1, 2021 21:49
Ruby array group / count same value to hash

Array Group By Same Value

2.7.1 :001 > [1, 2, 3, 4, 5, 6, 6, 5, 7, 8, 9, 0].group_by(&:itself).map { |k, v| [k, v.count] }.to_h
=> {1=>1, 2=>1, 3=>1, 4=>1, 5=>2, 6=>2, 7=>1, 8=>1, 9=>1, 0=>1}