Skip to content

Instantly share code, notes, and snippets.

View joshbuddy's full-sized avatar
🤡
meow

Joshua Hull joshbuddy

🤡
meow
View GitHub Profile
<html>
<body>hi!</body>
</html>
<html>
<body>
Testing
</body>
</html>
For an arbitrary string, detect the largest palindrome* present within it.
* a sequence of characters the same forwards and backwards at least 3 characters long.
For instance in "abbabcdedc", the longest palindrome would be "cdedc".
Answers?
240: adr
195: lusis
193: zunaid
189: megbutton
175: onebrightlight
167: 1ai1a
157: cripsahoy
154: fivethirtyeight
154: tamera
137: twilio
class Song
def initialize(title, length_in_seconds, author)
@title, @length_in_seconds, @author = title, length_in_seconds, author
end
# real ruby
def length_in_minutes
@length_in_seconds.to_f / 60
end
ruby-1.9.2-p180 :001 > body =<<-EMAIL.gsub(/ {6}/, '')
ruby-1.9.2-p180 :002"> asdasdasd
ruby-1.9.2-p180 :003"> EMAIL
=> "asdasdasd\n"
[joshbuddy@jj ~/Development/todo]$ bundle exec padrino g model List
/Users/joshbuddy/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/rake_compat.rb:33: undefined method `task' for class `Object' (NameError)
from /Users/joshbuddy/.rvm/gems/ree-1.8.7-2011.03/gems/padrino-core-0.9.28/lib/padrino-core/cli/base.rb:8
from /Users/joshbuddy/.rvm/gems/ree-1.8.7-2011.03/gems/padrino-core-0.9.28/bin/padrino:7:in `require'
from /Users/joshbuddy/.rvm/gems/ree-1.8.7-2011.03/gems/padrino-core-0.9.28/bin/padrino:7
from /Users/joshbuddy/.rvm/gems/ree-1.8.7-2011.03/bin/padrino:19:in `load'
from /Users/joshbuddy/.rvm/gems/ree-1.8.7-2011.03/bin/padrino:19
development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000
Whenever you're called on to make up your mind.
And you're hampered by not having any.
The simplest way to solve the dilemma you'll find,
Is simply by flipping a penny.
No, not so that chance shall decide the affair;
As you're passively standing there moping.
But as soon as the penny is up in the air,
You'll suddenly know what you're hoping.
import java.net.InetSocketAddress
import java.util.concurrent.Executors
import org.jboss.netty.bootstrap.ServerBootstrap
import org.jboss.netty.channel.ChannelPipelineFactory
import org.jboss.netty.channel.Channels
import org.jboss.netty.channel.SimpleChannelUpstreamHandler
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory
import org.jboss.netty.channel.MessageEvent
class EchoServer