Search Results

Search found 8391 results on 336 pages for 'partial hash arguments'.

Page 10/336 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Passing arguments and values form HTML to jQuery (events)

    - by Jaroslav Moravec
    What is the practice to pass arguments from HTML to jQuery events function. For example getting id of row from db: <tr class="jq_killMe" id="thisItemId-id"> ... </tr> and jQuery: $(".jq_killMe").click(function () { var tmp = $(this).attr('id).split("-"); var id = tmp[0] // ... } What's the best practise, if I want to pass more than one argument? Is it better not to use jQuery? For example: <tr onclick="killMe('id')"> ... </tr> I didn't find the answer on my question, I will be glad even for links. Thanks.

    Read the article

  • Default Arguments in Matlab

    - by Scott
    Hello. Is it possible to have default arguments in Matlab? For instance, here: function wave(a,b,n,k,T,f,flag,fTrue=inline('0')) I would like to have the true solution be an optional argument to the wave function. If it is possible, can anyone demonstrate the proper way to do this? Currently, I am trying what I posted above and I get: ??? Error: File: wave.m Line: 1 Column: 37 The expression to the left of the equals sign is not a valid target for an assignment. Thanks!

    Read the article

  • How does R treat positional arguments

    - by inspectorG4dget
    I'm a python guy and very new to R (so far, all I've done is copy-paste code and screen-shot the resulting, graph). I would now like to actually learn the language so that I can draw useful plots (right now, I am trying to plot this). In attempting my first plot, I came across this function call: sets_options("universe", seq(from = 0, to = 25, by = 0.1)) Now, I would like to know if I can achieve the same result by calling sets_options("universe", seq(0, 25, 0.1)) The help page for seq doesn't speak to this specifically (or I'm not reading it correctly), so I was hoping someone could shed some light on how R handles positional arguments I tried calling the function that way in R and it worked (no syntax errors, etc), but I don't know how to test the output of that function, so I'm forced to ask here

    Read the article

  • c++: truth assignment warning with arguments?

    - by John
    I use the following to work with arguments in my programs, but it seems to just hand me a warning (just a warning): "warning: suggest parentheses around assignment used as truth value" The beginning of the code is as follows: enum{OPT_DISP_H = 0x2, OPT_DISP_W = 0x1}; int main(int argc, char *argv[]) { int opt = 0x00; char c; while((++argv)[0] && argv[0][0]=='-'){ while(c =* ++argv[0]) switch(c){ case 'h': opt |= OPT_DISP_H; break; //etc.. The while(c =* ++argv[0]) part being where the warning persists. The code works fine, but what does this warning mean opposed to what is used? I think the code is c = *++argv[0], using the pointer. So why does the single = work and what is really recommended to be used?

    Read the article

  • Issue with class template partial specialization

    - by DeadMG
    I've been trying to implement a function that needs partial template specializations and fallen back to the static struct technique, and I'm having a number of problems. template<typename T> struct PushImpl<const T&> { typedef T* result_type; typedef const T& argument_type; template<int StackSize> static result_type Push(IStack<StackSize>* sptr, argument_type ref) { // Code if the template is T& } }; template<typename T> struct PushImpl<const T*> { typedef T* result_type; typedef const T* argument_type; template<int StackSize> static result_type Push(IStack<StackSize>* sptr, argument_type ptr) { return PushImpl<const T&>::Push(sptr, *ptr); } }; template<typename T> struct PushImpl { typedef T* result_type; typedef const T& argument_type; template<int StackSize> static result_type Push(IStack<StackSize>* sptr, argument_type ref) { // Code if the template is neither T* nor T& } }; template<typename T> typename PushImpl<T>::result_type Push(typename PushImpl<T>::argument_type ref) { return PushImpl<T>::Push(this, ref); } First: The struct is nested inside another class (the one that offers Push as a member func), but it can't access the template parameter (StackSize), even though my other nested classes all could. I've worked around it, but it would be cleaner if they could just access StackSize like a normal class. Second: The compiler complains that it doesn't use or can't deduce T. Really? Thirdly: The compiler complains that it can't specialize a template in the current scope (class scope). I can't see what the problem is. Have I accidentally invoked some bad syntax?

    Read the article

  • New Perl user: using a hash of arrays

    - by Zach H
    I'm doing a little datamining project where a perl script grabs info from a SQL database and parses it. The data consists of several timestamps. I want to find how many of a particular type of timestamp exist on any particular day. Unfortunately, this is my first perl script, and the nature of perl when it comes to hashes and arrays is confusing me quite a bit. Code segment: my %values=();#A hash of the total values of each type of data of each day. #The key is the day, and each key stores an array of each of the values I need. my @proposal; #[drafted timestamp(0), submitted timestamp(1), attny approved timestamp(2),Organiziation approved timestamp(3), Other approval timestamp(4), Approved Timestamp(5)] while(@proposal=$sqlresults->fetchrow_array()){ #TODO: check to make sure proposal is valid #Increment the number of timestamps of each type on each particular date my $i; for($i=0;$i<=5;$i++) $values{$proposal[$i]}[$i]++; #Update rolling average of daily #TODO: To check total load, increment total load on all dates between attourney approve date and accepted date for($i=$proposal[1];$i<=$proposal[2];$i++) $values{$i}[6]++; } I keep getting syntax errors inside the for loops incrementing values. Also, considering that I'm using strict and warnings, will Perl auto-create arrays of the right values when I'm accessing them inside the hash, or will I get out-of bounds errors everywhere? Thanks for any help, Zach

    Read the article

  • Iterating Over Params Hash

    - by Joe Clark
    I'm having an extremely frustrating time getting some images to upload. They are obviously being uploaded as rack/multipart but the way that I'm iterating over my params hash must be causing the problem. I could REALLY use some help, so I can stop pulling out my hair. So I've got a params hash that looks like this: Parameters: {"commit"=>"Submit", "sighting_report"=>[{"number_seen"=>"1", "picture"=>#<File:/var/folders/IX/IXXrbzpCHkq68OuyY-yoI++++TI/-Tmp-/RackMultipart.85991.5>, "species_id"=>"2"}], "authenticity_token"=>"u0eN5MAfvGWtfEzrqBt4qfrL54VJ9SGX0jFLZCJ8iRM=", "sighting"=>{"sighting_date(2i)"=>"6", "name"=>"", "sighting_date(3i)"=>"5", "county"=>"0", "notes"=>"", "location"=>"", "sighting_date(1i)"=>"2010", "email"=>""}} My form can have multiple sighting reports with multiple pictures in each sighting report. Here's my controller code: def create_multiple @report = Report.new @report.name = params[:sighting]["name"] @report.sighting_date = Date.civil(params[:sighting][:"sighting_date(1i)"].to_i, params[:sighting][:"sighting_date(2i)"].to_i, params[:sighting][:"sighting_date(3i)"].to_i) @report.county_id = params[:sighting][:county] @report.location = params[:sighting][:location] @report.notes = params[:sighting][:notes] @report.email = params[:sighting][:email] @report.save! @report.reload for sr in params[:sighting_report] do sighting = SightingReport.new sighting.report_id = @report.id sighting.species_id = sr[:species_id] sighting.number_seen = sr[:number_seen] sighting.save if sr[:picture] sighting.reload for pic in sr[:picture] do p = SpeciesPic.new p.uploaded_picture = pic p.species_id = sighting.species_id p.report_id = @report.id p.save! end end end redirect_to :action => 'new_multiple' end

    Read the article

  • Problem storing a hash in DB using Storable::nfreeze in Perl

    - by Sam
    I want to insert a hash in the db using Storable::nfreeze but the data is not inserted properly. My code is as follows: %rec=(); $rec{'name'} = 'my name'; $rec{'address'} = 'my address'; my $order1 = new Order(); $order1->set_session(\%rec); $self->createOrder($order1); sub createOrder { my $self = $_[0]; my $order = $_[1]; # Retrieve the fields to insert into the database. my $st = $dbh->prepare("insert into order (session,.......) values(?,........)"); my $session = %{$order->get_session()}; $st->execute(&Storable::nfreeze(\%session),.....); $st->finish(); } sub getOrder { ... my $session = &Storable::thaw( $ref->{'session'} ); ..... } The thaw is working fine because I tested it withe some rows that have been inserted correctly, but when I try to get a row that was inserted using the createOrder subroutine, I get an error saying: Storable binary image v36.65 more recent than I am (v2.7) at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al) line 415 The error comes from the line that have thaw. The nfreeze did not store the hash properly. Can someone point me to what I'm doing wrong in the createOrder subroutine? I know the module version have nothing to do with the problem.

    Read the article

  • problem storing a hash in DB using Storage::nfreeze Perl

    - by Sam
    Hello, I want to insert a hash in the db using Storage::nfreeze but the data is not inserted properly. the code is as follow: %rec=(); $rec{'name'} = 'my name'; $rec{'address'} = 'my address'; my $order1 = new Order(); $order1->set_session(\%rec); $self->createOrder($order1); sub createOrder { my $self = $_[0]; my $order = $_[1]; # Retrieve the fields to insert into the database. my $st = $dbh->prepare("insert into order (session,.......) values(?,........)"); my $session = %{$order->get_session()}; $st->execute(&Storable::nfreeze(\%session),.....); $st->finish(); } sub getOrder { ... my $session = &Storable::thaw( $ref->{'session'} ); ..... } the thaw is working fine because I tested it withe some rows that have been inserted correctly. but when I try to get a row that was inserted using the createOrder subroutine, I get an error saying" Storable binary image v36.65 more recent than I am (v2.7) at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al) line 415 the error comes from the line that have thaw. the nfreeze did not store the hash properly. Can someone point me to what i m doing wrong in the createOrder subroutine? Thanks in advance. I know the module version have nothing to do with the problem.

    Read the article

  • Technical choices in unmarshaling hash-consed data

    - by Pascal Cuoq
    There seems to be quite a bit of folklore knowledge floating about in restricted circles about the pitfalls of hash-consing combined with marshaling-unmarshaling of data. I am looking for citable references to these tidbits. For instance, someone once pointed me to library aterm and mentioned that the authors had clearly thought about this and that the representation on disk was bottom-up (children of a node come before the node itself in the data stream). This is indeed the right way to do things when you need to re-share each node (with a possible identical node already in memory). This re-sharing pass needs to be done bottom-up, so the unmarshaling itself might as well be, too, so that it's possible to do everything in a single pass. I am in the process of describing difficulties encountered in our own context, and the solutions we found. I would appreciate any citable reference to the kind of aforementioned folklore knowledge. Some people obviously have encountered the problems before (the aterm library is only one example). But I didn't find anything in writing. Even the little piece of information I have about aterm is hear-say. I am not worried it's not reliable (you can't make this up), but "personal communication" and "look how it's done in the source code" are considered poor form in citations. I have enough references on hash-consing alone. I am only interested in references where it interferes with other aspects of programming, such as marshaling or distribution.

    Read the article

  • x86_64 Assembly Command Line Arguments

    - by Brandon oubiub
    I'm new to assembly, and I just got familiar with the call stack, so bare with me. To get the command line arguments in x86_64 on Mac OS X, I can do the following: _main: sub rsp, 8 ; 16 bit stack alignment mov rax, 0 mov rdi, format mov rsi, [rsp + 32] call _printf Where format is "%s". rsi gets set to argv[0]. So, from this, I drew out what (I think) the stack looks like initially: top of stack <- rsp after alignment return address <- rsp at beginning (aligned rsp + 8) [something] <- rsp + 16 argc <- rsp + 24 argv[0] <- rsp + 32 argv[1] <- rsp + 40 ... ... bottom of stack And so on. Sorry if that's hard to read. I'm wondering what [something] is. After a few tests, I find that it is usually just 0. However, occasionally, it is some (seemingly) random number. EDIT: Also, could you tell me if the rest of my stack drawing is correct?

    Read the article

  • Passing arguments and values from HTML to jQuery (events)

    - by Jaroslav Moravec
    What is the practice to pass arguments from HTML to jQuery events function. For example getting id of row from db: <tr class="jq_killMe" id="thisItemId-id"> ... </tr> and jQuery: $(".jq_killMe").click(function () { var tmp = $(this).attr('id).split("-"); var id = tmp[0] // ... } What's the best practise, if I want to pass more than one argument? Is it better not to use jQuery? For example: <tr onclick="killMe('id')"> ... </tr> I didn't find the answer on my question, I will be glad even for links. Thanks. Edit (pre solution) So you suggested two methods to do that: Add custom attributes to element (XHTML) Use attribute ID and parse it by regex Attribute data-* attributes in HTML5 Use hidden children elements I like first solution, but... I would like to (I have to (employer)) produce valid code. Here is a nice question and answers: http://stackoverflow.com/questions/994856/so-what-if-custom-html-attributes-arent-valid-xhtml And the second is not so pretty as the first, but valid. So the compromise is... The third is the solution for future, but here is a lot of CMS where we have to use XHTML or HTML4. (And HTML5 is the long process)

    Read the article

  • Hash#key for 1.8.6

    - by Tobias
    Greetings, I am trying to make my 1.9.1 source 1.8.6 compatible. I recognized that there's no Hash#key method. Any idea or method how to solve that? Thanks! Tobias

    Read the article

  • SQL Server 2000, yes 2000 password hash

    - by Justin808
    I need to store a password has in a SQL server 2000 database. The information isn't critical but I really don't want to store the password in clear text. How can I get a unique hash (sha, sha1, md5, etc) in SQL server 2000 as HashBytes isn't available. I'm not looking for compiled DLL or the ilk, I dont have access to the server, needs to be pure MS SQL.

    Read the article

  • setting ruby hash .default to a list

    - by matpalm
    i thought i understood what the default method does to a hash... give a default value for a key if it doesn't exist irb(main):001:0> a = {} => {} irb(main):002:0> a.default = 4 => 4 irb(main):003:0> a[8] => 4 irb(main):004:0> a[9] += 1 => 5 irb(main):005:0> a => {9=>5} all good. but if i set the default to be a empty list, or empty hash, i dont understand it's behaviour at all.... irb(main):001:0> a = {} => {} irb(main):002:0> a.default = [] => [] irb(main):003:0> a[8] << 9 => [9] # great! irb(main):004:0> a => {} # ?! would have expected {8=>[9]} irb(main):005:0> a[8] => [8] # awesome! irb(main):006:0> a[9] => [9] # unawesome! shouldn't this be [] ?? i was hoping / expecting the same behaviour as if i had used the ||= operator... irb(main):001:0> a = {} => {} irb(main):002:0> a[8] ||= [] => [] irb(main):003:0> a[8] << 9 => [9] irb(main):004:0> a => {8=>[9]} irb(main):005:0> a[9] => nil can anyone explain what is going on ???

    Read the article

  • computing hash values, integral types versus struct/class

    - by aaa
    hello I would like to know if there is a difference in speed between computing hash value (for example std::map key) of primitive integral type, such as int64_t and pod type, for example struct { int16_t v[4]; };. I know this is going to implementation specific, so my question ultimately pertains to gnu standard library. Thanks

    Read the article

  • Good Hash Function for Strings

    - by Leif Andersen
    I'm trying to think up a good hash function for strings. And I was thinking it might be a good idea to sum up the unicode values for the first five characters in the string (assuming it has five, otherwise stop where it ends). Would that be a good idea, or is it a bad one? I am doing this in Java, but I wouldn't imagine that would make much of a difference.

    Read the article

  • Use hash or case-statement [Ruby]

    - by user94154
    Generally which is better to use?: case n when 'foo' result = 'bar' when 'peanut butter' result = 'jelly' when 'stack' result = 'overflow' return result or map = {'foo' => 'bar', 'peanut butter' => 'jelly', 'stack' => 'overflow'} return map[n] More specifically, when should I use case-statements and when should I simply use a hash?

    Read the article

  • hash password in mssql (asp.net)

    - by ile
    Is this how hashed password stored in mssql should look like? This is function I use to hash password (I found it in some tutorial) public string EncryptPassword(string password) { //we use codepage 1252 because that is what sql server uses byte[] pwdBytes = Encoding.GetEncoding(1252).GetBytes(password); byte[] hashBytes = System.Security.Cryptography.MD5.Create().ComputeHash(pwdBytes); return Encoding.GetEncoding(1252).GetString(hashBytes); } Thanks, Ile

    Read the article

  • Perl, convert hash to array

    - by Mike
    If I have a hash in Perl that contains complete and sequential integer mappings (ie, all keys from from 0 to n are mapped to something), is there a means of converting this to an Array? I know I could iterate over the key/value pairs and place them into a new array, but something tells me there should be a built-in means of doing this.

    Read the article

  • Resolve a URL from a Partial View (ASP.NET MVC)

    Working on an ASP.NET MVC application and needed the ability to resolve a URL from a partial view. For example, I have an image I want to display, but I need to resolve the virtual path (say, ~/Content/Images/New.png) into a relative path that the browser can use, such as ../../Content/Images/New.png or /MyAppName/Content/Images/New.png. Astandard view derives from the System.Web.UI.Page class, meaning you have access to the ResolveUrl and ResolveClientUrl methods. Consequently, you can write markup/code like the following:' /The problem is that the above code does not work as expected in a partial view. What's a little confusing is that while the above code compiles and the page, when visited through a browser, renders, the call to Page.ResolveClientUrl returns precisely what you pass in, ~/Content/Images/New.png, in this instance. The browser doesn't know what to do with ~, it presumes it's part of the URL, so it sends the request to the server for the image with the ~ in the URL, which results in a broken image.I did a bit of searching online and found this handy tip from Stephen Walther - Using ResolveUrl in an HTML Helper. In a nutshell, Stephen shows how to create an extension method for the HtmlHelper class that uses the UrlHelper class to resolve a URL. Specifically, Stephen shows how to add an Image extension method to HtmlHelper. I incorporated Stephen's code into my codebase and also created a more generic extension method, which I named ResolveUrl.public static MvcHtmlString ResolveUrl(this HtmlHelper htmlHelper, string url) { var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext); return MvcHtmlString.Create(urlHelper.Content(url)); }With this method in place you can resolve a URL in a partial view like so:' /Or you could use Stephen's Html.Image extension method (althoughmy more generic Html.ResolveUrl method could be used in non-image related scenarios where you needed to get a relative URL from a virtual one in a partial view). Thanks for the helpful tip, Stephen!Happy Programming!Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Resolve a URL from a Partial View (ASP.NET MVC)

    Working on an ASP.NET MVC application and needed the ability to resolve a URL from a partial view. For example, I have an image I want to display, but I need to resolve the virtual path (say, ~/Content/Images/New.png) into a relative path that the browser can use, such as ../../Content/Images/New.png or /MyAppName/Content/Images/New.png. Astandard view derives from the System.Web.UI.Page class, meaning you have access to the ResolveUrl and ResolveClientUrl methods. Consequently, you can write markup/code like the following:' /The problem is that the above code does not work as expected in a partial view. What's a little confusing is that while the above code compiles and the page, when visited through a browser, renders, the call to Page.ResolveClientUrl returns precisely what you pass in, ~/Content/Images/New.png, in this instance. The browser doesn't know what to do with ~, it presumes it's part of the URL, so it sends the request to the server for the image with the ~ in the URL, which results in a broken image.I did a bit of searching online and found this handy tip from Stephen Walther - Using ResolveUrl in an HTML Helper. In a nutshell, Stephen shows how to create an extension method for the HtmlHelper class that uses the UrlHelper class to resolve a URL. Specifically, Stephen shows how to add an Image extension method to HtmlHelper. I incorporated Stephen's code into my codebase and also created a more generic extension method, which I named ResolveUrl.public static MvcHtmlString ResolveUrl(this HtmlHelper htmlHelper, string url) { var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext); return MvcHtmlString.Create(urlHelper.Content(url)); }With this method in place you can resolve a URL in a partial view like so:' /Or you could use Stephen's Html.Image extension method (althoughmy more generic Html.ResolveUrl method could be used in non-image related scenarios where you needed to get a relative URL from a virtual one in a partial view). Thanks for the helpful tip, Stephen!Happy Programming!Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Mathematica: get number of arguments passed to a function?

    - by dbjohn
    How do I get the number of arguments passed to a function, such as Plus[2,3,4,5] has 4 arguments passed to it. I was thinking it may involve the use of the function Length and getting the arguments into a list. The intention is to iterate an operation based on the number of arguments for a function. There is probably a simple solution or function but I haven't come across it yet. Any other ways or suggestions are welcome as well?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >