Skip to content

Instantly share code, notes, and snippets.

View erran's full-sized avatar

Erran Carey erran

View GitHub Profile
@erran
erran / main.m
Created June 10, 2012 19:08
Shodan Generate IP List Example
//
// Shodan Generate IP List Example
// Generation of an "IP List" using the Objective-C Shodan API
//
// main.m
// shodan_ips
//
// Created by Erran Carey on 6/10/12.
// Copyright (c) 2012 App2O. All rights reserved.
//
@erran
erran / .bashrc
Last active December 12, 2015 01:38
Git prompt in .bashrc
# Git
function git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u @ \w \$(git_branch)$ "

My Mac OS X Environment

Homebrew

RVM

Vim

+ MacVim

NERDTree

Lightline

Startify

@erran
erran / 1.9.3_ext_string.rb
Last active December 20, 2015 11:29
Converting a dash separated string into an IP range.
require 'ipaddr'
unless defined?(IPAddr::InvalidRangeError)
IPAddr::InvalidRangeError = Class.new(ArgumentError)
end
String.class_eval do
def to_ip_range
if split('-').count == 2
IPAddr.new(split('-').first)..IPAddr.new(split('-').last)
@erran
erran / full-trace
Last active December 20, 2015 23:39
The full stack trace I get when running cucumber-jvm with a default RVM installed version of JRuby.
[ecarey @ automation]$ cucumber-jvm
cucumber.runtime.CucumberException: java.lang.reflect.InvocationTargetException
at cucumber.runtime.io.ResourceLoaderReflections.newInstance(ResourceLoaderReflections.java:81)
at cucumber.runtime.io.ResourceLoaderReflections.instantiateSubclasses(ResourceLoaderReflections.java:57)
at cucumber.runtime.Runtime.loadBackends(Runtime.java:78)
at cucumber.runtime.Runtime.<init>(Runtime.java:52)
at cucumber.api.cli.Main.run(Main.java:18)
at cucumber.api.cli.Main.main(Main.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
@erran
erran / stack-trace
Created August 12, 2013 21:40
Require path/glue issues with cucumber-jvm
[ecarey @ automation]$ RUBY_VERSION=2.0 jruby -S cucumber-jvm -g features/ features/
NoMethodError: undefined method `Given' for main:Object
(root) at ui/step_definitions/prototype.rb:1
(root) at /Users/ecarey/.rvm/gems/jruby-1.7.4/gems/cucumber-jvm-1.1.4-java/bin/cucumber-jvm:7
load at org/jruby/RubyKernel.java:1073
(root) at /Users/ecarey/.rvm/gems/jruby-1.7.4/bin/cucumber-jvm:19
org.jruby.embed.EvalFailedException: (NoMethodError) undefined method `Given' for main:Object
at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:133)
at org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1264)
at org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1280)
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
<meta http-equiv="set-cookie" content="cf_use_ob=0; expires=Sat, 24-Aug-13 21:48:25 GMT; path=/">
@erran
erran / validate_json.rb
Last active December 23, 2015 00:58
A script that validates the syntax of all of the JSON files in your CWD recursively. Run it by copying and pasting it into irb after you've cd'd into the correct directory.
#!/usr/bin/env ruby
# vi: set ft=ruby
require 'json'
Dir['**/*.json'].each do |json|
puts json
JSON.parse(File.read(json))
end
@erran
erran / gist:6563698
Created September 14, 2013 17:05
Discovery of the day, off of a fact I learned a few weeks ago. This is because the JSON filetype is a subset of YAML it remains readable to `YAML.parse()`.
JSON.parse(json) == YAML.parse(json).to_ruby
@erran
erran / example.rb
Last active December 23, 2015 09:49
Nexpose console class and example usages
#!/usr/bin/env ruby
# vi: set ft=ruby :
require_relative './nexpose-console.rb'
nsc = Nexpose::Console.new({ :host => ARGV[0] })
nsc.scan({ :scan_template => 'full-audit', :site_id => 1 })