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
# Copyright 2012-2013 Barry Allard <barry.allard@gmail.com> | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without modification, | |
# are permitted provided that the following conditions are met: | |
# | |
# 1. Redistributions of source code must retain the above copyright notice, this | |
# list of conditions and the following disclaimer. | |
# | |
# 2. Redistributions in binary form must reproduce the above copyright notice, |
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
/** | |
* @version 1.20 25 Mar 1998 | |
* @author Cay Horstmann | |
*/ | |
import java.awt.*; | |
import java.awt.event.*; | |
import javax.swing.*; | |
class MousePanel extends JPanel implements MouseMotionListener { |
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
-- PostgreSQL 9.2 beta (for the new JSON datatype) | |
-- You can actually use an earlier version and a TEXT type too | |
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8 | |
-- Inspired by | |
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html | |
-- http://ssql-pgaustin.herokuapp.com/#1 | |
-- JSON Types need to be mapped into corresponding PG types | |
-- |
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
/** | |
* inspired by JavaCPP's Loader utility | |
* @see http://bit.ly/loader-java | |
*/ | |
public class Caller { | |
/** | |
* Returns the {@link Class} object that contains a caller's method. | |
* | |
* @param i the offset on the call stack of the method of interest |
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
source 'https://rubygems.org' | |
gem 'rails', '3.2.16' # or whatever | |
# ... | |
group :assets do | |
# make sure you have the latest rhino : | |
gem 'therubyrhino', '>= 2.0.2', :platform => :jruby | |
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 'java' | |
module ThreadDump | |
def self.thread_dump(output = nil) | |
output ||= '' | |
thread_mbean = java.lang.management.ManagementFactory.getThreadMXBean | |
thread_ids = thread_mbean.getAllThreadIds # long[] | |
threads = thread_mbean.getThreadInfo(thread_ids, false, false) # ThreadInfo[] | |
threads.each do |thread_info| |
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 'jruby' | |
class CurrentThreadAwareFormatter < Logger::Formatter | |
FORMAT = "%s [%5s] {%s} -- %s\n".freeze | |
def call(severity, time, progname, msg) | |
thread = Thread.current | |
thread_id = JRuby.reference(thread).getNativeThread.to_s | |
thread_id << ' ' << ( thread[:name] || thread.to_s ) | |
FORMAT % [format_datetime(time), severity, thread_id, msg2str(msg)] | |
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
::ActiveRecord::ConnectionAdapters::ConnectionPool.class_eval do | |
def release_connection(with_id = current_connection_id) | |
#synchronize do | |
conn = @reserved_connections.delete(with_id) | |
checkin conn, true if conn | |
#end | |
end | |
def checkin(conn, on_release = nil) |
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 'java' | |
input = 'INPUT_FILE' | |
output = 'WHERE_TO_COPY' | |
input_file = nil; input_channel = nil; output_channel = nil | |
new_io_channels = Proc.new do | |
input_file = File.open(input, 'r') unless input_file | |
input_channel = input_file.to_channel |
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
/* | |
* Wait Until Exists Version v0.2 - http://javascriptisawesome.blogspot.com/ | |
* | |
* | |
* TERMS OF USE - Wait Until Exists | |
* | |
* Open source under the BSD License. | |
* | |
* Copyright © 2011 Ivan Castellanos | |
* All rights reserved. |