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
Femtosecond
Aug 2, 2003

Argh. I'm wanting to write a bit of code to keep track of statistics about my memory pool. I want to set up this UpdateMemoryStats function as a global so I can call it anywhere (or in the main loop) and I only want one set of stats, so I figure I should make the stats static. Unfortunately I keep getting a drat unresolved external symbol error. I'm obviously missing something... I've gone over this a bunch and I think I just need someone else to look at this or something.

Or if there's a better way to do this just suggest that.

code:
MemoryPool.hpp
==============
struct MemoryPoolStats
{
	int total_allocs;
};

class MemoryPool
{
	static MemoryPoolStats	mMemoryStats;
};

void	UpdateMemoryStats(); 

-------------------------------------------
MemoryPool.cpp
==============

void UpdateMemoryStats()
{
//an example of some operation on the mMemoryStats
MemoryPool::mMemoryStats.total_allocs = 0; //<-- I guess this is bad somehow

}

Adbot
ADBOT LOVES YOU

more falafel please
Feb 26, 2005

forums poster

Femtosecond posted:

Argh. I'm wanting to write a bit of code to keep track of statistics about my memory pool. I want to set up this UpdateMemoryStats function as a global so I can call it anywhere (or in the main loop) and I only want one set of stats, so I figure I should make the stats static. Unfortunately I keep getting a drat unresolved external symbol error. I'm obviously missing something... I've gone over this a bunch and I think I just need someone else to look at this or something.

Or if there's a better way to do this just suggest that.

code:
MemoryPool.hpp
==============
struct MemoryPoolStats
{
	int total_allocs;
};

class MemoryPool
{
	static MemoryPoolStats	mMemoryStats;
};

void	UpdateMemoryStats(); 

-------------------------------------------
MemoryPool.cpp
==============

void UpdateMemoryStats()
{
//an example of some operation on the mMemoryStats
MemoryPool::mMemoryStats.total_allocs = 0; //<-- I guess this is bad somehow

}

Somewhere (and only one place) you need to put
code:
MemoryPoolStats MemoryPool::mMemoryStats;
Probably in MemoryPool.cpp. If you put that definition in a header file, you'll get a multiply defined symbol error, assuming that header is included more than once.

poopiehead
Oct 6, 2004

edit: I meant to post this in the Java thread...

Jam2
Jan 15, 2008

With Energy For Mayhem
I am hiring programmers to write code for my online ticketing merchant's website. They will be building everything from scratch.

What is the best web scripting language/framework to have my website developed using? php, .net, cf, ruby?

What will be the easiest for a new programmer to interpret and add functionality to?

My main concern is that I don't want the site developed on a dead platform that mainstream programmers do not use.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
There isn't really a posterchild for "mainstream programmer". You'll find good/bad/excellent/retarded programmers of all types. Although, I haven't heard the term ColdFusion in a while, so maybe you'll want to stay away from that.

Avenging Dentist
Oct 1, 2005

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

Jam2 posted:

What is the best web scripting language/framework to have my website developed using? php, .net, cf, ruby?

You can make a good website in any language, though PHP practically encourages insecure code, and ColdFusion has fallen out of style. Other languages to consider would be Perl and Python.

Jam2 posted:

What will be the easiest for a new programmer to interpret and add functionality to?

Probably PHP, but chances are that the code will have security vulnerabilities. Most programmers should be able to adapt to any OO language, and if they can't, chances are the stuff they'd have written would have been trash anyway.

Jam2
Jan 15, 2008

With Energy For Mayhem

Triple Tech posted:

There isn't really a posterchild for "mainstream programmer". You'll find good/bad/excellent/retarded programmers of all types. Although, I haven't heard the term ColdFusion in a while, so maybe you'll want to stay away from that.

Yay for me. I recently had my flagship website coded in ColdFusion. Only after paying big money and receiving the finished product did I find out. Hooray for getting additional development done on my snazzy new site. Also spent $1.5K for a CF based CMS.

Jam2 fucked around with this message at 06:23 on Jun 23, 2008

Mr Crucial
Oct 28, 2005
What's new pussycat?
I'm not sure this counts as programming as such, but I have a question about how to do something in Excel.

If I have a list of dates in cells A1 to A10, how can I find the average time in days/hours between those dates?

Queen of Beans
Jun 15, 2007

Mr Crucial posted:

I'm not sure this counts as programming as such, but I have a question about how to do something in Excel.

If I have a list of dates in cells A1 to A10, how can I find the average time in days/hours between those dates?

