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
Bodhi Tea
Oct 2, 2006

seconds are secular, moments are mine, self is illusion, music's divine.
I want to write a certain program that will update a website with some new information everyday.

Since my computer is not on 24/7, and I have web hosting, I was thinking of writing this in either php or python and have it run on the web server.

I really have no idea how these things work, but would I need to have the script constantly be running? Or is there a way to have it run once per-day and then terminate? Or is there some easier way to do this?

Thanks!

Adbot
ADBOT LOVES YOU

Vanadium
Jan 8, 2005

This depends on what kind of access you have to your web server. Running stuff periodically sounds like a cronjob, but if you just have webhosting, you probably cannot do that, or really do anything beyond responding to http requests.

Bodhi Tea
Oct 2, 2006

seconds are secular, moments are mine, self is illusion, music's divine.

Vanadium posted:

This depends on what kind of access you have to your web server. Running stuff periodically sounds like a cronjob, but if you just have webhosting, you probably cannot do that, or really do anything beyond responding to http requests.

I'm not 100% sure if I can do cronjobs, but there is a section in cPanel labeled cronjobs. If I were able to do that, say I wanted to run a php script foo.php, would I just set the cronjob command to "php foo.php" ?

Vanadium
Jan 8, 2005

Bodhi Tea posted:

I'm not 100% sure if I can do cronjobs, but there is a section in cPanel labeled cronjobs. If I were able to do that, say I wanted to run a php script foo.php, would I just set the cronjob command to "php foo.php" ?

Commandline php might run in a different environment if it is available at all than apache's mod_php, but it might work. :) I have no experience with cpanel, so just try it.

POKEMAN SAM
Jul 8, 2004

Bodhi Tea posted:

I'm not 100% sure if I can do cronjobs, but there is a section in cPanel labeled cronjobs. If I were able to do that, say I wanted to run a php script foo.php, would I just set the cronjob command to "php foo.php" ?

Generally yes, but I've also had success using "wget" to get the page (wget is a command line tool to download a file. You can just have it do something like "wget -o /tmp/myfiletmp http://myserver.com/myfile.php". Alternately there are ways to have it email you when it fails, but I forget the specifics.

Bodhi Tea
Oct 2, 2006

seconds are secular, moments are mine, self is illusion, music's divine.

Ugg boots posted:

Generally yes, but I've also had success using "wget" to get the page (wget is a command line tool to download a file. You can just have it do something like "wget -o /tmp/myfiletmp http://myserver.com/myfile.php". Alternately there are ways to have it email you when it fails, but I forget the specifics.

Thanks both of you, the wget solution seems to work.

N.Z.'s Champion
Jun 8, 2003

Yam Slacker
This is probably a moronic question but there's someone I know who wants to migrate a REALBASIC project to something more modern (because they're having problems finding developers, libraries, community). Rather than starting from scratch I guess they should modularise their code as a library, perhaps exposing interfaces in COM or .Net?

It's just that I can't find any way out of realbasic, or any way to compile to something else. I'm hesitant to recommend a rewrite but what would you suggest?

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

N.Z.'s Champion posted:

This is probably a moronic question but there's someone I know who wants to migrate a REALBASIC project to something more modern (because they're having problems finding developers, libraries, community). Rather than starting from scratch I guess they should modularise their code as a library, perhaps exposing interfaces in COM or .Net?

Trying to expose interfaces through COM directly will be more of a headache than just porting the whole thing, unless it was designed that way from the start.

If Realbasic can target .NET, modularising to expose .NET interfaces and then do new development in Visual Basic is probably the way to go. Otherwise, I think you'll have to bite the bullet and port the whole thing to Visual Basic.

baquerd
Jul 2, 2007

by FactsAreUseless
So I'm using sybase and perl together, and I fork the perl process. The child process does its thing, and then I have it exit.

When the child process dies, I get the below errors from the parent process the next time it tries to call a function with a sybase statement in it.

Why the hell would the child process exiting invalidate a sybase statement? I've tried both prepare and prepare_cached methods.

edit: I figured it out: http://www.perlmonks.org/?node_id=594175

baquerd fucked around with this message at 10:49 on Nov 14, 2008

ndb
Aug 25, 2005

In Haskell, let's say I have a list of coordinate pairs, and am interested in deleting anything that has a first of 4, while I don't care what the second value is.

Is there anyway I can use the delete function for this, or do I have to write my own recursive function?

Vanadium
Jan 8, 2005

Clock Explosion posted:

In Haskell, let's say I have a list of coordinate pairs, and am interested in deleting anything that has a first of 4, while I don't care what the second value is.

You will probably want to use filter, as in filter ((/=) 4 . fst) yourList.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Vanadium posted:

You will probably want to use filter, as in filter ((/=) 4 . fst) yourList.

Haskell lets you write (/= 4), and it does what you think.

Vanadium
Jan 8, 2005

rjmccall posted:

Haskell lets you write (/= 4), and it does what you think.

How is ((/= 4) . fst) better than ((/=) 4 . fst)?

ndb
Aug 25, 2005

Vanadium posted:

You will probably want to use filter, as in filter ((/=) 4 . fst) yourList.

Bah! That's a good idea. Thanks!

SirPablo
May 1, 2004

Pillbug
I wish I would use this place more often, lots of knowledge here.

I'm working on a Google Maps app. I have an event listener for a click on the map. The click passes the latlng to a javascript function. I'd like the javascript function to then pass the latlng to a seperate php script (external file). The php script takes the latlng, queries a DB and gets some XML data back, does some formatting, then generates a HTML string. The php script would then pass back the HTML string, which could be opened in the Google Map in an infoWindow. I'm getting hung up on how do I go from javascript->php->javascript.

code:
function getXml(lat,lon) {
	// Send lat/lon to a PHP script to get the forecast data. Dump HTML back here, then to map.
	var html = wantToGetThisStringOfHtmlBack("xml.php?lat="+lat+"lon="+lon);
}

Vanadium
Jan 8, 2005

XMLHttpRequest, and some more asynchronicity than you are using right now?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Vanadium posted:

How is ((/= 4) . fst) better than ((/=) 4 . fst)?

Well, the grouping is more obvious, but you're right, it doesn't make a difference in this case.

chocojosh
Jun 9, 2007

D00D.
Does anyone have an easy way to implement web services in Java? I've done them in C# with Visual Studio 2003 at a previous job and it was fairly easy overall (create web service project, setup the service, setup client to call the webservice).

Our professor said to use this: http://java.sun.com/webservices/docs/2.0/tutorial/doc/index.html I spent several hours attempting to get hello world to work using glassfish but had no idea where the magical build.xml file comes from and I just couldn't get asant create-war to work.

I have many more important projects to do right now for school so I won't have time to do anything too complicated but if there's a straight forward solution I'd rather try that before giving up.

ndb
Aug 25, 2005

Is there a decent way to debug a Haskell through a program like gdb or something of that sorts, or am I forced to do it pen and paper?

I have a function that keeps returning an empty list, and I don't know why. :(

It's times like this that makes me wish I was using Visual Studio...or even Eclipse for that matter.

EDIT: While my question still stands, I just wanted to inform the Cavern that I am an idiot who should remember to make sure that he doesn't call a function by a state where it only gives you an empty list.

ndb fucked around with this message at 10:01 on Nov 17, 2008

10011
Jul 22, 2007
You can use GHCi for debugging, which would be simpler than trying to coax gdb into it. I don't know about Hugs or whatever, though.

hey mom its 420
May 12, 2007

Debugging Haskell kind of really goes against the grain of strongly typed functional programming. Haskell programs are pure and have no concept of state. They're an equation instead of a series of steps. So if your function typechecks but is still giving you wrong results, try thinking and reasoning about your function a bit more. If that doesn't work, go into GHCI and try to transform some input into your desired output and then see what you did along the way.

Bishop01
Apr 27, 2007

Has you seen my bucket?!
Where could I find decent free 3rd part information on learning how run windows scripts ala running remote executables and running remote install scripts for software

Bishop01 fucked around with this message at 01:30 on Nov 19, 2008

The Remote Viewer
Jul 9, 2001
Can someone give me a common sense explanation, or link to one, explaining the difference between local and global variables? I think I've got the gist of it almost, but it still seems confusing in practice somehow.

chocojosh
Jun 9, 2007

D00D.

The Remote Viewer posted:

Can someone give me a common sense explanation, or link to one, explaining the difference between local and global variables? I think I've got the gist of it almost, but it still seems confusing in practice somehow.

