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
deedee megadoodoo
Sep 28, 2000
Two roads diverged in a wood, and I, I took the one to Flavortown, and that has made all the difference.


awesmoe posted:

Because 1.5 was only released near the end of 2004 and before that there was no replace all method, iirc

Even if that's the case, this is part of a new application that was written last year. And we've been on 1.5 for as long as I can remember. We just started the 1.6 upgrade process a few months ago.

Adbot
ADBOT LOVES YOU

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

awesmoe posted:

Because 1.5 was only released near the end of 2004 and before that there was no replace all method, iirc

replaceAll was in 1.4. At least according to the javadoc.

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.
What are you talking about? I love finding code that badly re-implements standard library features and is copy/pasted in three different private methods in the same already-bloated class:
code:
private void removeThing(Thing thing)
{
    int index = -1;
    for(int i = 0; i < items.size(); i++) // items is a List
    {
        if(items.get(i).equals(thing))
        {
            index = i;
            break;
        }
    }
    if(index != -1)
    {
        items.remove(index);
    }
}

awesmoe
Nov 30, 2005

Pillbug

TRex EaterofCars posted:

replaceAll was in 1.4. At least according to the javadoc.
my bad, I must have been thinking of a different function. We recently moved from 1.4 to 1.6 in the way only my company can, that is, writing different source files for both versions and swapping them in and out with retarded makefile hacks. Sigh.

Parantumaton
Jan 29, 2009


The OnLy ThInG
i LoVe MoRe
ThAn ChUgGiNg SeMeN
iS gEtTiNg PaId To Be A
sOcIaL MeDiA sHiLl
FoR mIcRoSoFt
AnD nOkIa
Java's String#replaceAll(String, String) is regex based which means there's the overhead of generating internal Pattern object for the actual regex, creating a Matcher object from the said Pattern object and then calling Matcher#replaceAll(String) to get the output. If all you need is simple replacement ("change all 'a':s to 'b':s") which is going to get used a lot in your application then rolling out your own #replaceAll() will actually result in a lot faster throughput than the Java's native regex one. Same applies especially to Pattern#split(String) too.

In reality, all the text above means that I've actually done the same thing myself and I need to justify my micro-optimizations to not fall into despair.

Avenging Dentist
Oct 1, 2005

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

Parantumaton posted:

In reality, all the text above means that I've actually done the same thing myself and I need to justify my micro-optimizations to not fall into despair.

Maybe you should try profiling your code next time, bub!

zootm
Aug 8, 2006

We used to be better friends.

Parantumaton posted:

Java's String#replaceAll(String, String) is regex based which means there's the overhead of generating internal Pattern object for the actual regex, creating a Matcher object from the said Pattern object and then calling Matcher#replaceAll(String) to get the output. If all you need is simple replacement ("change all 'a':s to 'b':s") which is going to get used a lot in your application then rolling out your own #replaceAll() will actually result in a lot faster throughput than the Java's native regex one. Same applies especially to Pattern#split(String) too.

In reality, all the text above means that I've actually done the same thing myself and I need to justify my micro-optimizations to not fall into despair.

This is all potentially well and good but just look at the code they're using - there's no way it's an optimisation.

Parantumaton
Jan 29, 2009


The OnLy ThInG
i LoVe MoRe
ThAn ChUgGiNg SeMeN
iS gEtTiNg PaId To Be A
sOcIaL MeDiA sHiLl
FoR mIcRoSoFt
AnD nOkIa

zootm posted:

This is all potentially well and good but just look at the code they're using - there's no way it's an optimisation.

Indeed, it messes around with Strings in the most non-performant ways possible. I'm guilty of similar code too so maybe I can't just go completely rampant on it right now. I do agree it's a horror though.

...actually now that I really look at it, it reminds me a lot of PHP's str_replace.

Scaevolus
Apr 16, 2007

10:33:11 < MononcQc> This has to come close to balls next to a cliff in terms of analogies: http://groups.google.com/group/comp.lang.scheme/msg/e7431893c4da4bbf?hl=en

