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
Polio Vax Scene
Apr 5, 2009



Just had to defend use of the below to someone in figuring out if a DateTime falls on a weekday
code:
(dateTime.DayOfWeek != DayOfWeek.Sunday &&
    dateTime.DayOfWeek != DayOfWeek.Saturday)
Verbatim: "What if in the future we add or remove days from the week though!?"


vvv oh gently caress me

Polio Vax Scene fucked around with this message at 00:33 on Dec 31, 2013

Adbot
ADBOT LOVES YOU

Zhentar
Sep 28, 2003

Brilliant Master Genius
Joke's on you. Saturday and Sunday aren't the weekend in every country.



Sagacity posted:

(btw, SVN is still worse, doing any kind of merging while trying to stay sane just sucks)

We must be using different SVNs. I can barely remember last time I had a difficult merge, and the ones I have had would've been rough with any VCS, since they usually involved logical conflicts.

Zhentar fucked around with this message at 23:56 on Dec 30, 2013

ManoliIsFat
Oct 4, 2002

Manslaughter posted:

Just had to defend use of the below to someone in figuring out if a DateTime falls on a weekday
code:
(dateTime.DayOfWeek != DayOfWeek.Sunday &&
    dateTime.DayOfWeek != DayOfWeek.Saturday)
Verbatim: "What if in the future we add or remove days from the week though!?"

Not too crazy. http://en.wikipedia.org/wiki/Workweek_and_weekend#Around_the_world (why the heck is Afghanistan Saturday->Thursday? Brunei takes Friday and Sunday off? craziness.) I bet you can get 99% there with CultureInfo, like take the 2 days before the FirstDayOfWeek as the weekend.

ManoliIsFat fucked around with this message at 00:27 on Dec 31, 2013

HORATIO HORNBLOWER
Sep 21, 2002

no ambition,
no talent,
no chance
God, stupid people loving exhaust me.

So I get in this morning I go talk to Guy and tell him "look, I think I really hosed up on Friday, this has been driving me nuts all weekend. I think you lost all your changes on Thing X that you were working on. That git command I told you to run reset your repository to the last commit, so if you had uncommitted changes, they're all gone."

Guy is totally blithe and blasé about it. "No, no, I'm sure everything's fine, you've been stressing over nothing, I'm sure I didn't lose anything." I'd love for this to reassure me but he has Git Extensions open behind him and I can see he's on the same mainline that I am and there's no extra commits I don't have. Again Guy has no idea about branching or stashing so I'm 99% sure I was right, his work is gone, and he just doesn't realize it yet. But I don't argue (because there isn't any point in doing so), and hey, maybe what he means is that he has some kind of local backup and everything will be fine. I broach the subject of having an in-depth conversation about how to use git, what commits and branches are, and how we can safely collaborate and make sure nothing like this happens in the future. I get pushed off. Of course.

Finally around two o'clock I hear: "Horatio...? ... I think you were right. My changes are gone."

We find the WAR file from the staging server. It's on my desktop, where I copied it first thing in the morning. Guy had already overwritten the one on the staging server.

We pull out the JSPs and JavaScript files. So that's something. It's the perfect time to create a branch so we can collaborate on fixing this mess. "Do you have some time right now? We can get this changes into a branch and..."

"No, no, we can't put this code in a branch. It's broken right now."

"...Right, yes, well, that's kind of the point of a branch, so you can work on code in a broken or incomplete state and it doesn't affect the mainline."

"Oh. Well, no, let me just see what kind of progress I can make and maybe Thursday we can talk about putting it in a branch...."

At this point I feel like I'm banging my head on a brick wall but I still feel responsible for loving his poo poo up so I say, "Well, I'm happy to help you try to recreate some of the Java files that were lost."

"No, what I'm going to do is go online and try to find a decompiler to generate some Java from the class files in the WAR."

:stare:

Well, whatever. I give the gently caress up. You wanna be a stubborn idiot, go ahead and be a stubborn idiot. I can't stop you. I owned up to it, I tried to make amends, and Lord knows I've tried like hell to implement some revision control and build management processes that aren't total trash. It's a lost loving cause.

Son of Thunderbeast
Sep 21, 2002
I offer my own powershell horror from shortly before I learned about Get-Date -format:

