Thursday, May 15, 2008
Wednesday, May 14, 2008
A Good Reason to CHECK Your Site For SQL Injections
Friday, May 09, 2008
Wednesday, May 07, 2008
Thursday, February 14, 2008
Monday, February 11, 2008
I needed a refresher with RJS so I watched Peepcode’s screencast on RJS. I know it was not rails 2 so I decided to share what I changed to make it work with rails 2.
I used the SQL lite db for the demo. To set it up I created the rails project
rails rjs_demo
I used the scaffold to get it off the ground
script/generate scaffold Task name:string value:integer
And that will take care of the CRUD, routes and all that fun stuff.
You don’t need the dom_id plugin we can use the div_for
I’m just used the index.html.erb file instead of making a list file.
I added to the routes file
:collection => { :hello => :any }
To the map.resources :tasks line and the link now says
map.resources :tasks, :collection => { :hello => :any }
The link for the say hello
<%= link_to_remote "Say Hello", :url => hello_tasks_path %>
Instead of
<%= link_to_remote "Say Hello", :url => tasks_url(:action => 'hello') %>
In the tasks_controller.rb add a hello method.
def hello respond_to do |format| format.js end end
add into the views/tasks folder the file hello.js.rjs
page.alert "hello world!"
Partials.
For the tasks partial create the _task.html.erb file.
With rails 2 you can call a partial but using <%= render :partial => @tasks %>
and then in the task instead of using the dom_id you can use the div_for
Highlight me.
In routes file I added
:member => { :highlight => :post }
to the map.resources :tasks line. It should read
map.resources :tasks, :collection => { :hello => :any }, :member => { :highlight => :post }
that gives us the route
highlight_task POST /tasks/:id/highlight {:action=>"highlight", :controller=>"tasks"}
so the link is <%= link_to_remote "highlight me ", :url => highlight_task_path(task) %>
In the controller
def highlight @task = Task.find(params[:id]) respond_to do |format| format.js end end
And make the highlight.js.rjs file
the form.
you can use the remote_form_for
<%= error_messages_for :task %> <% remote_form_for(:task, :url => tasks_path, :html => {:id => "task_form"}) do |f| %> <p> <b>Name</b><br /> <%= f.text_field :name %> </p> <p> <b>Value</b><br /> <%= f.text_field :value %> </p> <p> <%= f.submit "Create" %> </p> <% end %>
And in the index.html.erb file call the partial
<%= render :partial => 'form' %>
Don't forget the add the format.js in the is @save section
Now make the create.js.rjs file
page.insert_html :bottom, 'tasks', :partial => @task page['task_form'].reset
When adding the super_special class I changed the link to
page.call "set_class_name", "task_#{@task.id}", 'super_special'
and it works
now destroy
In the destroy.js.rjs file
page.remove "task_#{@task.id}"
and add the format.js to the destroy method.
The destroy link will look like.
<%= link_to_remote "destroy", :url => task_path(task), :method => :delete, :confirm => "Do you want to delete '#{task.name}'?" %>
Replace.
_totals.js.rjs file I used this line
page.replace_html 'task_totals', @task_totals
The shared error file
create the shared folder and add an error.js.rjs file to it
the code it the same in the rjs file
in the tasks_controller in the condidtional andd this for an error
format.js { render :template => "shared/error.js.rjs" }
that will make the popup work.
These are my rough notes.
John
I used the SQL lite db for the demo. To set it up I created the rails project
rails rjs_demo
I used the scaffold to get it off the ground
script/generate scaffold Task name:string value:integer
And that will take care of the CRUD, routes and all that fun stuff.
You don’t need the dom_id plugin we can use the div_for
I’m just used the index.html.erb file instead of making a list file.
I added to the routes file
:collection => { :hello => :any }
To the map.resources :tasks line and the link now says
map.resources :tasks, :collection => { :hello => :any }
The link for the say hello
<%= link_to_remote "Say Hello", :url => hello_tasks_path %>
Instead of
<%= link_to_remote "Say Hello", :url => tasks_url(:action => 'hello') %>
In the tasks_controller.rb add a hello method.
def hello respond_to do |format| format.js end end
add into the views/tasks folder the file hello.js.rjs
page.alert "hello world!"
Partials.
For the tasks partial create the _task.html.erb file.
With rails 2 you can call a partial but using <%= render :partial => @tasks %>
and then in the task instead of using the dom_id you can use the div_for
Highlight me.
In routes file I added
:member => { :highlight => :post }
to the map.resources :tasks line. It should read
map.resources :tasks, :collection => { :hello => :any }, :member => { :highlight => :post }
that gives us the route
highlight_task POST /tasks/:id/highlight {:action=>"highlight", :controller=>"tasks"}
so the link is <%= link_to_remote "highlight me ", :url => highlight_task_path(task) %>
In the controller
def highlight @task = Task.find(params[:id]) respond_to do |format| format.js end end
And make the highlight.js.rjs file
the form.
you can use the remote_form_for
<%= error_messages_for :task %> <% remote_form_for(:task, :url => tasks_path, :html => {:id => "task_form"}) do |f| %> <p> <b>Name</b><br /> <%= f.text_field :name %> </p> <p> <b>Value</b><br /> <%= f.text_field :value %> </p> <p> <%= f.submit "Create" %> </p> <% end %>
And in the index.html.erb file call the partial
<%= render :partial => 'form' %>
Don't forget the add the format.js in the is @save section
Now make the create.js.rjs file
page.insert_html :bottom, 'tasks', :partial => @task page['task_form'].reset
When adding the super_special class I changed the link to
page.call "set_class_name", "task_#{@task.id}", 'super_special'
and it works
now destroy
In the destroy.js.rjs file
page.remove "task_#{@task.id}"
and add the format.js to the destroy method.
The destroy link will look like.
<%= link_to_remote "destroy", :url => task_path(task), :method => :delete, :confirm => "Do you want to delete '#{task.name}'?" %>
Replace.
_totals.js.rjs file I used this line
page.replace_html 'task_totals', @task_totals
The shared error file
create the shared folder and add an error.js.rjs file to it
the code it the same in the rjs file
in the tasks_controller in the condidtional andd this for an error
format.js { render :template => "shared/error.js.rjs" }
that will make the popup work.
These are my rough notes.
John
Tuesday, July 10, 2007
Trip to Erie PA
Amy and I went up to Erie on June 21st for Jeff Mattoe's funeral. It was very sad. He looked liked at anytime he would sit up and say "Boo." He suffered from a massive heart attack. John Dalton Works for Bruger Funeral Home. He went to the hospital to get jeff and preped him for the viewing.
-----------------------------------------
Jeffrey J. Matteo Loving Husband and Father Jeffrey J. Matteo, 40, of Erie, died unexpectedly at Hamot Medical Center on Monday, June 18, 2007. Born in Erie on June 24, 1966, he was a son of Jeffrey J. Matteo and Barbara Graham Matteo, both of Erie. Jeffrey was the Detail Manager at Car Care II on W. Eighth St. in Millcreek. Jeffrey was an avid fan of the Dallas Cowboys and Chicago Cubs. He enjoyed playing golf and belonged to a dart league at Lombardo’s Tavern on W. 21st St. In addition to his parents, Jeffrey is survived by his loving wife, Carla Nemenz Matteo; two adoring children, Dominic and Anthony Matteo; two brothers, Michael and Daniel Matteo, wife Star; two nieces, Kara and Samantha Matteo; one nephew, Corey Matteo; a grandmother, Caroline Graham, all of Erie; two uncles, his Godfather, James Graham, of Shreveport, La., and David Graham of Erie; an aunt, Linda Chase, of Erie; and many loving friends. Friends are invited to call at the Brugger Home for Funerals, 1595 W. 38th St. at Greengarden Blvd. on Thursday from 2 p.m. to 5 p.m. and 7p.m. to 9 p.m., and may attend a prayer service there on Friday at 9:15 a.m. followed by a Mass of Christian Burial at Our Lady of Peace Church at 10 a.m. Burial to follow. In lieu of flowers, memorials are suggested to the Jeffery J. Matteo Memorial Fund, c/o NW Savings Bank, Kmart Plaza West, 2863 W. 26th St., Erie, PA 16506. Condolences at bruggerfuneralhomes .com. Sign the guestbook at www.GoErie.com/obits.
Published in the Erie Times-News on 6/20/2007.
----------
http://www.legacy.com/ErieTimesNews/GB/GuestbookView.aspx?PersonId=89282122
Amy and I went up to Erie on June 21st for Jeff Mattoe's funeral. It was very sad. He looked liked at anytime he would sit up and say "Boo." He suffered from a massive heart attack. John Dalton Works for Bruger Funeral Home. He went to the hospital to get jeff and preped him for the viewing.
-----------------------------------------
Jeffrey J. Matteo Loving Husband and Father Jeffrey J. Matteo, 40, of Erie, died unexpectedly at Hamot Medical Center on Monday, June 18, 2007. Born in Erie on June 24, 1966, he was a son of Jeffrey J. Matteo and Barbara Graham Matteo, both of Erie. Jeffrey was the Detail Manager at Car Care II on W. Eighth St. in Millcreek. Jeffrey was an avid fan of the Dallas Cowboys and Chicago Cubs. He enjoyed playing golf and belonged to a dart league at Lombardo’s Tavern on W. 21st St. In addition to his parents, Jeffrey is survived by his loving wife, Carla Nemenz Matteo; two adoring children, Dominic and Anthony Matteo; two brothers, Michael and Daniel Matteo, wife Star; two nieces, Kara and Samantha Matteo; one nephew, Corey Matteo; a grandmother, Caroline Graham, all of Erie; two uncles, his Godfather, James Graham, of Shreveport, La., and David Graham of Erie; an aunt, Linda Chase, of Erie; and many loving friends. Friends are invited to call at the Brugger Home for Funerals, 1595 W. 38th St. at Greengarden Blvd. on Thursday from 2 p.m. to 5 p.m. and 7p.m. to 9 p.m., and may attend a prayer service there on Friday at 9:15 a.m. followed by a Mass of Christian Burial at Our Lady of Peace Church at 10 a.m. Burial to follow. In lieu of flowers, memorials are suggested to the Jeffery J. Matteo Memorial Fund, c/o NW Savings Bank, Kmart Plaza West, 2863 W. 26th St., Erie, PA 16506. Condolences at bruggerfuneralhomes .com. Sign the guestbook at www.GoErie.com/obits.
Published in the Erie Times-News on 6/20/2007.
----------
http://www.legacy.com/ErieTimesNews/GB/GuestbookView.aspx?PersonId=89282122
Tuesday, June 12, 2007
Anchoring an Image to the Bottom Right Corner of a Flash File.
I need to dynamically load images into flash but the width and height could very but the image needed to stay in the lower right corner. With the help of the Help in flash this is what I came up with.
--------------------------------------------
this.createEmptyMovieClip("container", 0);
var image_mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
trace(target_mc._name+" = "+target_mc._width+" X "+target_mc._height+" pixels");
trace("stage width " + Stage.width + " stage height " + Stage.height );
image_mc._x = Stage.width - target_mc._width;
image_mc._y = Stage.height - target_mc._height;
};
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://rcm-images.amazon.com/images/I/11I4WKohKxL._SL110_.jpg", container);
--------------------------------------------

