Browsing All Posts filed under »Ruby«

Using Gradient in HTML using simple CSS

August 12, 2011

0

In this post I show(after some googling) how to use gradients(color transitions) in your html using simple CSS. I am putting the CSS code below. This code can be pasted in the css file of your project. you have to create a div with id as “gradient”. Alternatively, you can paste this code in style… [Read more…]

Some Core Rails Helper for Ruby

August 10, 2011

3

The Core Extensions are ActiveSupport’s collection of extensions to Ruby’s core classes and modules. They are basic design patterns solving problems that are encountered often in Ruby. These methods are one level below the Rails API; they are the internal functions that Rails uses. Class:Array–> ————————————————————————————————————————————- Conversions core_ext/array/conversions.rb • Array#to_sentence joins the array’s elements and… [Read more…]

Programming Language

August 9, 2011

0

The primary purpose of source code should not be expressing implementation to a computer; it should be expressing meaning to people. Programming languages are an incredibly expressive and terse medium for the concepts programmers talk about. Proposals to make programming languages more English-like inevitably fail not because of poor implementation but because there is an… [Read more…]

Ruby we might Miss

August 9, 2011

0

This is the continuation part of the series I started. The topic for this post : String —————————————————————————————————————— String#%(args) interpolates the arguments into itself in the manner of sprintf. To provide more than one value for interpolation, you must supply an array. “%.5f” % Math::PI # => “3.14159″ “%.5f, %.5f” % [Math::PI, Math::E] # =>… [Read more…]

Ruby we might Miss

August 9, 2011

0

This is the continuation part of the series I started. The topic for this post : Proc —————————————————————————————————————— • Proc#[] is shorthand for Proc.call. p = lambda{|x| x * 2} p[3] # => 6 ——————————————————————————————————————

Ruby we might Miss

August 9, 2011

0

This is the continuation part of the series I started. The topic for this post : Module —————————————————————————————————————— • Module#remove_method removes a method from the specified class. Module#undef_method, on the other hand, actively prevents that method from being invoked on the class; it inserts a special entry into the m_tbl that stops method lookup. ——————————————————————————————————————

Ruby we might Miss

August 9, 2011

0

This is the continuation of the series I started. The topic for this post : Kernel —————————————————————————————————————— • Kernel#Array tries to coerce its argument into an array: Array([1,2,3]) # => [1, 2, 3] Array(1..3) # => [1, 2, 3] Array(1) # => [1] ——————————————————————————————————————

Ruby we might Miss

August 9, 2011

0

This is the continuation of the series I started. The topic for this post : Hash —————————————————————————————————————— • Hash.new accepts a block, which provides a way to calculate a default value if the hash has none. This is useful for caching. The first time a cached method is called with a particular set of arguments,… [Read more…]

Ruby we might Miss

August 9, 2011

0

This is the third part of the series I started. The topic for this post : File ———————————————————————————————————— • File.join(*parts) is a platform-independent way to join path segments: File.join(“..”, “test.rb”) # => “../test.rb” ———————————————————————————————————— ———————————————————————————————————— •File.open can take a block, which will automatically close the file when exited. ————————————————————————————————————

Ruby we might Miss

August 9, 2011

0

This is the third part of the series I started. The topic for this post : Enumerable ———————————————————————————————————— • Enumerable#all? returns true if the given block returns a true value for all items in the enumerable. Similarly, Enumerable#any? returns true if the block returns a true value for any item. (1..10).all?{|i| i > 0 &&… [Read more…]

Follow

Get every new post delivered to your Inbox.