Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
pankus
Jul 30, 2003
I couldn't find the answer to this on google so I thought I would ask it here. It's an excel question so if it doesn't belong here I'll ask somewhere else.

I have my entire worksheet set up for color banding using conditional formatting, but I want blank cells to not be banded, that is I only want a cell to be colored once something is in it. I've tried =isblank(address(row(),column())) and isnontext, istext, but those don't seem to work. Can someone help me out? Thanks.

EDIT: I figured it out and learned something about conditional formatting on the way! all right!

pankus fucked around with this message at 19:38 on Aug 8, 2008

Adbot
ADBOT LOVES YOU

dagard
Mar 31, 2005

fankey posted:

Does anyone know if it's possible to block Windows svn clients from getting a particular directory? We share a common code base between Linux and Windows and some of the Linux files are different by case only. Of course that makes a checkout fail on Windows. There's no reason for Windows to get that particular directory but the source tree is structured such that it would be too complicated to manually get around it.

The only way I know of is to do it per-user, or a user group, since there's not really any way for the repo to know for sure otherwise what client you're using.

EngineerJoe
Aug 8, 2004
-=whore=-



I'm doing my first Ruby on Rails project and I'm stuck with some quirky behavior.

I'll try my best to describe the problem:

System A: my RoR server (my iMac)
System B: some other system running Java

System B receives messages and dispatches them to various systems. One of those systems is System A.

It uses POST to send the data as text/xml to a specific url.

Problem: I'm not seeing the data. I've verified that the XML is being sent with a packet sniffer but nothing is coming up in logs. I've logged params and I get:

Processing someclass#received (for 192.168.xxx.xx at 2008-08-08 13:55:11) [POST]
Session ID: e193a41d387440baaac4070c029e1651
Parameters: {"action"=>"received", "controller"=>"processor"}

