|
keefb wrote: I still can't work out why
As to why, he only wants the date, with the time portion set to 0.
Marc
Will work for food.
Interacx
I'm not overthinking the problem, I just felt like I needed a small, unimportant, uninteresting rant! - Martin Hart Turner
|
|
|
|
|
And I should add the simplest version is:
DateTime.Today
Regards,
Mark Hurd, B.Sc.(Ma.) (Hons.)
|
|
|
|
|
Not good but I've seen worse.
I'm sitting in front of code that's full of...
try
{
// various code here
}
catch
{
}
finally
{
}
Empty catch and finally blocks everywhere.
In your case though I think that will break if regional language settings define the date format as anything other than date/month/year as it'll format it with the date first and then reparse it as say mm/dd/yyyy in the US causing the date and month to be swapped.
|
|
|
|
|
I just ran across this line of condition in a KeyUp handler.
if ((e.Modifiers.GetHashCode().ToString() + "+" + e.KeyCode.GetHashCode().ToString()) == "131072+39")
|
|
|
|
|
It could be worse. They could then split the generated string by the "+", convert each element to a float, and ask if the value is 131072. Then if it is, repeat the process with the second element using a nested if-statement.
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
... so that's the way to do it
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Of course. I can't think of any 'better' way to obfuscate make it version-dependant write it
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
I remember one program which wanted to check if two variables were equal to something like 73 and 89, in either order, so rather than testing whether (var1=73 and var2=89) or (var1=89 and var2=73) it tested whether var*var2=6497. Not sure whether that qualifies as brilliant or horrible. The two variables were bytes, and the constants were primes, so the factorization was unique.
|
|
|
|
|
supercat9 wrote: Not sure whether that qualifies as brilliant or horrible. The two variables were bytes, and the constants were primes, so the factorization was unique.
I'd go with horrible. Because they are bytes, the multiplication test relies on an implicit conversion to (at least) int16. Future failure coming up!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I'd go with horrible. Because they are bytes, the multiplication test relies on an implicit conversion to (at least) int16. Future failure coming up!
I can't see a problem there, since I don't know of any language which wouldn't do at least an 8x8->16 multiply. A more interesting problem would arise if the constants changed so the factorization was no longer unique.
|
|
|
|
|
Brilliant if documented by a comment that they must be primes. Otherwise Horror.
JustAStupidGurl
|
|
|
|
|
No comment...
If Request.QueryString("tsid") IsNot Nothing Then
Session("TSID") = sql.SQLValue("SELECT TSID FROM TimeRegHeader
WHERE TSID = " & Request.QueryString("tsid"))
End If
|
|
|
|
|
Do you mean the SQL injection vulnerability, the fact that data is stored in the session object or that you don't like this kind of validation?
|
|
|
|
|
I think he means the fact that the code sets the value of TSID to the result of a query that selects the value of TSID where the value of TSID is equal to the value of tsid.
Or something like that...
|
|
|
|
|
I think a web service query would have been even better!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
I supported an ASP classic application written by someone in almost the exact same way. Might it possibly be written by the same person idiot?
"A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson
"Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin
Edbert
Sydney, Australia
|
|
|
|
|
|
Where the code easy could be optimized to simply say: User.Allowed = UserAllowed;.
The question would be whether there would likely be any requirement to do something different in the true and false cases.
Incidentally, on some processors, if the source operand is of type bit, the "var1 = var2;" statement may be implemented a number of different ways (for the following examples, the destination is also of type bit; each line is a possible implementation):
var1 = 0; if (var2) var1 = 1;
var1 = 1; if (!var2) var1 = 0;
if (!var2) var1 = 0; if (var2) var1 = 1;
if (var2) var1 = 1; if (!var2) var1 = 0;
if (var2) var1 = 1; else var1 = 0;
if (!var2) var1 = 0; else var1 = 1;
If var1 is volatile, the first two ways are clearly distinct from the rest. If var1 and var2 are both volatile, the third and fourth ways are also distinct from the fifth and sixth (if var1 starts out 1, and if var2 changes from 0 to 1 between the two 'if' tests, var1 could change twice as a result of the assignment). The fifth and sixth ways are almost identical to each other, except that each will be faster in one case than the other (though one would have to examine the compiled code to know which was faster in each case).
|
|
|
|
|
I reserve my judgment and give the title idiot sparingly and in this case the person is truly an idiot (and no, he's had 10+ years of dev experience).
If you had seen the code he wrote you would agree too.
"A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson
"Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin
Edbert
Sydney, Australia
|
|
|
|
|
Just trying to get a list of websites for IIS7.
First we start here:
TempVBS2(WINSYSDIR ^ "inetsrv" ^ "appcmd.exe list site /text:site.name > " + FOLDER_TEMP ^ "site.names");
Next interesting bit in function TempVBS2:
if (LaunchAppAndWait(WINSYSDIR ^ "CScript.exe", SUPPORTDIR ^ "tmpbat2.vbs \"" + strCommand + "\" " + FOLDER_TEMP ^ "Magic.bat", LAAW_OPTION_HIDDEN + LAAW_OPTION_WAIT + LAAW_OPTION_WAIT_INCL_CHILD) < 0) then
Ok so now lets run some VBScript:
myCmd = argObj(0)
batFile = argObj(1)
myCmd = Replace(myCmd, "'", Chr(34))
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set oTS = oFSO.CreateTextFile(batFile)
oTS.WriteLine myCmd
oTS.Close
cmdCmd = "cmd /C " & batFile
Set oShell = CreateObject("WScript.Shell")
Call oShell.Run(cmdCmd, 0, True)
Great!! At this point its 50/50 whether or not the command actually ran. Assuming it did we then:
if (OpenFile(nFileHandle, FOLDER_TEMP, "site.names") < 0) then
abort;
endif;
ret = ListCreate(STRINGLIST);
while (GetLine(nFileHandle, sLine) = 0)
ListAddString(ret, sLine, AFTER);
endwhile;
if (CloseFile(nFileHandle) < 0) then
abort;
endif;
And VOILA!! We have our list of websites. Simple, elegant, mind-numbing.
By the way if anyone is interested this is mostly InstallScript.
|
|
|
|
|
Just wrote this 5 minutes ago...
Got a panel that displays a bunch of thumbnails of images. You can highlight these by mousing over them.
In the MouseMove event for the panel, I had this...
queueHighlight determinines which slide is currently highlighted.
queueOffset determines the start position of what is visible.
slideHovered is calculated from MouseEventArgs.X based on the thumbnail width.
if ((slideHovered + queueOffset) != queueHighlight)
{
if (queueHighlight != (slideHovered + queueOffset))
{
queueHighlight = (ushort)(slideHovered + queueOffset);
forceRender(HymnMgrTarget.QueueList);
}
else
{
queueHighlight = (ushort)(slideHovered + queueOffset);
}
}
I added the outer block when I first wrote the method. When tweaking it just then, I managed to add the inner if block, and only when I ran it and noticed that nothing had changed, did I realise my error.
this.Edit(reason:="oops");
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
|
At least you spotted and admitted it!
Weight loss Target
Weight at start [1/Feb/2009] 127kg
Weight now [31/Jul/2009] 107.7kg
Target weight : 80kg
Only 28 TO go hope to be there by March Wish me luck!
|
|
|
|
|
My thoughts exactly. If there were more developers with your kind of humility it would make the rest of our jobs much easier.
Thanks
|
|
|
|
|