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
Vanadium
Jan 8, 2005

Did you try method="post"?

Adbot
ADBOT LOVES YOU

Gilgamesh
Nov 26, 2001

Vanadium posted:

Did you try method="post"?

Yes, same result

Also, I know it's posting because a refresh in my browser pulls up a "re-send" confirmation.

Gilgamesh
Nov 26, 2001

I figured it out... it needs to be "name" instead of "id". I knew it was something stupid.

MrMoo
Sep 14, 2000

Gilgamesh posted:

something stupid.
name="stupid"

hexadecimal
Nov 23, 2008

by Fragmaster
what is a good regex for a URL starting with [url]http://[/url]

POKEMAN SAM
Jul 8, 2004

hexadecimal posted:

what is a good regex for a URL starting with [url]http://[/url]

http://immike.net/blog/2007/04/06/5-regular-expressions-every-web-programmer-should-know/

ndb
Aug 25, 2005

I solved my problem, if anyone is interested.

The problem wasn't with the C++ file, but with the ASM.

My file was called FpMult.asm, and I ended the file with END FpMult (because I read somewhere that you were supposed to do an END <FILENAME>, so I thought it'd be a great idea). Well, apparently with an ASM file with more than one function, you're not supposed to do this, or you get the result I get, which was where the "driver" program doesn't ever get a chance to execute.

My professor simply deleted the label, telling me "This won't do anything," and sure enough it did. :)

EDIT: Blah.

adante
Sep 18, 2003
this is more of a estoeric crypto question than programming but I didn't want to make a new thread so unless someone can recommend another megathread to post it in:

I have a linear secret share of the form X + Y mod N = C

Let C be some 64-bit integer of the form C = A + B*(2^32)

If there are two parties, one of whom knows X and the other knows Y, is it possible for them to interact in some way to produce Xa, Xb and Ya, Yb such that Xa/Ya are secret shares of A, and Ya/Yb are secret shares of B, without either learning A, B or C?

This is related to this paper on secure scalar products. On page 13 they discuss the possibility of 'packing' plaintexts into a single ciphertext for batch scalar products and note that a subset of those plaintexts and be recovered "...efficiently by using standard cryptographic techniques." I'm not really sure how though.

Sgt. Raisins
Oct 21, 2007
Damnit
I guess COC is a good place to put this question.

There is a site with the same theme as http://getsatisfaction.com/ only you vote on what people want with points. It has the same 'Feedback' button and all.

POKEMAN SAM
Jul 8, 2004

Sgt. Raisins posted:

I guess COC is a good place to put this question.

There is a site with the same theme as http://getsatisfaction.com/ only you vote on what people want with points. It has the same 'Feedback' button and all.

What

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Sgt. Raisins posted:

I guess COC is a good place to put this question.

There is a site with the same theme as http://getsatisfaction.com/ only you vote on what people want with points. It has the same 'Feedback' button and all.

That isn't a question.

Sgt. Raisins
Oct 21, 2007
Damnit
Yeah, it was late and I didn't think it though.
Lets rephrase it.

I am looking for a site that offers to take care of feedback and feature requests. It is very similar to http://getsatisfaction.com/ The other site even has a similar feedback button that they have you to put in the page. The big difference is that they give you votes(4-5 I think) to put in to features you would like to see. Anyone have any idea what site I am talking about?


EDIT: Never mind, Someone found it for me http://uservoice.com/

Sgt. Raisins fucked around with this message at 15:08 on Dec 4, 2008

nbv4
Aug 21, 2002

by Duchess Gummybuns
code:
for(field in fields) {
		
	$("#button_" + field).click(function(event) {
		
		if( $("#id_" + field).val() == "") {
			$("#id_" + field).val($("#id_total").val());
		} else {
			$("#id_" + field).val("");
		}
	});
}
How can I get this little javascript code to work. The problem has to do with variable scope, I'm sure. Basically I want to create a bunch of jQuery objects through a loop.

Vanadium
Jan 8, 2005

nbv4 posted:

code:
for(field in fields) {
		
	$("#button_" + field).click(function(event) {
		
		if( $("#id_" + field).val() == "") {
			$("#id_" + field).val($("#id_total").val());
		} else {
			$("#id_" + field).val("");
		}
	});
}
How can I get this little javascript code to work. The problem has to do with variable scope, I'm sure. Basically I want to create a bunch of jQuery objects through a loop.

The problem is that field refers to the last object in all callbacks, right? I think you can workaround that by having the variable enclosed in the callback function come from another function's scope:

