Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

06-14-2011 , 12:26 PM
Quote:
Originally Posted by tyler_cracker
fyp.
Well corrected.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2011 , 12:56 PM
Masters of CS at Northeastern University in Boston. I'm halfway there, but it's part time. So it will still be a while before I finish.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2011 , 01:27 PM
Kind of a noob question, but I'm pretty stumped here although it is probably simple.

I am trying to combine certain lines of xml files I have into one ordered document, and trying to search through the file with regular expressions.
Lines I'm searching for look like this or similar:
000101101000101101 -> 000101101110101101
However, I'm always looking for the second binary string as a given, and just want to also find the first string. I store the second string I'm looking for in a string, so something like:
string='000101101000101101 -> 000101101110101101'
want='001001101110101101'

What I then try to do is re.search(r'([01]+).->.'(want), string) but that isn't working. The problem here is that I want to search for that specific binary string that I would like to store in the variable, ánd that I want to store both strings in a tuple group so I can call them later for other stuff.

Any idea how I can fix this?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2011 , 04:33 PM
Quote:
Originally Posted by Ankimo
I'm doing an architecture proposal for a scalable, highly available webapp. Does anyone have recommendations for caching? I know of memcached which can help alleviate db load by caching objects/query results. It's been around awhile and iirc is pretty stable and proven.

Just curious of there's anything newer and better for that type of thing.
I should note I use memcached and Zend Optimizer for most of my caching/accelerating needs, not APC. I plan on using a key-value DB for data warehousing in the near future but haven't really had the need to do so. (Likely to be SimpleDB or MongoDB)

Note to others: memcached is not likely to be available on shared web hosting due to the ridiculous security vuln this would create.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2011 , 07:45 PM
no experience with memcached but i'm reading coders at work right now and brad fitzpatrick is one of the chapters (guy who wrote memcached and started livejournal). i enjoyed this:

Quote:
Seibel: So all the pieces of infrastructure you built, like memcached and Perlbal, were written in response to the actual scaling needs of LiveJournal?

Fitzpatrick: Oh, yeah. Everything we built was because the site was falling over and we were working all night to build a new infrastructure thing. We bought one NetApp ever. We asked, "How much does it cost?" and they're like, "Tell us about your business model." "We have paid accounts." "How may customers do you have? What do you charge?" You just see them multiplying. "The price is: all the disposable income you have without going broke." We're like, "**** you." But we needed it, so we bought one. We weren't too impressed with the I/O on it and it was way too expensive and there was still a single point of failure. They were trying to sell us a configuration that would be high availability and we were like, "**** it. We're not buying any more of these things."
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2011 , 08:05 PM
Yeah, Brad is awesome. I started using LJ in like... 2000? Still check my friends list there from time to time, actually.

Smart guy. I moved up here to Seattle after he got out of the business. Too bad. Seems like a real genius.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-14-2011 , 09:20 PM
Quote:
Originally Posted by Neil S
It's back to VAX/VMS for everyone.
No ****ing way. I'd rather do JCL again...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2011 , 06:44 PM
Quote:
Originally Posted by Slick Strawberry
Kind of a noob question, but I'm pretty stumped here although it is probably simple.

I am trying to combine certain lines of xml files I have into one ordered document, and trying to search through the file with regular expressions.
Lines I'm searching for look like this or similar:
000101101000101101 -> 000101101110101101
However, I'm always looking for the second binary string as a given, and just want to also find the first string. I store the second string I'm looking for in a string, so something like:
string='000101101000101101 -> 000101101110101101'
want='001001101110101101'

What I then try to do is re.search(r'([01]+).->.'(want), string) but that isn't working. The problem here is that I want to search for that specific binary string that I would like to store in the variable, ánd that I want to store both strings in a tuple group so I can call them later for other stuff.

Any idea how I can fix this?
If you have XML files, why not use an XML parser and go for the specific elements you want? It'll be much easier/saner to extract than with Regex
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2011 , 09:55 PM
it's official: I hate Python.

Code:
x = 1
y = 5
z = 7
print x,y,z
if x < y:
	if x < z: print 'x is least'
elif y < z: print 'y is least'
else: print 'z is least'
does not equal:

Code:
x = 1
y = 5
z = 7
print x,y,z
if x < y:
	if x < z: print 'x is least'
	elif y < z: print 'y is least'
else: print 'z is least'
and that makes me sad.

I understand why they aren't the same, but so much of my time is spent on learning how to indent, breaking code because of indentation, worrying about whether or not I indented correctly, and so much garbage about indent indent indent. Thanks to Python, I now hate the word 'indent.'

Okay, aside from the indents, there are some pretty cool features to Python, but yuck, I can't wait to see some brackets again.

----------------------

On a more serious note:

There was one part of the lecture where the professor is talking about floating point numbers and he did this example directly into the Python Shell:

Code:
>>> x = 0.1
>>> print x
0.1
>>> x
0.1
>>>
his answer came out: 0.1000000000000001.

