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
Suspicious Dish
Sep 24, 2011

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

This reads like someone arguing against FORTRAN in favor of assembly in the 60s.

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

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




Am I reading it wrong or does he think most CSS is used for typography?

Suspicious Dish posted:

This reads like someone arguing against FORTRAN in favor of assembly in the 60s.

I just assume that every time he looks around his bathroom at home he wonders why there's a toilet, sink and bathtub when the tub is perfectly capable of doing the work of all three.

E: maybe not the best analogy, but I definitely had the same thought while I was reading it before I saw the date.

Munkeymon fucked around with this message at 21:15 on Sep 12, 2014

Westie
May 30, 2013



Baboon Simulator

eithedog posted:

It struck me as hilarious that I've seen a CSS rule spanning over 500 lines. Then I continued on drinking.

streetlamp posted:

i need to see this piece of art

I dunno if this is what eithedog was referring to, however I do recall him enjoying it when he saw this:

Westie posted:

Also, a site went live today. And uh, things weren't going that easily so I decided to have a look at the selectors to see what was going on.

code:
.hero-head .sections .unstyled li.regular-giving,
.hero-head .sections .grid-block li.regular-giving,
.hero-head .sections .tabs li.regular-giving,
.hero-head .sections .inherit-flexslider .slides li.regular-giving,
.inherit-flexslider .hero-head .sections .slides li.regular-giving,
.hero-head .sections .inherit-flexslider .slides-nested li.regular-giving,
.inherit-flexslider .hero-head .sections .slides-nested li.regular-giving,
.hero-head .sections .flex-direction-nav li.regular-giving,
.hero-head .sections .flex-control-nav li.regular-giving,
.hero-head .sections .primary-navigation .dropdown-small .nav-grid li.regular-giving,
.primary-navigation .dropdown-small .hero-head .sections .nav-grid li.regular-giving,
.hero-head .sections .primary-navigation .nav-column div ul li.regular-giving,
.primary-navigation .nav-column div .hero-head .sections ul li.regular-giving,
.hero-head .sections .primary-cause-widget #homebanner ul.slides li.regular-giving,
.primary-cause-widget #homebanner .hero-head .sections ul.slides li.regular-giving,
.hero-head .sections .primary-cause-widget #home-banner-controller ul.slides li.regular-giving,
.primary-cause-widget #home-banner-controller .hero-head .sections ul.slides li.regular-giving,
.hero-head .sections .how-to-help ul.feeds li.regular-giving,
.how-to-help .hero-head .sections ul.feeds li.regular-giving,
.hero-head .sections .client-project-feeds ul.slides li.regular-giving,
.client-project-feeds .hero-head .sections ul.slides li.regular-giving,
.hero-head .sections .emergency-content ul.feeds li.regular-giving,
.emergency-content .hero-head .sections ul.feeds li.regular-giving,
.hero-head .sections .timeline .content > ul li.regular-giving,
.timeline .hero-head .sections .content > ul li.regular-giving,
.timeline .content > ul > li div.more-images .hero-head .sections ul li.regular-giving,
.hero-head .sections .image-gallery.widget-2 ul.thumbs li.regular-giving,
.image-gallery.widget-2 .hero-head .sections ul.thumbs li.regular-giving,
.hero-head .sections .section-info ul li.regular-giving,
.section-info .hero-head .sections ul li.regular-giving,
.hero-head .sections .project-slider.v-categories ul.slides li.regular-giving,
.project-slider.v-categories .hero-head .sections ul.slides li.regular-giving,
.hero-head .sections .media-navigation-main ul li.regular-giving,
.media-navigation-main .hero-head .sections ul li.regular-giving,
.hero-head .sections .comment-section .comments-list ul li.regular-giving,
.comment-section .comments-list .hero-head .sections ul li.regular-giving,
.hero-head .sections .pub-search .grid-control ul li.regular-giving,
.pub-search .grid-control .hero-head .sections ul li.regular-giving,
.hero-head .sections .pub-search .search-listing ul li.regular-giving,
.pub-search .search-listing .hero-head .sections ul li.regular-giving,
.hero-head .sections .pagination ul li.regular-giving,
.pagination .hero-head .sections ul li.regular-giving,
.hero-head .sections .primary-content-section .children-sponsored ul li.regular-giving,
.primary-content-section .children-sponsored .hero-head .sections ul li.regular-giving,
.hero-head .sections .news-holder ul li.regular-giving,
.news-holder .hero-head .sections ul li.regular-giving,
.hero-head .sections .document-listing ul li.regular-giving,
.document-listing .hero-head .sections ul li.regular-giving,
.hero-head .sections .donation-type .container > ul li.regular-giving,
.donation-type .hero-head .sections .container > ul li.regular-giving,
.hero-head .sections .primary-content-section .donation-stats ul li.regular-giving,
.primary-content-section .donation-stats .hero-head .sections ul li.regular-giving,
.hero-head .sections footer.primary-footer ul li.regular-giving,
footer.primary-footer .hero-head .sections ul li.regular-giving,
.hero-head .sections .left-navigation nav ul li.regular-giving,
.left-navigation nav .hero-head .sections ul li.regular-giving,
.hero-head .sections .primary-content-section .content-blurb ul li.regular-giving,
.primary-content-section .content-blurb .hero-head .sections ul li.regular-giving,
.hero-head .sections .listings.more-challenges ul li.regular-giving,
.listings.more-challenges .hero-head .sections ul li.regular-giving,
.hero-head .sections .listings.user-challenges ul li.regular-giving,
.listings.user-challenges .hero-head .sections ul li.regular-giving,
.hero-head .sections .listings.generic-listing > ul li.regular-giving,
.hero-head .sections .contact-us .social-identity ul li.regular-giving,
.contact-us .social-identity .hero-head .sections ul li.regular-giving,
.hero-head .sections .contact-info-box ul li.regular-giving,
.contact-info-box .hero-head .sections ul li.regular-giving,
.hero-head .sections .register-template .social-identity ul li.regular-giving,
.register-template .social-identity .hero-head .sections ul li.regular-giving
{
    background-color: #FFF;
}
I've protected the guilty in some parts of it, but this is the only bit of that selector that will ever get matched:

code:
.hero-head .sections .unstyled li.regular-giving
This is repeated a grand total of 8 times, replacing 'regular giving' with different names. The CSS file is now just under 500kb, where usually for our framework it ends up at about 300kb.

And yes, that was the only instruction - to set the background colour to white.

canis minor
May 4, 2011

Munkeymon posted:

Am I reading it wrong or does he think most CSS is used for typography?

He thinks that it's 20 years ago. Another thing about it, is that it's not even valid HTML. Where are his closing tags? Not one </p>, no </html> :(

streetlamp posted:

i need to see this piece of art

Generated in LESS - somebody forgot what a given macro does and how does it expand, and didn't notice until we looked at the loading times of the page and why this CSS file weights... some (did any of you see CSS files that weighted ~1MB?). It didn't help much that the containers had all names like "div.communications-module-1-container" or that the CSS folks used it as "body.main-body-container > div.main-content-container > div.left-sidebar-container > div.left-sidebar > div.left-sidebar-first-menu-container" etc.

Unfortunately it ceased to be, but don't worry, next time (and there definitely be a next time) I'll save it to wonder what causes people to do that. I don't know if it's hate or just not bothering.

canis minor fucked around with this message at 21:57 on Sep 12, 2014

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

ExcessBLarg! posted:

There's also the problem where the world runs on a shitload of legacy software. Can you run a legacy C library in this environment? If so, does it still protect you against all the traditional C-language vulnerabilities for which we've spent decades hardening traditional kernels? If either answer is no, yeah, you're not going to get wide adoption.

True enough; I thought it would be interesting to support running legacy code or VMs in this kind of environment, but make them live in ring 3 with traditional memory protection and have a ring 0 VM manager/proxy handle messages on their behalf.

Not that I have the time, knowledge, or inclination to write an operating system... I just downloaded the Singularity public release and played with it in a VM and poked at the source a bit.

Suspicious Dish
Sep 24, 2011

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

eithedog posted:

He thinks that it's 20 years ago. Another thing about it, is that it's not even valid HTML. Where are his closing tags? Not one </p>, no </html> :(

That's valid HTML. Closing tags of certain elements are optional, and that has been part of the spec for a long time.

Munkeymon
Aug 14, 2003

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



I have a grammar horror to report. What's the opposite of active?

If you answered
CSS code:
.deactive { }
You win!

And, no, this wasn't a misspelling of 'deactivate', it's used as the inverse of .active but good thought.

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

Suspicious Dish posted:

That's valid HTML. Closing tags of certain elements are optional, and that has been part of the spec for a long time.

Well there's a lot of valid stuff that isn't necessarily the best way to go about it.

Example:
bool foo = items.Count > 0 ? items.Count == 1 ? true : false : true ad nauseum.

XHTML has it right with closing tags imo.

vv And yes

Knyteguy fucked around with this message at 23:25 on Sep 12, 2014

canis minor
May 4, 2011

Suspicious Dish posted:

That's valid HTML. Closing tags of certain elements are optional, and that has been part of the spec for a long time.

The pedant in me will disagree :sterv:

(to be fair I always treated HTML documents as XML, and, as such it would be an irk to have malformed nodes... - the more you know, I guess)

Suspicious Dish
Sep 24, 2011

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

eithedog posted:

(to be fair I always treated HTML documents as XML)

Too bad your browser doesn't, and neither does the WHATWG.

ExcessBLarg!
Sep 1, 2001

Ender.uNF posted:

True enough; I thought it would be interesting to support running legacy code or VMs in this kind of environment, but make them live in ring 3 with traditional memory protection and have a ring 0 VM manager/proxy handle messages on their behalf.
That's awfully a lot like microkernels running with a monolithic BSD service daemon. Next step is to cut out the microkernel.

Yeah, it's interesting stuff to think about, it's just too hard to move to towards.

I'm actually kind of amused we're doing the opposite now: writing applications against VMs hosted inside strict sandboxes (web browsers) that use a lot of message passing (in the form of REST calls). All of which is built on top of a base of probably-insecure-but-getting-better system and UI libraries that date back 30 years. And they said microkernels were slow.

qntm
Jun 17, 2009

eithedog posted:

The pedant in me will disagree :sterv:

(to be fair I always treated HTML documents as XML, and, as such it would be an irk to have malformed nodes... - the more you know, I guess)

There was a brief time when I served my website with a Content-Type: application/xhtml+xml HTTP header, which forces browsers to treat the payload as strict, correct XML or else display a parsing error. But even though my website has perfect XHTML markup (even the comments, thanks to draconian input validation), several moderately obscure browsers refused to render it as a web page, and I had to revert it.

We live in a fallen world.

qntm fucked around with this message at 01:10 on Sep 13, 2014

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Munkeymon posted:

I have a grammar horror to report. What's the opposite of active?

If you answered
CSS code:
.deactive { }
You win!

And, no, this wasn't a misspelling of 'deactivate', it's used as the inverse of .active but good thought.

Similarly, what's the opposite of "plugged in"? Specifically in the context of firmware for a NAS device. If you said "unplugged", as in "Warning: drive 3 was unplugged", then you have a better grasp of English than QNAP's developers.

"Warning: drive 3 was plugged out".

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

qntm posted:

There was a brief time when I served my website with a Content-Type: application/xhtml+xml HTTP header, which forces browsers to treat the payload as strict, correct XML or else display a parsing error. But even though my website has perfect XHTML markup (even the comments, thanks to draconian input validation), several moderately obscure browsers refused to render it as a web page, and I had to revert it.

We live in a fallen world.

There's always XSLT :unsmith:

fritz
Jul 26, 2003

Suspicious Dish posted:

This reads like someone arguing against FORTRAN in favor of assembly in the 60s.

I wonder how much assembly was actually being written in the 60s vs fortran/algol (ok, it was a long decade tech-wise, but still).

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
Shitloads of both were being written for a long time to come (actually I don't know how much Algol-60 or -68 got written "in anger", though it was used for basically every paper published for years). All the firmware for early digital gauges and transducers that my employer put out in the 80s were done in (Z80, 68HC08, or 6502) assembly.

On a somewhat less serious note, NBA Jam was written in assembly (in 1993!), as were most games before about 1990.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
All of the games for the original Nintendo and then Super Nintendo were hand-written assembly, unless somebody wrote a compiler we aren't aware of.

qntm
Jun 17, 2009

Suspicious Dish posted:

All of the games for the original Nintendo and then Super Nintendo were hand-written assembly, unless somebody wrote a compiler we aren't aware of.

And there are some pretty amazing bugs coming out of them, if you follow videogame speed running at all.

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

Suspicious Dish posted:

All of the games for the original Nintendo and then Super Nintendo were hand-written assembly, unless somebody wrote a compiler we aren't aware of.

I remember reading an article about how Sonic Pinball was the first Sonic game to be written in C rather than assembly, about how everyone thought it was a crazy idea at the time, how they don't think it was much slower than assembly, and how they managed to put it together quicker than earlier Sonic games.

Harik
Sep 9, 2001

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


Plaster Town Cop

ratbert90 posted:


The appropriate code is this btw:

code:
#define _MX6Q_PAD_CSI0_DAT17__UART4_CTS IOMUX_PAD(0x066C, 0x029C, 3, 0, 0, 0)
Thanks Freescale! This is the second time a TRM has been incorrect in my years of doing firmware coding! :argh:

Neither of those lines are correct, they need human-readable names (Yes, including for the addresses, unless the address is literally the only thing in the define)

Edit: Actually, where did you get that version? Freescale's 3.0.35 is currently:

No I'm literally retarded, I have the same code as you do.

Harik fucked around with this message at 14:44 on Sep 13, 2014

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.

Blotto Skorzany posted:

On a somewhat less serious note, NBA Jam was written in assembly (in 1993!), as were most games before about 1990.
Given the sad state of C compilers those days, it's not surprising. Hand-coded assembly was still a major component of games up to around ~95, until the scale of games and teams started way outweighing any performance benefits.

FlapYoJacks
Feb 12, 2009

Harik posted:

Neither of those lines are correct, they need human-readable names (Yes, including for the addresses, unless the address is literally the only thing in the define)

Edit: Actually, where did you get that version? Freescale's 3.0.35 is currently:

No I'm literally retarded, I have the same code as you do.

I want to move to kernel 3.10, but the project is almost done and .dts files scare me. :smith:

Volmarias
Dec 31, 2002

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

qntm posted:

There was a brief time when I served my website with a Content-Type: application/xhtml+xml HTTP header, which forces browsers to treat the payload as strict, correct XML or else display a parsing error. But even though my website has perfect XHTML markup (even the comments, thanks to draconian input validation), several moderately obscure browsers refused to render it as a web page, and I had to revert it.

We live in a fallen world.

If someone with Konqueror complains that your website isn't rendering for them, gently caress em.

xtal
Jan 9, 2011

by Fluffdaddy

Volmarias posted:

If someone with Konqueror complains that your website isn't rendering for them, gently caress em.

The point of standards is that they make the web work for everybody, even people using marginal browsers. So I hope what you're saying is "if somebody with a broken browser like Konqueror or Internet Explorer complains that your website isn't rendering for them, gently caress em."

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

xtal posted:

The point of standards is that they make the web work for everybody, even people using marginal browsers. So I hope what you're saying is "if somebody with a broken browser like Konqueror or Internet Explorer complains that your website isn't rendering for them, gently caress em."

Yes, marginal browsers that are correct get a web. Major incorrect browsers also get a web, because the point of authoring a page is to reach people, not to satisfy the lust of a validator.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Not when it's a considerable amount of effort to reach them. For high-profile sites like Facebook, yeah, you still need to support IE6 in tyool2014. For anybody else, writing an IE6-compliant site is a big loving pain, and we shouldn't have to do it.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Yeah, I agree; I don't think IE6 is a major browser any longer. (I don't think we even support fully it on the main FB site.) I don't think supporting broken large-user-base browsers is a moral imperative, I just think it tends to happen a lot.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

SupSuper posted:

Given the sad state of C compilers those days, it's not surprising. Hand-coded assembly was still a major component of games up to around ~95, until the scale of games and teams started way outweighing any performance benefits.

Yeah it's important to understand that codegen and optimization in C compilers was really, really awful for a long time. Using C removed a bit of tedium, but most of the time it simply wasn't worth the performance hit and memory overhead. With practice and an assembler with a decent macro system you can write fairly high level code. On the oldest machines the hardware had a lot of useful intelligence built into support chips which effectively gave you powerful "APIs" for graphics and sound, and later on PCs you had access to useful libraries and utility routines via BIOS and OS APIs that achieved the same thing.

FamDav
Mar 29, 2008

Subjunctive posted:

Yeah, I agree; I don't think IE6 is a major browser any longer. (I don't think we even support fully it on the main FB site.) I don't think supporting broken large-user-base browsers is a moral imperative, I just think it tends to happen a lot.

ie6 is tricky for us because we do have a big(ger) presence in places like china where usage is pegged at ~10-15 percent of the population. how good the feature has to work in ie6 is heavily dependent on if it will be internationalized to markets where its a serious proportion.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

FamDav posted:

ie6 is tricky for us because we do have a big(ger) presence in places like china where usage is pegged at ~10-15 percent of the population. how good the feature has to work in ie6 is heavily dependent on if it will be internationalized to markets where its a serious proportion.

Yeah, if we worked in China the calculus might be different. Though honestly supporting IE6 would be so much work that I could see arguing for just not addressing that submarket.

FamDav
Mar 29, 2008

Subjunctive posted:

Yeah, if we worked in China the calculus might be different. Though honestly supporting IE6 would be so much work that I could see arguing for just not addressing that submarket.

we've managed to make it saner over the past several years by adopting (and enforcing) a style guide w/ the necessary libraries to make it all happen. before that it was very much so a free-for-all, developers having to reinvent and retest what should be common components, and our site design being the worse for it.

Cool Matty
Jan 8, 2006
Usuyami no Sekai

Edison was a dick posted:

I remember reading an article about how Sonic Pinball was the first Sonic game to be written in C rather than assembly, about how everyone thought it was a crazy idea at the time, how they don't think it was much slower than assembly, and how they managed to put it together quicker than earlier Sonic games.

Yeah, it was one of the first console games in general to use C (I won't go as far to say THE first, but it's up there). That said, I don't think the game really made a great argument for its usage.

Munkeymon
Aug 14, 2003

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



qntm posted:

There was a brief time when I served my website with a Content-Type: application/xhtml+xml HTTP header, which forces browsers to treat the payload as strict, correct XML or else display a parsing error. But even though my website has perfect XHTML markup (even the comments, thanks to draconian input validation), several moderately obscure browsers refused to render it as a web page, and I had to revert it.

We live in a fallen world.

I remember trying to get that to work. You had to return a different content type based on the user agent the browser was reporting because not all of them liked application/xhtml+xml, but at the time spoofing UAs was so common because of all of the lovely old code that would tell, say FireFox users, to 'upgrade' to IE 5.5 or Netscape 4(?) that it wound up being basically impossible to support XHTML.

1337JiveTurkey
Feb 17, 2005

I can't decide whether to leave this as is or to handle surrogate pairs properly :effort:

Java code:
	/**
	 * Get BigInteger value of String value
	 *
	 * @param input
	 * @return
	 */
	public String makeNumber(String input) {
		// Create stringbuffer to handle length of minimum the input size.
		StringBuffer sb = new StringBuffer(input.length());
		char c;
		for (int i = 0; i < input.length(); i++) {
			c = input.charAt(i);
			if (Character.isDigit(c)) {
				sb.append(c);
			} else {
				byte[] bytes = new byte[1];
				bytes = (c + "").getBytes();
				sb.append(new BigInteger(1, bytes));
			}
		}
		return sb.toString();
	}

b0lt
Apr 29, 2005

1337JiveTurkey posted:

I can't decide whether to leave this as is or to handle surrogate pairs properly :effort:

Java code:
	/**
	 * Get BigInteger value of String value
	 *
	 * @param input
	 * @return
	 */
	public String makeNumber(String input) {
		// Create stringbuffer to handle length of minimum the input size.
		StringBuffer sb = new StringBuffer(input.length());
		char c;
		for (int i = 0; i < input.length(); i++) {
			c = input.charAt(i);
			if (Character.isDigit(c)) {
				sb.append(c);
			} else {
				byte[] bytes = new byte[1];
				bytes = (c + "").getBytes();
				sb.append(new BigInteger(1, bytes));
			}
		}
		return sb.toString();
	}

What is this even trying to do?
Also, "௫"

1337JiveTurkey
Feb 17, 2005

b0lt posted:

What is this even trying to do?
Also, "௫"

I guess it's massaging a string that's supposed to be a number so that it's always a number (for certain values of number) when fed to a downstream third party system. Since the string is ultimately just an opaque identifier anyhow, so long as everything maps the ID consistently it works (for certain values of works).

Edit: Call it an industrial grade injective mapping

1337JiveTurkey fucked around with this message at 18:49 on Sep 16, 2014

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
So if you're working on a legacy database suffering from the results of no input validation, duplicate keys (6 that mean "It's a file" in a type table, but 3 File and 3 FILE...) and keys with no description, keys used in the document table that don't match anything in the type table, and descriptions in the type table with no key associated, is that a database horror?

Is it a bigger horror that the numbers you search for files with should be "year-2LetterCode-6digitNumber-+4 characters maybe" (1234-AB-123456-XXXX) but with no input validation many times the year, code, or both are missing, so you can't split it into columns and do proper index searches and have to just do a LIKE '%foo%' with a drat scan? Oh and you can't edit the database in any way anyhow, so you're stuck with unindexed scans.

Thankfully it is used maybe a few times a month, so it can afford to be slow - it's only 1.8 million rows, so those ugly scans don't even take a second, but my god, I'd like to think people knew what input validation and schemas were. The other scary thing is it's still around because it's tracking non-digitized, printed documents! The cherry on top is the location they're stored at is often $PERSON's desk or $PERSON's office, not SECURE_FILING_CABINET or REPOSITORY, and more than one time said document was found propping up a table leg because the floor settled.

:q:

pigdog
Apr 23, 2004

by Smythe

b0lt posted:

What is this even trying to do?
Also, "௫"
As far as I can tell
code:
 return new BigInteger(input.replaceAll("\\D","1"));

Fellatio del Toro
Mar 21, 2009

Oh boy. I get an IM from a coworker:

IM posted:

now THAT... is a SQL statement

Round(((Q1.T_CAT_I-DQ.D_CAT_I-LQ.L_CAT_I)* 1.00/(Q1.T_Count-DQ.D_Count-LQ.L_Count)*10+(Q1.T_CAT_II-DQ.D_CAT_II-LQ.L_CAT_II)* 1.00/(Q1.T_Count-DQ.D_Count-LQ.L_Count)*4+(Q1.T_CAT_III-DQ.D_CAT_III-LQ.L_CAT_III)* 1.00/(Q1.T_Count-DQ.D_Count-LQ.L_Count)*1)/15,2) AS S_Weighted

I naturally laugh and ask him where he found that thing:

IM posted:

I had to write it from scratch >_<

:eyepop:

Adbot
ADBOT LOVES YOU

Steve French
Sep 8, 2003

Ruby code:
class Thing
  def operation
    ...
  end
end

class ThingRetryWrapper
  def initialize(thing)
    @thing = thing
  end

  def operation
    retries = 3
    begin
      thing.operation
    rescue => ex
      if retries > 0
        retries -= 1
        retry
      else
        raise
      end
    end
  end
end

# meanwhile, in specs ...


describe ThingRetryWrapper
  let(:thing) { Thing.new }
  let(:thing_retry_wrapper) { ThingRetryWrapper.new(thing) }

  it "retries the right number of times" do
    thing.should_receive(:operation).exactly(3).times.and_raise(SomeError.new("oh noes"))

    expect {
      thing_retry_wrapper.operation
    }.to raise_error
  end
end
The reason why this passes is awesome (or at least something like it that doesn't have any dumb mistakes in it that this hastily thrown together minimal example probably does).

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