« first day (1566 days earlier)      last day (3380 days later) » 

8:01 PM
@BradleyDotNET umm... nope - don't know of any < 20 users to try to add to chat...
Ahhh hang on - we've got someone's 1-rep bot for close vote monitoring or something in another room... I'll try adding that
 
Sounds good
I tried logging in via FB instead, but it outsmarted me :(
 
So I've got this static class called Operations with fields that are constant ints. I have this method signature of: public static string GetOperationNameByValue(int operationId). With that method, I want to get the name of the Field by the value of the OperationId. I know I need to use reflection, but I can't seem to get to the name by the value.
 
@BradleyDotNET ^^^ result of adding the 1 rep user
 
Well thats dumb
 
I started with var fields= typeof(Operations).GetFields(), which appears to get some sort of IEnumerable of the field names, but I can't find any method that identifies a field by its value.
 
8:09 PM
GetFields should return FieldInfo structs
 
@EternalLearner sounds kinky
 
That you could then call GetValue on
The one that matches your value is the winner!
And yes, this sounds very odd.
 
private fields or public?
 
public
One sec and I'll try to figure out why GetValue doesn't seem to work...
Cause I've tried it before, but I can't remember why I had a problem with it.
 
the problem is you marked them as const
 
8:15 PM
Ah now I remember. GetValue(object obj) takes an object parameter for I have no idea what. I tried the following code expecting it to get the first field that had operationId as its value, but it throws an IndexOutOfBounds exception: var field = typeof(Operations).GetFields().GetValue(operationId);
 
@EternalLearner the parameter to GetValue is the instance you're looking to get the field value from
 
@EternalLearner
 
... So since it's a static class, I just pass in the Type?
 
typeof(Operations).GetFields(BindingFlags.NonPublic|BindingFlags.Static).Where(‌​x => (int)x.GetRawConstantValue() == 2)
 
I think, anyway. Someone asked a similar question here a couple of weeks ago. Turned out there was a missing overload
 
8:18 PM
Ooh! I'll take a look at that @CharlieBrown. Give me a sec.
 
Ohhh. Static
tl;dr
 
still wont work, compiler sees it as non-intialized
 
Yeah, on my end my ErrorList says there are errors, but isn't marking them. I'm restarting VS to see if it can see them.
 
@BradleyDotNET anyway... gonna head back to my room - nice to meet you and see you around no doubt
 
8:26 PM
@JonClements - thanks for stopping by :)
Rhubarb
 
@JonClements Nice to meet you as well
 
That's interesting. Copying and pasting code from here was the error. VS saw some characters that didn't exist. I retyped it, everything compiled fine. Testing now.
 
This SitemapSubmission application is almost done, oh thank the heavens.
 
@EternalLearner here you go, it even caches the reflection so you only pay the price once
public static class Operations
{
	private const int Angry = 1;
	private const int Happy = 2;
	private const int Jumpy = 3;
	private static IDictionary<object, string> _fields;

	static Operations(){
		_fields = typeof(Operations)
			.GetFields(BindingFlags.NonPublic|BindingFlags.Static)
			.Where(f => f.IsLiteral)
			.ToDictionary(f => f.GetRawConstantValue(), f => f.Name);
	}

	public static string GetOperationNameByValue(int operationId)
	{
		return _fields[operationId];
	}
}
 
Ooh! I didn't even think about caching the result! What a great idea!
On a sidenote, the code you pasted earlier worked like a charm! I got what I needed from that! Thanks a lot @CharlieBrown
 
8:38 PM
cool
 
I had considered a dictionary before too, but the value was where I was having trouble at. The "GetRawConstantValue" appears to be where I needed to go to get it.
 
const makes things kinky
 
Like my name apparently. XD
 
on the whole though, i would advise against ever doing this in the real world
 
Why is that?
 
8:42 PM
Its difficult to see the need, but im going to guess you have one, otherwise why do it? But ultimately you are making something that could be difficult to understand and maintain in the future
What does the calling code look like?
 