What language? For most common languages all variables belong in a scope. This scope defines where the variable can be used. Global variables have global scope, which means ANYBODY in the program can modify them (this can be very dangerous!). Local variables means that the scope is limited to the local block (usually we talk about function scope for a particular function) and once you've exited the block/function, that variable no longer exists.

The Remote Viewer
Jul 9, 2001

chocojosh posted:

What language? For most common languages all variables belong in a scope. This scope defines where the variable can be used. Global variables have global scope, which means ANYBODY in the program can modify them (this can be very dangerous!). Local variables means that the scope is limited to the local block (usually we talk about function scope for a particular function) and once you've exited the block/function, that variable no longer exists.

Python. I think what might be confusing me is the example:

code:
#!/usr/bin/python
# Filename: func_local.py

def func(x):
	print 'x is', x
	x = 2
	print 'Changed local x to', x

x = 50
func(x)
print 'x is still', x
which prints:
code:
x is 50
Changed local x to 2
x is still 50
The example is confusing enough that I'm having trouble extracting exactly what point I'm supposed to get out of it. What if we assigned a value to x before the function, would it change from 50 to 2 (when the function is called) and then back to 50, or does the local variable exist independently when func(x) is being called?

csammis
Aug 26, 2003

Mental Institution

The Remote Viewer posted:

The example is confusing enough that I'm having trouble extracting exactly what point I'm supposed to get out of it. What if we assigned a value to x before the function, would it change from 50 to 2 (when the function is called) and then back to 50, or does the local variable exist independently when func(x) is being called?

It exists independently. The point you're supposed to get is that the x in func is not the same x as in the code calling func. The lesson is that all names are local to the scope in which they're defined.


edit: This is called passing by value, by the way - the parameters passed to a function are copied, and local changes to them don't persist. Passing by reference causes the actual object to be passed to the function instead of a copy, and any local changes to them persist after the function call.

csammis fucked around with this message at 02:05 on Nov 19, 2008

POKEMAN SAM
Jul 8, 2004

The Remote Viewer posted:


The example is confusing enough that I'm having trouble extracting exactly what point I'm supposed to get out of it. What if we assigned a value to x before the function, would it change from 50 to 2 (when the function is called) and then back to 50, or does the local variable exist independently when func(x) is being called?

Ah, in this example you're creating a new x variable for your function that is not related to the outside environment. Since you're creating a new x, when you're in that function, talking about x is talking about the local one (the argument.)

See if you understand this example:

code:
#!/usr/bin/python
# Filename: func_local.py

def func(y):
        print 'y is', y
        y = 2
        print 'Changed local y to', y

x = 50
func(x)
print 'x is still', x
which prints:
code:
x is 50
Changed local y to 2
x is still 50
efb

chocojosh
Jun 9, 2007

D00D.

The Remote Viewer posted:

Python. I think what might be confusing me is the example:

code:
#!/usr/bin/python
# Filename: func_local.py

def func(x):
	print 'x is', x
	x = 2
	print 'Changed local x to', x

x = 50
func(x)
print 'x is still', x
which prints:
code:
x is 50
Changed local x to 2
x is still 50
The example is confusing enough that I'm having trouble extracting exactly what point I'm supposed to get out of it. What if we assigned a value to x before the function, would it change from 50 to 2 (when the function is called) and then back to 50, or does the local variable exist independently when func(x) is being called?

One suggestion may be to try what you want to see. "What if we assigned a value to x before the function" -- try it!

The thing here is you have a global x (x = 50), which is outside the function call. The function func accepts a parameter, which is also called x. This parameter ("local variable") exists independently of the global x. You may find it easier to understand if you change func as follows:


def func(y):
print 'y is', y
y = 2
print 'Changed local y to', y

Edit: beaten.

The Remote Viewer
Jul 9, 2001

csammis posted:

It exists independently. The point you're supposed to get is that the x in func is not the same x as in the code calling func. The lesson is that all names are local to the scope in which they're defined.

So basically it exists in a vacuum whenever the function is called, and then goes poof afterwards? That's what I had assumed, I might be just be assuming things are more complicated than they are.

Another thing that's confusing me from the same page: In the example I posted, the function is func(x). In the next example, which is exactly the same except x is defined as global, it's just func().

Is this a significant difference? Why does it have a parameter of x in the first example?

csammis
Aug 26, 2003

Mental Institution

The Remote Viewer posted:

Another thing that's confusing me from the same page: In the example I posted, the function is func(x). In the next example, which is exactly the same except x is defined as global, it's just func().

Is this a significant difference? Why does it have a parameter of x in the first example?

The lesson is all about variable scope and naming, right? Presumably it's to show that things happen differently when you pass a variable to a method rather than leave a variable at the global scope and have a method operate on it.

The Remote Viewer
Jul 9, 2001

csammis posted:

The lesson is all about variable scope and naming, right? Presumably it's to show that things happen differently when you pass a variable to a method rather than leave a variable at the global scope and have a method operate on it.

Yes, I'm not sure what a method is, though.

Let me reproduce the second example so we're all on the same page.

code:
#!/usr/bin/python
# Filename: func_global.py

def func():
	global x

	print 'x is', x
	x = 2
	print 'Changed global x to', x

x = 50
func()
print 'Value of x is', x
Which outputs 50, 2, 2. The important thing from the example seems to be that the behavior changes when you define a variable as global within a function, but otherwise I don't see the difference between func(x) in the first example and func() in the second example.

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.
func() changes a specific x that any other function can use. func(x) changes a copy of whatever variable you pass to it. "Method" is a synonymn for "function."

Avenging Dentist
Oct 1, 2005

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

Bishop01 posted:

Where could I find decent free 3rd part information on learning how run windows scripts ala running remote executables and running remote install scripts for software

What does this even mean???

rugbert
Mar 26, 2003
yea, fuck you
how would I make an input box in vbscript that accepts multiple lines? like a comment box, but im passing the comment into some variable.

baquerd
Jul 2, 2007

by FactsAreUseless

rugbert posted:

how would I make an input box in vbscript that accepts multiple lines? like a comment box, but im passing the comment into some variable.

<textarea>? I haven't used vbscript, but I'm pretty sure that's the HTML tag..

Turkmenbashi
Apr 25, 2008

:I
dumb MATLAB Q: I'm trying create a set of vectors which includes every possible combination of 1 and 0 in the n elements of the vector.
My first idea is making the set, putting 1 in the first element for the first half of the vectors, then putting 1 in the second element for the first quarter and 3rd quarter of the vectors, and so on.
So, for n = 3, I'd get these 8 vectors in this order:
code:
 1 1 1
 1 1 0
 1 0 1
 1 0 0
 0 1 1
 0 1 0
 0 0 1
 0 0 0
This doesn't seem very efficient at all, so I was wondering if anyone knew of a better way?

Vanadium
Jan 8, 2005

Turkmenbashi posted:

dumb MATLAB Q: I'm trying create a set of vectors which includes every possible combination of 1 and 0 in the n elements of the vector.
Would you not just count up to 2^n, and then set the elements of the current vector to 1 that correspond to the bits that are set in the counter?

I have no clue about MATLAB so this might very well be a stupid idea.

rugbert
Mar 26, 2003
yea, fuck you

quadreb posted:

<textarea>? I haven't used vbscript, but I'm pretty sure that's the HTML tag..

yea it is, I need it in just VBS. I have a script that spoofs email in my domain:
code:
senderName = InputBox("Address to Spoof:", "Spoof!")

victimName = InputBox("Victim's Name:", "Victim")

subjectField = InputBox("Enter Subject:", "Subject")

bodyField = InputBox("Enter Body Text", "Body")

Set objEmail = CreateObject("CDO.Message")

objEmail.Configuration.Fields.Item( "http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

objEmail.Configuration.Fields.Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailhost.x.x"

objEmail.Configuration.Fields.Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 

objEmail.Configuration.Fields.Update

objEmail.From = senderName

objEmail.To = victimName

objEmail.Subject = subjectField

objEmail.Textbody = bodyField
objEmail.Send

Set objEmail = nothing
I want to be able to write a paragraph's worth of text for the body, but inputbox only accepts one line

rugbert fucked around with this message at 18:50 on Nov 20, 2008

graffin
Sep 28, 2002
I am starting my first software development job in about a month and a half, and I want to get a good understanding of the software development life cycle. Are there any good books on this subject?

Adbot
ADBOT LOVES YOU

Turkmenbashi
Apr 25, 2008

:I

Vanadium posted:

Would you not just count up to 2^n, and then set the elements of the current vector to 1 that correspond to the bits that are set in the counter?

I have no clue about MATLAB so this might very well be a stupid idea.

No, I should be able to implement that. Thanks!

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