Skip to content

Instantly share code, notes, and snippets.

@blasterpal
blasterpal / elastic_apm_sidekiq_error.txt
Created Jul 2, 2020
Elastic APM Gem error related to Sidekiq when running Rails console or Rails server.
View elastic_apm_sidekiq_error.txt
# To prevent:
# ENV['ELASTIC_APM_DISABLE_INSTRUMENTATIONS'] = "json,sidekiq"
[DEPRECATED] The option active has been renamed to enabled to align with other agents and with the remote config.
Traceback (most recent call last):
99: from bin/rails:10:in `<main>'
98: from /Users/hbeaver/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
97: from /Users/hbeaver/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
96: from /Users/hbeaver/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
95: from /Users/hbeaver/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
View sandbox_ecs_task_role_secrets_test.js
// NODE_ENV=production node inspect dist/server.js
var AWS = require('aws-sdk');
var secretsmanager = new AWS.SecretsManager();
console.log(secretsmanager.config);
var params = {
SecretId: process.env.DOCUMENT_API_KEY
};
secretsmanager.getSecretValue(params, function(err, data) {
View example_graylog_regex.txt
source:atldockerhaproxy* AND time_backend_response:/[6-9][0-9][0-9][0-9][0-9]/ AND request_header_host:/s.*enable.*/
@blasterpal
blasterpal / test_secrets_aws.js
Created Apr 6, 2020
Test JS Secret in Node
View test_secrets_aws.js
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: process.env.AWS_REGION
});
var secretsmanager = new AWS.SecretsManager();
@blasterpal
blasterpal / sed_print_matched_group.sh
Last active Apr 21, 2020
Print a matched group from a file using sed
View sed_print_matched_group.sh
cat graylog-search-result-relative-604800.csv | while read line
do
echo $line | sed -n -r 's/.*db":([0-9]*\.[0-9]*).*/\1/p'
done
cat graylog-search-result-keyword-since-april3.csv | while read line
do
echo $line | sed -n -r 's/.*email":"([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,})",.*/\1/pi'
done
View enc-dec-crypto-example.js
/ Encrypt
const ciphertext = CryptoJS.AES.encrypt('a8f0840ce2388', process.env.JWT_SECRET);
console.log('ciphertext', ciphertext.toString());
// // Decrypt
const plaintext = CryptoJS.AES.decrypt(ciphertext.toString(), process.env.JWT_SECRET).toString(CryptoJS.enc.Utf8);
console.log('plaintext', plaintext);
@blasterpal
blasterpal / gh_audit_parsing_report.rb
Created Apr 24, 2018
Ruby script to parse GH audit download
View gh_audit_parsing_report.rb
require 'json'
require 'pry'
require 'active_support'
require 'date'
require 'csv'
class GHAudit
def initialize
@file = File.open('./gh_audit.json','r')
@blasterpal
blasterpal / com.hankbeaver.dockerformacloopback.plist
Created May 11, 2017
Docker For Mac Loopback adapter MacOS LaunchAgent script
View com.hankbeaver.dockerformacloopback.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.hankbeaver.DockerForMacLoopBack</string>
<key>ProgramArguments</key>
<array>
<string>/System/Library/CoreServices/Spotlight.app/Contents/MacOS/Spotlight</string>
</array>
@blasterpal
blasterpal / bigquery_semantic_gh_metadata.rb
Last active Apr 30, 2017
Script to merge results from BigQuery Github Dataset with GitHub meta data
View bigquery_semantic_gh_metadata.rb
#Gemfile contents
source "https://rubygems.org"
gem 'octokit'
gem "pry"
# END Gemfile
require 'rubygems'
require 'bundler/setup'
require 'octokit'
require 'csv'
@blasterpal
blasterpal / bigquery_semantic_distinct.sql
Created Apr 30, 2017
BigQuery Github Semantic UI Temp Table DISTINCT/GROUP BY Query
View bigquery_semantic_distinct.sql
SELECT sample_repo_name from [bigquery-semantic-ui-work:semantic_ui_bigquery_fun.semantic_all_repo_results] GROUP BY sample_repo_name