Oh damn... and making this easier to maintain was why I was doing this too. To be specific, the reason I needed to get the name of the operation was to write an error message by passing the Operations.
So for instance, I would do a security test on the Operations that the user has for a page, and if they fail them, I would call the BuildUnauthorizedUserMessage(params int[] operations) method.
 
ok, i see that
 
The BuildUnauthorizedUserMessage method would go through each param and get the name and operationId (the Operations constants themselves), then return them all in the message.
 
Ok, what about this instead
_errorMessages = new Dictionary<string, string>():
_errorMessages.Add(Operations.MakeUnicorns, "You totally screwed up the unicorns dude");
var error = _errorMessages[Operations.MakeUnicorns];
 
That's an interesting idea. I didn't think of storing the errorMessages themselves.
 
8:51 PM
well, its an idea anyway. 42 ways to skin a cat they say
 
I think this is more flexible though. With the way I have the BuildUnauthorizedUserMessage method set up, it will display all of the Operation Names/Ids together in an attractive format, and I just need to feed it Operations.CreateSalesOrder and/or Operations.ReadSalesOrder, and all that jazz.
I really appreciate all the input guys! Especially you @CharlieBrown! You all are awesome!
 
@CharlieBrown - Why show that error message?
There is no recovering from totally screwing up the unicorns.
 
Because blue obviously weighs more than red on the moon
 
Can I get some feedback on an answer?
 
@CharlieBrown - It really depends on how far the pin point can make a banana ride a bike.
 
8:56 PM
That depends, is it a good answer? ;)
 
0
Q: Postback inside update panel issue

NoBullManI have a panel inside an update panel that is initially hidden. When a row inside a grid is selected this panel is made visible with details of selected record. In this panel I have a dropdown list that does a postback in order to set the text of a label. When postback happens, the panel is made...

I don't know, I want to know if I answered it well.
 
Well, the italic usage seemed a bit gratuitous
 
Aside from that?
 
It seems like an XY problem. You gave him Y without helping with X
That said, I didn't understand the question enough to figure out what was broken, so I could be wrong
If the answer is "You can't do that" I would emphasize that
Right now it looks more like a discourse on why to do Y
 
@BradleyDotNET Because X is going to become a nightmare with each fix, essentially his code is always going to find its way to not being correct because of the inbalance of state between server / client.
@BradleyDotNET Well, you can... It will be a nightmare and difficult to maintain.
 
9:00 PM
i thought it was a good answer
the update panel is for those of us who do not know how to use ajax otherwise
but there is a price to pay for using it...spaghetti
 
I think it was a good post but the "addressing the question" part is really mixed in.
27
A: Good answers, but not to the question asked?

BradleyDotNETIn the best case, these are XY problems where they don't address the actual question. With the notable exception of "No, you can't do this, here's how to get where you want though" (with these, there is ideally an explanation of why you can't do it); these answers are not useful, since they don'...

 
I'll take a look at that in a second.
 
there is a good and bad to answering x but not really y as well. It forces the programmer to think, however, in a pinch and at crunch time these can be fustrating
 
I would just change it to emphasize/highlight the part that addresses the question. I usually do that in the first paragraph, then do the "Except you really should be doing Y" with the rest of the post
 
@BradleyDotNET I added a important note at the bottom, what you think?
 
9:06 PM
@ton.yeung i agree with that...its difficult to make the change though and commit. I guess its the whole "style under pressure" if your boss is up your ass with a deadline, you go with what you know that you can get done fast
 
Achievement: Iteratively apply "XY problem" to someone enough times to get them to question their purpose in life.
 
not saying you should...just saying the ability to commit to something new is difficult
but I guess one could retort with, "Welcome to Programming"
haha
 
Yeah.
 
@Greg Please review my edit
I added what (I think is) a direct answer to the question above your excellent explanation. I also fixed some verb tense/grammar issues.
 
@BradleyDotNET I did, couldn't handle the italics?
 
9:14 PM
you said the price to using webforms...so I added that if someone like myself for instance who is learning MVC started a project using MVC and the boss said he needed it tommorrow OR ELSE, since I know MVC less I would write spaghetti so I made sure I could pay my bills on friday
 
