Skip to content

Instantly share code, notes, and snippets.

View eoinkelly's full-sized avatar

Eoin Kelly eoinkelly

View GitHub Profile
@eoinkelly
eoinkelly / css-animation-specs.js
Last active March 9, 2024 13:37
Test CSS Animations in Ember with Mocha & Chai
// TODO:
// * work with all browser prefixes for event names
// * make error message more helpful
it('tests that a CSS animation ran correctly', function (done) { // <-- notice the done param
// Visit whatever route we are going to test
visit('/unique_testing_route')
.then(function () {
# 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.
@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
@eoinkelly
eoinkelly / visualize-stacking-contexts.js
Last active February 7, 2021 08:04
Some console output to help you visualise stacking contexts on a page
/*
Usage:
* Paste this into your dev tools console (or even better as a snippet)
* It will parse the page and find all the things that create a new stacking context
and dump some info about them to the console. It will also outline them on the page.
* This is pretty rough and probably misses heaps of bugs and edge cases.
*/
@eoinkelly
eoinkelly / tinymce_fill_in.rb
Created September 9, 2014 23:53
A capybara helper to fill in text into a TinyMCE editor instance
##
# id must be the id attribute of the editor instance (without the #) e.g.
# <textarea id="foo" ...></textarea>
# would be filled in by calling
# tinymce_fill_in 'foo', 'some stuff'
#
def tinymce_fill_in(id, val)
# wait until the TinyMCE editor instance is ready. This is required for cases
# where the editor is loaded via XHR.
sleep 0.5 until page.evaluate_script("tinyMCE.get('#{id}') !== null")
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