Daily Archives

Articles indexed Friday January 7 2011

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

  • Apache mod_proxy to another server

    - by trobrock
    I am using the proxy_balancer in Apache2 to proxy requests to a Rails application to my rails server on the port the application is running on. This is how its set up... Rails Server Mongrel running on port 8000, when accessing the url directly to http://rails_server:8000 the site loads fine Apache Server Conf file for the site: <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName myserver.com ServerAlias application.myserver.com <Proxy balancer://application_cluster> Allow from localhost BalancerMember http://ip.to.server:8000 retry=10 </Proxy> ProxyPass / balancer://application_cluster </VirtualHost> The problem I am having is going to http://rails_server:8000 works fine, but going to http://application.myserver.com Loads the right content, but is displaying all the HTML as text and not rendering it as html

    Read the article

  • is ksplice production ready?

    - by faultyserver
    I would be interested to hear the serverfault community's experiences with Ksplice in production. Quick blurb from wikipedia: Ksplice is a free and open source extension of the Linux kernel which allows system administrators to apply security patches to a running kernel without having to reboot the operating system. and Ksplice can, without restarting the kernel, apply any source code patch that only needs to modify the kernel code. Unlike other hot update systems, Ksplice takes as input only a unified diff and the original kernel source code, and it updates the running kernel correctly, with no further human assistance required. Additionally, taking advantage of Ksplice does not require any preparation before the system is originally booted (the running kernel does not need to have been specially compiled, for example). In order to generate an update, Ksplice must determine what code within the kernel has been changed by the source code patch. So a few questions: How has the stability been? any odd issues that you have encountered with its 'rebootless live patching' of the kernel? Kernel panics or horror stories? I have been running it on a few test systems and so far its been working as advertised, but I am interested in what other sysadmins experiences have been with Ksplice before going 'all in' and deploying this on our production servers. So, anybody using Kspice in production? update: hmm, not seeing any real activity on this question after a couple of hours (besides some kind upvotes and favs). Maybe to spark some activity I'll also ask a few more questions and see if we can get this discussion going... "If you are aware of Ksplice, is there a reason you are not using it?" "Do you feel its still too bleeding edge, unproven or untested?" "Does Ksplice not fit well within your current patch-management system?" "Do you hate having systems that have long (and secure) uptimes?" ;-)

    Read the article

  • rpd over https using a linux client

    - by Nils
    My employer switched from vpn and rdp to using what our admin calls "rdp over https". Since that switch I find myself unable to connect to the "new" rdp server. I think the progress is as follows: A rdp gateway-server is connected via tls the requested sever (different from the gateway-server) is then connected through the tls connection. In windows mstsc-settings the server name is the "internal network name" of the machine I wish to connect. And on the last tab (in German it is called "leistung" - could be activity) I go to the "connection from everywhere" settings and set the gateway-server under gateway-server. Now: Is there any way to use this scenario under linux (apart from a virtual machine running Windows)? I am interested in free ideas (e.g. is it possible to create a tls tunnel and connect through that using freerdp/rdesktop?) non-free ideas. As long as they work I'll worry about the costs later. Free ideas would be better :-)

    Read the article

  • How would you change a home wireless router with a self-signed admin site certificate to be more secure?

    - by jldugger
    littleblackbox is publishing "private keys" that are accessible on publicly available firmwares. Debian calls these "snake-oil" certs. Most of these routers are securing their HTTPS certs with these, and as I think about it, I've never seen one of these internal admin websites with certs that wasn't self signed. Given a webserver on IP 192.168.1.1, how do you secure it to the point that Firefox doesn't offer warnings (and is still secured)?

    Read the article

  • Program to customize mouse buttons?

    - by roflwaffle
    I have a Logitech M510 wireless mouse and am on a Mac. Right now I can assign different actions to the 2 thumb buttons through the Logitech control panel. What I want to do is have mouse button combos to perform actions. So if I am holding thumb button 1 and click the left button, a tab will close in Chrome. As well as any other "hold one button, click another" combination. Is there any program out there that gives this type of customization?

    Read the article

  • The effects of Agile Programming can alter the five desirable properties of modeling tools and techniques

    The effects of Agile Programming can alter the five desirable properties of modeling tools and techniques as documented by Pfleeger. The agile methodology does promote human understanding and communication through the use of short iterative software development life cycles which forces stakeholders to review the project and adjust the project for any requirement changes.  Due to the consistent evaluations of a project and requirements, process are continually being refined, upgraded, and compared against other alternatives to ensure the best design delivered to the client. Due to the short repetitive development cycles, increased time is devoted to process management due to the fact that requirements and designs could be constantly changing. This requires additional forecasting, monitoring, and planning for each iteration. Because things can change so rapidly, automated guidance in performing process must be updated for each iteration because the environment and the available reusable process could change. In addition, the original guidance and suggestions for the project also need to be updated to account for these changes as well.   In essence the automation of process execution is supported by the agile methodology because during every iteration all processes must be tested, evaluated to ensure process integrity and compliance with the customer’s requirements. I do not think the agile approach diminishes modeling, in fact I think it increases the modeling because before the start of every development cycle, modeling must be checked for accuracy based on the changed requirements. So in essence the reduced time spent initially designing the models is in fact gained as the project completes every iteration of the project.

    Read the article

  • PERT shows relationships between defined tasks in a project without taking into consideration a time line

    The program evaluation and review technique (PERT) shows relationships between defined tasks in a project without taking into consideration a time line. This chart is an excellent way to identify dependencies of tasks based on other tasks. This chart allows project managers to identify the critical path of a project to minimize any time delays to the project. According to Craig Borysowich in his article “Pros & Cons of the PERT/CPM Method stated the following advantages and disadvantages: “PERT/CPM has the following advantages: A PERT/CPM chart explicitly defines and makes visible dependencies (precedence relationships) between the WBS elements, PERT/CPM facilitates identification of the critical path and makes this visible, PERT/CPM facilitates identification of early start, late start, and slack for each activity, PERT/CPM provides for potentially reduced project duration due to better understanding of dependencies leading to improved overlapping of activities and tasks where feasible.  PERT/CPM has the following disadvantages: There can be potentially hundreds or thousands of activities and individual dependency relationships, The network charts tend to be large and unwieldy requiring several pages to print and requiring special size paper, The lack of a timeframe on most PERT/CPM charts makes it harder to show status although colors can help (e.g., specific color for completed nodes), When the PERT/CPM charts become unwieldy, they are no longer used to manage the project.” (Borysowich, 2008) Traditionally PERT charts are used in the initial planning of a project like in a project that is utilizing the waterfall approach. Once the chart was created then project managers could further analyze this data to determine the earliest start time for each stage in the project. This is important because this information can be used to help forecast resource needs during a project and where in the project. However, the agile environment can approach this differently because of their constant need to be in contact with the client and the other stakeholders.  The PERT chart can also be used during project iteration to determine what is to be worked on next, such as a prioritized To-Do list a wife would give her husband at the start of a weekend. In my personal opinion, the COTS-centric environment would not really change how a company uses a PERT chart in their day to day work. The only thing I can is that there would be less tasks to include in the chart because the functionally milestones are already completed when the components are purchased. References: http://www.netmba.com/operations/project/pert/ http://web2.concordia.ca/Quality/tools/20pertchart.pdf http://it.toolbox.com/blogs/enterprise-solutions/pros-cons-of-the-pertcpm-method-22221

    Read the article

  • Common business drivers that lead to creating and sustaining a project

    Common business drivers that lead to creating and sustaining a project include and are not limited to: cost reduction, increased return on investment (ROI), reduced time to market, increased speed and efficiency, increased security, and increased interoperability. These drivers primarily focus on streamlining and reducing cost to make a company more profitable with less overhead. According to Answers.com cost reduction is defined as reducing costs to improve profitability, and may be implemented when a company is having financial problems or prevent problems. ROI is defined as the amount of value received relative to the amount of money invested according to PayperclickList.com.  With the ever increasing demands on businesses to compete in today’s market, companies are constantly striving to reduce the time it takes for a concept to become a product and be sold within the global marketplace. In business, some people say time is money, so if a project can reduce the time a business process takes it in fact saves the company which is always good for the bottom line. The Social Security Administration states that data security is the protection of data from accidental or intentional but unauthorized modification, destruction. Interoperability is the capability of a system or subsystem to interact with other systems or subsystems. In my personal opinion, these drivers would not really differ for a profit-based organization, compared to a non-profit organization. Both corporate entities strive to reduce cost, and strive to keep operation budgets low. However, the reasoning behind why they want to achieve this does contrast. Typically profit based organizations strive to increase revenue and market share so that the business can grow. Alternatively, not-for-profit businesses are more interested in increasing their reach within communities whether it is to increase annual donations or invest in the lives of others. Success or failure of a project can be determined by one or more of these drivers based on the scope of a project and the company’s priorities associated with each of the drivers. In addition, if a project attempts to incorporate multiple drivers and is only partially successful, then the project might still be considered to be a success due to how close the project was to meeting each of the priorities. Continuous evaluation of the project could lead to a decision to abort a project, because it is expected to fail before completion. Evaluations should be executed after the completion of every software development process stage. Pfleeger notes that software development process stages include: Requirements Analysis and Definition System Design Program Design Program Implementation Unit Testing Integration Testing System Delivery Maintenance Each evaluation at every state should consider all the business drivers included in the scope of a project for how close they are expected to meet expectations. In addition, minimum requirements of acceptance should also be included with the scope of the project and should be reevaluated as the project progresses to ensure that the project makes good economic sense to continue. If the project falls below these benchmarks then the project should be put on hold until it does make more sense or the project should be aborted because it does not meet the business driver requirements.   References Cost Reduction Program. (n.d.). Dictionary of Accounting Terms. Retrieved July 19, 2009, from Answers.com Web site: http://www.answers.com/topic/cost-reduction-program Government Information Exchange. (n.d.). Government Information Exchange Glossary. Retrieved July 19, 2009, from SSA.gov Web site: http://www.ssa.gov/gix/definitions.html PayPerClickList.com. (n.d.). Glossary Term R - Pay Per Click List. Retrieved July 19, 2009, from PayPerClickList.com Web site: http://www.payperclicklist.com/glossary/termr.html Pfleeger, S & Atlee, J.(2009). Software Engineering: Theory and Practice. Boston:Prentice Hall Veluchamy, Thiyagarajan. (n.d.). Glossary « Thiyagarajan Veluchamy’s Blog. Retrieved July 19, 2009, from Thiyagarajan.WordPress.com Web site: http://thiyagarajan.wordpress.com/glossary/

    Read the article

  • Term for unit testing that separates test logic from test result data

    - by mario
    So I'm not doing any unit testing. But I've had an idea to make it more appropriate for my field of use. Yet it's not clear if something like this exists, and if, how it would possibly be called. Ordinary unit tests combine the test logic and the expected outcome. In essence the testing framework only checks for booleans (did this match, did the expected result result). To generalize, the test code itself references the audited functions, and also explicites the result values like so: unit::assert( test_me() == 17 ) What I'm looking for is a separation of concerns. The test itself should only contain the tested logic. The outcome and result data should be handled by the unit testing or assertion framework. As example: unit::probe( test_me() ) Here the probe actually doubles as collector in the first run, and afterwards as verification method. The expected 17 is not mentioned in the test code, but stored or managed elsewhere. How is this scheme called? Or how would you call it? I hope I can find some actual implementations with the proper terminology. Obviously such a pattern is unfit for TDD. It's strictly for regression testing. Also obviously, it cannot be used for all cases. Only the simpler test subjects can be analyzed that way, for anything else the ordinary unit test setup and assertion steps are required. And yes, this could be manually accomplished by crafting a ResultWhateverObject, but that would still require hardwiring that to the test logic. Also keep in mind that I'm inquiring for use with scripting languages, and not about Java. I'm aware that the xUnit pattern originates there, and why it's hence as elaborate as it is. Btw, I've discovered one test execution framework which allows for shortening simple test notations to: test_me(); // 17 While thus the result data is no longer coded in (it's a comment), that's still not a complete separation and of course would work only for scalar results.

    Read the article

  • Intercepting Xstream conversion while parsing XML

    - by Shane Bell
    Suppose I have a simple Java class like this: public class User { String firstName; String lastName; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } } Now, suppose I want to parse the following XML: <user> <firstName>Homer</firstName> <lastName>Simpson</lastName> </user> I can do this with no problems in XStream like so: User homer = (User) xstream.fromXML(xml); Ok, all good so far, but here's my problem. Suppose I have the following XML that I want to parse: <user> <fullName>Homer Simpson</fullName> </user> How can I convert this XML into the same User object using XStream? I'd like a way to implement some kind of callback so that when XStream parses the fullName field, I can split the string in two and manually set the first name and last name fields on the user object. Is this possible? Note that I'm not asking how to split the string in two (that's the easy part), I want to know how to intercept the XML parsing so XStream doesn't try to reflectively set the fullName field on the User object (which obviously doesn't exist). I looked at the converters that XStream provides but couldn't figure out how to use it for this purpose. Any help would be appreciated.

    Read the article

  • catching erros and exiting

    - by apple pie
    In python, is there a way to exit a class after testing a condition, without exiting out of python? say i have the class class test(): def __init__(self): self.a = 2 def create_b(self): self.b = 3 def does_b_exist(self): if <self.b doesnt exist>: #terminate self.b += 1 try/except` doesnt work since the rest of the program doesnt terminate after failing. im basically trying to catch an error, and do what python does when it shows you errors, but i cant figure out how to do it

    Read the article

  • virtual keyword in different scenarios

    - by Mahesh
    I figured out 2 different meanings for virtual based on the situation it is being used. If a baseClass has a function defined virtual, then the derivedClass is going to override the function. The baseClass::~baseClass() should be defined virtual, if there is any class derived from it. Here it means, the derived class destruction first takes place followed by base class destruction. Are there any other situations where virtual hold a different meaning ?

    Read the article

  • error in midlet while implementing command..

    - by garima
    hi I have imported import com.sun.lwuit.Command; import javax.microedition.midlet.; import javax.microedition.lcdui.; in my code but still the following errors are coming... exitCommand = new Command("Exit", Command.EXIT, 2); //line 1 textbox.addCommand(exitCommand); //line 2 Command.EXIT cannot be resolved.. The method addCommand(Command) in the type Displayable is not applicable for the arguments (Command)

    Read the article

  • How should i build my GUI in Qt ?

    - by Apollo
    I am wondering which way is the best to start building a GUI+SOFT in Qt. I am trying to build a sound media player based on a MVC pattern. Until now i have found 3 ways to do so. 1- Should I use a .ui file thanks to Qt designer, is it flexible enough ? 2- Should I use QML to make the design than integrate it to a C++ development ? 3- Should I just start from scratch and do it by hand without Qt Designer and using Qt library ? Thank you very much for your answers.

    Read the article

  • Problem with unix pipe command

    - by Keyo
    I have a list of directory names in a text file. I want to use these as part of a file_name a git-svn clone command. This prints out the contents of the file line by line. cat repos_to_migrate.txt | tee $1 This however does not work: cat repos_to_migrate.txt | git svn clone file:///home/svn/$1 ... Unable to open repository 'file:///home/svn' ... Any ideas here? I'f it matters I'm running centos5.

    Read the article

  • ThickBox - update inside without redirect

    - by Alex Maslakov
    ASP.NET MVC and jQuery ThickBox. I show some content in ThickBox. It includes file upload form The view multi-media.apsx (it's strange, the this editor doesn't allow start the line with "<" in the code) form action="/upload/multi-media" method="post" enctype="multipart/form-data" label for="file"File name: input type="file" name="file" id="file" / input type="submit" value="Upload" / <% if (Model.Count > 0) { foreach (FileInfo mediaFile in Model) { <img width="100px" height="100px" src="<%: ResolveUrl("~/audio.png") %>" border="0" alt="<%: mediaFile.Name %>" / //................ After file upload I redirect to /upload/multi-media action and content shows in normal window, not in ThickBox. [ActionName("multi-media"), HttpPost] public ActionResult MultiMedia(HttpPostedFileBase file) { if (file.ContentLength > 0) { file.SaveAs(GenerateNewFileName(fullFileName)); return View("multi-media", model); } } How can I stay into ThickBox after file upload? I need show content in ThickBox all the time, even after the file upload.

    Read the article

  • What is the use of Method Overloading in Java when it is achieved by changing the sequence of parameters in the argument list?

    - by MediumOne
    I was reading a Java training manual and it said that Method Overloading in Java can be achieved by having a different argument list. It also said that the argument list could differ in (i). Number of parameters (ii). Datatype of parameters (iii). Sequence of parameters My concern is about (iii). What is the use of trying to overload a method just by changing the sequence of parameters? I am unable to think of any benefits by this way.

    Read the article

  • .NET assembly not loading from NTVDM

    - by John Reid
    I have a VDD dll that's loaded by a DOS program running inside the NTVDM. This dll uses C++/CLI and references a .NET assembly. All in all, the loading process is something like this: NTVDM runs: prntsr.com which uses VDD RegisterModule to load: prnvdd.dll which references .NET assembly: prnlib.dll The prntsr.com, prnvdd.dll and prnlib.dll files are all in the same folder. However, when loading it, I get the following exception: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'PRNLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ecf23cee305e91b7' or one of its dependencies. The system cannot find the file specified. File name: 'PRNLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ecf23cee305e91b7' at VDD_Initialise() === Pre-bind state information === LOG: User = DOMAIN\user LOG: DisplayName = PRNLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ecf2 3cee305e91b7 (Fully-specified) LOG: Appbase = file:///C:/WINDOWS/system32/ LOG: Initial PrivatePath = NULL Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: No application configuration file found. LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config. LOG: Post-policy reference: PRNLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ecf23cee305e91b7 LOG: Attempting download of new URL file:///C:/WINDOWS/system32/PRNLib.DLL. LOG: Attempting download of new URL file:///C:/WINDOWS/system32/PRNLib/PRNLib.DLL. LOG: Attempting download of new URL file:///C:/WINDOWS/system32/PRNLib.EXE. LOG: Attempting download of new URL file:///C:/WINDOWS/system32/PRNLib/PRNLib.EXE. It only searches C:\WINDOWS\system32\ for the assembly, which I guess this is due to NTVDM.EXE - as this is the actual process that the assembly is being loaded into, it takes its location as the AppBase. Any ideas how to change the AppBase or otherwise work around this problem?

    Read the article

  • how to create popup panel in mozilla firefox?

    - by user495688
    hello all.. i want to ask something about popup .. how to create popup panel in my addons to show text when users click context menu? the popup panel will execute javascript function inlinetrans.process() to show the result of inlinetrans process. this is my code to show context menu : <popup id="contentAreaContextMenu"> <menuseparator /> <menuitem id="inlinetransContextMenuPage" label="Terjemahkan dengan inlinetrans" image="chrome://inlinetrans/skin/imagesOn.png" class="menuitem-iconic" hidden="false" onclick="inlinetrans.process();"/> </popup> i want to create pop up like this http://abcdefu.wordpress.com/2008/07/25/writing-beautiful-ui-with-xul/ i don't need text box but i need to display my result of translation, what should i do? thank you for helping me..:)

    Read the article

  • Why do date manipulation in Java with milliseconds?

    - by staticsan
    I was recently faced with the problem of calculating the number of days from two dates in Java (without using joda, I'm afraid). Searching on the 'net shows most answers to this question say to get the milliseconds of the two days and convert that to days, which I found appalling. However, a scant few show a different approach: use a temporary variable to count how many times it takes adding 1 day to the first date to get to the second. This leaves the conversions to the code that does it best: the library. Why do so many people advocate the first? In another project, I had previously encountered numerous subtle date calculation problems involving time-zones, daylight-saving and once even leap years using seconds to do date comparisions and calculations. All these went away when all the comparison and calculation code was rewitten to use the language libraries. (This was in PHP, though, where the libraries are structured quite differently to Java.) So I'm understandably reluctant to use this "common wisdom" in the world of Java about comparing dates.

    Read the article

  • unchecked the store only latest version in VSS for a project?

    - by SCM
    Hi I have an issue in VSS 2005, there is a project in VSS, having multiple folders files in it, and most of the files around 2000 having their property "Store only latest version" is checked. I don't know how it is set. I want to change those around 2000 files property "Store only latest version" to unchecked, so that VSS retain all those files previous version. can it be done through a single command to unchecked this option for all those files in project recursively? Thanks

    Read the article

  • Calculating the union of 2 longitudal intervals (that may wrap around 180 degrees)

    - by timpatt
    The story: I have a LatLongBounds class that represents an area on the surface of the earth by a latitudinal interval (bounded by north & south - not important to this question) and a longitudinal interval (bounded by east and west; both normalized to a range [-180, 180] - negative being a westerly direction). In order to be able to represent an area that straddles the 180 degree meridian the value of west may be set to be greater than east (eg. the range west = 170, east = -170 will straddle said meridian). In effect the longitudinal interval may wrap around at 180 degrees (or equivalently -180 degrees). My Question: Does anyone have any suggestions as to how I can calculate the union of two longitudinal intervals that may wrap around at 180 degrees. Thanks.

    Read the article

  • Confusing Java syntax...

    - by posfan12
    I'm trying to convert the following code (from Wikipedia) from Java to JavaScript: /* * 3 June 2003, [[:en:User:Cyp]]: * Maze, generated by my algorithm * 24 October 2006, [[:en:User:quin]]: * Source edited for clarity * 25 January 2009, [[:en:User:DebateG]]: * Source edited again for clarity and reusability * 1 June 2009, [[:en:User:Nandhp]]: * Source edited to produce SVG file when run from the command-line * * This program was originally written by [[:en:User:Cyp]], who * attached it to the image description page for an image generated by * it on en.wikipedia. The image was licensed under CC-BY-SA-3.0/GFDL. */ import java.awt.*; import java.applet.*; import java.util.Random; /* Define the bit masks */ class Constants { public static final int WALL_ABOVE = 1; public static final int WALL_BELOW = 2; public static final int WALL_LEFT = 4; public static final int WALL_RIGHT = 8; public static final int QUEUED = 16; public static final int IN_MAZE = 32; } public class Maze extends java.applet.Applet { /* The width and height (in cells) of the maze */ private int width; private int height; private int maze[][]; private static final Random rnd = new Random(); /* The width in pixels of each cell */ private int cell_width; /* Construct a Maze with the default width, height, and cell_width */ public Maze() { this(20,20,10); } /* Construct a Maze with specified width, height, and cell_width */ public Maze(int width, int height, int cell_width) { this.width = width; this.height = height; this.cell_width = cell_width; } /* Initialization method that will be called when the program is * run from the command-line. Maze will be written as SVG file. */ public static void main(String[] args) { Maze m = new Maze(); m.createMaze(); m.printSVG(); } /* Initialization method that will be called when the program is * run as an applet. Maze will be displayed on-screen. */ public void init() { createMaze(); } /* The maze generation algorithm. */ private void createMaze(){ int x, y, n, d; int dx[] = { 0, 0, -1, 1 }; int dy[] = { -1, 1, 0, 0 }; int todo[] = new int[height * width], todonum = 0; /* We want to create a maze on a grid. */ maze = new int[width][height]; /* We start with a grid full of walls. */ for (x = 0; x < width; ++x) { for (y = 0; y < height; ++y) { if (x == 0 || x == width - 1 || y == 0 || y == height - 1) { maze[x][y] = Constants.IN_MAZE; } else { maze[x][y] = 63; } } } /* Select any square of the grid, to start with. */ x = 1 + rnd.nextInt (width - 2); y = 1 + rnd.nextInt (height - 2); /* Mark this square as connected to the maze. */ maze[x][y] &= ~48; /* Remember the surrounding squares, as we will */ for (d = 0; d < 4; ++d) { if ((maze[][d][][d] & Constants.QUEUED) != 0) { /* want to connect them to the maze. */ todo[todonum++] = ((x + dx[d]) << Constants.QUEUED) | (y + dy[d]); maze[][d][][d] &= ~Constants.QUEUED; } } /* We won't be finished until all is connected. */ while (todonum > 0) { /* We select one of the squares next to the maze. */ n = rnd.nextInt (todonum); x = todo[n] >> 16; /* the top 2 bytes of the data */ y = todo[n] & 65535; /* the bottom 2 bytes of the data */ /* We will connect it, so remove it from the queue. */ todo[n] = todo[--todonum]; /* Select a direction, which leads to the maze. */ do { d = rnd.nextInt (4); } while ((maze[][d][][d] & Constants.IN_MAZE) != 0); /* Connect this square to the maze. */ maze[x][y] &= ~((1 << d) | Constants.IN_MAZE); maze[][d][][d] &= ~(1 << (d ^ 1)); /* Remember the surrounding squares, which aren't */ for (d = 0; d < 4; ++d) { if ((maze[][d][][d] & Constants.QUEUED) != 0) { /* connected to the maze, and aren't yet queued to be. */ todo[todonum++] = ((x + dx[d]) << Constants.QUEUED) | (y + dy[d]); maze[][d][][d] &= ~Constants.QUEUED; } } /* Repeat until finished. */ } /* Add an entrance and exit. */ maze[1][1] &= ~Constants.WALL_ABOVE; maze[width - 2][height - 2] &= ~Constants.WALL_BELOW; } /* Called by the applet infrastructure to display the maze on-screen. */ public void paint(Graphics g) { drawMaze(g); } /* Called to write the maze to an SVG file. */ public void printSVG() { System.out.format("<svg width=\"%d\" height=\"%d\" version=\"1.1\"" + " xmlns=\"http://www.w3.org/2000/svg\">\n", width*cell_width, height*cell_width); System.out.println(" <g stroke=\"black\" stroke-width=\"1\"" + " stroke-linecap=\"round\">"); drawMaze(null); System.out.println(" </g>\n</svg>"); } /* Main maze-drawing loop. */ public void drawMaze(Graphics g) { int x, y; for (x = 1; x < width - 1; ++x) { for (y = 1; y < height - 1; ++y) { if ((maze[x][y] & Constants.WALL_ABOVE) != 0) drawLine( x * cell_width, y * cell_width, (x + 1) * cell_width, y * cell_width, g); if ((maze[x][y] & Constants.WALL_BELOW) != 0) drawLine( x * cell_width, (y + 1) * cell_width, (x + 1) * cell_width, (y + 1) * cell_width, g); if ((maze[x][y] & Constants.WALL_LEFT) != 0) drawLine( x * cell_width, y * cell_width, x * cell_width, (y + 1) * cell_width, g); if ((maze[x][y] & Constants.WALL_RIGHT) != 0) drawLine((x + 1) * cell_width, y * cell_width, (x + 1) * cell_width, (y + 1) * cell_width, g); } } } /* Draw a line, either in the SVG file or on the screen. */ public void drawLine(int x1, int y1, int x2, int y2, Graphics g) { if ( g != null ) g.drawLine(x1, y1, x2, y2); else System.out.format(" <line x1=\"%d\" y1=\"%d\"" + " x2=\"%d\" y2=\"%d\" />\n", x1, y1, x2, y2); } } Anyway, I was chugging along fairly quickly when I came to a bit that I just don't understand: /* Remember the surrounding squares, as we will */ for (var d = 0; d < 4; ++d) { if ((maze[][d][][d] & Constants.QUEUED) != 0) { /* want to connect them to the maze. */ todo[todonum++] = ((x + dx[d]) << Constants.QUEUED) | (y + dy[d]); maze[][d][][d] &= ~Constants.QUEUED; } } What I don't get is why there are four sets of brackets following the "maze" parameter instead of just two, since "maze" is a two dimensional array, not a four dimensional array. I'm sure there's a good reason for this. Problem is, I just don't get it. Thanks!

    Read the article

  • display selectedItems in a label

    - by Cecilia
    I need to display the selecteditems in a label I am using VB 2005 I set the selection mode to multi-extended It did work selecting only one item with the following code: me.xresultslabel.text= me.xlisttextbox.text.selectedItem.tostring But when I tried to display more than one item using the following code: me.resultlabel.text= me.xlisttextbox.text.selectedItems, I get the following string on the label: system.windows.forms.listbox+selectedobjetcollections. any help will be highly appreciate

    Read the article

  • Python os module path functions

    - by broiyan
    From the documentation: os.path.realpath(path) Return the canonical path of the specified filename, eliminating any symbolic links encountered in the path (if they are supported by the operating system). When I invoke this with an extant file's name, I get the path to it: /home/myhome/myproject. When I invoke this with a 'nonsense.xxx' string argument, I still get a path to /home/myhome/myproject/nonsense.xxx. This is a little inconsistent because it looks like nonsense.xxx is taken to be a directory not a file (though it is neither: it does not exist). When I invoke this with a null string file name, I still get a path to /home/myhome/myproject. How can I account for this behaviour when the documentation says so little about realpath()? (I am using Python 2.5.) Edit: Somebody suggested a way to test if files exist. My concern is not to test if files exist. My concern is to account for behaviour.

    Read the article

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