instruction stringlengths 0 30k ⌀ |
|---|
I'm getting into ASP.NET (C# - I know it doesn't matter for this particular question, but full disclosure and all that), and while I love that the `asp:`-style controls save me a lot of tedious HTML-crafting, I am often frustrated with certain behaviors. I encountered one last night when working with Master Pages: my `... |
But, [You could have invented Monads!][1]
> sigfpe says:
>>But all of these introduce monads as something esoteric in need of explanation. But what I want to argue is that they aren't esoteric at all. In fact, faced with various problems in functional programming you would have been led, inexorably, to certain solu... |
I'm not sure of the SQL Server syntax for this but in MySQL I would do
SELECT IDColumn, ( IF( Column1 >= 3, 1, 0 ) + IF( Column2 >= 3, 1, 0 ) + IF( Column3 >= 3, 1, 0 ) + ... [snip ] ) AS NumberOfColumnsGreaterThanThree FROM TableA;
EDIT: A very (very) brief Google search tells me that the CASE statement does wha... |
I'm guessing you're trying to prevent screen scraping?
In my honest opinion it's a tough one to solve and trying to fix by checking the value of HTTP_REFERER is just a sticking plaster. Anyone going to the bother of automating submissions is going to be savvy enough to send the correct referer from their 'automaton'... |
Another version of this (in middle school) was "Please Excuse My Dear Aunt Sally".
- Parentheses
- Exponents
- Multiplication
- Division
- Addition
- Subtraction
The mnemonic device was helpful in school, and still useful in programming today. |
You can't tell apart users and malicious scripts by their http request. But you can analyze which users are requesting too many pages in too short a time, and block their ip-addresses. |
If you are writing a site which takes credit card numbers for payment:
1. You should probably be as permissive as possible, so that if it does expire, you allow the credit card company to catch it. So, allow it until the last second of the last day of the month.
2. Don't write your own credit card processing code. ... |
Efficiently selecting a set of random elements from a linked list |
|language-agnostic|algorithm|list| |
Say I have a linked list of numbers of length N. N is very large and I don’t know in advance the exact value of N.
How can I most efficiently write a function that will return k completely random numbers from the list? |
check if your compiler supports stackavail() |
Programmatically access browser history |
|firefox| |
how can i create an application to read all my browser (firefox) history?
i noticed that i have in
C:\Users\user.name\AppData\Local\Mozilla\Firefox\Profiles\646vwtnu.default
what looks like a sqlite database (urlclassifier3.sqlite) but i don't know if its really what is used to store de history information.
i... |
|firefox|sqlite| |
One thing you can try is opening up the old .csproj file in notepad and replacing the ProjectReference tags with Reference tags. If you can write a parser, feel free to share. :)
Entry in .csproj file if it is a project reference
<ItemGroup>
<ProjectReference Include="..\WindowsApplication2\Windo... |
using System.Security.Principal;
...
WindowsPrincipal wp = (WindowsPrincipal)HttpContext.Current.User;
to get the current domain user. Of course you have to make sure that the IIS is set up to handle Windows Authentication. |
I don't know any tool, but you can try to access user settings via [IVsPersistSolutionOpts][1] interface
[1]: http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivspersistsolutionopts_members%28VS.80%29.aspx |
If you need specific servers, use WMI. If you just want all available servers:
<http://support.microsoft.com/kb/q287737/> |
I use [Tweak UI][1] to configure explorer so that apps don't steal focus; you can also configure how many times they flash in the taskbar as well.
EDIT: Once you are within Tweak UI, these options are found under General > Focus.
[1]: http://www.microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx |
I use [Tweak UI][1] to configure explorer so that apps don't steal focus; you can also configure how many times they flash in the taskbar as well.
EDIT: Once you are within Tweak UI, these options are found under General > Focus.
EDIT: @Kev, apparently there is [a 64-bit version][2] (not MS approved, apparently, ... |
Remember the order of the page lifecycle, and where you are databinding your form.
* PreInit
* Init
* Load
* Your Control Event Handler
If you are reading the value in the Control Event handler, yet databinding in Init or Load, you'll have the old value.
The trick is to always databind in the correct event,... |
I get all my unixish/GNU support using <A href="http://www.finkproject.org/">Fink</A> (which provides Debian-like package control) with the emacs22-carbon package which means I also get a clickable application. It does everything I expect it to do, and automagically starts using emacs extensions loaded with fink.
Go... |
I would certainly go with Vincent's answer. Just make absolutely certain you are closing and disposing the tcp connections properly etc. WMI seems a bit of overkill to me if that is all you're after. |
For myself, I have started insisting that every bug I find and fix be expressed as a test:
1. "Hmmm, that's not right..."
2. Find possible problem
3. Write a test, show that the code fails
4. Fix the problem
5. Show that the new code passes
6. Loop if the original problem persists
I try to do this even... |
For myself, I have started insisting that every bug I find and fix be expressed as a test:
1. "Hmmm, that's not right..."
2. Find possible problem
3. Write a test, show that the code fails
4. Fix the problem
5. Show that the new code passes
6. Loop if the original problem persists
I try to do this even... |
Using a referrer is very unreliable as a method of verification. As other people have mentioned, it is easily spoofed. Your best solution is to modify the application (if you can)
You could use a CAPTCHA, or set some sort of cookie or session cookie that keeps track of what page the user last visited (a session woul... |
In addition to the benefits already mentioned, another nice feature of using FogBugz is BugzScout, which you can use to report errors from your app and log them into FogBugz automatically. If you're a one person team, chances are there are some bugs in your code you've never seen during your own testing, so it's nice ... |
Javascript is another helpful tool to prevent (or at least delay) screen scraping. Most automated scraping tools don't have a Javascript interpreter, so you can do things like setting hidden fields, etc. |
Javascript is another helpful tool to prevent (or at least delay) screen scraping. Most automated scraping tools don't have a Javascript interpreter, so you can do things like setting hidden fields, etc.
Edit: Something along the lines of [this Phil Haack article](http://haacked.com/archive/2006/09/26/Lightweight_I... |
When I learned this in grade school (in Canada) it was referred to as BEDMAS:
**B**rackets
**E**xponents
**D**ivision
**M**ultiplication
**A**ddition
**S**ubtraction
Just for those from this part of the world... |
You may consider a third party email service who handles delivery issues:
- Exact Target
- Vertical Response
- Constant Contact
- Campaign Monitor
- Emma
- Return Path
- IntelliContact
- SilverPop |
I'm not really sure how applicable to programming the old BODMAS mnemonic is anyways. There is no guarantee on order of operations between languages, and while many keep the standard operations in that order, not all do. And then there are some languages where order of operations isn't really all that meaningful (Lis... |
How do I rake tasks within a ruby script? |
|ruby|cli|rake| |
I've got a Rakefile with a rake task that I would normally call from the commandline (rake blog:post Title).
I'd like to write a ruby script that calls that rake task multiple times, but the only solution I see is shelling out (`` or system).
What's the right way to do this? |
I had to do this for a project before. One of the major difficulties I had was explaining what I was trying to do to other people. I spent a ton of time trying to do this in SQL, but I found the pivot function woefully inadequate. I do not remember the exact reason why it was, but it is too simplistic for most applicat... |
I'm working on an application where users have to make a call and type a verification number with the keypad of their phone.
I would like to be able to detect if the number they type is correct or not. The phone system does not have access to a list of valid numbers, but instead it will validate the number against a... |
Recommendations for Web application performance benchmarks |
|performance|testing|web-application|benchmarking| |
I am about to start testing an intranet web application. Specifically, I have to determine the application's performance.
Please could somone suggest formal/informal standards for how I can judge the application's performance. |
|performance|testing|web-applications|benchmarking| |
Testing a variable to determine if it's numeric in Perl |
|perl|number| |
Is there a simple way in Perl that will allow me to determine if a given variable is numeric? Something along the lines of:
if (is_number($x))
{ ... }
would be ideal. A technique that won't throw warnings when the `-w` switch is being used is certainly preferred. |
Is there a simple way in Perl that will allow me to determine if a given variable is numeric? Something along the lines of:
if (is_number($x))
{ ... }
would be ideal. A technique that won't throw warnings when the `-w` switch is being used is certainly preferred.
---
Update. Thank you all for yo... |
|perl|numbers| |
Suggestions for Migrating from ASP.NET WebForms to ASP.NET MVC? |
|.net|asp.net|asp.net-mvc|webform| |
ASP.NET MVC has been [discussed](http://stackoverflow.com/questions/tagged/mvc) on this forum a few times. I'm about to do a large **migration** of several websites from classic ASP/ASP.NET WebForms to ASP.NET MVC and was wondering what kind of advice those of you with experience in both technologies have.
What I ha... |
I process a lot of credit card transaction at work, and I can tell you that the expiry date is inclusive. |
I process a lot of credit card transaction at work, and I can tell you that the expiry date is inclusive.
Also, I agree with Gorgapor. Don't write your own processing code. They are some good tools out there for credit card processing. Here we have been using [Monetra][1] for 3 years and it does a pretty decent job... |
We actually built one in-house where I work. Unfortunately, it's not available for the public.
This is actually a great project to work on and it's not that hard to do. If you plan on doing something by yourself, I suggest you read about [Quantity][1], [Dimension][2] and [Unit][3] ([fundamental units][4]).
These ... |
Any restrictions on development in Vista |
|iis|windows-vista| |
I'm looking at a new computer which will probably have vista on it. But there are so many editions of vista; are there any weird restrictions on what you can run on the various editions? For instance you couldn't run IIS on Windows ME. Can you still run IIS on the home editions of vista? |
In your example a credit card is expired on 6/2008.
Without knowing what you are doing I cannot say definitively you should not be validating ahead of time but be aware that sometimes business rules defy all logic.
For example, where I used to work they often did not process a card at all or would continue on tra... |
I would suggest: First find your k random numbers. Sort them. Then traverse both the linked list and your random numbers once.
If you somehow don't know the length of your linked list (how?), then you could grab the first k into an array, then for node r, generate a random number in [0, r), and if that is less than ... |
vBulletin uses a sort of Pseudo-Cron system, that basically checks a schedule on every page access, and fires any processes that are due then.
It's been a while since I worked with Wordpress, but I think something like this should work if it runs on each page view. |
Well, you do need to know what N is at runtime at least, even if this involves doing an extra pass over the list to count them. The simplest algorithm to do this is to just pick a random number in N and remove that item, repeated k times. Or, if it is permissible to return repeat numbers, don't remove the item.
Unle... |
<pre><code>
--Example SQL
CREATE TABLE D001_Students
(
StudentID INTEGER CONSTRAINT nnD001_STID NOT NULL,
ChristianName NVARCHAR(255) CONSTRAINT nnD001_CHNA NOT NULL,
Surname NVARCHAR(255) CONSTRAINT nnD001_SURN NOT NULL,
CONSTRAINT pkD001 PRIMARY KEY(StudentID)
);
CREATE INDEX idxD001_STI... |
Perhaps you could deserialise the byte array using a known encoding and ensure that (a) it doesn't throw any exceptions, and (b) deserialises to the original string. It seems that from your description of the scenario, you may not have the original string readily available. Might there be a way to create it? |
How do i enable MSTDC on sqlserver? |
|msdtc| |
Is that even a valid question? I have a .Net windows app that is using MSTDC and it throwing an exception:
> System.Transactions.TransactionManagerCommunicationException:
> Network access for Distributed
> Transaction Manager (MSDTC) has been
> disabled. Please enable DTC for
> network access in the security
> ... |
You can use Merge Replication. Theres a tutorial here [SQL Server Compact 3.5 How-to Tutorials][1] (Number 5).
[1]: http://msdn.microsoft.com/en-us/sqlserver/bb219480.aspx |
MSDTC must be enabled on both systems, both server and client.
<br />
Also, make sure that there isn't a firewall between the systems that blocks RPC.<br/>
<a href="http://www.sqldev.net/misc/DTCTest.htm">DTCTest</a> is a nice litt app that helps you to troubleshoot any other problems.<br /> |
|asp.net|controls| |
Scheme
(define (factorial x)
(if (= x 0) 1
(* x (factorial (- x 1)))))
|
**Scheme**
Here is a simple recursive definition:
(define (factorial x)
(if (= x 0) 1
(* x (factorial (- x 1)))))
Scheme also provides the requirement that tail-recursive functions use constant stack space. Here is a version of factorial that is tail-recursive:
(define factorial
... |
**Scheme**
Here is a simple recursive definition:
(define (factorial x)
(if (= x 0) 1
(* x (factorial (- x 1)))))
In Scheme tail-recursive functions use constant stack space. Here is a version of factorial that is tail-recursive:
(define factorial
(letrec ((fact (lambda (x a... |
**C/C++**
unsigned long factorial(int n)
{
unsigned long factorial = 1;
int i;
for (i = 2; i <= n; i++)
factorial *= i;
return factorial;
}
**PHP**
function factorial($n)
{
for ($factorial = 1, $i = 2; $i <= $n; $i++)
$factorial *... |
**C/C++**
unsigned long factorial(int n)
{
unsigned long factorial = 1;
int i;
for (i = 2; i <= n; i++)
factorial *= i;
return factorial;
}
**PHP**
function factorial($n)
{
for ($factorial = 1, $i = 2; $i <= $n; $i++)
$factorial *... |
**C/C++**: Procedural
unsigned long factorial(int n)
{
unsigned long factorial = 1;
int i;
for (i = 2; i <= n; i++)
factorial *= i;
return factorial;
}
**PHP**: Procedural
function factorial($n)
{
for ($factorial = 1, $i = 2; $i <= $n; $... |
Suggestions on Ajax development environment for PHP |
|php|ajax|ide|webdevelopment| |
I am a C/C++ programmer professionally, but I've created a couple of personal web sites using PHP and MySQL. They're pretty basic, and I'd like to jazz them up using Ajax, but I've never done any Ajax. I've done all the development so far manually, i.e. no IDE or anything like that.
Does anyone have suggestions on A... |
Sorry I can't help toooooo much, but go to http://twit.tv, and find the Security Now podcast - they did one a couple of weeks ago on DNS - get the first one. It has a good explanation of how it works etc (which may help).
The second one on that site is about how it's been "hacked" - the first one is the how it works... |
Sorry I can't help toooooo much, but go to http://twit.tv, and find the Security Now podcast - they did one a couple of weeks ago on DNS - get the first one. It has a good explanation of how it works etc (which may help).
The second one on that site is about how it's been "hacked" - the first one is the how it works... |
.NET Console Application Tab Completion |
|.net|console| |
Any ideas on how to implement tab completion for a .NET (C#) Console Application?
And I mean within an application that is run and then loops for user input (like if you run ftp.exe without any arguments), like this:
string line = string.Empty;
while (line != "exit")
{
... |
Since there currently isn't a MS SQL client for Mac OSX, I would, as [Modesty][1] has suggested, use [Remote Desktop][2] for the Mac.
[1]: http://stackoverflow.com/questions/3452/sql-server-client-for-osx#3455
[2]: http://www.microsoft.com/mac/products/remote-desktop/default.mspx |
Ed: phpmyadmin is for MySQL, but the asker needs something for Microsoft SQL Server (MSSQL).
Most solutions that I found involve using an ODBC Driver and then whatever client app you use. For example, [Gorilla SQL][1] claims to be able to do that, even though the project seems abandoned.
Most **good** solutions a... |
from [timocracy.com][1]:
require 'rake'
require 'rake/rdoctask'
require 'rake/testtask'
require 'tasks/rails'
def capture_stdout
s = StringIO.new
oldstdout = $stdout
$stdout = s
yield
s.string
ensure
$stdout = oldstdout
end
... |
@CodingTheWheel Heres your code through eclipse (ctrl+shift+f) and the inserted back here :)
Including the four spaces in front each line.
public static boolean simpleNLP(String inputline, String keywords[]) {
int i;
int maxToken = keywords.length;
int to, from;
if (inputline.length() < 1)
re... |
@CodingTheWheel Heres your code, a bit clean up and through eclipse (ctrl+shift+f) and the inserted back here :)
Including the four spaces in front each line.
public static boolean simpleNLP(String inputline, String keywords[]) {
if (inputline.length() < 1)
return false;
List<String> lexed = new ... |
That's good.
You're right, I don't have the original string, since I'm testing a module that creates an XML document as a byte array. I didn't think about deserializing to a String with an expected encoding. That will do the trick. Thanks! |
Do you even need MSDTC? The escalation you're experiencing is often caused by creating multiple connections within a single TransactionScope.
If you do need it then you need to enable it as outlined in the error message. On XP:
- Go to Administrative Tools -> Component Services
- Expand Component Services -> Com... |
Have a look at this:
http://www.albahari.com/nutshell/linqbridge.html
Linq is several different things, and I'm not 100% sure which bits you want, but the above might be useful in some way. If you don't already have a book on Linq (I guess you don't), then I found "Linq In Action" to be be good. |
If you're looking for high performance, you are going to want to avoid paging completely, so the page file size becomes less significant. Invest in as much RAM as feasible for the DB server. |
Copy some simple code line by line and get them to read and interpret it as they go along. They will soon work it out. I started programming on an Acorn Electron with snippets of code from Acorn magazines. I had no idea about programming when I was 6, I used to copy the text, but gradually I learnt what the different w... |
I would recommend in first teaching the very basics that are used in almost every language, but doing so without a language. Outline all the basic concepts If-Else If-Else, Loops, Classes, Variable Types, Structures, etc. Everything that is the foundation of most languages. Then move onto really understanding Boolean, ... |
If I understand you correctly, the idea is to get a different "singleton" object for each caller object or "context".
One thing you can do is to create a thread-local global variable where you write the ID of the current context. (This can be done with AOP.) Then in the singleton getter, the context ID is fetched from... |
Sometimes you might find yourself working on a team where #regions are encouraged or required. If you're like me and you can't stand messing around with folded code you can turn it off outlining for C#:
1. Options -> Text Editor -> C# -> Advanced Tab
2. Uncheck "Enter outlining mode when files open" |
Sometimes you might find yourself working on a team where #regions are encouraged or required. If you're like me and you can't stand messing around with folded code you can turn off outlining for C#:
1. Options -> Text Editor -> C# -> Advanced Tab
2. Uncheck "Enter outlining mode when files open" |
According to Visa's "Card Acceptance and Chargeback Management Guidelines for Visa Merchants"; "Good Thru" (or "Valid Thru") Date is the expiration date of the card. It is located below the embossed account number. **If the current transaction date is after the "Good Thru" date, the card has expired.** |
So you're using a DOM method to create a `script` element and append that to an existing element and this then causes the content of the appended `script` element to execute? That sounds good.
You say that the script tag is part of a larger HTML page and therefore cannot be singled out. Can you not give the script t... |
This might be helpful:
WindowsIdentity myIdentity = WindowsIdentity.GetCurrent();
WindowsPrincipal myPrincipal = new WindowsPrincipal(myIdentity);
string name = myPrincipal.Identity.Name;
string authType = myPrincipal.Identity.AuthenticationType;
string isAuth = myPrincipal.Identity.I... |
Why can't you just do something like
List GetKRandomFromList(List input, int k)
List ret = new List();
for(i=0;i<k;i++)
ret.Add(input[Math.Rand(0,input.Length)]);
return ret;
I'm sure that you don't mean something that simple so can you specify further?
|