parameters

Perl: Named parameters validation best practice

人盡茶涼 提交于 2019-12-22 10:29:15
问题 I am using named parameters in class method calls and was wondering if there is a best practice to make sure no unknown parameters are passed. Here's what I am doing sub classmethod { my $self = shift; my %args = ( "param1" => "default1", "param2" => "default2", @_ ) if (my @invalid = grep { !/^(param1|param2)$/ } keys %args) { croak "received unknown arg(s) ".join(",", @invalid)." from ".caller(); } } Is that a proper way to go forward, or could this cause a performance problem? Best, Marcus

rails link_to remote with params

守給你的承諾、 提交于 2019-12-22 09:57:33
问题 I'd like to trigger a remote action for a model using a link. Basically all this link needs to do is trigger a method with one parameter. Here's my code: = link_to 'Move Up', reorder_collection_folder_path(@collection, folder), :reorder => :up, :remote => true This does trigger the Folders#reorder controller action as expected, but the :reorder param is not being passed through. My log says: Started GET "/collections/1/folders/1/reorder" for 127.0.0.1 at 2011-03-01 18:03:31 -0600 Processing

Socket.io send disconnect event with parameter

喜欢而已 提交于 2019-12-22 09:48:41
问题 I want to send disconnect event manually with custom parameter to socket.io server. I use this function but won't work: //client var userId = 23; socket.disconnect(user); //Server socket.on('disconnect', function (data) { console.log('DISCONNECT: '+ data) }) Now how can I send a additional data to server when disconnect event sent? 回答1: Socket IO's disconnect event is fired internally but you can emit a custom event when it is called. You need to first listen for the disconnect event. Once

Is it possible to force PowerShell script to throw if a required *pipeline* parameter is omitted?

℡╲_俬逩灬. 提交于 2019-12-22 09:46:11
问题 Interactive PowerShell sessions prompt the user when a required parameter is omitted. Shay Levy offers a workaround to this problem. The problem is that workaround does not work when you use the pipeline to bind parameters. Consider this example: function f { [CmdletBinding()] param ( [Parameter(ValueFromPipeLineByPropertyName=$true)] [ValidateNotNullOrEmpty()] [string]$a=$(throw "a is mandatory, please provide a value.") ) process{} } $o = New-Object psobject -Property @{a=1} $o | f This

Accessing URL parameters in Oracle Forms / OC4J

旧城冷巷雨未停 提交于 2019-12-22 09:34:08
问题 How do I access parameters passed into an Oracle Form via a URL. Eg given the url: http://example.com/forms90/f90servlet?config=cust&form='a_form'&p1=something&p2=else This will launch the 'a_form' form, using the 'cust' configuration, but I can't work how (or even if it's possible) to access p1 (with value of 'something') p2 (with value of 'else') Does anyone know how I can do this? (Or even if it is/isn't possible? Thanks 回答1: Within Forms you can refer to the parameters p1 an p2 as follows

MVC3: button to send both form (model) values and an extra parameter

主宰稳场 提交于 2019-12-22 08:47:18
问题 In an MVC3 project, i use an Html.BeginForm to post some (model-)values. Along with those i want to send an extra parameter that is not part of the form (the model) but in the ViewBag. Now, when i use a Button (code in answer here: MVC3 razor Error in creating HtmlButtonExtension), all the form values are posted but the extra parameter remains null. When i use an ActionLink, the parameter is posted but the form values are not :) Any know how i can combine the two? Thanks! @Html.Button(

How to access literal wildcard argument before it's expanded to matching files?

♀尐吖头ヾ 提交于 2019-12-22 08:22:50
问题 Background: I'm writing a bash script that must receive these arguments: a file name (a file containing a set of rules ) a list of file names ( files to be processed, can use wildcards) a destination folder ( where processed versions of files will be stored ) In theory there are 3 parameters but in reality the second argument expands, so the real number of argument varies if the wildcard matches more than one file: When I call ./myscript file.conf *.data dest_foder *.data expands into as many

How to add a post parameter to manual form submission?

自闭症网瘾萝莉.ら 提交于 2019-12-22 08:22:15
问题 I want to submit a form manually after some complicated checks. Because checks involve user interaction, the whole check process is not done synchronously. Here is the scenario: User clicks a button (an HTML <button id='button-id'> tag) I prevent the default action of the button (which is the form submission) I do a complicated check. Somewhere in the check process, I show a dialog and wait for the user to respond (here, the original check function proceeds and returns) I provide a callback

Check if parameter is NULL within WHERE clause

淺唱寂寞╮ 提交于 2019-12-22 07:08:22
问题 I´m having trouble with a Stored Procedure that takes about forever to execute. It is quite large and I can understand that I´ll take some time but this one continues for almost 20 minutes. After some debugging and researching I noticed that replacing this part of the WHERE clause; ((p_DrumNo IS NULL) OR T_ORDER.ORDER_ID IN (SELECT ORDER_ID FROM ORDERDELIVERY)) made a HUGE difference. So the Procedure works just fine as long as p_DrumNo is NULL or I modify the above to not check if p_DrumNo

Pass a value to a specific parameter without caring about the position of the parameter [duplicate]

烂漫一生 提交于 2019-12-22 05:59:33
问题 This question already has answers here : Is there a way to provide named parameters in a function call in JavaScript? (10 answers) Closed 4 years ago . I was wondering if it is possible to pass a value to a specific parameter by for example specifying its name, not taking into account if this parameter is the first, the second or the 100th one. For example, in Python you can do it easily like: def myFunction(x, y): pass myFunction(y=3); I really need to pass a value to a specific parameter of