Hi,
I understand continuations as taking a photo of what is happening, a special photo that you can use afterwards to go "to the past" where the photo was taking.
Continuations are very good on daily work, because you can take a photo (capture the *current* continuation) while you're having beers at the bar with your friends. If your daily work is boring you can always get your photo from your pocket and go instantly back to the bar with beers and friends. Great!!
Furthermore, when you take your photo (capture the *current* continuation) you pass a procedure to your camera (you *call* this procedure with the *current* continuation). The value returned by this procedure is then substituted in the very place you took your photo.
So continuations are a way to "return values from the future too" (you *call* a procedure with the *current* photo).
And this is fantastic!!
Imagine, for instance, that you're having beers with your friends at the bar. You then capture the current, comfortable, beer&friends continuation (take your photo) and say "let's capture a continuation here, and let's call a procedure that seeks what the winning lottery number is".
You then go to work, and you find in google what the winning lottery number is. You then pass this value (the value returned by the procedure) to the photo (the captured continuation). As a consequence you go immediately back to the bar... knowing what the winning lottery number is going to be!!
Now, isn't this fantasic? You just can win the lottery while being at the bar with beers and friends!! You won't have to go back to work again if you don't want to!!
In real life continuations don't exist (I wish they existed!), but while working with Scheme you can use continuations for doing some sort of things:
- Take a photo before seeking for something in a list. Pass a procedure to the photo that seeks for something in the list. (Looping).
- Iterate over all possible solutions to a problem. For each possible solution take a photo and pass it a procedure that sees if the solution is acceptable or not (backtracking).
- Perform a task. In the middle of the task take a photo and pass it a procedure that does another task (multitasking).
For examples of real-life usages of continuations you can take a look at [1], that contains "Design Patterns" explaining common situations for using continuations.
Cheers,
Antonio

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Parantumaton posted:

Java's String#replaceAll(String, String) is regex based which means there's the overhead of generating internal Pattern object for the actual regex, creating a Matcher object from the said Pattern object and then calling Matcher#replaceAll(String) to get the output. If all you need is simple replacement ("change all 'a':s to 'b':s") which is going to get used a lot in your application then rolling out your own #replaceAll() will actually result in a lot faster throughput than the Java's native regex one. Same applies especially to Pattern#split(String) too.

In reality, all the text above means that I've actually done the same thing myself and I need to justify my micro-optimizations to not fall into despair.

Apache Commons to the rescue.

http://commons.apache.org/lang/api-...va.lang.String)

mr_jim
Oct 30, 2006

OUT OF THE DARK

Scaevolus posted:

10:33:11 < MononcQc> This has to come close to balls next to a cliff in terms of analogies: http://groups.google.com/group/comp.lang.scheme/msg/e7431893c4da4bbf?hl=en

Hi,
I understand continuations as taking a photo of what is happening, a special photo that you can use afterwards to go "to the past" where the photo was taking.
Continuations are very good on daily work, because you can take a photo (capture the *current* continuation) while you're having beers at the bar with your friends. If your daily work is boring you can always get your photo from your pocket and go instantly back to the bar with beers and friends. Great!!
Furthermore, when you take your photo (capture the *current* continuation) you pass a procedure to your camera (you *call* this procedure with the *current* continuation). The value returned by this procedure is then substituted in the very place you took your photo.
So continuations are a way to "return values from the future too" (you *call* a procedure with the *current* photo).
And this is fantastic!!
Imagine, for instance, that you're having beers with your friends at the bar. You then capture the current, comfortable, beer&friends continuation (take your photo) and say "let's capture a continuation here, and let's call a procedure that seeks what the winning lottery number is".
You then go to work, and you find in google what the winning lottery number is. You then pass this value (the value returned by the procedure) to the photo (the captured continuation). As a consequence you go immediately back to the bar... knowing what the winning lottery number is going to be!!
Now, isn't this fantasic? You just can win the lottery while being at the bar with beers and friends!! You won't have to go back to work again if you don't want to!!
In real life continuations don't exist (I wish they existed!), but while working with Scheme you can use continuations for doing some sort of things:
- Take a photo before seeking for something in a list. Pass a procedure to the photo that seeks for something in the list. (Looping).
- Iterate over all possible solutions to a problem. For each possible solution take a photo and pass it a procedure that sees if the solution is acceptable or not (backtracking).
- Perform a task. In the middle of the task take a photo and pass it a procedure that does another task (multitasking).
For examples of real-life usages of continuations you can take a look at [1], that contains "Design Patterns" explaining common situations for using continuations.
Cheers,
Antonio

Time works the same way.

1337JiveTurkey
Feb 17, 2005

mr_jim posted:

Time works the same way.

So my stack is actually a cube?

JingleBells
Jan 7, 2007

Oh what fun it is to see the Harriers win away!

Edit: Ignore me, I'm an idiot

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

1337JiveTurkey posted:

So my stack is actually a cube?

-1 x -1= +1 is WRONG, it is academic stupidity and is evil. The educated stupid should acknowledge the natural antipodes of +1 x +1 = +1 and -1 x -1 = -1 exist as plus and minus values of opposite creation - depicted by opposite sexes and opposite hemispheres.

mr_jim
Oct 30, 2006

OUT OF THE DARK

Otto Skorzeny posted:

-1 x -1= +1 is WRONG, it is academic stupidity and is evil. The educated stupid should acknowledge the natural antipodes of +1 x +1 = +1 and -1 x -1 = -1 exist as plus and minus values of opposite creation - depicted by opposite sexes and opposite hemispheres.

You have opposite brains to think opposite, but Big Brother icepick academic lobotomy has destroyed your mentality to think opposite of the evil singularity you are taught.

Zombywuf
Mar 29, 2008

mr_jim posted:

You have opposite brains to think opposite, but Big Brother icepick academic lobotomy has destroyed your mentality to think opposite of the evil singularity you are taught.
This is the closest I've seen to managing to parody timecube. However it still falls short. Is it actually possible to parody it?

BigRedDot
Mar 6, 2008

Zombywuf posted:

This is the closest I've seen to managing to parody timecube. However it still falls short. Is it actually possible to parody it?

Timecube is invariant under parody operations.

mr_jim
Oct 30, 2006

OUT OF THE DARK

Zombywuf posted:

This is the closest I've seen to managing to parody timecube. However it still falls short. Is it actually possible to parody it?

That's a copy/paste from timecube.com.

Zombywuf
Mar 29, 2008

mr_jim posted:

That's a copy/paste from timecube.com.
oh....

Lurchington
Jan 2, 2003

Forums Dragoon
Granted, it's a pretty nice little framework, and yes, I'm using old (last official) code, but there's some weird stuff with Route-Me. Open-Source mapping Framework for iPhone. Before the 3.0DSK it was the only real option for maps.

Specifically:

their most recent documentation specifies 1 method for getting the bounds of the viewable area:

code:
- (RMLatLongBounds) getScreenCoordinateBounds  	
So, a variable that contains the bounds of the area on screen, awesome. RMLatLongBounds is defined as:

code:
CLLocationCoordinate2D 	northWest
CLLocationCoordinate2D 	southEast
Core Location Coordinates (standard type for this kind of thing) for Northwest and Southeast corners. Simple, not a big deal so far.

Let's look at the method for setting the bounds of the viewable area:

code:
- (void) zoomWithLatLngBoundsNorthEast: (CLLocationCoordinate2D) ne
                             SouthWest: (CLLocationCoordinate2D) se	 
so... you think it's right to give me Northwest and Southeast, and then only accept Northeast and Southwest? Not to mention naming the argument representing Southwest as "se." Thanks. :)


This is all changed in their dailies, but there's no example code or documentation since the deprecated version.

Reaten
Jun 29, 2002

crotchety old goat
Even if this were actually necessary (avoiding 0 as a magic number I guess?) this still can't be the best way to do it.

public static class DefaultValues
{
public static int GetIdDefaultMinValue()
{
return (0);
}
public static int GetLoginQAIdMinValue()
{
return (0);
}
public static int GetLoginQuestionIdMinValue()
{
return (0);
}
public static int GetOtherActivityIdMinValue()
{
return (0);
}
public static int GetAwardRecognitionIdMinValue()
{
return (0);
}
//etc etc etc for every object in the app
}

Reaten fucked around with this message at 20:09 on Sep 8, 2009

PraxxisParadoX
Jan 24, 2004
bittah.com
Pillbug
The Doctrine ORM framework for PHP. That is all.

blorpy
Jan 5, 2005

PraxxisParadoX posted:

PHP

:mmmhmm:

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Any attempt to start the PHP derail should be bannable throughout CoC.

Zombywuf
Mar 29, 2008

pokeyman posted:

Any attempt to start the PHP derail should be bannable throughout CoC.
Any attempt to derail the PHP derail, thus leading to a PHP meta-derail should be bannable throughout CoC.

tef
May 30, 2004

-> some l-system crap ->
We already have a php coding horrors thread

enki42
Jun 11, 2001
#ATMLIVESMATTER

Put this Nazi-lover on ignore immediately!

Reaten posted:

Even if this were actually necessary (avoiding 0 as a magic number I guess?) this still can't be the best way to do it.

I've worked with apps where specifying a starting seed (I guess this is what they are trying to do here?) was a requirement, but yeah, that's pretty much the worst way you could do it.

Tad Naff
Jul 8, 2004

I told you you'd be sorry buying an emoticon, but no, you were hung over. Well look at you now. It's not catching on at all!
:backtowork:
I swear, not a PHP derail. I use it all the time.

expertsexchange posted:

I could not figure out how to get SSH to work from a key, instead I did find that I could do the following. Have a file with the root password in it that I hide in a bunch of subfolders and run the following command from php...
php:
<?
exec("sudo -u root -S chown admin:staff /Users/alal/ < /ghost/folder/la41230/pass\n");
?>
Where pass contains the root password, hidden in a few subfolders for minor security.

http://www.experts-exchange.com/Security/Unix_Security/Q_20569275.html

Lurchington
Jan 2, 2003

Forums Dragoon
I've plain-texted a (non-root) password inside a master-to-all rsync script :v:. I don't know if being on a completely cut-off DOD classified network makes that better or worse.

RussianManiac
Dec 27, 2005

by Ozmaugh
i have seen following things at my job

code:
#if 0
.... some code ...
#endif
Apparently it is how they comment it out.

Steve French
Sep 8, 2003

RussianManiac posted:

i have seen following things at my job

code:
#if 0
.... some code ...
#endif
Apparently it is how they comment it out.

I think this is an entirely reasonable thing to do and not a coding horror at all.

Commenting out large blocks of code is a bitch for a few reasons, including:
- usually the commented out code will not be syntax highlighted in most (all?) editors, making it harder to tell what it does/did while reading the code without removing the comments
- you can't just /* ... */ block comment poo poo out because the code might have some of that style comment inside it.

RussianManiac
Dec 27, 2005

by Ozmaugh

Steve French posted:

I think this is an entirely reasonable thing to do and not a coding horror at all.

Commenting out large blocks of code is a bitch for a few reasons, including:
- usually the commented out code will not be syntax highlighted in most (all?) editors, making it harder to tell what it does/did while reading the code without removing the comments
- you can't just /* ... */ block comment poo poo out because the code might have some of that style comment inside it.

Oh ok, that makes sense. At the time it was exceedingly weird tho.

Shavnir
Apr 5, 2005

A MAN'S DREAM CAN NEVER DIE
Also unlike using multiple lines of //s that sort of ifdef will properly diff for source control.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Steve French posted:

- usually the commented out code will not be syntax highlighted in most (all?) editors, making it harder to tell what it does/did while reading the code without removing the comments

This applies to #if 0 ... #endif also

ehnus
Apr 16, 2003

Now you're thinking with portals!
I have no problem with #if 0 ... #endif but it's nearing horror status when it gets checked in.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

ehnus posted:

I have no problem with #if 0 ... #endif but it's nearing horror status when it gets checked in.

Yeah, checking in commented out code is terrible. You're using source control for that reason, just take it out.

Lurchington
Jan 2, 2003

Forums Dragoon

Ryouga Inverse posted:

Yeah, checking in commented out code is terrible. You're using source control for that reason, just take it out.

Shavnir posted:

Also unlike using multiple lines of //s that sort of ifdef will properly diff for source control.

I'm inclined to agree with Ryouga, but there's apparently disagreement.

Shavnir
Apr 5, 2005

A MAN'S DREAM CAN NEVER DIE

Lurchington posted:

I'm inclined to agree with Ryouga, but there's apparently disagreement.

I don't make it a habit of checking in commented out code, but I've seen what blocks of //s do to the diffs.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost

Ryouga Inverse posted:

Yeah, checking in commented out code is terrible. You're using source control for that reason, just take it out.
If you're doing an Agile development model, you'll be checking in code so often you'll probably hit a point where you'll just check it in and fix it up in another commit happening in only a matter of hours while you work on it. I typically check in commented out code when I'm about done for the day or because I'm completely stuck / having a brainfart and could use a kickstart the next time I look at it, but it should be obvious to anyone looking at it why it's commented out. Everyone works differently and so long as it works, I don't see what's wrong.

Adbot
ADBOT LOVES YOU

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


necrobobsledder posted:

If you're doing an Agile development model, you'll be checking in code so often you'll probably hit a point where you'll just check it in and fix it up in another commit happening in only a matter of hours while you work on it. I typically check in commented out code when I'm about done for the day or because I'm completely stuck / having a brainfart and could use a kickstart the next time I look at it, but it should be obvious to anyone looking at it why it's commented out. Everyone works differently and so long as it works, I don't see what's wrong.

I tend to agree with you, but as the guy who does a lot of the team's source control stuff, a message to my team: please god just use block comment constructs, I don't care if it's /* or #if 0, just don't use // everywhere :(

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