Skip to content

Instantly share code, notes, and snippets.

View picatz's full-sized avatar
Graph Theory

Kent Gruber picatz

Graph Theory
View GitHub Profile
@picatz
picatz / mongo_mauler_v1.rb
Created January 4, 2017 01:43
Writing another article. Following this mongo DB hype 'yo.
require 'mongo'
require 'trollop'
require 'colorize'
foo = ARGV[0] || ARGV[0] = '-h'
opts = Trollop::options do
banner "Mongo Mauler".red.blue + " | " + "NoSQL? No Problem!".white.bold
version "Mongo Mauler v 1.0"
opt :ip, "Specify a host ip address to work with", :type => :string, :default => '127.0.0.1'
require 'mongo' # must have this to work
def connect_to_db(args={})
ip = args[:ip] || '127.0.0.1'
port = args[:port].to_s || '27017'
begin
client = Mongo::Client.new(["#{ip}:#{port}"])
rescue Mongo::Auth::Unauthorized, Mongo::Error => e
puts "Error #{e.class}: #{e.message}"
require 'sinatra'
require 'pi_charts'
def bake_pie
chart = PiCharts::Pie.new
chart.add_dataset(label: "cats", data: 80)
chart.add_dataset(label: "dogs", data: 50)
chart.hover
chart.responsive
"<head>" + chart.cdn + "</head>" + "<body>" + chart.html(width: 60) + "</body>"
var chartInstance = new Chart(ctx, {
type: 'line',
data: data,
options: {
responsive: false
}
});
require "pi_charts"
# create a new line chart
chart = PiCharts::Line.new
# add labels ( x values )
chart.add_labels(["January", "February", "March", "April", "May"])
# add datasets
chart.add_dataset(label: "cats", data: [3, 1, 3, 3, 7])
require "pi_charts"
# create a new line chart
chart = PiCharts::Bar.new
# add labels ( x values )
chart.add_labels(["January", "February", "March", "April", "May"])
# add datasets
chart.add_dataset(label: "cats", data: [ 2, 0, 4, 7, 3 ])
@picatz
picatz / basic_socket_usage.rb
Created April 14, 2017 19:23
Violent Ruby: Banner Grabber - Basic Socket Usage
# coding: utf-8
# Basic socket usage to grab a banner.
# @author Kent 'picat' Gruber
require 'socket'
# Grab the banner of a given +ip+ address and +port+
# to attempt to connect to.
#
# @param ip [String] Target IP address.
@picatz
picatz / basic_socket_usage_with_rescue.rb
Created April 14, 2017 19:37
Violent Ruby: Banner Grabber - Basic Socket Usage with Rescue
# coding: utf-8
# Basic socket usage to grab a banner.
# @author Kent 'picat' Gruber
require 'socket'
# Grab the banner of a given +ip+ address and +port+
# to attempt to connect to.
#
# @param ip [String] Target IP address.
@picatz
picatz / basic_socket_usage_with_port_range.rb
Created April 14, 2017 19:48
Violent Ruby: Banner Grabber - Basic Socket Usage with Port Range
# coding: utf-8
# Basic socket usage to grab a banner.
# @author Kent 'picat' Gruber
require 'socket'
# Target ports... a range of all of the possible ports lol.
target_ports = 1..65535
# Grab the banner of a given +ip+ address and +port+
@picatz
picatz / basic_socket_usage_with_ip_and_port_range.rb
Last active April 14, 2017 20:20
Violent Ruby: Banner Grabber - Basic Socket Usage with IP/Port Ranges
# coding: utf-8
# Basic socket usage to grab a banner.
# @author Kent 'picat' Gruber
require 'socket'
# Target ports... a range of all of the possible ports lol.
target_ports = 1..65535
target_ips = ['10.0.0.2', '10.0.0.3', '10.0.0.4']