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
Fullets
Feb 5, 2009

csammis posted:

In your language of choice that supports regular expressions: String.Replace("<.+?>", "") will strip out anything between angle brackets.
<![CDATA[ You might want to keep stuff between some angle brackets ]]>

Adbot
ADBOT LOVES YOU

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Fullets posted:

<![CDATA[ You might want to keep stuff between some angle brackets ]]>

Please, if he was doing stuff that involved this he wouldn't be asking such a shallow question and getting shallow answers. Obviously the ideal is something that parses HTML.

gwar3k1
Jan 10, 2005

Someday soon
Cross post from the Windows software thread as I think it may be more appropriate here. This is a general question and any pointers to sites with relevant guides would be appreciated.

Is it possible to have Vista / W7 sidebar gadgets show Excel sheets? I keep track of birthdays in a workbook and have a macro update a sheet to show me birthdays for today, this month and next month.

If not show Excel, what would be a good storage format for this type of project? XML? I wrote a gadget for displaying F@H text files when Vista was still new. Do gadgets still use the same structure and scripting? I'm trying to find a lazy solution but one that will keep me informed with mininal interaction (other than adding contacts).

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



gwar3k1 posted:

Is it possible to have Vista / W7 sidebar gadgets show Excel sheets? I keep track of birthdays in a workbook and have a macro update a sheet to show me birthdays for today, this month and next month.

If not show Excel, what would be a good storage format for this type of project? XML? I wrote a gadget for displaying F@H text files when Vista was still new. Do gadgets still use the same structure and scripting? I'm trying to find a lazy solution but one that will keep me informed with mininal interaction (other than adding contacts).

Sure, if you want to find or write some code to do Excel interop from an ActiveX object. It'd probably be easier to export the spreadsheet to a CSV file and parse it in javascript.

line.split(',') is a whole fuckton easier, Id wager.

gwar3k1
Jan 10, 2005

Someday soon

Munkeymon posted:

Sure, if you want to find or write some code to do Excel interop from an ActiveX object. It'd probably be easier to export the spreadsheet to a CSV file and parse it in javascript.

line.split(',') is a whole fuckton easier, Id wager.

That'll do me fine. Thanks, I don't think things through like that. Excel to update contacts, save as a csv. Use javascript for the gadget. Simple, thanks.

jupo
Jun 12, 2007

Time flies like an arrow, fruit flies like a banana.

Munkeymon posted:

I disagree (depending on the version of ASP).

Using an Access database is pretty much the only red flag in his post, but it's a big loving flag - unless the site is guaranteed to be tiny and then it's just a normal-sized red flag.

Yeah couldn't agree more. Both Classic ASP and PHP each have their strengths and weaknesses but are both relatively horrendous when you compare them to modern languages.

Back in the day it wouldn't be unheard of to find yourself in a situation where for whatever reasons a client simply needed work done with Access, for example an existing investment in Windows hosting without the desire to invest in MSSQL.

You could actually really push ADO/Access a lot further than people would have you believe, check out some of the stuff here: http://www.learnasp.com/advice/whygetrows.asp

Not an Anthem
Apr 28, 2003

I'm a fucking pain machine and if you even touch my fucking car I WILL FUCKING DESTROY YOU.
I'm in a basic mathematical computer science course and finishing up a project on sorting (bubble sort, better bubble, quick sort). We were given pseudocode that would work perfectly when translated, however it doesn't seem to. We're supposed to keep the sort algorithms in a seperate module and call them from the first module's main function.

http://www.chicagoburning.com/mp4/sort.py

Can anyone tell me what I'm doing wrong? Its not sorting the list I have set up to test it in the main function.

The other files in the directory are the main program and the explanation. I'm almost positive the main program works 100% and my hiccup is just the sorting.

Meganiuma
Aug 26, 2003

Not an Anthem posted:

I'm in a basic mathematical computer science course and finishing up a project on sorting (bubble sort, better bubble, quick sort). We were given pseudocode that would work perfectly when translated, however it doesn't seem to. We're supposed to keep the sort algorithms in a seperate module and call them from the first module's main function.

http://www.chicagoburning.com/mp4/sort.py

Can anyone tell me what I'm doing wrong? Its not sorting the list I have set up to test it in the main function.

The other files in the directory are the main program and the explanation. I'm almost positive the main program works 100% and my hiccup is just the sorting.

range() assumes a default stepping of 1, to get it to create a decrementing list you need to explicitly set it to a stepping of -1. Your range(n, 1) should read range(n, 1, -1).

Also,
code:
				x[i]=x[i+1]
				x[i+1]=x[i]
Is probably not what you intended.

Not an Anthem
Apr 28, 2003

I'm a fucking pain machine and if you even touch my fucking car I WILL FUCKING DESTROY YOU.
Fixed first with reversed(range(1,n)) and fixed second part wheee god why can I not see the tiny glaring errors when I check code

I think, it works perfectly now.

Not an Anthem fucked around with this message at 13:27 on May 8, 2009

Not an Anthem
Apr 28, 2003

I'm a fucking pain machine and if you even touch my fucking car I WILL FUCKING DESTROY YOU.
New issue:

RuntimeError: maximum recursion depth exceeded

I understand I have to increase the stack size via googling, but someone just suggested bumping sys.setrecursionlimit to 1500 instead of 1000. I don't want to just set it to 20000 or something because apparently it can really crash. What can I set it to?

I'm sorting 20 test arrays starting at size 500 and incrementing up by 500 each time (we're graphing and showing big O and all that jazz).

Oh, and this is quicksort, so its really recursive for these guys :/

edit: drat I got like halfway there with setrecusionlimit to 5000 (ubuntu 8.1)

Not an Anthem fucked around with this message at 14:15 on May 8, 2009

baquerd
Jul 2, 2007

by FactsAreUseless

Not an Anthem posted:

New issue:

RuntimeError: maximum recursion depth exceeded

I understand I have to increase the stack size via googling, but someone just suggested bumping sys.setrecursionlimit to 1500 instead of 1000. I don't want to just set it to 20000 or something because apparently it can really crash. What can I set it to?

If you hit a recursion depth of 1000 with quicksort on an array that fits in your computer's memory, you have a problem.

Edit: OK, worst case scenario that's not true, I forgot it could go to O(n) worst case... Just implement it iteratively.

baquerd fucked around with this message at 14:12 on May 8, 2009

tef
May 30, 2004

-> some l-system crap ->
You can transform it into an iterative form with an explict stack:

code:
def quicksort(x):
   stack = [(0, len(x))]

   while stack:
       low, high = stack.pop() # take arguments from stack

       ....


       stack.push((nextl,nexth)) # push here is like the recursive call.
       stack.push((lowa, higha))

   return x

Not an Anthem
Apr 28, 2003

I'm a fucking pain machine and if you even touch my fucking car I WILL FUCKING DESTROY YOU.
tef and quadreb, this is my first python class and I don't know exactly what that means.. can you explain further?

Not an Anthem
Apr 28, 2003

I'm a fucking pain machine and if you even touch my fucking car I WILL FUCKING DESTROY YOU.
code:
def quicksort(x):
   stack = [(0, len(x))]

   while stack:
      low, high = stack.pop() # take arguments from stack
      if low >= high:
         return
      m = low
      for i in range (low+1, high+1):
         if x[i] < x[low]:
            m+=1
            t=i
            i=m
            m=t
      t=m
      m=low
      low=t
      #quick_sort(x,low,m-1)  <-- ***these get replaced with two below?***
      #quick_sort(x,m+1,high)

      stack.push((nextl,nexth)) # push here is like the recursive call.
      stack.push((lowa, higha))

   return x
Like so? Do I replace the arguments from recursive call directly ie stack.push(low,m-1) and stack.push(lowa,higha) ?

baquerd
Jul 2, 2007

by FactsAreUseless

Not an Anthem posted:

Like so? Do I replace the arguments from recursive call directly ie stack.push(low,m-1) and stack.push(lowa,higha) ?

Half of learning how to program is throwing out something you think might work and then figuring out why it didn't. Does python have a step debugger available? Those can be really useful in figuring out what's happening.

tef
May 30, 2004

-> some l-system crap ->
We can transform your first function into one that does not call itself:

It takes a low, high pair, and returns a list of new pairs that need to be sorted.

code:
def partial_quicksort(x,low,high):
	if low >= high:
		return [] # no new pairs to sort
	m = low
	for i in range (low+1, high+1):
		if x[i] < x[low]:
			m+=1
			t=i
			i=m
			m=t
	t=m
	m=low
	low=t[
	return [ (low,m-1), (m+1,high)]
If we call this function, it returns two pairs of values, that indicate the range that needs to be sorted next.

We could then do

code:
def quicksort(x,low,high): 
    ranges_to_sort = [ (low, high) ]
 
    while ranges_to_sort:  
       low_, high_ = ranges_to_sort.pop() # remove the last pair, and store it as low_, high_
       new_ranges = partial_quicksort(x, low_, high_)
       ranges_to_sort.extend(new_ranges) # add the new pairs


    return x

tef
May 30, 2004

-> some l-system crap ->
This also means you can test quicksort partial to see if it is partitioning the lists.

edit: because I haven't tested anything.

Not an Anthem
Apr 28, 2003

I'm a fucking pain machine and if you even touch my fucking car I WILL FUCKING DESTROY YOU.
Our teach said to just find help online if we get stack size problems, we didn't learn any of this stuff aghhh. Thank you for explaining what is going on, I'm going to see if this works

edit- it seems like its working! thank you. testing it as well..

Not an Anthem fucked around with this message at 14:39 on May 8, 2009

Not an Anthem
Apr 28, 2003

I'm a fucking pain machine and if you even touch my fucking car I WILL FUCKING DESTROY YOU.
Hah. Right, simple idiot problem again, was swapping m++,i instead of x[m]++,x[i] and low,m instead of x[low],x[m]

Not an Anthem fucked around with this message at 15:01 on May 8, 2009

mlnhd
Jun 4, 2002

quadreb posted:

Does python have a step debugger available? Those can be really useful in figuring out what's happening.
I want to know this too. Basically my dream program is a python debugger that is as good as Visual Studio's.

hlfrk414
Dec 31, 2008
Python debugging isn't terribly hard. IDLE has a debugger, just look at the Debug menu in the shell and then right click on source to set breakpoints. Pydev takes advantage of Eclipse's debug interface as well. It's not hard to debug the way you want, without having to use a massive IDE like VS.

tripwire
Nov 19, 2004

        ghost flow

Melonhead posted:

I want to know this too. Basically my dream program is a python debugger that is as good as Visual Studio's.

:psyduck:
I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a statement.

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog

tripwire posted:

:psyduck:
I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a statement.

Visual Studio owns.

POKEMAN SAM
Jul 8, 2004

Free Bees posted:

Visual Studio owns.

Sointenly
Sep 7, 2008
Hey everyone... Hoping someone can help with some Oracle syntax that I am stumped on.

I need to do an update statement to an Inventory table, but it will require subtracting values from two different tables, Is that possible?

The two tables:

--Invoice--
Invoice_Number
Product_ID
Quantity_Ordered
Warehouse_ID

and

--Inventory--
Warehouse_ID
Product_ID
Invtory_Quantity



What i need to do is subtract the "quantity ordered" in the invoice table from the "Inventory_Quantity" in the Inventory table and have that result be updated as the new "Inventory Quantity"

so basically for example you had 20 units at the warehouse, someone orders 5 units, so you need the Warehouse inventory to be updated to 15.


is it even possible to do a calculation in the update statement?
I would REALLY appreciate any help you guys could offer.

Sointenly fucked around with this message at 05:46 on May 9, 2009

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Free Bees posted:

Visual Studio owns.
Pretty much this. It took me about half an hour to get as proficient with the VS debugger as I was with gdb after like a month.

tripwire
Nov 19, 2004

        ghost flow
Python is interpreted and comes with an interactive shell. On top of this it includes a debugger which has worked fine for me. What functionality are you missing from it that you can get in visual studio?

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

I don't think they're talking about functionality so much as the intuitiveness of VS' debugger. In general, debuggers that are built into IDEs are easier for the neophyte to pick up - think about setting a breakpoint in Eclipse as compared to gdb, for instance. Once you know a bit about the latter there's nothing to it, but it seems a bit more arcane than clicking a tab to the left of the line you want a break on.

tripwire posted:

Python is interpreted and comes with an interactive shell.
This seems unrelated to what they're talking about :confused:

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
It isn't totally unrelated; depending on your application, you often can do a lot of useful investigation in an interactive mode without ever needing to actually start stepping through functions.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Ah, that's a good point; I suppose instead of inspecting your data in a debugger, you could quite literally just print it out in the intepreter :) I hadn't really thought about things that way.

Chuu
Sep 11, 2004

Grimey Drawer
I only have been coding in Python for a week, but Netbeans' debugger has most of the basic functionality you want in one (i.e. step, step-in, step-out, variable viewing, breakpoints, and *I THINK* conditional breakpoints).

I was messing around with every free python IDE I could find looking for a decent debugger, and I'm pretty sure it's the best you're going to find, unless you want to tear your hair out and see if you can get Eclipse/Jython working properly (I couldn't).

hlfrk414
Dec 31, 2008
Why Eclipse/Jython? Why not just Eclipse with Python through pydev? Or just learn to use the pdb module I linked and not tie yourself to an IDE.

Chuu
Sep 11, 2004

Grimey Drawer

hlfrk414 posted:

Why Eclipse/Jython? Why not just Eclipse with Python through pydev? Or just learn to use the pdb module I linked and not tie yourself to an IDE.

Well, when starting to program my goal was "find something that works" and the links off the Python wiki led me down the Jython route. Also using the eclipse CDT framework for a couple of months really soured me to using eclipse for anything but Java in general, rational or not.

hlfrk414
Dec 31, 2008
Works easy for me. Have Eclipse and Python installed. Go to Eclipse's help/updates. Add link to pydev and install it. Point pydev settings to python. Use pydev. Since I have to do a lot of java work with eclipse, it works well for me. I've never had too many issues using or installing Eclipse plugins though.

BigRedDot
Mar 6, 2008

One other mention. If you are using the python shell at all you should really, really install ipython. They should honestly just make it the default python shell as it is so much better that the standard shell in every conceivable way (automatic debugger invocation, syntax highlighting, tab completion, command history, output cache, aliases, shell command access, doctest support, object exploration....)

bitprophet
Jul 22, 2004
Taco Defender

BigRedDot posted:

One other mention. If you are using the python shell at all you should really, really install ipython. They should honestly just make it the default python shell as it is so much better that the standard shell in every conceivable way (automatic debugger invocation, syntax highlighting, tab completion, command history, output cache, aliases, shell command access, doctest support, object exploration....)

Totally.


Click for full size

Ludicrous Gibs!
Jan 21, 2002

I'm not lost, but I don't know where I am.
Ramrod XTreme
Visual C++ gives me linker errors when I try to define inline functions in a .cpp file instead of the .h file where they're declared. According to MS' support page, this is intentional. They give several workarounds, and I'm thinking of using the first one (add "extern" keywords to all the inline function declarations).

Is this a bad idea? I'm under the impression that you should usually assume that compilers know "what's best" for code organization and optimization.

Vanadium
Jan 8, 2005

Well, the compiler cannot actually inline them if there is no definition available in the translation unit in which they are used.

Avenging Dentist
Oct 1, 2005

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

Ludicrous Gibs! posted:

Is this a bad idea? I'm under the impression that you should usually assume that compilers know "what's best" for code organization and optimization.

This may be true, but it assumes you know the semantics of the language, and in particular the compilation model in C/C++. Compilation for each translation unit occurs separately, so as Vanadium said, the full function definition is required in order to inline the function. Prepending extern will (most likely) turn off inlining of that function except inside the translation unit in which it is defined. Keep in mind that inline is a recommendation to the compiler and it is free to do whatever it pleases.

Adbot
ADBOT LOVES YOU

That Turkey Story
Mar 30, 2003

Vanadium posted:

Well, the compiler cannot actually inline them if there is no definition available in the translation unit in which they are used.

Modern compilers do link-time optimization which includes inlining.

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