Skip to content

Instantly share code, notes, and snippets.

@fallwith
fallwith / obfus.rb
Created August 21, 2024 03:49
SQL Obfuscation While Exempting Comments Proof of Concept
#!/usr/bin/env ruby
# frozen_string_literal: true
statements = [{ input: 'SELECT this FROM there WHERE userId = 123 AND roleId = 456 LIMIT 11',
expected: 'SELECT this FROM there WHERE userId = ? AND roleId = ? LIMIT ?' },
{ input: "SELECT this FROM there WHERE userId = 123 AND roleId = 456 LIMIT 11\n-- Linking id: 867",
expected: "SELECT this FROM there WHERE userId = ? AND roleId = ? LIMIT ?\n-- Linking id: 867" },
{ input: "SELECT this FROM there WHERE userId = 123 /* linking id:\n867 */ AND roleId = 456 LIMIT 11",
expected: "SELECT this FROM there WHERE userId = ? /* linking id:\n867 */ AND roleId = ? LIMIT ?" }]
@fallwith
fallwith / span_events.rb
Created April 19, 2024 23:44
Use the New Relic Ruby agent to report 10,000 spans within a minute
#!/usr/bin/env ruby
# frozen_string_literal: true
# Instructions:
# 1. Copy a valid newrelic.yml file to the same directory as span_events.rb
# 2. Make sure at least the following parameters are set in newrelic.yml:
# - license_key: <your license key>
# - audit_log.enabled: true
# - span_events.max_samples_stored: 10000
# 3. ruby span_events.rb
@fallwith
fallwith / README.md
Last active May 15, 2024 21:41
Beta test instructions for observing Ruby based AWS Lambda functions with New Relic

NOTE - Ruby is now fully supported and out of beta

New Relic's support for Ruby AWS Lambda functions is now out of beta and the instructions below should be considered out of date. Please see the official documentation for instructions on instrumenting your Lambda functions. When using the New Relic Lambda CLI tool, everything is automated. When manually introducing New Relic to your Lambda functions, please use one of the official New Relic Lambda layers instead of the .zip files contained in these beta test instructions.

Beta test instructions for observing Ruby based AWS Lambda functions with New Relic

Synopsis

These instructions will explain how to enhance an existing Ruby based AWS Lambda function to have it observed by New Relic.

@fallwith
fallwith / Gemfile
Created February 28, 2024 10:21
New Relic with Resque Demonstration
# frozen_string_literal: true
source 'https://rubygems.org'
gem 'resque', '1.27.4'
gem 'newrelic_rpm'
@fallwith
fallwith / fake_server.rb
Created February 8, 2024 22:35
A "fake" HTTP server for local development or testing of HTTP clients
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'webrick'
class FakeServlet < WEBrick::HTTPServlet::AbstractServlet
RESPONSE_BODY = "Success\n"
TEXT_PLAIN = 'text/plain'
def do_GET(_request, response)
@fallwith
fallwith / steam_deck_rclone.md
Last active December 28, 2023 09:08
Setting up Rclone on Steam Deck to upload screenshots to Dropbox

Setting up Rclone on Steam Deck to upload screenshots to Dropbox

Launch Konsole and install Neovim and Rclone:

NOTE: Neovim is optional and only used here for editing your ~/.bashrc script

mkdir -p ~/bin
mkdir -p ~/scratch
@fallwith
fallwith / standalone.rb
Created November 14, 2023 17:18
Standalone New Relic Ruby agent demonstration
#!/usr/bin/env ruby
# frozen_string_literal: true
# Instructions:
# 1. Copy newrelic.yml with a valid license key to the same directory as
# standalone.rb
# 1. rm -rf log
# 2. ruby standalone.rb
# 3. inspect log/newrelic_agent.log
  • A Short Hike (Nintendo Switch) [2019]
  • Alien Carnage (originally Halloween Harry) (PC) [1993]
  • Assassin's Creed II (PS3) [2009]
  • Assassin's Creed IV (PC) [2013]
  • Choplifter (Sega Master System) [1986]
  • Baldur’s Gate II (PC) [2000]
  • Baldur's Gate III (PC) [2023]
  • Below the Root (PC) [1984]
  • Borderlands (PC) [2009]
  • Burnout 3 (PS2) [2004]
@fallwith
fallwith / test.rb
Created July 19, 2023 17:12
New Relic Ruby agent demonstration of the notice_error API inside a transaction
#!/usr/bin/env ruby
# frozen_string_literal: true
# INSTRUCTIONS:
# - Place this file somewhere. It can be called something like `test.rb`
#
# - Either place a newrelic.yml file in the same directory as this file OR
# export the NEW_RELIC_LICENSE_KEY environment variable. For a
# non-production host, also export the NEW_RELIC_HOST environment variable.
#
@fallwith
fallwith / new_relic_ruby_agent_with_sidekiq.md
Last active July 14, 2023 19:30
New Relic Ruby agent Sidekiq demonatration

New Relic Ruby agent Sidekiq demonstration

This guide will demonstrate using the New Relic Ruby agent to report metrics for Sidekiq jobs being performed by workers. A minimal Ruby on Rails app with a minimal Sidekiq job class will be created.

Prerequisites

required

  • Ruby