Daily Archives

Articles indexed Saturday January 8 2011

Page 19/30 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • Sharing between Vista and Windows 7

    - by Metro Smurf
    Vista Ultimate 32 bit Windows 7 Ultimate 64 bit I've read through similar questions about sharing between Win7 and Vista, but none of them have resolved my issue of not being able to share between Win7 and Vista: Connecting to a Vista shared folder from Windows 7 Networking Windows 7 and Vista Enable File sharing in Windows Vista Previously I had previously had my Vista and XP system sharing back and forth without any problems. I was able to access the shares without entering a user name / password in the NT challenge prompt (note: account names and passwords were different on the Vista and XP systems). Currently I replaced my XP system with a Win7 system. Now, when I attempt to access shares to/from Vista / Win7, I am continually prompted with an NT challenge to enter my credentials. Things I've Verified/Tried Both systems are on the same workgroup. Win 7 is using the Home network. Vista is using the Private network. In other words, neither system is using a Public network profile. Enabled file sharing with and without password protection on both Vista and Win7 Tried HomeGroup Connections (win7) with Windows to manage connections and Use user accounts to connect. Reviewed too many online articles to count to trouble shoot. Set the shares to have full control by everyone. Set up the shares directly on the directory and through the share manager. My Question How can I enable file sharing between Vista and Win7 without being prompted with a username/password challenge, ever?

    Read the article

  • How cpu writes data to dynamic RAM

    - by Krit
    Hello, I would like to know what kind of electrical signals does a cpu send to a dynamic RAM when it wants to write one bit (a 1 or 0). Is it simply that cpu sends just a single electric pulse, and if that electric pulse's voltage is higher than a certain level, it charges the capacitor to a voltage level that is "1" and if it is at a lower voltage band, it charges capacitor to level that it is "0"?

    Read the article

  • How do you customize Excel 2010 keyboard shortcuts?

    - by Sam
    How do you customize Excel 2010 keyboard shortcuts? This article from microsoft.com provides instructions for "Microsoft Office 2010" but seems only apply to Word, not Excel. http://www.microsoft.com/athome/organization/compshortcuts.aspx In Microsoft Office 2010: Click the File tab to open Backstage view, and then click Options. Click Customize Ribbon and then, next to the Keyboard Shortcuts heading, click Customize. You can enter the new key combination here. Here's the dialog it points to shown in Word: But here's the same dialog shown in Excel: Notice it looks almost exactly the same but no "Keyboard Shortcuts: Customize.." button. So how do you customize the keyboard shortcuts in Excel?

    Read the article

  • Memory Speeds: 1x4GB or 2x2GB? [closed]

    - by Dasutin
    When it comes to speeds what is faster having one 4GB module in your system or having two 2GB modules. I'm not taking in the fact that the system could have dual channel capabilities. Also what about a server environment? Would it be better to have one large, high density module or break it up into several modules for speed and price? I heard an engineer at my office having a discussion with an employee. He said that its better in all situations to have one large capacity modules instead of breaking it up. It would be cheaper and perform faster. He also said it would take longer for the computer to access what it needed if there were more modules instead of having just one. His explanation didn't seem right to me and I thought I would post this question here to see what other people thought.

    Read the article

  • VIM: How do you get the last ex command you used?

    - by TrevorBoydSmith
    I find that sometimes I write a really long ex mode command that do lots of stuff. They are sort of "mini-scripts" that I write in the text editor then I start ex mode and copy them into the ex line and execute. But then I always end up editing in the ex mode and then I find it difficult to get the changes i did in ex mode back to my text editing session. Using the keyboard, how do you copy the last ex command you used and paste it into your text editor? (Note: This is sort of the opposite of this question "how do I copy/paste in vim ex mode" where the user asks "how do you copy from the text editor and paste INTO the ex mode?". My question is the opposite because I wish to copy from the ex mode and paste into my text editor.)

    Read the article

  • Download folders from dev server to local drive

    - by Niall Collins
    I am developing a .net web application on a local environment. I have a dev server that the application is installed on. Within the web application on the dev server I have four folders that I dont have locally and that are controlled by another application. In my day to day development I require the four folders on local PC. I would like to automate the process of pulling the folders from the dev server to my local drive, so I can keep thing in sync. Ideally something like this Run file from main folder (be it a bat file, powershell, some sort of job, open to recommendations) Download 4 folders supplied to it. First download bring everything down, from them on only pull the changes Not sure where to start with achieving this but would appreciate any help would with. I know there are apps out there that do something like this but would like to give a go writing something to do this before I resort to using one of them.

    Read the article

  • Which paradigm to use for writing chess engine?

    - by poke
    If you were going to write a chess game engine, what programming paradigm would you use (OOP, procedural, etc) and why whould you choose it ? By chess engine, I mean the portion of a program that evaluates the current board and decides the computer's next move. I'm asking because I thought it might be fun to write a chess engine. Then it occured to me that I could use it as a project for learning functional programming. Then it occured to me that some problems aren't well suited to the functional paradigm. Then it occured to me that this might be good discussion fodder.

    Read the article

  • Can't Boot Ubuntu, video drivers or x-server problem?

    - by ZacharyH
    I was uninstalling some programs that I installed to try and get my iPod touch working with Ubuntu (I gave up on that) when ubuntu just crashed. Now after I choose ubuntu in GRUB, it gives me a screen that says "Ubuntu is running in low-graphics mode: your screen, graphics card, and input device settings could not be detected correctly. You will need to configure these yourself" It was working just fine before I started to uninstall those programs. I think that I might have uninstalled something necessary to the system. If I click OK on the screen, it gives me options to reconfigure, troubleshoot, exit to console, or restart X. But no matter what I choose I still can't boot into ubuntu - I get stuck looking at the splash screen which stalls forever. I was receiving support from one of my mate's and he was doing something with the LiveCD, and now the message doesn't pop up any more, I just get stuck at a never ending splash screen. Any help would be appreciated, thanks!

    Read the article

  • UIImageView doesn't update with my image

    - by Sheehan Alam
    I am trying to set my image: detailedEventViewController.thumbnail.image = [UIImage imageNamed:@"amnesia.png"]; But the imageview appears blank. amnesia.png is in my resources group. The file exists. Results of my log: 2011-01-08 10:52:32.822 HD Pocket Vacations[25271:207] Image: <UIImage: 0x66203b0> 2011-01-08 10:52:32.823 HD Pocket Vacations[25271:207] dEVC: <DetailedEventViewController: 0x6628340> 2011-01-08 10:52:32.824 HD Pocket Vacations[25271:207] thumbnail: (null)

    Read the article

  • Running Send_SMS method from BroadcastReceiver

    - by burmat
    My application is an auto-reply application for text messages. I have a BroadcastReceiver for when a message arrives, and I need it to run a public method (Send_SMS). SMS_Sender.sendSMS(phoneNumber, messageText); does not work however, and eclipse wants to change my method to static. This would not be an issue if I did not have more receivers that catch when the message is sent/delivered/etc in this class. These receivers are then errors for being contained in a static method. So my question is, how do I run this method from a broadcast receiver so I can send the auto reply whenever it is triggered with a received message? -Thank you in advance, Nate

    Read the article

  • Problem saving as png a SVG generated by Raphael JS in a canvas

    - by ClemDesm
    Hi fellow SOers, I'm trying to convert a SVG generated by Raphael JS (and the user, since you can drag and rotate the images). I followed this Conversion of SVG to Jpeg but still can't get it. It must be easy but I can't put my finger on what I get wrong. I got my svg in a div with #ec as id and the canvas's one is #canvas. function saveDaPicture(){ var img = document.getElementById('canvas').toDataURL("image/png"); $('body').append('<img src="'+img+'"/>'); } $('#save').click(function(){ var svg = $('#ec').html(); alert(svg); canvg('canvas', svg, {renderCallback: saveDaPicture(), ignoreMouse: true, ignoreAnimation: true}); }); The alert gives me : <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="600" height="512"> <desc>Created with Raphael</desc> <defs></defs> <image x="0" y="0" width="300" height="512" preserveAspectRatio="none" href="imageurl.jpg"></image> <rect x="168" y="275" width="52" height="70" r="0" rx="0" ry="0" fill="none" stroke="#000" stroke-dasharray="8,3" transform="rotate(21.91207728 194 310)" style="opacity: 1; display: none; " opacity="1"></rect> <circle cx="50" cy="50" r="50" fill="none" stroke="#000"></circle> <image x="358" y="10" width="39" height="138" preserveAspectRatio="none" href="imageurl2.png" style="cursor: move; "></image> <image x="397" y="10" width="99" height="153" preserveAspectRatio="none" href="imageurl3.png" style="cursor: move; "></image> <image x="184" y="286" width="10" height="10" preserveAspectRatio="none" href="imageurl4.png" style="cursor: pointer; opacity: 1; display: none; " opacity="1"></image> <image x="204" y="286" width="10" height="10" preserveAspectRatio="none" href="imageurl5.png" style="cursor: pointer; opacity: 1; display: none; " opacity="1"></image> <image x="170" y="277" width="48" height="66" preserveAspectRatio="none" href="imageurl6.png" style="cursor: move; opacity: 1; " r="50" opacity="1" transform="rotate(21.91207728 194 310)"></image> </svg> which is the xml of the svg and if I believe canvg documentation, it's good. Anyway, with this code, the variable img, which should have the converted image data, got the data of an empty png with the dimensions of the svg. The only thing I guess is that the svg generated by Raphael JS is not well formated for canvg (like, href of image should be xlink:href if I follow the W3C recommandations ) Anyone got an idea on this problem ? :D

    Read the article

  • Struts 2 how to display messages saved in a Interceptor which would redirec to another action?

    - by mui13
    in my interceptor, if user doesn't have enough right, there would be a warn message: public String intercept(ActionInvocation invocation) throws Exception { ActionContext actionContext = invocation.getInvocationContext(); Map<String, Object> sessionMap = actionContext.getSession(); User loginUser = (User) sessionMap.get("user"); Object action = invocation.getAction(); if (loginUser != null && loginUser.getRole().getId() != Constant.AUTHORITY_ADMIN) { ((ValidationAware) action).addFieldError("user.authority", ((DefaultAction) action).getText("user.action.authority.not.enough")); return DefaultAction.HOME_PAGE; } return invocation.invoke(); } then, it would redirect to "HOME_PAGE" action, if success, display information in the jsp. So how to display the warn message? i have used two interceptors configed in strust.xml, for admin right requirment: <interceptor-stack name="authorityStack"> <interceptor-ref name="authority" /> <interceptor-ref name="defaultStack" /> <interceptor-ref name="store"> <param name="operationMode">STORE</param> </interceptor-ref> </interceptor-stack> default is: <interceptor-stack name="default"> <interceptor-ref name="login" /> <interceptor-ref name="defaultStack" /> <interceptor-ref name="store"> <param name="operationMode">AUTOMATIC</param> </interceptor-ref> </interceptor-stack>

    Read the article

  • In Java, is it possible for a super constructor invocation actually invoke a constructor in the calling class?

    - by John Assymptoth
    Super constructor invocation definition: [Primary.] [NonWildTypeArguments] super ( ArgumentListopt ) ; A super constructor call can be prefixed by an Primary expression. Example (taken from JLS): class Outer { class Inner{ } } class ChildOfInner extends Outer.Inner { ChildOfInner() { (new Outer()).super(); // (new Outer()) is the Primary } } Does a Primary expression exist that makes the call to super() the invocation of a constructor of the calling class? Or Java prevents that?

    Read the article

  • iPhone SDK: How to determine keyboard type within a UIKeyboardDidShowNotification?

    - by iPhone Developer
    Hello, I need to know the current keyboard type. I was setting an instance variable in - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField However, testing has shown that this is not always reliable because of the asynchronous nature of notifications. What I am wondering is if anyone can tell me how to determine the current keyboard type within a notification? - (void)keyboardDidShow:(NSNotification *) { // Need way to determine keyboard type here } Thanks.

    Read the article

  • PHP resizing PNGs results in corrupted files

    - by Robert
    I have a PHP script that resizes .jpg, .gif, and .png files to a bounding box. $max_width = 500; $max_height = 600; $filetype = $_FILES["file"]["type"]; $source_pic = "img/" . $idnum; if($filetype == "image/jpeg") { $src = imagecreatefromjpeg($source_pic); } else if($filetype == "image/png") { $src = imagecreatefrompng($source_pic); } else if($filetype == "image/gif") { $src = imagecreatefromgif($source_pic); } list($width,$height)=getimagesize($source_pic); $x_ratio = $max_width / $width; $y_ratio = $max_height / $height; if( ($width <= $max_width) && ($height <= $max_height) ) { $tn_width = $width; $tn_height = $height; } else if (($x_ratio * $height) < $max_height) { $tn_height = ceil($x_ratio * $height); $tn_width = $max_width; } else { $tn_width = ceil($y_ratio * $width); $tn_height = $max_height; } $tmp = imagecreatetruecolor($tn_width,$tn_height); imagecopyresampled($tmp,$src,0,0,0,0,$tn_width, $tn_height,$width,$height); $destination_pic = "img/thumbs/" . $idnum . "thumb"; if($filetype == "image/jpeg") { imagejpeg($tmp,$destination_pic,80); } else if($filetype == "image/png") { imagepng($tmp,$destination_pic,80); } else if($filetype == "image/gif") { imagegif($tmp,$destination_pic,80); } imagedestroy($src); imagedestroy($tmp); The script works fine with jpeg and gif but when running on a png the file will be corrupted. Is there anything special I need to use when working with a png? I have never worked with this sort of thing in PHP so I'm not very familiar with it.

    Read the article

  • Waiting for a subset of threads in a Java ThreadPool

    - by David Semeria
    Let's say I have a thread pool containing X items, and a given task employs Y of these items (where Y is much smaller than X). I want to wait for all of the threads of a given task (Y items) to finish, not the entire thread pool. If the thread pool's execute() method returned a reference to the employed thread I could simply join() to each of these Y threads, but it doesn't. Does anyone know of an elegant way to accomplish this? Thanks.

    Read the article

  • Where can I learn advanced Haskell?

    - by FredOverflow
    In a comment to one of my answers, SO user sdcwc essentially pointed out that the following code: comb 0 = [[]] comb n = let rest = comb (n-1) in map ('0':) rest ++ map ('1':) rest could be replaced by: comb n = replicateM n "01" which had me completely stunned. Now I am looking for a tutorial, book or PDF that teaches these advanced concepts. I am not looking for a "what's a monad" tutorial aimed at beginners or online references explaining the type of replicateM. I want to learn how to think in monads and use them effectively, monadic "patterns" if you will.

    Read the article

  • Check if key exists in $_SESSION by building index string

    - by Kim
    I need to check if a key exists and return its value if it does. Key can be an array with subkeys or endkey with a value. $_SESSION['mainKey']['testkey'] = 'value'; var_dump(doesKeyExist('testkey')); function doesKeyExist($where) { $parts = explode('/',$where); $str = ''; for($i = 0,$len = count($parts);$i<$len;$i++) { $str .= '[\''. $parts[$i] .'\']'; } $keycheck = '$_SESSION[\'mainKey\']' . $str; if (isset(${$keycheck})) { return ${$keycheck}; } // isset($keycheck) = true, as its non-empty. actual content is not checked // isset(${$keycheck}) = false, but should be true. ${$var} forces a evaluate content // isset($_SESSION['mainKey']['testkey']) = true } What am I doing wrong ? Using PHP 5.3.3.

    Read the article

  • Node.js + Express.js. How to RENDER less css?

    - by Paden
    Hello all, I am unable to render less css in my express workspace. Here is my current configuration (my css/less files go in 'public/stylo/'): app.configure(function() { app.set('views' , __dirname + '/views' ); app.set('partials' , __dirname + '/views/partials'); app.set('view engine', 'jade' ); app.use(express.bodyDecoder() ); app.use(express.methodOverride()); app.use(express.compiler({ src: __dirname + '/public/stylo', enable: ['less']})); app.use(app.router); app.use(express.staticProvider(__dirname + '/public')); }); Here is my main.jade file: !!! html(lang="en") head title Yea a title link(rel="stylesheet", type="text/css", href="/stylo/main.less") link(rel="stylesheet", href="http://fonts.googleapis.com/cssfamily=Droid+Sans|Droid+Sans+Mono|Ubuntu|Droid+Serif") script(src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js") script(src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js") body!= body here is my main.less css: @import "goodies.css"; body { .googleFont; background-color : #000000; padding : 20px; margin : 0px; > .header { border-bottom : 1px solid #BBB; background-color : #f0f0f0; margin : -25px -25px 30px -25px; /* important */ color : #333; padding : 15px; font-size : 18pt; } } AND here is my goodies.less css: .rounded_corners(@radius: 10px) { -moz-border-radius : @radius; -webkit-border-radius: @radius; border-radius : @radius; } .shadows(@rad1: 0px, @rad2: 1px, @rad3: 3px, @color: #999) { -webkit-box-shadow : @rad1 @rad2 @rad3 @color; -moz-box-shadow : @rad1 @rad2 @rad3 @color; box-shadow : @rad1 @rad2 @rad3 @color; } .gradient (@type: linear, @pos1: left top, @pos2: left bottom, @color1: #f5f5f5, @color2: #ececec) { background-image : -webkit-gradient(@type, @pos1, @pos2, from(@color1), to(@color2)); background-image : -moz-linear-gradient(@color1, @color2); } .googleFont { font-family : 'Droid Serif'; } Cool deal. Now: I have installed less via npm and I had heard from another post that @imports should reference the .css not the .less. In any case, I have tried the combinations of switching .less for .css in the jade and less files with no success. If you can help or have the solution I'd greatly appreciate it. Note: The jade portion works fine if I enter any ol' .css. Note2: The less compiles if I use lessc via command line.

    Read the article

  • How can make a variable (not class member) "read only" in C#

    - by devfreak
    Hi, I'm new to the C# world and I can't find a method to declare read only variable in C# (something like declaring "const" variable in c++). Is there one? I'll give you an example: ... int f() { return x; } // x is not const member ... void g() { int readOnlyVar = f(); // is there a method to declare readOnlyVar as read only or const // Some code in which I want to restrict access to readOnlyVar to read only }

    Read the article

  • Allowing developer-specific settings in VS2008 projects

    - by Xavier Nodet
    Is it possible to combine the following properties, and if so, how? Store in our version control system some Visual Studio 2008 native C++ project files for the developers in our team that use this IDE. Allow some of those developers to tweak their projects (e.g. using debug version of third-party libraries instead of the usual ones). Make sure these modifications are done in files that are not versioned. In other words, I would like to allow developers to tweak some settings in their projects without risking that these changes are committed. An 'optional VSPROP' file approach seems doomed to fail, as VS2008 refuses to load projects that refer to non-existent VSPROP files... Any other suggestion? Is this possible with VS2010?

    Read the article

  • Problem implementing Blinn–Phong shading model

    - by Joe Hopfgartner
    I did this very simple, perfectly working, implementation of Phong Relflection Model (There is no ambience implemented yet, but that doesn't bother me for now). The functions should be self explaining. /** * Implements the classic Phong illumination Model using a reflected light * vector. */ public class PhongIllumination implements IlluminationModel { @RGBParam(r = 0, g = 0, b = 0) public Vec3 ambient; @RGBParam(r = 1, g = 1, b = 1) public Vec3 diffuse; @RGBParam(r = 1, g = 1, b = 1) public Vec3 specular; @FloatParam(value = 20, min = 1, max = 200.0f) public float shininess; /* * Calculate the intensity of light reflected to the viewer . * * @param P = The surface position expressed in world coordinates. * * @param V = Normalized viewing vector from surface to eye in world * coordinates. * * @param N = Normalized normal vector at surface point in world * coordinates. * * @param surfaceColor = surfaceColor Color of the surface at the current * position. * * @param lights = The active light sources in the scene. * * @return Reflected light intensity I. */ public Vec3 shade(Vec3 P, Vec3 V, Vec3 N, Vec3 surfaceColor, Light lights[]) { Vec3 surfaceColordiffused = Vec3.mul(surfaceColor, diffuse); Vec3 totalintensity = new Vec3(0, 0, 0); for (int i = 0; i < lights.length; i++) { Vec3 L = lights[i].calcDirection(P); N = N.normalize(); V = V.normalize(); Vec3 R = Vec3.reflect(L, N); // reflection vector float diffuseLight = Vec3.dot(N, L); float specularLight = Vec3.dot(V, R); if (diffuseLight > 0) { totalintensity = Vec3.add(Vec3.mul(Vec3.mul( surfaceColordiffused, lights[i].calcIntensity(P)), diffuseLight), totalintensity); if (specularLight > 0) { Vec3 Il = lights[i].calcIntensity(P); Vec3 Ilincident = Vec3.mul(Il, Math.max(0.0f, Vec3 .dot(N, L))); Vec3 intensity = Vec3.mul(Vec3.mul(specular, Ilincident), (float) Math.pow(specularLight, shininess)); totalintensity = Vec3.add(totalintensity, intensity); } } } return totalintensity; } } Now i need to adapt it to become a Blinn-Phong illumination model I used the formulas from hearn and baker, followed pseudocodes and tried to implement it multiple times according to wikipedia articles in several languages but it never worked. I just get no specular reflections or they are so weak and/or are at the wrong place and/or have the wrong color. From the numerous wrong implementations I post some little code that already seems to be wrong. So I calculate my Half Way vector and my new specular light like so: Vec3 H = Vec3.mul(Vec3.add(L.normalize(), V), Vec3.add(L.normalize(), V).length()); float specularLight = Vec3.dot(H, N); With theese little changes it should already work (maby not with correct intensity but basically it should be correct). But the result is wrong. Here are two images. Left how it should render correctly and right how it renders. If i lower the shininess factor you can see a little specular light at the top right: Altough I understand the concept of Phong illumination and also the simplified more performant adaptaion of blinn phong I am trying around for days and just cant get it to work. Any help is appriciated. Edit: I was made aware of an error by this answer, that i am mutiplying by |L+V| instead of dividing by it when calculating H. I changed to deviding doing so: Vec3 H = Vec3.mul(Vec3.add(L.normalize(), V), 1/Vec3.add(L.normalize(), V).length()); Unfortunately this doesnt change much. The results look like this: and if I rise the specular constant and lower the shininess You can see the effects more clearly in a smilar wrong way: However this division just the normalisation. I think I am missing one step. Because the formulas like this just dont make sense to me. If you look at this picture: http://en.wikipedia.org/wiki/File:Blinn-Phong_vectors.svg The projection of H to N is far less than V to R. And if you imagine changing the vector V in the picture the angle is the same when the viewing vector is "on the left side". and becomes more and more different when going to the right. I pesonally would multiply the whole projection by two to become something similiar (and the hole point is to avoid the calculation of R). Altough I didnt read anythinga bout that anywehre i am gonna try this out... Result: The intension of the specular light is far too much (white areas) and the position is still wrong. I think I am messing something else up because teh reflection are just at the wrong place. But what? Edit: Now I read on wikipedia in the notes that the angle of N/H is in fact approximalty half or V/R. To compensate that i should multiply my shineness exponent by 4 rather than my projection. If i do that I end up with this: Far to intense but still one thing. The projection is at the wrong place. Where could i mess up my vectors?

    Read the article

  • Problem with java and conditional (game of life)

    - by Muad'Dib
    Hello everybody, I'm trying to implement The Game of Life in java, as an exercise to learn this language. Unfortunately I have a problem, as I don't seem able to make this program run correctly. I implemented a torodial sum (the plane is a donut) with no problem: int SumNeighbours (int i, int j) { int value = 0; value = world[( i - 1 + row ) % row][( j - 1 + column ) % column]+world[( i - 1 + row ) % row][j]+world[( i - 1 + row ) % row][( j + 1 ) % column]; value = value + world[i][( j - 1 + column ) % column] + world[i][( j + 1 ) % column]; value = value + world[( i + 1 ) % row][( j - 1 + column ) % column] + world[( i + 1 ) % row][j]+world[ ( i+1 ) % row ][( j + 1 ) % column]; return value; } And it sums correctly when I test it: void NextWorldTest () { int count; int [][] nextWorld = new int[row][row]; nextWorld = world; for (int i=0; i<row; i++) { for (int j=0; j<column; j++) { count = SumNeighbours(i,j); System.out.print(" " + count + " "); } System.out.println(); } world=nextWorld; } Unfortunately when I add the conditions of game of life (born/death) the program stop working correctly, as it seems not able anymore to count correctly the alive cells in the neighborhood. It counts where there are none, and it doesn't count when there are some. E.g.: it doesn't count the one below some living cells. It's a very odd behaviour, and it's been giving me a headache for 3 days now... maybe I'm missing something basic about variables? Here you can find the class. void NextWorld () { int count; int [][] nextWorld = new int[row][column]; nextWorld = world; for (int i=0; i<row; i++) { for (int j=0; j<column; j++) { count = SumNeighbours(i,j); System.out.print(" " + count + " "); if ( ( world[i][j] == 0) && ( count == 3 ) ) { nextWorld[i][j] = 1; } else if ( ( world[i][j] == 1 ) && ( (count == 3) || (count == 2) )) { nextWorld[i][j] = 1; } else { nextWorld[i][j]=0; } } System.out.println(); } world=nextWorld; } } Am I doing something wrong? Below you can find the full package. package com.GaOL; public class GameWorld { int [][] world; int row; int column; public int GetRow() { return row; } public int GetColumn() { return column; } public int GetWorld (int i, int j) { return world[i][j]; } void RandomGen (int size, double p1) { double randomCell; row = size; column = size; world = new int[row][column]; for (int i = 0; i<row; i++ ) { for (int j = 0; j<column; j++ ) { randomCell=Math.random(); if (randomCell < 1-p1) { world[i][j] = 0; } else { world[i][j] = 1; } } } } void printToConsole() { double test = 0; for (int i=0; i<row; i++) { for (int j=0; j<column; j++) { if ( world[i][j] == 0 ) { System.out.print(" "); } else { System.out.print(" * "); test++; } } System.out.println(""); } System.out.println("ratio is " + test/(row*column)); } int SumNeighbours (int i, int j) { int value = 0; value = world[( i - 1 + row ) % row][( j - 1 + column ) % column]+world[( i - 1 + row ) % row][j]+world[( i - 1 + row ) % row][( j + 1 ) % column]; value = value + world[i][( j - 1 + column ) % column] + world[i][( j + 1 ) % column]; value = value + world[( i + 1 ) % row][( j - 1 + column ) % column] + world[( i + 1 ) % row][j]+world[ ( i+1 ) % row ][( j + 1 ) % column]; return value; } void NextWorldTest () { int count; int [][] nextWorld = new int[row][row]; nextWorld = world; for (int i=0; i<row; i++) { for (int j=0; j<column; j++) { count = SumNeighbours(i,j); System.out.print(" " + count + " "); } System.out.println(); } world=nextWorld; } void NextWorld () { int count; int [][] nextWorld = new int[row][column]; nextWorld = world; for (int i=0; i<row; i++) { for (int j=0; j<column; j++) { count = SumNeighbours(i,j); System.out.print(" " + count + " "); if ( ( world[i][j] == 0) && ( count == 3 ) ) { nextWorld[i][j] = 1; } else if ( ( world[i][j] == 1 ) && ( (count == 3) || (count == 2) )) { nextWorld[i][j] = 1; } else { nextWorld[i][j]=0; } } System.out.println(); } world=nextWorld; } } and here the test class: package com.GaOL; public class GameTestClass { public static void main(String[] args) { GameWorld prova = new GameWorld(); prova.RandomGen(10, 0.02); for (int i=0; i<3; i++) { prova.printToConsole(); prova.NextWorld(); } } }

    Read the article

  • Storing C++ templated objects as same type

    - by JaredC
    I have a class that is a core component of a performance sensitive code path, so I am trying to optimize it as much as possible. The class used to be: class Widget { Widget(int n) : N(n) {} .... member functions that use the constant value N .... const int N; // just initialized, will never change } The arguments to the constructor are known at compile time, so I have changed this class to a template, so that N can be compiled into the functions: template<int N> class Widget { .... member functions that use N .... } I have another class with a method: Widget & GetWidget(int index); However, after templating Widget, each widget has a different type so I cannot define the function like this anymore. I considered different inheritance options, but I'm not sure that the performance gain from the template would outweigh the cost of inherited function invocations. SO, my question is this: I am pretty sure I want the best of both worlds (compile-time / run-time), and it may not be possible. But, is there a way to gain the performance of knowing N at compile time, but still being able to return Widgets as the same type? Thanks!

    Read the article

  • CLR Function not working in restored database

    - by Ben Thul
    So I've restore a database with CLR assemblies in it from one physical server to another. One of the functions in the CLR assembly essentially does an uncompress of some compressed data. When I run this function against data in the restored database it returns the compressed data (rather than the uncompressed data). No error is thrown in SSMS or in the SQL server error logs. At the suggestion of others, I've checked differences in the database ownership (both owned by sa), trustworthiness (both set to not trustworthy). I also checked differences in the .NET framework installs on both machines but found only that the target machine had a 1.1 version installed that the source didn't. I don't know what else to try. Any suggestions would be most appreciated. Thanks in advance. Thanks in advance, Ben

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >