Skip to content

Instantly share code, notes, and snippets.

View johnnymo87's full-sized avatar

Jonathan Mohrbacher johnnymo87

View GitHub Profile
number name
0 Black
1 Maroon
2 Green
3 Olive
4 Navy
5 Purple
6 Teal
7 Silver
8 Grey
@johnnymo87
johnnymo87 / plan.md
Last active April 24, 2023 13:52
How I pascal-cased a bunch screaming snake case variables
  • I am a neovim user and software engineer working on a rails 6.1 ruby 2.7 application.

  • All constants in the application use the SCREAMING_SNAKE_CASE naming convention.

  • The rubocop style guide suggests that I don't have to follow this convention when the constant refers to a class. For those that refer to a class, they can be PascalCased like classes normally are in ruby.

    image
  • I'm using ripgrep, and in vim I have a plugin where I can send search queries to ripgrep via the :Rg command.

  • I've written a ripgrep query to find all instances of where a class is assigned to a SCREAMING_SNAKE_CASE constant.

:Rg "[A-Z][A-Z0-9_]+\s+=\s+[A-Z][a-z]" -g "**/*.rb"

@johnnymo87
johnnymo87 / flip_flop_yard_doc.vim
Last active April 22, 2023 18:06
Vim script that I used to flip YARDoc from Java style to Ruby style
" Fix YARD documentation comments in one file.
function! FixYardComments()
" Search for incorrect @param syntax.
let search_pattern = '@param \[\(.*\)]\s\+\(\w\+\)'
" Replace incorrect syntax with correct one.
let replace_pattern = '@param \2 \[\1\]'
" Apply the replacement to the entire file.
execute '%s/' . search_pattern . '/' . replace_pattern . '/g'
@johnnymo87
johnnymo87 / .vimrc
Created April 21, 2023 15:50
How I converted all javascript files in a codebase from amd imports to commonjs
function! ReplaceRequireJS()
StripTrailingWhitespaces
normal gg
call search(')')
let @e= line('.')
call MaybeAddNewLineBelow()
call PrependModuleExports()
normal gg
normal @eJ
normal ^"aD
@johnnymo87
johnnymo87 / chatgpt-flyway-advice.md
Last active February 3, 2023 03:41
ChatGPT flyway advice

Prompt

Help me use flyway in python to define a postgresql schema for a coffee tasting application.

Response

Flyway is a database migration tool primarily designed for Java applications. It can also be used with other programming languages including Python, but requires a separate Flyway CLI component to be installed. To use Flyway in Python, you would need to write SQL scripts to define your database schema and manage its evolution over time.

Here's a simple example of how you could use Flyway to define a schema for a coffee tasting application:

  1. Install Flyway CLI: You can download the latest version of the Flyway CLI from the official Flyway website (https://flywaydb.org/).
@johnnymo87
johnnymo87 / auto-unit-cycle.diff
Created November 13, 2016 16:22
Expose 'Auto Unit Cycle' option in the UI
From 04157d2e3825baf4793e454076ffa0a12765bf6e Mon Sep 17 00:00:00 2001
From: johnnymo87 <[email protected]>
Date: Sun, 13 Nov 2016 16:14:16 +0000
Subject: [PATCH] Expose 'Auto Unit Cycle' option in the UI
---
Text/en_US/FrontEndText.xml | 3 +++
UI/Options.lua | 5 +++++
UI/Options.xml | 4 ++++
3 files changed, 12 insertions(+)
@johnnymo87
johnnymo87 / gist:1becb9c35216fa891b04d7f567bf34ad
Created July 27, 2016 00:29
SQL Server on Mac via virtualization
SQL Server on Mac via virtualization
Goal: I want to be able to spin up generic instances of sql server on-demand
Assumptions:
* [Windows Server 2016 Technical Preview (Core) is installed on virtualbox](http://ezeeetm.github.io/Docker-Engine-for-Windows-Server-Walkthrough/)
* Typical defaults: 4096MB RAM, 32 GB fixed space
* The image name is "sql server"
* The network is "bridged adapter"
* Guest additions are installed via `D:\VBoxWindowsAdditions.exe`
module ExercisesSpec where
import Test.Hspec
import Test.QuickCheck
import Control.Exception (evaluate)
import Exercises
main :: IO ()
main = hspec $ do
require 'spec_helper'
describe 'WITH RECURSIVE' do
# http://www.postgresql.org/docs/8.4/static/queries-with.html
# http://www.cybertec.at/common-mistakes-union-vs-union-all/
def query(n)
ActiveRecord::Base.connection.exec_query(
<<-SQL
M-D to D-M
:%s:\(\d\{1,2}/\)\(\d\{1,2}/\):\2\1:g
Discard all but the last 4 digits
::%s:\v.*(\d{4}):\1:g