Search Results

Search found 7897 results on 316 pages for 'generate'.

Page 42/316 | < Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >

  • kill SIGABRT does not generate core file from daemon started from crontab.

    - by Guma
    I am running CentOS 5.5 and working on server application that sometimes I need to force core dump so I can see what is going on. If I start my server from shell and send kill SIGABRT, a core file is created. If I start same program from crontab and then I send the same signal to it the server is "killed" but no core file is generated. Does any one know why is that and what need to be added to my code or changed in system settings to allow core file generation? Just a side note I have ulimit set to unlimited in /etc/profile I have set kernel.core_uses_pid = 1 kernel.core_pattern=/var/cores/%h-%e-%p.core in /etc/sysctl.conf Also my server app was added to crontab under same login id as I am running it from shell. Any help greatly appreciated

    Read the article

  • How to generate good serials for DNS zones with Puppet?

    - by Bittrance
    My tradition is to set all zone serials to the timestamp at modification. Now that Puppet is my new religion, I want to set serial timestamps when building zone files from exported resources. A somewhat trivialized example may look like this: file { "/tmp/dafile": content = inline_template("<%= Time.now.to_i %>"), } The problem with this approach is that content will be different all the time, which will (ultimately) provoke rebuilding of zone files on each puppet config poll. Is there some way I can insert a timestamp without it being included in the data that is compared against previous state?

    Read the article

  • Silverlight and Encryption, how to store/generate they key/iv pair?

    - by cmaduro
    I have a Silverlight app that connects to a php webservice. I want to encrypt the communication between the webservice and the Silverlight client. I'm not relying on SSL. I'm encrypting/decrypting the POST string myself using AES 256bit Key and IV. The big questions then are: How do I generate a random unique key/iv pair in PHP. How do I share this key/iv pair between the web service and silverlight client in a secure way. It seems impossible without having some kind of hard coded key or iv on the client. Which would compromise security. This is a public website, there are no logins. Just the requirement of secure communication. I can hard code the seed for the key/iv (which is hashed with SHA256 with a time stamp salt and then assigned as the key or iv) in PHP source code, that's on the server so that is pretty safe. However on the client the seed for the key/iv pair would be visible, if it is hard coded. Further more using a time stamp as the basis for uniqueness/randomness is definitely not ok, since timestamps are predictable. It does however provide a common factor between the C# code and the PHP code. The only other option that I can think of would be to have a 3rd service involved that provides the key/iv to the Silverlight client, as well as the php webservice. This of course start the cycle anew, with the question of how to store the credentials for accessing the key/iv distribution service on the Silverlight client. Sounds like the solution is then asymmetric encryption, since sensitive data will be viewed only on the administrative back end of the website. Unfortunately Silverlight has no asymmetric encryption classes. The solution? Roll my own Diffie-Hellman key exchange! Plug that key into AES256!

    Read the article

  • How to generate Thumbnails with phpThumb and save it into a file?

    - by CuSS
    Hi all, i wan't to know how to generate thumbnails with phpThumb Class, with an array with file paths already. And then Save the result of each image on other path but with the same name. Thank you all ;) EDIT: I have my code something like this: echo "A iniciar gerador de miniaturas para a área de cliente: \n"; include $wincli['files']['phpThumbClass']; $files = file_list($wincli['dirs']['logos']); $phpThumb = new phpThumb(); foreach( $files as $file ) { echo " # A converter o ficheiro '".basename($file)."' : "; if(is_file($file)){ $phpThumb->setSourceFilename($file); $phpThumb->setParameter('w', 880); $phpThumb->setParameter('h', 241); $phpThumb->setParameter('q', 90); $phpThumb->setParameter('zc', 1); $outputFilename = $wincli['dirs']['logosthumbs'].$file; if($phpThumb->GenerateThumbnail()){ if($phpThumb->RenderToFile($outputFilename)){ echo "OK \n"; }else{ echo "Falhou (Ao guardar no ficheiro)\n"; } }else{ echo "Falhou (Ao gerar miniatura)\n"; } }else{ echo "Falhou (Ficheiro inexistente)\n"; } }

    Read the article

  • Using MD5 to generate an encryption key from password?

    - by Charles
    I'm writing a simple program for file encryption. Mostly as an academic exercise but possibly for future serious use. All of the heavy lifting is done with third-party libraries, but putting the pieces together in a secure manner is still quite a challenge for the non-cryptographer. Basically, I've got just about everything working the way I think it should. I'm using 128-bit AES for the encryption with a 128-bit key length. I want users to be able to enter in variable-length passwords, so I decided to hash the password with MD5 and then use the hash as the key. I figured this was acceptable--the key is always supposed to be a secret, so there's no reason to worry about collision attacks. Now that I've implemented this, I ran across a couple articles indicating that this is a bad idea. My question is: why? If a good password is chosen, the cipher is supposed to be strong enough on its own to never reveal the key except via an extraordinary (read: currently infeasible) brute-force effort, right? Should I be using something like PBKDF2 to generate the key or is that just overkill for all but the most extreme cryptographic applications?

    Read the article

  • Generate colors between red and green for a power meter?

    - by Simucal
    I'm writing a java game and I want to implement a power meter for how hard you are going to shoot something. I need to write a function that takes a int between 0 - 100, and based on how high that number is, it will return a color between Green (0 on the power scale) and Red (100 on the power scale). Similar to how volume controls work: What operation do I need to do on the Red, Green, and Blue components of a color to generate the colors between Green and Red? So, I could run say, getColor(80) and it will return an orangish color (its values in R, G, B) or getColor(10) which will return a more Green/Yellow rgb value. I know I need to increase components of the R, G, B values for a new color, but I don't know specifically what goes up or down as the colors shift from Green-Red. Progress: I ended up using HSV/HSB color space because I liked the gradiant better (no dark browns in the middle). The function I used was (in java): public Color getColor(double power) { double H = power * 0.4; // Hue (note 0.4 = Green, see huge chart below) double S = 0.9; // Saturation double B = 0.9; // Brightness return Color.getHSBColor((float)H, (float)S, (float)B); } Where "power" is a number between 0.0 and 1.0. 0.0 will return a bright red, 1.0 will return a bright green. Java Hue Chart: Thanks everyone for helping me with this!

    Read the article

  • What is the best way to auto-generate INSERT statements for a SQL Server table?

    - by JosephStyons
    We are writing a new application, and while testing, we will need a bunch of dummy data. I've added that data by using MS Access to dump excel files into the relevant tables. Every so often, we want to "refresh" the relevant tables, which means dropping them all, re-creating them, and running a saved MS Access append query. The first part (dropping & re-creating) is an easy sql script, but the last part makes me cringe. I want a single setup script that has a bunch of INSERTs to regenerate the dummy data. I have the data in the tables now. What is the best way to automatically generate a big list of INSERT statements from that dataset? I'm thinking of something like in TOAD (for Oracle) where you can right-click on a grid and click Save As-Insert Statements, and it will just dump a big sql script wherever you want. The only way I can think of doing it is to save the table to an excel sheet and then write an excel formula to create an INSERT for every row, which is surely not the best way. I'm using the 2008 Management Studio to connect to a SQL Server 2005 database.

    Read the article

  • How to generate a key for a group entity?

    - by user246114
    Hi, I'm trying to make a group entity. Something like: class User { } class UserColor { } ... Key key = new KeyFactory.Builder( User.class.getSimpleName(), username). .addChild(UserColor.class.getSimpleName(), ???).getKey(); I know the unique username up-front to use for the key of the User object. But I just want app engine to generate a random unique value for the key value of the UserColor instance. I think this is described here, but I don't understand their wording: http://code.google.com/appengine/docs/java/datastore/transactions.html To create an object with a system-generated numeric ID and an entity group parent, you must use an entity group parent key field (such as customerKey, above). Assign the key of the parent to the parent key field, then leave the object's key field set to null. When the object is saved, the datastore populates the key field with the complete key, including the entity group parent. and this is their example: @Persistent @Extension(vendorName="datanucleus", key="gae.parent-pk", value="true") private Key customerKey; but I don't understand - should UserColor look like this then?: class UserColor { @Persistent @Extension(vendorName="datanucleus", key="gae.parent-pk", value="true") private Key mKeyParent; @Primary private Key mKey; // leave null } ... Key keyParent = new KeyFactory.Builder( User.class.getSimpleName(), username); UserColor uc = new UserColor(); uc.setKeyParent(keyParent); pm.makePersistent(uc); // now generated for me automatically? is that correct? Using this method, I should be able to use a User and a UserColor object in a transaction together, right? Thanks

    Read the article

  • How Can I: Generate 40/64 Bit WEP Key In Python?

    - by Aktariel
    So, I've been beating my head against the wall of this issue for several months now, partly because it's a side interest and partly because I suck at programming. I've searched and researched all across the web, but have not had any luck (except one small bit of success; see below), so I thought I might try asking the experts. What I am trying to do is, as the title suggests, generate a 40/64 bit WEP key from a passphrase, according to the "de facto" standard. (A site such as [http://www.powerdog.com/wepkey.cgi] produces the expected outputs.) I have already written portions of the script that take inputs and write them to a file; one of the inputs would be the passphrase, sanitized to lower case. For the longest time I had no idea what the defacto standard was, much less how to even go about implementing it. I finally stumbled across a paper (http://www.lava.net/~newsham/wlan/WEP_password_cracker.pdf) that sheds as much light as I've had yet on the issue (page 18 has the relevant bits). Apparently, the passphrase is "mapped to a 32-bit value with XOR," the result of which is then used as the seed for a "linear congruential PRNG (which one of the several PRNGs Python has would fit this description, I don't know), and then from that result several bits of the result are taken. I have no idea how to go about implementing this, since the description is rather vague. What I need is help in writing the generator in Python, and also in understanding how exactly the key is generated. I'm not much of a programmer, so explanations are appreciated as well. (Yes, I know that WEP isn't secure.)

    Read the article

  • How to generate an ear file from a maven-archetype-webapp artifact?

    - by Mike
    I currently have a project built with maven-archetype-webapp artifact. The default packaging for this project is war. Is it possible for me to insert the maven-ear-plugin in this webapp pom.xml generate an ear file that contains this project war? I tried that, but the war file doesn't get embedded in the generated ear file. It has everything except the war file. I read many Maven related articles, and perhaps I could use maven-archetype-j2ee-simple artifact. However, I'm reluctant to this use for 2 reasons:- This artifact handles ejbs and all the extra features that I don't use. It makes my project looks bloated. Second, it seems like it requires me to install the web module into the repository first before I can create the ear file. Is this the preferred way to create an ear file? How do I create an ear file that contains the war file using maven-ear-plugin from my webapp's pom.xml? If this way is not possible, what's the preferred way? I'm sorry if my questions sound a little novice, I realized I have whole lot more to learn about Maven. Thanks much.

    Read the article

  • How can I generate the Rowland prime sequence idiomatically in J?

    - by Gregory Higley
    If you're not familiar with the Rowland prime sequence, you can find out about it here. I've created an ugly, procedural monadic verb in J to generate the first n terms in this sequence, as follows: rowland =: monad define result =. 0 $ 0 t =. 1 $ 7 while. (# result) < y do. a =. {: t n =. 1 + # t t =. t , a + n +. a d =. | -/ _2 {. t if. d > 1 do. result =. ~. result , d end. end. result ) This works perfectly, and it indeed generates the first n terms in the sequence. (By n terms, I mean the first n distinct primes.) Here is the output of rowland 20: 5 3 11 23 47 101 7 13 233 467 941 1889 3779 7559 15131 53 30323 60647 121403 242807 My question is, how can I write this in more idiomatic J? I don't have a clue, although I did write the following function to find the differences between each successive number in a list of numbers, which is one of the required steps. Here it is, although it too could probably be refactored by a more experienced J programmer than I: diffs =: monad : '}: (|@({.-2&{.) , $:@}.) ^: (1 < #) y'

    Read the article

  • How should I generate the partitions / pairs for the Chinese Postman problem?

    - by Simucal
    I'm working on a program for class that involves solving the Chinese Postman problem. Our assignment only requires us to write a program to solve it for a hard-coded graph but I'm attempting to solve it for the general case on my own. The part that is giving me trouble is generating the partitions of pairings for the odd vertices. For example, if I had the following labeled odd verticies in a graph: 1 2 3 4 5 6 I need to find all the possible pairings / partitions I can make with these vertices. I've figured out I'll have i paritions given: n = num of odd verticies k = n / 2 i = ((2k)(2k-1)(2k-2)...(k+1))/2 So, given the 6 odd verticies above, we will know that we need to generate i = 15 partitions. The 15 partions would look like: 1 2 3 4 5 6 1 2 3 5 4 6 1 2 3 6 4 5 ... 1 6 ... Then, for each partition, I take each pair and find the shortest distance between them and sum them for that partition. The partition with the total smallest distance between its pairs is selected, and I then double all the edges between the shortest path between the odd vertices (found in the selected partition). These represent the edges the postman will have to walk twice. At first I thought I had worked out an appropriate algorithm for generating these partitions / pairs but it is flawed. I found it wasn't a simple permutation/combination problem. Does anyone who has studied this problem before have any tips that can help point me in the right direction for generating these partitions?

    Read the article

  • How to generate XML from an Excel VBA macro?

    - by SuperNES
    So, I've got a bunch of content that was delivered to us in the form of Excel spreadsheets. I need to take that content and push it into another system. The other system takes its input from an XML file. I could do all of this by hand (and trust me, management has no problem making me do that!), but I'm hoping there's an easy way to write an Excel macro that would generate the XML I need instead. This seems like a better solution to me, as this is a job that will need to be repeated regularly (we'll be getting a LOT of content in Excel sheets) and it just makes sense to have a batch tool that does it for us. However, I've never experimented with generating XML from Excel spreadsheets before. I have a little VBA knowledge but I'm a newbie to XML. I guess my problem in Googling this is that I don't even know what to Google for. Can anyone give me a little direction to get me started? Does my idea sound like the right way to approach this problem, or am I overlooking something obvious? Thanks StackOverflow!

    Read the article

  • How to generate lots of redundant ajax elements like checkboxes and pulldowns in Django?

    - by iJames
    Hello folks. I've been getting lots of answers from stackoverflow now that I'm in Django just be searching. Now I hope my question will also create some value for everybody. In choosing Django, I was hoping there was some similar mechanism to the way you can do partials in ROR. This was going to help me in two ways. One was in generating repeating indexed forms or form elements, and also in rendering only a piece of the page on the round trip. I've done a little bit of that by using taconite with a simple URL click but now I'm trying to get more advanced. This will focus on the form issue which boils down to how to iterate over a secondary object. If I have a list of photo instances, each of which has a couple of parameters, let's say a size and a quantity. I want to generate form elements for each photo instance separately. But then I have two lists I want to iterate on at the same time. Context: photos : Photo.objects.all() and forms = {} for photo in photos: forms[photo.id] = PhotoForm() In other words we've got a list of photo objects and a dict of forms based on the photo.id. Here's an abstraction of the template: {% for photo in photos %} {% include "photoview.html" %} {% comment %} So here I want to use the photo.id as an index to get the correct form. So that each photo has its own form. I would want to have a different action and each form field would be unique. Is that possible? How can I iterate on that? Thanks! {% endcomment %} Quantity: {{ oi.quantity }} {{ form.quantity }} Dimensions: {{ oi.size }} {{ form.size }} {% endfor %} What can I do about this simple case. And how can I make it where every control is automatically updating the server instead of using a form at all? Thanks! James

    Read the article

  • Dynamically generate client-side HTML form control using JavaScript and server-side Python code in Google App Engine

    - by gisc
    I have the following client-side front-end HTML using Jinja2 template engine: {% for record in result %} <textarea name="remark">{{ record.remark }}</textarea> <input type="submit" name="approve" value="Approve" /> {% endfor %} Thus the HTML may show more than 1 set of textarea and submit button. The back-end Python code retrieves a variable number of records from a gql query using the model, and pass this to the Jinja2 template in result. When a submit button is clicked, it triggers the post method to update the record: def post(self): if self.request.get('approve'): updated_remark = self.request.get('remark') record.remark = db.Text(updated_remark) record.put() However, in some instances, the record updated is NOT the one that correspond to the submit button clicked (eg if a user clicks on record 1 submit, record 2 remark gets updated, but not record 1). I gather that this is due to the duplicate attribute name remark. I can possibly use JavaScript/jQuery to generate different attribute names. The question is, how do I code the back-end Python to get the (variable number of) names generated by the JavaScript? Thanks.

    Read the article

  • algorithm to generate maximum number of character 'A' using keystrokes 'A', CTRL + 'A', CTRL + 'C' and CTRL + 'V'

    - by munda
    This is an interview question from google. I am not able to solve it by myself. Can somebody throw some light? The question goes like this. Write a program to print the sequence of keystrokes such that it generates the maximum number of character 'A's. You are allowed to use only 4 keys: 'A', CTRL + 'A', CTRL + 'C' and CTRL + 'V'. Only N keystrokes are allowed. All CTRL+ characters are considered as one keystroke, so CTRL+A is one keystroke. e.g.: A, ctrl+A, ctrl+C, ctrl+V generates two As in 4 keystrokes. Edit: CTRL + A is Select All CTRL + C is copy CTRL + V is paste I did some mathematics. For any N, using x numbers of A's , one CTRL+A, one CTRL+C and y CTRL+V, we can generate max ((N-1)/2)^2 numbers of A's. But for some N M, it is better to use as many ^A, ^C and ^V as it doubles the number of As. Edit 2: ^A, ^V and ^C will not overwrite on the existing selection but it will append the copied selection to selected one.

    Read the article

  • Can Delphi 5 generate a .PDB file that VS can use?

    - by Vilx-
    We've got this large application written in Delphi 5, and development is ongoing to this day. There is research going on into migrating to newer versions, but so far there is no success, as some 3rd party components have not been updated in ages and do not work on later versions. In the meantime however people need to continue work on it. Now Delphi 5 IDE is no real treat. It's pretty bug-ridden and lacks a lot of features of contemporary IDEs which makes it difficult to use. Especially when it comes to debugging. So I was wondering - would it be possible to use Visual Studio in the process? As far as I know the .PDB file format is pretty old and is well documented. Could it be possible to make the Delphi compiler to somehow generate a .PDB files for it's compiled results? Then the program could be debugged with Visual Studio, possibly to a much greater extent than in the original IDE. Well, the absolute Holy Grail would be to move all development to VS, just keeping the compiler from Delphi, but I imagine that would be pretty impossible.

    Read the article

  • Interview question : What is the fastest way to generate prime number recursively ?

    - by hilal
    Generation of prime number is simple but what is the fastest way to find it and generate( prime numbers) it recursively ? Here is my solution. However, it is not the best way. I think it is O(N*sqrt(N)). Please correct me, if I am wrong. public static boolean isPrime(int n) { if (n < 2) { return false; } else if (n % 2 == 0 & n != 2) { return false; } else { return isPrime(n, (int) Math.sqrt(n)); } } private static boolean isPrime(int n, int i) { if (i < 2) { return true; } else if (n % i == 0) { return false; } else { return isPrime(n, --i); } } public static void generatePrimes(int n){ if(n < 2) { return ; } else if(isPrime(n)) { System.out.println(n); } generatePrimes(--n); } public static void main(String[] args) { generatePrimes(200); }

    Read the article

  • EDIT: I need to generate a string of 7 chars that is based on the id of the row.

    - by Totty
    EDIT: I need to generate a string of 7 chars that is based on the id of the row. So knowing the id of the image and a secret key, i should get the generated string. the string must contain chars from "a" to "z" and numbers from 0 to 9. I have a dir that contains photos like this dir/p3/i2/s21/thumb.jpg the generated string is p3i2s21, then is used to calculate the path of the image. EDIT: currently im using the id of the image: id = 55 then i modify and i get path = 000000055 then path = "000/000/055" then path = "000/000/055/thumb.jpg" ready to use! now i want something more clever because is easy to track down all the images from a server, because ids are sequencial: 1, 2, 3, 4, 5, 6... so i must think of creating from 55 a string that is 7 char length and will not overlap with other numbers. I can even transform the 55 to 0000055 and from this convert to a 7 char length string using a secret string. then when i got the secret string and the id i want to get back that 7 char length string. Is this possible? i was thinking about hases but they only uses 0-9 and a-e and are more chars.. :s

    Read the article

  • Nested generator functions in python

    - by Yuval A
    Consider a tuple v = (a,b,c) and a generator function generate(x) which receives an item from the tuple and generates several options for each item. What is the pythonic way of generating a set of all the possible combinations of the result of generate(x) on each item in the tuple? I could do this: v = (a,b,c) for d in generate(v[0]): for e in generate(v[1]): for f in generate(v[2]): print d,e,f but that's just ugly, plus I need a generic solution.

    Read the article

  • On Redirect - Failed to generate a user instance of SQL Server...

    - by Craig Russell
    Hello (this is a long post sorry), I am writing a application in ASP.NET MVC 2 and I have reached a point where I am receiving this error when I connect remotely to my Server. Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed. I thought I had worked around this problem locally, as I was getting this error in debug when site was redirected to a baseUrl if a subdomain was invalid using this code: protected override void Initialize(RequestContext requestContext) { string[] host = requestContext.HttpContext.Request.Headers["Host"].Split(':'); _siteProvider.Initialise(host, LiveMeet.Properties.Settings.Default["baseUrl"].ToString()); base.Initialize(requestContext); } protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (Site == null) { string[] host = filterContext.HttpContext.Request.Headers["Host"].Split(':'); string newUrl; if (host.Length == 2) newUrl = "http://sample.local:" + host[1]; else newUrl = "http://sample.local"; Response.Redirect(newUrl, true); } ViewData["Site"] = Site; base.OnActionExecuting(filterContext); } public Site Site { get { return _siteProvider.GetCurrentSite(); } } The Site object is returned from a Provider named siteProvider, this does two checks, once against a database containing a list of all available subdomains, then if that fails to find a valid subdomain, or valid domain name, searches a memory cache of reserved domains, if that doesn't hit then returns a baseUrl where all invalid domains are redirected. locally this worked when I added the true to Response.Redirect, assuming a halting of the current execution and restarting the execution on the browser redirect. What I have found in the stack trace is that the error is thrown on the second attempt to access the database. #region ISiteProvider Members public void Initialise(string[] host, string basehost) { if (host[0].Contains(basehost)) host = host[0].Split('.'); Site getSite = GetSites().WithDomain(host[0]); if (getSite == null) { sites.TryGetValue(host[0], out getSite); } _site = getSite; } public Site GetCurrentSite() { return _site; } public IQueryable<Site> GetSites() { return from p in _repository.groupDomains select new Site { Host = p.domainName, GroupGuid = (Guid)p.groupGuid, IsSubDomain = p.isSubdomain }; } #endregion The Linq query ^^^ is hit first, with a filter of WithDomain, the error isn't thrown till the WithDomain filter is attempted. In summary: The error is hit after the page is redirected, so the first iteration is executing as expected (so permissions on the database are correct, user profiles etc) shortly after the redirect when it filters the database query for the possible domain/subdomain of current redirected page, it errors out.

    Read the article

  • How to use jQuery to generate 2 new associated objects in a nested form?

    - by mind.blank
    I have a model called Pair, which has_many :questions, and each Question has_one :answer. I've been following this railscast on creating nested forms, however I want to generate both a Question field and it's Answer field when clicking on an "Add Question" link. After following the railscast this is what I have: ..javascripts/common.js.coffee: window.remove_fields = (link)-> $(link).closest(".question_remove").remove() window.add_fields = (link, association, content)-> new_id = new Date().getTime() regexp = new RegExp("new_" + association, "g") $(link).before(content.replace(regexp, new_id)) application_helper.rb: def link_to_add_fields(name, f, association) new_object = f.object.class.reflect_on_association(association).klass.new fields = f.simple_fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render(association.to_s.singularize + "_fields", :f => builder) end link_to_function(name, "window.add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")", class: "btn btn-inverse") end views/pairs/_form.html.erb: <%= simple_form_for(@pair) do |f| %> <div class="row"> <div class="well span4"> <%= f.input :sys_heading, label: "System Heading", placeholder: "required", input_html: { class: "span4" } %> <%= f.input :heading, label: "User Heading", input_html: { class: "span4" } %> <%= f.input :instructions, as: :text, input_html: { class: "span4 input_text" } %> </div> </div> <%= f.simple_fields_for :questions do |builder| %> <%= render 'question_fields', f: builder %> <% end %> <%= link_to_add_fields "<i class='icon-plus icon-white'></i> Add Another Question".html_safe, f, :questions %> <%= f.button :submit, "Save Pair", class: "btn btn-success" %> <% end %> _question_fields.html.erb partial: <div class="question_remove"> <div class="row"> <div class="well span4"> <%= f.input :text, label: "Question", input_html: { class: "span4" }, placeholder: "your question...?" %> <%= f.simple_fields_for :answer do |builder| %> <%= render 'answer_fields', f: builder %> <% end %> </div> </div> </div> _answer_fields.html.erb partial: <%= f.input :text, label: "Answer", input_html: { class: "span4" }, placeholder: "your answer" %> <%= link_to_function "remove", "remove_fields(this)", class: "float-right" %> I'm especially confused by the reflect_on_association part, for example how does calling .new there create an association? I usually need to use .build Also for a has_one I use .build_answer rather than answers.build - so what does this mean for the jQuery part?

    Read the article

  • How do I generate an array from a string representation of that array?

    - by question_about_the_problem
    I want to generate the array $result_array. There is no error at the page, but not works! that not works ! //BOF: Result Array $result_array = ''; $result_array .= '"messages" => "' . $errors .'",'; $result_array .= '"this_addr_type" => "' . (int)$_REQUEST['edit'] .'",'; if (ACCOUNT_GENDER == 'true') { $result_array .= '"gender_male" => "' . $male .'",'; $result_array .= '"gender_female" => "' . $female .'",'; } $result_array .= '"firstname" => "' . $entry['entry_firstname'] .'",'; $result_array .= '"lastname" => "' . $entry['entry_lastname'] .'",'; if (ACCOUNT_COMPANY == 'true') { $result_array .= '"company" => "' . $entry['entry_company'] .'",'; } $result_array .= '"street_address" => "' . $entry['entry_street_address'] .'",'; if (ACCOUNT_SUBURB == 'true') { $result_array .= '"suburb" => "' . $entry['entry_suburb'] .'",'; } $result_array .= '"postcode" => "' . $entry['entry_postcode'] .'",'; $result_array .= '"city" => "' . $entry['entry_city'] .'",'; if (ACCOUNT_STATE == 'true') { $result_array .= '"state" => "' . $entry['entry_state'] .'",'; } $result_array .= '"country" => "' . $entry['entry_country_id'] .'"'; //EOF: Result Array $_RESULT = array($result_array); that works $_RESULT = array( "this_addr_type" => (int)$_REQUEST['edit'], "gender_male" => $male, "gender_female" => $female, "firstname" => $entry["entry_firstname"], "lastname" => $entry["entry_lastname"], "company" => $entry["entry_company"], "street_address" => $entry["entry_street_address"], "suburb" => $entry["entry_suburb"], "postcode" => $entry["entry_postcode"], "city" => $entry["entry_city"], "state" => $entry["entry_state"], "country" => $entry["entry_country_id"] );

    Read the article

  • System.InvalidOperationException: Unable to generate a temporary class (result=1).

    - by keepsmilinyaar
    Hi, I have developed an application using .net 3.5 and have deployed it as an .exe on a number of machines with the same environment. However, on one particular machine I get the following error. Am puttin in the Stack Trace. See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ********** Exception Text ********** System.InvalidOperationException: Unable to generate a temporary class (result=1). error CS2001: Source file 'C:\WINDOWS\TEMP\wz58eig4.0.cs' could not be found error CS2008: No inputs specified at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence) at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies) at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence) at System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping[] mappings, Type type) at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type) at System.Web.Services.Protocols.SoapClientType..ctor(Type type) at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor() at SSOClient..ctor() at sc.tradesvc.SSOManager..ctor() at sc.tradesvc.SSOManager.get_Inst() at sc.cashflowgenerator.Controls.LoginForm.btnLogin_Click(Object sender, EventArgs e) at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.PerformClick() at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData) at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData) at System.Windows.Forms.Control.PreProcessMessage(Message& msg) at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg) at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg) ********** Loaded Assemblies ********** mscorlib Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll CashflowGenerator Assembly Version: 1.0.0.0 Win32 Version: 1.0.0.0 CodeBase: file:///C:/DATA/DEVEL/Output/CashflowGenerator.exe System.Windows.Forms Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll System Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll System.Drawing Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll System.Configuration Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll System.Xml Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll System.Core Assembly Version: 3.5.0.0 Win32 Version: 3.5.21022.8 built by: RTM CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll System.Web.Services Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Web.Services/2.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll ********** JIT Debugging ********** To enable just-in-time (JIT) debugging, the .config file for this application or computer (machine.config) must have the jitDebugging value set in the system.windows.forms section. The application must also be compiled with debugging enabled. For example: When JIT debugging is enabled, any unhandled exception will be sent to the JIT debugger registered on the computer rather than be handled by this dialog box. Could someone help me with this? As I am new to .net could someone also tell me when why a temporary class needs to be created in the first place? Thank you very much.

    Read the article

  • Code Contracts with Interfaces: "Method Invocation skipped. Compiler will generate method invocation

    - by Jörg Battermann
    Good evening, I just started playing with Microsoft.Contracts (latest version) and plugging it on top of a sample interface and right now it looks like this: namespace iRMA2.Core.Interfaces { using System; using System.Collections.Generic; using System.ComponentModel.Composition; using System.Diagnostics.Contracts; /// <summary> /// Base Interface declarations for iRMA2 Extensions /// </summary> [InheritedExport] [ContractClass(typeof(IiRMA2ExtensionContract))] public interface IiRMA2Extension { /// <summary> /// Gets the name. /// </summary> /// <value>The name of the Extension.</value> string Name { get; } /// <summary> /// Gets the description. /// </summary> /// <value>The description.</value> string Description { get; } /// <summary> /// Gets the author of the extension. Please provide complete information to get in touch with author(s) and the corresponding department /// </summary> /// <value>The author of the extensions.</value> string Author { get; } /// <summary> /// Gets the major version. /// </summary> /// <value>The major version of the extension.</value> int MajorVersion { get; } /// <summary> /// Gets the minor version. /// </summary> /// <value>The minor version.</value> int MinorVersion { get; } /// <summary> /// Gets the build number. /// </summary> /// <value>The build number.</value> int BuildNumber { get; } /// <summary> /// Gets the revision. /// </summary> /// <value>The revision.</value> int Revision { get; } /// <summary> /// Gets the depends on. /// </summary> /// <value>The dependencies to other <c>IiRMA2Extension</c> this one has.</value> IList<IiRMA2Extension> DependsOn { get; } } /// <summary> /// Contract class for <c>IiRMA2Extension</c> /// </summary> [ContractClassFor(typeof(IiRMA2Extension))] internal sealed class IiRMA2ExtensionContract : IiRMA2Extension { #region Implementation of IiRMA2Extension /// <summary> /// Gets or sets the name. /// </summary> /// <value>The name of the Extension.</value> public string Name { get { Contract.Ensures(!String.IsNullOrEmpty(Contract.Result<string>())); return default(string); } set { Contract.Requires(value != null); } } /// <summary> /// Gets the description. /// </summary> /// <value>The description.</value> public string Description { get { throw new NotImplementedException(); } } /// <summary> /// Gets the author of the extension. Please provide complete information to get in touch with author(s) and the corresponding department /// </summary> /// <value>The author of the extensions.</value> public string Author { get { throw new NotImplementedException(); } } /// <summary> /// Gets the major version. /// </summary> /// <value>The major version of the extension.</value> public int MajorVersion { get { throw new NotImplementedException(); } } /// <summary> /// Gets the minor version. /// </summary> /// <value>The minor version.</value> public int MinorVersion { get { throw new NotImplementedException(); } } /// <summary> /// Gets the build number. /// </summary> /// <value>The build number.</value> public int BuildNumber { get { throw new NotImplementedException(); } } /// <summary> /// Gets the revision. /// </summary> /// <value>The revision.</value> public int Revision { get { throw new NotImplementedException(); } } /// <summary> /// Gets the Extensions this one depends on. /// </summary> /// <value>The dependencies to other <c>IiRMA2Extension</c> this one has.</value> public IList<IiRMA2Extension> DependsOn { get { Contract.Ensures(Contract.Result<IList<IiRMA2Extension>>() != null); return default(IList<IiRMA2Extension>); } } #endregion } } Now why are the two Contract.Ensures(...) 'blured' out visually with the tooltip saying "Method Invocation skipped. Compiler will generate method invocation because the method is conditional or it is partial method without implementation" and in fact the CodeContracts output does not count/show them... What am I missing & doing wrong here? -J

    Read the article

< Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >