Skip to content

Instantly share code, notes, and snippets.

View shadowbq's full-sized avatar
👔
Doing Things

shadowbq shadowbq

👔
Doing Things
View GitHub Profile
@shadowbq
shadowbq / cdn-reverse-check.rb
Last active January 2, 2021 06:08
Check if reverse dns lookup matches a known CDN. (used for unblocking in blacklists)
#/usr/bin/env ruby
# github/shadowbq - 2014
# GNU GENERAL PUBLIC LICENSE Version 2, June 1991
# Things to match..
# CDN List provided by - (23 Dec 2014) https://github.com/WPO-Foundation/webpagetest/blob/master/agent/wpthook/cdn.h
require 'rubygems'
require 'net/dns'
@shadowbq
shadowbq / test-deps-barnyard2-mysql-freebsd-9.3.rb
Created January 26, 2015 16:42
Dependency test for Barnyard2 compiled on FreeBSD 9.3 with MySQL
#!/usr/bin/env ruby
## Barnyard2 compiled on FreeBSD 9.3 with MySQL
filelist = %w{ /usr/local/lib/mysql/libmysqlclient.so.18 /lib/libz.so.6 /lib/libpcap.so.8 /lib/libm.so.5 /lib/libc.so.7 /usr/lib/libstdc++.so.6 /lib/libgcc_s.so.1 /lib/libthr.so.3}
require 'fileutils'
filelist.each do |libso|
puts "Missing: #{libso}" unless File.file?(libso)
end
puts "done."
@shadowbq
shadowbq / .gitignore
Last active August 29, 2015 14:14 — forked from cehoffman/.gitignore
SSHGuard => sshguard-dump sshguard-reprieve
build/
Makefile
sshguard-prefix/
CMakeFiles
CMakeCache.txt
cmake_install.cmake
@shadowbq
shadowbq / CheckExif.sh
Last active August 29, 2015 14:14
Zenity (Gnome) Shell popup to show Exif data or Hash files
#!/bin/bash
AppVer="1.0.1-shadowbq"
if [ "$1" = "" ]; then
SelectedFile=`zenity --title="Choose a file to check" --file-selection`
fi
if [ "$SelectedFile" = "" ]; then
if [ $# -gt 1 ]; then
@shadowbq
shadowbq / barnyard_waldo.rb
Created May 14, 2015 20:23
Print the struct data from the barnyard waldo file
#!/usr/bin/env ruby
#
# $> ./barnyard_waldo.rb
# Barnyard spool: /var/log/snort/merged.log.1431634445
# 2015-05-14 20:14:05 +0000
# Notes:
# Ruby String #unpack
# V | Integer | 32-bit unsigned, VAX (little-endian) byte order
@shadowbq
shadowbq / gem_hunt.sh
Created May 23, 2015 15:54
find shebangs that are explict .. and likely wrong.
#!/usr/bin/env bash
#
# Find FreeBSD gems that are hardcoded to a ruby minor version
# example: /usr/local/bin/ruby20
find /usr/local/bin/ -type f | xargs file | grep Ruby | awk 'BEGIN { FS = ":" }; { print $1 }' |xargs head -1
@shadowbq
shadowbq / restart_worker.rb
Last active August 29, 2015 14:24
find and kill all old worker.rb and restart in context
#!/bin/sh
# Ubuntu tested 14.04.2
# root@downloader:/usr/local/www/ydl# ps -U www-data -u www-data ajf |grep 'worker.rb' |grep -v 'grep'
# 1 10193 10185 1320 pts/0 10440 Sl 33 0:00 ruby ./worker.rb
# 1 10163 10155 1320 pts/0 10440 Sl 33 0:00 ruby ./worker.rb
echo 'killing old proc'
ps -U www-data -u www-data ajf |grep 'worker.rb' |grep -v grep | awk -F ' ' '{print $3}'| xargs -I {} kill -9 -{}
echo 'starting worker'
sudo -u www-data sh -c 'nohup ./worker.rb >> logs/worker.log &'
@shadowbq
shadowbq / GITHUB-SUBMODULE-PR-README.md
Created July 16, 2015 15:25
Adding a submodule to existing 3rd party repo via pull request

Fork the hack-night (https://github.com/rubyloco/hack-night.git) on github to your account (ala https://github.com/shadowbq/hack-night.git)

Using the shell download your clone, create/switch to your topic branch, add your submodule, commit it, push it to your account.

git clone https://github.com/shadowbq/hack-night.git
cd hack-night/
git remote add upstream https://github.com/rubyloco/hack-night.git
git fetch upstream
git checkout -b shadowbq-loco-flag upstream/master
require 'rubygems'
require 'sqlite3'
require 'rest-assured'
require 'pry'
RestAssured::Server.start(port: 7899)
@double = RestAssured::Double.create(:fullpath => '/some/api')
@double = RestAssured::Double.create(:fullpath => '/some/api2', :response_headers => { 'Content-Type2' => 'text/html' })
@shadowbq
shadowbq / app.rb
Last active December 10, 2015 18:49
Email Backtraces if an exception occurs in Production, else just show the user..
require 'bundler' # gem requires
Bundler.require(:default, ENV['RACK_ENV'].to_sym) # only loads environment specific gems
if ENV['RACK_ENV'] == 'production' # production config / requires
require './lib/middleware/exceptionmailer'
use Rack::ExceptionMailer,
:to => ['[email protected]'],
:from => '[email protected]',
:subject => 'Error Occurred on Rack Application'