Feb 29

Simplified Internet and its interaction, enjoy

A) USER LAYER :: normal usage, browsers
1.Computer
2.Operating System (Windows OSX)
3.Browser (Internet Explorer / Safari)
4.Internet (Comcast, Verizon)

B) The network :: NETWORK LAYER
Probably the area we control the LEAST. We can’t MAKE routers talk faster OR make Sprint love us!!!

C) Website/Hosting/Servers :: SERVER LAYER
1.Server(s) (which is a fancy name for computer) ie. Dell
2.Database (where information is stored) ie Oracle, DB2, SQL Server, MySQL
3.Basic HTML files and images( STATIC CONTENT)
-> HTML, CSS, JPG, Javascript, Flash

D) Website base language/framework (does the heavy lifting, most of work***) :: APPLICATION_LAYER
This requires (B)
-> From Microsoft, Open Source, 3rd party.

E) Our code. :: CODE_LAYER
Our programs: (this is where I/we work most of the time, you MUST understand A-D though)
*we write code in the Base/fundamental programming languages from D
*we implement Extra modules/libraries other people write

DONE with A,B,C,D
***************************
***************************
***************************

Web Pages are really akin yelling across canyon!!!!

Internet Applications in the real world(web pages)
——————–
STEPS FOR ONE WEB REQUEST:
1. User A) Users  —> give me a page |NETWORK B) —> |SERVER C) Joe user want to look at ‘XYZ web page’.
2. SERVER C) Send ‘XYZ web page’ to user |NETWORK B) —-> traverse network |USER A) User receives response. Views ‘XYZ web page.’

The above is TRUE even for just an image or buying a widget!

*** In the old days of the internet. All web pages were just layer C. They were simple files served up by the server. This harkens back to the days of the home page internet, when everyone had an internet home page like so: “www.mindspring.com~hbeaver” which I DID!.

Feb 20

Because of the versions of Westhost apache and other files, the easiest way is not to install the latest and greatest. I had success installing this version: subversion-1.2.0-rc4

I also make my own apps directory that I put in my path.

./configure –prefix=/apps/subversion

Feb 10

Soon the rest of this blog will deal with a basic overview of has_many associations and a practical use. For now look at this simple tag that uses has_many of a Blog model to show the Interests (or topics) for a given blog. You would use this helper_tag like so in your view, given that you have a single instance of a blog object called ‘blog’

<%= more_ugly_interests_tag(blog) %>

I hope this small article might help others:

#########################################
#Tag to show usage of has_many for a model.
#Ruby on Rails
#*this_model* is the actual instance of a blog or photo
#which has a list of interests.
#
#Call tag like this:
# <%= more_ugly_interests_tag(blog) %>
#the syntax below uses what Ruby calls a 'block'
#this is the format:
# some_variable_that_has_a_list.each { |list_item
# #do something with each item
# puts list_item + " !!!!"
# }
#########################################
def more_ugly_interests_tag(this_model)

to_return = "INTERESTS"

this_model.interests.each { |each_interest|

to_return =  << each_interest << "
"

}

#now we have end the whole function/method with what we want to return/print
to_return

end

Tagged with:
Jan 04

First as you read Rails and learn more you will discover the DRY (Don’t Repeat Yourself) principle. This means do something once and then don’t dig another ditch.

So here’s my opinion, both partials and tags are for DRY.

One usage difference in my opion: Is if the output is only a few lines, then a tag is simpler and cleaner. However, if the output is many, many lines of HTML like a menu then I start to lean toward partial. However,

There is one thing that a tag can do nicely that partials can’t as cleanly. Arguments can be passed and code run away from the view. Example:

<%=  commentor_pretty_name(blog.login_id) %>

here is the actual tag in application_helper.rb:

##############################
# takes a login_id alone and converts to pretty name for comment/tag
##############################
def commentor_pretty_name(login_id)

def_return = "Nil Name"
begin
logger.debug("app helper commenter_pretty_name")
#the "||" operand below means that we will use the def_return of "Nil Name" if Login.find returns nil
Login.find(login_id).unique_name || def_return
#end
rescue
def_return
end

end

#### END CODE

To do the same in a partial you would have to have this:

<%= render :partial => 'commenter', :locals => { :login_id => user.id} %>

user.id would be passed as argument AND then on the partial you would need some of the ruby code in the actual partial to lookup the user.

