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
vOv
Feb 8, 2014

ChubbyThePhat posted:

Not a horror but came across this on a random reddit post:

"I like to live dangerously, [ $[ $RANDOM % 6] == 0 ] && rm -rf / || echo Click"

They were looking for something to put on a CS club shirt. I liked this. I laughed.

code:
~> rm -rf /
rm: it is dangerous to operate recursively on ‘/’
rm: use --no-preserve-root to override this failsafe
GNU to the rescue!

Adbot
ADBOT LOVES YOU

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Whether you brace one-liners or not, code that looks like this:

code:
if (someCondition)
    someVeryLongVariableName[withSomeArraySubscripting].andMaybeAMemberAccess =
        somethingElseThatIsVeryLong.andMakesTheLineAsAWhole[excessivelyLong]
should surely be a no-no

xzzy
Mar 5, 2009

Sinestro posted:

What font are you using?



OSX has done Unicode well for a while. The screenshot I posted was a rhel6 based system running KDE.. which is a little more dicey.

I haven't tried it on rhel7 yet, maybe they improved it.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



xzzy posted:

The forums "support" it just fine. You can spam unicode and emoji all you want and it works.

If the characters don't show up, it's your browser or the font you're using.

Since the last re-design it's actually gotten worse. The lambda in my title stopped working (for me on Windows, at least) when that went in, for example :rolleye:

xzzy
Mar 5, 2009

Lamba is showing up on my OSX system.

Get the placeholder on my Windows 10 machine though. I thought Unicode support on Windows was pretty good these days, guess there's some gaps!

Carbon dioxide
Oct 9, 2012

Lambda works perfectly well on my Windows 10.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



It's a web font from Google, so it's mainly their fault. Worked fine for years when it was using system fonts. As usual with web stuff, the more things improve the more broken everything gets.

Anyone know of an extension that'll block web fonts on a per-domain basis?

Vanadium
Jan 8, 2005

NihilCredo posted:

I think I'll start posting tiny horrors from our production codebase once per day and see how long these ~70k LoCs keep delivering.

Let's start with a classic. How do you check if a Decimal variable is negative?

Answer: If quantity.ToString().Substring(0, 1) = "-" Then ...

Our production database uses floating point numbers for things that have no business being floating point numbers. Apparently someone before my time ran into issues with rounding (big surprise), so the currently used rounding function involves a conversion to string, chopping off some decimals and converting back. Now it seems to work as expected. :thumbsup:

Pollyzoid
Nov 2, 2010

GRUUAGH you say?
Works for me on Firefox, placeholder on Chrome, same results with web font (Roboto) enabled or disabled. An issue with Chrome maybe?

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
Chrome has historically struggled with Unicode for god only knows what reason. It wasn't until, what, a few months ago that they finally added support on OS X for emoji? And then right after they rolled that out, the skin tone modifiers came along and those weren't supported correctly either.

The drat frustrating part is that this is all stuff that Just Works in the underlying text APIs on OS X. I guess they have their own layers of stuff on top of those because of the need for cross-platform support and that's what's loving up their text processing, but come on.

xzzy
Mar 5, 2009

All web browsers suck, we should start work on a new one. This time we'll get it right!

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that

xzzy posted:

All web browsers suck, we should start work on a new one. This time we'll get it right!

Pff, are you saying you don't browse by just curl-ing the pagesource?

Space Kablooey
May 6, 2009


ChubbyThePhat posted:

Not a horror but came across this on a random reddit post:

"I like to live dangerously, [ $[ $RANDOM % 6] == 0 ] && rm -rf / || echo Click"

They were looking for something to put on a CS club shirt. I liked this. I laughed.

I'm totally stealing this.

Karate Bastard
Jul 31, 2007

Soiled Meat
PYTHONIOENCODING!!!!

:argh:

e: I am perfectly capable of doing my encoding myself. You keep your grubby paws off my code, Pythonio!

e2: While I'm at it False - True == -1, thanks Python for clearing that up I always wondered.

Karate Bastard fucked around with this message at 20:08 on Oct 22, 2015

necrotic
Aug 2, 2005
I owe my brother big time for this!

Karate Bastard posted:

PYTHONIOENCODING!!!!

:argh:

e: I am perfectly capable of doing my encoding myself. You keep your grubby paws off my code, Pythonio!

e2: While I'm at it False - True == -1, thanks Python for clearing that up I always wondered.

"Booleans in Python are implemented as a subclass of integers."

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Karate Bastard posted:

e2: While I'm at it False - True == -1, thanks Python for clearing that up I always wondered.

This one is true in quite a few languages. False==0, any other value evaluates as true but the True keyword==1. Bool is basically a teeny-tiny enum in many languages.

Karate Bastard
Jul 31, 2007

Soiled Meat

necrotic posted:

"Booleans in Python are implemented as a subclass of integers."

That makes so much sense, and I'm happy they could make that very common use pattern just work by default. There is literally a mountain of code that hinges on boolean arithmetics, and it's real neat that it just blends in with the code rather requiring us to bloat it all up with unnecessary exception handling. I wonder why they didn't go all the way and made all other things subclasses of interegers as well, like colors, and horses? Like, being able to just trust that Red - Turquoise == -8 would be so valuable to me, just like I can now just know that I can increment i by doing i += (None != -1) & (None == None).

xzzy
Mar 5, 2009

Karate Bastard posted:

That makes so much sense, and I'm happy they could make that very common use pattern just work by default. There is literally a mountain of code that hinges on boolean arithmetics, and it's real neat that it just blends in with the code rather requiring us to bloat it all up with unnecessary exception handling. I wonder why they didn't go all the way and made all other things subclasses of interegers as well, like colors, and horses? Like, being able to just trust that Red - Turquoise == -8 would be so valuable to me, just like I can now just know that I can increment i by doing i += (None != -1) & (None == None).

Unfortunately red - turquoise equals dark red (#be1f30).

-8 is just silly.

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that
e^(pi * i) + True == False

Karate Bastard
Jul 31, 2007

Soiled Meat
You are right. Obviously, Red - Turquoise == 12459824. What was I thikning?

Soricidus
Oct 21, 2010
freedom-hating statist shill
It was better in older versions of the language where True and False were literally just variables that you could reassign to anything you liked.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Pavlov posted:

Pff, are you saying you don't browse by just curl-ing the pagesource?

Look at this poser. Telnet to port 80 and type in your GET request.

Karate Bastard
Jul 31, 2007

Soiled Meat

Soricidus posted:

It was better in older versions of the language where True and False were literally just variables that you could reassign to anything you liked.

I love hate love this webpage:

http://mindprod.com/jgloss/unmain.html

code:
#define TRUE 0
#define FALSE -1
#define ONCE 1
#define TWICE 1
#define SSLPROTO http
#define SSLPORT 80

#ifndef DONE
#ifdef TWICE
// put stuff here to declare 3rd time around
void g(char* str);
#define DONE
#else // TWICE
#ifdef ONCE
// put stuff here to declare 2nd time around
void g(void* str);
#define TWICE
#else // ONCE
// put stuff here to declare 1st time around
void g(std::string str);
#define ONCE
#endif // ONCE
#endif // TWICE
#endif // DONE

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Pavlov posted:

Pff, are you saying you don't browse by just curl-ing the pagesource?

Richard stallman detected

KaneTW
Dec 2, 2011

LeftistMuslimObama posted:

This one is true in quite a few languages. False==0, any other value evaluates as true but the True keyword==1. Bool is basically a teeny-tiny enum in many languages.

just because a lot of languages do it doesn't mean it's a good thing

also enums as ints are a travesty and even more so ints as sum types.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Ithaqua posted:

Richard stallman detected

He didn't mention emacs though

Marta Velasquez
Mar 9, 2013

Good thing I was feeling suicidal this morning...
Fallen Rib

ChubbyThePhat posted:

Not a horror but came across this on a random reddit post:

"I like to live dangerously, [ $[ $RANDOM % 6] == 0 ] && rm -rf / || echo Click"

They were looking for something to put on a CS club shirt. I liked this. I laughed.

I put this in the company /etc/bashrc years ago:

code:
[ `date '+%m%d'` != '0401' ] && alias emacs=vim

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that

Ithaqua posted:

Richard stallman detected

I'm pretty sure I read once that Stallman actually requests a remote server to curl the page, and then email it to him.

...Which he opens in Emacs.

JawnV6
Jul 4, 2004

So hot ...

quote:

I generally do not connect to web sites from my own machine, aside from a few sites I have some special relationship with. I usually fetch web pages from other sites by sending mail to a program (see git://git.gnu.org/womb/hacks.git) that fetches them, much like wget, and then mails them back to me. Then I look at them using a web browser, unless it is easy to see the text in the HTML page directly. I usually try lynx first, then a graphical browser if the page needs it (using konqueror, which won't fetch from other sites in such a situation).

I occasionally also browse unrelated sites using IceCat via Tor. Except for rare cases, I do not identify myself to them. I think that is enough to prevent my browsing from being connected with me.
I like that last bit, hiding amongst the vast flock of IceCat via Tor users.

xzzy
Mar 5, 2009

Pavlov posted:

I'm pretty sure I read once that Stallman actually requests a remote server to curl the page, and then email it to him.

...Which he opens in Emacs.

The fun part is that facebook still probably knows his favorite type of porn.

Karate Bastard
Jul 31, 2007

Soiled Meat
Browsing such objectionable pornography, all the time, that Stallman. Hell to have oneself connected with that sort of thing.

Kazinsal
Dec 13, 2011

xzzy posted:

The fun part is that facebook still probably knows his favorite type of porn.

This gets really terrifying when you connect it to the idea that he visits "unrelated websites" through Tor.

Yaoi Gagarin
Feb 20, 2014


quote:

Hungarian Notation is the tactical nuclear weapon of source code obfuscation techniques; use it! Due to the sheer volume of source code contaminated by this idiom nothing can kill a maintenance engineer faster than a well planned Hungarian Notation attack.

This guy knows what's up.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

contrapants posted:

I put this in the company /etc/bashrc years ago:

code:
[ `date '+%m%d'` != '0401' ] && alias emacs=vim

so, on april fools, emacs users can actually use emacs?

Harik
Sep 9, 2001

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


Plaster Town Cop
Oh goodie, I have some code for you guys! This comes from a very large chip vendor that will remain nameless, but I bet someone here will recognize their bad coding style.
code:
void InitDevice(DeviceType * pthisDev) {
        // write 0010 0001 = 0x21 to CTRL_REG1
        // [7-6]: rate_a = 00
        // [5-3]: rate_b = 100 for 50 hz
        // [2] RESERVED = 0
        // [1]: mode = 0 for normal reads
        // [0]: active = 1 to enable
        I2CWrite(DEV_ADDR, DEV_CTRL_REG1, 0x21);

        // same type of comment
        I2CWrite(DEV_ADDR, DEV_CTRL_REG2, 0x01);

        dev->unit_ratio = DEV_TYPE_UNIT_RATIO;
        // .. not too bad so far
}

int ReadFromDevice(DeviceType * pthisDev) {
        unsigned char buffer[12];
        I2CRead(buffer, DEV_ADDR, DEV_READ_ADDR, 12);

        pthisDev->data_raw_a = (buffer[0] << 8) | buffer[1];

        thisDev.data_a = thisDev.data_raw_a * thisDev.unit_ratio;
}
A few different horrors at work - first, the meticulous comment documentation for a magic hex number instead of spending that time turning it into #defines
0x21 should be RATE_A(0)|RATE_B(RB_50HZ)|MODE_NORMAL|ACTIVE; which documents the intent AND isn't fragile as poo poo.

Yes, the assumption that pthisDev is just a pointer to global thisDev is exactly that, so I have no loving clue what they thought they were doing. The entire thing is frustrating as poo poo to follow because of constant pointer/global aliasing issues.

Open-coded byte-stuffing serial transmission scheme because __attribute__((packed)) and HTONS() on a structure was just too difficult. Thank god I can just delete all that poo poo.

It remains to be determined if it'd be faster for me to do the calibration matrix math myself instead of trying to wedge this poo poo into my code. I've already spent an hour cleaning up pointer/global confusion.

xzzy
Mar 5, 2009

Dessert Rose posted:

so, on april fools, emacs users can actually use emacs?

Imagine how surprised they'll be!

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Flobbster posted:

The drat frustrating part is that this is all stuff that Just Works in the underlying text APIs on OS X. I guess they have their own layers of stuff on top of those because of the need for cross-platform support and that's what's loving up their text processing, but come on.

The issue for browsers isn't the cross-platform part; each platform has a full text display implementation written to native APIs, even if it shares a shaping/glyph selection/etc. subsystem. The issue for browsers is that they put demands on text that virtually no system APIs can support, in terms of performance and functionality.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

KaneTW posted:

just because a lot of languages do it doesn't mean it's a good thing

also enums as ints are a travesty and even more so ints as sum types.

i mean, what's the good way to do bools and enums? I'm genuinely curious. When you get right down to it, no matter how you represent it it's going to have some consistent integer value underneath, even if you go to pains for it to be inaccessible. And people will go to further pains to get at that value anyway. So just leave them as ints, imo. Makes coding up console menu options really easy if you want to be lazy and require numerical input :).

Asymmetrikon
Oct 30, 2009

I believe you're a big dork!
code:
type Bool = True | False
If you really need to use a bool as an int,
code:
boolToInt : Bool -> Int
boolToInt True = 1
boolToInt False = 0

Adbot
ADBOT LOVES YOU

TheresaJayne
Jul 1, 2011

xzzy posted:

Imagine how surprised they'll be!

i can't stand emacs,

The best editor i ever saw was an old DOS editor called edit.exe amazing then and todays editors are not even close.

and in linux if i haven't got vi i will not use the system.

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