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
tef
May 30, 2004

-> some l-system crap ->

furtheraway posted:

I only want the numerals between the first parenthesis and the percent sign. That group can contain from one to three numerals. How do I extract it?

code:
[0-9]*(\([0-9]*%\))

re_format(7) posted:

Obsolete (``basic'') regular expressions differ in several respects. `|'
is an ordinary character and there is no equivalent for its functional-
ity. `+' and `?' are ordinary characters, and their functionality can be
expressed using bounds (`{1,}' or `{0,1}' respectively). Also note that
`x+' in modern REs is equivalent to `xx*'. The delimiters for bounds are
`\{' and `\}', with `{' and `}' by themselves ordinary characters. The
parentheses for nested subexpressions are `\(' and `\)', with `(' and `)'
by themselves ordinary characters. `^' is an ordinary character except
at the beginning of the RE or= the beginning of a parenthesized subex-
pression, `$' is an ordinary character except at the end of the RE or=
the end of a parenthesized subexpression, and `*' is an ordinary charac-
ter if it appears at the beginning of the RE or the beginning of a paren-
thesized subexpression (after a possible leading `^'). Finally, there is
one new type of atom, a back reference: `\' followed by a non-zero deci-
mal digit d matches the same sequence of characters matched by the dth
parenthesized subexpression (numbering subexpressions by the positions of
their opening parentheses, left to right), so that (e.g.) `\([bc]\)\1'
matches `bb' or `cc' but not `bc'.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

Appa Time! posted:

code:
(define (reverse mylist)
  (if (null? mylist) mylist
      (append (reverse (rest mylist)) (list (first mylist)))))

Reverse of the empty list is the empty list.
Reverse of any list is taking the first element off, reversing the rest, and appending the first element back onto the end.

When you try to reverse an empty list:

(reverse ()), mylist is null so the return is ()

When you try to reverse one:

(reverse (1)) is:

append (reverse (rest (1))) (list (first (1)))

rest (1) is () and first (1) is 1

which is

append (reverse ()) (1)

which is

append () (1)

which is (1).

reverse (2 1) is:

append ( reverse (rest (2 1))) (list (first (2 1)))

rest (2 1) is (1) and first (2 1) is 2.

append (reverse (1)) (2)

reverse (1) is (1) from above, and (list 2) is (2)

append (1) (2)

which is (1 2).

tef
May 30, 2004

-> some l-system crap ->
Can we get The book thread sticked? This is the second or third time we've had one now and it would be nice to keep one.

Aside: I'm tempted to write a FAQ but really the only frequent question is "WHat Language should I learn?"

Edit: I'm sure I meant to post this in the other sticked thread

tef fucked around with this message at 18:06 on Mar 4, 2008

tef
May 30, 2004

-> some l-system crap ->

N.Z.'s Champion posted:

This is a bit of a weird question but what programming languages use :: (double colon) as part of their syntax and for what? Info on any language would be appreciated, particularly if the syntax has different uses. :)

http://merd.sourceforge.net/pixel/language-study/syntax-across-languages.html

tef
May 30, 2004

-> some l-system crap ->

csammis posted:

And the answer is "don't bother asking because you won't listen anyway" :smith:

"Who needs a project to learn a language when I can post a thread to ask moot questions" :smith::respek::smith:

tef fucked around with this message at 17:33 on Mar 4, 2008

tef
May 30, 2004

-> some l-system crap ->
The Practice of Programming by Kernighan and Pike is an excellent tome on style and methodology.

It's short, concise and well written. A very accessible book with broad coverage with summaries at the end of each Chapter.

http://plan9.bell-labs.com/cm/cs/tpop/


If anything you will gain most experience from reviewing your own code and others, and asking people to do the same for your code (don't forget to write more code). A book will encourage you to think in a good way, but it will take time for the new practices to become standard.


P.s. feel free the resurect the last book thread

tef
May 30, 2004

-> some l-system crap ->
You might be better off using \(\[^'\]\) over .*.

\[...\]is a character class, so \[abc\] matches a,b, or c.

\[^...\] is the negation, so \[^abc\] matches anything but a,b, or c.

tef
May 30, 2004

-> some l-system crap ->

6174 posted:

What I'm looking for is numbers that look like XXXX.YYYY (with the . and Y optional) that are not of the form XXXX.YYYYDZZZ.

This seems to work for me: /(\b(\d{1,4}(?!\.)|\d{1,4}\.\d{1,4})(?!D\d{3})\b)/

Although you may want: /(\b(\d{4}(?!\.)|\d{4}\.\d{4})(?!D\d{3})\b)/

code:
$ cat > numbertest                                              
1
1.0
1.02D1   
3D1
$ cat numbertest |  perl -p -e  'if (/(\b(\d{1,4}(?!\.)|\d{1,4}\.\d{1,4})(?!D\d{3})\b)/) {print "matched: $1 - "}else{print"fail: "}'
matched: 1 - 1
matched: 1.0 - 1.0
fail: 1.02D1
fail: 3D1
$ 

tef
May 30, 2004

-> some l-system crap ->

poofactory posted:

Hopefully someone can give me an answer. I know perl isn't the most popular language right now.

You realise that "Amount" is a string and "$Amount" is the string containing the variable $Amount ?

I would suggest continuing this over in the perl thread here

tef
May 30, 2004

-> some l-system crap ->
Chiming in with the whole "You can write bad unreadable code in any language" point.


I would recommend the shell if you were on a unix machine, as it is perfectly capable of small text processing tasks.

Do what bonus says and go and look at some examples and pick one. Really the advantages and disavantages between the choices of ruby, perl and python are trivial at best for the tasks you want.

tef
May 30, 2004

-> some l-system crap ->
Why don't you two take this outside and settle this like real programmers ?

tef
May 30, 2004

-> some l-system crap ->

nbv4 posted:

I have a form on a webpage that has like 50 checkboxes. I'm using a javascript function to validate the form. I'm trying to formulate an IF statement that returns true if there are more than one of those boxes checked.

Put an on change in each checkbox - when it is set add one to a total, and when it is unset substract one. The form is valid if the total is greater than one?

tef
May 30, 2004

-> some l-system crap ->
What you are looking for is called 'Sniping software'

tef
May 30, 2004

-> some l-system crap ->
It is a pretty similar mode of operation: Refresh until conditions are met, then execute an action.

Another thing would be to look at macros for web browsers.

tef
May 30, 2004

-> some l-system crap ->
It is an in-place O(n) shuffle when implemented correctly, so finding something faster might be a challenge.

Why are you shuffling the table?

tef
May 30, 2004

-> some l-system crap ->
You don't own the root directory, and so you can only put the file uploader in a subdirectory.

tef
May 30, 2004

-> some l-system crap ->
If you are trying to pick the toolset to learn so as to aid your course in industry, pick the buggiest, most frustrating toolkit you can find. The patience you develop will be a useful skill.

tef
May 30, 2004

-> some l-system crap ->

Atltais posted:

What's the easiest way of getting the terminal type from a remote client in a telnet session?

the TERM variable, try echo $TERM, however many terminals lie.

tef
May 30, 2004

-> some l-system crap ->

Vanadium posted:

10:44 -!- 1 - #cobol: ban *!*@synIRC-F5376B42.mibbit.com [by rocketsauce, 14847 secs ago]

Unbanned now. We should use the (eugh) unreal extentions to ban people by whois info for mibbit clients.

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 ".

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 [.]

tef
May 30, 2004

-> some l-system crap ->

Geno posted:

this is probably a stupid question but what do you guys think are better for programming: macs or PCs?

If you are writing mac software, macs.

If you are writing windows software, pcs.

Why not ask this in sh/sc as I am sure this sensible question will get a sensible answer.

Beyond that I think the answers are in the realms of personal preference.

I would suggest avoiding anything with Vista :v:

tef
May 30, 2004

-> some l-system crap ->

Scaevolus posted:

Silly tef, an open ended question is clearly a plea for personal opinions and anecdotal evidence.

So - how do you pronounce Mac OS X, do you say ecks or ten ?

Can we at least have one thread where we don't derail it into moot arguments about trivialities?

(probably not)

:smith:

tef
May 30, 2004

-> some l-system crap ->

Ugg boots posted:



:smithicide:

If the original poster still thinks this is a good question, can we move it to a thread.

tef
May 30, 2004

-> some l-system crap ->

Div posted:

to quickly and easily make nice diagrams

There is always xfig :v:

Have you thought of emailing the guy you mentioned to ask him what he uses?

tef fucked around with this message at 14:35 on Jul 16, 2008

tef
May 30, 2004

-> some l-system crap ->
Hidden surface determination ?

tef
May 30, 2004

-> some l-system crap ->
If you're using python - lxml will do xpath over html. It's pretty awesome.

tef
May 30, 2004

-> some l-system crap ->
It seems it is something that doesn't handle Cross Site Scripting Errors:

http://www.virginradio.co.uk/vip/index.html?msg=%3Cscript%3Ealert(document.cookie)%3C/script%3E&action=login&url=&username=&email=

Aside: The server is clamining to be "apache" without a version string, which does suggest it might not be apache.

Although the date on this page is http://www.virginradio.co.uk/event/333 unix epoch, so it might be on a unix system. (it says 1 am because it is midnight in gmt :3)

Also, one of the subsections is hosted on another domain which uses asp.net


Ooh, another XSS: http://www.virginradio.co.uk/about_us/for_your_site/email.html?url=--%3E%3C/script%3E%3C/textarea%3E%3Cscript%3Ealert(document.cookie)%3C!--

tef fucked around with this message at 00:53 on Aug 1, 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

tef
May 30, 2004

-> some l-system crap ->

more falafel please posted:

The XOR trick is not an optimization, it's a trick.
Unless you're optimizing for cleverness, or on a CPU with little to no instruction pipeline, don't ever do this.

I did this to annoy my tutor in CS1. He retaliated by making me explain it to the rest of the group.

The group who were told to chant "public static void main" as he had abandoned all hope of getting them to be able more than one question.

tef
May 30, 2004

-> some l-system crap ->

Scaevolus posted:

How long did it take for them to understand the binary representation of integers?

A while, or at least they were good at nodding. Suprisingly enough from first principles most of them were able to follow the explanation -- although I doubt much of it made it's way into their memory.

On the other hand, chanting "public static void main" is going to stay with me for a while.

tef
May 30, 2004

-> some l-system crap ->

outlier posted:

I'm casting about looking for a suitable cross-platform installer

Mac applications tend to come stand alone - you drag Application.app into /Applications

Installers aren't very popular.

tef
May 30, 2004

-> some l-system crap ->
On a complete aside:

If you are curious about joel atwood and jeff spolsky's latest adventure 'stackoverflow', but not enough of a rockstar to get in the beta, fear not:

Go to:

http://beta.stackoverflow.com

Change your cookies - type this into the address bar:

javascript:alert(document.cookie="soba=-9999999");

(any big negative number seems to work)

And then go back to:

http://beta.stackoverflow.com and refresh!

Volia!

tef fucked around with this message at 17:57 on Aug 29, 2008

tef
May 30, 2004

-> some l-system crap ->

JawnV6 posted:

Thank god, with this sort of crucial information I can finally ditch experts exchange.

http://beta.stackoverflow.com/questions/35185/finding-a-single-number-in-a-list#35190

quote:

Memory isn't always free, you know, so just because your time complexity is O(N) and mine is O(N*lgN) it doesn't mean that yours is better.

tef
May 30, 2004

-> some l-system crap ->

Vanadium posted:

Now if only someone would take all the cool features and put them into a useful language. :c00lbert:

Man C++ needs a seperate symbol table for functions and variables.

tef
May 30, 2004

-> some l-system crap ->

CryptoDerk posted:

Alternately, I could do this in Perl. I'm less familiar with Perl, but I can do the regexp stuff.

If you pick perl: http://search.cpan.org/dist/WWW-Mechanize/lib/WWW/Mechanize.pm

tef
May 30, 2004

-> some l-system crap ->
It depends what you're learning from. If you are constantly hitting a wall it might be that your learning technique and materials aren't suited to you, or that you are trying to learn too quickly.

Learning doesn't normally get easier - it still requires a lot of work, patience and thought in any subject - but once you have the fundamentals nailed down, you don't have to learn as much to understand things.

What I would suggest is:

Be a little more patient - if it takes you longer to understand something you may well come away with a better understanding of it.

Try different materials - look for slides, video lectures, books, exercises to learn from instead of just one source of information. You may find that learning from one is prefferable to the others.

Talk to other people - you could ask for help in this forum rather than asking for reassurance.

tef
May 30, 2004

-> some l-system crap ->
http://uk.php.net/function.parse-url

Also PHP Thread: http://forums.somethingawful.com/showthread.php?threadid=2802621

tef
May 30, 2004

-> some l-system crap ->

ZorbaTHut posted:

Here's a wacky question.

I need an algorithm for anonymous distributed reputation. Distributed reputation is tough, but I can't come up with any possible way to make it anonymous. I'm guessing it's just not possible, but I'm wondering if there's any research along those lines :) Any suggestions?

I would suggest the following things in order:
  • cry
  • restrict the problem domain some more

Does this help any - I remember this being at a codecon:

http://www.geekness.net/tools/aura/

Can't you just rely on the network layer to provide anonynimity )and what is your threat model for it anyway)?

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

ZorbaTHut posted:

World of Warcraft. Yeah, I'm a geek.

quote:

I want a system where people can rate other players up or down based on their skill.

How will you deal with cycles ?

quote:

I'm failing, and I'm not sure it's possible, but I'd feel more comfortable if I could somehow prove it was not possible.

If it's distributed, then it's public. There might be some really really smart ways around this, but you're just raising the bar for attacks.

quote:

Right now it's mostly annoying me.

Technical solutions to social problems often work out this way.

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