Skip to content

Instantly share code, notes, and snippets.

View eoinkelly's full-sized avatar

Eoin Kelly eoinkelly

View GitHub Profile
@eoinkelly
eoinkelly / retheme.rb
Created July 13, 2022 20:29
Choose a random VSCode theme for your current project
#!/usr/bin/env ruby
# Purpose:
#
# * Edits .vscode/settings.json file to set a new theme for the project.
# * If no arg passed then a theme is chosen randomly.
# * You must already have the themes installed
# * You should edit the list of themes to match your favourites.
#
# Installation:
@eoinkelly
eoinkelly / lib.rb
Last active July 4, 2022 04:43
Helper scripts for testing devise-two-factor 4.x to 5.x
# common helper functions
def replace_line(file_path:, old_line_regex:, new_line:)
new_lines = File.readlines(file_path, chomp: true).map do |line|
if old_line_regex.match?(line)
new_line
else
line
end
end
@eoinkelly
eoinkelly / VS Code Extensions.txt
Created June 14, 2022 03:32
My VS Code Extensions
4ops.packer
adrianhumphreys.silverstripe
ahmadalli.vscode-nginx-conf
akamud.vscode-theme-onelight
alefragnani.rtf
aliariff.vscode-erb-beautify
andys8.jest-snippets
anotherglitchinthematrix.monochrome
anteprimorac.html-end-tag-labels
arcticicestudio.nord-visual-studio-code
#!/usr/bin/env ruby
# 1. save this somewhere on your path as 'retheme'
# 2. chmod u+x retheme
require 'json'
require 'fileutils'
THEMES = {
# shorthand-name => Actual theme name
class ThingyExporter
SQL_QUERY_PATH = Rails.root.join("app/services/thingy_exporter/query.sql")
SQL_QUERY = File.read(SQL_QUERY_PATH)
HEADERS = %w[
thingy_id
tag_id
thingy_filename
survey_question_token
tag_name
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
Rails.application.config.content_security_policy do |policy|
# These directives define a quite strict policy by default. You may have to
# loosen this policy as you add elements to the app. Some examples of common
# additions are shown below.
class SaferRawSQL
TEXT_FORMAT = 0
BINARY_FORMAT = 1
##
# You must be using the PostgreSQL database to use this method because it
# relies on PostgreSQL features.
#
# This method returns the same results as `ActiveRecord::Base.execute` but it
# helps you avoid SQL injection attacks by using the PostgreSQL feature which
# Add this to your ~/.zshrc (it only works in zsh not bash AFAIK)
# #####################################
# A fast way of chdir to a code project
function work {
cd ~/Code/repos/$1
}
function _work() {
local state

GET /numbers at log level 'debug' is 462 lines

[c23afe93-b615-4c4d-bf0a-539ea1d6928f] Started GET "/numbers/" for 127.0.0.1 at 2019-01-19 17:25:17 +1300
[c23afe93-b615-4c4d-bf0a-539ea1d6928f] Processing by PagesController#show as HTML
[c23afe93-b615-4c4d-bf0a-539ea1d6928f]   Parameters: {"slug"=>"numbers"}
[c23afe93-b615-4c4d-bf0a-539ea1d6928f]   Setting Load (1.4ms)  SELECT  "settings".* FROM "settings" WHERE "settings"."key" = $1 LIMIT $2  [["key", "footer"], ["LIMIT", 1]]
[c23afe93-b615-4c4d-bf0a-539ea1d6928f]   Page Load (11.2ms)  SELECT  "pages".* FROM "pages" WHERE "pages"."id" = $1 ORDER BY "pages"."order" ASC LIMIT $2  [["id", 11], ["LIMIT", 1]]
[c23afe93-b615-4c4d-bf0a-539ea1d6928f]   Page Load (3.2ms)  SELECT  "pages".* FROM "pages" WHERE "pages"."slug" = $1 ORDER BY "pages"."order" ASC LIMIT $2  [["slug", "numbers"], ["LIMIT", 1]]
[c23afe93-b615-4c4d-bf0a-539ea1d6928f]   Rendering pages/numbers.html.haml within layouts/application
module Part2
# 1
# 2 3 4
# 5 6 7 8 9
# A B C
# D
class State
def go_u; self; end
def go_d; self; end
def go_l; self; end