Now I know the example loads a hard coded image so it's not dynamic but this is in addition to an earlier post
I need to dynamically load images into flash but the width and height could very but the image needed to stay in the lower right corner. With the help of the Help in flash this is what I came up with.
--------------------------------------------
this.createEmptyMovieClip("container", 0);
var image_mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
trace(target_mc._name+" = "+target_mc._width+" X "+target_mc._height+" pixels");
trace("stage width " + Stage.width + " stage height " + Stage.height );
image_mc._x = Stage.width - target_mc._width;
image_mc._y = Stage.height - target_mc._height;
};
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://rcm-images.amazon.com/images/I/11I4WKohKxL._SL110_.jpg", container);
--------------------------------------------
Now I know the example loads a hard coded image so it's not dynamic but this is in addition to an earlier post
Wednesday, April 25, 2007
Developing a flash piece to read an XML doc and then randomly show images.
We have an XML document that has names of people and the associated image for that person. The structure is
people
+ person
++ name
++ picture
+ person
+ person
++ name
++ picture
+ person
people
We'll load the document into flash.
Then we'll loop through each person node and extract the name and picture values.
We push those values into a two dimensional array.
After we have inserted all the values into the array we'll get the length of the array.
We'll take that value and pass it into a random number generator.
We'll generate a number no greater that the array length minus one. (if there five people we need a number between zero and four since arrays start numbering at zero and if we returned five we would get an error.)
Then we'll take that number and use it to get a person from the array.
So if we have five people in the XML document we will generate a number ranging from zero through four
If we return the number three we get the fourth person in the XML document.
So we Just edit the XML document to add or remove people and never have to touch the flash source code to make changes.
Wednesday, December 13, 2006
A CMS In Ruby on Rails
I am starting to build a rails app for a content management system. I think this will be a little different than the ones I've seen. Meaning this will be used to manage various types of content not just update/manage web pages. Ok so that's old school CMS
I will be thinking out loud on this so we'll see if this holds true to my original thoughts.
I want to be able to create content, as in write an article about something. and that something might have a attachment to it. example, write about a white paper or some code and attach a zip file. Maybe I just want to upload an image/pdf. A message board?
It will have security on it. That is the part I am working on first.
I will be thinking out loud on this so we'll see if this holds true to my original thoughts.
I want to be able to create content, as in write an article about something. and that something might have a attachment to it. example, write about a white paper or some code and attach a zip file. Maybe I just want to upload an image/pdf. A message board?
It will have security on it. That is the part I am working on first.
Wednesday, May 03, 2006
Technology Review: Emerging Technologies and their Impact
Technology Review: Emerging Technologies and their Impact: "The Times Emulates Print on the Web
Microsoft and The New York Times have unveiled software that preserves the print edition's design online."
Something else to design for. Wee.
Microsoft and The New York Times have unveiled software that preserves the print edition's design online."
Something else to design for. Wee.
Monday, May 01, 2006
Thursday, April 27, 2006
Fuel Economy Tips from Car Talk
Car Talk: "You can walk, bike, or crawl! And there are other benefits, besides saving money on gas. When you walk, you'll get exercise and live longer. When you bike, you can stop and meet that new, single neighbor down the street. When you crawl, you could pick up loose change!"
MAKE: Blog: Daryl Hannah goes DIY at the Maker Faire
MAKE: Blog: Daryl Hannah goes DIY at the Maker Faire: "Daryl Hannah goes DIY at the Maker Faire"
Thursday, April 20, 2006
The Virtues of a Second Screen - New York Times
The Virtues of a Second Screen - New York Times: "Survey after survey shows that whether you measure your productivity in facts researched, alien spaceships vaporized, or articles written, adding an extra monitor will give your output a considerable boost — 20 percent to 30 percent, according to a survey by Jon Peddie Research."
I have to send this to the boss.
I have to send this to the boss.
Tuesday, April 11, 2006
Friday, April 07, 2006
iAlertU Puts Alarm on MacBook Pro || The Mac Observer
iAlertU Puts Alarm on MacBook Pro || The Mac Observer: "iAlertU, a utility that takes advantage of the motion sensor built into the MacBook Pro to sound an alarm when someone picks up the computer."
Thursday, April 06, 2006
Apple - Boot Camp
Apple - Boot Camp: "More and more people are buying and loving Macs. To make this choice simply irresistible, Apple will include technology in the next major release of Mac OS X, Leopard, that lets you install and run the Windows XP operating system on your Mac. Called Boot Camp (for now), you can download a public beta today."
Wednesday, April 05, 2006
Worst tech of 2006 (so far) - CNET.com
Worst tech of 2006 (so far) - CNET.com: "By Tim Moynihan, Michelle Thatcher, and Peter Butler (March 31, 2006)
Calling a piece of tech the 'best' often starts an argument, but just about everyone knows a lemon when they see it. December is a long way away, but we couldn't wait to put together a list of the worst tech, tech events, and downloads of 2006. If there's a particularly horrendous gadget or tech happening you think we've missed, let us know in our TalkBack section. Here we go, in no particular order..."
Calling a piece of tech the 'best' often starts an argument, but just about everyone knows a lemon when they see it. December is a long way away, but we couldn't wait to put together a list of the worst tech, tech events, and downloads of 2006. If there's a particularly horrendous gadget or tech happening you think we've missed, let us know in our TalkBack section. Here we go, in no particular order..."
Subscribe to:
Posts (Atom)