instruction stringlengths 0 30k ⌀ |
|---|
I know this is going to seem old-fashioned, but I don't think much of using online tutorials to learn programming languages or platforms. These generally give you no more than a little taste of the language. To really learn a language, you need the equivalent of a "book", and in many cases, this means a real dead-tree book.
If you want to learn C, read K&R. If you want to learn C++, read Stroustrup. If you want to learn Lisp/Scheme, read SICP. Etc.
If you're not willing to spend more than $30 and a few hours to learn a language, you probably aren't going to learn it. |
TortoiseSVN, at least, has an option called Relocate which you can use if the location of the repository has changed.
Also, this is a good example why you should always, always use DNS/hostnames instead of the IP address directly. |
I don't believe you can. You might be better off aliasing commonly used commands in a script that you call from your profile script.
Example -
Set-Alias np c:\windows\notepad.exe
Then you have your short, easily typeable name available from the command line. |
CSV (or sheet in XLS) to SQL create (and insert) statements with .Net? |
|.net|sql|csv|xls| |
Does anyone have a technique for generating SQL table create (and data insert) commands pragmatically from a CSV (or sheet in a .xls) file?
I've got a third party database system which I'd like to populate with data from a csv file (or sheet in a xls file) but the importer supplied can't create the table structure automatically as it does the import. My csv file has lots of tables with lots of columns so I'd like to automate the table creation process as well as the data importing if possible but I'm unsure about how to go about generating the create statement... |
Paul's right.
In PowerShell, function parameters are not enclosed in parenthesis. (Method parameters still are.)
Your initial call was just passing one big array to the function, rather than the three separate parameters you wanted. |
Matt Sheppard's answer is great (mod up), but I would take account these factors when thinking about a spindle:
1. Structure : does it obviously break into pieces, or are you making tradeoffs?
2. Usage : how will the data be analyzed/retrieved/grokked?
3. Lifetime : how long is the data useful?
4. Size : how much data is there?
One particular advantage of CSV files over RDBMSes is that they can be easy to condense and move around to practically any other machine. We do large data transfers, and everything's simple enough we just use one big CSV file, and easy to script using tools like rsync. To reduce repetition on big CSV files, you could use something like [YAML](http://yaml.org). I'm not sure I'd store anything like JSON or XML, unless you had significant relationship requirements.
As far as not-mentioned alternatives, don't discount [Hadoop](http://hadoop.apache.org/core/), which is an open source implementation of MapReduce. This should work well if you have a TON of loosely structured data that needs to be analyzed, and you want to be in a scenario where you can just add 10 more machines to handle data processing.
For example, I started trying to analyze performance that was essentially all timing numbers of different functions logged across around 20 machines. After trying to stick everything in a RDBMS, I realized that I really don't need to query the data again once I've aggregated it. And, it's only useful in it's aggregated format to me. So, I keep the log files around, compressed, and then leave the aggregated data in a DB.
*Note* I'm more used to thinking with "big" sizes. |
Here is a couple of ideas that may help
1. long running processes, they are not asp.net best friend.
2. scaling, using client side processing as compared to bigger or more servers reduces cost etc.
|
@Mark
> scaling, using client side processing as compared to bigger or more servers reduces cost etc.
I'm not sure I would entirely agree with this. It would seem to cost less to buy 1 powerful server and 1,000's of "dum terminals" than an average powerful server and 1,000 of powerful desktop computers. |
You could use <a href="http://search.cpan.org/~rgarcia/perl-5.10.0/lib/DirHandle.pm">DirHandle</a>:
<pre>
use DirHandle;
$d = new DirHandle ".";
if (defined $d) {
while (defined($_ = $d->read)) { something($_); }
$d->rewind;
while (defined($_ = $d->read)) { something_else($_); }
undef $d;
}
</pre>
DirHandle provides an alternative, cleaner interface to the opendir(), closedir(), readdir(), and rewinddir() functions. |
Currently these are the most popular video frameworks available on Win32 platforms:
1. Video for Windows: old windows framework coming from the age of Win95 but still widely used because it is very simple to use. Unfortunately it supports only AVI files for which the proper VFW codec has been installed.
2. DirectShow: standard WinXP framework, it can basically load all formats you can play with Windows Media Player. Rather difficult to use.
3. [Ffmpeg][1]: more precisely libavcodec and libavformat that comes with Ffmpeg open- source multimedia utility. It is extremely powerful and can read a lot of formats (almost everything you can play with [VLC][2]) even if you don't have the codec installed on the system. It's quite complicated to use but you can always get inspired by the code of ffplay that comes shipped with it or by other implementations in open-source software. Anyway I think it's still much easier to use than DS (and much faster). It needs to be comipled by MinGW on Windows, but all the steps are explained very well [here][3] (in this moment the link is down, hope not dead).
4. [QuickTime][4]: the Apple framework is not the best solution for Windows platform, since it needs QuickTime app to be installed and also the proper QuickTime codec for every format; it does not support many formats, but its quite common in professional field (so some codec are actually only for QuickTime). Shouldn't be too difficult to implement.
5. [Gstreamer][5]: latest open source framework. I don't know much about it, I guess it wraps over some of the other systems (but I'm not sure).
All of this frameworks have been implemented as backend in OpenCv Highgui, except for DirectShow. The default framework for Win32 OpenCV is using VFW (and thus able only to open some AVI files), if you want to use the others you must download the CVS instead of the official release and still do some hacking on the code and it's anyway not too complete, for example FFMPEG backend doesn't allow to seek in the stream.
If you want to use QuickTime with OpenCV [this][6] can help you.
[1]: http://ffmpeg.mplayerhq.hu/
[2]: http://www.videolan.org/vlc/
[3]: http://arrozcru.no-ip.org/ffmpeg/
[4]: http://developer.apple.com/quicktime/download/
[5]: http://www.gstreamer.net/
[6]: http://path.berkeley.edu/~zuwhan/QTforOpenCVWin/ |
Anonymous types have nothing to do with the design of systems or even at the class level. They're a tool for developers to use when coding.
I don't even treat anonymous types as types per-se. I use them mainly as method-level anonymous tuples. If I query the database and then manipulate the results, I would rather create an anonymous type and use that rather than declare a whole new type that will never be used or known outside of the scope of my method.
For instance:
var query = from item in database.Items
// ...
select new { Id = item.Id, Name = item.Name };
return query.ToDictionary(item => item.Id, item => item.Name);
Nobody cares about `a, the anonymous type. It's there so you don't have to declare another class. |
Use them with Linq. |
I would advice following the advice from @Sean, but if that fails for whatever reason, it should be possible to configure dhclient to not request DNS servers in /etc/dhcp3/dhclient.conf
|
Be careful when using smart pointers and container classes. |
How to save persistent objects databound to a DataLayoutControl (DevExpress tools) ? |
|devexpress|xpo| |
I have a small form displaying the DataLayoutControl component.
If I use a GridControl the objects get saved. If I use the DataLayoutControl (which shows them individually) they do not get saved after they are changed. The underlying object is changed after the user interface edits, but doesn't get saved.
How can I enable this ?
PS: I have tried UnitOfWork.CommitChanges (i have one uow going through the whole architecture) to no avail. |
|.net|devexpress|xpo| |
If you are using a database that supports map-reduce, like couchdb, storing tags in a plain text field or list field is indeed the best way. Example:
tagcloud: {
map: function(doc){
for(tag in doc.tags){
emit(doc.tags[tag],1)
}
}
reduce: function(keys,values){
return values.length
}
}
Running this with group=true will group the results by tag name, and even return a count of the number of times that tag was encountered. It's very similar to [counting the occurrences of a word in text][1].
[1]: http://jchris.mfdz.com/posts/107 |
UDP vs TCP, how much faster is it? |
|c++|networking|udp| |
For general protocol message exchange, with loss tolerant. How much more efficient is UDP over TCP? |
|networking|udp| |
Here's code that may give you ideas:
<style>
.containerdiv { float: left; position: relative; }
.cornerimage { position: absolute; top: 0; right: 0; }
</style>
<div class="containerdiv">
<img border="0" src="http://www.gravatar.com/avatar/" alt="" width="100px;" height="100px;">
<img class="cornerimage" border="0" src="http://www.gravatar.com/avatar/" alt="" width="40px;" height="40px;">
<div>
I suspect that [Espo's solution](http://stackoverflow.com/questions/48474#48484) may be inconvenient because it requires you to position both images absolutely. You may want the first one to position itself in the flow.
Usually, there is a natural way to do that is CSS. You put position: relative on the container element, and then absolutely position children inside it. Unfortunately, you cannot put one image inside another. That's why I needed container div. Notice that I made it a float to make it autofit to its contents. Making it display: inline-block should theoretically work as well, but browser support is poor there. |
FogBugz is great as others have mentioned. I use it for my bug/feature tracking system, but I like to separate out my support ticketing system for my support staff to use. Another tool that has great email integration also is called [HelpSpot][1], they have hosted and non-hosted versions for purchase, depending on your budget. It has a lot of great features, that make the prices worth it. Take the tour and see for yourself.
[1]: http://www.userscape.com/products/helpspot/ |
If you don't want to go the SMO route you can search and replace "GO" for ";" and the query as you would. Note that soly the the last result set will be returned. |
Bug tracker setup with Git integration? |
|git|version-control|bugtracking|integration| |
I know I can do most of this by hacking Trac and using Git hooks, but I was wondering if someone has / knows of something ready.
Commenting on (and closing) tickets from commit messages would be nice, specially if the diff appears inline with the comment/closing remark.
sha1 hashes should be auto-linked to gitweb/cigt/custom git browser.
I tried the GitPlugin for Trac, but the code browser was soo slow... any alternatives? |
|git|bug-tracking|version-control|integration| |
I guess there are a couple of options:
1. For a pure CLI solution, use something like gnuplot. See [here](http://t16web.lanl.gov/Kawano/gnuplot/intro/working-e.html) for example usage. I haven't used gnuplot since my student days :-)
2. Not really a pure CLI solution, but download something like [JFreeChart](http://www.jfree.org/jfreechart/) and write a simple Java app that reads stdin and creates your chart.
Hope this helps.
|
Business Application UI Design |
|wpf|user-interface| |
Basically I'm going to go a bit broad here and ask a few questions to get a bit of a picture of how people are handling UI these days.
Lately I've found it pretty easy to do some fancy things with UI design and with WPF specifically we're finding new ways to do layouts that are better looking and more functional for the user, but in contrast one of the business focused guys at our local .NET User Group wouldn't even think of using WPF until it had a datagrid that he could use to make Excel like input forms.
1. So basically, have you rethought the design of your business apps as you move to Web/WPF/Silverlight designs, because for us at least - in winforms we kept things fairly functional and uniform, or are you trying to keep that "known" UI?
2. Would a dedicated design guy (for larger teams), or a dev with more design chops rank higher when looking at hiring these days? (Check out what a designer did for [Scott Hanselman's BabySmash][1] and [Microsoft's Prism demo][2])
3. Are there any design hints/tips/guidelines you use for your UI - especially for WPF?
4. What sites would you recommend for design?
[1]: http://www.hanselman.com/blog/LearningWPFWithBabySmashManuallyManagingClickOnceAndSomeMoreDesignerGoodness.aspx
[2]: http://codebetter.com/blogs/glenn.block/archive/2008/05/08/wpf-from-this-to-that-wow.aspx |
What's the best approach to naming classes? |
|naming| |
Coming up with good, precise names for classes is notoriously difficult. Done right, it makes code more self-documenting and provides a vocabulary for reasoning about code at a higher level of abstraction.
Classes which implement a particular design pattern might be given a name based on the well known pattern name (e.g. FooFactory, FooFacade), and classes which directly model domain concepts can take their names from the problem domain, but what about other classes? Is there anything like a programmer's thesaurus that I can turn to when I'm lacking inspiration, and want to avoid using generic class names (like FooHandler, FooProcessor, FooUtils, and FooManager)?
|
Try adding
CONNECT_DATA=(SID=myDB)(SERVICE_NAME=ORCL)
in the connection string. |
@GateKiller
when i speak of scaling i was talking about the cost of buying more servers and not clients.
most workstations in an organization barely use 50% of their computing power right through the day. If i was to use a click once deployed application i would be using the grunt of existing workstations therefore not having any further cost on the organiztion.
|
Check out [Linq to XML](http://www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashx) - it's really good way to write and read Xml based data. Easier than the System.Xml.XmlDocument mechanisms.
Given that you are supplying the XSLT and the CSS, why not build the page in XHTML and inline the CSS? Alternatively just add the XSLT and CSS files as content in your installer.
Compiled help actually does something like what you're describing - you can copy a link from a CHM file and visit it with a normal browser. I suppose you could embed your display resources in a help file, depending on how they're used. |
An easy way is to use an online domain tool. My favorite is [Domain Tools][1] (formerly whois.sc). I'm not sure if they can resolve conflicting DNS records though. As an example, the DNS servers for stackoverflow.com are
NS51.DOMAINCONTROL.COM
NS52.DOMAINCONTROL.COM
[1]: http://whois.domaintools.com/stackoverflow.com |
Why does Splint (the C code checker) give an error when comparing a float to an int? |
|c|lint|splint| |
Both are mathematical values, however the float does have more precision. Is that the only reason for the error - the difference in precision? Or is there another potential (and more serious) problem? |
I have a <a href="http://www.preshweb.co.uk/cgi-bin/dns-propagation-tracker.pl">DNS propagation tool</a> designed to answer these kind of questions.
Source is released under the AGPLv3.
(Yes, the interface is rather basic at the moment :) )
You could also find out the nameservers for a domain with the "host" command:
<pre>
[davidp@supernova:~]$ host -t ns stackoverflow.com
stackoverflow.com name server ns51.domaincontrol.com.
stackoverflow.com name server ns52.domaincontrol.com.
</pre>
|
Because it probably isn't a very good idea. Not all floats can be truncated to ints; not all ints can be converted to floats. |
% Matches any number of characters
_ Matches a single character
I've never used Full-Text indexing but you can accomplish rather complex and fast search queries with simply using the build in T-SQL string functions. |
One thing worth keeping in mind is that leading wildcard queries come at a significant performance premium, compared to other wildcard usages. |
I've had great success using [NUnit][1] as well.
I've also used [NMock][2] when the need arose for mock objects. As an added bonus, the factory for creating your mock objects is called the Mockery.
To facilitate the running of unit tests, I've used [TestDriven.NET][3] to run unit tests as I coded. Also, I've used [Cruise Control .NET][4] to watch SVN and check that every new commit builds and passes all unit tests.
[1]: http://www.nunit.org
[2]: http://www.nmock.org
[3]: http://testdriven.net
[4]: http://ccnet.thoughtworks.com |
[Instant Rails][1] is a good way to get started quick.
I can verify that it works well on Vista.
[1]: http://instantrails.rubyforge.org/wiki/wiki.pl |
The problem with leading Wildcards: They cannot be indexed, hence you're doing a full table scan. |
Greg,
The wildcard character in MS SQL is the % sign and it works just fine, leading, trailing or otherwise.
That said, if you're going to be doing any kind of serious full text searching then I'd consider utilising the Full Text Index capabilities.
Hope this helps. |
Greg,
The wildcard character in MS SQL is the % sign and it works just fine, leading, trailing or otherwise.
That said, if you're going to be doing any kind of serious full text searching then I'd consider utilising the Full Text Index capabilities. Using % and _ wild cards will cause your database to take a serious perf hit.
Hope this helps.
[1]: http://beta.stackoverflow.com/questions/3400/how-do-you-get-leading-wildcard-full-text-searches-to-work-in-ms-sql#3422 |
You might want to take a look at this:
[http://www.sapphiresteel.com/][1]
There's a free personal edition too
[1]: http://www.sapphiresteel.com/ |
You might want to take a look at this:
[http://www.sapphiresteel.com/][1]
There's a free personal edition too
(Updated: Assuming that you already have Visual Studio Full Fat Edition)
[1]: http://www.sapphiresteel.com/ |
Options for Google Maps over SSL |
|ssl|google|https|iframe|maps| |
We recently discovered that the Google Maps API does not play nicely with SSL. Fair enough, but what are some options for overcoming this that others have used effectively?
> [Will the Maps API work over SSL (HTTPS)?][1]
>
> At this time, the Maps API is not
> available over a secure (SSL)
> connection. If you are running the
> Maps API on a secure site, the browser
> may warn the user about non-secure
> objects on the screen.
We have considered the following options
1. Splitting the page so that credit card collection (the requirement for SSL) is not on the same page as the Google Map.
2. Switching to another map provider, such as Virtual Earth. Rumor has it that they support SSL.
3. Playing tricks with IFRAMEs. Sounds kludgy.
4. Proxying the calls to Google. Sounds like a lot of overhead.
Are there other options, or does anyone have insight into the options that we have considered?
[1]: http://code.google.com/support/bin/answer.py?answer=65301&topic=10945 |
If you set the Modifiers property of your components to strict protected makes them accessible without the use of a components collection.
Edit:
Discoverability could be done using reflection to walk over each field. Although that might be suboptimal in your case. |
A WYSIWYG Markdown control for Windows Forms? |
|markdown|html|winforms|asp.net| |
[We have a Windows Forms database front-end application that, among other things, can be used as a CMS; clients create the structure, fill it, and then use a ASP.NET WebForms-based site to present the results to publicly on the Web. For added flexibility, they are sometimes forced to input actual HTML markup right into a text field, which then ends up as a varchar in the database. This works, but it's far from user-friendly.]
As such… some clients want a WYSIWYG editor for HTML. I'd like to convince them that they'd benefit from using simpler language (namely, Markdown). Ideally, what I'd like to have is a WYSIWYG editor for that. They don't need tables, or anything sophisticated like that.
A cursory search reveals [a .NET Markdown to HTML converter][1], and then we have [a Windows Forms-based text editor that outputs HTML][2], but apparently nothing that brings the two together. As a result, we'd still have our varchars with markup in there, but at least it would be both quite human-readable and still easily parseable.
Would this — a WYSIWYG editor that outputs Markdown, which is then later on parsed into HTML in ASP.NET — be feasible? Any alternative suggestions?
[1]: http://aspnetresources.com/blog/markdown_announced.aspx
[2]: http://www.codeproject.com/KB/edit/editor_in_windows_forms.aspx |
|asp.net|html|winforms|components|markdown| |
C++ rarely uses the “generics” terminology. Instead, the word “templates” is used and is more accurate. Templates describes one *technique* to achieve a generic design.
C++ templates is very different from what both C# and Java implement for two main reasons. The first reason is that C++ templates don't only allow compile-time type arguments but also compile-time const-value arguments: templates can be given as integers or even function signatures. This means that you can do some quite funky stuff at compile time, e.g. calculations:
template <unsigned int N>
struct product {
static unsigned int const VALUE = N * product<N - 1>::VALUE;
};
template <>
struct product<1> {
static unsigned int const VALUE = 1;
};
// Usage:
unsigned int const p5 = product<5>::VALUE;
This code also uses the other distinguished feature of C++ templates, namely template specialization. The code defines one class template, `product` that has one value argument. It also defines a specialization for that template that is used whenever the argument evaluates to 1. This allows me to define a recursion over template definitions. I believe that this was first discovered by [Andrej Alexandrescu](http://erdani.org/).
Template specialization is important for C++ because it allows for structural differences in data structures. Templates as a whole is a means of unifying an interface across types. However, although this is desirable, all types cannot be treated equally inside the implementation. C++ templates takes this into account. This is very much the same difference that OOP makes between interface and implementation with the overriding of virtual methods.
C++ templates are essential for its algorithmic programming paradigm. For example, almost all algorithms for containers are defined as functions that accept the container type as a template type and treat them uniformly. Actually, that's not quite right: C++ doesn't work on containers but rather on *ranges* that are defined by two iterators, pointing to the beginning and behind the end of the container. Thus, the whole content is circumscribed by the iterators: begin <= elements < end.
Using iterators instead of containers is useful because it allows to operate on parts of a container instead of on the whole.
Another distinguishing feature of C++ is the possibility of *partial specialization* for class templates. This is somewhat related to pattern matching on arguments in Haskell and other functional languages. For example, let's consider a class that stores elements:
template <typename T>
class Store { … }; // (1)
This works for any element type. But let's say that we can store pointers more effciently than other types by applying some special trick. We can do this by *partially* specializing for all pointer types:
template <typename T>
class Store<T*> { … }; // (2)
Now, whenever we instance a container template for one type, the appropriate definition is used:
Store<int> x; // Uses (1)
Store<int*> y; // Uses (2)
Store<string**> z; // Uses (2), with T = string*. |
|asp.net|user-controls|webforms| |
|asp.net|user-controls|webform| |
|asp.net|webforms|user-controls| |
Preventing accidental double clicking on a button |
|asp.net|javascript|button| |
I have a few controls that inherit from ASP.NET buttons and use 'onserverclick'.
If the user clicks twice, the button fires two server side events. How can I prevent this?
I tried setting "this.disabled='true'" after the click (in the 'onclick' attribute) via javascript, but that blocks the first postback as well. |
|asp.net|javascript|button| |
a more generic visitor pattern |
|design-patterns|visitor|c++| |
A more generic visitor pattern |
|c++|design-patterns|visitor| |
|c++|design-patterns|visitors| |
I'm sorry if my question is so long and technical but I think it's so important other people will be interested about it
I was looking for a way to separate clearly some softwares internals from their representation in c++
I have a generic parameter class (to be later stored in a container) that can contain any kind of value with the the boost::any class
I have a base class (roughly) of this kind (of course there is more stuff)
class Parameter
{
public:
Parameter()
template typename<T> T GetValue() const { return any_cast<T>( _value ); }
template typename<T> void SetValue(const T& value) { _value = value; }
string GetValueAsString() const = 0;
void SetValueFromString(const string& str) const = 0;
private:
boost::any _value;
}
There are two levels of derived classes:
The first level defines the type and the conversion to/from string (for example ParameterInt or ParameterString)
The second level defines the behaviour and the real creators (for example deriving ParameterAnyInt and ParameterLimitedInt from ParameterInt or ParameterFilename from GenericString)
Depending on the real type I would like to add external function or classes that operates depending on the specific parameter type without adding virtual methods to the base class and without doing strange casts
For example I would like to create the proper gui controls depending on parameter types:
Widget* CreateWidget(const Parameter& p)
Of course I cannot understand real Parameter type from this unless I use RTTI or implement it my self (with enum and switch case), but this is not the right OOP design solution, you know.
The classical solution is the Visitor design pattern <http://en.wikipedia.org/wiki/Visitor_pattern>
The problem with this pattern is that I have to know in advance which derived types will be implemented, so (putting together what is written in wikipedia and my code) we'll have sort of:
struct Visitor
{
virtual void visit(ParameterLimitedInt& wheel) = 0;
virtual void visit(ParameterAnyInt& engine) = 0;
virtual void visit(ParameterFilename& body) = 0;
};
Is there any solution to obtain this behaviour in any other way without need to know in advance all the concrete types and without deriving the original visitor?
Thanks for your time
|
What OS is this? Is it on a 64-bit system? What is the nature of the failure: silent or is an exception thrown?
You could try running [ProcessMonitor][1] and seeing if it sees the attempt to set the value.
[1]: http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx |
If you store it as a secure string and save the secure string to a file (possibly using [Isolated Storage][1], the only time you will have a plain text password is when you decrypt it to create your mbstore. Unfortunately, the constructor does not take a SecureString or a Credential object.
[1]: http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.aspx |
Is there any reason that you have to do it through the registry?
If not, you can use Environment.SetEnvironmentVariable() since .NET 2.0. It allows you to set on a machine, process or user basis. |
The sanctified method is to use CryptoAPI and the Data Protection APIs.
To encrypt, use something like this (C++):
DATA_BLOB blobIn, blobOut;
blobIn.pbData=(BYTE*)data;
blobIn.cbData=wcslen(data)*sizeof(WCHAR);
CryptProtectData(&blobIn, description, NULL, NULL, NULL, CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN, &blobOut);
_encrypted=blobOut.pbData;
_length=blobOut.cbData;
Decryption is the opposite:
DATA_BLOB blobIn, blobOut;
blobIn.pbData=const_cast<BYTE*>(data);
blobIn.cbData=length;
CryptUnprotectData(&blobIn, NULL, NULL, NULL, NULL, CRYPTPROTECT_UI_FORBIDDEN, &blobOut);
std::wstring _decrypted;
_decrypted.assign((LPCWSTR)blobOut.pbData,(LPCWSTR)blobOut.pbData+blobOut.cbData/sizeof(WCHAR));
If you don't specify CRYPTPROTECT_LOCAL_MACHINE then the encrypted password can be securely stored in the registry or config file and only you can decrypt it. If you specify LOCAL_MACHINE, then anyone with access to the machine can get it. |
Here's how I've done this in my current project.
First I've defined a class (as @Daren Thomas said - just a plain old C# class, no associated XAML file), like this (and yes, this is a real class - best not to ask):
public class PigFinderPage : Page
{
/* add custom events and properties here */
}
Then I create a new Page and change its XAML declaration to this:
<my:PigFinderPage x:Class="Qaf.PigFM.WindowsClient.PenSearchPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:Qaf.PigFM.WindowsClient"
/>
So I declare it as a PigFinderPage in the "my" namespace. Any page-wide resources you need have to be declared using a similar syntax:
<my:PigFinderPage.Resources>
<!-- your resources go here -->
</my:PigFinderPage.Resources>
Lastly, switch to the code-behind for this new page, and change its class declaration so that it derives from your custom class rather than directly from Page, like this:
public partial class EarmarkSearchPage : PigFinderPage
Remember to keep it as a partial class.
That's working a treat for me - I can define a bunch of custom properties and events back in "PigFinderPage" and use them in all the descendants. |
Cannot create an environment variable in the registry |
|c#|registry|environment| |
Here's code that may give you ideas:
<style>
.containerdiv { float: left; position: relative; }
.cornerimage { position: absolute; top: 0; right: 0; }
</style>
<div class="containerdiv">
<img border="0" src="http://www.gravatar.com/avatar/" alt="" width="100;" height="100;">
<img class="cornerimage" border="0" src="http://www.gravatar.com/avatar/" alt="" width="40;" height="40;">
<div>
I suspect that [Espo's solution](http://stackoverflow.com/questions/48474#48484) may be inconvenient because it requires you to position both images absolutely. You may want the first one to position itself in the flow.
Usually, there is a natural way to do that is CSS. You put position: relative on the container element, and then absolutely position children inside it. Unfortunately, you cannot put one image inside another. That's why I needed container div. Notice that I made it a float to make it autofit to its contents. Making it display: inline-block should theoretically work as well, but browser support is poor there. |
Here's code that may give you ideas:
<style>
.containerdiv { float: left; position: relative; }
.cornerimage { position: absolute; top: 0; right: 0; }
</style>
<div class="containerdiv">
<img border="0" src="http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png" alt=""">
<img class="cornerimage" border="0" src="http://www.gravatar.com/avatar/" alt="">
<div>
I suspect that [Espo's solution](http://stackoverflow.com/questions/48474#48484) may be inconvenient because it requires you to position both images absolutely. You may want the first one to position itself in the flow.
Usually, there is a natural way to do that is CSS. You put position: relative on the container element, and then absolutely position children inside it. Unfortunately, you cannot put one image inside another. That's why I needed container div. Notice that I made it a float to make it autofit to its contents. Making it display: inline-block should theoretically work as well, but browser support is poor there.
EDIT: I deleted size attributes from the images to illustrate my point better. If you want the container image to have its default sizes and you don't know the size beforehand, you cannot use the [background trick](http://stackoverflow.com/questions/48474/how-do-i-position-one-image-on-top-of-another-in-html#48482). If you do, it is a better way to go. |
I typically do it by iterating over the keyset instead of the entry set. I find the code looks a bit cleaner. You also know that you are always looking at items in keys order for ordered maps such as the LinkedHashMap:
for (String key: map.keySet()) {
System.out.println(key + "/" + map.get(key));
}
|
I managed to solve this problem on my own. I put the following lines in a file named visitors.cgi:
#!/bin/sh
printf "Content-type: text/html\n\n"
exec visitors -A /home/logs/access_log
|
[JCharts][1] is another option. It is similar to JFreeChart but the documentation is free. It does not have direct support for SWT but you can always generate an image and embed it in an SWT frame.
[1]: http://jcharts.sourceforge.net/ |
Anyone have experience with [Aqua Connect][1]? Found them from Google, and they claim the next version works on RDP as well as VNC. Wondering if it's just a nice wrapper around the VNC capabilities `@Soeren Kuklau` pointed out.
Thanks for the link to Vine Server, that's worth investigating.
[1]: http://www.aquaconnect.net/?page_id=26 |
Hyposaurus,
It is possible to have multiple versions of Python installed simultaneously. Installing two versions in parallel solves your problem and helps avoid the problems laid out by Jason Baker above.
The easiest way, and the way I recommend, is to use [MacPorts][1], which will install all its software separately. By default, for example, everything is installed in /opt/local
Another method is to simply download the source and compile with a specified prefix. Note that this method doesn't modify your PATH environment variable, so you'll need to do that yourself if you want to avoid typing the fully qualified path to the python executable each time
./configure --prefix=/usr/local/python64
make
sudo make install
Then you can simply point your Apache install at the new version using mod_python's [PythonInterpreter][2] directive
[1]: http://www.macports.org/
[2]: http://www.modpython.org/live/current/doc-html/dir-other-pi.html |
In Java, generics are compiler level only, so you get:
a = new ArrayList<String>()
a.getClass() => ArrayList
Note that the type of 'a' is an array list, not a list of strings. So the type of a list of bananas would equal() a list of monkeys.
So to speak. |
I think you might want to rethink your design (that is, if you have control over the design yourself). If you're using so many timers that this is actually a concern for you, there's clearly some potential for consolidation there.
Here's a good article from MSDN Magazine from a few years ago that compares the three available timer classes, and gives some insight into their implementations:
http://msdn.microsoft.com/en-us/magazine/cc164015.aspx |
Take a look at [sctp][1] which has a combination of tcp and udp features. There is a windows [implementation][2] available.
[1]: http://en.wikipedia.org/wiki/Stream_Control_Transmission_Protocol
[2]: http://www.sctp.be/sctplib/index.htm |
Yoy should take a look at the Norm (NACK-Oriented Reliable Multicast) specification. You can find [information about Norm here][1].
> The NORM protocol is designed to
> provide end-to-end reliable transport
> of bulk data objects or streams over
> generic IP multicast routing and
> forwarding services. NORM uses a
> selective, negative acknowledgement
> (NACK) mechanism for transport
> reliability and offers additional
> protocol mechanisms to conduct
> reliable multicast sessions with
> limited "a priori" coordination among
> senders and receivers
It somewhat very well known in the military world.
[Norm specs.][2]
[Norm Source][3]
[1]: http://cs.itd.nrl.navy.mil/work/norm/index.php
[2]: http://cs.itd.nrl.navy.mil/pubs/docs/rfc3940.pdf
[3]: http://downloads.pf.itd.nrl.navy.mil/norm/ |
According to [this][1] you need to call VEMap.GetDirections every 25 points until you reach the end of the route and then plot a custom shape of the complete route.
[1]: http://www.lightmaker-manchester.com/blog/post.aspx?id=f081ca81-88a1-4958-9e15-b935d52e99cd |
I've read something similar to what you said in the past, Lars. Unfortunately, I'm somewhat restricted with what I can do with the machine in question (in other words, I can't go creating user groups willy-nilly: it's a server, not just some random PC).
Thanks for the answers, Will and Lars. Unfortunately, they didn't solve my problem.
Ultimate solution to this is to use WMI:
using System.Management;
String queryString = "select CreationDate from Win32_Process where ProcessId='" + ProcessId + "'";
SelectQuery query = new SelectQuery(queryString);
ManagementScope scope = new System.Management.ManagementScope(@"\\.\root\CIMV2");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection processes = searcher.Get();
//... snip ... logic to figure out which of the processes in the collection is the right one goes here
DateTime startTime = ManagementDateTimeConverter.ToDateTime(processes[0]["CreationDate"].ToString());
TimeSpan uptime = DateTime.Now.Subtract(startTime);
Parts of this were scraped from Code Project:
http://www.codeproject.com/KB/system/win32processusingwmi.aspx
And "Hey, Scripting Guy!":
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jul05/hey0720.mspx |
You can use the whois service. On a UNIX like operating system you would execute the following command. Alternatively you can do it on the web at <http://www.internic.net/whois.html>.
whois stackoverflow.com
You would get the following response.
...text removed here...
Domain servers in listed order:
NS51.DOMAINCONTROL.COM
NS52.DOMAINCONTROL.COM
You can use nslookup or dig to find out more information about records for a given domain. This might help you resolve the conflicts you have described. |