The implications of this is beyond my head (there is something magical about the number 17 here), but I find this sort of valuable to know about if you are really into this side of things. Regardless, this only means something changed, and I don't know why. Is this new thing universal to all programming languages or only Python?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2011 , 10:04 PM
dave,

just curious: what is the difference between indenting and braces? they are visually very similar, it seems completely cosmetic to me...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2011 , 10:05 PM
Computers don't do floating point math well.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2011 , 10:18 PM
I really don't get the indent complaint. I mean... they're different and they even look different.

As for the floating point number - it just has to do with how floating point numbers are represented and is common to many languages. Here's one reference: http://docs.python.org/tutorial/floatingpoint.html
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-15-2011 , 11:07 PM
It was covered in the python thread and basically comes down to either 1: configure your ****ing editor correctly, or b: real programmers don't need no syntactic sugar coating.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-16-2011 , 12:10 AM
Quote:
Originally Posted by daveT
Code:
x = 1
y = 5
z = 7
print x,y,z
if x < y:
	if x < z: print 'x is least'
elif y < z: print 'y is least'
else: print 'z is least'
does not equal:

Code:
x = 1
y = 5
z = 7
print x,y,z
if x < y:
	if x < z: print 'x is least'
	elif y < z: print 'y is least'
else: print 'z is least'
This would be a lot clearer if you put the statements on a new line instead of with the if clause.

[PHP]x = 1
y = 5
z = 7
print x,y,z
if x < y:
if x < z:
print 'x is least'
elif y < z:
print 'y is least'
else: print 'z is least'[/PHP]

But really, this is just one of those things you have to learn and understand. It is similar to people that get frustrated by:
[php]
if (x < y)
doX();
doY();
//vs
if (x < y) {
doX();
doY();
}[/php]

Python is not the only language where you can do funky things with indentation and expect them to work differently than they do.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-16-2011 , 12:14 AM
you should be properly indenting anyway so this complaint is moot. unless of course you prefer braces because you like to code like this:

Code:
x = 1
y = 5
z = 7
print x,y,z
if x < y: {
if x < z: { print 'x is least' }
elif y < z: { print 'y is least' } }
else: { print 'z is least' }
what time you spend "learning" indentation is easily recouped the first time you go back to old code that you wrote and you comprehend it on sight instead of having to squint at the above codeblock and wonder WTF. and this is coming from someone who can be quite sloppy when he codes
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-16-2011 , 01:12 AM
Yeah, I know, it was a stupid complaint. I hate having every single thing I suck at exposed, which this course does a pretty good job at. Rather than say "I have no ability to logic...."

I see now why people say stuff like: "I wouldn't want to use some hacker guy that's been programming since he was 9 with zero education vs a college student who never seen a computer before going into programming."

That sentence is terrible, but you get the point I hope.

But, yes, Greg Nice, I'm not that bad, though I never considered indentation vital until a few days ago (thanks to braces and my pitiful javaScript).

Embarrassed to say that I am using pencil and paper as much as using the computer to learn this stuff.

IrishThug: do people really get frustrated by that?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-16-2011 , 01:25 AM
i felt a pang of ren-style anger ("you eeeeeeediot") just reading irishthug's example, so my answer is yes.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-16-2011 , 05:19 AM
Is it clear to you yet that the best way to learn programming was probably not to dive into the PL/SQL reference manual?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-16-2011 , 05:47 AM
lol
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-16-2011 , 08:00 AM
Quote:
Originally Posted by daveT
IrishThug: do people really get frustrated by that?
It's more that it is a case of common bug that can easily come up when people are not careful. Like if you come back to edit a file and you need to do two things when something is true. So you click at the end of the line and hit enter. The editor indents for you and you add "doY();". Quick and easy fix!

The last company I worked with actually had a rule in their code style to always use curly brackets to prevent just what I described.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-16-2011 , 10:07 AM
I have a rule myself that if I use braces with one side of an if/then, I always use them on the other side. Safety first.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-16-2011 , 01:57 PM
Quote:
Originally Posted by TheIrishThug
The last company I worked with actually had a rule in their code style to always use curly brackets to prevent just what I described.
I always do this myself, good idea imo.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-16-2011 , 02:14 PM
Yeah, I've been doing that myself since working there. I just wanted to point out that the company mandated it to show daveT that it was a bigger issue than some would think.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-16-2011 , 07:17 PM
I've had a (personal) mandatory braces rule for years. The only time I break it is if I'm doing a single line thing, where it's going to be obvious when I come back later to change it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-16-2011 , 10:30 PM
RFC about the ternary operator, like/dislike?

Code:
if_bool_expression ? then_do_this : else_do_this
vs

Code:
if (boolexpression)
   then_do_this
else
   else_do_this
i dislike the ternary due to code readability (lets forget nested ternaries, jeez!). i tend to prefer human readability over compactness. what say you?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m