Coding: Fleeting Thoughts

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

commodorejohn
Posts: 958
Joined: Thu Dec 10, 2009 6:21 pm UTC
Location: Placerville, CA
Contact:

Re: Coding: Fleeting Thoughts

Postby commodorejohn » Thu Sep 15, 2016 5:32 pm UTC

Tub wrote:Yeah, "neat", but ultimately, even though prototypes provide a superset of class functionality, I never really got any advantage out of it. The common javascript engines optimize under the assumption of static classes with immutable prototypes, so that's what you use. Can you show a problem that can be solved more elegantly with prototypes than with classes?

Nah, it just feels cleaner (in the abstract, of course, not in the eldritch horror that is Javascript.)
"'Legacy code' often differs from its suggested alternative by actually working and scaling."
- Bjarne Stroustrup
www.commodorejohn.com - in case you were wondering, which you probably weren't.

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5086
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Thu Sep 15, 2016 5:42 pm UTC

It works fine in a statically typed language like C#!

Code: Select all

var prototype1 = new {foo = 42};
var prototype2 = new {foo = "fourty-two"};
var obj = new Random().NextDouble() < 0.5 ? (dynamic)prototype1 : prototype2;
var x = obj.foo;
[/cheating]

User avatar
Yakk
Poster with most posts but no title.
Posts: 11045
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Thu Sep 15, 2016 6:42 pm UTC

Well, first assume everything is an any.

Now, define a set of common properties on these any's. Stuff like "has a key-value map", "possibly can be invoked", etc. Add type erasing wrappers around that.

You might get as resulting C++:

Code: Select all

property foo("foo");

var prototype1 = create{ foo = 42 };
var prototype2 = create{ foo = "forty-two" };
var obj = from_prototype{ flip_coin()? prototype1 : prototype2 };
var x = obj->*foo;
(x->*print)();

with myriads of exceptions thrown if you do anything illegal, or default behavior occurring, or whatever.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
Xanthir
My HERO!!!
Posts: 5215
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Thu Sep 15, 2016 10:56 pm UTC

commodorejohn wrote:Suffice to say, the first time I heard of Node was the Great leftpad Debacle. That pretty well encapsulated everything I needed to know about it.

This is nonsensical. The "leftPad" thing was a problem with NPM's policies. NPM is the primary package repository for Node; it has nothing to do with Node itself. NPM has since updated their unpublishing policies to be saner in the face of malice.

To the rest of y'all, JS is a pretty decent language. There are several scary parts of the web platform, separate from the core language, but JS itself is handy little language, if you enjoy functional languages without strict typing. As a heavy user of both JS and Python, the two are extremely similar.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

commodorejohn
Posts: 958
Joined: Thu Dec 10, 2009 6:21 pm UTC
Location: Placerville, CA
Contact:

Re: Coding: Fleeting Thoughts

Postby commodorejohn » Thu Sep 15, 2016 11:18 pm UTC

Xanthir wrote:This is nonsensical. The "leftPad" thing was a problem with NPM's policies. NPM is the primary package repository for Node; it has nothing to do with Node itself. NPM has since updated their unpublishing policies to be saner in the face of malice.

No, the problem has to do with a developer culture where people import a third-party external include rather than write a trivial six-line function.
"'Legacy code' often differs from its suggested alternative by actually working and scaling."
- Bjarne Stroustrup
www.commodorejohn.com - in case you were wondering, which you probably weren't.

EvanED
Posts: 4324
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Thu Sep 15, 2016 11:46 pm UTC

Xanthir wrote:To the rest of y'all, JS is a pretty decent language. ... As a heavy user of both JS and Python, the two are extremely similar.
Guido, and hence Python, knows what a type error is. :-)

(Yeah, I know I cut out the "if you enjoy languages without strict typing" part, but you can probably guess how I feel about that. :-))

User avatar
Xanthir
My HERO!!!
Posts: 5215
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Fri Sep 16, 2016 12:05 am UTC

commodorejohn wrote:
Xanthir wrote:This is nonsensical. The "leftPad" thing was a problem with NPM's policies. NPM is the primary package repository for Node; it has nothing to do with Node itself. NPM has since updated their unpublishing policies to be saner in the face of malice.

No, the problem has to do with a developer culture where people import a third-party external include rather than write a trivial six-line function.

A "trivial" six-line function that is still very easy to get wrong. Go look at "trivial" solutions to this problem on Stack Overflow - they're very often wrong in obvious corner cases. "Trivial" code usually isn't.

The Node ecosystem does lean pretty strongly into the "small modules" philosophy as a rule, but the idea of getting some decent reference implementation for a "trivial" function is not a bad one, particularly when the inclusion tool is so easy to use.

EvanED wrote:Guido, and hence Python, knows what a type error is. :-)

So does JS - pass the wrong type of object to most DOM methods, and you'll get a type error. JS is just a little more lax in allowing auto-conversions between primitives than Python is. (The majority of the "WAT"s I see about JS are just this - some artificial test-case that induces some non-obvious conversion to/between primitives.)
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

commodorejohn
Posts: 958
Joined: Thu Dec 10, 2009 6:21 pm UTC
Location: Placerville, CA
Contact:

Re: Coding: Fleeting Thoughts

Postby commodorejohn » Fri Sep 16, 2016 12:34 am UTC

Xanthir wrote:A "trivial" six-line function that is still very easy to get wrong. Go look at "trivial" solutions to this problem on Stack Overflow - they're very often wrong in obvious corner cases. "Trivial" code usually isn't.

"People on StackOverflow get it wrong" is hardly a conclusive test for non-triviality. Looking over the code (as seen here) the only bits that are even remotely tricky are the bit with casting the "str" argument to a string (one of the necessities of using a language with weak typing, which means it should be filed under You Should Already Know This if you're working with Javascript in the first place,) the bit defaulting invalid "chr" arguments to a space (ditto,) and the slightly kooky way the loop counter is handled (which seems to be a peculiar way of avoiding an off-by-one error, and not anything particularly difficult to replace.)
"'Legacy code' often differs from its suggested alternative by actually working and scaling."
- Bjarne Stroustrup
www.commodorejohn.com - in case you were wondering, which you probably weren't.

korona
Posts: 495
Joined: Sun Jul 04, 2010 8:40 pm UTC

Re: Coding: Fleeting Thoughts

Postby korona » Fri Sep 16, 2016 8:31 am UTC

To be fair reusing even trivial functions often does make more sense than rewriting them every time they are needed (and of course introducing different naming schemes, calling conventions and subtle differences in behavior each time). I don't know how often I wrote a ceil_to_2pow(size_t) function in C (bonus points: try to write it in an efficient way that does not assume sizeof(size_t) in {32, 64}; alternative challenge: do assume the above but try to generate optimal assembly code on all major compilers on {x86, arm, power}). If C had a npm like package manager I would gladly "import trivial_bitutils" instead.

User avatar
ahammel
My Little Cabbage
Posts: 2135
Joined: Mon Jan 30, 2012 12:46 am UTC
Location: Vancouver BC
Contact:

Re: Coding: Fleeting Thoughts

Postby ahammel » Fri Sep 16, 2016 1:43 pm UTC

Sure, I'm not opposed to a big ol' utility dependency or three, but having every single one of your trivial utility functions in its own package has the potential to be a total operational clusterfudge. Especially if your package manager is as slow as npm. Especially especially if your team is not in the habit of locking down package versions ('the cause of the outage was that server a and server b had didferent ideas about what a positive number is').
He/Him/His/Alex
God damn these electric sex pants!

User avatar
Wildcard
Candlestick!
Posts: 251
Joined: Wed Jul 02, 2008 12:42 am UTC
Location: Outside of the box

Re: Coding: Fleeting Thoughts

Postby Wildcard » Mon Sep 19, 2016 5:02 pm UTC

commodorejohn wrote:
Xanthir wrote:This is nonsensical. The "leftPad" thing was a problem with NPM's policies. NPM is the primary package repository for Node; it has nothing to do with Node itself. NPM has since updated their unpublishing policies to be saner in the face of malice.

No, the problem has to do with a developer culture where people import a third-party external include rather than write a trivial six-line function.

I agree with this completely.

You can talk about code reuse all you want. But there's a difference between understanding and reusing something, and just grabbing any old piece of code from anyone and slapping it into your production system.

If you're building a computer, it's perfectly fine to get the pieces ready-made from manufacturers rather than manufacturing the silicon chips yourself. It's not so fine to get some blobs of fused silicon from some hobbyist (or a collection of hobbyists) who claim the blobs are in fact well-designed microchips.

I'm not saying all NPMs are like that, of course. But there is a developer mindset in the NPM world where if it has been published (doesn't matter by whom), you assume it works as advertised and incorporate it as a dependency in your production codebase with no further questions (and without even studying the source code or doing quality checks on it). This is a cultural problem.

You can say the leftPad debacle was a problem with NPM's policies, but all those developers failing to even inquire into those policies before blindly trusting NPM to handle all their dependencies is, again, a cultural problem.
There's no such thing as a funny sig.

korona
Posts: 495
Joined: Sun Jul 04, 2010 8:40 pm UTC

Re: Coding: Fleeting Thoughts

Postby korona » Mon Sep 19, 2016 5:31 pm UTC

I don't know much about the node culture so I cannot really comment on it. If someone uses a library of questionable quality that is of course a problem but at least in this case that is not what happened. I also doubt that someone who doesn't spend any time on evaluating the quality of a library can be expected to produce high quality code at all. It does not make sense to blame the infrastructure just because bad programmers use it.

Importing code is fine, even if it is trivial. I suspect the second ceil_to_2pow() example from my previous post cannot be implemented without two layers of nested #ifdefs (one to differentiate between compilers and one to differentiate between word sizes). Plus there is the 0-argument corner case that needs to be taken care of. I'd rather reuse a small header in every project than rewrite this tedious code numerous times if C had the required repository infrastructure.

EvanED
Posts: 4324
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Wed Sep 21, 2016 4:25 am UTC

Code: Select all

for (SomeIterator iter = something; iter != end; ++iter) {
    SomeObject * p = *iter;
#define wat continue
    if (p == NULL)
        wat;
#undef wat

    foo(p);
}


That should pass code review, right?

I have an iterator that "returns" pointers, of course. I have no idea why it's giving me NULL... I think it shouldn't be. But I'm not sure I want to debug that now...

Tub
Posts: 312
Joined: Wed Jul 27, 2011 3:13 pm UTC

Re: Coding: Fleeting Thoughts

Postby Tub » Wed Sep 21, 2016 8:08 am UTC

EvanED wrote:That should pass code review, right?

Not yet. You need to put the opening curly braces on a separate line. Otherwise it's fine. :roll:

EvanED wrote:I have an iterator that "returns" pointers, of course. I have no idea why it's giving me NULL... I think it shouldn't be. But I'm not sure I want to debug that now...

Sure, just assign that task to future you. Don't bother adding a comment to the code, or even adding a task to the bug tracker. Future you will be reminded sooner or later.

User avatar
Yakk
Poster with most posts but no title.
Posts: 11045
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Wed Sep 21, 2016 1:11 pm UTC

Tub wrote:
EvanED wrote:That should pass code review, right?

Not yet. You need to put the opening curly braces on a separate line. Otherwise it's fine. :roll:

There should be a space after the ( and before the closing ).

There should not be a space between the * and the p on the variable declaration.

Indentation should be two spaces.

The end } of the for loop needs a comment saying what it ends.

Before the start of the loop, you need a block-comment stating what the loop does.

These are the important things to check in code review.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
phlip
Restorer of Worlds
Posts: 7543
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Coding: Fleeting Thoughts

Postby phlip » Wed Sep 21, 2016 1:42 pm UTC

Naturally, the only things worth checking in a code-review are things that could be fixed by a pre-commit hook.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
Yakk
Poster with most posts but no title.
Posts: 11045
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Wed Sep 21, 2016 2:30 pm UTC

I am glad you understand.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
raudorn
Posts: 347
Joined: Mon Jun 13, 2011 11:59 am UTC

Re: Coding: Fleeting Thoughts

Postby raudorn » Wed Sep 21, 2016 6:53 pm UTC

At my last place of work:

New guy, first day: Makes pull request, gets 40 comments about formatting
New guy, after a week: Makes 40 comments about formatting in pull requests
Guy, after a few months: Stares at pull request for five minutes, hits approve without comments
Old guy, has been there forever: Glances at pull request, makes insightful comment about deep underlying issue that will not immediately show, but make life hell down the road. Hits approve anyway.

User avatar
Flumble
Yes Man
Posts: 1945
Joined: Sun Aug 05, 2012 9:35 pm UTC

Re: Coding: Fleeting Thoughts

Postby Flumble » Wed Sep 21, 2016 9:16 pm UTC

raudorn wrote:New guy, first day: Makes pull request, gets 40 comments about formatting
New guy, after a week: Makes 40 comments about formatting in pull requests

I can't get my head around this: either explain thoroughly during the job interview what the code style is and why you don't bother making the aforementioned pre-commit hook, or shut the fuck up about code formatting.

raudorn wrote:Old guy, has been there forever: Glances at pull request, makes insightful comment about deep underlying issue that will not immediately show, but make life hell down the road. Hits approve anyway.

I think that's alright as long as that underlying issue goes into the tracker rather than be forgotten with the approval of the PR.

User avatar
raudorn
Posts: 347
Joined: Mon Jun 13, 2011 11:59 am UTC

Re: Coding: Fleeting Thoughts

Postby raudorn » Wed Sep 21, 2016 9:25 pm UTC

Flumble wrote:explain thoroughly during the job interview what the code style is and why you don't bother making the aforementioned pre-commit hook
[...]
as long as that underlying issue goes into the tracker


I'm not sure if I have become cynical, if the world is simply that unoptimized or if we don't know what exactly the issue is, but neither of these things happened of course.

User avatar
Flumble
Yes Man
Posts: 1945
Joined: Sun Aug 05, 2012 9:35 pm UTC

Re: Coding: Fleeting Thoughts

Postby Flumble » Wed Sep 21, 2016 9:41 pm UTC

I think it's called "the human condition".
I'm lucky to still be in university right now and only had to bother with formatting comments during one project. And the issues discovered/caused by a PR were actually documented in that project. :o

I'd expect in a software company that there'd be such a code formatter though. You don't want to continuously waste time on spaces vs tabs and the else keyword on the same line as the closing brace (yuck). That's FTEs of money and countless missed deadlines.

User avatar
raudorn
Posts: 347
Joined: Mon Jun 13, 2011 11:59 am UTC

Re: Coding: Fleeting Thoughts

Postby raudorn » Wed Sep 21, 2016 10:14 pm UTC

In theory every project has a definite coding style (even if borrowed from elsewhere) and a linter/pre-commit hook/IDE plugin/whatever, that takes care of pesky formatting issues. In practice even if the language and framework allow the use of such (partial HTML templates ruin this, for example), just getting everyone to use it is hard enough. And if a sufficient amount of programmers don't use it, nobody will.

The same is true for an issue tracker. If not everyone uses it, stuff falls by the wayside, causing frustration with the development cycle and frustrated programmers are, paradoxically, less likely to use tools like an issue tracker to make things better.

I'm not sure what part of human psychology causes this, but I have noticed (at least at one particular place of work) that there is a positive feedback loop for using productivity tools and the equilibrium points are close to 0% and 100% usage.

EvanED
Posts: 4324
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Thu Sep 22, 2016 1:37 am UTC

Yakk wrote:There should not be a space between the * and the p on the variable declaration.
But what if putting spaces on both sides is designed to annoy adherents of both Type* p and Type *p at once? :-)

Flumble wrote:I'd expect in a software company that there'd be such a code formatter though.
I wouldn't; I doubt most companies would. It's sort of a fantasy of mine where everything would be standardized to a specific style on commit, and then on checkout you could automatically transform it to whatever you like. Then heathens that like 2-space indents could be happy as well as God's chosen (I am in the religious wars subforum, right? O:-)).

But instituting this on an existing project would be hard I think, because you'd have a commit that is just formatting and that would break lots of tools. For example, we use Subversion. svn blame doesn't seem to have an option to ignore whitespace changes, so that'll give you the reformatting commit. And what about branches? You can tell svn to ignore whitespace changes when merging, but I can also imagine if this goes wrong it could easily cost hours or days. We have both Trac and ViewVC for repo browsing; Trac nicely offers a toggle for ignoring whitespace, but ViewVC, from what I know, doesn't. There is a configuration option, but that's global. diff has options for ignoring whitespace changes, but they're off by default. (You could say "use better tools" but I don't think that's a good argument here for a few reasons, as much as I'd love to switch to Git or Hg, for reasons I'm too lazy to type out now.)

