Skip to content

Instantly share code, notes, and snippets.

@mikewadhera
mikewadhera / gist:786861
Created January 19, 2011 21:01
snippet of explorer.js
function buildPhotoPanel() {
photoPanel = new Ext.Panel({
html: '<canvas id="photos"></canvas>',
cls: 'card',
layout: 'fit'
});
// attach the panel listeners
photoPanel.addListener('afterrender', function() {
initPhotoGrid();
#!/bin/sh
echo 'Updating apt-get sources'
echo '
# Debian Lenny
deb http://ftp.debian.org/debian/ lenny main contrib non-free
deb-src http://ftp.debian.org/debian/ lenny main contrib non-free
deb http://http.us.debian.org/debian lenny main contrib non-free
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>[Channel Name]</title>
<link>[Channel URL]</link>
<description>[Channel Description]</description>
<ttl>[Channel TTL]</ttl>
<item>
<title>[Title]</title>
<link>[Link to External]</link>
<guid>[Item GUID]</guid>
@mikewadhera
mikewadhera / _INSTALL
Created July 1, 2010 03:15
git bash prompt
1. Install to ~/.git_bash_prompt
2. Stick this in your ~/.profile or ~/.bash_profile or ~/.bashrc
if [ -f ~/.git_bash_prompt ]; then
. ~/.git_bash_prompt
fi
3. PROFIT!
def sml_attr(name, options={)
# Same as before
if options[:default].respond_to?(:call)
define_method sml_method(attribute), options[:default]
elsif options[:default].nil?
define_method sml_method(attribute), lambda {self.send(attribute)}
end
self.sml_attributes.push(attribute) if !self.sml_attributes.include?(attribute)
Jun 17 19:24:00 domU-12-31-39-13-C1-41 rails[5015]: ActiveRecord::StatementInvalid (NativeException: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.: SELECT count(*) AS count_all FROM `users` ): /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:188:in `log' /usr/jruby-1.3.1/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.1/lib/active_record/connection_adapters/jdbc_adapter.rb:563:in `execute' /usr/jruby-1.3.1/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.1/lib/active_record/connection_adapters/jdbc_adapter.rb:623:in `select' /usr/jruby-1.3.1/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.1/lib/active_record/connection_adapters/jdbc_adapter.rb:559:in `select_one' /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:19:in `select_value'
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
xmlns:prop="http://www.involver.com/schema/property-set.xsd"
xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>RSS Example</title>
<description>This is an example of an RSS feed</description>
<link>http://www.domain.com/link.htm</link>
<lastBuildDate>Mon, 28 Aug 2006 11:12:55 -0400 </lastBuildDate>
(rdb:5) @config
{:url=>"jdbc:mysql:replication//localhost:3306/involver_dev?zeroDateTimeBehavior=convertToNull&jdbcCompliantTruncation=false&useUnicode=true&characterEncoding=utf8", :driver=>"com.mysql.jdbc.ReplicationDriver", :adapter=>"jdbcmysql", :username=>"root", :password=>"letmein", :port=>3306}
(rdb:5) spec
JdbcSpec::MySQL
(rdb:5) connection_class
ActiveRecord::ConnectionAdapters::JdbcConnection
(rdb:5) connection_class.new(@config)
ActiveRecord::ConnectionNotEstablished Exception: no connection available
(rdb:5) connection
nil
[ ~/involver-rails ] master> time jruby script/runner "exit"
/Users/mikewadhera/.gem/gems/json-jruby-1.1.6-universal-java-1.6/lib/json/common.rb:60 warning: already initialized constant State
/Users/mikewadhera/.gem/gems/json_pure-1.1.6/lib/json/ext.rb:14 warning: already initialized constant JSON_LOADED
**Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance.
/Users/mikewadhera/code/work/involver-rails/lib/platforms.rb:4 warning: already initialized constant SubdomainMappings
SQL (1.0ms) SET SQL_AUTO_IS_NULL=0
New Relic Agent not running.
real 0m26.544s
$ jruby script/console
Loading development environment (Rails 2.2.2)
>> ActiveRecord::Base.connection
*** inside no_conn_pool.rb's #checkout override...
*** jdbcmysql adapter configured with driver: com.mysql.jdbc.ReplicationDriver url: jdbc:mysql:replication://localhost:3306/involver_dev?zeroDateTimeBehavior=convertToNull&jdbcCompliantTruncation=false&useUnicode=true&characterEncoding=utf8
RuntimeError: The driver encountered an error: no connection available
from /Users/mikewadhera/.gem/gems/activerecord-jdbc-adapter-0.9.1/lib/active_record/connection_adapters/jdbc_adapter.rb:330:in `initialize'
from /Users/mikewadhera/.gem/gems/activerecord-jdbc-adapter-0.9.1/lib/active_record/connection_adapters/jdbc_adapter.rb:457:in `initialize'
from /Users/mikewadhera/.gem/gems/activerecord-jdbc-adapter-0.9.1/lib/active_record/connection_adapters/jdbc_adapter.rb:53:in `jdbc_connection'
from /Users/mikewadhera/.gem/gems/activerecord-jdbc-adapter-0.9.1/lib/jdbc_adapter/jdbc_mysql.rb:22:in `mysql_connection'