Skip to main content

Posts

Showing posts from December, 2009

Splinter Cell: Chaos Theory - disabling lights

Well, the right click (alt fire) on the suppressed pistol activates some magic device that can temporarily knock out a light - for about 10s or so. Why did I have to search on the internet and track down vague clues until I hit this page and found out for sure? Shouldn't there  be a manual somewhere? UPDATE: I gotta read the notes on the equipment screen more carefully...

UPDATE2: The manual is useful. Save trees/animal skins, don't print it out.

Max os x service start up : StartupItem

A good guide is available here

File:  /Library/StartupItems/RRiki/StartupParameters.plist:

{
 Description = "RRiki server";
 Provides    = ("RRiki");
 Uses        = ("Ruby");
 OrderPreference = "Last";
 Messages =
 {
  start = "Starting RRiki server";
  stop = "Stopping RRiki server";
  restart = "Restarting RRiki server";
 };
}

File: /Library/StartupItems/RRiki/RRiki

#!/bin/sh

##
# RRiki service startup script
##

. /etc/rc.common

StartService ()
{
    ConsoleMessage "Starting RRiki"
    cd /Users/kghose/Source/Rriki2/
    /usr/local/bin/thin start -eproduction -d
}

StopService ()
{
    ConsoleMessage "Stopping RRiki"
    cd /Users/kghose/Source/Rriki2/
    /usr/local/bin/thin stop 
}

RestartService ()
{
    ConsoleMessage "Restarting RRiki"
    cd /Users/kghose/Source/Rriki2/
    /usr/local/bin/thin restart -eproduction -d
}

RunService "$1"

To manipulate the service:
sudo Syste…

Calling an action when a selection box changes

in partial (view)

<%= select('history', 'sel', history_list, {:selected => selected}, {:class => 'historyselect'}) %>
<%= link_to_remote 'x',
      :url => {:controller => 'rriki',
               :action => 'clear_history'},
      :html => {:title => 'Clear history'},
      :method => :get %>
<%= observe_field 'history_sel',
    :url => {:controller => 'rriki',
             :action => 'select_item_in_history'},
    :with => 'history_sel' %>

changing the select will call the action select_item_in_history with params['history_sel'] set to the selected value.

Rails: Debugging form helpers generated with remote calls (AJAX)

When parts of a webpage are updated using AJAX calls (e.g remote functions) these updated parts do not show up when you ask Firefox for the webpage html (using CTRL+U). A hack to see the generated html from a suspect rails call is to simply print out the html on the webpage instead of executing it by doing:

<%=h ...rails command... %> Instead of

<%= ...rails command... %>

html_options for rails select tag

I had a select tag that I wanted to mess with a little to apply some styles etc. to. The select tag has an html_options hash and I was trying to use that. My initial attempt was

select('history', 'sel', history_list, html_options => {:class => 'historyselect'}) WRONG

This is not python, and even though the rails docs setout the syntax as:

select(object, method, choices, options = {}, html_options = {})

ruby can not accept keyword arguments. Only positional, so you have to do:

select('history', 'sel', history_list, {}, {:class => 'historyselect'})

The empty braces signify the empty 'options' argument, and the next set of braces signify the html_options hash