In the cell you want the summary type =AVERAGE(A1:A10), then right-click on the cell, choose "Format Cells", choose "Custom" and set it to dd/MM/yyyy hh:mm (or MM/dd/yyyy hh:mm if you are American).

Queen of Beans fucked around with this message at 11:12 on Jun 23, 2008

Mr Crucial
Oct 28, 2005
What's new pussycat?

hobofood posted:

In the cell you want the summary type =AVERAGE(A1:A10), then right-click on the cell, choose "Format Cells", choose "Custom" and set it to dd/MM/yyyy hh:mm (or MM/dd/yyyy hh:mm if you are American).

That's not what I'm after, that gives an 'average date' whatever that might be, on my data it spit out a date near the middle of the data set.

What I want is the average time between dates in a list - say if the list had the 20th, 24th and 30th of any particular month, the average time between dates is 5 days, if you see what I mean.

Vanadium
Jan 8, 2005

So set B1, B2 to =A2-A1, =A3-A2 and so on and average through that?

Aredna
Mar 17, 2007
Nap Ghost
If you want a formula that works in one cell, you'll need an array formula:

code:
=AVERAGE(A2:A10-A1:A9)
For this to work you need to type it in and then press CTRL-SHIFT-ENTER. Afterwards, it should look like this in the formula bar:

code:
{=AVERAGE(A2:A10-A1:A9)}
What this is actually doing is taking taking the average of the following values:

A2-A1
A3-A2
A4-A3
...
A10-A9

Mr Crucial
Oct 28, 2005
What's new pussycat?

Aredna posted:

If you want a formula that works in one cell, you'll need an array formula:

This works, thanks.

fankey
Aug 31, 2001

I didn't see a Regex megathread ( I thought there was one at one point ) so hopefully this is a good place to ask this. I'm looking for a regex expression that will match space delimited tokens. If a token contains a space then the token is quoted. Currently I don't need to worry about quotes in the tokesn themselves. So a string like
code:
foo bar "with a space" "another space" woo
would match as
code:
foo
bar
with a space
another space
woo
Any help would be appreciated since regular expressions hurt the inside of my brain. This is using the .NET Regex class.

Zombywuf
Mar 29, 2008

fankey posted:

So a string like
code:
foo bar "with a space" "another space" woo
would match as
code:
foo
bar
with a space
another space
woo

code:
(?:(\w+)|"([^"]*)")
Will have either submatch 0 or submatch 1 as your desired value

code:
(\w+|"[^"]*")
Will have the quotes included in the match.

Also, how do I stop smilies appearing in code blocks?

Zombywuf fucked around with this message at 19:58 on Jun 25, 2008

csammis
Aug 26, 2003

Mental Institution

Zombywuf posted:

Also, how do I stop smilies appearing in code blocks?

Check the "Disable smilies" box in your post

fankey
Aug 31, 2001

Zombywuf posted:

code:
(\w+|"[^"]*")
Will have the quotes included in the match.
Thanks, that worked with a slight modification. I forgot to mention that my tokens might be floating point numbers so
code:
([\w.]+|"[^\"]*")
appears to pick that up as well.

tef
May 30, 2004

-> some l-system crap ->

fankey posted:

([\w.]+|"[^\"]*")

. means every character, so '"toot toot"' would match as '"toot', and 'toot"'.