code:
var make_callback = function(field) {
  return function(event) {
    if( $("#id_" + field).val() == "") {
      $("#id_" + field).val($("#id_total").val());
    } else {
      $("#id_" + field).val("");
    }
  }
}

for(field in fields) {
  $("#button_" + field).click(make_callback(field))
}

tractor fanatic
Sep 9, 2005

Pillbug
Is this a thread for algorithms? I was wondering if there was a quick or easy algorithm to test if a point is inside a non-convex polygon

Fruit Smoothies
Mar 28, 2004

The bat with a ZING
All these years, with the little network programming I've done, I've written communication like this:

my appz posted:

Client: SEND|FILE|<file>
Server: FILE|<size>
Server: FILE|<type|
Server: Stream data

Now I wonder if it's better to just send the file back with the first bytes of the stream set as the size, type etc.

Is it better to header the packets, or to use the more interactive client/server command system?

hexadecimal
Nov 23, 2008

by Fragmaster

tractor fanatic posted:

Is this a thread for algorithms? I was wondering if there was a quick or easy algorithm to test if a point is inside a non-convex polygon

I don't know about testing for concave property, but the one test I remember off hand is drawing a line from some point inside polygon and seeing how many times it intersects the edges of polygon. If it's odd then the point is inside, if it its even its outside.

hey mom its 420
May 12, 2007

