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
Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Doctor w-rw-rw- posted:

Commit Message Generator
Heh. Why produce bad commit messages when the computer can do it for you?

How did you find our repository?! Get out of there you do not belong shoo go!

Adbot
ADBOT LOVES YOU

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Wheany posted:

Am I interpreing this correctly: The first assignment opens a file, the second sets the file's mode to write and the third assignment is written into the file?

Well that's just genius.

Perfectly intuitive.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Jewel posted:

Both people replied with a git command but I wasn't using git. I haven't gotten a chance to use/learn it yet v:shobon:v

(I do most of my personal work in class where we use perforce so I just use it because it's there, and use it at home because I have to use it for class. I used to use TortoiseSVN when I did the majority of work on my own projects from home though. I tried out git for the first time about.. 2-6 months ago, and I liked it! I don't know any of the commands yet, but I definitely can see why it's liked, and will try to learn it thoroughly when I get the chance (probably after uni or during a break).

You should definitely learn it. After coming from P4 and SVN it's like a breath of fresh air wrapped in diamonds inside of a TARDIS

Also, for those suggesting that he rewrite history, I'm sure you're all aware that this is a bad thing when others have pulled that commit already.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
code:
AtomicBoolean registeredWithFoo = new AtomicBoolean(false);

private void addBar(...) {
  ...
  if(!registeredWithFoo.get()) {
    foo.addCallback(this);
    registeredWithFoo.set(true);
  }
  ...
}
:cripes:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Rocko Bonaparte posted:

A minor horror, but I found a data pool that I had mislabeled as "poot" in my code for a bit. It must be how late it is, but the idea of my code having farts in it is making me giggle too much. The code smells!

On a related note, I smiled when someone marked a code review with "looks good, make sure you blah blah blah then you can poo poo it"

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Sang- posted:

In scala I will occasionally use ✓ (unicode tick) as a value for true.

I honestly can't tell if this is a serious post.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

code:

gently caress->ppu->dump_vram();
gently caress->dump_ram();
exit(0);

Not the worst error handler I can think of.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Scaramouche posted:

I had to support an ancient PHP app back in the day (think like php 3.0) and I had no exposure to php before that. I basically had to learn it in one weekend and make this monstrously awful billing app that served millions of customers work. In my frustration I had several variables called things like gently caress, FUCKKK, and FUCKKKKKKKKYOOOOOOOOOUUUUUPHP but the thing eventually got working. A couple weeks ago one of the guys I used to work with got hold of me on LinkedIn and the first thing he told me was that they were all still there 'because if we tried to change one it broke everything'.

The real coding horror is that you can't change a goddamned variable name in PHP without everything breaking.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Pilsner posted:

Has anyone ever seen a method in code named Do____ (for example DoEmails) that wasn't crap? I assume it's a holdover from VB or something.

DoItInTheButt(...) :pervert:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Naturally, there's no goddamned documentation. :argh:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

That Turkey Story posted:

I wanted to go and do it anyway:

C++ code:
#include <iostream>
#include <type_traits>

template< char... C >
struct tmp_string
{
  typedef tmp_string type;
  static char const c_string[ sizeof...( C ) + 1 ];
};

template< char... C >
char const tmp_string< C... >::c_string[ sizeof...( C ) + 1 ]
  = { C..., '\0' };

template< class... Strings > struct combine;

template< char... LC, char... RC >
struct combine< tmp_string< LC... >, tmp_string< RC... > >
  : tmp_string< LC..., RC... > {};

template< class L, class R, class... Strings >
struct combine< L, R, Strings... >
  : combine< typename combine< L, R >::type, Strings... > {};

template< unsigned Digit > struct digit_to_string
  : tmp_string< static_cast< char >( '0' + Digit ) > {};

template< unsigned Value, class CurrString >
struct value_to_string_impl
  : value_to_string_impl
    < Value / 10
    , typename combine
      < typename digit_to_string< Value % 10 >::type
      , CurrString
      >::type
    > {};

template< class CurrString >
struct value_to_string_impl< 0, CurrString > : CurrString {};

template< unsigned Value >
struct value_to_string : value_to_string_impl< Value, tmp_string<> > {};

template<> struct value_to_string< 0 > : tmp_string< '0' > {};

template< unsigned Curr, unsigned End >
struct fizzbuzz_impl;

template< unsigned Curr, unsigned End >
struct fizzbuzz_impl_fizz_or_buzz
  : combine
    < typename std::conditional
      < Curr % 3 == 0, tmp_string< 'F', 'i', 'z', 'z' >, tmp_string<> >::type
    , typename std::conditional
      < Curr % 5 == 0, tmp_string< 'B', 'u', 'z', 'z' >, tmp_string<> >::type
    , tmp_string< ' ' >
    , typename fizzbuzz_impl< Curr + 1, End >::type
    > {};

template< unsigned Curr, unsigned End >
struct fizzbuzz_impl_not_fizz_or_buzz
  : combine
    < typename value_to_string< Curr >::type
    , tmp_string< ' ' >
    , typename fizzbuzz_impl< Curr + 1, End >::type
    > {};

template< unsigned Curr, unsigned End >
struct fizzbuzz_impl
  : std::conditional< Curr % 3 == 0 || Curr % 5 == 0
                    , fizzbuzz_impl_fizz_or_buzz< Curr, End >
                    , fizzbuzz_impl_not_fizz_or_buzz< Curr, End >
                    >::type {};

template< unsigned Curr >
struct fizzbuzz_impl< Curr, Curr > : tmp_string<> {};

typedef fizzbuzz_impl< 1, 101 >::type fizzbuzz;

int main()
{
  std::cout << fizzbuzz::c_string;
}
This one produces a single, c-style string at compile time.

You're hired. When can you begin?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

hobbesmaster posted:

I notice a distinct lack of a return statement from main. They made void legal for a reason!

You're fired. Pack your things and get out.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

FateFree posted:

I was cleaning out a development folder and I found a file called MP.java. I had no recollection until I opened it and it all came rushing back to me. I suppose this falls under the category of code that makes you laugh.

When I was a younger buck working at Morgan Stanley, I thought I would die from the boredom of writing loan reporting applications. My boss sat directly behind me so I couldn't slack off and read the internet. To pass the time I would try to code things that would keep me entertained. So I created this little work of art.

If you have a Java IDE, run it as a java application and watch the console - but the console needs to be sized correctly. Shrink it down until you can only see one square frame. Enjoy.

http://imadp.com/static/MP.java


Ephphatha posted:

That's amazing. For the lazy set your console window to 65x17 and run java -jar MP.jar.

:golfclap:

Your tree was planted in the very soul of the 1 minute I spent downloading and running this artistic masterpiece.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Dren posted:

What about having staging and like, one behavioral test with selenium webdriver?

This. Why the crap would you ever deploy directly to prod, let alone edit prod directly?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Volte posted:

Sometimes it's nice to just type code into a text editor.

In the YOOL 2013 I still dick around at the command line, and sometimes I want to just pop open an editor to change a line or something. I'll use an IDE for doing active development, but VIM fills a great niche.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

evensevenone posted:

People still use IDEs?

As opposed to...

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

:cripes:

I'd say I really hope someone gets that taken down, but it's from 2011 so I think that ship has sailed.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

facepalmolive posted:

Because knowing the implementation of a hash function means knowing how to crack it, right?

I can know how SHA works without knowing how to effectively crack it.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
I continue to find code like

code:
void function(String str) {
  ...
  if(str == "true") {
in the Java code reviews that come to me. Why :cripes:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

b0lt posted:

Sounds like you have some ~fun-defined behavior~

I prefer to think of it like this :yayclod:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
You have not seen my coworker's code :negative:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

yaoi prophet posted:

Today at work I saw a 59-argument function. That's a loving horror.

Let me guess: someone didn't understand the concept of passing arrays, and instead had input1 through input50, along with a few other arguments.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

quiggy posted:

Holy poo poo I forgot about the loving plane :lol:

Oh my god. I just saw that for the first time. Everyone on the train was staring at me :blush:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

pokeyman posted:

Hey, these are the jerks who had an "email us and we'll give you some cool crypto problems to solve", and I did and they never wrote back so I wrote again and they still never wrote back so now I'm sad.

I emailed them and they gave me some cool crypto problems to solve (and then more when I solved them, rinse repeat).

Maybe it's just you?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

seiken posted:

C++ code:
#define pirate private

I think this is a pretty reasonable define to put in.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

zergstain posted:

So today I edited a file with 4 space indenting, tab indenting, 2 space indenting, and I believe there was a few lines with 5 space indenting. And of course tabs and spaces mixed on the same line. What I really love is the if that is indented with spaces, except for the closing brace, so it's way over to the right.

This sounds like a problem that could be solved with a quick ctrl-shift-F.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Dicky B posted:

Our team is currently reviewing our c++ style guide (our current one is basically badly adapted from an old C style guide so a lot of stuff is missing/inappropriate) and today we spent a good 30 minutes discussing whether or not there should be a space between if and (

Yes, there should be.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Aleksei Vasiliev posted:

x264 uses
C code:
    if( i_frame_size )
    {
        i_frame_size = cli_output.write_frame( hout, nal[0].p_payload, i_frame_size, &pic_out );
        *last_dts = pic_out.i_dts;
    }
so therefore this is the one true brace style

The one truly wasteful and ugly brace style, yes. Opening curly on the same line as if is the way to go and we all know it.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Jewel posted:

See, the thing that makes

code:
if ( <expr> )
{
    //code
} else {
    //other code
}
make the most sense is because when you're going to the brace opening, you get your end brace, scroll your eyes exactly upwards, and bam, you're there.

I get that having the brace on the same line is shorter and cleaner in some fashions, but why would you suffer one newline character (which is a space otherwise anyway) to sacrifice easy human readability. I don't get why you wouldn't use brace-on-newline style.

If you don't have whitespace, yes, I can see where that's easier. However, most of the world can handle auto-indent, so not only do you not gain readability from knowing where the block starts, but you're also decoupling the brace from the if statement, which in my opinion actually makes this LESS readable. When I scroll my eyes up from }, I don't look for a {, I look for another line of code that's at that level of indentation.

Consider what python does; no braces, indentation is its own mechanism of blocking. And it works, pretty well too.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Brace style holy wars are the horror here because I'm right and we all know it because it's really a matter of personal preference.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Che Delilas posted:

Is this where I ask about "EmployeeID" vs. "EmployeeId" vs. "Employee_ID" vs. Employee_Id" vs. "Employee_id" ?
:buddy:

employeeID and I dare anyone to tell me otherwise :colbert:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

tef posted:

i'd make a lilliputian reference to big-endian and little-endian, but satire is dead.

http://en.wikipedia.org/wiki/Endianness#Etymology

I don't think the joke was lost on the folks who borrowed the terms for computing.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

yaoi prophet posted:

Have you ever hated the convenience of exceptions having stack traces?

Java code:

public abstract class ReaderException extends Exception {

  ReaderException() {
    // do nothing
  }

  // Prevent stack traces from being taken
  // srowen says: huh, my IDE is saying this is not an override. native methods can't be overridden?
  // This, at least, does not hurt. Because we use a singleton pattern here, it doesn't matter anyhow.
  @Override
  public final Throwable fillInStackTrace() {
    return null;
  }

}

public final class NotFoundException extends ReaderException {

  private static final NotFoundException instance = new NotFoundException();

  private NotFoundException() {
    // do nothing
  }

  public static NotFoundException getNotFoundInstance() {
    return instance;
  }
}

Why would anyone do this? I mean, if your code needs to be so secure that even stacktraces give away information, just don't enable logging :psyduck:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

QuarkJets posted:

Nah don't worry guys, it's cool, we'll just put up some signs around the office saying "DO NOT STEAL OUR DATABASE" and we'll be covered

What if someone uses whiteout on the "NOT" and then claims that you asked them to steal it?

Check and mate :smugdog:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Amarkov posted:

So I learned last year how to access private member fields with Java's reflection library. Funny little trick, but I'm never going to use it right?

Well, this application dispatches events to an asynchronous scheduler with private access. I need to write unit tests to check that these events actually complete. And thus I end up with

code:
Field f = OurSession.class.getDeclaredField("scheduler");
f.setAccessible(true);
OurScheduler scheduler = (OurScheduler) f.get(session);

If you have access to the source, try making the private inner class package private, and/or write a subclass to expose that variable for testing.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

TheresaJayne posted:

These are to prevent people putting unpleasant words on the site we have written,
Someone entered a job description (without the 1337 5p33k and non alphabetic characters)as:

"A Fu*&ing Cr4p job where you sit around and do Sh17 all day except getting p1553d and high on wacky backy"

And after being admonished for naughty language, they'll just change characters around enough to break the filter.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
The code that contractors are writing for me as part of the phone screen process of their interview.

This is the code that makes me cry.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

1337JiveTurkey posted:

var ┻━┻ = new WhateverException()
(╯°□°)╯︵ ┻━┻

Please tell me that this is a thing that can actually be some in some language.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Ithaqua posted:

I firmly believe that well-written code is self-documenting. That goes double if you have good unit tests that are grouped around expected behavior.

Which, while nice and to some extent true, doesn't excuse you from actually writing documentation. One step above well written code that I can examine is well documented code that I don't actually have to physically examine to understand.

Adbot
ADBOT LOVES YOU

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Ithaqua posted:

Documentation of a software product and/or API is a different story.

Ask me about the "self documenting" spaghetti code that my coworker has written that needs to be maintained. I dare you.

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