Search Results

Search found 787 results on 32 pages for 'floor planner'.

Page 11/32 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • How'd they do it: Millions of tiles in Terraria

    - by William 'MindWorX' Mariager
    I've been working up a game engine similar to Terraria, mostly as a challenge, and while I've figured out most of it, I can't really seem to wrap my head around how they handle the millions of interactable/harvestable tiles the game has at one time. Creating around 500.000 tiles, that is 1/20th of what's possible in Terraria, in my engine causes the frame-rate to drop from 60 to around 20, even tho I'm still only rendering the tiles in view. Mind you, I'm not doing anything with the tiles, only keeping them in memory. Update: Code added to show how I do things. This is part of a class, which handles the tiles and draws them. I'm guessing the culprit is the "foreach" part, which iterates everything, even empty indexes. ... public void Draw(SpriteBatch spriteBatch, GameTime gameTime) { foreach (Tile tile in this.Tiles) { if (tile != null) { if (tile.Position.X < -this.Offset.X + 32) continue; if (tile.Position.X > -this.Offset.X + 1024 - 48) continue; if (tile.Position.Y < -this.Offset.Y + 32) continue; if (tile.Position.Y > -this.Offset.Y + 768 - 48) continue; tile.Draw(spriteBatch, gameTime); } } } ... Also here is the Tile.Draw method, which could also do with an update, as each Tile uses four calls to the SpriteBatch.Draw method. This is part of my autotiling system, which means drawing each corner depending on neighboring tiles. texture_* are Rectangles, are set once at level creation, not each update. ... public virtual void Draw(SpriteBatch spriteBatch, GameTime gameTime) { if (this.type == TileType.TileSet) { spriteBatch.Draw(this.texture, this.realm.Offset + this.Position, texture_tl, this.BlendColor); spriteBatch.Draw(this.texture, this.realm.Offset + this.Position + new Vector2(8, 0), texture_tr, this.BlendColor); spriteBatch.Draw(this.texture, this.realm.Offset + this.Position + new Vector2(0, 8), texture_bl, this.BlendColor); spriteBatch.Draw(this.texture, this.realm.Offset + this.Position + new Vector2(8, 8), texture_br, this.BlendColor); } } ... Any critique or suggestions to my code is welcome. Update: Solution added. Here's the final Level.Draw method. The Level.TileAt method simply checks the inputted values, to avoid OutOfRange exceptions. ... public void Draw(SpriteBatch spriteBatch, GameTime gameTime) { Int32 startx = (Int32)Math.Floor((-this.Offset.X - 32) / 16); Int32 endx = (Int32)Math.Ceiling((-this.Offset.X + 1024 + 32) / 16); Int32 starty = (Int32)Math.Floor((-this.Offset.Y - 32) / 16); Int32 endy = (Int32)Math.Ceiling((-this.Offset.Y + 768 + 32) / 16); for (Int32 x = startx; x < endx; x += 1) { for (Int32 y = starty; y < endy; y += 1) { Tile tile = this.TileAt(x, y); if (tile != null) tile.Draw(spriteBatch, gameTime); } } } ...

    Read the article

  • Spatial Rotation in Gmod Expression2.

    - by Fascia
    I'm using expression2 to program behavior in Garry's mod (http://wiki.garrysmod.com/?title=Wire_Expression2) Okay so, to set the precedent. In Gmod I have a block and I am at a complete loss of how to get it to rotate around the 3 up, down and right vectors (Which are local. ie; if I pitch it 45 degrees the forward vector is 0.707, 0.707, 0). Essentially, From the 3 vectors I'd like to be able to get local Pitch/Roll/Yaw. By Local Pitch Roll Yaw I mean that they are completely independent of one another allowing true 3d rotation. So for example; if I place my craft so its nose is parallel to the floor the X,Y,Z would be 0,0,0. If I turn it parallel to the floor (World and Local Yaw) 90 degrees it's now 0, 0, 90. If I then pitch it (World Roll, Local Pitch) it 180 degrees it's now 180, 0, 90. I've already explored quaternions however I don't believe I should post my code here as I think I was re-inventing the wheel. I know I didn't explain that well but I believe the problem is pretty generic. Any help anyone could offer is greatly appreciated. Oh, I'd like to avoid gimblelock too. Essentially calculating the rotation around each of the crafts up/forward/right vectors using the up/forward/right vectors. To simply the question a generic implementation rather than one specific to Gmod is absolutely fine.

    Read the article

  • Javascript help fixing a working time ago date function to simply show seconds ago.

    - by Scarface
    Hey guys quick question, I am using a javascript function and it works except I can only make it say 0 seconds ago, when the time is under a minute. Can anyone quickly explain what I am doing wrong? function handleDate( timestamp ) { var n=new Date(), t, ago = " "; if( timestamp ) { t = Math.round( (n.getTime()/1000 - timestamp)/60 ); ago += handleSinceDateEndings( t, timestamp ); } else { ago += ""; } return ago; } function handleSinceDateEndings( t, original_timestamp ) { var ago = " ", date; if( t <= 1 ) { ago += t + " seconds ago"; } else if( t<60) { ago += t + " mins ago"; } else if( t>= 60 && t<= 120) { ago += Math.floor( t / 60 ) + " hour ago" } else if( t<1440 ) { //console.log(t) ago += Math.floor( t / 60 ) + " hours ago"; } else if( t< 2880) { ago += "1 day ago"; } else if( t > 2880 && t < 4320 ) { ago += "2 days ago"; } else { date = new Date( parseInt( original_timestamp )*1000 ) ago += months[ date.getMonth() ] + " " + date.getDate(); } return ago; } var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

    Read the article

  • Fuzzy Date algorithm in Objective-C

    - by Brock Woolf
    I would like to write a fuzzy date method for calculating dates in Objective-C for iPhone. There is a popular explanation here: http://stackoverflow.com/questions/11/how-do-i-calculate-relative-time However it contains missing arguments. How could this be used in Objective-C?. Thanks. const int SECOND = 1; const int MINUTE = 60 * SECOND; const int HOUR = 60 * MINUTE; const int DAY = 24 * HOUR; const int MONTH = 30 * DAY; if (delta < 1 * MINUTE) { return ts.Seconds == 1 ? "one second ago" : ts.Seconds + " seconds ago"; } if (delta < 2 * MINUTE) { return "a minute ago"; } if (delta < 45 * MINUTE) { return ts.Minutes + " minutes ago"; } if (delta < 90 * MINUTE) { return "an hour ago"; } if (delta < 24 * HOUR) { return ts.Hours + " hours ago"; } if (delta < 48 * HOUR) { return "yesterday"; } if (delta < 30 * DAY) { return ts.Days + " days ago"; } if (delta < 12 * MONTH) { int months = Convert.ToInt32(Math.Floor((double)ts.Days / 30)); return months <= 1 ? "one month ago" : months + " months ago"; } else { int years = Convert.ToInt32(Math.Floor((double)ts.Days / 365)); return years <= 1 ? "one year ago" : years + " years ago"; }

    Read the article

  • How to get image's coordinate on JPanel

    - by Jessy
    This question is related to my previous question http://stackoverflow.com/questions/2376027/how-to-generate-cartesian-coordinate-x-y-from-gridbaglayout I have successfully get the coordinate of each pictures, however when I checked the coordinate through (System.out.println) and the placement of the images on the screen, it seems to be wrong. e.g. if on the screen it was obvious that the x point of the first picture is on cell 2 which is on coordinate of 20, but the program shows x=1. Here is part of the code: public Grid (){ setPreferredSize(new Dimension(600,600)); .... setLayout(new GridBagLayout()); GridBagConstraints gc = new GridBagConstraints(); gc.weightx = 1d; gc.weighty = 1d; gc.insets = new Insets(0, 0, 0, 0);//top, left, bottom, and right gc.fill = GridBagConstraints.BOTH; JLabel[][] label = new JLabel[ROWS][COLS]; Random rand = new Random(); // fill the panel with labels for (int i=0;i<IMAGES;i++){ ImageIcon icon = createImageIcon("myPics.jpg"); int r, c; do{ //pick random cell which is empty r = (int)Math.floor(Math.random() * ROWS); c = (int)Math.floor(Math.random() * COLS); } while (label[r][c]!=null); //randomly scale the images int x = rand.nextInt(50)+30; int y = rand.nextInt(50)+30; Image image = icon.getImage().getScaledInstance(x,y, Image.SCALE_SMOOTH); icon.setImage(image); JLabel lbl = new JLabel(icon); // Instantiate GUI components gc.gridx = r; gc.gridy = c; add(lbl, gc); //add(component, constraintObj); label[r][c] = lbl; } I checked the coordinate through this code: Component[] components = getComponents(); for (Component component : components) { System.out.println(component.getBounds()); }

    Read the article

  • How to display image within cell boundary

    - by Jessy
    How can I place an image within the cell boundary? I mean without taking the space of other cell? In the code below, random cells were selected to display images. One image in one cell. The problem is that, the image seems to take other cells as well. ... setPreferredSize(new Dimension(600,600)); final int ROWS = 6; final int COLS = 6; final int IMAGES = 10; setLayout(new GridBagLayout()); GridBagConstraints gc = new GridBagConstraints(); gc.weightx = 1d; gc.weighty = 1d; gc.insets = new Insets(0, 0, 0, 0);//top, left, bottom, and right gc.fill = GridBagConstraints.NONE; JLabel[][] label = new JLabel[ROWS][COLS]; Random rand = new Random(); // fill the panel with labels for (int i=0;i<IMAGES;i++){ ImageIcon icon = createImageIcon("myImage.jpg"); int r, c; do{ //pick random cell which is empty to avoid overlap image in the same cell r = (int)Math.floor(Math.random() * ROWS); c = (int)Math.floor(Math.random() * COLS); } while (label[r][c]!=null); //scale the image int x = rand.nextInt(20)+30; int y = rand.nextInt(20)+30; Image image = icon.getImage().getScaledInstance(x,y, Image.SCALE_SMOOTH); icon.setImage(image); JLabel lbl = new JLabel(icon); gc.gridx = r; gc.gridy = c; add(lbl, gc); //add image to the cell label[r][c] = lbl; }

    Read the article

  • How to display image within cell boundary

    - by Jessy
    How can I place an image within the cell boundary? I mean without taking the space of other cell? In the code below, random cells were selected to display images. One image in one cell. The problem is that, the image seems to take other cells as well. ... setPreferredSize(new Dimension(600,600)); final int ROWS = 6; final int COLS = 6; final int IMAGES = 10; setLayout(new GridBagLayout()); GridBagConstraints gc = new GridBagConstraints(); gc.weightx = 1d; gc.weighty = 1d; gc.insets = new Insets(0, 0, 0, 0);//top, left, bottom, and right gc.fill = GridBagConstraints.NONE; JLabel[][] label = new JLabel[ROWS][COLS]; Random rand = new Random(); // fill the panel with labels for (int i=0;i<IMAGES;i++){ ImageIcon icon = createImageIcon("myImage.jpg"); int r, c; do{ //pick random cell which is empty to avoid overlap image in the same cell r = (int)Math.floor(Math.random() * ROWS); c = (int)Math.floor(Math.random() * COLS); } while (label[r][c]!=null); //scale the image int x = rand.nextInt(20)+30; int y = rand.nextInt(20)+30; Image image = icon.getImage().getScaledInstance(x,y, Image.SCALE_SMOOTH); icon.setImage(image); JLabel lbl = new JLabel(icon); gc.gridx = r; gc.gridy = c; add(lbl, gc); //add image to the cell label[r][c] = lbl; }

    Read the article

  • Calculating odds distribution with 6-sided dice

    - by Stephen
    I'm trying to calculate the odds distribution of a changing number of 6-sided die rolls. For example, 3d6 ranges from 3 to 18 as follows: 3:1, 4:3, 5:6, 6:10, 7:15, 8:21, 9:25, 10:27, 11:27, 12:25, 13:21, 14:15, 15:10, 16:6, 17:3, 18:1 I wrote this php program to calculate it: function distributionCalc($numberDice,$sides=6) { for ( $i=0; $i<pow($sides,$numberDice); $i++) { $sum=0; for ($j=0; $j<$numberDice; $j++) { $sum+=(1+(floor($i/pow($sides,$j))) % $sides); } $distribution[$sum]++; } return $distribution; } The inner $j for-loop uses the magic of the floor and modulus functions to create a base-6 counting sequence with the number of digits being the number of dice, so 3d6 would count as: 111,112,113,114,115,116,121,122,123,124,125,126,131,etc. The function takes the sum of each, so it would read as: 3,4,5,6,7,8,4,5,6,7,8,9,5,etc. It plows through all 3^6 possible results and adds 1 to the corresponding slot in the $distribution array between 3 and 18. Pretty straightforward. However, it only works until about 8d6, afterward i get server time-outs because it's now doing billions of calculations. But I don't think it's necessary because die probability follows a sweet bell-curve distribution. I'm wondering if there's a way to skip the number crunching and go straight to the curve itself. Is there a way to do this, so, for example, with 80d6 (80-480)? Can the distribution be projected without doing 6^80 calculations? I'm not a professional coder and probability is still new to me, so thanks for all the help! Stephen

    Read the article

  • Problem Loading multiple textures using multiple shaders with GLSL

    - by paj777
    I am trying to use multiple textures in the same scene but no matter what I try the same texture is loaded for each object. So this what I am doing at the moment, I initialise each shader: rightWall.SendShaders("wall.vert","wall.frag","brick3.bmp", "wallTex", 0); demoFloor.SendShaders("floor.vert","floor.frag","dirt1.bmp", "floorTex", 1); The code in SendShaders is: GLuint vert,frag; glEnable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); char *vs = NULL,*fs = NULL; vert = glCreateShader(GL_VERTEX_SHADER); frag = glCreateShader(GL_FRAGMENT_SHADER); vs = textFileRead(vertFile); fs = textFileRead(fragFile); const char * ff = fs; const char * vv = vs; glShaderSource(vert, 1, &vv, NULL); glShaderSource(frag, 1, &ff, NULL); free(vs); free(fs); glCompileShader(vert); glCompileShader(frag); program = glCreateProgram(); glAttachShader(program, frag); glAttachShader(program, vert); glLinkProgram(program); glUseProgram(program); LoadGLTexture(textureImage, texture); GLint location = glGetUniformLocation(program, textureName); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); glUniform1i(location, 0); And then in the main loop: rightWall.UseShader(); rightWall.Draw(); demoFloor.UseShader(); demoFloor.Draw(); Which ever shader is initialised last is the texture which is used for both objects. Thank you for your time and I appreciate any comments.

    Read the article

  • Why would this Lua optimization hack help?

    - by Ian Boyd
    i'm looking over a document that describes various techniques to improve performance of Lua script code, and i'm shocked that such tricks would be required. (Although i'm quoting Lua, i've seen similar hacks in Javascript). Why would this optimization be required: For instance, the code for i = 1, 1000000 do local x = math.sin(i) end runs 30% slower than this one: local sin = math.sin for i = 1, 1000000 do local x = sin(i) end They're re-declaring sin function locally. Why would this be helpful? It's the job of the compiler to do that anyway. Why is the programmer having to do the compiler's job? i've seen similar things in Javascript; and so obviously there must be a very good reason why the interpreting compiler isn't doing its job. What is it? i see it repeatedly in the Lua environment i'm fiddling in; people redeclaring variables as local: local strfind = strfind local strlen = strlen local gsub = gsub local pairs = pairs local ipairs = ipairs local type = type local tinsert = tinsert local tremove = tremove local unpack = unpack local max = max local min = min local floor = floor local ceil = ceil local loadstring = loadstring local tostring = tostring local setmetatable = setmetatable local getmetatable = getmetatable local format = format local sin = math.sin What is going on here that people have to do the work of the compiler? Is the compiler confused by how to find format? Why is this an issue that a programmer has to deal with? Why would this not have been taken care of in 1993? i also seem to have hit a logical paradox: Optimizatin should not be done without profiling Lua has no ability to be profiled Lua should not be optimized

    Read the article

  • convert list of relative widths to pixel widths

    - by mkoryak
    This is a code review question more then anything. I have the following problem: Given a list of relative widths (no unit whatsoever, just all relative to each other), generate a list of pixel widths so that these pixel widths have the same proportions as the original list. input: list of proportions, total pixel width. output: list of pixel widths, where each width is an int, and the sum of these equals the total width. Code: var sizes = "1,2,3,5,7,10".split(","); //initial proportions var totalWidth = 1024; // total pixel width var sizesTotal = 0; for (var i = 0; i < sizes.length; i++) { sizesTotal += parseInt(sizes[i], 10); } if(sizesTotal != 100){ var totalLeft = 100;; for (var i = 0; i < sizes.length; i++) { sizes[i] = Math.floor(parseInt(sizes[i], 10) / sizesTotal * 100); totalLeft -= sizes[i]; } sizes[sizes.lengh - 1] = totalLeft; } totalLeft = totalWidth; for (var i = 0; i < sizes.length; i++) { widths[i] = Math.floor(totalWidth / 100 * sizes[i]) totalLeft -= widths[i]; } widths[sizes.lenght - 1] = totalLeft; //return widths which contains a list of INT pixel sizes

    Read the article

  • How can I convert seconds to minutes in jQuery while updating an element with the current time?

    - by pghtech
    So I see a number of ways to display allot of seconds in a (static) hr/min/sec. However, I am trying to produce a visual count down timer: $('#someelement').html(minCounter + ' minutes ' + ((secCounter == 0) ? '' : (secCounter + ' seconds'))); My counter is reduced inside a SetInterval that triggers ever 1 second: //....... var counter = redirectTimer; jQuery('#WarningDialogMsg').html(minCounter + ' minutes ' + ((secCounter == 0) ? '' : (secCounter + ' seconds'))); //........ SetInternval( function() { counter -= 1; secCounter = Math.floor(counter % 60); minCounter = Math.floor(counter / 60); //....... $('#someelement').html(minCounter + ' minutes ' + ((secCounter == 0) ? '' : (secCounter + ' seconds'))); }, 1000) It is a two minute counter but I don't want to display 120 seconds. I want to display 1 : 59 (and counting down). I have managed to get it to work using the above, but my main question is: is there a more elegant way to accomplish the above? (note: I am redirecting once "counter == 0").

    Read the article

  • Artifacts when trying to draw background grid without anti-aliasing in a QGraphicsScene

    - by estan
    Hi folks, I'm trying to draw a background grid in the drawBackground() function of my QGraphicsScene subclass: void Scene::drawBackground(QPainter *painter, const QRectF &rect) { const int gridSize = 50; const int realLeft = static_cast<int>(std::floor(rect.left())); const int realRight = static_cast<int>(std::ceil(rect.right())); const int realTop = static_cast<int>(std::floor(rect.top())); const int realBottom = static_cast<int>(std::ceil(rect.bottom())); // Draw grid. const int firstLeftGridLine = realLeft - (realLeft % gridSize); const int firstTopGridLine = realTop - (realTop % gridSize); QVarLengthArray<QLine, 100> lines; for (qreal x = firstLeftGridLine; x <= realRight; x += gridSize) lines.append(QLine(x, realTop, x, realBottom)); for (qreal y = firstTopGridLine; y <= realBottom; y += gridSize) lines.append(QLine(realLeft, y, realRight, y)); //painter->setRenderHint(QPainter::Antialiasing); painter->setPen(QPen(QColor(220, 220, 220), 0.0)); painter->drawLines(lines.data(), lines.size()); // Draw axes. painter->setPen(QPen(Qt::lightGray, 0.0)); painter->drawLine(0, realTop, 0, realBottom); painter->drawLine(realLeft, 0, realRight, 0); } However, unless I turn on anti-aliasing, moving items around will sometimes leave artifacts in the grid (areas where it's not drawn). It seems it mostly happens at low zoom levels, when the view is zoomed out a bit. Any ideas what I might be doing wrong here? I'd really don't want to turn anti-aliasing on since the lines are strictly horizontal and vertical, and I'd like them to be as crisp as possible. Any help is much appriciated, Regards, Elvis

    Read the article

  • Random Movement in a Fixed Container

    - by James Barracca
    I'm looking to create something that can move randomly inside of a fixed div container. I love the way the object moves in this example that I found searching this website... http://jsfiddle.net/Xw29r/15/ The code on the jsfiddle contains the following: $(document).ready(function(){ animateDiv(); }); function makeNewPosition(){ // Get viewport dimensions (remove the dimension of the div) var h = $(window).height() - 50; var w = $(window).width() - 50; var nh = Math.floor(Math.random() * h); var nw = Math.floor(Math.random() * w); return [nh,nw]; } function animateDiv(){ var newq = makeNewPosition(); var oldq = $('.a').offset(); var speed = calcSpeed([oldq.top, oldq.left], newq); $('.a').animate({ top: newq[0], left: newq[1] }, speed, function(){ animateDiv(); }); }; function calcSpeed(prev, next) { var x = Math.abs(prev[1] - next[1]); var y = Math.abs(prev[0] - next[0]); var greatest = x > y ? x : y; var speedModifier = 0.1; var speed = Math.ceil(greatest/speedModifier); return speed; }? CSS: div.a { width: 50px; height:50px; background-color:red; position:fixed; }? However, I don't believe the code above constricts that object at all. I need my object to move randomly inside of a container that is let's say for now... 1200px in width and 500px in height. Can someone steer me in the right direction? I'm super new to coding so I'm having a hard time finding an answer on my own. Thanks so much! James

    Read the article

  • Determining two lines in MATLAB

    - by Sanyi
    Hi! I am making the game planarity in MATLAB, and i am stuck where the program have to determine that is there any lines that are in inscision with each other. Any ideas how could the program find the inscision points. Heres my source for the game: > clear; clc; a=1; b=10; x=floor(rand(5,1)*(b-a+1)+a); y=floor(rand(5,1)*(b-a+1)+a); fig1=figure; set(fig1,'Color','w','Position',[100 100 500 500]) plot(x,y,'o','MarkerSize',12,'MarkerFaceColor','r'); axis([0 11 0 11]); axis off grid on; hold on; FirstPlayerLines=[]; SecondPlayerLines=[]; for a1=1:+1:2 for a2=5:-1:2 plot([x(a1) x(a2)],[y(a1) y(a2)],'Color','black','LineWidth',3); end end waitforbuttonpress

    Read the article

  • R optimization: How can I avoid a for loop in this situation?

    - by chrisamiller
    I'm trying to do a simple genomic track intersection in R, and running into major performance problems, probably related to my use of for loops. In this situation, I have pre-defined windows at intervals of 100bp and I'm trying to calculate how much of each window is covered by the annotations in mylist. Graphically, it looks something like this: 0 100 200 300 400 500 600 windows: |-----|-----|-----|-----|-----|-----| mylist: |-| |-----------| So I wrote some code to do just that, but it's fairly slow and has become a bottleneck in my code: ##window for each 100-bp segment windows <- numeric(6) ##second track mylist = vector("list") mylist[[1]] = c(1,20) mylist[[2]] = c(120,320) ##do the intersection for(i in 1:length(mylist)){ st <- floor(mylist[[i]][1]/100)+1 sp <- floor(mylist[[i]][2]/100)+1 for(j in st:sp){ b <- max((j-1)*100, mylist[[i]][1]) e <- min(j*100, mylist[[i]][2]) windows[j] <- windows[j] + e - b + 1 } } print(windows) [1] 20 81 101 21 0 0 Naturally, this is being used on data sets that are much larger than the example I provide here. Through some profiling, I can see that the bottleneck is in the for loops, but my clumsy attempt to vectorize it using *apply functions resulted in code that runs an order of magnitude more slowly. I suppose I could write something in C, but I'd like to avoid that if possible. Can anyone suggest another approach that will speed this calculation up?

    Read the article

  • converting a UTC time to a local time zone in Java

    - by aloo
    I know this subject has been beaten to death but after searching for a few hours to this problem I had to ask. My Problem: do calculations on dates on a server based on the current time zone of a client app (iphone). The client app tells the server, in seconds, how far away its time zone is away from GMT. I would like to then use this information to do computation on dates in the server. The dates on the server are all stored as UTC time. So I would like to get the HOUR of a UTC Date object after it has been converted to this local time zone. My current attempt: int hours = (int) Math.floor(secondsFromGMT / (60.0 * 60.0)); int mins = (int) Math.floor((secondsFromGMT - (hours * 60.0 * 60.0)) / 60.0); String sign = hours > 0 ? "+" : "-"; Calendar now = Calendar.getInstance(); TimeZone t = TimeZone.getTimeZone("GMT" + sign + hours + ":" + mins); now.setTimeZone(t); now.setTime(someDateTimeObject); int hourOfDay = now.get(Calendar.HOUR_OF_DAY); The variables hour and mins represent the hour and mins the local time zone is away from GMT. After debugging this code - the variables hour, mins and sign are correct. The problem is hourOfDay does not return the correct hour - it is returning the hour as of UTC time and not local time. Ideas?

    Read the article

  • How do I vertcally align thumbnails of unknown height using jQuery?

    - by playahabana
    Ok, I am a complete beginner to this, in fact I am still building my first website. I am attempting to do this all by hand-coding without a CMS in order to try and learn as much possible as quickly as possible. If this post is in the wrong place I apologise, and a pointer to right place would be appreciated. Here goes, I am trying to peice together a bit of jQuery that will automatically vertically align my thumbnails in my image gallery (they are all different sizes). They are within fixed size div's and the function I am attempting looks something like this: <script type="text/javascript"> $('#ul.photo).bind(function() { var smartVert=$(this); var phty=ob.("ul.photo img").height(); //get height of photos var phtdif=Math.floor(208 - phty); //subtract height of photo from div height var phttop=Math.floor(phtdif / 2); //gets padding reqd. $ob.("ul.photo").css({'padding-top' : phttop}) //sets padding to center thumbnail }); smartVert(); unsurprisingly this doesn't work, if some kindly soul could take pity on a total noob, and point out where I am going wrong (probably in writing complete gibberish would be my first guess) it would be greatly appreciated- even if you could just point me in the direcion of a tutorial regarding these things, I have looked and found one reference that said such a function was easy to create, but it did not elaborate. thankyou in advance

    Read the article

  • SQL Server query

    - by carrot_programmer_3
    Hi, I have a SQL Server DB containing a registrations table that I need to plot on a graph over time. The issue is that I need to break this down by where the user registered from (e.g. website, wap site, or a mobile application). the resulting output data should look like this... [date] [num_reg_website] [num_reg_wap_site] [num_reg_mobileapp] 1 FEB 2010,24,35,64 2 FEB 2010,23,85,48 3 FEB 2010,29,37,79 etc... The source table is as follows... UUID(int), signupdate(datetime), requestsource(varchar(50)) some smple data in this table looks like this... 1001,2010-02-2:00:12:12,'website' 1002,2010-02-2:00:10:17,'app' 1003,2010-02-3:00:14:19,'website' 1004,2010-02-4:00:16:18,'wap' 1005,2010-02-4:00:18:16,'website' Running the following query returns one data column 'total registrations' for the website registrations but I'm not sure how to do this for multiple columns unfortunatly.... select CAST(FLOOR(CAST([signupdate]AS FLOAT ))AS DATETIME) as [signupdate], count(UUID) as 'total registrations' FROM [UserRegistrationRequests] WHERE requestsource = 'website' group by CAST(FLOOR(CAST([signupdate]AS FLOAT ))AS DATETIME)

    Read the article

  • Weird flex date issue

    - by CodeMonkey
    Flex is driving me CRAZY and I think it's some weird gotcha with how it handles leap years and none leap years. So here's my example. I have the below dateDiff method that finds the number of days or milliseconds between two dates. If I run the following three statements I get some weird issues. dateDiff("date", new Date(2010, 0,1), new Date(2010, 0, 31)); dateDiff("date", new Date(2010, 1,1), new Date(2010, 1, 28)); dateDiff("date", new Date(2010, 2,1), new Date(2010, 2, 31)); dateDiff("date", new Date(2010, 3,1), new Date(2010, 3, 30)); If you were to look at the date comparisons above you would expect to get 30, 27, 30, 29 as the number of days between the dates. There weird part is that I get 29 when comparing March 1 to March 31. Why is that? Is it something to do with February only having 28 days? If anyone has ANY input on this that would be greatly appreciated. public static function dateDiff( datePart:String, startDate:Date, endDate:Date ):Number { var _returnValue:Number = 0; switch (datePart) { case "milliseconds": _returnValue = endDate.time - startDate.time; break; case "date": // TODO: Need to figure out DST problem i.e. 23 hours at DST start, 25 at end. // Math.floor causes rounding down error with DST start at dayOfYear _returnValue = Math.floor(dateDiff("milliseconds", startDate, endDate)/(1000 * 60 * 60 * 24)); break; } return _returnValue; }

    Read the article

  • PHP date/time help/

    - by NOW
    I keep getting a value of 0 for $years and $months when there should be a value other then 0 can someone tell me what I'm doing wrong with my code? And what I need to fix? I'm trying to subtract two dates. Here is my PHP code. $delete_date = "2000-01-12 08:02:39"; $current_date = date('Y-m-d H:i:s'); //current date $diff = abs(strtotime($current_date) - strtotime($delete_date)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); echo $current_date . '<br />'; echo $delete_date. '<br />'; echo $diff. '<br />'; echo $years. '<br />'; echo $months. '<br />';

    Read the article

  • Cannot find Power Management Tab in XP

    - by Andrew Heath
    I have the problem that when I send my computer to sleep it wakes if you bump the table, floor, burp etc. I have read many threads that say go to Device Manager Mouse Properties Power Management Tab and uncheck the box for wake. My problem is I do not have a Power Management Tab! Anyone know how to enable the tab or stop the mouse from waking my machine? And no, turning it upside down doesn't work either!

    Read the article

  • Dell XPS Problem

    - by Alex B.
    Hi, Yesterday, my mom dropped her laptop to the floor and got the blue screen of death after trying to boot the system. I was able to start fedora live CD and get some of her stuff off the hard drive, but I cannot seem to be able to install Windows on it. The installation starts loading files and then the computer turns off. I am thinking that she might need a new hard drive. Any ideas?

    Read the article

  • Pushing Large Files to 500+ Computers [closed]

    - by WMIF
    I work with a team to manage 500-600 rented Windows 7 computers for an annual conference. We have a large amount of data that needs to be synced to these computers, up to 1 TiB. The computers are divided into rooms and connected through unmanaged gigabit switches. We prepare these computers ahead of time with the Windows installation and configuration, plus any files that we have available to us before we send the base image in for replication by the rental company. Every year, we have presenters approach on site with up to gigs of data that need to be pushed to the room that they will be presenting in. Sometimes they only have a few files that are small sizes, such as a slide PDF, but can sometimes be much larger 5 GiB. Our current strategy for pushing these files is using batch scripts and RoboCopy. For the large pushes, we actually use a BitTorrent client to generate a torrent file, and then we use the batch-RoboCopy to push the torrent into a folder on the remote machines that is being monitored by an installed BT client. Often times, this data needs to be pushed immediately with a small time window. We have several machines in a control room that are identical to the machines on the floor that we use for these pushes. We occasionally have a need to execute a program on the remote machines, and we currently use batch and PSexec to handle this task. We would love to be able to respond to these last minute pushes with "sorry, your own fault", but it won't happen. The BT method has allowed us to have a much faster response time, but the whole batch process can get messy when there are multiple jobs being pushed. We use Enterprise Ghost for other processes, and it doesn't work well in this large of scale, plus it is really quite expensive for a once-a-year task like this. EDIT: There is a hard requirement that the remote machines on the floor are running Windows. The control machines do not have a hard OS requirement. I would really like to stay away from Multicast because of complications with upstream routers. Is Multicast or BitTorrent the better way to go on this? Is there another protocol that might work better?

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >