Skip to content

Instantly share code, notes, and snippets.

@abrom
abrom / jenkins_log_extractor
Created June 9, 2020 06:12
Ruby script to extract logs for a specific Jenkins node
#!/usr/bin/ruby
## Jenkins log extractor
#
# Script iterates over the Jenkins log index file searching for log offsets matching the specified node ID.
# When a match is found the specified portion of the interleaved Jenkins log is streamed to STDOUT
#
# Example usage:
# jenkins_log_splitter /var/lib/jenkins/jobs/my_job/master/build/7/log 123
#
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# gem "rails", github: "rails/rails", branch: 'v6.0.2.2'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://github.com/CreateJS/EaselJS/releases/download/0.8.1/easeljs-0.8.1.min.js"></script>
</head>
<body style="display: flex">
<canvas id="canvas" width='800' height='800' style="border: 1px solid black; display: inline-block"></canvas>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body style="display: flex">
<canvas id="canvas" width='800' height='800' style="border: 1px solid black; display: inline-block"></canvas>
<div id="log" style="border: 1px solid green; width: 800px; height: 800px; display: inline-block; overflow: hidden"></div>
@abrom
abrom / config.ru
Last active March 30, 2022 07:43
Address CVE-2015-9284 for generic Rack apps (eg Sinatra) for Omniauth
require 'omniauth/strategies/<your strategy>'
require_relative 'omniauth_authenticity_checker'
OmniAuth.config.allowed_request_methods = [:post]
OmniAuth.config.before_request_phase = OmniauthAuthenticityChecker.new(reaction: :drop_session)
# And if you haven't already, you should be loading in the `Rack::Protection` middleware:
use Rack::Protection, reaction: :drop_session, use: :authenticity_token
# frozen_string_literal: true
require 'securerandom'
$test_db_name = "test_#{SecureRandom.rand(10_000)}.db"
puts "Using #{$test_db_name} database"
# Let's make sure it definitely doesn't exist
File.delete $test_db_name if File.exist? $test_db_name
@abrom
abrom / test.rb
Created January 31, 2018 03:14
PT 4 -> PT 5+ serialized attributes problem
# frozen_string_literal: true
require 'securerandom'
$test_db_name = "test_#{SecureRandom.rand(10_000)}.db"
puts "Using #{$test_db_name} database"
# Let's make sure it definitely doesn't exist
File.delete $test_db_name if File.exist? $test_db_name