instruction stringlengths 0 30k ⌀ |
|---|
|c#|java|python|openid| |
|web-application|openid| |
|web-applications|openid| |
How to hide the cancel button on an ASP.NET ChangePassword control |
|asp.net|webform| |
I'm considering using the ChangePassword control on an ASP.NET 2.0 Webform. I don't want the 'cancel' button to show.
Is there a good way to hide it without resorting to silly "width = 0" sort of games?
Or perhaps there's a generic way to walk through the parts of a composite control like this
and hide ind... |
|asp.net|webforms| |
How do you update your web application on the server? |
@Peter Hoffmann
Using generator expressions has the benefit of also producing an iterator but saves importing itertools. Furthermore, list comprehensions are generally preferred to map, thus, I'd expect generator expressions to be preferred to imap.
>>> l = [1, "foo", 4 ,"bar"]
>>> ",".join(str(bit) for ... |
I don't think that you can using pure LINQ. However, if you're doing this sort of thing a lot in your code you may be able to make this work with reflection. |
I've been on some of the jQuery mailing lists and from what I've read there, they most likely filter by tag name then class name (or vice versa if it was faster). They are obsessive about speed and would use anything to gain a smidgen of performance.
I really wouldn't worry about it too much anyway unless you are ru... |
This works in IE (and FF, I believe):
if(document.getElementById("uploadBox").value != "") {
// you have a file
}
|
> * I must have a reasonnable number of possible combinations (let's say 1M)
> * The code must be as short as possible, to avoid errors from the user
Well, if you want it to have at least one million combinations, then you need at least six digits. Is that short enough?
|
If you can use Javascript, there are several options:
navigator.appName
navigator.appVersion
[link][1]
Or something more robust by using a library such as [jQuery][2].
Finally, you could use the [BrowserDetect][3] object from QuirksMode.
Once you have the browser name and version, you can then in... |
At the end of the day, a single alphanumeric character has at least 36 possible values. If you include punctuation, lower case, etc then you can easily pass 72 possible values.
A non-colliding number that allows you to quickly compare strings would necessarily grow exponentially with the length of the string.
So... |
The main argument agaisnt building a pre-rocessor for C# is integration in Visual Studio: it would take a lot of efforts (if at all possible) to get intellisense and the new background compiling to work seamlessly.
Alternatives are to use a Visual Studio productivity plugin like [ReSharper][1] or [CodeRush][2].
The... |
I know that **Automator** in Mac OS X is not a shell but it is the best graphical tool I have ever used to do batch tasks. I think it is worth mentioning here as even I (self-titled as a power user) use it from time to time to rename files or other routines. Although these could be done in a few lines of shell script, ... |
@Matt Hamilton
Your answer works with the example above but would not work if the data set was 100, 75, 75, 50, 50 (where it would return only 3 rows). TOP WITH TIES only includes the ties of the last row returned... |
**JavaScript**
Using anonymous functions:
var f = function(n){
if(n>1){
return arguments.callee(n-1)*n;
}
return 1;
} |
I used to use git push to publish to my web server but lately I've just been using rsync. I try to make my site as agnostic about where it's running as possible (using relative paths, etc) and so far it's worked pretty well. The only challenge is keeping databases in sync, and for that I usually use the production data... |
Crucible got it (assuming SQL 2005 is an option). |
unit testing dynamic fixtures in CakePHP |
|unit-testing|cakephp|fixture| |
> If you are not familiar with the CakePHP framework, you can maybe still help me. CakePHP uses [SimpleTest][1]
In the cakephp framework i am building tests for a behavior that is configured by adding fields to the table. This is intended to work in the same way that adding the "created" and "modified" fields will a... |
unit testing of dynamic fixtures |
Is it possible to have a fixture change between test methods? If so, how can I do this?
My syntax for this problem :
In the cakephp framework i am building tests for a behavior that is configured by adding fields to the table. This is intended to work in the same way that adding the "created"
and "modified" f... |
Is there any reason not to just use [Google Analytics][1]? It's free, and you don't have to write it yourself. I use it, and it gives you a lot of information.
Sorry, I know it's not a "programming" answer ;)
[1]: http://www.google.com/analytics/ |
The best practice is to use a finaliser in your class and always use `using` blocks.
There isn't really a direct equivalent though, finalisers look like C destructors, but behave differently.
You're supposed to nest `using` blocks, that's why the C# code layout defaults to putting them on the same line...
... |
What I like to do is have a number of tables that represent the raw data, so in this case you'd have
Items (ID pk, Name, <properties>)
Tags (ID pk, Name)
TagItems (TagID fk, ItemID fk)
This works fast for the write times, and keeps everything normalized, but you may also note that for each tag, you'... |
I second the answer of Jonathan: this is a log analyzer, meaning that you must feed it as input the logfile of the webserver and it generates a summarization of it. Given that you are on a shared host, it is improbable that you can access to that file, and even if you would access it, it is probable that it contains th... |
Is there a way I can have a VM gain access to my computer? |
|vm| |
I would like to have a VM to look at how applications appear and to develop OS-specific applications, however, I want to keep all my code on my Windows machine so if I decide to nuke a VM or anything like that, it's all still there.
If it matters, I'm using VirtualBox. |
Your NAME variable is being substituted like this:
printf "Hello, %s\n" George W. Bush
Use this:
`#! /bin/sh
NAME="George W. Bush"
printf "Hello, %s\n" "$NAME"`
|
Your NAME variable is being substituted like this:
printf "Hello, %s\n" George W. Bush
Use this:
#! /bin/sh
NAME="George W. Bush"
printf "Hello, %s\n" "$NAME"
|
There is no doubt that **filtering by tag name first is much faster** than filtering by classname.
This will be the case until all browsers implement getElementsByClassName natively, as is the case with getElementsByTagName. |
If you're trying to test existing code that you're reluctant or unable to change, reflection is a good choice.
If the class's design is still flexible and you've got a complicated private method that you'd like to test separately, I suggest you pull it out into a separate class and test that class separately. This d... |
You should always be able make a normal network connection between the VM and the hosting OS, as though it were another computer on the same network. Which, in some sense, it is. |
This is usually handled with network shares. Share your code folder from your host machine and access it from the VMs. |
When you are creating the verification code, do you have access to the caller's phone number?
If so I would use the caller's phone number and run it through some sort of hashing function so that you can guarantee that the verification code you gave to the caller in step 1 is the same one that they are entering in st... |
Sounds like the controls aren't being databound properly after the postback.
Are you databinding the first dropdown in the page or in the codebehind?
If codebehind, are you doing it in on_init or on_load every time?
There might be an issue of the SelectedValue of the second drop down being set to a non-existent ... |
`wcstombs` doesn't get the size of the destination, so it can, in theory, buffer overflow.
And why are you using `sprintf` with what I assume are constants? Just use:
`EZMPPOST" " EZMPTAG "/" EZMPVER " " TYPETXT EOL`
C and C++ combines string literal declarations into a single string.
MSN |
It's still a technology worth using. There are lots of Windows Forms and unmanaged apps around that use GDI+ that either won't be upgraded, or that will be upgraded, but that don't need more advanced rendering capabilities. GDI+ is a good bolt-on solution for older applications, and for new applications written in Wind... |
The difference between loops |
|php|loops| |
It's about PHP but I've no doubt many of the same comments will apply to other languages.
Simply put, what are the differences in the different types of loop for PHP? Is one faster/better than the others or should I simply put in the most readable loop?
for ($i = 0; $i < 10; $i++)
{
# code...
}
fore... |
Eric Z Beard:
> I do store all dates in GMT. Here's the use case: something happened at 11:00 PM EST on the 1st, which is the 2nd GMT. I want to see activity for the 1st, and I am in EST so I will want to see the 11PM activity. If I just compared raw GMT datetimes, I would miss things. Each row in the report can repre... |
title in command prompt window |
|c|winapi| |
how can i change the command prompt window every time I execute a dos-based program by double clicking it, in c language. should i used windows API? thanks |
How to change the Title of the command prompt window |
How can I change the title of the command prompt window every time I execute a dos-based program by double clicking it, in c language. should I used windows API? |
How can I change the title of the command prompt window every time I execute a dos-based program by double clicking it, in c language. Should I use the Windows API? |
If you open the .aspx file and switch between design view and html view and
back it will prompt VS to check the controls and add any that are missing to
the designer file.
Also, according to [this blog][1], you can try to right click on the as(c/p)x and select "Convert to Web Application". When this is done you ... |
(The following comes from experience with VS2005.)
If you edit an ASPX page while debugging, then the codebehind doesn't get updated with the new classes. So, you have to stop debugging, trivially edit the ASPX page (like add a button or something), then click Design View, then delete the button. Then, your designer... |
ASP.NET and sending SMS/making phone calls |
|c#|asp.net|sms| |
I have a scenario where I need to make call a telephone(landline/mobile) or send SMS to a particular set of users only using ASP.NET and C#. The web application is not a mobile application.
How do I go about doing these? What typically would be the hardware requirements? I would be **extremely grateful** if you cou... |
I have a scenario where I need to make a call to a telephone(landline/mobile) or send SMS to a particular set of users only using ASP.NET and C#. The web application is not a mobile application.
How do I go about doing these? What typically would be the hardware requirements? I would be **extremely grateful** if yo... |
Well I found a solution that works, though I don't really like it. I had to delete the .designer.cs file then recreate and empty file with the same name. When I went back in and saved the aspx file again, the designer file was re-generated.
Dodgy! |
How do I implement a pre-commit hook script in SVN that calls dos2unix to validate checked-in file |
|python|svn|dos2unix| |
I was wondering if anyone here had some experience writing this type of script and if they could give me some pointers.
Thanks. |
Related to high availability: OpenBSD can be configured in a failover / HA way for firewalls. See [this description][1]. I've heard that they've done demos where such setups done as well (if not better) as high-end Cisco gear.
[1]: http://www.countersiege.com/doc/pfsync-carp/ |
Well, it seems I cannot do that. What I should be doing is [subclassing NSAnimation](http://developer.apple.com/documentation/Cocoa/Conceptual/AnimationGuide/Articles/TimingAnimations.html#//apple_ref/doc/uid/TP40003581-CJBGGDAD subclassing NSAnimation). This will work on a MacOS 10.4+ app, but not on Cocoa Touch, in w... |
>As fortune would have it I do have access to the log file for my site. I've been able to generate the HTML page on the server manually - I've just been looking for a way to get it to happen automatically. All I need is to execute a shell command and get the output to display as the page.
Sounds like a good job for ... |
Something like a callback delegate function in php |
|php|oop| |
I would like to implement something similar to a c# delegate method in PHP. A quick word to explain what I'm trying to do overall: I am trying to implement some asynchronous functionality. Basically some resource-intensive calls that get queued, cached, and dispatched when the underlying system gets around to it. W... |
You can use the WindowsIdentity.Impersonate method to
achieve this. This method allows code to impersonate a different Windows
user. Here is a link for more information on this method with a good sample:
<http://msdn.microsoft.com/en-us/library/system.security.principal.windowsidentity.impersonate.aspx>
Com... |
Definitely build. I help manage an ISP and we have two firewalls built. One is for fail over and for redundancy. We use a program called [pfsense][1]. I couldn't recommend this program more. It has a great web interface for configuring it and we actually run it off a compact flash card.
[1]: http://www.pfse... |
Troubleshooting a NullReference exception in a service |
|.net|exception|powershell|service| |
I have a windows service that runs various system monitoring operations. However, when running SNMP related checks, I always get a NullReference exception. The code runs fine when run through the user interface (under my username and password), but always errors running as the service. I've tried running the service... |
How to properly cast objects created through reflection |
|reflection|.net|c#| |
I'm trying to wrap my head around reflection, so I decided to add plugin capability to a program that I'm writing. The only way to understand a concept is to get your fingers dirty and write the code, so I went the route of creating a simple interface library consisting of the IPlugin and IHost interfaces, a plugin imp... |
|c#|.net|reflection| |
I'm trying to wrap my head around reflection, so I decided to add plugin capability to a program that I'm writing. The only way to understand a concept is to get your fingers dirty and write the code, so I went the route of creating a simple interface library consisting of the IPlugin and IHost interfaces, a plugin imp... |
As with most issues, it's not as simple as it sounds. There are cases where it would make sense to store the images in the database.
- You are storing images that are
changing dynamically, say invoices and you wanted
to get an invoice as it was on 1 Jan
2007?
- The government wants you to mainta... |
I use the first loop when iterating over a conventional (indexed?) array and the foreach loop when dealing with an associative array. It just seems natural and helps the code flow and be more readable, in my opinion. As for do...while loops, I use those when I have to do more than just flip through an array.
I'm not... |
Comparing effective dates in SQL |
|sql| |
Wondering if there is a better why in the WHERE clause of choosing records when you need to look at effective start and end dates?
Currently this how I've done it in the past on MS SQL Server. Just worried about the date and not the time. I'm using SQL Server 2005.
AND CAST(CONVERT( CHAR(10), ep.EffectiveStartDa... |
try
ep.EffectiveStartDate BETWEEN @date1 AND @date2
where you would do something like
declare @date1 datetime, @date2 datetime;
set @date1 = cast('10/1/2000' as datetime)
set @date2 = cast('10/1/2020' as datetime) |
Is there a Unix utility to prepend timestamps to lines of text? |
|unix|shell|sed| |
I ended up writing a quick little script for this in Python, but I was wondering if there was a utility you could feed text into which would prepend each line with some text -- in my specific case, a timestamp. Ideally, the use would be something like:
$ cat somefile.txt | prepend-timestamp
(Before you answe... |
|unix|shell| |
|unix|shell|awk| |
I ended up writing a quick little script for this in Python, but I was wondering if there was a utility you could feed text into which would prepend each line with some text -- in my specific case, a timestamp. Ideally, the use would be something like:
$ cat somefile.txt | prepend-timestamp
(Before you answe... |
Aside from network shares, another tool to use for this is a version-control system. |
Does it have to be only numbers? You could create a random number between 1 and 1M (I'd suggest even higher though) and then [Base32 encode it][1]. The next thing you need to do is Hash that value (using a secret salt value) and base32 encode the hash. Then append the two strings together, perhaps separated by the dash... |
The other thing to consider when using a GPU is the bus speed, Most Graphics cards are designed to have a higher bandwidth when transferring data from the CPU out to the GPU as that's what they do most of the time. The bandwidth from the GPU back up to the CPU, which is needed to return results etc, isn't as fast. So t... |
The TFS 2008 power toys does come with the tf history /followbranches command. But that command doesn't expand merges.
All it does is show you the change set history from A before branch B was created. What it doesn't show you is what change sets were merged from A -> B after the branch was created.
In other ... |
I have a tip regarding the "Track Active Item" option mentioned above, for when working with big projects. It's posted here:
<http://stackoverflow.com/questions/31163/forcing-the-solution-explorer-to-select-the-file-in-the-editor-in-visual-studio#46193> |
Test Driven Development in PHP |
|php|unit-testing|tdd| |
I am a web-developer working in PHP. I have some limited experience with using Test Driven Development in C# desktop applications. In that case we used nUnit for the unit testing framework.
I would like to start using TDD in new projects but I'm really not sure where to begin.
What recommendations do you have fo... |
Passing large files to WCF service. |