instruction stringlengths 0 30k ⌀ |
|---|
What is the easiest way to manage the authorized_keys file for openssh across a large number of hosts? If I need to add or revoke a new key to an account on 10 hosts say, I must login and add the public key manually, or through a clumsy shell script, which is time consuming.
Ideally there would be a central databas... |
Overriding the onchange attribute will not work if you have have AutoPostBack set to true because ASP.NET will always append the following to the end of your onchange script:
;setTimeout('__doPostBack(\'YourDropDown\',\'\')', 0)
If you set AutoPostBack to false, then overriding onchange with a "confirm and __... |
I think you need to give some more information. It's not really possible to answer why it's not working based on the information in the question. The basic documentation for random is at:
<http://docs.python.org/lib/module-random.html>
You might check there. |
Instead of using pdksh on linux, use the "real" ksh from kornshell.org. pdksh is a blind re-implementation of ksh. kornshell.org is the original korn shell dating back 25 years or so (the one written by David Korn). AIX and Solaris use versions of the original ksh, so the kornshell.org version is usually feature- an... |
Is it possible to connect to Mac OS X 10.5 Leopard's built in vnc server at a low color depth from Windows? |
|windows|macos|vnc| |
If I attempt to connect to Mac OS X 10.5 Leopard's built in vnc server at a low color depth from Windows, the client bombs after connecting. It only works when I set it to the highest color depth. I've tried with at least 3 windows VNC clients. Any ideas? There some setting I can set in Mac OS X?
It takes about 20 s... |
|macos|system-administration|osx-leopard| |
In other words:
1. Log on as Bert (who is an administrator)
2. Using fast user switching, log on as Ernie (Bert remains logged on)
3. Switch back to Bert
4. Bert logs Ernie off
What is the best way to achieve step 4? |
|macos|system-administration|osx-leopard| |
|macos|system-administration|osx-leopard| |
My goal in this question was to lock a file being used as a data store for several scripts. In the end I used similar code to the following (from Chris):
open (FILE, '>> test.dat'); # open the file
flock FILE, 2; # try to lock the file
# do something with the file here
close(FILE); # close the ... |
My goal in this question was to lock a file being used as a data store for several scripts. In the end I used similar code to the following (from Chris):
open (FILE, '>>', test.dat') ; # open the file
flock FILE, 2; # try to lock the file
# do something with the file here
close(FILE); # close t... |
This matches 1.2.3.* too
>^(\*|\d+(\.\d+){0,2}(\.\*)?)$
I would propose the less elegant:
(\*|\d+(\.\d+)?(\.\*)?)|\d+\.\d+\.\d+)
|
"[yield][1]" would come to my mind. Some of the Attributes like [[DefaultValue()]][2] are also among my favorites.
The "[var][3]" keyword is a bit more known, but that you can use it in .net 2.0 Applications as well (as long as you [use the .net 3.5 Compiler][4] and set it to output 2.0 code) does not seem to be kno... |
I've been using [this one][1], which goes a little lower than the WebBrowser, but still uses MSHTML, which does spit out some ugly HTML. For my purposes, I am doing a multi-tabbed editor with WYSIWYG and HTML edit mode (using [ICSharp.TextEditor][2]) with a Buffer class to update whenever tabs change. As part of that ... |
Changed the definition to int so that error messages could be transmitted.
int fsize(char* file) {
int size;
FILE* fh;
fh = fopen(file, "rb"); //binary mode
if(fh != NULL){
if( ! fseek(fh, 0, SEEK_END) ){
fclose(fh);
return -1;
}
... |
Change the definition to int so that error messages can be transmitted, and then use fseek() and ftell() to determine the file size.
int fsize(char* file) {
int size;
FILE* fh;
fh = fopen(file, "rb"); //binary mode
if(fh != NULL){
if( ! fseek(fh, 0, SEEK_END) ){
... |
Change the definition to int so that error messages can be transmitted, and then use fseek() and ftell() to determine the file size.
int fsize(char* file) {
int size;
FILE* fh;
fh = fopen(file, "rb"); //binary mode
if(fh != NULL){
if( fseek(fh, 0, SEEK_END) ){
... |
We've used both <http://jatha.sourceforge.net> and <http://www.jboss.com/products/rules>. They're both pretty good, but for the most part, JBoss rules seems to me to be overkill for a lot of what people do. They're both Java based.
It's worth remembering [Greenspun's Tenth Rule of Programming](http://c2.com/cgi/wiki... |
I believe this may be due to how the idea of [closures](http://en.wikipedia.org/wiki/Closure_(computer_science) work in Javascript.
I am just getting to grips with closures myself. Have a read of the linked wikipedia article.
Here's [another article](http://www.javascriptkit.com/javatutors/closures.shtml) with m... |
I believe this may be due to how the idea of [closures](http://en.wikipedia.org/wiki/Closure_(computer_science) work in Javascript.
I am just getting to grips with closures myself. Have a read of the linked wikipedia article.
Here's [another article](http://www.javascriptkit.com/javatutors/closures.shtml) with m... |
<pre>ORGANIZER;CN="Sally Example":mailto:sally@example.com<pre>
Looks like the answer |
I came up with a pseudocode solution, hope it helps.
create an array named timetable with 24 entries
initialise timetable to zero
for each user in SQLtable
firsthour = user.firsthour
lasthour = user.lasthour
firstminutes = 4 - (rounded down integer(user.firstminutes/15))
... |
In JavaScript, "this" always refers to the object invoking the function that is being executed. So if the function is being used as an event handler, "this" will refer to the node that fired the event. But if you have an object and call a function on it like:
myObject.myFunction();
Then "this" inside myFuncti... |
For simple Java apps I like to use Jar's. It is very simple to distribute one file that a user can just click on (Windows), or
java -jar jarname.jar
IMHO, jar is the way to go when simplicity is a main requirement. |
executable files are best but they are platform limited i.e. use gcj : http://gcc.gnu.org/java/ for linux to produce executables and use launch4j : http://launch4j.sourceforge.net/ to produce windows executables.
To package on linux you can use any rpm or deb packager. For win32 try http://en.wikipedia.org/wiki/Nullso... |
Create a table with just time in it from midnight to midnight containing each minute of the day. In the data warehouse world we would call this a time dimension. Here's an example:
TIME_DIM
-id
-time_of_day
-interval_15
-interval_30
an example of the data in the table would be
... |
Have you considered if you really *need* all that viewstate? For example, if you populate a datagrid from a database, all the data will be saved in viewstate by default. However, if the grid is just for presenting data, you dont need a form a all, and hence no viewstate.
You only need viewstate when there is some i... |
Since you have cygwin, I'd go with Perl. It's the easiest to learn (check out the O'Reily book: [Learning Perl][1]) and widely applicable.
[1]: http://books.google.com/books?id=bS--s5DAIHsC&dq=%22learning+perl%22&pg=PP1&ots=udTVanap5Y&sig=gJW55LqGpEXCHqRMgHfTJ8nmP70&hl=en&sa=X&oi=book_result&resnum=1&ct=result |
Maybe you been given sudo access to only some programs/paths? Then there is no way to do what you whant. (unless you will hack it somehow)<br/>
If it is not the case then maybe you can write bash script <br/>
<code>
cat > myscript.sh <br/>
#!/bin/sh </br>
ls -hal /root/ > /root/test.out <br/>
</code>press ctr... |
if you're wondering about setting up linux compatibility mode and you're running the GENERIC kernel:
# sysctl kern.emul.linux=1
to enable at boot uncomment the kern.emul.linux=1 line in /etc/sysctl.conf
|
You want some sort of IPC between clients and servers. If all clients were children, I think pipes would have been easiest; since they're not, I guess a server-operated shared-memory segment can be used to register clients, issue the shutdown command, and collect return codes posted there by clients successfully shutt... |
You want some sort of IPC between clients and servers. If all clients were children, I think pipes would have been easiest; since they're not, I guess a server-operated shared-memory segment can be used to register clients, issue the shutdown command, and collect return codes posted there by clients successfully shutt... |
Here's the VB6 declarations - I just copied them from the API viewer, which you should have as part of your VB6 installation. VB6 marshalls strings to null-terminated ANSI using the current code page.
Public Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
En... |
An easy way to do this would be to provide a cryptographic hash of your highscore value along with the score it self. For example, when posting the results via HTTP GET:
**http://example.com/highscores.php?score=500&checksum=0a16df3dc0301a36a34f9065c3ff8095**
When calculating this checksum, a shared secret should ... |
Try POP3Client in the [Net Commons package][1]; it'll let your Java program check for new mail for a particular account at whatever interval you want (every few minutes? hourly?), and get/delete messages as desired.
[1]: http://commons.apache.org/net/ |
We are using [Bitten][1] wich is integrated with trac. And it's python based.
[1]: http://bitten.edgewall.org/ |
JDIC may not always be available on your user's platform. A good way to do this is to use the javamail API. You can send a multi-part e-mail message as explained in this tutorial by SUN:
[Sending Attachments][1]
[1]: http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#SendingAttachments |
Is there a way to specify a different session store with Tomcat? |
|java|tomcat|session| |
Tomcat (version 5 here) stores session information in memory. When clustering this information is periodically broadcast to other servers in the cluster to keep things in sync. You can use a database store to make sessions persistant but this information is only written periodically as well and is only really used for ... |
It'll be in Active Directory, so you'd use ADSI/LDAP to look at CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=*example*,DC=*com*. Use Sysinternals' ADExplorer to have a dig around in there to find the value you're looking for. |
You might find that the [XNA library][1] has some support for working with WAV's etc. if you are willing to go down that route. It is designed to work with C# for game programming, so might just take care of what you need.
[1]: http://msdn.microsoft.com/en-us/xna/default.aspx |
Charting in web-based applications |
|asp.net|charts| |
What are the various charting tools that are available for displaying charts on a web page using ASP.NET?
I know about commercial tools such as Dundas and Infragistics.
I could have "googled" this but I want to know the various tools that SO participants have used? Any free charting tools that are available are a... |
The following works quite well for me:
string vsid;
protected override object LoadPageStateFromPersistenceMedium()
{
Pair vs = base.LoadPageStateFromPersistenceMedium() as Pair;
vsid = vs.First as string;
object result = Session[vsid];
Session.Remove(vsid);
return r... |
I recommend [Sortables][1] in [jQuery][2]. You can use it on list items or pretty much anything, including tables.
jQuery is very cross-browser friendly and I recommend it all the time.
[1]: http://docs.jquery.com/UI/Sortables
[2]: http://jquery.com/ |
What I want to do is something like this: I have enums with combined flagged values.
public static class EnumExtension
{
public static bool IsSet<T>( this T input, T matchTo ) where T:enum
{
return (input & matchTo) != 0;
}
}
So then I could do:
MyEnum tester = My... |
|c#|.net|enums|flags| |
What I want to do is something like this: I have enums with combined flagged values.
public static class EnumExtension
{
public static bool IsSet<T>( this T input, T matchTo )
where T:enum //the constraint I want that doesn't exist in C#3
{
return (input & matchTo) != 0;... |
Have you though of implementing the "Weak Event Pattern" instead of regular events?
1. [Weak Event Pattern in WPF][1]
2. [Weak Event Patterns (MSDN)][2]
[1]: http://shevaspace.spaces.live.com/blog/cns!FD9A0F1F8DD06954!471.entry
[2]: http://msdn.microsoft.com/en-us/library/aa970850.aspx |
Starting off with OpenGL under Cygwin |
|opengl|cygwin| |
Is it possible to compile and run OpenGL programs from under Cygwin? If yes, how? |
If you are testing the rendering engine I guess you could render specific test scenes, do a screen captures and compare them to reference test renderings. That way you can detect if changes in the engine breaks anything, visually. You can write similar test for the sound engine, or even animation (by comparing a series... |
It is possible to compile and run OpenGL programs under Cygwin. I illustrate the basic steps here:
1. I assume you know OpenGL programming. If not, get the [Red Book][1] (*The OpenGL Programming Guide*). It is mandatory reading for OpenGL anyway.
2. I assume you have Cygwin installed. If not, visit [cygwin.com][2... |
I'm not quite clear what you mean about hierarchical data with columns, can you clarify? One possibility is the new WPF DataGrid. Depending on the functionality you're looking for it *may* be what you're looking for. |
I'm not quite clear what you mean about hierarchical data with columns, can you clarify? One possibility is the new WPF DataGrid. Depending on the functionality you're looking for it *may* be what you're looking for.
The bits for datagrid are available on codeplex:
http://www.codeplex.com/wpf/Release/ProjectRelease... |
If you are making a game, you should be looking into [DirectX][1], [OpenGL][2], or [XNA][3].
[1]: http://msdn.microsoft.com/en-us/magazine/cc164112.aspx
[2]: http://csgl.sourceforge.net/
[3]: http://xna101.spaces.live.com/ |
Yes. Delphi for Win32 example here: <http://interop.managed-vcl.com/>
Shows how to use a C# as well as a Delphi.NET assembly from Delphi for Win32.
|
If it will work for what you're building, Virtual Earth is in 6.1 these days and has a lot of excellent and easy-to-use javascript calls in the API to load polygons. If you have the point data that defines the countries (which should be freely available), you can easily define a VEShape polygon with an array of VELatL... |
Can you post an example of what you're trying to do? It's not clear from your question what the actual problem is.
Here's an example of how to use the random module:
import random
print random.randint(0,10)
|
My experience with RS would lead me to suggest you go with just about anything else. I think the web services portion would work fine but I'd be concerned about how RS manages memory and how many reports you need to be running at once before making any decisions. I'm fighting with memory management problems today with ... |
Personally most users don't understand DPI and their images even trimmed down end up larger than the php.ini for most hosting companies allow.
I'm not sure how much control you want to give them or how you want the public side to behave.
I'd suggest using a dropbox FTP application such as http://etonica.com/dropb... |
How do I use an icon that is a resource in WPF? |
Attributes in general, but most of all DebuggerDisplay. Saves you years. |
Regions must never be used inside methods. They may be used to group methods but this must be handled with extreme caution so that the reader of the code does not go insane. There is no point in folding methods by their modifiers. But sometimes folding may increase readability. For e.g. grouping some methods that you u... |
BiranLy's answer is excellent. I would just like to add that document-vs-RPC can come down to implementation issues as well. We have found Microsoft to be Document-preferring, while our Java-based libraries were RPC-based. Whatever you choose, make sure you know what other potential clients will assume as well. |
I think that it's a useful tool, when used properly. In many cases, I feel that methods and enumerations and other things that are often folded should be little black boxes. Unless you must look at them for some reason, their contents don't matter and should be as hidden as possible. However, I never fold private metho... |
[Try this article][1] - I have some code at work that will erm, work if this doesn't...
[1]: http://bytes.com/forum/thread717576.html |
Generic Type Checking |
|c#|generics|type-safety|primitive| |
OK, here we go again! Following on from my [previous question](http://stackoverflow.com/questions/8625/generic-type-conversion-from-string) on Converting to a Generic Type from String, I thought I would ask another Generics-related question!
This time, **is there a way to enforce/limit the types that are passed to P... |
OK, here we go again! Following on from my [previous question](http://stackoverflow.com/questions/8625/generic-type-conversion-from-string) on Converting to a Generic Type from String, I thought I would ask another Generics-related question!
This time, **is there a way to enforce/limit the types that are passed to P... |
Ruby Net::HTTP - Read only x number of bytes of the body |
|ruby|http| |
It seems like the methods of Ruby's Net::HTTP are all or nothing when it comes to reading the body of a web page. How can I read, say, the just the first 100 bytes of the body?
I am trying to read from a content server that returns a short error message in the body of the response if the file requested isn't availa... |
Way to Alt-Tab through all applications in Virtual and Host PC |
|virtual-pc| |
I am using VirtualPc 2007 more and more, the one annoyance is "Alt-Tab".
What I want is to be able to use alt-tab to iterate through all of the applications in the host pc and virtual(s) as if they were one long list. Is there a setting or program to do this?
|
Hey - don't know if this works for ASP.NET but I've used the ZedGraph tool for my winforms apps and it is really nice.
|
Advanced MS-DOS by Ray Duncan. |
I don't like sed too much, but it works for such things...
var="Name2";sed -n "1p;s/\([^ ]*\) .*$var=\([^ ,]*\).*/\1 \2/p" < filename
Gives you
A B
a Val2
c Val7
|
If you use SQL Server, then SQL Server reporting services is not bad. It includes a free version of Dundas chart controls which allows you to do basic charting. There are are couple of issues with presentation and making it Firefox friendly but it's a pretty simple solution. - If you've SQL Server of course! |
In Struts 1.3, what's the best way for the Controller to fill the View with variables ? |
|java|model-view-controller|struts| |
I've just inherited some old Struts code.
If Struts (1.3) follows the MVC pattern, how do the Action classes fill the View with variables to render in HTML ?
So far, I've seen the Action classes push variables in `(1)` the HTTP request with
request.setAttribute("name", user.getName())
`(2)` in ActionFor... |
website or webapplication in.ASP.NET |
|asp.net|visual-studio| |
which VS template should be used for a ASP.NET website, the website template or the project | webapplication template. |
|wpf| |
I have a .ico file that is embedded as a resource (build action set to resource). I am trying to create a NotifyIcon. How can I reference my icon?
notifyIcon = new NotifyIcon();
notifyIcon.Icon = ?? // my icon file is called MyIcon.ico and is embedded
|
With Microsoft Sql Server:
--
-- Create test case
--
DECLARE @myDateTime DATETIME
SET @myDateTime = '2008-05-03'
--
-- Convert string
--
SELECT LEFT(CONVERT(VARCHAR, @myDateTime, 120), 10)
|
The only example I've seen is in [Pattern-Oriented Software Architecture Volume 1: A System Of Patterns][1].
[1]: http://www.amazon.com/Pattern-Oriented-Software-Architecture-System-Patterns/dp/0471958697 |
Redundant Call to Object.ToString() |
|c#|.net| |
I have a function that takes, amongst others, a parameter declared as *int privateCount*. When I want to call ToString() on this param, ReSharper greys it out and marks it as a redundant call. So, curious as I am, I remove the ToString(), and the code still builds!
How can a C# compiler allow this, where *str* is ... |
You don't say what language but I am assuming C#/.NET because it has a native DateTime data type. In that case just convert it using the ToString method and use a format specifier such as:
DateTime d = DateTime.Today;
string result = d.ToString("yyyy-MM-dd");
Howerver, I would caution against using this in a dat... |