You might want something like [^"]\S+|"[^"]+" to be a general case - match either someting that doesn't start with " followed by non whitespace characters, or " followed by anything that isn't a " then a final ".

fankey
Aug 31, 2001

tef posted:

. means every character, so '"toot toot"' would match as '"toot', and 'toot"'.

You might want something like [^"]\S+|"[^"]+" to be a general case - match either someting that doesn't start with " followed by non whitespace characters, or " followed by anything that isn't a " then a final ".

If I test my expression with this site it appears to work OK - test 1.2 "toot toot" matches as 'test', '1.2', and '"toot toot"'. If I send test 1.2 "toot toot" to your expression I get 4 matches - 'test', '1.2', '"toot' and 'toot"'.

Is there something I'm missing?

tef
May 30, 2004

-> some l-system crap ->

fankey posted:

Is there something I'm missing?

No, I'm missing something - . means match everything, but when it is in a character class it just means period, i.e \. is the same as [.]

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Is there such a thing as a private interface? Or a private abstract method that needs to be implemented by their sub classes? I'm using Perl so technically no problem like this exists, but I'm just double checking, like when I move on to a more OOPish language.

I have a process whose start and end is the same, and only one method, Start Process, is exposed via a superclass. Start Proccess consists of methods &Start, &Middle, and &End. Start and end are completely standardized while &Middle is what changes for any given subclass. So... Can &Middle be private? Technically it can't do anything on its own without the context of the entire process, that's why I'm wondering if it can be made private.

That Turkey Story
Mar 30, 2003

Triple Tech posted:

Is there such a thing as a private interface? Or a private abstract method that needs to be implemented by their sub classes? I'm using Perl so technically no problem like this exists, but I'm just double checking, like when I move on to a more OOPish language.
Yes, this is common and even generally the preferred approach. Herb Sutter has a nice article about this with respect to C++.

stubblyhead
Sep 13, 2007

That is treason, Johnny!

Fun Shoe
I saw a rails thread, but nothing for Ruby specifically, so I thought I would ask my question here. I'm reading through the O'Reilly Learning Ruby book, and it says "Unlike other languages, a Ruby constant is mutable—that is, you can change its value."

It doesn't go any more in-depth at that point, but it leaves me rather confused. If you can change it, then in what way is it a constant?

bitprophet
Jul 22, 2004
Taco Defender
According to the Pragmatic book on Ruby, it looks like constants are simply normal variables which raise a warning when changed. So you get the flexibility of being able to change them when desired (although, yes, I don't quite understand why one would not then use a normal variable...) but the extra rigidity of a warning being emitted when you do so.

Vanadium
Jan 8, 2005

They have different scoping rules, too.

Jo
Jan 24, 2005

:allears:
Soiled Meat
Regex Request:

I'm looking to parse the following file:
code:
<Map XMLblahblah>
  <XML Jibba Jabba>
  <Tour distance="FLOATINGPOINTVALUE!">
  <More>
</Map>
There are about 30,000 of these files. I need a regular expression I can feed to egrep that will extract only the value 'FLOATINGPOINTVALUE', not the surrounding quotes or xml.

I've tried distance=\"[0-9]*\.[0-9]*, but that gives me the XML before it, too.

hey wiz
Jun 18, 2005

grep/egrep will return the lines what match that regex you specify, not the regex itself. You'll need to redirect the egrep output to sed/awk(gawk) to extract the data from the line you want.

Scaevolus
Apr 16, 2007

Jo posted:

Regex Request:

I'm looking to parse the following file:
code:
<Map XMLblahblah>
  <XML Jibba Jabba>
  <Tour distance="FLOATINGPOINTVALUE!">
  <More>
</Map>
There are about 30,000 of these files. I need a regular expression I can feed to egrep that will extract only the value 'FLOATINGPOINTVALUE', not the surrounding quotes or xml.

I've tried distance=\"[0-9]*\.[0-9]*, but that gives me the XML before it, too.

grep -oP '(?<=distance=")[0-9]*\.[0-9]*' works.

Zombywuf
Mar 29, 2008

Jo posted:

Regex Request:

I'm looking to parse the following file:
code:
<Map XMLblahblah>
  <XML Jibba Jabba>
  <Tour distance="FLOATINGPOINTVALUE!">
  <More>
</Map>
There are about 30,000 of these files. I need a regular expression I can feed to egrep that will extract only the value 'FLOATINGPOINTVALUE', not the surrounding quotes or xml.

I've tried distance=\"[0-9]*\.[0-9]*, but that gives me the XML before it, too.

Do not use regular expressions to parse XML, XML is not a regular language. I have had to maintain code that used regular expressions to parse XML files and if I catch your doing it I will find you...

Use xmlgrep, it comes with the XML::Twig perl library.

Jo
Jan 24, 2005

:allears:
Soiled Meat

Zombywuf posted:

Do not use regular expressions to parse XML, XML is not a regular language. I have had to maintain code that used regular expressions to parse XML files and if I catch your doing it I will find you...

Use xmlgrep, it comes with the XML::Twig perl library.

Relax, I not using it in production code. I only need it in the final step to extract from the XML output that single value for use in a spreadsheet.

It feels the largest limitation right now is my work machine is Windows based. I'd swap to Debian in a heartbeat, but all our in house stuff was written for Windows. :(

Scaevolus: I will try that tomorrow when I get in.

Thank you to everyone who responded.

Kino
Aug 2, 2003
I'm trying to use a Visual Studio deployment project for the first time to create a .msi installer for my application. It's pretty simple for the most part, but I'm struggling to figure out how to create an uninstall link for the application. I think I can do it if I can make a shortcut to msiexec.exe, but it seems like I can't do that because apparently you can only create links to files in the installer package. Is there some trick to this that I'm missing? I've googled around a bit, but the only thing I can find is someone asking the question on experts-exchange where the usual google cache trick won't work.

csammis
Aug 26, 2003

Mental Institution

Kino posted:

I've googled around a bit, but the only thing I can find is someone asking the question on experts-exchange where the usual google cache trick won't work.

Does the "scroll down past the interstitial ads until you see the answer" method work on that page?

Kino
Aug 2, 2003

csammis posted:

Does the "scroll down past the interstitial ads until you see the answer" method work on that page?

Oh bah, for some reason I didn't do that. It didn't end up being that helpful though, as it just tells you to use msiexec to do it and doesn't explain how to actually create the shortcut in VS. I'm starting to wonder if it'd be easier to just make an application that calls msiexec programatically.

VV Great, thanks, that did it. Guess my search terms were slightly off.

Kino fucked around with this message at 19:00 on Jul 1, 2008

fankey
Aug 31, 2001

Kino posted:

I'm trying to use a Visual Studio deployment project for the first time to create a .msi installer for my application. It's pretty simple for the most part, but I'm struggling to figure out how to create an uninstall link for the application. I think I can do it if I can make a shortcut to msiexec.exe, but it seems like I can't do that because apparently you can only create links to files in the installer package. Is there some trick to this that I'm missing? I've googled around a bit, but the only thing I can find is someone asking the question on experts-exchange where the usual google cache trick won't work.
First result for googling 'create uninstall link visual studio installer'.

POKEMAN SAM
Jul 8, 2004
I wrote a Bloom Filter class, but I don't quite know what numbers to use for the number of slots and the number of hash functions to call. I really don't know where to begin on either of them, so I have 64 slots and 8 hashes, but I think those numbers might be a little low.

Does anyone know any guidelines that might help me? I'm prioritizing a low false-positive rate above performance, if that matters.

Edit: 256 slots with 16 hashes seems to be a bit better on the false positive side.

POKEMAN SAM fucked around with this message at 02:53 on Jul 2, 2008

POKEMAN SAM
Jul 8, 2004

Ugg boots posted:

I wrote a Bloom Filter class, but I don't quite know what numbers to use for the number of slots and the number of hash functions to call. I really don't know where to begin on either of them, so I have 64 slots and 8 hashes, but I think those numbers might be a little low.

Does anyone know any guidelines that might help me? I'm prioritizing a low false-positive rate above performance, if that matters.

Edit: 256 slots with 16 hashes seems to be a bit better on the false positive side.

For anyone who cares, this page really helped me out:
http://pages.cs.wisc.edu/~cao/papers/summary-cache/node8.html#tab:bf-config-1

Since my hash returns 16 bytes as it is, I'm probably going to just stick with 16 hash values with 256 slots, since each byte can represent 0-255, so the numbers go together pretty well.

checkeredshawn
Jul 16, 2007

A bash question:

The script takes one hostname, and n DNS servers to query with that hostname.

What I already have it doing is querying the DNS servers and putting just the IP address results into unique temporary files in /tmp/. The files are stored in an array in the script, and I'd like to diff all of them to see if any of the results differ, and then output which DNS servers gave different results.

Thanks for any help.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Why again is emulation for video games slow? Is it because the programmers lack the EXACT documentation for the original architecture? Basically is it a matter of accuracy or is it really processing power?

I guess it couldn't be processing power if today's systems are magnitudes more powerful than consoles... Also, just how powerful are the specialized components in consoles that couldn't be emulated away (quickly) in a modern desktop? (graphics, sound, "emotion", etc)

Allie
Jan 17, 2004

checkeredshawn posted:

The files are stored in an array in the script, and I'd like to diff all of them to see if any of the results differ, and then output which DNS servers gave different results.

Just choose one file as a base file and diff each of the other files against the base one individually. This will tell you if there any overall differences, but I'm not sure what you're actually trying to accomplish here. If you're trying to verify that your DNS records haven't changed, it might be better to actually compare the results against known good output (which would then be your base file).

As far as how that would look in bash, I'd use a for loop to iterate over the array (excluding the base file) and run diff -q on each file against the base file. You could build up results in a temporary file/buffer, or just have the program exit when when one of the diffs returns any output.

Adbot
ADBOT LOVES YOU

Coconut Pete
Jul 31, 2004

Bad Mother Fucker
This is not exactly a programming question, but it is related to programming:

If you are contracted to build a web application, say a CMS or whatever, how do you feel about building it with a framework, such as CodeIgniter for PHP or Django or whatever, not counting if the client specifically requests it?

I've always kind of wondered, do you use CodeIgniter, or since you are selling the application as your own to the client, should you write all of the code by hand? Is using a framework "cheating" when selling an application?

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