Displaying 20 results from an estimated 300 matches similar to: "More idiomatic way of doing this"
2006 Jun 30
4
More idiomatic way of writing a filter
Is there a more elegant way of writing this?
def verify_user
@user = User.find_by_username params[:username]
if @user.nil?
message = xml.error do |xm|
xm.message "User does not exists: #{params[:username]}"
end
render :xml => message
return false
else
true
end
end
Thanks, Joel
--
2009 Sep 09
4
what is the +hex in c++ stack traces?
What is the hex number after the method, e.g. +0x32f below?
It matches arg0 and I suspect it''s the c++ "this" pointer, aka hidden
first argument.
I would like to confirm, though.
Thanks, Joel
---
XUL`PresShell::ProcessReflowCommands(int)+0x32f
XUL`PresShell::FlushPendingNotifications(mozFlushType)
+0x19e
2006 Jun 28
2
undefined method `use_transactional_fixtures=''
Folks,
I checked my test_helper.rb and it has
self.use_transactional_fixtures = true
My code was generated with 1.1.2 and I''m using 1.1.3 right now after
but the error persists.
I googled for this issue and it appears that a require is missing or
something like that. I can''t figure it out, please help!
/opt/local/bin/ruby -Ilib:test
2011 Apr 29
1
importing and filtering time series data
Folks,
I'm new to R and would like to use it to analyze web server performance data.
I collect the data in this CSV format:
1304083104.41,Y,668.856249809
1304083104.41,Y,348.143193007
First column is a <seconds.microseconds> timestamp, rows with N instead of Y need to be skipped and the last column has the same format as the first column, except it's request duration (latency).
2011 May 01
1
microsecond timestamp support
Does R have support for microseconds in timestamps, e.g. when reading this in
"Time","Include","Kind","Duration"
2011-04-01 14:20:36.368324,Y,U,1.03238296509
2011-04-01 14:20:35.342732,Y,C,0.0252721309662
2011-04-01 14:20:34.337209,Y,R,0.00522899627686
Thanks, Joel
--------------------------------------------------------------------------
- for hire: mac
2009 Sep 09
4
usdt probes vs pid$target
I added a couple of static probes to Firefox to measure actual work
done. I could have used a pid$target probe with a function name but
work is done within an if statement, which is where I placed the
static probes.
I''m wondering about my use, though. Is the following significantly
more efficient than pid$target::FunName:entry and return?
I heard somewhere that $target does not
2009 Aug 28
13
putting a running app into trace mode
Suppose I have a USDT probe in Firefox and that I''m trying to catch
the startup with a probe like this:
proc:::exec-success
/execname == "firefox-bin"/
{
start = timestamp;
}
and stop tracing when Firefox hits this USDT probe:
mozilla:::main-entry
{
exit(0);
}
How do I put the running firefox-bin into "trace mode" so that my USDT
probe fires?
Thanks, Joel
2006 Jun 30
8
before_filter: nil vs. true vs. false
Folks,
My understanding of how filters work is that I should return true if
everything is ok and false if not. How does the filter below work
then (from the Rails Recipies book)?
It would return nil if there''s a user in the session. Does nil count
as true?
before_filter :check_authentication
def check_authentication
unless session[:user]
session[:intended_action] =
2009 Oct 28
3
where do kernel data types come from?
I have a script where I can freely reference struct nameidata*, struct
vnode*, etc. on Snow Leopard.
How does DTrace know about these data types? I understand things like
#pragma D depends_on library darwin.d
where darwin.d has typedefs.
I can''t find definitions of nameidata and vnode in any D scripts,
though. How does it work?
Thanks, Joel
---
firefox for android!
2006 Jun 23
2
Using fixtures from IRB
Folks,
I have the standard setup with auto-generated unit tests and
fixtures. I edited the fixtures and the tests but would now like to
test associations from irb. How do I do this?
I''m not sure how to load my fixtures into irb, for example. Once they
are loaded I would create objects, save them to the db and pull
things out.
Thanks, Joel
--
http://wagerlabs.com/
2009 Sep 09
10
dtrace overhead and proper measuring technique
I''m trying to time a function within Firefoxwith a pid$target probe
[2]. e.g
dtrace -Zqw -x dynvarsize=64m -x evaltime=preinit -p 13954 -s menu-
construct.d -s sigcont.d
elapsed: 12.7942481ms
cpu : 7.7911194ms
count : 40 times
I''m also measuring Firefox startup time by running it arguments like
this:
... file:///Users/joelr/work/mozilla/startup/startup.html#`python
2009 Sep 14
1
return from memset on mac osx
Does dtrace have a problem catching the return from memset on Mac OSX?
The script below catches the entry just fine but the return clause is
never entered.
Thanks, Joel
---
pid$target::memset:entry
/arg1 == 0/
{
self->size = arg2;
self->ts = timestamp;
self->vts = vtimestamp;
}
pid$target::memset:return
/self->size/
{
@ts = sum(timestamp - self->ts);
@vts =
2006 Jan 04
0
OT: Displaying errors on credit-card processing
Hi,
This question isn''t Rails-specific, but since Basecamp (& the family
of premium 37signals apps) have the best implementation of credit-card
processing I''ve seen, I''m hoping maybe DHH could lend an answer. Of
course, anyone is welcome to chime in!
# Some background
Our nonprofit is building a Rails-driven store and donation center and
our developer is
2006 May 02
0
Model validation when using ajax & form_remote_tag...
I am trying to understand why model validation error reporting in Rails
is so complicated compared to non ajax model validation. In my normal
form I use <%= error_messages_for ''user'' %> in my view and I get a nice
error message displayed when the user inputs invalid information into
the form.
When I convert that form to use Ajax using form_remote_tag the
2007 Oct 27
2
render_with_no_layout cause by Pingdom
Hi,
When I go to my homepage all is well, however when the Pingdom bot
arrives (every few seconds!), it throws the following error:
ActionController::RenderError occurred in home#index:
You called render with invalid options : available
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb:808:in
`render_with_no_layout''
My index action doesn''t call render, it
2006 Jun 11
3
Armageddon
I''m just wondering what happened to Armageddon and whether people had
any more information/news about it. I''ve thought about comet but I think
that a flash socket would be easier to implement. Does Armageddon have
the same drawbacks as other flash sockets, namely not working over port
80 (so the companies firewall blocks it)?
--
Posted via http://www.ruby-forum.com/.
2014 Sep 15
1
Issue creating mailboxes
CentOS 6.5, cyrus-imapd 2.3.16-6
So, I gather you're supposed to create mailboxes called user.<username>
But I wind up with user^<username>, and mailbox can't be found.
[joliver at localhost ~]$ cyradm -u testuser1 localhost
Password:
localhost> cm user.testuser2
localhost> cm user.testuser3
localhost> cm user.textuser4
[joliver at localhost ~]$ sudo ls -l
2008 Nov 05
3
Problems w/ before_filter getting ignored
Hello,
I''m setting up an authentication module that will be called from
application.rb. I want to save a rrequest.request_uri into a
session to be used as a place holder that
will take users back to the page they were on before they logged in.
I''m trying to call the store_location method for all methods EXCEPT
login by putting login in an except before filter.
For some
2006 Jun 29
0
@response.body accumulating in functional tests?
I have two functional tests for my user controller:
def test_bad_registration
post :register, :email => "tester1@foo.com"
assert_response :success
assert_not_nil @response.body =~ /^\<error/
assert_nil assigns[''user'']
end
def test_good_registration
@response.body = nil
post :register, :username => "tester",
2006 Jun 30
0
Storing additional data in the session
Folks,
I''m using the session db table to store additional data. When a user
logins I would like to store their user id in the session record and
save that.
I''m thinking of x = Session.find(session.id) and then x.save.
Is this the right way to do it?
Thanks, Joel
--
http://wagerlabs.com/