code:
Function Get-Timestamp
{
        $n=Get-Date
        $mo=(($n.Month).ToString()).PadLeft(2,"0")
        $dy=(($n.Day).ToString()).PadLeft(2,"0")
        $yr=($n.Year).ToString()
        $hr=(($n.hour).ToString()).PadLeft(2,"0")
        $mn=(($n.Minute).ToString()).PadLeft(2,"0")
 
        $result=$mo+"-"+$dy+"-"+$yr+"_"+$hr+"h"+$mn+"m"
 
        return $result
}
 
$t=Get-TimeStamp
$logsFolder = ".\_LOGS"
$newfile= $logsFolder+"\SetPermsLog_"+$t+".txt"

ManoliIsFat
Oct 4, 2002

HORATIO HORNBLOWER posted:

Well, whatever. I give the gently caress up. You wanna be a stubborn idiot, go ahead and be a stubborn idiot. I can't stop you. I owned up to it, I tried to make amends, and Lord knows I've tried like hell to implement some revision control and build management processes that aren't total trash. It's a lost loving cause.
That's just an awful situation. I totally feel you, there's no worse feeling for me than loving up someone else's poo poo, making their lives harder because of a screwup on my part. Maybe just give him time, and he'll come around to accepting your help. But I've managed guys like that before, who were slight under-skilled (or maybe more aptly, scared of their own shadow), and they were totally afraid of ever being involved in anything but totally solitary work. It's a shame, cuz that's no way to grow, but it's so frustrating trying to get to a guy like that. After a while it's just like "you keep doing you, bro, I'm just gonna try to avoid dealing with you" (which is just an awful thing for me to have done: a total disservice to the employee and just perpetuates him being a lovely asset to the company)

ManoliIsFat fucked around with this message at 01:15 on Dec 31, 2013

Brain Candy
May 18, 2006

HORATIO HORNBLOWER posted:

:words:

"No, what I'm going to do is go online and try to find a decompiler to generate some Java from the class files in the WAR."

The burned hand teaches best :unsmigghh:

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

Brain Candy posted:

The burned hand teaches best :unsmigghh:

I don't have any experience in Java except by proxy through Scala. Can you even do that (decompile I mean), meaningfully anyway?

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

Maluco Marinero posted:

I don't have any experience in Java except by proxy through Scala. Can you even do that (decompile I mean), meaningfully anyway?
You can easily decompile bytecode languages but you'll probably lose a lot of readability (assuming it wasn't obfuscated to begin with). Not as bad as decompiling native code though.

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
If "meaningfully" means producing anything like human-written code, the answer is "hell no."

QuarkJets
Sep 8, 2008

Suspicious Dish posted:

You mean the part where it says git init?

No, I was trying to describe creating a repository without a working directory: git --bare init and git --bare clone

QuarkJets fucked around with this message at 10:00 on Dec 31, 2013

omeg
Sep 3, 2012

Manslaughter posted:

Just had to defend use of the below to someone in figuring out if a DateTime falls on a weekday
code:
(dateTime.DayOfWeek != DayOfWeek.Sunday &&
    dateTime.DayOfWeek != DayOfWeek.Saturday)
Verbatim: "What if in the future we add or remove days from the week though!?"


vvv oh gently caress me

https://www.youtube.com/watch?v=-5wpm-gesOY

Also please don't use that horrible "edit with reply to the future" thing.

NFX
Jun 2, 2008

Fun Shoe

ManoliIsFat posted:

Not too crazy. http://en.wikipedia.org/wiki/Workweek_and_weekend#Around_the_world (why the heck is Afghanistan Saturday->Thursday? Brunei takes Friday and Sunday off? craziness.) I bet you can get 99% there with CultureInfo, like take the 2 days before the FirstDayOfWeek as the weekend.

Won't FirstDayOfWeek return Sunday in the Americas? Calendars are always a horror.

Polio Vax Scene
Apr 5, 2009



omeg posted:

https://www.youtube.com/watch?v=-5wpm-gesOY

Also please don't use that horrible "edit with reply to the future" thing.

Sadly I'm stuck with creating a library to manage appointments, schedules, and recurrences that are timezone compatible.

And "oh gently caress me" doesn't warrant a new post.

The true coding horror: the human race

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

QuarkJets posted:

No, I was trying to describe creating a repository without a working directory: git --bare init and git --bare clone

