Search Results

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

Page 47/316 | < Previous Page | 43 44 45 46 47 48 49 50 51 52 53 54  | Next Page >

  • how to generate an N level tree using datatable?

    - by Kishore Kumar
    I have a DataTable with column ID, Name, RootID. The tree stucture is implmented using the RootId field. If the RootId is null it is considered as Root Node. How to create an Nlevel tree using the DataTale. eg. 1 Manager null, 2 Project Lead 1, 3 Test Lead 1, 4 Sr Soft Eng 2, 5 Soft eng 2, 6 HR Manager Null, 7 HR exec 6, ......

    Read the article

  • How to iteratively generate k elements subsets from a set of size n in java?

    - by Bea Metitiri
    Hi, I'm working on a puzzle that involves analyzing all size k subsets and figuring out which one is optimal. I wrote a solution that works when the number of subsets is small, but it runs out of memory for larger problems. Now I'm trying to translate an iterative function written in python to java so that I can analyze each subset as it's created and get only the value that represents how optimized it is and not the entire set so that I won't run out of memory. Here is what I have so far and it doesn't seem to finish even for very small problems: public static LinkedList<LinkedList<Integer>> getSets(int k, LinkedList<Integer> set) { int N = set.size(); int maxsets = nCr(N, k); LinkedList<LinkedList<Integer>> toRet = new LinkedList<LinkedList<Integer>>(); int remains, thresh; LinkedList<Integer> newset; for (int i=0; i<maxsets; i++) { remains = k; newset = new LinkedList<Integer>(); for (int val=1; val<=N; val++) { if (remains==0) break; thresh = nCr(N-val, remains-1); if (i < thresh) { newset.add(set.get(val-1)); remains --; } else { i -= thresh; } } toRet.add(newset); } return toRet; } Can anybody help me debug this function or suggest another algorithm for iteratively generating size k subsets? EDIT: I finally got this function working, I had to create a new variable that was the same as i to do the i and thresh comparison because python handles for loop indexes differently.

    Read the article

  • Regex to GENERATE thumbnails!?!?! (but that's crazy!)

    - by CryptoMonkey
    Hello everyone! So here is my situation, and the solution that I've come up with to solve the problem. I have created an application that includes TinyMCE to allow users to create HTML content for publishing. The user can include images in their markup, and drag/resize those images effecting the final Width/Height attributes in the IMG tag. This is all great, the users can include images and resize/relocate them to their desired appearance. But one big problem is that I am now sending a (possibly) much larger image to the client, only to have the browser resize the image into the requested Width/Height attributes. All that bandwidth and lost load time.... So my solution is to pre-process my users markup content, scanning all of the IMG tags and parsing out the Height/Width/Src attributes. Then set each img's SRC tag to a phpThumb request with the parsed Height/Width passed into the thumbnails URL. This will create my reduced size image (optimising bandwidth at the expense of CPU and caching). What do you think about this solution? I've seen other posts where people were using mod_rewrite to do something similar, but I want to effect the content on the page service and not manipulate the image requests as they're being received. .... Any thoughts about this design? I need some help with the fine details as my regex skills need some work, but I'm very short on time and promise to pay my technical knowledge debt soon. To make the regex's easier, I can be sure of some things. Only img tags that need this processing will have an existing width="" height="" attributes (with the double quotes, and lower cased text, but I suppose matching the text case insensitive would be better if TinyMCE changes) So a regex to match only the necessary Img tags, and maybe another three regex's to extract the src, the width, and the height? Thanks everyone.

    Read the article

  • How to generate an Intent that jumps into a specific short message conversation?

    - by Janusz
    I would like to create an Intent that opens the messages application in a specific conversation. If a short message notification is clicked Logcat reveals the following: INFO/ActivityManager(31909): Starting activity: Intent { act=android.intent.action.VIEW dat=content://mms-sms/conversations/3 flg=0x34000000 cmp=com.android.mms/.ui.ConversationList bnds=[0,586][600,682] } This brought me a little bit further using content://mms-sms/conversations/3 as the data starts up the messages app in the correct conversation. I now only need to find out which conversation a message belongs to.

    Read the article

  • How can I generate a list of #define values from C code?

    - by djs
    I have code that has a lot of complicated #define error codes that are not easy to decode since they are nested through several levels. Is there any elegant way I can get a list of #defines with their final numerical values (or whatever else they may be)? As an example: <header1.h> #define CREATE_ERROR_CODE(class, sc, code) ((class << 16) & (sc << 8) & code)) #define EMI_MAX 16 <header2.h> #define MI_1 EMI_MAX <header3.h> #define MODULE_ERROR_CLASS MI_1 #define MODULE_ERROR_SUBCLASS 1 #define ERROR_FOO CREATE_ERROR_CODE(MODULE_ERROR_CLASS, MODULE_ERROR_SUBCLASS, 1) I would have a large number of similar #defines matching ERROR_[\w_]+ that I'd like to enumerate so that I always have a current list of error codes that the program can output. I need the numerical value because that's all the program will print out (and no, it's not an option to print out a string instead). Suggestions for gcc or any other compiler would be helpful.

    Read the article

  • How do I generate an Array string from an array in memory (php).

    - by Itay Moav
    I need to create a big array in my code, I have the values in several tables (for easy management). I select it and now I have all the values in an array, in memory in the way I want. My problem, I need to write this array down, into the code. Is there a way to take an array which sits in the memory and translate it into a string "array('g'='h','b'='d'....)" which I can then echo and just copy-paste into my code?

    Read the article

  • Why Timer does not work if we do not generate a window?

    - by Roman
    Here is the code: import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.Timer; public class TimerSample { public static void main(String args[]) { new JFrame().setVisible(true); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Hello World Timer"); } }; Timer timer = new Timer(500, actionListener); timer.start(); } } It generates a window and then periodically prints "Hello World Timer" in the terminal (Command Prompt). If I comment this line new JFrame().setVisible(true); the application do not print anything to the command line. Why?

    Read the article

  • Is it possible for PHP to generate a fresh page on every Javascript history.go(-1) ?

    - by Ho
    Hello, I have a PHP page (a.php) which is already sending these headers: <?php header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Pragma: no-cache'); ?> And on the PHP page (a.php) , it has a link to another page (b.html) on b.html, it has a javascript code to: <script type="text/javascript"> history.go(-1); </scirpt> It seems to me that, when the browser is "going back" to a.php,the content isn't fresh at all. Would you please advise me if generating a completely fresh page on history.go(-1) is possible? Thank you.

    Read the article

  • Can i get RSpec to generate specs with expect syntax?

    - by papirtiger
    When generating specs with : rails g controller Home index A spec is generated with the older object.should syntax require 'spec_helper' describe HomeController do describe "GET 'index'" do it "returns http success" do get 'index' response.should be_success end end end Is it possible to configure the generator to use the expect syntax instead? Desired output: require 'spec_helper' describe HomeController do describe "GET 'index'" do it "returns http success" do get 'index' expect(response).to be_success end end end in config/application.rb: config.generators do |g| g.test_framework :rspec, fixture: true g.fixture_replacement :factory_girl, dir: 'spec/factories' g.view_specs false g.stylesheets = false g.javascripts = false end

    Read the article

  • How do I remove line references in generate output in doxygen?

    - by MeThinks
    I want to remove lines look as follows but I still want to return source code browsing Definition at line 377 of file xxx.h. I have tried the following two in the doxygen config file but these just remove cross references on types # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = NO update: I've just trying setting the following and seems to do the jobs but waiting to confirm if this is the correct way of achieving what I want SOURCE_BROWSER = NO

    Read the article

  • Any tools can randomly generate the source code according to a language grammar?

    - by wbsun
    A C program source code can be parsed according to the C grammar(described in CFG) and eventually turned into many ASTs. I am considering if such tool exists: it can do the reverse thing by firstly randomly generating many ASTs, which include tokens that don't have the concrete string values, just the types of the tokens, according to the CFG, then generating the concrete tokens according to the tokens' definitions in the regular expression. I can imagine the first step looks like an iterative non-terminals replacement, which is randomly and can be limited by certain number of iteration times. The second step is just generating randomly strings according to regular expressions. Is there any tool that can do this?

    Read the article

  • Unable to generate a temporary class (result=1). error CS0030: Cannot convert type 'Type[]' to 'Type'?

    - by grady
    I get this error after I created a class from my xsd file using the xsd.exe tool. So I searched the net and found a solution. Here is the link: http://satov.blogspot.com/2006/12/xsdexe-generated-classes-causing.html Problem is that this makes the code run, but somehow the deserialized data seems corrupt. I did what the site suggests and in the end the 2nd array dimension is always empty (see the comments of the site, somebody also had this problem). Question is, how do I solve this issue now? Is there another tool to create the xsd file? I tried Xsd2Code, without success. Thanks :-)

    Read the article

  • C# Why does calling an interface member from a class generate an error?

    - by Jack
    So I have an interface: interface IFoo { int Bar(); int this[int i] {get; set;} } And a class that derives from it class Foo : IFoo { public int IFoo.Bar() { //Implementation { public int IFoo.this[int i] { //Implementation } } Now, I try to do this: var fooey = new Foo(); int i = Fooey.Bar(); or this: int i = Fooey[4]; I would expect these to work properly. However, the compiler generates an error as if such members don't exist. Why is that? I am aware I can cast Foo as IFoo, but I am also aware that casting is costly to performance, which is often the reason to use interfaces in the first place. EDIT 1: These are the errors generated 'Foo' does not contain a definition for 'Bar' and no extension method 'Bar' accepting a first argument of type 'Foo' could be found (are you missing a using directive or an assembly reference?) "Cannot apply indexing to an expression of type 'Foo'"

    Read the article

  • How to generate a script for changing a column of varchar to xml type with data being converted?

    - by user1323981
    Initially I have a column (partner_email) of varchar.Now a recent change has come where it needs to be changed to be changed to the XML type but the previous records needs to be reserve into the new column. I have applied the below algorithm to accomplish the work /*********************************************************************** Purpose: To change the partner_email column from Varchar Type To Xml Type and convert the existing records from varchar to xml types. Programmers Notes: 1. Create a new Column by the name partner_email_temp of type XML into the Partner Table 2. Copy the Email contents from partner_email to partner_email_temp column after proper conversion N.B.~ The format will be <PartnerEmails> <Email>[email protected]</Email> <Email /> <Email /> </PartnerEmails> 3. Drop the exisitng partner_email 4. Rename partner_email_temp column to partner_email ***********************************************************************/ USE [Test] GO --===== Create a partner_email_temp column of type xml into the Partner table IF NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.columns WHERE table_name = 'Partner' AND column_name = 'partner_email_temp' ) BEGIN ALTER TABLE [dbo].[Partner] ADD partner_email_temp XML NULL END GO --===== Copy the Email contents from partner_email to partner_email_temp column -- after proper conversion to xml type UPDATE [dbo].[Partner] SET partner_email_temp = CAST('<PartnerEmails><Email>' + REPLACE(partner_email, '&', '&amp;') + '</Email><Email></Email><Email></Email></PartnerEmails>' AS XML) GO --===== Drop the exisitng partner_email ALTER TABLE [dbo].[Partner] DROP COLUMN partner_email GO --===== Rename partner_email_temp column to partner_email Exec sp_RENAME 'Partner.partner_email_temp','partner_email','COLUMN' GO I works fine for the first time I ran. Now if I ran it for the next time, it am getting an error Msg 8116, Level 16, State 1, Line 4 Argument data type xml is invalid for argument 1 of replace function. Caution: Changing any part of an object name could break scripts and stored procedures. The intention is that, if the partner_email column is varchar, the script will change it to xml type and will convert all the data in xml format . If I ran it second time, it should ignore the statement. How to achieve this? I am trying in a different way DECLARE @columnDataType VARCHAR(50) SELECT @columnDataType = DATA_TYPE FROM INFORMATION_SCHEMA.columns WHERE table_name = 'Partner' AND column_name = 'partner_email' print @columnDataType IF (@columnDataType = 'varchar') BEGIN --===== Create a partner_email_temp column of type xml into the Partner table IF NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.columns WHERE table_name = 'Partner' AND column_name = 'partner_email_temp' ) BEGIN ALTER TABLE [dbo].[Partner] ADD partner_email_temp XML NULL --===== Copy the Email contents from partner_email to partner_email_temp column -- after proper conversion to xml type UPDATE [dbo].[Partner] SET partner_email_temp = CAST('<PartnerEmails><Email>' + REPLACE(partner_email, '&', '&amp;') + '</Email><Email></Email><Email></Email></PartnerEmails>' AS XML) --===== Drop the exisitng partner_email ALTER TABLE [dbo].[Partner] DROP COLUMN partner_email --===== Rename partner_email_temp column to partner_email EXEC sp_RENAME 'Partner.partner_email_temp','partner_email','COLUMN' END END but getting error Msg 207, Level 16, State 1, Line 29 Invalid column name 'partner_email_temp'. Help needed

    Read the article

  • Color schemes generation - theory and algorithms

    - by daniel.sedlacek
    Hi I will be generating charts and diagrams and I am looking for some theory on color schemes and algorithm examples. Example questions: How to generate complementary or analogous colors? How to generate pastel, cold and warm colors? How to generate any number of random but distinct colors? How to translate all that to the hex triplet (web color)? My implementation will be in AS3 but any examples in metacode are welcome.

    Read the article

  • Proper Usage of Arrays and Functions [closed]

    - by Ssegawa Victor
    Can some one help me write a C code that solves the following problem. PROBLEM Consider the faculty registrar who has to process results for 1st year 1st semester students. Students offer five courses CSC 1100, CSK 1101, CSC 1104, CSC 1105 and CSC 1106. The courses have credit units 4,4,4,3 and 3 respectively. Lecturers provide course work and exam marks. For each course, course work constitutes 40% of the final mark while the exam constitutes 60% of the final mark. The role of the registrar is to Compute the final mark for each student for each course. The final mark must be a whole number Compute the grade and grade point of the students for each course they offered. According to senate regulations, grades and grade points are awarded to final marks according to the following criteria Range Grade Grade Point 90 – 100 A+ 5.0 80 – 89 A 5.0 75 – 79 B+ 4.5 70 – 74 B 4.0 65 – 69 C+ 3.5 60 – 64 C 3.0 55 – 59 D+ 2.5 50 – 54 D 2.0 45 – 49 E 1.5 40 – 44 E- 1.0 0 – 39 F 0.0 Put a comment ‘Retake’ to a student for every course where the Grade Point is less than 2.0 Compute the cumulative grade point average CGPA for each student. The senate formula for CGPA is GGPA =(?_(i=1)^(i=N)¦?CU _i×GP _i ?)/(?_(i=1)^(i=N)¦CU i) Put a comment “Progress” for any student whose GGPA is greater than 2 and “Stay Put” on a student whose CGPA is less than 2 You are required to create a c program that considers a class of 25 students and: 1.Initializes an array ‘student’ which stores student names 2.Initializes arrays for course work and exam for each course. ‘cw_csc_1100’ and ‘ex_csc_1100’ store course work and exam marks (respectively) for CSC 1100. The same approach is considered for all other courses 3.Initializes the coursework and exam marks arrays with marks between 0 and 99 4.Write appropriate functions that will generate the final marks, generate grades, generate grade points, generate cumulative grade points, generate comments for students and comments for courses per student 5.Create appropriate arrays for final marks and insert the data there using the appropriate functions 6.Without having to create any extra arrays, use the functions created to generate a report per student that looks like the one bellow. Student Name: Ngubiri Course Unit Final mark Grade Grade Point Course Comment CSC 1100 43 E- 1.0 Retake CSK 1101 50 D 2.0 CSC 1104 59 D+ 2.5 CSC 1105 70 B 4.0 CSC 1106 65 C+ 3.5 CGPA 2.47 Overall Comment Progress NB It is advisable that the indices are used to identify the owners. Eg if student[x] is John, then cs_csc_100[x] should be a mark for John since the index is the same

    Read the article

  • How should I design a wizard for generating requirements and documentation

    - by user1777663
    I'm currently working in an industry where extensive documentation is required, but the apps I'm writing are all pretty much cookie cutter at a high level. What I'd like to do is build an app that asks a series of questions regarding business rules and marketing requirements to generate a requirements spec. For example, there might be a question set that asks "Does the user need to enter their age?" and a follow-up question of "What is the minimum age requirement?" If the inputs are "yes" and "18", then this app will generate requirements that look something like this: "The registration form shall include an age selector" "The registration form shall throw an error if the selected age is less than 18" Later on down the line, I'd like to extend this to do additional things like generate test cases and even code, but the idea is the same: generate some output based on rules determined by answering a set of questions. Are there any patterns I could research to better design the architecture of such an application? Is this something that I should be modeling as a finite state machine?

    Read the article

  • Procedurally generated 2d terrain for side scroller on Sega Genesis hardware?

    - by DJCouchyCouch
    I'm working on the Sega Genesis that has a 8mhz Motorola 68000 CPU. Any ideas on how to generate fast and decent 2d tile terrain for a side scroller in real time? The game would generate new columns or rows depending on the direction the player is scrolling in. The generation would have to be deterministic. The same seed value would generate the same terrain. I'm looking for algorithms that would satisfy the memory and CPU constraints of the hardware.

    Read the article

< Previous Page | 43 44 45 46 47 48 49 50 51 52 53 54  | Next Page >