Search Results

Search found 960 results on 39 pages for 'confusion'.

Page 7/39 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Confusion in RegExp Reluctant quantifier? Java

    - by Dusk
    Hi, Could anyone please tell me the reason of getting an output as: ab for the following RegExp code using Relcutant quantifier? Pattern p = Pattern.compile("abc*?"); Matcher m = p.matcher("abcfoo"); while(m.find()) System.out.println(m.group()); // ab and getting empty indices for the following code? Pattern p = Pattern.compile(".*?"); Matcher m = p.matcher("abcfoo"); while(m.find()) System.out.println(m.group());

    Read the article

  • yet another confusion with multiprocessing error, 'module' object has no attribute 'f'

    - by gatoatigrado
    I know this has been answered before, but it seems that executing the script directly "python filename.py" does not work. I have Python 2.6.2 on SuSE Linux. Code: #!/usr/bin/python # -*- coding: utf-8 -*- from multiprocessing import Pool p = Pool(1) def f(x): return x*x p.map(f, [1, 2, 3]) Command line: > python example.py Process PoolWorker-1: Traceback (most recent call last): File "/usr/lib/python2.6/multiprocessing/process.py", line 231, in _bootstrap self.run() File "/usr/lib/python2.6/multiprocessing/process.py", line 88, in run self._target(*self._args, **self._kwargs) File "/usr/lib/python2.6/multiprocessing/pool.py", line 57, in worker task = get() File "/usr/lib/python2.6/multiprocessing/queues.py", line 339, in get return recv() AttributeError: 'module' object has no attribute 'f'

    Read the article

  • Vector of Object Pointers, general help and confusion

    - by Staypuft
    Have a homework assignment in which I'm supposed to create a vector of pointers to objects Later on down the load, I'll be using inheritance/polymorphism to extend the class to include fees for two-day delivery, next day air, etc. However, that is not my concern right now. The final goal of the current program is to just print out every object's content in the vector (name & address) and find it's shipping cost (weight*cost). My Trouble is not with the logic, I'm just confused on few points related to objects/pointers/vectors in general. But first my code. I basically cut out everything that does not mater right now, int main, will have user input, but right now I hard-coded two examples. #include <iostream> #include <string> #include <vector> using namespace std; class Package { public: Package(); //default constructor Package(string d_name, string d_add, string d_zip, string d_city, string d_state, double c, double w); double calculateCost(double, double); void Print(); ~Package(); private: string dest_name; string dest_address; string dest_zip; string dest_city; string dest_state; double weight; double cost; }; Package::Package() { cout<<"Constucting Package Object with default values: "<<endl; string dest_name=""; string dest_address=""; string dest_zip=""; string dest_city=""; string dest_state=""; double weight=0; double cost=0; } Package::Package(string d_name, string d_add, string d_zip, string d_city, string d_state, string r_name, string r_add, string r_zip, string r_city, string r_state, double w, double c){ cout<<"Constucting Package Object with user defined values: "<<endl; string dest_name=d_name; string dest_address=d_add; string dest_zip=d_zip; string dest_city=d_city; string dest_state=d_state; double weight=w; double cost=c; } Package::~Package() { cout<<"Deconstructing Package Object!"<<endl; delete Package; } double Package::calculateCost(double x, double y){ return x+y; } int main(){ double cost=0; vector<Package*> shipment; cout<<"Enter Shipping Cost: "<<endl; cin>>cost; shipment.push_back(new Package("tom r","123 thunder road", "90210", "Red Bank", "NJ", cost, 10.5)); shipment.push_back(new Package ("Harry Potter","10 Madison Avenue", "55555", "New York", "NY", cost, 32.3)); return 0; } So my questions are: I'm told I have to use a vector of Object Pointers, not Objects. Why? My assignment calls for it specifically, but I'm also told it won't work otherwise. Where should I be creating this vector? Should it be part of my Package Class? How do I go about adding objects into it then? Do I need a copy constructor? Why? What's the proper way to deconstruct my vector of object pointers? Any help would be appreciated. I've searched for a lot of related articles on here and I realize that my program will have memory leaks. Using one of the specialized ptrs from boost:: will not be available for me to use. Right now, I'm more concerned with getting the foundation of my program built. That way I can actually get down to the functionality I need to create. Thanks.

    Read the article

  • ASP.NET Web Optimization - confusion about loading order

    - by Ciel
    Using the ASP.NET Web Optimization Framework, I am attempting to load some javascript files up. It works fine, except I am running into a peculiar situation with either the loading order, the loading speed, or its execution. I cannot figure out which. Basically, I am using ace code editor for javascript, and I also want to include its autocompletion package. This requires two files. /ace.js /ext-language_tools.js This isn't an issue, if I load both of these files the normal way (with <script> tags) it works fine. But when I try to use the web optimization bundles, it seems as if something goes wrong. Trying this out... bundles.Add(new ScriptBundle("~/bundles/js") { .Include("~/js/ace.js") .Include("~/js/ext-language_tools.js") }); and then in the view .. @Scripts.Render("~/bundles/js") I get the error ace is not defined This means that the ace.js file hasn't run, or hasn't loaded. Because if I break it apart into two bundles, it starts working. bundles.Add(new ScriptBundle("~/bundles/js") { .Include("~/js/ace.js") }); bundles.Add(new ScriptBundle("~/bundles/js/language_tools") { .Include("~/js/ext-language_tools.js") }); Can anyone explain why this would behave in this fashion?

    Read the article

  • OpenGL Coordinate system confusion

    - by user146780
    Maybe I set up GLUT wrong. Basically I want verticies to be reletive to their size in pixels. Ex:right now if I create a hexagon, it hakes up the whole screen even though the units are 6. #include <iostream> #include <stdlib.h> //Needed for "exit" function #include <cmath> //Include OpenGL header files, so that we can use OpenGL #ifdef __APPLE__ #include <OpenGL/OpenGL.h> #include <GLUT/glut.h> #else #include <GL/glut.h> #endif using namespace std; //Called when a key is pressed void handleKeypress(unsigned char key, //The key that was pressed int x, int y) { //The current mouse coordinates switch (key) { case 27: //Escape key exit(0); //Exit the program } } //Initializes 3D rendering void initRendering() { //Makes 3D drawing work when something is in front of something else glEnable(GL_DEPTH_TEST); } //Called when the window is resized void handleResize(int w, int h) { //Tell OpenGL how to convert from coordinates to pixel values glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); //Switch to setting the camera perspective //Set the camera perspective glLoadIdentity(); //Reset the camera gluPerspective(45.0, //The camera angle (double)w / (double)h, //The width-to-height ratio 1.0, //The near z clipping coordinate 200.0); //The far z clipping coordinate } //Draws the 3D scene void drawScene() { //Clear information from last draw glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); //Reset the drawing perspective glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBegin(GL_POLYGON); //Begin quadrilateral coordinates //Trapezoid glColor3f(255,0,0); for(int i = 0; i < 6; ++i) { glVertex2d(sin(i/6.0*2* 3.1415), cos(i/6.0*2* 3.1415)); } glEnd(); //End quadrilateral coordinates glutSwapBuffers(); //Send the 3D scene to the screen } int main(int argc, char** argv) { //Initialize GLUT glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(400, 400); //Set the window size //Create the window glutCreateWindow("Basic Shapes - videotutorialsrock.com"); initRendering(); //Initialize rendering //Set handler functions for drawing, keypresses, and window resizes glutDisplayFunc(drawScene); glutKeyboardFunc(handleKeypress); glutReshapeFunc(handleResize); glutMainLoop(); //Start the main loop. glutMainLoop doesn't return. return 0; //This line is never reached } How can I make it so that a polygon of 0,0 10,0 10,10 0,10 defines a polygon starting at the top left of the screen and is a width and height of 10 pixels? Thanks

    Read the article

  • Oracle TIMESTAMP w/ timezone data type confusion

    - by JuiceBox1337
    When would you use TIMESTAMP w/ timezone as opposed to TIMESTAMP w/ local time zone? When data is stored in a column of data type TIMESTAMP w/ local tz, the data is normalized to the database time zone, and the time zone displacement is not stored as part of the column data. When users retrieve the data, Oracle returns it in the users' local session time zone. Isn't that much more useful? I can't think of a reason why I'd want to use TIMESTAMP w/ timezone and get back some gobble gook with a UTC offset.

    Read the article

  • RS-232 confusion under C++

    - by rock
    What's the problem in given code? Why it is not showing the output for rs232 when we connect it by the d-9 connector with the short of pin number 2 & 3 in that? #include <bios.h> #include <conio.h> #define COM1 0 #define DATA_READY 0x100 #define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00) int main(void) { int in, out, status; bioscom(0, SETTINGS, COM1); /*initialize the port*/ cprintf("Data sent to you: "); while (1) { status = bioscom(3, 0, COM1); /*wait until get a data*/ if (status & DATA_READY) if ((out = bioscom(2, 0, COM1) & 0x7F) != 0) /*input a data*/ putch(out); if (kbhit()) { if ((in = getch()) == 27) /* ASCII of Esc*/ break; bioscom(1, in, COM1); /*output a data*/ } } return 0; }

    Read the article

  • Confusion in bind call in socket programming

    - by Tarun
    i was learning socket programming in unix using c/c++. I am confused with one function call bind(params..). Actually it takes the adreess structure "sockaddr_in" and we can create the structure in the following way sockaddr_in.*** = somthing.. sockaddr_in..s_addr htonl(INADDR_ANY) **Passing INADDR_ANY will alow to bind all local addresses** My question is , why do we need to use "INADDR_ANY" ? In my knowledge every machine can has only one unique IP Address. In this way there is only one address associated with the machien. Thye bind call should directly bind the socket to the single available address. Please explain what are the different scenarios and why is it so?

    Read the article

  • Apache Rewrite rule confusion

    - by Lee
    I'm trying to convert a simple url (below) in to a blog-style url, but not quite sure how to do it, all of my other rules are working fine, but I can't seem to figure this one out. URL I want to convert: http://www.website.com/myblog.php?id=1&title=My+blog+title URL I want it to create: http://www.website.com/1/my-blog-title What should the rule be? Any assistance appreciated :)

    Read the article

  • Bitmap Confusion Android

    - by Farhan
    I am getting an image from gallery in onActivityResult() through intent.getdata(). Now i get the data and set it to a bitmap, its size is 716x716 and its setting to full screen. (ImageView's width and height is set to wrap content). Now i created another bitmap after scaling the original through Bitmap.CreateScaledBitmap(orgBitmap,30,30,false); After this, i make sure these things(width,height n size) and they happen as they should be but the problem is that the image is still taking the full screen... rather it should only take 30dp x 30dp. Anyone have an idea what might be the problem??? Thanx

    Read the article

  • Confusion with cookie session token and oauth2.0 don't know where to go anymore

    - by byte_slave
    Hi guys, I'm completely confused, frustrated and nothing seems to make sense and work any more. I' dev some iframe fb app and i've been using the javascript sdk (FB.Init()) to get the access_token, but doesn't always work, sometimes i'm already logged into FB and doesn't works... Did some reading, and read also that there is problems using cookies in iframes in Opera and IE, so I was thinking in use the OAuth 2.0 but i'm not sure how via facebook sdk c# and now I'm now completely lost, don't know if i still need to use the javascript FB.Init(). Documentation out there is poor and unclear, a lot of stuff refers to old code, and after hours of reading, jumping on examples, i'm completely messed up and confused. Can some, please, point/explain/enlightening me about this? Thanks a lot guys, appreciated! Merry christmas!

    Read the article

  • Exceptions confusion

    - by Misiur
    Hi there. I'm trying to build site using OOP in PHP. Everyone is talking about Singleton, hermetization, MVC, and using exceptions. So I've tried to do it like this: Class building whole site: class Core { public $is_core; public $theme; private $db; public $language; private $info; static private $instance; public function __construct($lang = 'eng', $theme = 'default') { if(!self::$instance) { try { $this->db = new sdb(DB_TYPE.':host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASS); } catch(PDOException $e) { throw new CoreException($e->getMessage()); } try { $this->language = new Language($lang); } catch(LangException $e) { throw new CoreException($e->getMessage()); } try { $this->theme = new Theme($theme); } catch(ThemeException $e) { throw new CoreException($e->getMessage()); } } return self::$instance; } public function getSite($what) { return $this->language->getLang(); } private function __clone() { } } Class managing themes class Theme { private $theme; public function __construct($name = 'default') { if(!is_dir("themes/$name")) { throw new ThemeException("Unable to load theme $name"); } else { $this->theme = $name; } } public function getTheme() { return $this->theme; } public function display($part) { if(!is_file("themes/$this->theme/$part.php")) { throw new ThemeException("Unable to load theme part: themes/$this->theme/$part.php"); } else { return 'So far so good'; } } } And usage: error_reporting(E_ALL); require_once('config.php'); require_once('functions.php'); try { $core = new Core(); } catch(CoreException $e) { echo 'Core Exception: '.$e->getMessage(); } echo $core->theme->getTheme(); echo "<br />"; echo $core->language->getLang(); try { $core->theme->display('footer'); } catch(ThemeException $e) { echo $e->getMessage(); } I don't like those exception handlers - i don't want to catch them like some pokemons... I want to use things simple: $core-theme-display('footer'); And if something is wrong, and debug mode is enabled, then aplication show error. What should i do?

    Read the article

  • C++ Translation Phase Confusion

    - by blakecl
    Can someone explain why the following doesn't work? int main() // Tried on several recent C++ '03 compilers. { #define FOO L const wchar_t* const foo = FOO"bar"; // Will error out with something like: "identifier 'L' is undefined." #undef FOO } I thought that preprocessing was done in an earlier translation phase than string literal operations and general token translation. Wouldn't the compiler be more or less seeing this: int main() { const wchar_t* const foo = L"bar"; } It would be great if someone could cite an explanation from the standard.

    Read the article

  • Method parameters confusion

    - by elec
    Often time methods take more than 3 parameters which are all of the same type, eg. void mymethod (String param1, String param2, String param3) then it's very easy for the client to mix up the parameters orders, for instance inverting param1 and param2: mymethod (param2, param1, param3); ...which can be the cause of much time spent debugging what should be a trivial matter. Any tips on how to avoid this sort of mistake (apart from unit tests) ?

    Read the article

  • newbie hibernate first level cache confusion

    - by Bruce
    Hi all I'm just geting to grips with hibernate. Little bit confused. I just wanted to watch the operation of the first level cache, which I understood to batch up queries until the end of the session. But if I create an object, hibernate saves it immediately, so that when I later update it in the same transaction, it has to do an update too: Session session = factory.getCurrentSession(); session.beginTransaction(); Test1 test1 = new Test1(); test1.setName("Test 1"); test1.setValue(10); // Touch it session.save(test1); System.out.println("At checkpoint 1"); test1.setValue(20); session.getTransaction().commit(); I see the sql for the save, then 'At checkpoint 1', then the sql for the update. Do I have something set up wrong or am I misunderstanding hibernate's first level cache? Is there a good document on the first level cache - I didn't find anything in the hibernate docs, but I could easily have missed it.. Thanks!

    Read the article

  • C String input confusion

    - by ahref
    C really isn't my strong point and after reading 3 chapters of a book on the subject and spending ages trying to get stuff working it just doesn't: #include <stdio.h> char *a,*b; int main( ) { char input[10]; fgets(input,sizeof input, stdin); a = input; fgets(input,sizeof input, stdin); b = input; printf("%s : %s",a,b); } I've isolated the problem from my main project. This code is meant to read in two strings and then print them however it seems to be setting a and b to point to input. Sample output from this code when A and B are entered is(don't worry about the \n's i can remove them): A B B : B How do i store the value of input in another variable eg. a or b so that in the above case A B A : B Is output? Thanks

    Read the article

  • SQL server db and printing confusion.

    - by RAJ K
    I have billing application based on C# WPF, Screenshot is here. as you can see there is a datagrid, programmatically binded. this datagrid contains lists of item going to be billed. So when user reaches "Print memo" part (in stack panel 2) i have to update listed items in stock table and insert entries in sales table and finally print the memo. I want to know is there any speedy way to so because as user gives print command I have to clear datagrid which holds product lists and start accepting new lists. if you could provide few code or link, will be really helpful.. thanks.........

    Read the article

  • Django Import Error with URLS and ROOT_URLCONF confusion

    - by tipu
    The error can be seen here: http://djaffry.selfip.com:8080/ In httpd conf, <VirtualHost *:8080> ServerName tweet_search_engine DocumentRoot /var/www/microblogsearchengine/twingle </VirtualHost> <Directory /var/www/microblogsearchengine/twingle> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE settings PythonOption django.root /var/www/microbloggingsearchengine/twingle PythonDebug On </Directory> Running python manage.py runserver and visiting localhost:8000 returns a splash page telling me everything is okay. However when I visit this site through apache, I get an import error with urls. In my settings.py file I have a line, ROOT_URLCONF = 'twingle.urls' I'm assuming this is the cause of the error. The project folder contains only 4 files: __init__.py manage.py settings.py urls.py I tried replacing twingle.urls with urls.py but then it gave me a different error. What is it I can do to get this working?

    Read the article

  • C Static Function Confusion

    - by Lime
    I am trying to make the s_cord_print function visible in the cord_s.c file only. Currently the function is visible/runnable in main.c even when it is declared static. How do I make the s_cord_print function private to cord_s.c? Thanks! s_cord.c typedef struct s_cord{ int x; int y; struct s_cord (*print)(); } s_cord; void* VOID_THIS; #define $(EL) VOID_THIS=&EL;EL static s_cord s_cord_print(){ struct s_cord *THIS; THIS = VOID_THIS; printf("(%d,%d)\n",THIS->x,THIS->y); return *THIS; } const s_cord s_cord_default = {1,2,s_cord_print}; main.c #include <stdio.h> #include <stdlib.h> #include "s_cord.c" int main(){ s_cord mycord = s_cord_default; mycord.x = 2; mycord.y = 3; $(mycord).print().print(); //static didn't seem to hide the function s_cord_print(); return 0; } ~

    Read the article

  • BeautifulSoup Parser Confusion - HTML

    - by lyngbym
    I'm trying to scrape some content off another site and I'm not sure why BeautifulSoup is producing this output. It is only finding a blank space inside the match, but the real HTML contains a large amount of markup. I apologize if this is something stupid on my part. I'm new to python. Here's my code: import sys import os import mechanize import re from BeautifulSoup import BeautifulSoup def scrape_trails(BASE_URL, data): #Get the trail names soup = BeautifulSoup(data) sitesDiv = soup.findAll("div", attrs={"id" : "sitesDiv"}) print sitesDiv def main(): BASE_URL = "http://www.dnr.state.mn.us/skiing/skipass/list.html" br = mechanize.Browser() data = br.open(BASE_URL).get_data() links = scrape_trails(BASE_URL, data) if __name__ == '__main__': main() If you follow that URL you can see the sitesDiv contains a lot of markup. I'm not sure if I'm doing something wrong or if this is just malformed markup that the script can't handle. Thanks!

    Read the article

  • static initialization confusion

    - by Happy Mittal
    I am getting very confused in some concepts in c++. For ex: I have following two files //file1.cpp class test { static int s; public: test(){s++;} }; static test t; int test::s=5; //file2.cpp #include<iostream> using namespace std; class test { static int s; public: test(){s++;} static int get() { return s; } }; static test t; int main() { cout<<test::get()<<endl; } Now My question is : 1. How two files link successfully even if they have different class definitions? 2. Are the static member s of two classes related because I get output as 7. Please explain this concept of statics.

    Read the article

  • Confusion with a while statement evaluating if a number is triangular

    - by Darkkurama
    I've been having troubles trying to figure out how to solve a function. I've been assigned the development of a little programme which tells if a number is "triangular" (a number is triangular when the addition of certain consecutive numbers in the [1,n] interval is n. Following the definition, the number 10 is triangular, because in the [1,10] interval, 1+2+3+4=10). I've coded this so far: class TriangularNumber{ boolean numTriangular(int n) { boolean triangular = false; int i = n; while(n>=0 && triangular){ //UE06 is a class which contains the function "f0", which makes the addition of all the numbers in a determined interval UE06 p = new UE06(); if ((p.f0(1, i))==n) triangular = true; else i=i-1; } return triangular; } boolean testTriangular = numTriangular(10) == true && numTriangular(7) == false && numTriangular(6) == true; public static void main(String[] args){ TriangularNumber p = new TriangularNumber(); System.out.println("testTriangular = " + p.testTriangular); } } According to those boolean tests I made, the function is wrong. As I see the function, it goes like this: I state that the input number in the initial state isn't triangular (triangular=false) and i=n (determining the interval [1,i] where the function is going to be evaluated While n is greater or equals 0 and the number isn't triangular, the loop starts The loop goes like this: if the addition of all the numbers in the [1,i] interval is n, the number is triangular, causing the loop to end. If that statement is false, i goes from i to (i-1), starting the loop again with that particular interval, and so on till the addition is n. I can't spot the error in my "algorithm", any advice? Thanks!

    Read the article

  • confusion using rjs for a link_to_remote

    - by odpogn
    My application layout contains a navigation div, and a content div constructed as a partial. I want to use ajax so that whenever a person clicks on a link in the navigation div, the contents of that page renders in the content div without a refresh. I'm confused on how to properly do this... any help for a rails noob??? thanks in advance~ application.html.erb <body> <div id="container"> <%= render 'layouts/header' %> <%= render 'layouts/content'%> <%= render 'layouts/footer' %> </div> </body> _header.html.erb <%= link_to_remote "Home", :url => { :controller => "pages", :action => "home" } %> _content.html.erb <div id="content"> <%= yield %> </div> pages_controller.rb def home @title = "Home" respond_to do |format| format.js end end home.rjs page.replace_html :container, :partial => 'layouts/content'

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >