HNHacker News
TopNewBestAskShowJobs

DCoder

1,260 karma · joined November 2, 2009

not here anymore
submissionscomments
DCoder··on Why is European broadband faster and cheaper? Blame the government
Lithuania here - 25 pounds/month gives me unrestricted 100 Mbps, next month they're tripling all speeds for no additional costs. The one-step-cheaper option is 90% of the cost for only 10% of the speed, so I opted for this one instead.
DCoder··on Google discontinues support for IE7 in Google Apps
If web page "has nothing except JavaScript" (e.g. GMail) is probably is web app and indexing it makes little sense anyway.

What about JS frameworks like JavascriptMVC or Sammy [1]? Google even created a spec [2] for crawling such sites.

[1] http://sammyjs.org/ [2] http://code.google.com/web/ajaxcrawling/docs/getting-started...

DCoder··on These are things in PHP which make me sad
Missed one:

    foobar() is the same as FOOBAR()
    $foobar is completely separate from $FOOBAR
DCoder··on Game made using only CSS
More pure CSS minigames can be seen at http://www.cssplay.co.uk/menu/ , under Puzzles.
DCoder··on How decompilers work
The decompilation quality really depends on how obfuscated the original code was, and how much time you care to invest. For example, I'm using Hex-Rays to decompile Command & Conquer: Red Alert 2 and extend it, and now its output looks like [1] , which is a lot better than raw assembly menemonics. Though I've been digging into this game since late 2008, which is a long time.

[1] http://img824.imageshack.us/img824/1188/hexrayscpp.png

DCoder··on The 10 commandments of good source control management
Thanks for the ideas. However, in this case the DLL relies on MSVC for binary compatibility with its host, and the version control server is a *nix box.
DCoder··on The 10 commandments of good source control management
Compilation output does not belong in source control

I've seen this before, but never found a suitable alternative. Where does it belong? Suppose multiple developers are compiling a C++ .dll which testers are grabbing through websvn and testing. To track down crashes they get, we need the associated .pdb for the right revision. Where should these files be kept? In a plain folder where each revision gets its own subfolder named as the revision number? That means updating two separate locations with each build, using two different interfaces...

DCoder··on Great Unsolved Problem In Computer Science
Were those recurring meetings or one-offs?

Part of a product I'm working on now is being able to schedule repeating tasks every day, every month, etc. Which means that "07:30 every Friday" has to happen at 07:30 in the author's timezone, whether or not DST is active. To my knowledge Javascript can only tell you the timezone offset from UTC for a given date/time. You can determine the DST-less offset that way, but there are multiple timezones sharing the same offset (e.g. PHP has 63 separate timezone records for Europe alone) and then simply matching them by offsets doesn't work ideally, you need the user to make a choice.

DCoder··on Using client-side storage, today.
Google Gears still works on Firefox 3.x and IE 8, and can be used to emulate WebSQL. It doesn't support async queries, but it's still a good alternative.
DCoder··on Most common one-line bugs in C?
That sounds like something http://tenaciousc.com/ can help with.
DCoder··on Programming Question: When X != X?
SQL NULL. Javascript NaN.

Their behaviour is defined by the standards and special checks are required to identify these values properly. In SQL, it's

  X IS (NOT) NULL
, in Javascript it'd be

  isNaN(X)
.

rand() (well, most of the time[1]). This you just have to know :)

Improperly expanding C macros:

  #define isupper(c) ((c) >= 'A' && (c) <= 'Z')
  #define X isupper(getchar())
  printf("X == X = %d\n", X == X);
And like lurker14 said, anything in general that has side-effects.

[1] It is possible rand() will return the same value twice in a row, just not very likely. Also the original author might have been twisted enough to memoize it. Thank you, "Higher order Perl", for that idea.

DCoder··on First dump of Anon BofA Documents is up
Well noticed! I wasn't able to look at the images earlier (at work), but at least this image http://bankofamericasuck.com/wp-content/uploads/2011/01/boa1... is interesting - the email is timed March 11, but it's in the January folder. Wordpress doesn't let you upload new versions of the same image, so it can't be that... Which makes it look like a pre-scheduled hoax?
DCoder··on First dump of Anon BofA Documents is up
Draft post was written back in January, probably, and the files in /03 were only added recently. Wordpress can split uploaded files into this folder structure automatically based on upload time.
DCoder··on [dead]
I don't think you're doing this right. The first .then receives a function, but the second .then executes function.apply at construction time and receives only its result (null) as the callback.

Also, after understanding what's going on, existing solutions might be better than rolling your own: http://api.jquery.com/jQuery.proxy/ .

DCoder··on Can you use PHP without frameworks nowadays?
It's not just Apache you need to configure - PHP ignores Apache's directory access configurations entirely, you need open_basedir and preferably something like suPHP.

Disabling shell functions (system, exec, etc.) is also a good idea, unless the application itself requires them (e.g. if the host is too stupid/lazy to have the imagick extension installed and tells you to call /usr/bin/imagick instead...).

DCoder··on Can you use PHP without frameworks nowadays?
Sure you can, but why would you want to? Reinventing the wheel is not fun.

A colleague pointed me to Yii Framework [1] a couple years ago, and I stopped looking for alternatives. Don't see any reason to invent my own frameworks, since Yii has practically every feature I could want already implemented and, more importantly, well tested. In those rare cases when I need to customize or extend something, it's fairly simple to do so, since the code is well documented and organized (though the authors seem to be suffering from a severe allergy to whitespace...).

Controllers with access control rules and filters? Check.

Autoloading? Check.

Caching with support for multiple mechanisms (file cache, db cache, eAccelerator, MemCache, XCache, Zend Data Cache)? Check.

DB layer based on PDO? Check.

ActiveRecord? Check.

Mass attribute assignment to Active Record, complete with validation and allowed/forbidden attribute configuration)? Check.

Named scopes? Check.

Multiple database engine support (MySQL, MSSQL, Oracle, SQLite, PostgreSQL)? Check.

Testing environment? Check.

CLI mode? Check.

I18N support? Check.

Plain PHP views with simple HTML escaping and HTML construction? Check.

Event raising and handling? Check.

[1] http://www.yiiframework.com/

Edit: However, no framework can take away the programmer's stupidity. My former colleague used another framework that has decent support for parametrized queries and still concatenated his SQL from raw user input and printed data into javascript variables by simply wrapping it in '' with no escaping... So glad all of his code has been retired.

DCoder··on Stuxnet is now on GitHub
Thanks for the link! You were correct, the quality is noticeably better: https://github.com/Laurelai/decompile-dump/blob/master/outpu... vs http://img715.imageshack.us/img715/1051/hexraysstx.png
DCoder··on Stuxnet is now on GitHub
I've seen HexRays do the same thing - most of the time you need to actually tell it that a variable is a pointer before it tries to do that.

Stating the function type explicitly also helps it display the right arguments given to it. This output could be significantly improved if the assembly version were available as well.

DCoder··on Stuxnet is now on GitHub
This looks like the output of HexRays [1], which is the best C decompiler I've seen. Defining some structures and typing the variables would make it a lot more readable in some cases. I've used HexRays to make sense of C++ games several times, after investing enough time to define and use data types, the result looks [2] much better, but then again, that's unobfuscated and not optimized C++, not old-school "I know what I'm doing and I don't need the compiler second-guessing me" C.

Unfortunately there's still a lot decompilers can't do, mostly compiler tricks (e.g. storing a pointer to the middle of a structure instead of its beginning, and using negative offsets to access other struct members [3] - this is usually obvious when looking at it, but HexRays can't make sense of it so it falls back to raw pointer math).

[1] http://www.hex-rays.com/ [2] http://img824.imageshack.us/img824/1188/hexrayscpp.png [3] https://github.com/Laurelai/decompile-dump/blob/master/outpu...

DCoder··on How debuggers work: Part 1
Consider this sequence:

     0041301E  33 D2     xor edx, edx
     00413020  83 E8 02  sub eax, 2
     00413023  74 01     jz loc_00413026
     00413025  4A        dec edx
     00413026  ...
Without a single-byte int 3, a break on dec edx will mess up everything if that branch is not taken.
DCoder··on How debuggers work: Part 1
In x86 assembly (and a lot of other contexts), 16 bits are called a word (a left over from 16 bit days when 16 bits were in fact a machine word), and larger data types are named dword (double word, 32 bits), qword (quad word, 64 bits), and so on. This terminology is even included in certain instruction mnemonics (movsb|movsw|movsd, ...).
DCoder··on My, what strange NOPs you have!
Nowadays MSVC supports the /hotpatch command line option, which inserts fillers like "mov edx, edx" or "lea edi, [edi]" at the start of each function for the same purpose.
DCoder··on 20 Words from Around the World With No Single-word English Equivalent
Seems relevant:

The Korean concept of Han, as explained by The West Wing: "There is no literal English translation. It's a state of mind. Of soul, really. A sadness. A sadness so deep no tears will come. And yet still there's hope."

http://en.wikipedia.org/wiki/Han_%28cultural%29

DCoder··on 20 Words from Around the World With No Single-word English Equivalent
In Russian it's also called "mayak" (literally 'beacon').
DCoder··on CSS3 - A Practical Introduction
The presentation is nice, but I strongly disagree with the author's chosen method of drawing browser icons:

  .browser-support dd:nth-of-type(3) { background-image:url("img/opera-logo.png"); }
  .browser-support dd.no-support:nth-of-type(3) { background-image:url("img/opera-logo-white.png"); }
And looking at the calculated width example reminded me of the box-sizing property [1], which would simplify that particular use case.

[1]: http://www.w3.org/TR/css3-ui/#box-sizing

DCoder··on How script kiddies turns Linux box into a Zombie - True Story
"Let's execute command 382 to see what it does."

Oy. Not the best idea, generally speaking.

Edit: I used to read the localized paper version of http://xakep.ru/ several years ago, and practically every hacking story/tool roundup they had mentioned the annoying problem with ls --color, it was apparently present in almost every public rootkit at the time. It's kinda interesting to see that idiots still use outdated tools years later.

DCoder··on Ask HN: How do you deploy your PHP apps to production?
For hosts that support git, I simply clone/pull updates from a central repos.

For hosts that don't (i.e. we used to have one project running on a Windows server with nothing but Remote Desktop access and no permission to install any VCS), I use this:

    alias gdate=date\ +%Y.%m.%d-%H.%M.%S
    gitzip () { zip -ruv "$(gdate).zip" $(git diff $@ --name-only); }
Invoking `gitzip $commit` produces a zip file containing all the changed files since said commit. Unzip archive to wwwroot, check for files that need to be deleted, done.
DCoder··on Spades and Men
Some background: This was written by a defected Soviet military intelligence officer Victor Suvorov: http://en.wikipedia.org/wiki/Victor_Suvorov .

Suvorov wrote a lot of books exploring WWII and demonstrating large amounts of evidence for his "Icebreaker" theory, claiming that Stalin intentionally led Hitler to power, planning to occupy Europe after Nazis and the Western countries were both weary and weakened. The theory has a lot of vocal opponents, but Suvorov never misses a chance to point out that most of them are (paid by) Soviet political/military figures, who are obviously biased and would never admit such a plan. It's a shame that these books are not all translated to English.

He also wrote two memoir books, (Tales of a) "Liberator", describing his service in the Soviet regular forces, and "Aquarium", covering the period after he got noticed by and accepted into the intelligence forces. The first one contains some rather fascinating stories of everyday Soviet life and dogma, well worth a read if you can find it. The second one is also good, even though it lacks those everyday stories.

Summa summarum, the book OP linked to is an interesting view into the old Soviet thinking. Might be an eye opener for those who believe the Soviets were anywhere near as humane as the Western countries.

DCoder··on Historians rethink key Soviet role in Japan defeat
He had nothing to do with the Stalingrad breakthrough, and he wasted two whole tank armies in Berlin because he was too daft to see that narrow, barricaded and rubble-filled streets are not the best place for tanks. Such a great guy.

Excusing the Russians' war atrocities simply because they beat the Germans is quite like picking the frying pan instead of the fire - they are both very bad, just one is somewhat worse than the other. (Then again, I'm from the Baltic states, where we were actually stuck with the Russians until 1990, so I am probably biased.)

Did the Nazis have long distance bombers that could actually destroy the industrial complexes in Ural or further to the East? I am not aware of any.

DCoder··on Historians rethink key Soviet role in Japan defeat
No, he was a guy who

- carried out his orders blindly and without thinking ( see http://en.wikipedia.org/wiki/Battles_of_Rzhev where he blindly sent several hundred thousand troops into fortified German position - if you send your forces up the same road for two months straight without gaining any advances, wouldn't you at least try to find an alternate route that the enemy doesn't expect you to use? ) ,

- was very hungry for fame and glory (I can't find references now, but it was his initial reports to higher command during the first few days after 1941-06-22 that led Stalin to believe the German invasion was already mostly contained and delayed Russian defense deployments. In addition, Stalin demoted Zhukov later, citing "attributes others' achievements to himself" as a significant reason.), and

- was generally vain, sadistic and incompetent. Several high ranking officials and civilians reported his attitude towards his subordinates as nothing less than disgusting.

- He was also in charge of Totsk nuclear testing ( http://www.johnstonsarchive.net/nuclear/radevents/1954USSR1.... ), where he had over 40k soldiers split into two teams and engage each other moments after a nuke had been detonated above the battlefield.

Also, he had nothing to do with the German defeat at Stalingrad - he was still too busy headbutting Rzhev: http://en.wikipedia.org/wiki/Battle_for_Velikiye_Luki_(1943)

For more details, I suggest looking up Viktor Suvorov's "Shadow of Victory". And other Suvorov's books for a different view of WWII in general.

← PreviousPage 14 of 16Next →