Skip to content

Instantly share code, notes, and snippets.

@kyletolle
kyletolle / filesDeleted.js
Created December 18, 2023 20:19
Github PR review: Snippet to check viewed on files renamed without changes or deleted
// In a GitHub PR, you can run this script in a console to help automatically click the Viewed checkbox
// Worked as of 2023.12.18
// JS snippet to click 'Viewed' on files that were deleted entirely, not changed or renamed
Array.from(document.querySelectorAll('.js-diff-load')).forEach(fileInfo => {
const text = fileInfo.nextElementSibling.textContent.trim();
if(text.includes('This file was deleted.')) {
const viewedCheckbox = fileInfo.closest('.js-file.js-details-container').querySelector('.js-reviewed-checkbox');
if(viewedCheckbox && !viewedCheckbox.checked) {
viewedCheckbox.click();
}
@kyletolle
kyletolle / node-http-post-listener.js
Created September 11, 2013 22:56
A simple http server that listens for POST events at port 9000 and will print out the data it receives. Tweak the statusCode if you want to return something else like 500. This is useful for setting up as the url for a webhook and viewing/verifying the data that gets sent to that URL.
var app = require('http').createServer(handler);
var statusCode = 200;
app.listen(9000);
function handler (req, res) {
var data = '';
if (req.method == "POST") {
req.on('data', function(chunk) {
@kyletolle
kyletolle / form.update-parsed.txt
Last active January 31, 2020 06:23
form.update sample event payload for Fulcrum Webhooks
{
id: "dfb667fb-f192-4d6d-8794-e89ece5db6ed",
type: "form.update",
owner_id: "00053caf-4b6e-4c86-88b6-64695895dffe",
data: {
name: "Intersections",
description: "Intersection in the city of Colorado Springs.",
bounding_box: null,
record_title_key: "94f8",
status_field: { },
global.helloWorldText = 'Hello, world!';
helloWorld = function() {
console.log(global.helloWorldText);
return global.helloWorldText;
};
helloWorld();
@kyletolle
kyletolle / deep_each.rb
Last active February 19, 2019 18:55
deep_each.rb - a multidimensional each for Ruby
two_d_grid =
[
[ 1, 2, 3, 4, 5 ],
[ 6, 7, 8, 9, 10 ],
[ 11, 12, 13, 14, 15]
]
puts "Basic 2D each"
two_d_grid.each do |row|
row.each do |cell|
@kyletolle
kyletolle / alias_method_matcher.rb
Last active January 19, 2016 21:02
RSpec alias_method matcher
# spec/support/matchers/alias_method_matcher.rb
# RSpec matcher for alias_method.
# Orignal idea borrowed from: https://gist.github.com/1950961
# Usage:
#
# describe Boomerang do
# let(:boomerang) { described_class.new }
# let(:subject} { boomerang }
# it { is_expected.to alias_method(:in_flight?).to(:in_air?) }
@kyletolle
kyletolle / alleys.geojson
Created January 24, 2014 15:19
States and Alleys
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kyletolle
kyletolle / README.md
Created January 23, 2014 17:02
US States Colored by Name Length
@kyletolle
kyletolle / README.md
Created January 22, 2014 05:06
US States Colored by Name Length
@kyletolle
kyletolle / no_side_effects.rb
Created October 24, 2013 23:46
Which method of internal processing looks or feels best? Were the internal methods used have side effects, or no?
def Cherry
def initialize(cherry)
@cherry = cherry
end
def process
@cherry = remove_pit(@cherry)
@cherry = twist_stem(@cherry)
end