Search Results

Search found 31491 results on 1260 pages for 'simple talk'.

Page 72/1260 | < Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >

  • Simple OOP-related question.

    - by M4design
    This question came to my mind quite a few times. Let my explain my question through an example. Say I've got two classes: 1- Grid. 2- Cell. Now the location of the cell 'should' be stored in the grid class, not in the cell class itself. Say that the cell wanted to get its location through a method in the grid. How can it do that? Keep in mind that the cell was created/initialised by the Grid class. What good OO approach to solve this problem? Thank you

    Read the article

  • Simple Big O with lg(n) proof

    - by halohunter
    I'm attempting to guess and prove the Big O for: f(n) = n^3 - 7n^2 + nlg(n) + 10 I guess that big O is n^3 as it is the term with the largest order of growth However, I'm having trouble proving it. My unsuccesful attempt follows: f(n) <= cg(n) f(n) <= n^3 - 7n^2 + nlg(n) + 10 <= cn^3 f(n) <= n^3 + (n^3)*lg(n) + 10n^3 <= cn^3 f(n) <= N^3(11 + lg(n)) <= cn^3 so 11 + lg(n) = c But this can't be right because c must be constant. What am I doing wrong?

    Read the article

  • any simple jquery <table> paginators

    - by Mike
    I'm looking for a jquery plugin so I can paginate my html tables (the content of which is generated by a jsp c:forEach). But so far I haven't found anything that worked. The plugin doesn't need to be fancy, in fact something like the first example on http://dl.dropbox.com/u/4151695/html/pajinate-0.2/examples/example1.html would do fine. I'm still very new to jquery so I don't have the knowledge yet to write one myself. So does anyone have any pointers where I could find one?

    Read the article

  • Why does this code leak? (simple codesnippet)

    - by Ela782
    Visual Studio shows me several leaks (a few hundred lines), in total more than a few MB. I traced it down to the following "helloWorld example". The leak disappears if I comment out the H5::DataSet.getSpace() line. #include "stdafx.h" #include <iostream> #include "cpp/H5Cpp.h" int main(int argc, char *argv[]) { _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); // dump leaks at return H5::H5File myfile; try { myfile = H5::H5File("C:\\Users\\yyy\\myfile.h5", H5F_ACC_RDONLY); } catch (H5::Exception& e) { std::string msg( std::string( "Could not open HDF5 file.\n" ) + e.getCDetailMsg() ); throw msg; } H5::Group myGroup = myfile.openGroup("/so/me/group"); H5::DataSet myDS = myGroup.openDataSet("./myfloatvec"); hsize_t dims[1]; //myDS.getSpace().getSimpleExtentDims(dims, NULL); // <-- here's the leak H5::DataSpace dsp = myDS.getSpace(); // The H5::DataSpace seems to leak dsp.getSimpleExtentDims(dims, NULL); //dsp.close(); // <-- doesn't help either std::cout << "Dims: " << dims[0] << std::endl; // <-- Works as expected return 0; } Any help would be appreciated. I've been on this for hours, I hate unclean code...

    Read the article

  • Creating a simple sencha listview using a loop

    - by chris_sencha
    How do we substitute a hardcoded data with a for loop in sencha and extjs? Say, I have below hardcoded one Ext.application({ launch: function() { Ext.create('Ext.List', { fullscreen: true, itemTpl: '{title}', data: [{ title: 'Item 1' }, { title: 'Item 2' }, { title: 'Item 3' }, { title: 'Item 4' }] }); } }); In the above one, how to replace data to something like below Ext.application({ launch: function() { Ext.create('Ext.List', { fullscreen: true, itemTpl: '{title}', data: [ for(int i=0;i<5;i++){ {title: 'Item '+i}, } ] }); } });

    Read the article

  • Help with simple frame, and graphics in Java

    - by Crystal
    For hw, I'm trying to create a "CustomButton" that has a frame and in that frame, I draw two triangles, and a square over it. It's supposed to give the user the effect of a button press once it is depressed. So for starters, I am trying to set up the beginning graphics, drawing two triangles, and a square. The problem I have is although I set my frame to 200, 200, and the triangles I have drawn I think to the correct ends of my frame size, when I run the program, I have to extend my window to make the whole artwork, my "CustomButton," viewable. Is that normal? Thanks. Code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class CustomButton { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { CustomButtonFrame frame = new CustomButtonFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); } } class CustomButtonFrame extends JFrame { // constructor for CustomButtonFrame public CustomButtonFrame() { setTitle("Custom Button"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); CustomButtonSetup buttonSetup = new CustomButtonSetup(); this.add(buttonSetup); } private static final int DEFAULT_WIDTH = 200; private static final int DEFAULT_HEIGHT = 200; } class CustomButtonSetup extends JComponent { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; // first triangle coords int x[] = new int[TRIANGLE_SIDES]; int y[] = new int[TRIANGLE_SIDES]; x[0] = 0; y[0] = 0; x[1] = 200; y[1] = 0; x[2] = 0; y[2] = 200; Polygon firstTriangle = new Polygon(x, y, TRIANGLE_SIDES); // second triangle coords x[0] = 0; y[0] = 200; x[1] = 200; y[1] = 200; x[2] = 200; y[2] = 0; Polygon secondTriangle = new Polygon(x, y, TRIANGLE_SIDES); g2.drawPolygon(firstTriangle); g2.setColor(Color.WHITE); g2.fillPolygon(firstTriangle); g2.drawPolygon(secondTriangle); g2.setColor(Color.GRAY); g2.fillPolygon(secondTriangle); // draw rectangle 10 pixels off border g2.drawRect(10, 10, 180, 180); } public static final int TRIANGLE_SIDES = 3; }

    Read the article

  • super(type,subclass) in simple singleton implementation

    - by Tianchen Wu
    when I was implementing naive singleton in python, I came up with a problem with super key word. As usual the behavior of super is always tricky and buggy, hope someone can shed light on it. Thanks :) The problem is that: class Singleton(object): def __new__(cls,*args,**kw): if not hasattr(cls,'_instance'): #create a instance of type cls, origin=super(Singleton,Singleton).__new__(cls,*args,**kw) cls._instance=origin return cls._instance class B(Singleton): def __init__(self,b): self.b=b It actually works, but I am wondering Will it be better if I change line 5 to the below, like in most of the books? origin=super(Singleton,cls).__new__(cls,*args,**ks) what's the difference to make?

    Read the article

  • Simple C++ code (what's wrong here?)

    - by JW
    Noob to C++. I'm trying to get user input (Last Name, First Name Middle Name), change part of it (Middle Name to Middle Initial) and then rearrange it (First Middle Initial Last). Where am I messing up in my code? --Thanks for ANY help you can offer! ... #include <iostream> using std::cout; using std::cin; #include <string> using std::string; int main() { string myString, last, first, middle; cout << "Enter your name: Last, First Middle"; cin >> last >> first >> middle; char comma, space1, space2; comma = myString.find_first_of(','); space1 = myString.find_first_of(' '); space2 = myString.find_last_of(' '); last = myString.substr (0, comma); // user input last name first = myString.substr (space1+1, -1); // user input first name middle = myString.substr (space2+1, -1); // user input middle name middle.insert (0, space2+1); // inserts middle initial in front of middle name middle.erase (1, -1); // deletes full middle name, leaving only middle initial myString = first + ' ' + middle + ' ' + last; // return 0; }

    Read the article

  • Rewriting simple C# nested class

    - by Daniel
    What would be an elegant way to implement the functionality of this nested class in F#? private class Aliaser { private int _count; internal Aliaser() { } internal string GetNextAlias() { return "t" + (_count++).ToString(); } } This was my first attempt, but it feels like there should be a sexy one-liner for this: let aliases = (Seq.initInfinite (sprintf "t%d")).GetEnumerator() let getNextAlias() = aliases.MoveNext() |> ignore aliases.Current

    Read the article

  • Simple logic in javascript

    - by Saurabh
    I have four variables of type integer - var tip_1, tip_2, tip_3, tip_4; The value of these variables are getting fill by some other logic which is always between 1 to 10. I need to maintain a hash with variable name as "key" and value as "value" by following these rules - The variable with MAX value should be the first element in the hash and so on. e.g. if tip_1 = 4, tip_2 = 1, tip_3 = 2, tip_4 = 10 then hash should be something like, Hash = {tip_4, 10} {tip_1, 4} {tip_3, 2} {tip_1, 1} In case of tie following order should be considered - tip_1 tip_2 tip_3 tip_4;

    Read the article

  • GWT celltable Simple pager Next and previous buttons

    - by Saritha
    I am working on a CellTable with a SimplePager. My paging works fine in the sense when i set the page size to be 5 only 5 records are being displayed. My question is that do next and previous buttons come by default or do we have to configure them. I have seen the show case example code and i do not see any external configurations . my SimplePager code is as follows: //create pager SimplePager.Resources resources = GWT.create(SimplePager.Resources.class); SimplePager simplePager = new SimplePager(TextLocation.CENTER, resources , false, 0, true); simplePager.setDisplay(cellTableSearchResults); simplePager.setPageSize(5); // create data provider ListDataProvider<GridDTO> dataProvider = new ListDataProvider<GridDTO>(); dataProvider.addDataDisplay(cellTableSearchResults); dataProvider.setList(components); Please help.

    Read the article

  • simple c++ file opening issue

    - by Robert
    #include <iostream> #include <fstream> using namespace std; int main () { ofstream testfile; testfile.open ("test.txt"); testfile << "success!\n"; testfile.close(); return 0; } 1)called "g++ testfile.cpp" 2)created "test.txt" 3)called "chmod u+x a.out" 4)??? 5)file remains blank. I feel like an idiot for failing at something as trivial as this is supposed to be.

    Read the article

  • How to get REALLY fast python over a simple loop

    - by totallymike
    I'm working on a spoj problem, INTEST. The goal is to specify the number of test cases (n) and a divisor (k), then feed your program n numbers. The program will accept each number on a newline of stdin and after receiving the nth number, will tell you how many were divisible by k. The only challenge in this problem is getting your code to be FAST because it k can be anything up to 10^7 and the test cases can be as high as 10^9. I'm trying to write it in python and having trouble speeding it up. Any ideas? import sys first_in = raw_input() thing = first_in.split() n = int(thing[0]) k = int(thing[1]) total = 0 i = 0 for line in sys.stdin: t = int(line) if t % k == 0: total += 1 print total

    Read the article

  • Transform shape built of contour splines to simple polygons

    - by Cheery
    I've dumped glyphs from truetype file so I can play with them. They have shape contours that consist from quadratic bezier curves and lines. I want to output triangles for such shapes so I can visualize them for the user. Traditionally I might use libfreetype or scan-rasterise this kind of contours. But I want to produce extruded 3D meshes from the fonts and make other distortions with them. So, how to polygonise shapes consisting from quadratic bezier curves and lines? There's many contours that form the shape together. Some contours are additive and others are subtractive. The contours are never open. They form a loop. (Actually, I get only contour vertices from ttf glyphs, those vertices define whether they are part of the curve or not. Even though it is easy to decompose these into bezier curves and lines, knowing the data is represented this way may be helpful for polygonizing the contours to triangles)

    Read the article

  • jQuery + Simple Dialog

    - by Panther24
    Hi, I have a jQuery Model windows which contains a form. On creating of the page, I'm able to see the fields although in my dialog, i have set autoOpen to false. All the forms are in a div. a sample of my dialog looks like this: $("#dialog-form").dialog({ autoOpen: false, height: 460, width: 750, modal: true, buttons: { 'Create Map': function() { document.registerFrm.submit(); }, Cancel: function() { $(this).dialog('close'); } }, close: function() { allFields.val('').removeClass('ui-state-error'); } }); Any way to resolve, I don't want the form fields to be visible on load/creation of the page.

    Read the article

  • Java or C# + XNA for some simple animations?

    - by lala
    I want to make a program that will involve some faces with various facial expressions. They will change from one facial expression to another based on their "mood" as influenced by user input. I know some java but I have done pretty much nothing with graphics. A friend tells me that it will be easier to do this in C# with XNA than to do it in java. I have about a month to do this, so I was hoping you folks would help me make a decision. Would I be better off figuring out how to do this in java, or learning C# and XNA and doing it in C#? Is it so much easier to do this in C# that it would be quicker to learn C# than to struggle with doing it in java? Will it probably come out looking much better if it is in C#?

    Read the article

  • how to start writing a very simple programming language

    - by Rex Homming
    Recently, I was going around looking for ideas on what I can build using C this summer and I came across this post: http://stackoverflow.com/questions/1257376/interesting-project-to-learn-c Implement a programming language. This doesn't have to be terribly hard - I did the language that must not be named - but it will force you to learn a lot of the important parts of C. If you don't want to write a lexer and/or parser yourself, you can use lex/flex and yacc/bison, but if you plan on that you might want to start with a somewhat smaller project. I was kinda intrigued about the implementing a programming language answer and I'm wondering how do I go about starting this? I've gone through the whole K&R book and I've done some of the exercises as well. I also have a bit of experience in C++ and Java if that matters. Any tips? Thanks!

    Read the article

  • Javascript simple regexp doesn't work

    - by bah
    Hi, I have this code, it looks alright and is really basic, but i can't make it work: function checkValid(elem){ var abc = elem.value; var re = "/[0-9]/"; var match = re.test(abc); alert(match); } It matches 0 and 9, but not 1 to 8, what's wrong here? Thanks.

    Read the article

  • Can't record or play with a simple recorder?

    - by user1280535
    I have 2 classes, a record and a player. In my main scene, I create an instance of them and play and record. But, as I see, it only records and somehow does not play (the file is not there!) Here is the code for both : -(void)record { NSArray *dirPaths; NSString *docsDir; NSString *sound= @"sound0.caf" ; dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) ; docsDir = [dirPaths objectAtIndex:0]; NSString *soundFilePath = [docsDir stringByAppendingPathComponent:sound]; NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath]; NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithFloat: 44100.0], AVSampleRateKey, [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey, [NSNumber numberWithInt: 1], AVNumberOfChannelsKey, [NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey, nil]; NSError *error; myRecorder = [[AVAudioRecorder alloc] initWithURL:soundFileURL settings:settings error:&error]; if (myRecorder) { NSLog(@"rec"); [myRecorder prepareToRecord]; myRecorder.meteringEnabled = YES; [myRecorder record]; } else NSLog( @"error" ); } I can see the log of rec. -(void)play { NSArray *dirPaths; NSString *docsDir; dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); docsDir = [dirPaths objectAtIndex:0]; NSString *soundFilePath1 = @"sound0.caf" ; NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath1]; BOOL isMyFileThere = [[NSFileManager defaultManager] fileExistsAtPath:soundFilePath1]; if(isMyFileThere) { NSLog(@"PLAY"); avPlayer1 = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:NULL]; avPlayer1.volume = 8.0; avPlayer1.delegate = self; [avPlayer1 play]; } } I DONT SEE THE LOG OF PLAY ! I call them both with: recInst=[recorder alloc]; //to rec [recInst record]; plyInst=[player alloc]; //play [plyInst play]; and to stop the recorder: - (void)stopRecorder { NSLog(@"stopRecordings"); [myRecorder stop]; //[myRecorder release]; } What's wrong here? Thanks.

    Read the article

  • Simple question about javascript history.go

    - by Camran
    I have a classifieds website. In every classified, there is a back link which simply takes the browser back one step. This is because when users search classifieds, and click on one to view it, they can easily go back with a link also (instead of only the browser back button). Here is the problem, if the classified is entered directly into the adress bar of a browser, or if somebody bookmarked a classified, then this back-link would take them someplace else... Is there any way of making sure that the previous page is a certain page (index.php in my case)? This way I would only display the back link if the previous page was index.php... Thanks

    Read the article

  • I'm following Qt Tutorials and got a simple question

    - by nzer0
    If I want to create my own class MyWidget which inherits from QWidget Tutorial tells me to write constructor like this... MyWidget::MyWidget(QWidget *parent) : QWidget(parent){....} I'm wondering what is the role of : QWidget(parent) Does it mean explicit call for QWidget's constructor?

    Read the article

  • Simple stream read/write question in java

    - by Marius
    Hi, I'm trying to upload a file via URLConnection, but i need to read/write it as a binary file without any encoding changes. So i've tried to read byte[] array from FileInputStream, but now i have an issue. The PrintWriter object i use for outputing to the server does not allow me to do writer.write(content) (where content is of type byte[]). How can i fix this? Or is there another way to quickly copy binary data from a FileInputStream to a PrintWriter? Thank you

    Read the article

  • Google App Engine/Simple HTML, how to write input boxes with google autocomplete

    - by Calm Storm
    I am writing a GAE application and I would like to have an input box with google auto-suggest. Specifically, when a user types "Shawshank" I would like to see google's suggestions in my drop down. Can someone tell me what are the different ways of doing this? I understand I may have to use some javascript libraries so any code samples etc will help immensely. (Pure javascript/jquery kinda solutions will be more preferable)

    Read the article

< Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >