instruction stringlengths 0 30k ⌀ |
|---|
First, synchronize all clocks in the system using NTP.
Second, if you are collecting the logs in a single location (like the UDP appender you mention) make sure the logs have enough information to actually help. I would include at least the server that generated the log, the time it happened, and the message. If t... |
This is a Windows Forms application? I was able to make a very fat and thick scrollbar by adjusting the "Width" property of my scroll bar control.
![Fat Scroll Bar][1]
Is your scroll bar something you have programmatic access to (i.e. it is a control you added to the form)?
[1]: http://www.smips.com/bra... |
My eventual (and hopefully temporary) solution to this problem was a Python CGI script. My script follows for anyone who might find it useful (despite the fact that this is a total hack).
#!/usr/bin/python
"""A CGI script to produce an RSS feed of top-level Gallery2 albums."""
#import cgi
#im... |
WPF Databinding |
|wpf| |
Can anyone point me to a good resource (or throw me a clue) to show me how to do databinding to controls (combobox, listbox, etc.) in WPF? I'm at a bit of a loss when all my WinForms niceities are taken away from me, and I'm not all that bright to start with...
Many Thanks, my fellow Stackies. |
The best resource I've found for WPF data binding is [Bea Costa's blog][1]. Start from the first post and read forward. It's awesome.
[1]: http://www.beacosta.com |
<? require 'auth.php' ?>
<.ul.>
<.li.><a href="">Home</a></.li.>
<.li.><a href="">Products</a></.li.>
<? if( loggedin() ) ?><li><.a href="">Secret area</a.></.li.><? endif; ?>
</.ul.>
Then in pages that require auth just do this:
<?php
require 'auth.php';
require_log... |
Outside the scope of your question so I debated not posting this but in Java there are actually 2 types of exceptions, checked and unchecked. The basic difference is that, much like in c[++], you dont have to catch an unchecked exception.
For a good reference [try this][1]
[1]: http://java.sun.com/docs/books... |
This isn't much better:
public function createShipment($startZip, $endZip, $weight=null){
$weight = !$weight ? $this->getDefaultWeight() : $weight;
}
// or...
public function createShipment($startZip, $endZip, $weight=null){
if ( !$weight )
$weight = $this->getDe... |
Modify Address Bar URL in AJAX App to Match Current State |
|ajax|rest|url|address-bar| |
I'm writing an AJAX app, but as the user moves through the app, I'd like the URL in the address bar to update despite the lack of page reloads. Basically, I'd like for them to be able to bookmark at any point and thereby return to the current state.
How are people handling maintaining RESTfulness in AJAX apps? Than... |
The way I typically go about coding permission systems is having 6 tables.
- Users - this is pretty straight forward it is your typical users table
- Groups - this would be synonymous to your departments
- Roles - this is a table with all permissions generally also including a human readable name and a descr... |
An approach I've used in various applications is to have a generic PermissionToken class which has a changeable Value property. Then you query the requested application, it tells you which PermissionTokens are needed in order to use it.
For example, the Shipping application might tell you it needs:
new Permi... |
The way to do this is to manipulate location.hash when AJAX updates result in a state change that you'd like to have a discreet URL. For example, this page's URL is:
> http://stackoverflow.com/questions/1457/modify-address-bar-url-in-ajax-app-to-match-current-state
If a client side function executed this code:
... |
Easy: [BCrypt][1].
[1]: http://www.mindrot.org/projects/ |
Just to clarify Greg's point 1. IIS Manager > Site properties > Directory Security > Secure Communications > Require Secure Channel (SSL) |
Hmm... I know that WebSphere is kind of hard to configure. Thats part of the reason we used ServiceMix for our ESB. Maybe its not enabled by default in WebSphere and you would have to turn it on in the config somewhere. |
using too much static bad or good ? |
|c++|static| |
i like to use static functions in c++ as a way to categorize them, like c# does.
Console::WriteLine("hello")
but is it good or bad ?
if the functions are often used i guess it doesn't matter, but if not do they put pressure on memory ?
The same goes for static const... |
> If I understand correctly, Perforce makes all files that are not checked out read-only.
This is only the default behaviour. If required, frequently changing files can be set to be read-write instead. See a full list of file modifiers [here](http://www.perforce.com/perforce/doc.current/manuals/p4guide/ab_filetypes... |
Pass reference to element in C# Array |
|c#|arrays| |
I build up an array of strings with
string[] parts = string.spilt(" ");
And get an array with X parts in it, I would like to get a copy of the array of strings starting at element
parts[x-2]
Other than the obvious brute force approach (make a new array and insert strings), is there a more elegant w... |
[I used this][1] in one of my internal tools at work.
[1]: http://einaros.blogspot.com/2006/11/put-hex-on-that-dump.html |
I think the best way for larger project is optparse, but if you are looking for an easy way, maybe http://werkzeug.pocoo.org/documentation/script is something for you.
from werkzeug import script
# actions go here
def action_foo(name=""):
"""action foo does foo"""
pass
... |
I think the best way for larger projects is optparse, but if you are looking for an easy way, maybe http://werkzeug.pocoo.org/documentation/script is something for you.
from werkzeug import script
# actions go here
def action_foo(name=""):
"""action foo does foo"""
pass
... |
I'm now using [ModelBinder](http://stackoverflow.com/questions/34709/how-do-you-use-the-new-modelbinder-classes-in-aspnet-mvc-preview-5#34725) so that my action method can look (basically) like:
public ActionResult Insert(Contact contact)
{
if (this.ViewData.ModelState.IsValid)
... |
**O(N) time, O(N) memory**
go over the list in order
for each item you see
if(HT.Contains(item)) -> HT.Remove(item)
else
ht.add(item)
at the end, the item in the HT is the item you are looking for.
|
**O(N) time, O(N) memory**
go over the list in order
for each item you see
if(HT.Contains(item)) -> HT.Remove(item)
else
ht.add(item)
at the end, the item in the HT is the item you are looking for.
----------
**comment**: I don't see how can people vote up solutions that give you NLogN ... |
**O(N) time, O(N) memory**
go over the list in order
for each item you see
if(HT.Contains(item)) -> HT.Remove(item)
else
ht.add(item)
at the end, the item in the HT is the item you are looking for.
----------
**comment**: I don't see how can people vote up solutions that give you NLogN ... |
**O(N) time, O(N) memory**
HT= Hash Table
HT.clear()
go over the list in order
for each item you see
if(HT.Contains(item)) -> HT.Remove(item)
else
ht.add(item)
at the end, the item in the HT is the item you are looking for.
Note (credit @Jared Updike): This system will find all Odd inst... |
I'm not sure Scrum is the central issue here; I'm guessing she feels threatened by the new guy bringing in a lot of new ideas and stirring things up. I've been in that situation before as the new person bringing in a new perspective on things, and sometimes it's just difficult to immediately bring those existing peopl... |
What is the diffference between the | and || or operators? |
In your menu file or w/e you put:
<? require 'auth.php' ?>
<ul>
<li><a href="">Home</a></li>
<li><a href="">Products</a></li>
<? if( loggedin() ): ?><li><a href="">Secret area</a></li><? endif; ?>
</ul>
Then in pages that require auth just do this:
<?php
require 'auth... |
in code behind -- set the DataContext of your list box equal to the collection you're binding to.
private void OnInit(object sender, EventArgs e)
{
//myDataSet is some IEnumerable
// myListBox is a ListBox control.
// Set the DataContext of the ListBox to myDataSet
myListB... |
@akdom's question to me:
Looping would work fine on my previous suggestion, and you don't need to do any calculations to determine if a number is even; in your loop, simply skip every even number, as shown below:
//Assuming theInteger is the number to be tested for primality.
// Check if theInteger is di... |
You could also log to the Windows Event log or to a table in a database. How often are people looking at the event log? If it's being examined on a regualr basis, writing to a table amkes the reporting back much easier as it's trivial to reverse the order and only show the last X events for the current time period. ... |
Eclipse : Class file name must end with .class exception in Java Search |
|eclipse|java|search|bug| |
|java|eclipse|search| |
I was hoping someone could help me out with a problem I'm having using the java search function in Eclipse on a particular project.
When using the java search on one particular project, I get an error message saying 'Class file name must end with .class' (see stack trace below). This does not seem to be happening on... |
Why do you need to fetch the sequence IDs in the first place? In most cases you would insert into a table and return the ID.
insert into t (my_pk, my_data) values (mysequence.nextval, :the_data)
returning my_pk into :the_pk;
It sounds like you are trying to pre-optimize the processing.
If you ... |
If you don't want the button to submit the form, then be sure it has type 'button' rather than 'submit'. For example, you might do something like this:
<input type="button" value="Show My Password" onclick="toggleShowPassword()"/> |
If you get rid of the UpdatePanels do things work as expected with PostBacks? Chances are something in your Page_Load or other event higher up the chain are "resetting" things in some way before it gets to your click event. Could this be the case? |
How about Array.Copy?
http://msdn.microsoft.com/en-us/library/aa310864(VS.71).aspx
(sorry, you'll need to copy the URL)
>Array.Copy Method (Array, Int32, Array, Int32, Int32)
>Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the spe... |
How about Array.Copy?
<http://msdn.microsoft.com/en-us/library/aa310864(VS.71).aspx>
>Array.Copy Method (Array, Int32, Array, Int32, Int32)
>Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index. The length... |
[http://gotcodesnippets.com/][1]
[1]: http://gotcodesnippets.com/ |
[http://gotcodesnippets.com/][1]
[http://www.codekeep.net/][2] has a VS add-in for their snippets, too
[1]: http://gotcodesnippets.com/
[2]: http://www.codekeep.net/ |
The only thing I'd add to <a href="http://stackoverflow.com/questions/44408/how-do-you-generate-a-random-number-in-c#44428">Eric</a>'s response is an explanation; I feel that knowledge of why code works is better than knowing what code works.
The explanation is this: let's say you want a number between 2.5 and 4.5. ... |
Printing HTML |
|c#|html|printing| |
I want to print HTML from a C# web service. The Web Browser control is overkill, and does not function well in a service-environment, nor does it function well on a system with very tight security constraints. Is there any sort of free .NET library that will support the printing of a basic HTMl page? Here is the cod... |
I want to print HTML from a C# web service. The Web Browser control is overkill, and does not function well in a service-environment, nor does it function well on a system with very tight security constraints. Is there any sort of free .NET library that will support the printing of a basic HTML page? Here is the cod... |
This is similar to what Kevin said. You can have your client state as some javascript object, and when you want to save the state, you serialize the object (using JSON and base64 encoding). You can then set the fragment of the href to this string. |
You can set a limit to memory consumption for APC, but that potentially limits its effectiveness. If you're just using it for silent opcode caching, then it should be fine. Once the memory allotment is full, no new files will be cached, but everything will work as expected. However, the user-space cache functions like ... |
One option is to use serialization. Here's a blog post explaining it:
<http://weblogs.java.net/blog/emcmanus/archive/2007/04/cloning_java_ob.html>
|
Turn that into a spec:
-that objects need to implement an interface in order to be allowed into the collection
Something like `ArrayList<ICloneable>()`
Then you can be assured that you always do a deep copy - the interface should have a method that is guaranteed to return a deep copy.
I think that's the bes... |
I suppose it is an ovbious answer:
Make a requisite for the classes stored in the collection to be cloneable. You could check that at insertion time or at retrieval time, whatever makes more sense, and throw an exception.
Or if the item is not cloneable, just fail back to the return by reference option. |
Since you're looking at an entire application stack, you'll need to virtualize the entire server to provide your customers with a realistic demo experience. Thinstall is great for single apps, but not an entire stack....
Microsoft have licensing schemes for this type of situation, since it's only been used for demon... |
Go to **Environment > Fonts and Colors > Display Item**s and change
- Identifier
- String
|
Go to **Environment > Fonts and Colors > Display Item**s and change
- Identifier
- String
> I was hoping that their is I can be
> more specific with the colours - if
> their isn't then that's an acceptable
> answer - just disappointing for me.
Yeah, I don't think you can do that. :) |
Jesus wept.
OK, you asked about C++. Not C. Not frigging _macros_. C++.
C++ has proper strings. Not C's stupid NTBS nonsense. Proper strings. Use them! They're in the standard header string. #include <string> to use them. No more strcat/strcpy buffer overruns; no more missing null terminators; no m... |
In your HTML:
<input type="button" onclick="toggleShowPassword();">
You need to use "button" rather than "submit" to prevent your form from posting. |
I'll just throw this out there cuz it's been asked.
Mailto has a lot of disadvantages; mainly size. Since the sender needs to do alot of formatting on the email text, the html code generated can take up a lot of space that fails when using mailto.
thanks for the suggestion though. |
[JSON is valid YAML](http://redhanded.hobix.com/inspect/yamlIsJson.html) which could be very useful. Two for one! |
I did a quick example up of a working version:
<html>
<head>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript">
function toggleShowPassword() {
var textBox = $('PasswordText');
if (textBox)
{
alert(te... |
I have run into this before and resolved it, I just can't remember how. I will try to find my old code and get back to you. one thought, do you have EnablePartialRendering enabled in your scriptmanager? maybe try wrapping both containers in a third panel. |
Here is a snippet of how to get Cryographically safe random numbers:
This will fill in the 8 bytes with a crytographically strong sequence of random values.
byte[] salt = new byte[8];
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
rng.GetBytes(salt);
For more details see [How Random... |
Most databases support BULK UPDATE or BULK DELETE operations. |
You cannot open something on the client from server side code. You'd have to use script on the page to do what you're wanting (or something else client-side like ActiveX or embedded .NET or something) |
You cannot open something on the client from server side code. You'd have to use script on the page to do what you're wanting (or something else client-side like ActiveX or embedded .NET or something)
Here's a sample Javascript that invokes an Outlook MailItem from an webpage. This could easily be injected into th... |
Log4Cxx should work for you. You need to implement a provider that allows the library user to catch the log output in callbacks. The library would export a function to install the callbacks. That function should, behind the scenes, reconfigure log4cxxx to get rid of all appenders and set up the "custom" appender.
Of... |
|c#|php|conditional|operator|bool| |
I have always used || (two pipes) in OR expressions, both in C# and PHP. Occasonally I see a single pipe used: | What is the difference between those two usages? Are there any caveats when using one over the other or are they interchangeable? |
Others will probably pitch in with technical answers (e.g. the query syntax, use of caching, ease or otherwise of mapping to an existing database structure) -- but if you have an established ORM layer the answer is probably
"Why change"?
I've used XPO successfully for years in an established commercial product w... |
One is a "bitwise or".
10011b | 01000b => 11011b
The other is a logic or.
true or false => true |
FlexUnit component testing patterns: use addAsync or manually initialize? |
|unit-testing|apache-flex| |
We've been using Flex for about 6 months here at work, and I found that my first batches of FlexUnit tests involving custom components would tend to follow this sort of pattern:
import mx.core.Application;
import mx.events.FlexEvent;
import flexunit.framework.TestCase;
public... |
Difference between a byte array and MemoryStream |
|performance|comparison| |
I am reading a binary file into a parsing program. I will need to iterate through the file and look for certain markers so I can split the file up and pass those parts into their respective object’s constructors.
Is there an advantage to holding the file as a stream, either MemoryStream or FileStream, or should it ... |
If I were in your shoes I would try to leverage what I knew (sprocs) with Linq2Sql. Linq2Sql can still use your sprocs but then you have the added bonus of putting a new tool in your belt. I think having a grap on the Linq2XXX (X being a random technology not adult entertainment....which isn't a bad idea now that I t... |
If I were in your shoes I would try to leverage what I knew (sprocs) with Linq2Sql. Linq2Sql can still use your sprocs but then you have the added bonus of putting a new tool in your belt. I think having a grasp on the Linq2XXX (X being a random technology not adult entertainment....which isn't a bad idea now that I ... |
You can right click on the tab strip and insert a new vertical (or horizontal) tab group.
This allows you to view multiple tabs at the same time. |
By the way you can use
> $_REQUEST['destroy']
which would work regardless if the data is passed in a POST or a GET request. |
What is the best way to rename (move) file system branches in .NET? |
|system.io.fileinfo|moveto|directory|branch| |
I would like to rename files and folders recursively by applying a string replacement operation.
E.g. The word "shark" in files and folders should be replaced by the word "orca".
C:\Program Files\Shark Tools\Wire Shark\Sharky 10\Shark.exe
should be moved to:
C:\Program Files\Orca Tools\Wire Orca\Orcay 10\Orc... |
|system.io.fileinfo|moveto|directory| |
|file|directory|system.io.fileinfo| |
I can appreciate the logic of not putting binaries in the repository but I think there is a huge advantage too. If you want to be able to pull a specific revision out from the past (usually an older tag) I like being able to have everything I need come from the svn checkout. Of course this doesn't include Visual Studio... |
This is similar to what Kevin said. You can have your client state as some javascript object, and when you want to save the state, you serialize the object (using JSON and base64 encoding). You can then set the fragment of the href to this string.
var encodedState = base64(json(state));
var newLocation = ... |
It has been a while, so this is not comprehensive.
**Character Sets**
Unicode is great, but you can't get away with ignoring other character sets. The default character set on Windows XP (English) is Cp1252. On the web, you don't know what a browser will send you (though hopefully your container will handle mos... |
It has been a while, so this is not comprehensive.
**Character Sets**
Unicode is great, but you can't get away with ignoring other character sets. The default character set on Windows XP (English) is Cp1252. On the web, you don't know what a browser will send you (though hopefully your container will handle mos... |
It has been a while, so this is not comprehensive.
**Character Sets**
Unicode is great, but you can't get away with ignoring other character sets. The default character set on Windows XP (English) is Cp1252. On the web, you don't know what a browser will send you (though hopefully your container will handle mos... |
> Is there a way one can ensure that the
> exceptions thrown are always caught
> using try/catch by the calling
> function?
I find it rather funny, that the Java crowd - [including myself][1] - is trying to avoid checked Exceptions. They are trying to work their way around being forced to catch Exceptions by usin... |