No, I left those in there
much as I was tempted not to :)
I even italicized my "Update Panel" to match your style
 
@ton.yeung not that I think its better because it isn't; its because i know webforms more so I could get the project done faster
 
I try to only do it to keywords / buzz words.
 
@Greg that is like the worst answer ever
 
the poster?
 
9:16 PM
instead of answering the question, it turned into a soap box of how much you dont like ajax update panels
 
@Greg why would you italicize those?
italics are usually for emphasis
 
@KendallFrey Idk
 
no...I was just adding my 2 cents
 
hahaha!
 
9:17 PM
@CharlieBrown Well, the Update Panel is horrible.
 
gah, my ^ got pushed out of the way :(
 
@Greg sure, but you didnt address the question at all
 
@ton.yeung lucky bastard....I have an hour left!
 
@CharlieBrown Sure I did, rethink because the approach is going to always encounter unless he enforces with query string and client side states to ensure they match.
 
@Greg the OP should be able to take the answer and implement the fix. you provided nothign
 
9:19 PM
@Greg emphasis on "Update Panel"
 
and most of the answer is incorrect
 
What is incorrect about it?
 
"this problem will be very complicated to fix" incorrect
"Hard to gauge page state" not true
 
In all fairness, I added the first one to try and summarize his answer into something that remotely addressed the question
 
"The only way to truly fix this, is what I call the circle jerk. You have to implement QueryStrings and other nuances to help ensure the Server-Side and Client-Side stay in synchronization. This will create spaghetti incredibly quick, so hopefully you enjoy pasta." basically just crazy talk
the last one is so untrue, i could rant about it all day
 
9:24 PM
Then rant about it, I'm curious. It constantly becomes inconsistent with Client-Side / Server Side interaction. I'm always fighting with the Update Panel.
 
i only worked in classic asp.net (weird calling it classic, huh?) for about a year and a half, and i dont think i've heard anybody say stay away from the update panel
 
@Greg and in the end, all the OP has to do is set the panel to visible on postback
 
personally, i have 0 experience with it
 
Ok, rant..
 
His implementation your correct.
 
9:25 PM
No need for querystrings at all, the update panel and the container page both maintain there own postback state
 
But in most instances the Update Panel is evil.
 
"The only way to truly fix this, is what I call the circle jerk." lol
!!urban circle jerk
 
How Can I return string from HttpRequest.SaveAs instead of saving on file?
 
@Steve [circle jerk](http://circle-jerk.urbanup.com/750544) 1.) When a group of males sit in a circle, jerking each other off.

2.) *NOT* when a group of males stand in a circle to jerk off onto a cookie or anything of the sort. That retarded [\[frat\]](http://urbandictionary.com/define.php?term=frat) game is called "Limp Biscuit"... which kind of indirectly explains why the band of the same namesake is so fucking horrible.

3.) When a bunch of blow(snip)
 
You dont have to synchronize, the point of of the update panel is so you DONT NEED to synchronize
"so hopefully you enjoy pasta" is sitting on the edge of calling the OP dumb
 
9:27 PM
I know the point of it, but the sheer point is often deviated from constantly. Especially when you rely on multiple grid pages that may exist within the same page.
Grid A dictates state of Grid B at postback even with Update Panel, Grid A will loose the Client-Side paging.
Breaking Grid B to
 
you just put them in the same updatepanel
 
Even when they're in the same one, it often still breaks.
You can create a simple handler, if a Web-Service is too much.
The Update Panel is horrible, maybe in 2005 it was awesome but now it sucks.
 
/s/The Update Panel/Asp.net
 
Its a nice discussion to have, ajax update panels VS web services (which is apples VS oranges)... but Stackoverflow is for answers to programming problems, not discussions on which technology is best. The fact that we are even arguing over it should tell you. SO community focus is on 'answers' to problems
By SO guidelines, its a bad answer
 
I'll agree with that, thus I deleted it.
However, the reality is the Update Panel doesn't play nicely with other components and libraries often. In reality it breaks frequently. You can often use a simple handler file to calculate and do most things. In the original OP's case it wouldn't of been ideal, but for others it is.
 
9:33 PM
dont get me wrong, just two days ago i was bashing updatepanel as well
 
46
A: Logging raw HTTP request/response in ASP.NET MVC & IIS7

mckameyDefinitely use an IHttpModule and implement the BeginRequest and EndRequest events. All of the "raw" data is present between HttpRequest and HttpResponse, it just isn't in a single raw format. Here are the parts needed to build Fiddler-style dumps (about as close to raw HTTP as it gets): reques...

 
but if the OP is getting paid to fix that updatepanel, he probs doesnt have time to redesign the entire app... youve been there yourself.
 
@CharlieBrown Ah, that is true.
I've had horrible experience with the Update Panel.
 
I avoid certain women for the same reason
 
lol
if you find them at the bar, add them to that list, if you find them in a club, add them to that list
if they have a tramp stamp, add them to that list
 
9:38 PM
If you find them at a wedding - make sure it's not your wedding
 
haha
 
He could solve it with:

if(Page.IsPostback)
pnContent.Visible = true;
 
Page.IsAjaxPostback
 
man i dont miss webforms at all
 
or is it:
var scriptManager = ScriptManager.GetCurrent(Page);

   if(scriptManager.IsInAsyncPostBack)
   {
     //do stuff on .net ajax postbacks
   }
i forget
 
9:40 PM
@CharlieBrown Are you sure? I thought it was just Page.IsPostback
 
it is on the code behind
i think he's using js (script manager)
 
Well, the Update Panel should still call the Asp.Net Page Life Cycle thus hitting Page_Load and hitting the Page.IsPostback
 
IsPostback is for normal postback, ajax triggers it too
but you should filter and handle separately
 
@Greg you should really remove the circle jerk reference out of your answer, it's really awkward reading it
 
thats what made webforms so messy
i wonder what meaning other cultures would make of that reference?
 
9:42 PM
i'm not sure
 
@CharlieBrown I call it the Circle Jerk because it jerks you between Client-Server-Client-Server
 
on a side note, incognito windows aren't incognito if you have multiple up
 
or if there is a window behind you
see what i did there?
 
NO :(
 
@CharlieBrown by "circle jerk" they may assume you're referencing to someone like this i.imgur.com/tdSdUxL.jpg
i.e. a literal circle who is a jerk.
 
9:48 PM
SFW?
 
ye
 
Wouldn't that be a circular jerk?
 
damn circles, they think they own flatland.
 
so
i have a question for you @CharlieBrown
 
uh oh
 
9:51 PM
i answered it myself as i was typing it
basically
The whole idea behind MODEL-view-controller is you create a model that supports your view. This is not the same model as your database models
 
@CharlieBrown - Do you have a brother named leroy or a friend named snoopy? :P
 
so when you structure databases, you try to come up with entities then go through the whole normalization thing
 
layers layers layers :P
 
when you do something like DDD, you kind of go through through the same process, except not normalizing it
 
i dont -try- to normalize, most of the time it just works
 
9:53 PM
but i think MVC refers to the UI pattern, so i'm not confused between MVC models and lets say DDD
 
and honestly, normalization is great, but not a goal
 
but i am confused because so many books say your DDD models shouldn't be modeled after your database
 
DDD is an approach, MVC is pattern that solves a programming problem
 
but we go through the same process for creating domain models as we do for designing database tables
sorry
/s/DDD/domain
 
Jeet Kune Do
 
9:54 PM
huh
 
Choose the best parts of each type of programming and use them together, throw the rest away
 
i like to put 10k lines in main
im bored
 
DDD is fun and all, but it wants you to make your whole domain model up front
 
is that bad?
 
write up user stories, write up ERD to support stories, create database based on ERD, create classes to map to database, create repository to expose classes, write up workflow based on user stories, create logic based on workflow to leverage repository, create services to abstract logic, create controllers based on workflow, leverage services in controllers, create views which utilize exposed abstracted logic to the user.
 
9:56 PM
personally, i think it's a good thing
 
i lean on XP a bit more. create the smallest thing that solves the immediate requirement, put off all other tasks until it is no longer responsible to do so
 
Does anyone know if there will be any adverse effects with:

var index = value.Split('\\').Last();
 
hm, that sounds like you don't worry about the design at all, and just have at it
lol
 
of course you need to design it. but im not going to make models for things that im not going to use yet
 
ohh i see
so you still create like domain models and shit, just not all at the start
 
9:58 PM
b/c it could change.
yeah
 
/s/could/will
man i'm on a roll with these string replaces today
 
i kind of do like a test first approach, but without tests... i like to write the code that uses /client code first... then make it compile
 
10:57 PM
sooooo much red tape
 
@Greg of course, if value is null or empty i'd assume
and depends what value is, because its not a string
 
11:18 PM
Anyone know of a really clean way through a console application submit a path to Google / Bing for a Sitemap.
 
Hey guys I have a question about A* pathfinding, I've been making a function that follows the psuedocode at the very bottom of this link : http://web.mit.edu/eranki/www/tutorials/search/

but I wanted some clarification on the last part, where it says to skip a node with a lower cost at the same position
 
@NETscape It is coming from the path of a File, so it should always be a valid item.
 
@Greg but string[] isn't an enumerable
so you can't do .Last
 
I need to sort out this URL Sitemap.
 
Sure it is :)
Arrays work with LINQ extensions
string[] test = new string[5];
string lastString = test.Last();
works just fine
System.Array implements IEnumerable
 
11:30 PM
Anyone have an idea to submit a file to Google and Bing through a Console? Basically need to submit something to here:
 
anybody? :C
 
guess it would help to add System.Linq; :p
 
@bug56 you might get better luck on CompSci.SE
I don't even know what A* pathfinding is
 
@bug56 i'm reading it
 
@Greg You should be able to use HttpClient to do that, I would think
 
11:31 PM
@Net
woops
thanks man
 
@Greg Not sure on the details though
 
i had to implement Dijkstra's in uni
 
@BradleyDotNET Just set as a reference in the console application? I know I could, just wasn't sure if it was the proper thing to do.
 
A* is finding the shortest path between two "nodes"
@NETscape basically the part I'm confused about is where it says "if a node with the same position as successor is in the OPEN list \" which doesn't make sense because no two nodes have the same position
 
@Greg sure, I don't see anything wrong with that reference in a console app
@NETscape I did as well (not that I remember any of it)
 
11:37 PM
Hm, that will be easy then.
Ugh, Google is going to force me to login with OAuth- Fuckers!
 
@Greg don't complain. I have an RSA dongle I have to use to log in to my VPN for two factor authentication
 
@Pheonixblade9 I'm trying to simply push up a Sitemap for Google to Crawl.
 
why not just update your robots.txt?
 
@Pheonixblade9 ...?
@Pheonixblade9 Not sure what that is, boss said we need to submit our SEO to Google and here are a bunch of files that you need to compress with GZip and push to google.
 
@Greg maybe with SEO it's different. Do you have a single page application or something?
with SEO you can usually provide routes in the robots.txt to allow crawlers to know how to access all of your content
 
11:52 PM
@Pheonixblade9 No, we have a massive EComeerce with over 50K links
@Pheonixblade9 Well, that is what I built
Just uses GZip and creates xml.
 
I'm not sure what to tell you without more information
 
@bug56 it makes sense i believe now
 
elaborate?
 
so you choose an arbitrary number of successors, in this case it is 8. right?
 
yep
2d tile based system
 
11:55 PM
yes
 
each node having it's own unique x and y coordinate
 
you could get to the tile marked in the pink square by going 6 east, and 1 north, or 5 east and 1 northeast or 1 northeast and 5 east, or 1 north and 6 east.
the distance cost of 5 east and 1 northeast is 6.414 or whatever
but the distance cost going 1 north and 6 east is 7
 
@Johan - I missed 33333
 
ouch. 44444 then
 
Yup lol, next week though :)
 

« first day (1566 days earlier)      last day (3380 days later) »