This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'sinatra' | |
class Application < Sinatra::Base | |
get '/' do | |
"Hello World" | |
end | |
get '/about' do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def is_float? | |
Float(self) != nil rescue false | |
end | |
def is_integer? | |
Integer(self) != nil rescue false | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rake/testtask' | |
Rake::TestTask.new do |t| | |
t.pattern = 'test/*_test.rb' | |
end | |
task(default: :test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given unit tests are located in the test/ directory. | |
In Shell: | |
$ ruby test/test_test.rb --name name_of_test_method | |
----------------------- | |
Or for all in that spec, simply: | |
In Shell: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :generate do | |
desc "Add new Unit Test file" | |
task :test do | |
unless ENV.has_key?('NAME') | |
raise "Must specify a unit test file name, e.g., rake generate:test NAME=test_name" | |
end | |
unit_test_path = "test/" + ENV['NAME'].downcase + "_test.rb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
require 'netaddr' # this is a gem | |
class Address | |
# Pull the ip address from the local machine | |
def initialize | |
@info = Socket.getifaddrs.find do |ifaddr| | |
(ifaddr.flags & Socket::IFF_BROADCAST).nonzero? && | |
ifaddr.addr.afamily == Socket::AF_INET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
require 'celluloid' | |
class Nmapper | |
include Celluloid | |
def nmap opts = '' | |
`nmap #{opts}` | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse, os, subprocess | |
parser = argparse.ArgumentParser() | |
parser.add_argument("directory", help="The repository directory - /var/lib/sbopkg/{SBo,SBo-git}/") | |
parser.add_argument("maintainer", help="Supply SlackBuilds maintainer in quotes") | |
args = parser.parse_args() | |
for root, dirs, files in os.walk(args.directory): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse, os, subprocess | |
parser = argparse.ArgumentParser() | |
parser.add_argument("directory", help="The repository directory - /var/lib/sbopkg/{SBo,SBo-git}/") | |
parser.add_argument("requires", help="Search SlackBuilds for a dependency or related SlackBuild") | |
args = parser.parse_args() | |
for root, dirs, files in os.walk(args.directory): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
page = Nokogiri::HTML(open("https://duckduckgo.com/html/?q=what%20is%20my%20ip", proxy: "")) | |
@text = page.css('div#zero_click_abstract')[0].text.strip | |
open('/tmp/whatismyip', 'w') do |f| |
OlderNewer