Skip to content

Instantly share code, notes, and snippets.

Avatar

Scott Watermasysk scottwater

View GitHub Profile
@scottwater
scottwater / page.htm
Created Mar 16, 2021
Setting the email address based on a query string
View page.htm
<script>
document.addEventListener("DOMContentLoaded", () => {
const url = new URL(window.location)
const email = url.searchParams.get("email_address")
if (email) {
document.querySelectorAll("input[type='email']").forEach((el) => el.value = email);
}
});
</script>
@scottwater
scottwater / kol_form_email.js
Created Feb 25, 2021
For those who cannot use standard input types. We recommend using type=email and type=tel
View kol_form_email.js
window.kolOptions = {
form: {
mappings: {
email: {
selector: "input[name='you_custom_selector']"
}
}
}
};
@scottwater
scottwater / fly_graphql.rb
Created Feb 9, 2021
FlyGraphql For Domains
View fly_graphql.rb
class FlyGraphql
include HTTParty
debug_output $stderr if Rails.env.development?
base_uri "api.fly.io:443/graphql"
headers "Authorization" => "Bearer #{ENV["FLY_API_KEY"]}"
format :json
attr_reader :app_id
class FlyGraphqlError < StandardError
def initialize(message = "Error in FlyGraphql")
@scottwater
scottwater / code.rb
Last active Dec 2, 2020
2020 Advent of Code Day 2
View code.rb
unless RUBY_VERSION.start_with?("2.7")
puts "Please use Ruby 2.7.x"
return
end
data = File.open("input.txt").map { |line|
parts = line.split(" ")
p1, p2 = parts[0].split("-").map(&:to_i)
{
p1: p1,
@scottwater
scottwater / day1.rb
Created Dec 2, 2020
Day1 Advent Code Ruby
View day1.rb
numbers = File.open("input.txt").map(&:to_i)
combinations = ENV.fetch("COMBOS", 2).to_i
puts numbers
.combination(combinations)
.find { |pair| pair.sum == 2020 }
.reduce(:*)
@scottwater
scottwater / test.js
Created Apr 10, 2020
Restripe a Table's Rows
View test.js
reStripe() {
const rows = [...document.getElementsByClassName("archive-row")];
rows.forEach((element, index) => {
if (index % 2 == 0) {
element.classList.remove("bg-gray-50");
element.classList.add("bg-white");
} else {
element.classList.add("bg-gray-50");
element.classList.remove("bg-white");
}
@scottwater
scottwater / lb.html
Created Nov 4, 2019
Leaderboard Limit Override
View lb.html
<script>
window.kol_leader_board_options = {
board_settings: {
limit: 100
}
}
</script>
@scottwater
scottwater / pageData.js
Created Oct 17, 2019
See what data is available on a page in Eleventy
View pageData.js
eleventyConfig.addNunjucksTag("pageData", function(nunjucksEngine) {
return new (function() {
this.tags = ["pageData"];
this.parse = function(parser, nodes, _) {
var tok = parser.nextToken();
var args = parser.parseSignature(null, true);
// fake it until you make it!
// https://github.com/mozilla/nunjucks/issues/158#issuecomment-34919343
@scottwater
scottwater / base_webhook.json
Last active Oct 3, 2020
KickoffLabs WebHooks
View base_webhook.json
{
"__event": "the_webhook_event",
"avatar": "https://d1ts43dypk8bqh.cloudfront.net/v1/avatars/310c4ac2-7026-4700-afde-496b1d217b03",
"counter": 252,
"contest_score": 300,
"contest_score_rank": 19588,
"custom_fields": {
},
"email": "scott@kickofflabs.com",
@scottwater
scottwater / tailwind.config.js
Created Sep 13, 2019
Nord color palette in Tailwind
View tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
nord: {
"0": "#2E3440",
"1": "#3B4252",
"2": "#434C5E",
"3": "#4C566A",
"4": "#D8DEE9",