|
|
|
Friday, 21 October 2011 18:36 |
Make your life more simple take the personal loans and all you require. Read more: |
|
|
Tuesday, 18 October 2011 02:44 |
//
// Setup instructions for Ruby on Rails:
Do not forget to set your site token after testing!
Get the gem:
gem install madvertise
Add
require 'madvertise'
to app/controllers/application.rb, or to any specific controller as needed and / or
provide the necessary default settings in your environment.rb file, e.g.
require 'madvertise'
Madvertise::config do |c|
c.site_token = 'TestTokn'
end
Place a request in the view, e.g.
<%= Madvertiese.get_ad(request) %>
 Read more: |
|
Sunday, 02 October 2011 19:24 |
// this code will add normcase to Pathname and File in ruby correctly (only the OS X part has been tested)
module NormCase
require 'rbconfig'
require 'pathname'
require 'tempfile'
require 'tmpdir'
def case_sensitive(path=nil) #if not given will use tempfile on OS X
case RbConfig::CONFIG["host_os"]
when /mswin|mingw|cygwin/i #windows is always insensitive
return false
when /darwin/i # the trouble maker as only the underlying file system knows and that requires using Cocoa
require 'osx/cocoa'
include OSX
#OSX.require_framework('Foundation') #this would be false as it loaded already
if ! path then
tf=Tempfile.new(["Temp","Test"],File(path).dirname)
path=tf.path
tf.close
tf.unlink
end
realpath=Pathname(path).parent.realpath().to_s # now we have a full path
# filesystem is an NSURL for realpath with isDirectory => true
filesystem = NSURL.FileURLWithPath_isDirectory_(realpath,true)
#result = [has res., res. value, error value] forKey=>NSURLVolumeSupportsCaseSensitiveNamesKey
result = filesystem.getResourceValue_forKey_error_(NSURLVolumeSupportsCaseSensitiveNamesKey)
return result[1].to_ruby # convert to_ruby because it is an NSCFBoolean (this likely is is false, thanks to Adobe)
when /sunos|solaris|linux/i #unix types are case sensitive
return true
when /vms|os/i #vms or os/2 # TODO: check this but I know that vms and OS/2 are case-insensitive
return false
else # freeBSD, OpenBSD, etc #assume they are posix types with case sensitive file systems
return true
end
end
def normcase(path)
if ! case_sensitive(path) then
self.to_s().upcase()
else
self.to_s()
end
end
end
# don't forget to include this to extend Pathname and File
class Pathname
include NormCase
end
class File
include NormCase
end
 Read more: |
|
|
Tuesday, 19 October 2010 04:00 |
 | About Liquid Defense
A unique puzzle game where you must eliminate all of the incoming water, gas and oil. Each of the levels is carefully designed to require innovative solutions while managing limited resources. |
Read more: |
|
Tuesday, 04 May 2010 16:12 |
If you want to require a specific version of a gem you have to both specify the version using the gem method AND require the gem as you normally do. If you don't do this you will receive an error like "NameError: uninitialized constant RestClient".
Some gems make this more complex by having a gem name that is not the same as the name of the file you then have to require like in the example below.
#!/usr/bin/env ruby -rubygems
gem 'rest-client', '= 1.5.0' #Install with: sudo gem install rest-client -v 1.5.0
require 'rest_client'
puts RestClient.get("http://example.com").body
 Read more: |
|
|
|
|
|
|
|