<%   #note no '=' tag this is purely to run ruby code and set variables

@def_return = "Nil Name"
begin
logger.debug("app helper commenter_pretty_name")
@def_return  = Login.find(login_id).unique_name
#end
rescue
@def_return
end
%>
    <%= @def_return  %>

Best of both worlds? Use a tag to run the ruby code and then a partial to render? When the tag gets riddled with html/view then this presents a good blend of keeping view and model seperate by using a tag to setup/do ruby work and simple partial to present.

Dec 10

This is DEPRECATED, because Gavin Stark wrote a native ruby class last month. I will leave this up if someone wants a C implementation for OSX, but after that Gavin did the work in Ruby and I encourage looking there:

 http://hasmanyquestions.wordpress.com/2007/11/23/perfect-paper-passwords-in-ruby/

Ruby Extension for GRC’s Perfect Paper Passwords V3.
UPDATE 12/11/2007, current version only supports Mac OSX, I will be creating a Linux version shortly. Not sure if I’ll wrap a Windows version.
Ruby Extension for GRC’s Perfect Paper Passwords/PPP C (http://www.grc.com/ppp/) implementation by John Graham-Cumming.
Create with SWIG.
Version .01
CODE/LIB: http://www.1000fires.com/ppp3-Ruby-extension.zip
C Ref: http://www.jgc.org/blog/2007/11/steve-gibsons-ppp-new-version-3-in-java.html
NOTE: Because of the way C works, the first argument must be a space (not a null char).

Entry point to ppp3 is “Ppp3.main” Ruby call after include with a Ruby array as argument.

USAGE in ruby:

require ‘ppp3′ #ppp3.bundle#Usage 1, just get a random sequence key.
Ppp3.main([” “,” “])

# Usage 2, create an array and call with arguments.
# call the Ppp3.main call with this array:

a = Array[”",”efbda242bd1db23fd343b516a2a10d0eed08250e542a789811307f2011a92df6″,”0″,”2″]
Ppp3.main(a)

#Usage 3, call with implied array string.
Ppp3.main([”",”efbda242bd1db23fd343b516a2a10d0eed08250e542a789811307f2011a92df6″,”0″,”70″])

TODO. Add a Ruby convenience library to do some parsing and pretty printing as well as prepare for Rails integration.

Nov 30

Causes?

1. ‘require ‘action_controller/integration’ is in your environment.rb instead of just production. This is added to allow script/runner to do background jobs,etc as suggested on a site elsewhere I can’t find. Put this in the specific environment -> config/environments/production.rb’

Nov 19

I’m writing these rules for my own projects and because I have yet to see anything concrete.

1. method names should be ALL lower case with underscores. Use standard verbs for the purpose of the method if possible, ie. get, set, create, add,etc with the item acted upon also as part of method. Examples:

‘get_profile_names’, ’set_profile_pictures’

2. DON’t BE redudant. no method names with ‘method or function’.

3. Keep variables names meaningful. NO: x,y,i unless it’s simply part of a loop increment. Make them: pic_count, event_name.

4. About commenting. Actually this is the part I find most confounding about Ruby and Rails. There is no standard way other than RDoc. I AM NOT suggesting Hungarian notation. Yuck! BUT. I have started using the below on my projects for basic Rails Controller and Model documentation.

##############################
# OUTER METHOD COMMENTS
##############################

#******************************
# INNER METHOD COMMENTS
#******************************

One of the hardest things for me when I dove into the Ruby pool was the abundance of ‘def’ tags and NO other control characters. My mind becomes glazed and overwhelmed with bigger classes. While Java and C has {}; and other items to help break up the appearance.

This will be a work in progress.

Nov 17

Found a good post:

http://www.railsjitsu.com/ruby-on-rails/partial-flash-messages-in-rails/trackback/

Nov 16

1. Run dispatch.fcgi (if you are using fast CGI) from command line and get no errors. Move to #2.

2. Replace all ‘puts’ in your views or code to logger. This will kill Rails when executing.

3. In progress…..

Nov 09

For the life of me I can’t get ethereal or any variant to work on my OS X 10.4 ( yes I have X11 installed). So for some method I get ethereal which comes with tethereal ( a command line variant ). The below is how I sniffed my Rails app in action.

/sw/bin/tethereal -V -S -i lo0 -d ‘tcp.port==3000,http’