Any specific reason?

ManoliIsFat
Oct 4, 2002

NFX posted:

Won't FirstDayOfWeek return Sunday in the Americas? Calendars are always a horror.
Uggh, that's right. gently caress a calendar.

qntm
Jun 17, 2009

NFX posted:

Won't FirstDayOfWeek return Sunday in the Americas? Calendars are always a horror.

FirstDayOfWeek will vary between two retail stores sitting next to one another on the same street.

ninjeff
Jan 19, 2004


Assuming we're still around in fifty thousand years, the interstellar humans of the future will look at this video and enjoy the laughable idea that there's a Time that applies across the whole of the human species at once, then send version-vector-stamped hypertweets to their friends about the dumbass third-millenium humans.

QuarkJets
Sep 8, 2008

Suspicious Dish posted:

Any specific reason?

Bare repositories are useful for all sorts of things, such as transporting changes between networks that can't touch each other except via optical media (government work)

QuarkJets
Sep 8, 2008

ninjeff posted:

Assuming we're still around in fifty thousand years, the interstellar humans of the future will look at this video and enjoy the laughable idea that there's a Time that applies across the whole of the human species at once, then send version-vector-stamped hypertweets to their friends about the dumbass third-millenium humans.

An atomic clock in a universally agreed-upon inertial reference frame :colbert:

QuarkJets fucked around with this message at 19:55 on Jan 1, 2014

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

ManoliIsFat posted:

(why the heck is Afghanistan Saturday->Thursday? Brunei takes Friday and Sunday off? craziness.)

Friday is the Day of Assembly in Islam. Brunei additionally has a significant Christian minority and used to be a British protectorate.

ninjeff
Jan 19, 2004

QuarkJets posted:

An atomic clock in a universally agreed-upon inertial reference frame :colbert:

That's what we're using now, and it doesn't scale. Your terrestrial ideas have no place in Big Space.

QuarkJets
Sep 8, 2008

ninjeff posted:

That's what we're using now, and it doesn't scale. Your terrestrial ideas have no place in Big Space.

Why doesn't it scale? You travel with your own atomic clock that stays in your reference frame. From time to time your computer checks in with the space system's central atomic clock to see how far you're off by and making an adjustment accordingly. It's not going to be exact, but time-keeping between two non-inertial frames where you don't necessarily know your velocity relative to the central clock that well is going to be impossible. The atomic clock is basically like having a clock tower; each town (space system) gets its own and from time to time some people get together to make sure that all of the clocks are running about right. I don't see us being able to do much better than that with the technology that exists today, and it's a pretty good and realistic solution

And I hardly see what's terrestrial about a system of atomic clocks orbiting stars so that spaceship pilots can have some reasonably accurate way of telling time, but okay

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
Well, according to Poul Anderson,

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

Maluco Marinero posted:

I don't have any experience in Java except by proxy through Scala. Can you even do that (decompile I mean), meaningfully anyway?

You end up with almost exactly the original source since its bytecode and not assembly, but everything's stripped.

Hope you like reading

hj a = new mb().a("98403").b(Color.Red);
hj b = new df();
hj c = new el().k();

and so on. You never realize how important good variable/function names are until you don't have them at all. It is theoretically possible to walk the code and reverse engineer it and rename it enough to work with, but... you don't want to have to do that. Easier to just write the code again, unless you're specifically trying to hack some 3rd party closed source software.

FlapYoJacks
Feb 12, 2009
Timezones? I haven't had to deal with them in forever. Just use popen with a script that changes the timezone in Linux, and then use Epoc time with that. :smug:

*edit* Jesus Christ, I just watched the end of that video. LEAP SECONDS?! Why isn't there a emoticon of a psyduck drinking scotch?

FlapYoJacks fucked around with this message at 17:34 on Jan 2, 2014

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

ratbert90 posted:

Timezones? I haven't had to deal with them in forever. Just use popen with a script that changes the timezone in Linux, and then use Epoc time with that. :smug:

*edit* Jesus Christ, I just watched the end of that video. LEAP SECONDS?! Why isn't there a emoticon of a psyduck drinking scotch?

Watch this video by Jon Skeet. He talks about time starting at about 17 minutes, but the entire thing is pretty interesting.

http://vimeo.com/7516539

Amberskin
Dec 22, 2013

We come in peace! Legit!

Zaphod42 posted:

You end up with almost exactly the original source since its bytecode and not assembly, but everything's stripped.


Is it posible to back-translate (decompile) every posible chunk of bytecode? That is for sure not the case with old-school compiled code... the optimizations usually mangle the object code in ways that just make sense in assembly, but not in a high level language.

(I had once to look at a dissassembled fragment of compiled PL/I code and it was an absolute mess...).

omeg
Sep 3, 2012

I don't know about Java but it's not possible with .NET. The runtime has more features that for example C# doesn't support (like global variables).

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.

Amberskin posted:

Is it posible to back-translate (decompile) every posible chunk of bytecode?
I don't think so; there are several JVM ops like dup2_x1 that exist just to move stuff around within the stack.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
I've dug around in .net bytecode a bit and it is more or less a direct transcription of the source; often even trivial constant-foldings didn't seem to be performed, presumably because the loader/JIT would take care of that. I would assume that JVM bytecode is similarly straightforward.

FlapYoJacks
Feb 12, 2009

Ithaqua posted:

Watch this video by Jon Skeet. He talks about time starting at about 17 minutes, but the entire thing is pretty interesting.

http://vimeo.com/7516539

Yep, I agree with the first video guy. Find somebody elses code, thank them, and then never look at that code again.

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

Zaphod42 posted:

You end up with almost exactly the original source since its bytecode and not assembly, but everything's stripped.

Hope you like reading

hj a = new mb().a("98403").b(Color.Red);
hj b = new df();
hj c = new el().k();

and so on. You never realize how important good variable/function names are until you don't have them at all. It is theoretically possible to walk the code and reverse engineer it and rename it enough to work with, but... you don't want to have to do that. Easier to just write the code again, unless you're specifically trying to hack some 3rd party closed source software.
At least in .NET, class names, methods and fields are preserved (probably for documentation/linking purposes), but anything local is pretty much lost. Here's an example from an old version of Reflector: http://hastebin.com/ramoneyuvi.cs

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
Java decompilers like Jad and JD actually work surprisingly well, and produce fairly readable code (big caveat: if it hasn't been run through an obfuscator). The biggest problem they usually have is with exception handler blocks -- those are tough to reverse engineer correctly a lot of times.

I've used them on numerous occasions to figure out what a library was doing when the source wasn't available. Keep in mind that even private method names and fields are preserved by the compiler for reflection purposes, so the biggest place where you lose names is with local variables and parameters.

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop

Flobbster posted:

Java decompilers like Jad and JD actually work surprisingly well, and produce fairly readable code (big caveat: if it hasn't been run through an obfuscator). The biggest problem they usually have is with exception handler blocks -- those are tough to reverse engineer correctly a lot of times.

I've used them on numerous occasions to figure out what a library was doing when the source wasn't available. Keep in mind that even private method names and fields are preserved by the compiler for reflection purposes, so the biggest place where you lose names is with local variables and parameters.

Java/C++ (probably others) make higher-level structure easier to decompile due to various language features such as overloading - that information has to make it into the binary, and now you have type-information of call arguments. Decompiling C code? Good luck with that, you can see it accessing a 32-bit register and try to guess what type it is based on what it does next.

Java decompilation is how all minecraft mods are made. You run the .jar through an obfuscator with the purpose of renaming A, B into usable class names (Block, Player, etc) via a community-updated database. Then you decompile it, make your modifications/addon, recompile and re-obfuscate back to the original class names - which now mangles your references as well. Compare the stock .jar to the produced .jar, extract the files that changed and presto, a mod that you can distribute.

There's a set of patches you can add that do some code cleanup for readability (where the decompiler went off the rails) but it's usable. It's amazing that it works at all, honestly. The nightmare mish-mash of competing and conflicting infrastructure in the modding community is a horror all on it's own though.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

Harik posted:

Java/C++ (probably others) make higher-level structure easier to decompile due to various language features such as overloading - that information has to make it into the binary, and now you have type-information of call arguments. Decompiling C code? Good luck with that, you can see it accessing a 32-bit register and try to guess what type it is based on what it does next.

Java decompilation is how all minecraft mods are made. You run the .jar through an obfuscator with the purpose of renaming A, B into usable class names (Block, Player, etc) via a community-updated database. Then you decompile it, make your modifications/addon, recompile and re-obfuscate back to the original class names - which now mangles your references as well. Compare the stock .jar to the produced .jar, extract the files that changed and presto, a mod that you can distribute.

There's a set of patches you can add that do some code cleanup for readability (where the decompiler went off the rails) but it's usable. It's amazing that it works at all, honestly. The nightmare mish-mash of competing and conflicting infrastructure in the modding community is a horror all on it's own though.

Yeah, I spent a good bit of a year working on a fairly ambitious minecraft mod, and slowly lost my mind due to complete rewrites of what little and lovely common APIs existed (which were SUPPOSED to provide a static link target so you wouldn't have to break your mod and rewrite the drat thing every loving minecraft patch, except the stupid APIs changed as much as minecraft did!)

I'm honestly pretty loving pissed at Notch for making a big deal out of an official API, talking about going so far as to charge money for API support, and then just dropping the whole thing on the community and walking away.

That game could be SO much more, but gently caress, I can't be bothered to keep up with it. Its a real coding horror. They refactor EVERYTHING every loving week! And Documentation? What's that? Nope I've decided to just work on my own game from scratch in my free time, and I'm all the happier for it.

astr0man
Feb 21, 2007

hollyeo deuroga

Harik posted:

Java/C++ (probably others) make higher-level structure easier to decompile due to various language features such as overloading - that information has to make it into the binary, and now you have type-information of call arguments. Decompiling C code? Good luck with that, you can see it accessing a 32-bit register and try to guess what type it is based on what it does next.

As someone who used to do RE for a living, I can say with a certainty that it is easier to reverse C code than it is C++.

Scaevolus
Apr 16, 2007

Harik posted:

Java decompilation is how all minecraft mods are made. You run the .jar through an obfuscator with the purpose of renaming A, B into usable class names (Block, Player, etc) via a community-updated database. Then you decompile it, make your modifications/addon, recompile and re-obfuscate back to the original class names - which now mangles your references as well. Compare the stock .jar to the produced .jar, extract the files that changed and presto, a mod that you can distribute.

There's a set of patches you can add that do some code cleanup for readability (where the decompiler went off the rails) but it's usable. It's amazing that it works at all, honestly. The nightmare mish-mash of competing and conflicting infrastructure in the modding community is a horror all on it's own though.
I wrote my Minecraft mods (Optimine, MCRegion) directly using the obfuscated source. It's painful, but strangely doable once you accept that the names are arbitrary and meaningless, and look more at the structure of the code itself to guess at intent.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Scaevolus posted:

I wrote my Minecraft mods (Optimine, MCRegion) directly using the obfuscated source. It's painful, but strangely doable once you accept that the names are arbitrary and meaningless, and look more at the structure of the code itself to guess at intent.

That sounds like a very zen coding experience.

Adbot
ADBOT LOVES YOU

Zhentar
Sep 28, 2003

Brilliant Master Genius

astr0man posted:

it is easier to reverse C code than it is C++.

That reminds me of something I wanted to post in here...


I was trying to figure out how something worked in a game, so on a whim I decided to try reversing it...

This was inferred from a single function:
code:
struct god_object
{
  _BYTE f0[32];
  _DWORD dword20;
  _DWORD dword24;
  _BYTE f28[12];
  char *pchar34;
  _BYTE f38[12];
  _DWORD dword44;
  _DWORD dword48;
  _BYTE f4C[4];
  _DWORD dword50;
  _BYTE f54[44];
  _DWORD dword80;
  _DWORD dword84;
  _BYTE f88[308];
  _DWORD dword1BC;
  _BYTE f1C0[244];
  _BYTE byte2B4;
  _BYTE f2B5[3];
  _DWORD dword2B8;
  _DWORD dword2BC;
  _BYTE f2C0[16];
  _DWORD dword2D0;
  _BYTE f2D4[1416];
  _DWORD dword85C;
  _BYTE byte860;
  _BYTE f861[3];
  _DWORD dword864;
  _DWORD dword868;
  _BYTE f86C[4];
  _BYTE byte870;
  _BYTE f871[123];
  _DWORD dword8EC;
  _BYTE f8F0[112];
  _BYTE byte960;
};
A single function referenced 20 members of a 2400+ byte object. Game programmers, man.

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