actionreceivedcontrollerprocessor
Rendering processor/received
Completed in 0.00148 (673 reqs/sec) | Rendering: 0.00065 (43%) | 200 OK [http://192.168.xxx.xx/processor/received]


I've tried feeding it data via telnet:
Parameters: {"xml"=>"alala", "action"=>"received", "controller"=>"processor"}
where the data is <xml>alala</xml>

Maybe I'm missing something but where can I access the XML data in the controller?

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
Edit: Got it.

OneEightHundred fucked around with this message at 19:20 on Aug 14, 2008

Thirteenth Step
Mar 3, 2004

Edit: Found a PHP thread.

Emo.fm
Jan 2, 2007
never mind, figured it out

Emo.fm fucked around with this message at 00:16 on Aug 12, 2008

tef
May 30, 2004

-> some l-system crap ->
On a complete aside, we set up a last.fm group

http://www.last.fm/group/cobol

Geno
Apr 26, 2004
STUPID
DICK
This is in Javascript.

So I got 2 2D arrays. One stores the month and the day, with the month being in the first position and day being in the second. myArray[0] would be 10,1--specifically, myArray[0][0] = 10, myArray[0][1] = 1 for October 1. myArray[1] would be a different date and so on.

I'm trying to transfer these into another 2D array that is categorized by the month and days. Kinda like so:

var hello = {
0 : [],
1 : [],
2 : [],
3 : [],
4 : [],
5 : [],
6 : [],
7 : [],
8 : [],
9 : [],
10 : [],
11 : []
};

Basically, I would want myArray[0] to be in hello[10][0] and so on for subsequent dates. I'm having trouble with this part. I was thinking that double for-loops should be used but I'm not sure.

I've been programming for less than a year and am not really good at explaning things so bare with me.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Geno posted:

I've been programming for less than a year and am not really good at explaning things so bare with me.

I have no idea what the gently caress you're trying to do. Try telling us what you want to do in words rather than code.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Also those aren't even arrays, they're objects.

hey mom its 420
May 12, 2007

Yeah, usually it's better if you tell us what you're actually trying to achieve overall (for instance: I want to find all the Sundays that fall on even dates or something) instead of asking how to solve your problem in a very specific way which just might be wrong. JavaScript has pretty decent date handling functions for messing around with the calendar and such.

Jo
Jan 24, 2005

:allears:
Soiled Meat
Am I handling this problem in the wrong way?

I have a somewhat math intensive raycasting function. The most expensive step right now is determining what occluding surfaces are within range of the light. I tried using quadtrees to limit down the size of the search area, but there's the issue of light beams crossing boundaries. Should I be using some other method like binary space partitioning or vistrees?

mantaworks
May 6, 2005

by Fragmaster

Geno posted:

So I got 2 2D arrays. One stores the month and the day, with the month being in the first position and day being in the second. myArray[0] would be 10,1--specifically, myArray[0][0] = 10, myArray[0][1] = 1 for October 1. myArray[1] would be a different date and so on.

If you can do myArray[0] to return a number, how come you can also do myArray[0][1]? If myArray[0][1] is possible, then myArray[0] should return an array (or object, whatever you want to call it), not a number.

Geno
Apr 26, 2004
STUPID
DICK
...yeah, definitely failed in trying to explain my problem, sorry about that.

What I'm trying to do is convert a string into the objects (var hello) that I mentioned earlier with the 0-11 : []. I need to convert it to that because I'm trying to implement it in a Javascript calendar that highlights specific dates in that format. For example, 0: [1,5,30] would have January 1,5,30 all highlighted.

The string is a bunch of dates in the format of mm/dd/yr, which are separated by a "|" Only the months and the dates are of importance so I use a .split("|"). Hopefully, this code will be a bit better:

code:
var myArray = new Array();
var myArray1 = new Array();
var str = "10/1/08 12:00 AM|10/12/08 12:00 AM";
myArray = str.split("|");
  
var index;
var monthIndex;
var i=0;
for (i=0;i<myArray.length;i++) {
  index = myArray[i].indexOf(" ");
  myArray[i]=myArray[i].substring(0,index);
  myArray1[i] = myArray[i].split("/", 2);	
}
myArray[0] would print 10,1; myArray[0][0] would print 10, etc.

So I'm trying to make it so that 10/1/08 date would appear in the "var hello" as 9: [1], if that makes sense.

Geno fucked around with this message at 19:44 on Aug 17, 2008

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
I don't think you quite understand how arrays work. If you have a 2-dimensional array in Javascript, printing my2DArray[0] is going to give you something like "(Object Array)". You're making this way harder on yourself than you need to, though. Here's how I'd do it (not tested):

code:
var str = "2/3/08 12:00 AM|10/1/08 12:00 AM|10/12/08 12:00 AM";
var pieces = str.split("|");

var importantDates = [];
for(var i=0; i<12; i++)
    importantDates[i] = [];

for(var i=0; i<pieces.length; i++)
{
    var matches = pieces[i].match(/^(\d+)\/(\d+)/);
    if(matches) // if matches is null, the regex above failed for some reason
    {
        // this is more explicit than I'd normally be
        var month = matches[1];
        var day   = matches[2];
        importantDates[month-1].push(day);
    }
}
Note that foo = []; is shorthand for creating a new array.

Given the input I supplied, you'd get the following:
code:
importantDates[ 0 /*Jan*/] = []
importantDates[ 1 /*Feb*/] = [3]
importantDates[ 2 /*Mar*/] = []
importantDates[ 3 /*Apr*/] = []
importantDates[ 4 /*May*/] = []
importantDates[ 5 /*Jun*/] = []
importantDates[ 6 /*Jul*/] = []
importantDates[ 7 /*Aug*/] = []
importantDates[ 8 /*Sep*/] = []
importantDates[ 9 /*Oct*/] = [1,12]
importantDates[10 /*Nov*/] = []
importantDates[11 /*Dec*/] = []

Rabbi Dan
Oct 26, 2005

ASK ME ABOUT MY CREEPY FACEBOOK APP FOR STALKING GIRLS I DON'T KNOW
Quick question about memory/performance...

In Java, If I create a class, call it A, and add 5 methods to it.

I then proceed to create a TON of instances of the class (objects).

Does the fact that the class have 5 methods get multiplied by the number of instances to take up more space in memory?

If a method is just a general calculation method that could be placed outside of the class, will it take a LOT less memory (given that I'm making thousands of instances) if I take it out of the class?

TSDK
Nov 24, 2003

I got a wooden uploading this one

Jo posted:

Am I handling this problem in the wrong way?

I have a somewhat math intensive raycasting function. The most expensive step right now is determining what occluding surfaces are within range of the light. I tried using quadtrees to limit down the size of the search area, but there's the issue of light beams crossing boundaries. Should I be using some other method like binary space partitioning or vistrees?
Yeah, searching through triangle soups is always one of the most expensive parts of anything like this.

There are dozens of spatial partitioning algorithms you can try out, but how effective they are can depend largely on the type of geometry you're trying to partition. If you've got the time, then it might be worth coding up a few different methods and actually measuring how effective the algorithm is at cutting down your ray-tri tests. If you've already tried quad-trees, then some other starters for ten:

http://en.wikipedia.org/wiki/Kd-tree
http://en.wikipedia.org/wiki/Binary_space_partitioning
http://isg.cs.tcd.ie/spheretree/
AABB or OOBB trees

This guy's blog is quite useful as well:
http://realtimecollisiondetection.net/

Standish
May 21, 2001

Rabbi Dan posted:

Quick question about memory/performance...

In Java, If I create a class, call it A, and add 5 methods to it.

I then proceed to create a TON of instances of the class (objects).

Does the fact that the class have 5 methods get multiplied by the number of instances to take up more space in memory?

If a method is just a general calculation method that could be placed outside of the class, will it take a LOT less memory (given that I'm making thousands of instances) if I take it out of the class?
No and no. There's only one copy of a method no matter how many instances of its class you create.

minidracula
Dec 22, 2007

boo woo boo
What's the closest thing to Core Animation on Windows? In a quick look, it seems to be WPF, and some WPF-related links I've followed seem to indicate that WPF supports an implicit animation model like Core Animation (set start, end, and interval, and it figures out interpolation for you). It's probably less elegant than Core Animation, but is it functionally accurate? If not WPF, is there something else I should be looking at?

csammis
Aug 26, 2003

Mental Institution

mnd posted:

What's the closest thing to Core Animation on Windows? In a quick look, it seems to be WPF, and some WPF-related links I've followed seem to indicate that WPF supports an implicit animation model like Core Animation (set start, end, and interval, and it figures out interpolation for you). It's probably less elegant than Core Animation, but is it functionally accurate?

Yeah, Windows Presentation Foundation is as close to Core Animation as it gets for the Windows platform. I've never used Core Animation so I can't speak to elegance in comparison, but WPF is pretty slick, and there's a thread about it if you have any questions while you're learning. Keep in mind WPF is only supported on Windows XP SP2 and up.

Pensive Goat
Dec 31, 2005

What's a hypotenuse?

Standish posted:

No and no. There's only one copy of a method no matter how many instances of its class you create.

That is correct, though it isn't really the entire picture.

Since all methods in Java are virtual by default, all instances of a class will carry around a reference to each of their (non-final) methods. So if all of these methods can be stored in an external class, each instance of the original class only needs a reference to the external class instead of references to each method.

Really though, this is just an academic view of things; you should focus on making the methods make sense from an object-oriented perspective instead of focusing on tiny optimizations.

Runaway Five
Dec 31, 2007
I hate gays almost as much as I hate good posting. Also, God is good. Amen
Simple question, I'm pretty sure I have the answer, but I wanted to make sure.

It is about efficiency.

So, let's say I have n-many variables. Let's say n = 4.

So, int a = 7; int b = 3; int c = 43; int d = 213;
[I made their values up]

Now, what I want to do in a sense is swap all of them with another variable.

So,
b gets assigned the value of a.
c gets assigned the value of b.
d gets assigned the value of c.
a gets assigned the value of d.

Of course, doing b = a; c = b; d = c; a = d; Is not any good because if you do this, you are overwriting variables you need to use later.

As far as I can tell, you MUST create 4 temporary (local) variables, copy the current values of a,b,c and d into the local copies, and THEN reassign the original a,b,c, and d accordingly. Is this the best it gets?

Additionally, is there any special case where you could use trickery? Such as using pointers and/or if the original variables are contiguous in memory, etc...

Scaevolus
Apr 16, 2007

Runaway Five posted:

So, int a = 7; int b = 3; int c = 43; int d = 213;
b gets assigned the value of a.
c gets assigned the value of b.
d gets assigned the value of c.
a gets assigned the value of d.
You could do it with one temporary variable

code:
int a = 7, b = 3, c = 43, d = 213;
int t;
t = d;
d = c;
c = b;
b = a;
a = t;
(you could probably also do the retarded xor trick but that's pointless and slow)

Unless I missed something?

Runaway Five
Dec 31, 2007
I hate gays almost as much as I hate good posting. Also, God is good. Amen

Scaevolus posted:

You could do it with one temporary variable

Okay, I feel really stupid You are 100% correct. Thank you. Man, this feels like the dumbest C++ thing I've done in a long time.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Pensive Goat posted:

Since all methods in Java are virtual by default, all instances of a class will carry around a reference to each of their (non-final) methods. So if all of these methods can be stored in an external class, each instance of the original class only needs a reference to the external class instead of references to each method.
That wording makes it sound like an object has a reference per member method, but I'm sure that Java implements it as one reference to a table of all member methods.

bitprophet
Jul 22, 2004
Taco Defender

Runaway Five posted:

Okay, I feel really stupid You are 100% correct. Thank you. Man, this feels like the dumbest C++ thing I've done in a long time.

For what it's worth, some languages let you do this on the fly, although I don't remember the technical term for it (I believe there was one).

In Python, for example:
code:
>>> a = 25
>>> b = 50
>>> c = 75
>>> d = 100
>>> print a, b, c, d
25 50 75 100
>>> d, c, b, a = a, b, c, d
>>> print a, b, c, d
100 75 50 25
>>> 

Scaevolus
Apr 16, 2007

bitprophet posted:

For what it's worth, some languages let you do this on the fly, although I don't remember the technical term for it (I believe there was one).

In Python, for example:
In Python this is called unpacking, and it works by making a tuple (a,b,c,d) and then unpacking it and doing the assignment to each variable. So it's the equivalent of making four temporary variables, and then doing the assignment.

bitprophet
Jul 22, 2004
Taco Defender

Scaevolus posted:

In Python this is called unpacking, and it works by making a tuple (a,b,c,d) and then unpacking it and doing the assignment to each variable. So it's the equivalent of making four temporary variables, and then doing the assignment.

Sounds about right; also fits with how higher level languages usually do things that are syntactically simpler than their lower level counterparts, but not necessarily any faster or more efficiently.

Scaevolus
Apr 16, 2007

bitprophet posted:

Sounds about right; also fits with how higher level languages usually do things that are syntactically simpler than their lower level counterparts, but not necessarily any faster or more efficiently.

code:
$ cat pretty.py && time python pretty.py
a, b, c, d = 25, 50, 75, 100

for x in xrange(10000000):
    a, b, c, d = b, c, d, a

real	0m6.473s
user	0m6.264s
sys	0m0.052s

$ cat savage.py && time python savage.py
a, b, c, d = 25, 50, 75, 100

for x in xrange(10000000):
    t = d
    d = c
    c = b
    b = a
    a = d

real	0m6.796s
user	0m6.588s
sys	0m0.028s
v:shobon:v

Unless you're swapping megabytes of memory many times per second, swapping probably isn't anywhere close to a bottleneck.

Allie
Jan 17, 2004

The objects aren't being "swapped", you're just changing what objects the names a, b, c, and d refer to. If you use a temporary variable for whatever reason, you're just creating an extra reference, not a copy of the object.

Scaevolus
Apr 16, 2007

Milde posted:

The objects aren't being "swapped", you're just changing what objects the names a, b, c, and d refer to. If you use a temporary variable for whatever reason, you're just creating an extra reference, not a copy of the object.
Crap, I keep on forgetting that everything is an object. :smith:

(assigning references should about as expensive as assigning ints anyways)

zootm
Aug 8, 2006

We used to be better friends.

Mustach posted:

That wording makes it sound like an object has a reference per member method, but I'm sure that Java implements it as one reference to a table of all member methods.
This may well be right but considering the extent of the runtime optimisations of which the JVM is capable it's often best to avoid reasoning based on these high-level views of implementation.

Vanadium
Jan 8, 2005

Scaevolus posted:

v:shobon:v
The lower level equivalent would be C, not ugly python code :colbert:

bitprophet posted:

For what it's worth, some languages let you do this on the fly, although I don't remember the technical term for it (I believe there was one).

In C++, for example:

int a = 25, b = 50, c = 75, d = 100;
boost::tie(a, b, c, d) = boost::make_tuple(b, c, d, a);

Vanadium fucked around with this message at 18:37 on Aug 24, 2008

Runaway Five
Dec 31, 2007
I hate gays almost as much as I hate good posting. Also, God is good. Amen
I have yet another question.

How do I make my C++ Visual Studio 2005 projects build/compile/link in such a way that as an executable they can stand alone and run on another computer which does not have Visual Studio installed on it.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Runaway Five posted:

How do I make my C++ Visual Studio 2005 projects build/compile/link in such a way that as an executable they can stand alone and run on another computer which does not have Visual Studio installed on it.
They need either the VC++ runtime library installed or you need to statically link to it at build time.

Deployment
More deployment

This gets asked a lot; could you add info on it to the first post, Avenging Dentist? Oops, this isn't the C++ thread

Mustach fucked around with this message at 00:04 on Aug 25, 2008

N.Z.'s Champion
Jun 8, 2003

Yam Slacker
This is probably a stupid question but lets say that I've got variables A and B... is there a way to swap their values without using a third variable (Eg, C = A, A = B, B = C) and without meddling with pointers?

I guess I was just wondering whether there's some syntax for this that I was unaware of, perhaps in a single expression.

(in Python, PHP, whatever)

POKEMAN SAM
Jul 8, 2004

N.Z.'s Champion posted:

This is probably a stupid question but lets say that I've got variables A and B... is there a way to swap their values without using a third variable (Eg, C = A, A = B, B = C) and without meddling with pointers?

I guess I was just wondering whether there's some syntax for this that I was unaware of, perhaps in a single expression.

(in Python, PHP, whatever)


is this a loving joke?

fake edit: this has to be a loving joke.

N.Z.'s Champion
Jun 8, 2003

Yam Slacker

Ugg boots posted:

is this a loving joke?

fake edit: this has to be a loving joke.

Nope, serious, and I'm sure it's a stupid question (I'm pretty tired). Is there a way of doing it in a single expression?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

N.Z.'s Champion posted:

Nope, serious, and I'm sure it's a stupid question (I'm pretty tired). Is there a way of doing it in a single expression?

Dude, someone showed how to do it like 5 posts up.

Adbot
ADBOT LOVES YOU

N.Z.'s Champion
Jun 8, 2003

Yam Slacker

Avenging Dentist posted:

Dude, someone showed how to do it like 5 posts up.

gently caress, sorry folks :(

So unpacking tuples works in Python, but can this be done in PHP?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply