Mimic, the Evil Script That Will Drive Programmers To Insanity (github.com) 246
JustAnotherOldGuy writes: Mimic implements a devilishly sick idea floated on Twitter by Peter Ritchie: "Replace a semicolon (;) with a Greek question mark (;) in your friend's C# code and watch them pull their hair out over the syntax error." There are quite a few characters in the Unicode character set that look, to some extent or another, like others – homoglyphs. Mimic substitutes common ASCII characters for obscure homoglyphs. Caution: using this script may get you fired and/or beaten to a pulp.
Simple (Score:5, Insightful)
git revert [commit]
"Your commit broke the build. Fix it."
Bonus points if your continuous integration build server catches it automatically.
Then have a talk with the author of this non-sense commit about wasting corporate resources.
Re:Simple (Score:5, Interesting)
Time-delayed or rarely-occurring "evil" can often be better. There's a number of examples here [github.com], although some would be harder to sneak past code review than others. Unless your code review system is lax, or (best) if you have write access to the repository. But some of the aforementioned ideas (or variants thereof) would be just brilliantly evil, to the point that the code works fine when you leave, but say three months later it starts rarely breaking at random times and locations, and the "code plague" just gets more and more common with time.
One case where Mimic could sneak past the compiler (and code review) but still cause problems would be inside strings. For example, there's a number of characters that render like spaces but are actually multibyte unicode characters. Same with dashes, underscores, and many other characters. Using them would cause the length of the string to not be what the user thinks it is. And string operations could accidentally break up the unicode characters. Such errors could slip code review by and cause random inexplicable runtime errors for quite some time. And the nice thing about those kinds of errors are that you can chock them up to accidents. "Oh, I'm so sorry! I was just copying some code off the net, the character must have gotten mucked up..."
Re: (Score:3)
> --
> It's not the 1990s, Slashdot; fix your unicode support. It's ridiculous that I can't type a thorn here.
Bwaa-haa-haa. Maybe they know better than you.
Re: (Score:2)
IOW because they are lazy, incompetent, or both.
Re: (Score:2)
Indeed. I can't write about places where I live or the names of some people I know for example because the characters disappear. It's not that Slashdot gives a warning that they're not allowed - they just silently vanish, so even if you know about Slashdot's "appetite", it's easy to forget / screw up. Yet it's only *some* characters that do that. I can't write a thorn but I can write an eth.... why exactly? And I can't tell you how many times I've written exponents (which my keyboard automatically transl
Re:Simple (Score:5, Insightful)
Besides, anyone here who can honestly say he never did the "magic" thing, i.e. delete a line and retype it only to have it suddenly work for no good reason whatsoever?
I dare say that most programmers would simply delete the offending line and retype it once everything that does actually make sense has been tried.
Black magic. Do it. I get the candles, Fred brings the voodoo doll, you can start chanting.
Re:Simple (Score:4, Informative)
This happens a lot with Russian programmers due to Latin C and Cyrillic Es homoglyphs that happen to be on the same key, and it's very easy to forget which keyboard layout is currently selected and type the wrong letter.
Re: (Score:2)
Re:Simple (Score:4, Interesting)
A few years ago I had a problem when I would use OS X TextEdit to edit code. Somehow, I never figured out how, it would occasionally insert a control-P character into the text. Of course it was invisible. Other than looking at the file in a hex editor, the only way that I could find it was to use the arrow keys and note when the cursor didn't move. Or the error message from trying to compile/assemble the code.
I haven't seen this in a long time, and I currently still use 10.6.8, so maybe it was a problem in 10.5 that got fixed in 10.6.
And I have had other times where I had to retype a visually good line of code more than once. Not to mention the times when the font and my less than perfect eyesight make commas and periods hard to tell apart.
Re: (Score:2)
Re: (Score:2)
Besides, anyone here who can honestly say he never did the "magic" thing, i.e. delete a line and retype it only to have it suddenly work for no good reason whatsoever?
I dare say that most programmers would simply delete the offending line and retype it once everything that does actually make sense has been tried.
Black magic. Do it. I get the candles, Fred brings the voodoo doll, you can start chanting.
It's not black magic at all! It happens all the time with my students: they copy/paste some code from the pdf containing the exercises and then scream for help as the compiler complains. Truth is, they pasted some non-printable characters. When I tell them what happened, that they should never copy/paste code for whatever reason, erase the faulty lines and advise them to type their own version, they almost always seem so disappointed. It's amazing how the young people can be lazy...
Re: (Score:2)
... It's amazing how the young people can be lazy...
And older people can be so intolerant of inexperience.
Re: (Score:2)
But cargo cult programming is not the way out of inexperience. It's the road to ignorance.
Re: (Score:2)
Re:Simple (Score:4, Funny)
Re: (Score:2)
Besides, anyone here who can honestly say he never did the "magic" thing, i.e. delete a line and retype it only to have it suddenly work for no good reason whatsoever?
It's practically standard practice in python coding where you might copy/paste another line which gets converted into tabs instead of 3 spaces or 3 spaces instead of tabs depending on your IDE.
Re: (Score:2)
No, which is why cargo cult programming is shit.
It has become a bad habit of people who think they can code but cannot. Look up the problem they have, find sample code, copy that sample code and do a search-replace to fill in their variables.
That may be at least halfway acceptable if, and only if, they know what they're doing. 9 out of 10 times, they do not. Which not only results in crappy frankensteinian code that looks like someone slapped together a monster out of the corpse of many innocent code pieces
Re: (Score:2)
Besides, anyone here who can honestly say he never did the "magic" thing, i.e. delete a line and retype it only to have it suddenly work for no good reason whatsoever?
Yeah, except for the last part. I always feel like an idiot when it doesn't work. Well of course it doesn't work, I just retyped the same very thing!
Re: (Score:2)
Of course this should only happen if you know for a fact that what you typed was correct. Retyping wrong code, I give you that, is useless.
Re: (Score:2)
It's faster to retype it.
Kids these days and their reliance on their fancy toys... Hex editors...
Re:Simple (Score:4, Insightful)
Then have a talk with the author of this non-sense commit about wasting corporate resources.
Stern talk, as in "Clean out your desk." I would have zero tolerance for childish pranks like this.
Re: (Score:3)
As all of our code was internal, I might have giggled a little if it was done on the dev end (not in production) and on the 1st of April. We were pretty lax during that one day of the year. It hampered productivity but, in return, we got people with honed skills and insights. So, there's that. I don't think they ever used this but they did use others. Before I turned my code over and stopped working on it myself I had an "I'm drunk" menu nested in and unfinished. Fortunately, I hired professionals. They had
Re: (Score:2)
Alternatively improve compilers to warn against these specific symbols or treat them as equivalent?
Re: (Score:2)
That's if someone checks in non-building code, which should happen almost never. After all, rarely is it true it builds on one machine and not another if your build environment is properly set up.
This trick is good for someone who can't seem to get their code to compile for no goo
Re: (Score:3)
What? No.
Do you write your code in MS-Word or something? Do the non-ASCII spaces slip in when you cuntpaste code from web pages that are too stupid to even use <code> tags or some other means to preserve the actual characters?
Hint: stop it. Both of it. You're not doing it right.
spaces that were different ascii codes.
Good grief.
Re: (Score:2)
svn revert and git revert do not do the same thing, conceptually.
svn revert reverts your UNCOMMITTED changes in your working directory.
git revert reverts commits by producing more commits.
Which is one of the annoying things with git, it takes existing terminology and gives it another meaning.
That said, achieving what 'svn revert' does with git is straightforward (git reset --hard), achieving what 'git revert' does with svn is somewhat unintuitive (svn merge -c -<revision> .)
Re: (Score:2)
BTW how are the merges going over in svn-land, mr manager?
We have streamlined our svn merging experience with a webscale cloud enterprise solution giving us low time-to-market and advanced workflow synergies. Why do you ask?
funny. (Score:2)
Re:funny. (Score:5, Insightful)
It's probably funny to people who don't have to earn a living. I expect I'd have considered it hilarious back in high school... but now, if a colleague did this, I'd probably demand he be fired.
Re: (Score:3)
Re: (Score:3)
I work for a university department. We don't have large development teams nor the same formal review process - a lot of times one person will handle a particular project from start to finish. One of my coworkers could, if they chose to, go onto a server and mess with a perl or python script.
Fortunately while I have coworkers that like to joke around, no one would consider this acceptable.
Re: (Score:3)
Having worked in several university settings, I know how small and undisciplined dev teams in academia can be.
Having moved to commercial web development, I also know how easy it is to set up a VCS for a small team.
Once any repo is managed in a VCS (like git and GitHub), it's fairly straightforward to check a project's history and discover when and where the project stopped working as expected.
If you're not using a VCS, you should seriously consider doing so given the small overhead of setting it up and the
Re: (Score:3)
Re: (Score:2)
It's probably funny to people who don't have to earn a living. I expect I'd have considered it hilarious back in high school... but now, if a colleague did this, I'd probably demand he be fired.
It's hysterical.
Yes, on April 1st I would do that to you and replace the ";" on just one of your source files. I would only do it for about 30 minutes or so and chuckle and see if you can find out what I did etc.
Notice I would not do a find and replace all and take a whole project done and miss a deadline. But I do have a sense of humor. If you did it to me I would be amazed and pissed laughing it off at the same time for being super genius. I would not demand you would be fired. Now if you did this for a w
Re: (Score:2)
If my hashes changed in directories I had not touched, I'd call IT ands raise merry hell. You would be found and punished.
Re: (Score:3)
>It's probably funny to people who don't have to earn a living. I expect I'd have considered it hilarious back in high school... but now, if a colleague did this, I'd probably demand he be fired.
Great. You just fired young Steve Wozniak. I heard him talk a couple weeks ago, and the man was an inveterate prankster. He also encouraged all the young kids in the audience to try to think up clever pranks to pull on people as a way of honing their mental skills.
Re: (Score:2)
And it'd be right firing him. He was fantastic when working on his own, on projects he could hold in his head. And while he's as nice as they come, he was not a team player of the kind needed in a project based environment. And he would have hated working in one as well. It'd be a waste of everyone's time to keep him in one.
And then... (Score:2)
Somebody reverts your code.
At least Slashdot will never fall victim to this.
Re: (Score:2)
Somebody reverts your code.
You are assuming this was done through Git. But the best way to pull a prank like this is to paste it directly into a co-worker's editor when they get up to go to the toilet.
Re: (Score:3)
You (well, people like you) are the reason I lock my workstation every time I leave my desk.
Re: (Score:3)
And, really, anybody who doesn't do this at their place of work is probably both violating corporate security policies, and is likely an idiot.
If you're in an office full of people and not locking your computer and your personal items, you are simply asking for trouble.
Not saying trust nobody but ... well, actually, yes. I am saying that a healthy level of distrust is a good idea in general.
Sooner or later someone will reinforce that notion for you.
Maybe before source code control (Score:5, Insightful)
Wouldn't they see your change to the file in the history/blame for the line?
Or do they suggest you hack your co-workers machine to run this script on their system?
Re: (Score:2)
You'd never get to submit the code to the trunk if there's even a minimal build gate for submissions -- it wouldn't compile. So, yeah, it would have to be on someone's computer.
A special hell (Score:2, Funny)
is reserved for these kind of people...
One thing that always drove me crazy... (Score:5, Interesting)
One thing that always drove me crazy was the Unix "make" command because of the syntax of the Makefiles. The problem was, unlike just about every other language, Makefiles distinguish between TAB and SPACE characters, and they can look indistinguishable in printouts. I always avoided make for that reason and just wrote shell scripts to compile my code. I've also stayed away from Python because of its use of indentation to indicate the scope of control structures. Too easy to screw up by mixing tabs and spaces. In many fonts used in early terminals and printers, zeros were drawn with a slash through them so they wouldn't be confused with uppercase O's. Now with Unicode replacing ASCII as the encoding for source code in most languages, let the nightmares begin!
Re: (Score:2)
Example [sublimetexttips.com]
Re: (Score:3)
Re: (Score:2)
Emacs highlights space/tab related errors in its Makefile mode. I believe vim does the same.
Re: (Score:2)
Re: (Score:3)
vim :set list
nano Alt-P
(note: I sometimes use vim, I only googled nano)
Re: (Score:2)
vim: set listchars=tab:>.,nbsp:.,trail:.
Re: (Score:2)
vim: set expandtab
vim: set tabstop=4
Is what i have on every computer i use with vim. That way when i hit the tab key I get 4 spaces and never need to turn on highlighting. I'm normally doing something in python, where that's the convention anyways.
Re: (Score:2)
Git filters can convert tabs to spaces automatically (or vice versa); chances are your editor (or a plugin) can too. Unicode may be a bit more challenging, but I'd suggest an office policy that anyone who uses unicode outside a string gets impaled on a rusty lawnmower blade.
Re: (Score:2)
Git filters can convert tabs to spaces automatically
Shockingly, not everyone uses git (even if they should).
Even more shocking, a fair number of small code shops don't use any kind of real version control software (even if they should).
I don't think this was meant to be a tool to subvert code, just a sneaky way to piss off coworkers. That said, I'd never mess with this thing in any kind of actual work environment.
Re: (Score:2)
I just committed code with unicode characters in it for the first time. I've been programming since the '80s. It was for a test. It still made me feel dirty :-)
Re: (Score:2)
What about comments? Greek character are very useful in comments.
Right! Anyone who uses unicode outside of strings and comments gets impaled on a rusty lawnmower blade.
Re: (Score:2)
Re: (Score:2)
In my freshman year of college, before I knew anything about Unix-like operating systems, we were forced to program C exercises in a text editor that actually represented SHIFT-SPACE as a different character than SPACE. The character looked no different than space, but broke the compiler.
And of course, the C compiler told us something completely useless, like "missing parenthesis at end of file", which had no correlation at all to where the erroneous character resided.
I can't tell you how many times I had
Good to know (Score:2)
That is certainly good to be reminded of. In case of weird errors, pass your code through something that checks for characters beyond ASCII.
In fact, I am often bitten by something similar on Macs: when typing the pipe character on my keyboard (Alt-7), followed by a space, I end up typing Alt-space, which ends up as a nicode non-breaking space or something. It took me a while to get used to and understand the error saying "-bash: grep: command not found".
Bad compiler, then (Score:4, Informative)
My students regularly copy-paste from an otherwise excellent source in which plain vertical double quotes have been auto-replaced with pretty slanted quotes. GCC complains about the illegal character on line XXX, I usually have to explain, and that's it. No hair-pulling involved, only git pulling.
remember nonstandard Latin 1 symbols (Score:2)
Re: (Score:2)
the non-standard MS symbols, which still hunt me sometimes
This sounds like a case for gun-emoji control.
I code in ASCII (Score:3)
Unicode in code is for people that do not understand what they are doing.
Re: (Score:2, Flamebait)
Unicode in code is for people that do not understand what they are doing.
This. To me it's the same argument as keeping domain names in plain ASCII -- portability. If I cannot type a domain name on any random keyboard, then it has no place on the _inter_net. Code should be similarly universal for a number of reasons, even if it's restricted to one organization; it's like math notation.
(My native language has a few non-Latin characters and I also use Hanzi occasionally, but I like having some common ground with other people.)
Re: (Score:2)
Math notation is a good analogy.
Re: (Score:2)
ironic, then, that most math letters/symbols can't be typed in ASCII.
Re: (Score:2)
not everyones' alphabet fits in the ASCII codeset.
Re: (Score:2)
Ever heard of escaping things? Apparently not. Sane languages do not even allow you to use Unicode in source code and sane compilers reject it.
Syntactic salt to force i18n (Score:2)
Then a sane language would not allow strings in the source code to be presented to the user, as a string presented to a user might contain characters outside US-ASCII. I'm curious what sort of syntactic salt your preferred language has to force developers to use internationalization best practices.
Everyone has already figured out (Score:2)
that Revision Control instantly beats this bullshit.
Nice try ... (Score:4, Funny)
Re:Nice try ... (Score:5, Insightful)
Mimic, Script To Mildly Inconvenience Programmers (Score:2)
SomeScriptKiddie writes:
Mimic rehashes an old idea that we all thought died out with MSN: "Replace normal characters like a semicolon (;) with a Greek question mark (;) in your friend's batch files and watch them pull out the previous branch from version control." There are quite a few characters in the Unicode character set that look, to some extent or another, like others – so almost homoglyphs, but not quite. Mimic is a horribly convoluted implementation of what is essentially search & replace. Caution: using this script may get you laughed at and/or promoted to entry level computer hardware mover.
Re: (Score:2)
promoted to entry level computer hardware mover
If it's up to me, the new title will be "exit-level developer".
Re: (Score:2)
Well, once you suspect it, it's easy to detect. Just use a font that only displays in ASCII.
What's old is new again (Score:2)
In the late 1980s as a student I spent several hours feverishly debugging an inscrutable syntax error on a green monochrome monitor at a school lab. I just managed to make the deadline, because on that crappy monitor with its crappy font, ( and { looked too much alike. This took enough time away so that I lost points for not properly formatting my output; but at that point I was happy just to *have* output.
Never undstood this crap (Score:3, Interesting)
Re: (Score:3, Insightful)
The symbols are visually identical but have different meanings. For a human reading the text, with the human understanding of context and the weird, fuzzy logic that our brains do, that's not a problem. For a computer processing the text, however, it is important to be able to distinguish a semicolon (sentence not finished, or end of coding line, or terminator in a list containing commata) from a Greek question mark (interrogative sentence finished), especially in a text mixing Greek and Latin or English
Re: (Score:2)
I think his point was, if the glyph is visually indistinguishable, why is there another character in unicode for it?
Re: (Score:2)
Probably because it's trying to avoid ambiguity with computers reading the texts eventually. This doesn't really answer the question, given that it might have been more sensible to set it so glyphs with the same meaning shared a code point, and you treated any variations as alternate forms of it, which is something the Unicode standard seems to have already though I've no idea how well it works nor how well-supported it is.
Re: (Score:2)
Re:Never undstood this crap (Score:4, Interesting)
See: Han Unification, and all the problems it's caused. Because of this, the Japanese need to jump through hoops if they wish to write a Chinese name in an otherwise Japanese section of text. Since few other western languages have this problem, many Japanese were rather upset at this decision of the Unicode consortium.
TL;DR: Semantics matter.
Re:Never undstood this crap (Score:5, Funny)
Han Unification:
Han shot at the same time.
-
Re: (Score:2)
Bullshit. Most character are nearly identical.
I never said they weren't. But the ones that aren't can cause problems, not just in theory, but in everyday life [vengaglobal.com]. You counter with "but you wouldn't want to do that anyways", which is a pretty lousy way to defend a broken system. It's particularly problematic when trying to preserve the characteristics of writing in historic or scholarly works.
Again, bullshit. Western language render foreign names using different characters far more frequently than Japanese/Chinese.
No, you misunderstand. I'm saying western scripts don't have a *problem* when trying to do so, unlike in Japanese scripts with embedded Chinese names. You can
Re: (Score:3)
That's what they currently do. Japanese and Koreans just use a special font which renders the characters the way their language draws the glyphs. But that's ultimately a rather poor solution - essentially no better than what we used to have to do with code pages, where the text needed language metadata to render properly.
Let's take your example of the letter "A". What would happen if both the Latin A and Greek Alpha mapped to the same code point? Would you consider those equivalent? They have similar h
Re: (Score:2)
I understand perfectly that other languages have different symbols. But when those symbols are effectively identical to an existing symbol, JUST USE THAT SYMBOL.
Well said! And this should apply as well to the "smart quotes" non-sense. If you want a quote, just store a quote, and nothing else.
Re: (Score:2)
Plus, when you can support a huge number of characters, why /not/ support every character?
Because then, some idiotic software will start "helpfully" substituting one variant of the character by the other. And no, I'm not thinking here about this mimic or other similar prank-ware, but about "well-meaning" applications such as Microsoft Office and Wordpress.
How often have I wondered in the last couple of years why some apparently correct shell-script pasted from a Wordpress blog or Microsoft Office user manual was not working as expected? Yeah, these softwares replace quotes, dashes and other ass
It wouldn't stump me for very long (Score:2)
This would only work on people who don't understand how syntax errors work. Any time an error occurs that I feel is impossible I examine the ordinal values of the characters, or I will delete and retype the line. No real programmer is going to be stumped by this for longer than 5 minutes.
I'm old enough to remember... (Score:2)
...when editors were so very incompetent at displaying non-printing characters that "try deleting the line and retyping it" was a standard debugging technique. It worked often enough to stay in the toolbox. (Helping this was one compiler bug that occasionally wrote into the source file.)
I like to think that we have passed that stage. For many years, I believe that was true. Perhaps the dark times are about to return.
Some things are eternal, though; if you're editing machine code in hex or octal, you're prob
This is news??? Old, old, old trick. (Score:2)
1976 - Our high school ran time shared BASIC on a PDP-8. We wrote a program that would read in a program source file, and randomly replace one or two zeros with letter O, commas with semi colons and round brackets with square brackets. Not all of them, just a few. Drove our well deserving victims nuts.
A classic trick, but hardly new.
This is why we can't have a nice civilization (Score:2)
Values of "destroy" range from petty theft, vandalism, gaming the system, being a jerk, apathy and sloth, active sabotage, and outright war.
Be nice, even if nobody is watching. Looters should be shot.
Re: (Score:3)
It's important that children destroy: It teaches them that they're an influence on the world around them & they have impact.
Then at some later point they should be taught (or just realize) the value of creating over destruction.
This kind of thing is for people who never make it fully through that 2nd psychological development step.
Why go that far? (Score:2)
real issue (Score:2)
It's funny or not, but it does illustrate a real problem. We've seen the discussion about whether or not URLs should have unicode support. Yes it's nice to non-western languages. But it introduces the same kind of problems and suddenly you are not on the website you think you are on anymore.
The more I look at it, the more I decide that Unicode is simply evil.
The idea is as old as computers... (Score:2)
So we made a DOS TSR program that hooked in the keyboard interrupt, and if it detected that it was called from Turbo Pascal, and that the sequence for compilation was keyed in, it would locate Turbo Pascal's editor buffer and randomly change a couple of semicolons to colons.
This was both annoying as hell (plenty of syntax errors), and diffi
it is called a 'hex' editor. (Score:2)
the oldest solution to this 'mimic bug' is a hex editor. also many 'reveal codes' in complex word processors will show the actual data as to which character is in use, it is only the novice who are going to be tricked by this stuff!
Re: (Score:2)
Re: (Score:2)
Semi-related: Back when Windows XP was new and LAN parties were still a thing, *that* was a party: http://ms.demo.org/98/ [demo.org] we are (were) family ...
Re: (Score:2)
https://www.youtube.com/watch?... [youtube.com]
Re: (Score:2)
\xFF is no-break space in CP 437. It looks identical to ascii \x20 space. But I assure you Turbo C and djgpp think of it very differently.