Search Results

Search found 4088 results on 164 pages for 'params keyword'.

Page 126/164 | < Previous Page | 122 123 124 125 126 127 128 129 130 131 132 133  | Next Page >

  • c# - best way to initialize an array of reference type object

    - by lidong
    I wonder if there is better way to initialize an array of reference type object, like this. Queue<int>[] queues = new Queue<int>[10]; for (int i = 0; i < queues.Length; i++) { queues[i] = new Queue<int>(); } I tried Enumerable.Repeat, but all elements in the array refer to same instance, Queue<int>[] queues = Enumerable.Repeat(new Queue<int>(), 10).ToArray(); I also tried Array.ForEach, but it doesn't work without ref keyword: Queue<int>[] queues = Array.ForEach(queues, queue => queue = new Queue<int>()); any other idea?

    Read the article

  • How to override virtual function in good style? [C++]

    - by Knowing me knowing you
    Hi, guys I know this question is very basic but I've met in few publications (websites, books) different style of override virtual function. What I mean is: if I have base class: class Base { public: virtual void f() = 0; }; in some publications I saw that to override this some authors would just say: void f(); and some would still repeat the virtual keyword before void. Which form of overwriting is in good style? Thank you for your answers.

    Read the article

  • Rails modeling for a user

    - by Trevor Hartman
    When building a rails app that allows a User to login and create data, is it best to setup a belongs_to :user association on every single model? For example, let's say a user can create Favorites, Colors and Tags. And let's say Favorites has_many :tags and Colors also has_many :tags. Is it still important for Tags to belong_to :user assuming the User is the only person who has authority to edit those tags? And a similar question along the same lines: When updating data in FavoritesController, I've come to the conclusion that you perform CRUD operations by always doing something like User.favorites.find(params[:id].update_attributes(param[:favorite]) so that they can definitely only update models that belong to them. Right?

    Read the article

  • IE8 is still caching my requests even with mathrandom.

    - by Ozaki
    TLDR IE is still caching my requests even with Math.random() included in the URL. So I added math random onto the end of my url: var MYKMLURL = 'http://' + host + 'data/pattern?key='+ Math.random(); I also added math random onto my function param: window.setTimeout(RefreshPatternData, 1000, MYKMLLAYER); function RefreshPatternData(layer) { layer.loaded = false; layer.setVisibility(true); layer.refresh({ force: true, params: { 'key': Math.random()} }); setTimeout(RefreshPatternData, 30000, MYKMLLAYER); } So the request appears as http://host/data/pattern?key=35678652545 etc. It changes everytime the request is made. It works in Firefox & Chrome & Safari etc. But IE8 is still caching the data and not updating my layer. Any ideas as to why this might be occuring?

    Read the article

  • How to model a relationship that NHibernate (or Hibernate) doesn’t easily support

    - by MylesRip
    I have a situation in which the ideal relationship, I believe, would involve Value Object Inheritance. This is unfortunately not supported in NHibernate so any solution I come up with will be less than perfect. Let’s say that: “Item” entities have a “Location” that can be in one of multiple different formats. These formats are completely different with no overlapping fields. We will deal with each Location in the format that is provided in the data with no attempt to convert from one format to another. Each Item has exactly one Location. “SpecialItem” is a subtype of Item, however, that is unique in that it has exactly two Locations. “Group” entities aggregate Items. “LocationGroup” is as subtype of Group. LocationGroup also has a single Location that can be in any of the formats as described above. Although I’m interested in Items by Group, I’m also interested in being able to find all items with the same Location, regardless of which group they are in. I apologize for the number of stipulations listed above, but I’m afraid that simplifying it any further wouldn’t really reflect the difficulties of the situation. Here is how the above could be diagrammed: Mapping Dilemma Diagram: (http://www.freeimagehosting.net/uploads/592ad48b1a.jpg) (I tried placing the diagram inline, but Stack Overflow won't allow that until I have accumulated more points. I understand the reasoning behind it, but it is a bit inconvenient for now.) Hmmm... Apparently I can't have multiple links either. :-( Analyzing the above, I make the following observations: I treat Locations polymorphically, referring to the supertype rather than the subtype. Logically, Locations should be “Value Objects” rather than entities since it is meaningless to differentiate between two Location objects that have all the same values. Thus equality between Locations should be based on field comparisons, not identifiers. Also, value objects should be immutable and shared references should not be allowed. Using NHibernate (or Hibernate) one would typically map value objects using the “component” keyword which would cause the fields of the class to be mapped directly into the database table that represents the containing class. Put another way, there would not be a separate “Locations” table in the database (and Locations would therefore have no identifiers). NHibernate (or Hibernate) do not currently support inheritance for value objects. My choices as I see them are: Ignore the fact that Locations should be value objects and map them as entities. This would take care of the inheritance mapping issues since NHibernate supports entity inheritance. The downside is that I then have to deal with aliasing issues. (Meaning that if multiple objects share a reference to the same Location, then changing values for one object’s Location would cause the location to change for other objects that share the reference the same Location record.) I want to avoid this if possible. Another downside is that entities are typically compared by their IDs. This would mean that two Location objects would be considered not equal even if the values of all their fields are the same. This would be invalid and unacceptable from the business perspective. Flatten Locations into a single class so that there are no longer inheritance relationships for Locations. This would allow Locations to be treated as value objects which could easily be handled by using “component” mapping in NHibernate. The downside in this case would be that the domain model becomes weaker, more fragile and less maintainable. Do some “creative” mapping in the hbm files in order to force Location fields to be mapped into the containing entities’ tables without using the “component” keyword. This approach is described by Colin Jack here. My situation is more complicated than the one he describes due to the fact that SpecialItem has a second Location and the fact that a different entity, LocatedGroup, also has Locations. I could probably get it to work, but the mappings would be non-intuitive and therefore hard to understand and maintain by other developers in the future. Also, I suspect that these tricky mappings would likely not be possible using Fluent NHibernate so I would use the advantages of using that tool, at least in that situation. Surely others out there have run into similar situations. I’m hoping someone who has “been there, done that” can share some wisdom. :-) So here’s the question… Which approach should be preferred in this situation? Why?

    Read the article

  • PHP: Return string between two characters

    - by Nic Hubbard
    I am wanting to use "keywords" within a large string. These keywords start and end using *my_keyword* and are user defined. How, within a large string, can I search and find what is between the two * characters and return each instance? The reason it might change it, that parts of the keywords can be user defined, such as *page_date_Y* which might show the year in which the page was created. So, again, I just need to do a search and return what is between those * characters. Is this possible, or is there a better way of doing this if I don't know the "keyword" length or what i might be?

    Read the article

  • Header files in C++

    - by user269037
    Hi, I am making a simulator and have written lots of files and headers. The problem is whenever I include a file I give the relative path of the particular file. For example a typical code in my application would begin like ifndef AI_H define AI_H include include "../world/world.h" include "pathPlan.h" include "skills/tryskill.h" include "../info/condition.h" include "dataStructures/destination.h" include "../params/gamePlay.h" include "../modules/controlModule.h" class ai { public: etc etc I want to avoid using the relative paths. For example I want to directly include "tryskill.h" and "destination.h" without giving the absolute paths. That way I wont need to bother if I change the location of any particular file. I am using Ubuntu 9.10. Any help would be highly appreciated.

    Read the article

  • How do I use a graphics method to pass parameters? Example is below.

    - by sonny5
    private static void getCorners(out float Wx, out float Wy, out float Vx, out float Vy) { // note-- I don't know how to flip the Y axis using this method... this is not a "graphics" method // In other words, I should use something like: // flipY(object sender, System.EventArgs e); // but don't know the syntax or whatever // I tried to do this: //Graphics g = this.CreateGraphic //Matrix myMatrix2 = new Matrix(1, 0, 0, -1, 0, 0); // flip Y axis //g.Transform = myMatrix2; //g.TranslateTransform(0, 480, MatrixOrder.Append); // ...but I get the error: // error CS0026: Keyword 'this' is not valid in a static property, static method, or // static field initializer Wx = 1.00F; Wy = 1.00F; // make this 1.00 (not 3.00F) down from the TOP since cannot get Y flipped Vx = ((Wx- WXmin)*((VXmax-VXmin)+VXmin)/(WXmax-WXmin)); Vy = ((Wy-WYmin)*(VYmax-VYmin)/(WYmax-WYmin)+VYmin); } thanks, Sonny5

    Read the article

  • TSQL - create a stored proc inside a transaction statement

    - by Chris L
    I have a sql script that is set to roll to production. I've wrapped the various projects into separate transactions. In each of the transactions we created stored procedures. I'm getting error messages Msg 156, Level 15, State 1, Line 4 Incorrect syntax near the keyword 'procedure'. I created this example script to illustrate Begin Try Begin Transaction -- do a bunch of add/alter tables here -- do a bunch of data manipulation/population here -- create a stored proc create procedure dbo.test as begin select * from some_table end Commit End Try Begin Catch Rollback Declare @Msg nvarchar(max) Select @Msg=Error_Message(); RaisError('Error Occured: %s', 20, 101,@Msg) With Log; End Catch The error seems to imply that I can't create stored procs inside of transaction, but I'm not finding any docs that say otherwise(maybe google isn't being freindly today).

    Read the article

  • fields_for to stop pluralizing.

    - by Dmitriy Likhten
    I have a fields_for tag, where I specify the prefix (lets say for some good reasons), and this is supposed to represent a one-to-one relationship. I am trying to represent a relationship widget has_many thingamagigs thingamagig has_one whatchamacallit The field_for code is: fields_for "widgt[thingamagigs_attributes][][whatchamacallit_attributes]", thingamagig.whatchamacallit do |x| which generates names (wrongly): widget[thingamagigs_attributes][][whatchamacallit_attributes][][value] The better solution would be t.fields_for :whatchamacallit do |x| where t = fields_for the thingamagig... However if I do that, the following names are generated widgt[thingamagigs_attributes][whatchamacallit_attributes][] which is completely wrong as all other fields for a thingamagig is... widgt[thingamagigs_attributes][][name] So in all cases I am screwed. The original field_for using a string cannot be used with accepts_nested_attributes_for :whatchamacallit since whatchamacallit is a singular relationship and an object is expected not an array. The second fields_for will simply not work because rails cannot parse the params object correctly. Is there a way to tell the first forms_for to not add the [] after [whatchamacallit_attributes] in all field names?

    Read the article

  • Python configuration file generator

    - by Stan
    I want to use Python to make a configuration file generator. My roughly idea is feeding input with template files and some XML files with the real settings. Then use the program to generate the real configuration files. I got several questions: Is there any open source configuration generator program? (what could be the keyword), I wonder if there's anything can be added/modified in the design. Does Python have good XML parser module? Is it good idea to use XML file to save the original settings? I've been thinking to use Excel since it's more intuitive to maintain, but harder for program to parse. Not sure how people deal with this. Hope the community can give me some suggestions. Thanks a lot!

    Read the article

  • Assigning a pointer variable to a const int in C++?

    - by John
    I'm wondering if anyone can explain the following to me: If I write int i = 0; float* pf = i; I get a compile error (gcc 4.2.1): error: invalid conversion from ‘int’ to ‘float*’ Makes sense - they are obviously two completely different types. But if instead I write const int i = 0; float* pf = i; It compiles without error. Why should the 'const' make a difference on the right hand side of the assignment? Isn't part of the idea of the 'const' keyword to be able to enforce type constraints for constant values? Any explanation I have been able to come up with feels kind of bogus. And none of my explanations also explain the fact that const int i = 1; float* pf = i; fails to compile. Can anyone offer an explanation?

    Read the article

  • Whether to check for null

    - by coffeeaddict
    I know that you should always check incoming params to a method for null. But what if I have this scenario with a try/catch referring to a local variable. Do I really need to check for null below? Because it's gonna catch it anyway if it's null and the next line of code tries to use the refundResponse variable: public string DoRefund(...) { try { ...... string refundTransactionID = string.Empty; ...... RefundTransactionResponseType refundResponse = transaction.DoRefund(...); if (refundResponse != null) refundTransactionID = refundResponse.RefundTransactionID; ..... } catch (Exception ex) { LogError(ex); return ex.ToString(); } }

    Read the article

  • Fastest method for SQL Server inserts, updates, selects

    - by Ian
    I use SPs and this isn't an SP vs code-behind "Build your SQL command" question. I'm looking for a high-throughput method for a backend app that handles many small transactions. I use SQLDataReader for most of the returns since forward only works in most cases for me. I've seen it done many ways, and used most of them myself. Methods that define and accept the stored procedure parameters as parameters themselves and build using cmd.Parameters.Add (with or without specifying the DB value type and/or length) Assembling your SP params and their values into an array or hashtable, then passing to a more abstract method that parses the collection and then runs cmd.Parameters.Add Classes that represent tables, initializing the class upon need, setting the public properties that represent the table fields, and calling methods like Save, Load, etc I'm sure there are others I've seen but can't think of at the moment as well. I'm open to all suggestions.

    Read the article

  • PHP - Search array in array

    - by Anonymous2011
    I have tried googling for the past one hour straight now and tried many ways to search for an array, in an array. My objective is, to find a keyword in the URL, and the keywords are in a txt file. This is what i have so far - but doesn't work. $file = "keywords.txt"; $open = fopen($file,'r'); $data = fread($open,filesize($file)); $data = explode(" ",$data); $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; $url = parse_url($url); //parse the URL into an array foreach($data as $d) { if(strstr($d,$url)) { echo "yes"; } } This works WITHOUT the text file, or array - but that's not what i want. I'd appreciate it if anyone can assist me.

    Read the article

  • Void pointer cast C++ and GTK

    - by Tarantula
    See this GTK callback function: static gboolean callback(GtkWidget *widget, GdkEventButton *event, gpointer *data) { AnyClass *obj = (AnyClass*) data; // using obj works } (please note the gpointer* on the data). And then the signal is connected using: AnyClass *obj2 = new AnyClass(); gtk_signal_connect(/*GTK params (...)*/, callback, obj2); See that the *AnyClass is going to be cast to gpointer* (void**). In fact, this is working now. The callback prototype in GTK documentation is "gpointer data" and not "gpointer *data" as shown in code, what I want to know is: how this can work ? Is this safe ?

    Read the article

  • :from parameter in active record find not well designed?

    - by potlee
    i got this error: SQLite3::SQLException: no such column: apis.name: SELECT * FROM examples WHERE ("apis"."name" = 'deep') my code Api.find :all, :from => params[:table_name], :conditions => {:name => 'deep' } I need to make a back end rails application which will be used by a silverlight application. one of the requirements is to fetch simple data from the database. i need to be able to query different tables with the same code.(my app has 2000 tables!) i think it does not make sense for rails to put in "apis" in the WHERE clause. is there any speciic reason for this?

    Read the article

  • How do customize the g:sortableColumn?

    - by kakaotalk
    Well, I have one column in my list that I need to customize, the thing is grails' own g:sortable doesn't work. For instance, my first column shows employee ids, then my second column, shows the employees full name where full name is a combination of first name and last name. I got it to work, sorting and all, but when I try to place it in a table with g:sortable, the g:sortable just wouldn't work. I'm thinking about passing params around but it's a bit tricky. Any suggestions? I've looked around the internet, and seems like nothing. :\

    Read the article

  • How do I pass object values with render :action => 'new'

    - by PlanetMaster
    Hi, In an app I have the following: def new @property = Property.new(:country_id => 1, :user_id => current_user.id, :status_id => 'draft') end def create @property = Property.new(params[:property]) if @property.save flash[:success] = t('The_property_is_successfully_created') redirect_to myimmonatie_url else flash.now[:error]=t("The_property_could_not_be_created") render :action => 'new' end end When an error accors, the line render :action = 'new' gets executed, but the my form gives an error: user blank country blank These cannot be blank (defined in model), meaning this code: @property = Property.new(:country_id => 1, :user_id => current_user.id, :status_id => 'draft') is not executed anymore. What is the reason and solution? Thanks!

    Read the article

  • How can I avoid explicitly declaring directory paths in C or C++ #include directives?

    - by user269037
    Hi, I am making a simulator and have written lots of files and headers. The problem is whenever I include a file I give the relative path of the particular file. For example a typical code in my application would begin like #ifndef AI_H #define AI_H #include <cstdlib> #include "../world/world.h" #include "pathPlan.h" #include "skills/tryskill.h" #include "../info/condition.h" #include "dataStructures/destination.h" #include "../params/gamePlay.h" #include "../modules/controlModule.h" class ai { public: etc etc I want to avoid using the relative paths. For example I want to directly include "tryskill.h" and "destination.h" without giving the absolute paths. That way I wont need to bother if I change the location of any particular file. I am using Ubuntu 9.10. Any help would be highly appreciated.

    Read the article

  • how i insert values from list of Data Grid View,current time ,EmployeeID using button click event (C

    - by Six fourty
    hi, it show me this error Incorrect syntax near the keyword 'Select' to make to clear Employee ID in this case is FK in the table (Attendance detail) and the other thing is i am using Data Grid View from another table(Employee information) to Show the list of the staff in my form. then i want to transfer each selected cell value from Data Grid View to attendance detail table. 10q private void time_in_Click(object sender, EventArgs e) { employee_InformationDataGridView.SelectedCells[0].Style.ForeColor = Color.Green; time_in.Enabled = false; time_out.Enabled = true; con = new SqlConnection(GlobalClass.conn); con.Open(); SqlCommand cmd = new SqlCommand("Insert into Attendancedetail Values(" + "Select from EmployeeInformation(EmployeeID)" + ",'" + employee_InformationDataGridView.SelectedCells[0] + "','" + DateTime.Now.ToLongDateString() + "','" + null + "','" + null + "','" + DateTime.Now.ToLongTimeString() + "'," + null + ")", con); int i = cmd.ExecuteNonQuery(); MessageBox.Show(i.ToString() + " record inserted"); }

    Read the article

  • Call function by pointer and set parametrs in memory block

    - by Ellesmess Glain
    Hi, I've little problem : I'm solving problem with calling function by pointer and passing to it parameters in continuous memory block. My goal is to have function named e.g CallFunc(void * func,void *params, unsigned int param_length); that I'll send function pointer, pointer to function's parameters and eventually parameters length and this calling function will call passed function with it's parameters. I will like write this in C/C++, but if somebody has idea, how this resolve in other language, that supports DLL generation and exportet functions, it will be fine too. Thanks for answers, Ellesmess P.S. I'm sorry about my English, but I'm Czech, thanks :o)

    Read the article

  • Format String become xxx1, xx10 or 1****, 10*** etc

    - by trycatch4j
    Hi all, I have following numbers : 1, 2, 3, 4, 10 But I want to print those numbers like this: 0001 0002 0003 0004 0010 I have searched in Google. the keyword is number format. But I've got nothing, I just get, format decimal such ass 1,000,000.00. I hope you can suggest me a reference or give me something to solve this problem. Thanks Edit, we can use NumberFormat, or String.format("%4d", somevalue); but it just for adding 0 character before integer. How If I wanna use character such as x, # or maybe whitespace. So the character become: xxxx1 xxx10 or ####1 ###10 or 1#### 10###

    Read the article

  • Trying to get paperclip to refresh or reprocess..

    - by Trip
    I have over time, changed the size for thumbs of the class Deal. Through these changes, users were uploading to the site, so there are few people who have different sized thumbs. I wanted to reprocress or refresh these, so I went to into my root and typed: $ rake paperclip:refresh class=Deal Did nothing for the thumb sizes.. Then I : irb Deal.find(987).reprocess! Returned this : NoMethodError: undefined method `reprocess!' for #<Deal:0xb68a0988> from /data/HQ_Channel/releases/20100607130346/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:260:in `method_missing' from (irb):7 My deal class is this : => Deal(id: integer, organization_id: integer, deal: string, value: string, what: string, description: string, image_file_name: string, image_content_type: string, image_file_size: integer, image_updated_at: datetime, created_at: datetime, updated_at: datetime, deal_image_file_name: string, deal_image_content_type: string, deal_image_file_size: integer, deal_image_uploaded_at: datetime) What can i do to have it reprocess the original to make the thumb the correct size in the current thumb size params?

    Read the article

  • Encryption By Certificate

    - by user1817240
    I am encrypting customer name in database at database level. While saving in database only first letter of customer name is saved and hence while decrypting only first letter is retrieved. The following code shows the test sp. ALTER PROCEDURE [dbo].[spc_test_insert] ( @sFIRST_NAME typ_encryptedtext, ) AS BEGIN DECLARE @sSENCRYPTION_KEY char(15) DECLARE @sCERTIFICATE char(22) SET @sSENCRYPTION_KEY='SymmetricKey1' SET @sCERTIFICATE='CustomerCertificate' OPEN SYMMETRIC KEY SymmetricKey1 DECRYPTION BY CERTIFICATE CustomerCertificate; INSERT INTO test_table ( FIRST_NAME, ) Values ( -- Add the Params to be Added... EncryptByKey(Key_GUID(@sSENCRYPTION_KEY),@sFIRST_NAME), ) CLOSE SYMMETRIC KEY SymmetricKey1 END encryption decryption working fine in normal insert but its not working in stored procedure.

    Read the article

< Previous Page | 122 123 124 125 126 127 128 129 130 131 132 133  | Next Page >