Skip to content

Instantly share code, notes, and snippets.

@mguymon
mguymon / knockr.rb
Created December 8, 2011 17:58
Simply ruby port knocker
#!/usr/bin/env ruby
require 'socket'
require 'timeout'
def knock?(ip, port)
begin
Timeout::timeout(2) do
begin
s = TCPSocket.new(ip, port)
@mguymon
mguymon / Jarfile
Created February 4, 2012 01:19
LockJar Examples
repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
jar "org.apache.mina:mina-core:2.0.4"
pom 'spec/pom.xml'
scope 'runtime' do
jar 'org.apache.tomcat:servlet-api:jar:6.0.35'
end
scope 'test' do
@mguymon
mguymon / gist:2029254
Created March 13, 2012 14:52
Remove old directories
DAYS = 30
DIR_COUNT=`ls -tr | wc -l`
if [ "${DIR_COUNT}" -gt ${DAYS} ]
then
ls | sort -n | head -`expr ${DIR_COUNT} - ${DAYS}` | xargs echo "removing dirs
: "
ls | sort -n | head -`expr ${DIR_COUNT} - ${DAYS}` | xargs rm -rf
fi
@mguymon
mguymon / lockjar_buildfile
Created April 16, 2012 21:00
lockjar buildfile
require 'lock_jar/buildr'
# app definition, inherited into all projects
lock_jar do
repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
scope 'test' do
jar 'junit:junit:jar:4.10'
end
end
@mguymon
mguymon / Jarfile.lock
Created April 16, 2012 21:01
LockJar Jarfile.lock
---
scopes:
compile:
dependencies:
- org.apache.mina:mina-core:2.0.4
resolved_dependencies:
- org.apache.mina:mina-core:jar:2.0.4
- org.slf4j:slf4j-api:jar:1.6.1
- com.slackworks:modelcitizen:jar:0.2.2
- commons-lang:commons-lang:jar:2.6
@mguymon
mguymon / gist:3720118
Created September 14, 2012 06:10
Example of using ModelFactory with a DAO
// https://github.com/mguymon/model-citizen
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
@TransactionConfiguration( transactionManager="transactionManager",defaultRollback=true )
public class CategoryDAOTest {
@Autowired
private CategoryDAO categoryDAO;
@mguymon
mguymon / Jarfile.lock
Created October 17, 2012 04:59
Example Jarfile.lock
---
version: 0.7.1
local_repository: ~/.m2/repository
groups:
default:
dependencies:
- ch.qos.logback:logback-classic:jar:0.9.24
- ch.qos.logback:logback-core:jar:0.9.24
- com.metapossum:metapossum-scanner:jar:1.0
- com.slackworks:modelcitizen:jar:0.2.2
@mguymon
mguymon / gist:5040582
Created February 26, 2013 17:59
Bundle install fails for JRuby 1.7.3
+ bundle install --deployment
Fetching gem metadata from https://rubygems.org/.Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
OpenSSL::SSL::SSLError: Socket closed
connect at org/jruby/ext/openssl/SSLSocket.java:170
connect at /var/lib/jenkins/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/net/http.rb:799
timeout at org/jruby/ext/timeout/Timeout.java:105
connect at /var/lib/jenkins/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/net/http.rb:799
do_start at /var/lib/jenkins/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/net/http.rb:755
start at /var/lib/jenkins/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/net/http.rb:750
@mguymon
mguymon / Gemfile
Created February 28, 2013 17:27
MRI and JRuby friendly Rails Gemfile
source 'https://rubygems.org'
gem 'rails', '~> 3.2.12'
gem "figaro", '~> 0.5.3'
gem 'inherited_resources'
# Upload
gem "paperclip" , '~> 3.4.0'
gem 'paperclip-ffmpeg', '~> 0.9.4'
gem 'aws-sdk', '~> 1.8.2'
@mguymon
mguymon / stomp_client.rb
Created May 25, 2013 18:59
Ruby StompClient updated to support headers
class StompClient < Stilts::Stomp::Client
field_accessor :destroyExecutor, :channel, :bootstrap
# override send to add header support
def send(destination, message, headers = nil)
method_args = [destination]
if headers