« first day (1185 days earlier)      last day (3131 days later) » 

17:00
public void ProcessRequest(HttpContext context)
{
    try
    {
        var responseTypeString = context.Request.QueryString["FileType"] ?? string.Empty;
        var responseType = Utilities.Extensions.ResponseTypeExtensions.FromString(responseTypeString);

        // Do some work
        var response = ""; // This variable is filled with the response to write to the context

        context.Response.ContentType = "text/plain";
        context.Response.Write(response);
    }
    catch (Exception e)
So, all the ProcessRequest methods look like that.
alright hold up right there young man
Is there any way I can extract that out?
What's ProcessRequest? A helper you call from your action methods?
No, it's an ashx page.
okay no experience with that
euhm
can you use action filters?
17:02
So, you call API/1.0/SiteHistory.ashx which calls ProcessRequest(HttpContext) by default.
What are action filters?
aka an attribute above your method that is applied to every incoming request before entering the method body
No idea.
Basically a piece of code that hooks into the pipeline of the request right before the request enters the method
But, I was wondering if I could put all the code into a Lambda.
It's what [Authorize] is based on in ASP.NET for example
well why don't you just have a helper method bool ValidateRequest(HttpContext)?
do all that in there
pass your context to it
17:04
Well that's not how it does it.
It doesn't just validate.
Did you see the sample code?
response is filled based on what // Do some work did.
if the return value is true, validation passed. If it doesn't, just return from your API endpoint
Validation isn't the issue.
The issue is exceptions.
ah, and // do work is the thing that changes?
Yeah.
So // Do some work will be different in each ashx page.
My thought, was to move all the code into a method that takes an Action<HttpContext>.
how about template method pattern?
17:06
Never used that.
        public void DoWork(Action<HttpContext> work, HttpContext context)
        {
            try
            {
                var responseTypeString = context.Request.QueryString["FileType"] ?? string.Empty;
                var responseType = Utilities.Extensions.ResponseTypeExtensions.FromString(responseTypeString);

                work.Invoke(context);

                context.Response.ContentType = "text/plain";
                context.Response.Write("Hello World");
            }
            catch (Exception e)
        public void ProcessRequest(HttpContext context)
        {
            Action<HttpContext> work = (c) =>
            {
                var fields = context.Request.QueryString["Fields"] ?? _defaultFields;
                var site = context.Request.QueryString["Site"];

                if (string.IsNullOrWhiteSpace(site))
                {
                    throw new ArgumentException("The 'Site' parameter is required and cannot be empty.", "Site");
                }
            };

            DoWork(work, context);
But that's what I'm looking at for how to handle it right now.
class Request { } with overridable method protected virtual string GetWorkResult()
abstract class Request
{
	private HttpContext _context;

	public Request(HttpContext context)
	{
		_context = context;
	}

	public void ProcessRequest()
	{
		try
		{
			var responseTypeString = _context.Request.QueryString["FileType"] ?? string.Empty;
			var responseType = Utilities.Extensions.ResponseTypeExtensions.FromString(responseTypeString);

			// Do some work
			var response = DoWork();

			_context.Response.ContentType = "text/plain";
			_context.Response.Write(response);
		}
		catch (Exception e)
Hmm...that might work.
Then I can just create an instance of SomeRequest and process from there.
Yup. You'll have a bunch of classes that subclass this one, one for each kind of request
Yeah.
Each one can do it's validation as needed.
And I can separate concerns a bit better.
That should work.
have it sanity checked by someone else though. It's the end of the day and my brain is resembling a fried egg
17:11
Sometimes I think I'm in a room filled with idiots.
5
@Mast Three of those were me...lol
I thought I was in that, but it was just someone specifically mentioning to me that they were an idiot
@Mat'sMug :(
@Mast Wow, I don't know what's worse.
The aliasing, or the fact I'm on there 3 times.
Oh crap
I can't do this
Or can I?
Nope, can't be done. Carp.
qqqqqqqqqqqqqqq
crap
i thought i was in game
well, that explains falling off a cliff
17:17
Yes, I can do this. :D
@DanPantry Less qq, more pew pew.
I was trying to turn :(
@DanPantry Don't worry. Everyone falls of a cliff sometimes. It is perfectly normal to fall of a cliff. calls paramedics
@EBrown It least here nobody is whipping up a GUI in VB to trace something...
Anyone want to sanity check something for me?
17:19
That's an entirely different kind of stupid.
3
1
Q: Where can my code break in the following scenario

SkynetI have the following JSON: { "Email_Id": "[email protected]", "OrderHistory": [ { "Coupon_Code": "55510018795", "Coupon_Expiry_Date": "8/3/2016 8:48:28 PM", "Prod_Type": "ENT_SIM", "Status": "55001", "Imei1": "458754896541236...

Go for it, @EBrown
@CaptainObvious WHY DID YOU GET UPVOTED
GITHUB YOU STUPID PIECE OF CRAP
FFS WHY?
"I'm an idiot" incoming in 3.. 2....
No, "GitHub needs to not be stupid as f---" incoming.
> There have been several failed attempts to sign in from this account or IP address. Please wait a while and try again later.
Really?
Worthless piece of trash.
17:23
"I forgot my password enough times to lock my account out. The software ist he problem!"
:p
That's after 3, by the way.
No option to reset it or anything.
And one of them was a "You cannot use that password, we've seen too many hackers..." or whatever it is.
Password manager up, friend
@DanPantry Or this. One more CV.
I did, they locked my out because they think my password is insecure.
while True:
  breath.in()
  breath.out()
17:24
@EBrown That's rate limiting. All the good guys do it.
My new Girlfriend() says I treat her like an object. girlfriend.comfort().
@Mast It's dumb, I need far more than 3 attempts.
(I don't have a girlfriend. Just a lame joke)
@DanPantry I don't think you're a lame joke
we have dogs barking and kids crying
this office is so much fun
wish I had chips
17:31
@JeroenVannevel Look inside your computer
@JeroenVannevel Go to the local fish n chips for lunch (if they still have those).
@Trojan404 Those are crisps you heathen
@DanPantry To you maybe, but in America they are chips
@JeroenVannevel is in the land of tea
not in the land of freedom and guns
17:32
@DanPantry The frequent misunderstandings with my flatmates are starting to make me want to use crisps
but I persevere
problem solved
@Trojan404 that's the good stuff
not crispy enough
> 12 running, 30 queued, 11 completed
17:33
Let's see how long my Roslyn tests take to run.
@JeroenVannevel better?
those are ugly
@Trojan404 Those are french fries.
@Trojan404 those are freedom fries
these are the ones I eat at my typical Belgian place:
(pic from my phone from back when I was in the promised land)
17:34
Looks like the lunches in the French book I used, lol.
Welcome in the 2nd monitor, where we talk about food.
@JeroenVannevel Does it make sense to do the response writing in the Request class or the handler?
French fries, hot dogs, and Coca cola.
            _context.Response.ContentType = "text/plain";
            _context.Response.Write(responseString);
not crispy enough - penn-station.com best fries in the world, IMO
17:35
Right now it's in Request.ProcessRequest() which means that the ashx page only has:
@EBrown write where you have the best knowledge of what is to be written
    /// <summary>
    /// Summary description for SiteHistory
    /// </summary>
    public class SiteHistory : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            var request = new SiteHistoryRequest(context);
            request.ProcessRequest();
        }

        public bool IsReusable { get { return false; } }
    }
don't spread it out for the sake of spreading out
> 12 running, 20 queued, 21 completed
@Trojan404 curious claim for someone that hasn't been in Belgium
17:36
Or, should Request.ProcessRequest() just return a string?
they look like typical fries with the potato skin still on. Makes no sense and does not taste good at all to me
this might be better on code review.se — uoɥʇʎPʎzɐɹC 56 secs ago
@EBrown meh, I'd keep it as it is now
@JeroenVannevel Best place to get fries is always as convenient as possible. 5 minute drive vs. 12 hour flight
@JeroenVannevel I feel like this method is a bit better.
17:37
Not my fault you live in the sticks
EUROPE EUROPE EUROPE
I've not had french fries for several years.
@Hosch250 you are truly evil
@Hosch250 I feel sad for you
And yes, we are surrounded by Burger Kings and MacDonalds.
@Hosch250 why not Wendy's?
17:38
Yeah, this works a bit better.
On the other hand, we (usually) have more delicious meals than you an get at a restaurant.
@Trojan404 Those too.
And Perkins.
And Hiltons. (Well, just one of those.)
@Hosch250 Those still exist? I thought Frisch's put them out of business, then everything else put Frisch's out of business
No, there is at least one in our area.
I don't know how they and Big Boy still make money
I've not seen Big Boy or Frisch.
17:40
Nobody really goes to sit down fast food diners anymore. You either hit the drive thru or you're going to a semi-nice sit down
As an example of our delicious suppers, we had fresh corn on the cob and tacos last night.
It's silly. I could've gone home 40 minutes ago but I like to work too much -- Most days I just don't want to
3
@Hosch250 BBQ Chicken and corn on the cob
@JeroenVannevel That's how it was for me at the beginning of RD too.
I have to force myself now though -- otherwise no time for gym. And I'm starving
@Hosch250 well I'm 2 months in already
17:41
@Trojan404 No, ground beef, lettuce, cheese, peppers.
@JeroenVannevel Nice.
@Hosch250 Let's change the topic. I just had lunch an hour ago and this is making me hungry....
I had a hard time at the end. It was several weeks of hitting my head on bug walls bigger and sturdier than Trump's.
it is better to use codereview.stackexchange.com in this case — iraj jelodari 57 secs ago
@Trojan404 Nah, I can't eat chicken. I don't mind, though, because I don't like the taste.
@Trojan404 I'm just coming up to lunch. Time to whet my appetite ;)
@Hosch250 MST or PST?
17:44
Central time.
Lunch at 1 PM??
> 12 running, 9 queued, 32 completed
Yeah.
how do you live...
By having breakfast at 9:30 AM?
And supper at 7 PM, and bed at midnight?
ah i see - breakfast at 6:45 AM
and by breakfast, I mean 2 granola bars
17:46
@JeroenVannevel @DanPantry How does this look: gist.github.com/EBrown8534/733879f904381997ddb11df0bf202dac
Want to swap? I had a bowl of yogurt (I'll keep my opinion about yogurt to myself) and some raw oats.
Oh wait, idea.
@EBrown Not half bad.
@Hosch250 Updated.
The ExceptionResponse parameters are set in the constructors.
0
Q: How to read/manage test data from a DB in a clean and efficient manner?

Nikolay AdvolodkinSo I am writing automated functional tests for my application. To interact with the application, I require the ability to interact with the SQL database to retrieve data and validate data. One of the challenges that I'm facing is that Some data that I need to pull at run time can take 5 minutes t...

17:50
Is there any way to mark a method so that no derived classes can use public new ... to hide it?
I'm not sure.
I doubt it.
You can seal the class so it can't be derived.
Oh well, I'll deal with it.
@Hosch250 Not allowed, class has to be derived. Lol
@EBrown do you need to support subclasses at all?
you could just seal the class
17:52
@DanLyons Yeah, it's abstract...lol
public class SiteHistoryRequest : Request<ArgumentExceptionResponse>
{
    private const string _defaultFields = "Date,TotalQuestions,TotalAnswers,QuestionAnswerRate,AnswerAcceptRate,AnswersPerQuestion";

    private string _fields;
    private string _site;

    public SiteHistoryRequest(HttpContext context)
        : base(context)
    {
        _fields = context.Request.QueryString["Fields"] ?? _defaultFields;
        _site = context.Request.QueryString["Site"];
    }

    protected override ApiResponseWrapper<ArgumentExceptionResponse> DoWork()
That's how a derived class implements it.
No validation is done in the constructor, the private fields are just set, then DoWork validates them.
Obviously ArgumentExceptionResponse isn't the actual type for the class.
@CaptainObvious I don't like it.
that's disappointing - even sealing the method doesn't help against using new
No, it'll be alright though.
I think it's .
18:04
@Quill you around?
You know, you really don't want to use std::string, but an actual securestring-type to ensure all buffers get scrubbed. Take a look at codereview.stackexchange.com/questions/107991/… for a way to hack std::basic_string to fill the need. — Deduplicator 48 secs ago
@Mast That's the first time I remember replacing four tags with five completely different tags.
Is it really broken code?
Zak
Zak
@Mast looool.
Probably should've added as well for good measure
@200_success That's how it reads, but I can't verify that. The implementation of some of the classes appear to be missing.
Or they're part of some includes I'm not familiar with, he hasn't included those either.
18:13
It would be more helpful to ask that instead of accusing it of being broken.
Honestly, I can't remember why I stamped it like that. But I think it's because he's asking for general guidelines about something that he doesn't appear to have implemented yet himself.
@Quill one of the issues raised by a user is due to event.scrollingElement being undefined in Failfox. Try getting window.scrollTop/window.scrollLeft (scrollY and scrollX may work respectively)?
@200_success Asked for clarification.
Monking
I'm stomped. Worked almost 10 hours with my family to give the living room a new paintjob
18:31
0
Q: Simple Node.js localization package

ROALI wanted a simple localization module to manage multi-language strings in my new personal Node.js project. As I'm working on this project primarily to learn and play around and the packages I found felt too complex, I though of writing one by myself. Primary concern: memory. The module uses Nod...

0
Q: Testing file IO errors in python

SJCBelow is a simple class with two methods: the first calls open() to read in a file. The second calls the first method and does error handling. There is also a corresponding test class that tests the first methods returns data as expected and the other methods test the error handling of potentia...

@CaptainObvious Er.. this is generated code
Zak
Zak
@Zak is always good. — pacmaninbw 2 hours ago
^^
@Vogel612 Was it worth it?
oh yes it was
it's actually white again :D
Very nice. :) I need to finish up my basement so I can get it painted.
@Vogel612 You should be interested to know, Stack Exchange Statistics Explorer should be up in a couple of days.
Maybe sooner depending on the time I get on it tonight.
Zak
Zak
18:35
Oh. cool.
user image
4
damn. When did 6k become a thing. I swear I haven't been here long enough for that.
@EBrown that sounds great, thanks :)
You're winning our race big time so far.
youch... yea syb0rg is also far ahead of me ..
Zak
Zak
Not by much. I think I started out about 700 ahead
@Zak good f-ing work mate
that's impressive
18:38
@Vogel612 Only 250ish
@Vogel612 I'm trying to polish off bits of the API as we speak.
@syb0rg I'm gonna be out for 10 days starting next friday.
I expect you to increase your distance then
also the java tag seems less voted on than C and C++
@Vogel612 I'm literally going on vacation at the same time for the same length lol
user image
3
Zombie Rate as of this morning.
thanks santa btw:
Zak
Zak
18:40
@Vogel612 you should try ^^
I do a more-than-above-average amount of pimping and my average vote-count is only about 6 per post.
@Zak my latest answer is and it's also the highest voted since I started the race, I think
@Zak high-vote problems ...
0
Q: Phishing Project - Refactored Controller Class

Trojan404Following the last review, I felt that my project was starting to get too complex to continue moving forward as such. So I created a new project and migrated pieces of it over to streamline it's cleanliness and readability. As a result, I ended up scrapping the idea of PhishingController and crea...

Zak
Zak
Median is 4
Carp
Forgot how many columns are in this table.
I was in that race... but with the fact that I'm working on my senior thesis, working full time, designing a website for a friend, building a WordPress plugin for another website, and starting to build an Applicant Tracking System, I don't think I have time....
18:43
@Zak median in the last month is 3
@EBrown Crap.
Zak
Zak
@Vogel612 huh. Maybe VBA isn't quite so bad after all
Sometimes I forget CR as a whole has a low Vote-Density
Unlike some other sites...
@Zak lol you capped out twice on that one answer :D
well that's HNQ you can't really compare them
Yeah, I saw that in the list.
@Zak Meh, we vote a lot more than some others though.
18:48
Well, that's why I left that // Generated by CoffeeScript 1.10.0 part there. Should I instead post the original CoffeeScript? Also, could you point me to somewhere where I could find some background on this? — ROAL 13 mins ago
@Pimgd How many times did you cap from your LOLCODE answers?
Good guy OP corrects his code from JS to CoffeeScript
Zak
Zak
@Vogel612 My regex thing also went HNQ. I'm not seeing 156 votes over there ^^
Repcap formula for Code Review: Pokémon Lolcode FizzBuzz Brainfuck
12
@Mast We're 27th for number of votes per Question/Answer.
18:49
@200_success lol
Zak
Zak
@200_success TS
Oh crap, now somebody is going to use that as a title.
Not me.
Zak
Zak
@Mast I can definitely get the first 3 in a question. Adding BrainFuck as well would be somewhat difficult
I take that back, we're 29th in votes per question/answer.
Zak
Zak
18:51
Plus, you know, I'd have to learn BrainFuck.
We average 4.42 votes per question/answer.
If not repcap, then at least it's star-bait.
The highest in network is 16.11 by Skeptics.
@Zak @EthanBierlein, @Quill and I got a lot of rep from Gamedev once.
Well, I'm only counting graduated sites.
18:53
@Zak It isn't too hard once you've read a couple of the already existing answers.
Holy carp
If we count all SE sites (meta, beta, graduated) and check who has the highest number of Votes Per Entity (which is Votes per Question/Answer), we come in at 165/316.
And 97 of the sites ahead of us are linked meta sites.
That's interesting.
So we suck at voting
@syb0rg Not necessarily, the Meta sites are good at voting.
But, in all fairness, Meta sites can get more participation for that for each site.
I vote nearly everything on meta.
what about votes over time?
18:58
@Vogel612 I'll look when I get home, I have to go to work.
If anyone wants to see any comparisons, ping me with the comparison you want to see. (Including your last one @Vogel612.)
That way I see them when I get home.
19:15
possible answer invalidation by Roll Tide Brad on question by Roll Tide Brad: codereview.stackexchange.com/posts/136552/revisions
@Duga Seems reasonable.
@Duga S'all good. I'll see if I need to add anything to my review. :-)
This question is off topic. It should be moved to Code Review. — Ryan89 52 secs ago
possible answer invalidation by 200_success on question by striderno9: codereview.stackexchange.com/posts/136553/revisions
19:30
@syb0rg No, but it could be better.
19:49
It seems that your code currently works, and you are looking to improve it. Generally these questions are too opinionated for this site, but you might find better luck at CodeReview.SE. Remember to read their requirements as they are a bit more strict than this site. — FrankerZ 40 secs ago
@FrankerZ This would be closed as off-topic on Code Review. It isn't considered real code. — syb0rg 41 secs ago
3
0
Q: javascript - create an object containing objects based on JSON data

devdropper87based on JSON data I receive, I am trying to track a teams home and away games. The json data is stored in $scope.gameSchedules and has "team1" for home games and "team2" for away games. I need to initially create an object with each teams name and the only way I can get all the teams names are v...

Ripe zombie; open question with answers, at least one answer having score 0, no answer having score > 0: Admin panel, secure login
20:38
@Hosch250 Only once per answer
CR questions don't tend to stay near the top
0
Q: Pulling data from a ticketing system via REST API

James RiveraI'm building a web app that pulls data from a ticketing system via REST API. I'm currently able to pull all of the data I need just fine but the loading process is really slow. I'd love any feedback regarding the optimization of my code. Thanks. <?php include 'schedule.php'; $curl = curl_init()...

Actually, not even that
43
A: NUMAH LITTERS OV KITTEHS ON TEH NETZ

PimgdVariable capitalization IT IZ PRETTY GUD LOLCODE HOWEVEZ ME THINKS THAT TEH LOLCODEZ R EZYR 2 READ IF TEH VARZ R lowercase ZIS BECUZ ALL CAPS IS HARD TOO READ (all spelling "mistakes" made by my cat, who assisted me in that part of this review) More seriously, it is an issue that there are no g...

72
A: Find min of 3 numbers hardcoded

PimgdFor these things we have java.lang.Math: public static int min(final int a, final int b, final int c){ return Math.min(a, Math.min(b, c)); } Wow, look how short it is! But it's 3 numbers today, it's 10 tomorrow. As an alternative, how about an array? public static int min(int... numbers)...

These are the only two posts to have scored me a repcap.
The rest of my repcaps were all multi-answer efforts
20:55
lol
@DanPantry that one is ages old
yes sorry I forgot that you had seen everything on the internet and I must never repost it :P @Vogel612
the all-seeing Vogel accepts your apologies /s
But, the only way this makes sense is if Einstein did all the work
in which case, that's an energetic old man
still doesn't contradict any of the evidence
20:57
well, relatively speaking
:^)
Also, I don't know at what speeds time dilation starts to kick in noticeably, but... I'm pretty sure that bed won't last.
Yes, I'm real fun
shhhhh
You're almost reaching German "Spießer" levels of humor
Found in a landing page:
> If not, the code generated by SoundToClass will fail gracefully and simply do nothing when you attempt to play it on an unsupported machine.
Is Syb0rg around? Had a tiny question about neural networks.
21:01
> tiny
> neural network question
pick one.
more like dnc
@DanPantry The question is tiny, the answer is another case.
I was just wondering why it does not seem like neural networks are used much in chess evaluations. Seems like they still rely in brute force and keeping a large database of known positions.
@N3buchadnezzar training is too expensive-ish I guess.
aside from that the "intelligent" brute-force-ish approach works just fine
@Vogel612 Well AlphaGo used a neural network sort of
yea, but that's because the solution space is vastly larger than chess
aside from that it also relied on "known constellations" a lot IIUC
21:08
Yeah. To rephrase, there are neural network engines for chess. They just do not perform as well, and are far fewer in numbers.
moreover Chess can be greatly cleaned with simple heuristics and A-B-Pruning
that doesn't work so much for Go
Yeah, because the solution space is so much greater.
soo... why are we using Neural Networks?
the point is that Neural Networks are not generally going for the "best" solution by default.
they just converge toward the "trained" "solution"
Chess has a comparatively small solution space that can be "easily" culled
0
Q: Why does my script throw an error when I send successive requests in a short time?

stackMy code work as well and all fine. I have a question and answer like stackoverflow. Following codes are for marking an answer as accepted one part. As I said it works perfectly, but sometimes it throws an error. I mean catch(PDOException $e) { block executes and $e is empty. even when I use just...

0
Q: Rainfall challenge: how big are the basins?

mdfst13August 2016 challenge The Rainfall Challenge Problem description is copied verbatim from the linked Code Review question: Problem Statement A group of farmers has some elevation data, and we're going to help them understand how rainfall flows over their farmland....

as such algorithms can be optimized for "correctness"
a Neural Network is usually harder to optimize for correctness while keeping reasonable speed
21:14
I see. I still think a computer learning chess without a book - set of openings - would be very interesting to see.
However with the current computerpower this seems unfeasible.
You could probably let two chess AIs play matches against each other using random allowed moves, and then train them using a neural network with a specific goal in mind, could be to win as fast as possible or something
genetic algorithms sound helpful here
just need to find a good heuristic
@skiwi Something like a Monte Carlo Tree search?
completely different topic...
> However, if this synthesizer doesn't make use of all 16 channels, some of the elements of the array might be null, so you should check each element before using it.
Bad Sound API for Java is Bad
@N3buchadnezzar Not sure, don't think so

« first day (1185 days earlier)      last day (3131 days later) »