Hey, I wrote an AVL tree implementation in C (btw comments welcome, I think it's pretty dashing) and I'm having some problems. When I manually insert these words by doing insert(root, "word") and then manually remove them by remove(&root, "word"), everything seems to work fine. For example, the root is relevailles, the height ends up at 4 and then when I remove them in order, the height ends up at 0 because all the elements are removed and root is a null pointer.

However, when I try to insert from a file like in the source and then iterate over that file to remove words, I get strange results, because after removing all the elements, I get that the final height is 1, when it should be 0. I suck at doing I/O in C and I recon there's a problem in the way I read the lines from the file. Anyone know what I'm doing wrong?

hey mom its 420 fucked around with this message at 18:32 on Dec 6, 2008

ani47
Jul 25, 2007
+
Probably your use of feof http://drpaulcarter.com/cs/common-c-errors.php#4.2

hey mom its 420
May 12, 2007

Hmm, tried checking for feof after the call to fgets and breaking out then, but no change.

EDIT: Ah, got it, when doing malloc, I wasn't reserving space for the null termination byte. When I do malloc(strlen(buf) + 1)), it seems to work fine. I found another problem though, ugh. When I load up a file with 1,5M words that are in order and load it up, I get a reported tree height of 21, which sounds good because log2(1,5M) is just under 21. However, if I shuffle the lines in that file and try to insert them, I get a reported tree height of 25, which seems way too much. Can anyone see any problems on a quick glance with the code?

EDIT: UGHH!!! I'm so stupid, nevermind, it didn't come to my stupid head that a 1,5M node AVL tree with a height of 25 can still be balanced.

hey mom its 420 fucked around with this message at 20:26 on Dec 6, 2008

im_afraid_of_clowns
Nov 28, 2000
I turn my camera on. I cut my fingers on the way.
I want to allow access to a site if terms are agreed upon. If the user hasn't agreed, they are re-directed to the terms page. What is a good approach?

baquerd
Jul 2, 2007

by FactsAreUseless

im_afraid_of_clowns posted:

I want to allow access to a site if terms are agreed upon. If the user hasn't agreed, they are re-directed to the terms page. What is a good approach?

A javascript alert window would be easiest.

im_afraid_of_clowns
Nov 28, 2000
I turn my camera on. I cut my fingers on the way.

quadreb posted:

A javascript alert window would be easiest.

I went with the setcookie php function and checking the cookie on every page. I'm still learning php and this is what I did:

code:
<?php
$expiresOn = time()+604800; 
$domain = $_SERVER['HTTP_HOST'];
if (isset($_POST['agree']))
{
	setcookie("agree", "yes", $expiresOn, "/", $domain, 0);
}
else 
{
	setcookie("agree", "no", $expiresOn, "/", $domain, 0);
}
?>
To check
code:
<?php
$domain = "http://www.".$_SERVER['HTTP_HOST'];
if ($_COOKIE['agree']==no || $_COOKIE['agree']=="")
{
	header("Location: $domain");
	exit;
}
?>

im_afraid_of_clowns fucked around with this message at 23:47 on Dec 6, 2008

MrMoo
Sep 14, 2000

im_afraid_of_clowns posted:

I want to allow access to a site if terms are agreed upon. If the user hasn't agreed, they are re-directed to the terms page. What is a good approach?

Any login system, make the terms part of the account signup agreement.

hey mom its 420
May 12, 2007

I'm going to also use a trie for storing words of the alphabet and searching through them, etc. What's the best way to store the edges in a node? If I use an array that I increase and decrease in size, I save space but I have to traverse the edges to find the next node. If I just use an array of 256 fields (one for each character in ASCII), I can just index them to get the next node but 256 fields times 8 for each (char, node pointer) pair is 2Kb. I could also use a hash table but I don't know if that's worth it.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Bonus posted:

I'm going to also use a trie for storing words of the alphabet and searching through them, etc. What's the best way to store the edges in a node?

The general rule with tries is that you should use a fixed-size array unless the character set is prohibitively large. 256 is not prohibitively large, but (say) the Unicode set is. Even if the "flat" character set is prohibitively large, you should consider splitting individual characters into sequences of smaller sets, e.g. with Unicode by branching on the bytes of a UTF-8 encoding.

Bonus posted:

If I use an array that I increase and decrease in size, I save space but I have to traverse the edges to find the next node.

If there's a clear pre-processing phase, you could keep them in sorted order and do a binary search. But again, this isn't worthwhile unless you can't use fixed-size arrays.

Bonus posted:

If I just use an array of 256 fields (one for each character in ASCII), I can just index them to get the next node but 256 fields times 8 for each (char, node pointer) pair is 2Kb.

1. Why would you need to store the character in each entry?
2. Another advantage of fixed-size arrays (if you're using C/C++) is that you can keep the array inline in each node, which should help space usage a little (and significantly reduce your running time).
3. The only reason to support 256 branches at each node is if you want to treat strings as opaque binary data, which is reasonable if they're 1) actually binary data or 2) arbitrary Unicode text. Otherwise, you should figure out what assumptions are valid about your data, then go hog-wild: notably, case-insensitive English words only need 26 branches per node (plus a few if you allow compounds / hyphenated compounds / contractions).

Bonus posted:

I could also use a hash table but I don't know if that's worth it.

This is a decent option if your character set is very large (or infinite).

rjmccall fucked around with this message at 23:04 on Dec 7, 2008

hey mom its 420
May 12, 2007

Cool, I just implemented the trie by using a field which increases and decreases in size but I have to traverse when seeing which edge to follow. It performs alright for inserting, looking up and then deleting 1.5M words, but not as well as the AVL tree and hash table. I'll try doing some branching to see how fast it is if I switch to a hash table for storing edges or a field that I can index in O(1) time.

I've done an analysis of the input files and I've found that they contain 78 different ASCII characters, so that shouldn't be a problem.

Later I'll have to add the ability to find the n nearest words for any word by Levenshtein distance and I have a feeling tries will give good performance there. AVL trees will probably be alright for that too but I have no idea if it's even possible to implement that efficiently if I'm storing the words in a hash table.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
This is a question about using curl, but I thought it might be answered here since I think anybody here who has done some automation has probably done this before. Suppose I want to access IBM's news on Google Finance. Your browser can go there at:

http://finance.google.com/finance?morenews=10&rating=1&q=NYSE:IBM

Now I want to retrieve that from the command line. Generally when I see '&' I assume it's time for curl.

I am trying:

curl -d "morenews=10" -d "rating=1" -d "q=NYSE:IBM" http://finance.google.com/finance > test.html

test.html will end up being the main google finance page. No good. What am I missing?

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Rocko Bonaparte posted:

This is a question about using curl, but I thought it might be answered here since I think anybody here who has done some automation has probably done this before. Suppose I want to access IBM's news on Google Finance. Your browser can go there at:

http://finance.google.com/finance?morenews=10&rating=1&q=NYSE:IBM

Now I want to retrieve that from the command line. Generally when I see '&' I assume it's time for curl.

I am trying:

curl -d "morenews=10" -d "rating=1" -d "q=NYSE:IBM" http://finance.google.com/finance > test.html

test.html will end up being the main google finance page. No good. What am I missing?

curl 'http://finance.google.com/finance?morenews=10&rating=1&q=NYSE:IBM'

It's a GET request, not a POST, so you just request the URL with no particular cleverness.

Edit: Just to be clear, this is a property of HTTP, not of curl; wget or indeed any web client behaves the same way. The only time you need to use curl's -d stuff is when the page requires POST data (and, consequently, could not be made into a [url][/url] link).

ShoulderDaemon fucked around with this message at 06:17 on Dec 8, 2008

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I was trying wget on the full URL and was getting a 404. Is there something to it or should that have just worked?

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Rocko Bonaparte posted:

I was trying wget on the full URL and was getting a 404. Is there something to it or should that have just worked?

If you ran wget http://finance.google.com/finance?morenews=10&rating=1&q=NYSE:IBM without the quotes around the URL, it'll parse as wget http://finance.google.com/finance?morenews=10 & rating=1 & q=NYSE:IBM, which runs wget http://finance.google.com/finance?morenews=10 in the background, resulting in a 404, sets the environment variable rating to 1, and sets the environment variable q to NYSE:IBM.

Edit: This is sort of a pet peeve of me, I have no idea why the GET syntax settled on using ampersand to separate query components, even though many shells have used that as a reserved character for ages. What makes it worse is that recently a new separator was proposed (which, of course, web browsers can't safely use at this point because the server code may be too old to understand it) and that wound up as semicolon, possibly the only character reserved by more shells than ampersand.

ShoulderDaemon fucked around with this message at 08:17 on Dec 8, 2008

narbsy
Jun 2, 2007

Bonus posted:

Cool, I just implemented the trie by using a field which increases and decreases in size but I have to traverse when seeing which edge to follow. It performs alright for inserting, looking up and then deleting 1.5M words, but not as well as the AVL tree and hash table. I'll try doing some branching to see how fast it is if I switch to a hash table for storing edges or a field that I can index in O(1) time.

I've done an analysis of the input files and I've found that they contain 78 different ASCII characters, so that shouldn't be a problem.

Later I'll have to add the ability to find the n nearest words for any word by Levenshtein distance and I have a feeling tries will give good performance there. AVL trees will probably be alright for that too but I have no idea if it's even possible to implement that efficiently if I'm storing the words in a hash table.

That's pretty cool. There's another self-balancing tree that's faster than AVL called the DSW algorithm. It's different in the sense that it doesn't balance on each insert, delete but rather waits and then turns the tree into a "vine" (a linked list), and then re-forms the tree by unrolling the "vine". It is superb.

I always meant to implement a trie but never did :(

MrMoo
Sep 14, 2000

Rocko Bonaparte posted:

http://finance.google.com/finance?morenews=10&rating=1&q=NYSE:IBM
I am trying:

curl -d "morenews=10" -d "rating=1" -d "q=NYSE:IBM" http://finance.google.com/finance > test.html
Talk about making something way more complicated that it needs to be.

ShoulderDaemon posted:

Edit: This is sort of a pet peeve of me, I have no idea why the GET syntax settled on using ampersand to separate query components, even though many shells have used that as a reserved character for ages.

Ampersand wasn't evented for shell syntax, spaces don't work well in shell's too and that's 110% a neckbeards fault.

MrMoo fucked around with this message at 07:58 on Dec 9, 2008

hey mom its 420
May 12, 2007

narbsy posted:

That's pretty cool. There's another self-balancing tree that's faster than AVL called the DSW algorithm. It's different in the sense that it doesn't balance on each insert, delete but rather waits and then turns the tree into a "vine" (a linked list), and then re-forms the tree by unrolling the "vine". It is superb.

I always meant to implement a trie but never did :(
That's pretty cool stuff, I'll check out the paper, maybe even implement it for a bonus point in my class.
Just for fun I also went and implemented tries in Haskell, took me about 10 minutes, Haskell owns.
code:
data Trie a = Trie { isEnd :: Bool, getChildren :: [(a, Trie a)] }

trieInsert :: (Eq a) => [a] -> Trie a -> Trie a
trieInsert [] (Trie _ children) = Trie True children
trieInsert (x:xs) (Trie empty children) = 
    let (hit, rest) = partition ((==x) . fst) children in
    case hit of [(u, t)] -> Trie empty ((u, trieInsert xs t):rest)
                [] -> Trie empty ((x, trieInsert xs (Trie False [])):rest)

trieLookup :: (Eq a) =>  [a] -> Trie a -> Bool
trieLookup [] (Trie end _) = end
trieLookup (x:xs) (Trie end children) = 
    case lookup x children of Nothing -> False
                              Just nextTrie -> trieLookup xs nextTrie

trieDelete :: (Eq a) =>  [a] -> Trie a -> Trie a
trieDelete [] (Trie _ children) = Trie False children
trieDelete (x:xs) (Trie end children) = 
    let (hit, rest) = partition ((==x) . fst) children in
    case hit of [] -> Trie end children
                [(u, t)] -> let forwardDeleted = trieDelete xs t
                            in  if (null $ getChildren forwardDeleted) && (not $ isEnd forwardDeleted)
                                then Trie end rest
                                else Trie end ((u, trieDelete xs t):rest)

Cedra
Jul 23, 2007
Does anyone have any experience with FreePastry and Windows?

I'm going through the tutorials and have managed to get 2 nodes to see each other. The problem is that the first node does not report any messages being received from the second node.

Apparently the output should be :
code:
java -cp .:FreePastry-2.1alpha3.jar rice.tutorial.lesson3.DistTutorial 9001 10.9.8.7 9001
:1122933198281:Error connecting to address /10.9.8.7:9001: java.net.ConnectException: Connection refused: no further information
:1122933198296:No bootstrap node provided, starting a new ring...
Finished creating new node SocketNodeHandle (<0xC20545..>/FOO/10.9.8.7:9001 [-4445364026872145996])
MyApp <0xC20545..> received MyMsg from <0xDD90C6..> to <0xA67C20..>
MyApp <0xC20545..> received MyMsg from <0xDD90C6..> to <0xBF799E..>
MyApp <0xC20545..> received MyMsg from <0xDD90C6..> to <0xC4BEE7..>
MyApp <0xC20545..> received MyMsg from <0xDD90C6..> to <0x86ACA9..>
MyApp <0xC20545..> received MyMsg from <0xDD90C6..> to <0x9906E6..>
MyApp <0xC20545..> received MyMsg from <0xDD90C6..> to <0x8F5015..>
MyApp <0xC20545..> received MyMsg from <0xDD90C6..> to <0xC20545..>
MyApp <0xC20545..> received MyMsg from <0xDD90C6..> to <0xC20545..>
Instead I just get
code:
java -cp .:FreePastry-2.1alpha3.jar rice.tutorial.lesson3.DistTutorial 9001 10.9.8.7 9001
:1122933198281:Error connecting to address /10.9.8.7:9001: java.net.ConnectException: Connection refused: no further information
:1122933198296:No bootstrap node provided, starting a new ring...
Finished creating new node SocketNodeHandle (<0xC20545..>/FOO/10.9.8.7:9001 [-4445364026872145996])
Basically none of the received acknowledgements.

The 2nd node seemingly works fine, and it does attempt to directly send messages to the node, which is on the leaf set, so I don't know what's going wrong :confused:

csammis
Aug 26, 2003

Mental Institution

MrMoo posted:

This can only be a troll, no ones that stupid.


That is one 'tarded peeve. Can't possibly use meaningful punctuation it interferes with neckbeard shell syntax.

Looks like someone got his Cheerios pissed in on the wrong side of the bed this morning :shobon:

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

MrMoo posted:

This can only be a troll, no ones that stupid.


That is one 'tarded peeve. Can't possibly use meaningful punctuation it interferes with neckbeard shell syntax.
Wow I use curl only once or twice so I must be a complete loving moron when I ask something fairly basic. I should go back to riding tricycles right? The curl usage I saw online claimed that multiple -d statements get linked together. I tried using multiple '&' signs in one long -d parameter but it didn't work either.

Stephen
Feb 6, 2004

Stoned
This isn't entirely a programming question, but most of you guys are math geniuses anyways so I'll give it a shot.

If I have a polygon with n points each with a coordinate (e.g. longitude, latitude) and I have a point (x) on a map, how can I prove that x is either contained inside of the polygon or not?

If it's not too horribly obvious, my math skills are terrible I know.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
http://en.wikipedia.org/wiki/Point_in_polygon

Adbot
ADBOT LOVES YOU

hexadecimal
Nov 23, 2008

by Fragmaster

Stephen posted:

This isn't entirely a programming question, but most of you guys are math geniuses anyways so I'll give it a shot.

If I have a polygon with n points each with a coordinate (e.g. longitude, latitude) and I have a point (x) on a map, how can I prove that x is either contained inside of the polygon or not?

If it's not too horribly obvious, my math skills are terrible I know.

Draw a ray from the point in a direction of the polygon and count how many times the line intersects the polygon. If its odd then point is inside, if the number of intersections is even then its outside. If you don't encounter any intersection at all, then its outside, obviously.

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