I was going to highlight an example of a file in our codebase that, mostly through historical and organizational accidents, has some really terrible formatting (e.g. mixed 2 & 4 character indents, sometimes within a function). I've been really tempted to just run indent-region on that file, but I can't help but think I don't know how much that would screw up merging etc.; but after thinking about it I think I'll at least investigate it. :-) See if I can figure out how many branches have changes to that file and how extensive they are... it might be worth it there.

(And incidentally, when I wrote "But I'm not sure I want to debug that now..." I knew I was lying and would figure out where NULL was coming from, and I did. Well, not lying, because I really didn't want to debug it... but I didn't not want to debug it ever more.)

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5086
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Fri Sep 23, 2016 3:03 pm UTC

I can't figure out of the architects at work are just trying to get me to use dependency injection for dependency injection's sake, or if I'm just too stupid to figure out why what dependency injection actually gains us for this (tiny) project when we're only going to be creating a dozen+ interfaces that will only be used for dependency injection and nothing else...

And I can't be sure that the answers to my questions aren't clarifying it because my I'm not asking the right questions or I'm missing something obvious...

User avatar
Yakk
Poster with most posts but no title.
Posts: 11045
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Fri Sep 23, 2016 3:28 pm UTC

EvanED wrote:
Yakk wrote:There should not be a space between the * and the p on the variable declaration.
But what if putting spaces on both sides is designed to annoy adherents of both Type* p and Type *p at once? :-)

Excess whitespace reduces your code information density.

If the C++ language was meant to have whitespace somewhere, it would have been mandatory.

Look, I'm not a fanatic. You can have newlines as needed, and tab-indent stuff.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

korona
Posts: 495
Joined: Sun Jul 04, 2010 8:40 pm UTC

Re: Coding: Fleeting Thoughts

Postby korona » Fri Sep 23, 2016 3:58 pm UTC

Also, type* p is just wrong, right? If C wanted us to use that style it wouldn't have given us multiple variable declarations in a single statement!

User avatar
Flumble
Yes Man
Posts: 1945
Joined: Sun Aug 05, 2012 9:35 pm UTC

Re: Coding: Fleeting Thoughts

Postby Flumble » Sat Sep 24, 2016 12:17 am UTC

It's just to keep away the plebs.

Code: Select all

type* a,* b, c,** d
    ,* e;

User avatar
chridd
Has a vermicelli title
Posts: 765
Joined: Tue Aug 19, 2008 10:07 am UTC
Location: ...Earth, I guess?
Contact:

Re: Coding: Fleeting Thoughts

Postby chridd » Sat Sep 24, 2016 1:07 am UTC

Flumble wrote:It's just to keep away the plebs.

Code: Select all

type* a,* b, c,** d,*
      e;
FTFY
~ chri d. d. /tʃɹɪ.di.di/ (Phonotactics, schmphonotactics) · they (for now, at least) · Forum game scores
mittfh wrote:I wish this post was very quotable...
flicky1991 wrote:In both cases the quote is "I'm being quoted too much!"

Rysto
Posts: 1459
Joined: Wed Mar 21, 2007 4:07 am UTC

Re: Coding: Fleeting Thoughts

Postby Rysto » Sat Sep 24, 2016 7:15 pm UTC

phlip wrote:Naturally, the only things worth checking in a code-review are things that could be fixed by a pre-commit hook.

In my experience if the only feedback you're getting on your code reviews is trivial style issues, the issue is usually with the code change as presented rather than the reviewers. Try to keep your reviews to 400 lines or less (in a pinch, you can go up to 500). Anything more than that and you overflow your reviewer's L1 cache, and then their comments become limited to only easy-to-spot, local issues like style violations. If you want your reviewers to be able to understand your work well enough to comment on it intelligently, you need to present it in a way that's digestible. A number of small, independent reviews are infinitely more useful than a single giant review that nobody truly understands.

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5086
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Mon Sep 26, 2016 9:36 pm UTC

So the "standard" practice checking for image load issues with Selenium seems to be firing an HTTP request at each img element and validating it returns a 200 OK.

Except for whatever reason the web server seems to return 200 OK (possibly with an error page) for even missing images...

:|

User avatar
Flumble
Yes Man
Posts: 1945
Joined: Sun Aug 05, 2012 9:35 pm UTC

Re: Coding: Fleeting Thoughts

Postby Flumble » Tue Sep 27, 2016 10:57 am UTC

So the one who configured the web server doesn't know how to correctly set up 404 pages? (as in: redirect non-existent URIs to the 404 target and modifying the 404 template, rather than redirecting it to an existing page that says "404")
Have you tried loading example.com/nonexistent yet?

User avatar
phlip
Restorer of Worlds
Posts: 7543
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Coding: Fleeting Thoughts

Postby phlip » Tue Sep 27, 2016 2:38 pm UTC

I remember trying to do something that scraped pages off a site, that returned 200 for every url, but had some random HTTP header that was set to "404" if a page didn't exist. Still able to be used, but a bit head-scratching...

[edit] Oh, I remember which site it was...

Code: Select all

phlip@boris:~$ curl -I http://www.homestarrunner.com/thisdoesnotexist
HTTP/1.1 200 OK
Content-Length: 1553
Content-Type: text/html
Content-Location: http://www.homestarrunner.com/404error.html?404;http://www.homestarrunner.com:80/thisdoesnotexist
Last-Modified: Thu, 15 Oct 2009 17:10:49 GMT
Accept-Ranges: bytes
ETag: "6e8a8f71ba4dca1:229"
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Date: Tue, 27 Sep 2016 14:43:49 GMT

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
headprogrammingczar
Posts: 3072
Joined: Mon Oct 22, 2007 5:28 pm UTC
Location: Beaming you up

Re: Coding: Fleeting Thoughts

Postby headprogrammingczar » Tue Sep 27, 2016 5:24 pm UTC

For what it's worth, I have heard of websites that fail on every page load, but the 500 handler happens to be wordpress so nobody ever notices it's technically down.
<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Weeks> You're the goddamn headprogrammingspock!
<Cheese> I love you

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5086
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Tue Oct 04, 2016 10:00 pm UTC

I didn't realize lambdas existed as (or at least, support reflecting as needed) expression trees at runtime in C#... it makes sense I've just never thought about it till I was trying to figure out how DelegateCommand.ObservesProperty worked behind the scenes.

It's neat.

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5086
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Thu Oct 06, 2016 4:27 pm UTC

Woo, I get to install VS 2015 today! We're on the current version!

*sees VS 15 preview out yesterday* It's just a preview! It doesn't count yet I'm pretty sure!

User avatar
Yakk
Poster with most posts but no title.
Posts: 11045
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Thu Oct 06, 2016 6:59 pm UTC

Update 3.1?
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5086
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Fri Oct 07, 2016 2:24 pm UTC

I didn't know VS had decimal updates. I think I installed Update 2, which probably means I need to actually run an update at some point. I spent like 5 hours yesterday install VS, .Net 4.6.2 SDK, and then the VS SDK because I forgot to check a box... so I'm not in a rush. :P

User avatar
Yakk
Poster with most posts but no title.
Posts: 11045
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Fri Oct 07, 2016 6:06 pm UTC

Update 3, but they patched it to fix a bug.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5086
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Mon Oct 10, 2016 6:54 pm UTC

So I actually got the VS notification about the update today and figured I'd try installing it...

Apparently that's a no go. Not sure if it's a GP setting or what, but at a minimum the firewall blocks the direct download (if I just click "Update" in VS). If I try and download the Update 3 package manually it does download, but then when installing it just says "Update 2 is already installed" which... is not what I would expect for an Update 3 installer to say.

At least I can still use the new C# 6 features, that's something. Go go string interpolation!

User avatar
Flumble
Yes Man
Posts: 1945
Joined: Sun Aug 05, 2012 9:35 pm UTC

Re: Coding: Fleeting Thoughts

Postby Flumble » Wed Oct 12, 2016 7:09 pm UTC

So apparently postfix requires you to setup SASL with cyrus/dovecot if you want to send mail using a different domain. This was not clear from the get-go, so I spent 4 hours figuring out why I kept getting 454 relay access denied errors, despite having the same setup as the answers to various stackoverflow questions. :|

Also WP10's outlook app recently(?) added the option to use an imap+smtp client, so no more need to setup a whole exchange/openchange server. :D (except that I don't have a synchronized calendar this way)
Now the next challenge is finding out what type of push protocol WP10 accepts, because it's either that or "check every 15 minutes". Does anyone have a faint clue?


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 3 guests