instruction stringlengths 0 30k ⌀ |
|---|
At a previous job, I used a Java obfuscator that as well as obfuscating the code, also removed classes and methods that weren't being used. If you were doing "Class.byName" or any other type of reflection stuff, you needed to tell the obfuscator because it couldn't tell by inspecting the code what classes or methods c... |
My problem with Hyper-V is that it kills performance on some things on the host OS, especially A/V stuff. Whenever I would be playing music on the host OS and do something that hits the disk hard (like compiling), the music would begin skipping. Similarly, playing streaming video, you'd have to wait until it was comple... |
> Seriously speaking, LINQ to SQL had it's support for n-tier architecture see DataContext.Update method
Some of what I've read suggests that the business logic wraps the DataContext - in other words you wrap the update in the way that you suggest.
The way i traditionally write business objects i usually encaps... |
> Seriously speaking, LINQ to SQL had it's support for n-tier architecture see DataContext.Update method
Some of what I've read suggests that the business logic wraps the DataContext - in other words you wrap the update in the way that you suggest.
The way i traditionally write business objects i usually encaps... |
One good way to do this is via fixtures, particularly the `initial_data` fixtures.
A fixture is a collection of files that contain the serialized contents of the database. So it's like having a backup of the database but as it's something Django is aware of it's easier to use and will have additional benefits when ... |
One good way to do this is via fixtures, particularly the `initial_data` fixtures.
A fixture is a collection of files that contain the serialized contents of the database. So it's like having a backup of the database but as it's something Django is aware of it's easier to use and will have additional benefits when ... |
Use code.google.com
For example the [search result][1] for "Factory" will get you a lot of cases where the factory Pattern is implemented.
[1]: http://code.google.com/search/#q=Factory |
Here's an example from some actual Python code I wrote:
class Item(Model):
...
@property
def total(self):
if not hasattr(self, "_total"):
self._total = self.quantity \
+ sum(bi.quantity for bi in self.borroweditem_set.all())
... |
What is the role of the buried-buffer-list frame parameter in Emacs |
|emacs|elisp| |
In emacs, I've read the following code snippet in simple.el :
(frame-parameter frame 'buried-buffer-list)
What is the exact meaning of buried-buffer-list parameter ? What it is used for ? |
What I have done in similar situations is put a shortcut in the default folder that takes me straight to where I want to go, although I am not sure I completely understand your question. |
I am not sure I completely understand your question.
* If you are referring to the folder the IDE has as the current folder, then you can just change the shortcut that launches Delphi to set the current directory where ever you want it to be.
|
just make a const string that holds the md5 hash and compile it into your app ... your app can then just refer to this const string when validating the configuration file |
I hear you, I've followed the Pylons mailing list for a while looking for something similar. There have been some attempts in the past (see [AdminPylon][1] and [Restin][2]) but none have really kept up with SQLAlchemy's rapidly developing orm api.
Since DBSprockets is likely to be incorporated into TurboGears it wil... |
I wish I knew more about your specific situation, but as general piece of advice, you might look into C++/CLI for issues involving unmanaged/managed interoperability:
<a href="http://msdn.microsoft.com/en-us/library/ms379617%28VS.80%29.aspx#vs05cplus_topic12">C++: The Most Powerful Language for .NET Framework Progra... |
Related thread here, with some good contributions:
[What JavaScript library would you choose for a new project and why?][1]
[1]: http://stackoverflow.com/questions/913/what-javascript-library-would-you-choose-for-a-new-project-and-why |
To answer B:
[**Comparison of JavaScript frameworks**][1]
[1]: http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks |
To answer B:
[**Comparison of JavaScript frameworks**][1]
----------
**EDIT:** Although everyone and their mom is apparently riding the [**jQuery**][2] bandwagon (I use [**MochiKit**][3]), there are many libraries which provide the same functionality - the problem set which most libraries solve (async client-s... |
Swtiching to ORMs |
|orm|language-agnostic| |
I'm toying with the idea of phasing in an ORM into an application I support. The app is not very structured with no unit tests. So any change will be risky. I'm obviously concerned that I've got a good enough reason to change. The idea is that there will be less boiler plate code for data access and there for greater p... |
Switching to ORMs |
|language-agnostic|orm| |
Firstly, with a complex enough regexp, i beleive this can be impossible. But you should be able to put something together for simple regexps.
If you take a look at the source code of the class java.util.regex.Pattern, you'll see that it uses an internal representation of Node instances. Each of the different pattern... |
Overview:
A **naïve!!** algorithm keeps track of the frequency of words in a per-column manner, where one can assume that each line can be separated into columns with a delimiter.
Example input:
The dog jumped over the moon
The cat jumped over the moon
The moon jumped over the moon
The car j... |
Overview:
A **naïve!!** algorithm keeps track of the frequency of words in a per-column manner, where one can assume that each line can be separated into columns with a delimiter.
Example input:
>The dog jumped over the moon
The cat jumped over the moon
The moon jumped over the moon
The car jumped ove... |
At my workplace, we have two repositories. One with public read access, and one for everything else. I'd use just one for everything, but we need different access rights for public/private projects.
That said, I personally don't see the problem with the revision numbers incrementing on every update. The revision num... |
The issue is that an element without a namespace is declared to be in the NULL namespace - therefore if //foo matched against the namespace you consider to be the 'default' there would be no way to refer to an element in the null namespace.
Remember as well that the prefix for a namespace is only a shorthand convent... |
It seems that as javascript page-tagging becomes the more popular choice as a way of processing web stats, there's not as much work being done on log-based analysis tools anymore in the marketplace. My office used to use a product called LiveStats.XSP. It wasn't the greatest tool by any means, but it did have some nic... |
It seems that as javascript page-tagging becomes the more popular choice as a way of processing web stats, there's not as much work being done on log-based analysis tools anymore in the marketplace. My office used to use a product called LiveStats.XSP. It wasn't the greatest tool by any means, but it did have some nic... |
What is Lazy Loading? |
|data-binding| |
What is Lazy Loading? |
What is Lazy Loading?
[Edit after reading a few answers]
Why do people use this term so often?
Say you just use a ASP/ADO recordset and load it with data or ADO.NET Datasource for a gridview.
I guess I should have asked why people use the term Lazy Loading, what "other" types are their? |
F# language - hints for newbie |
|f#| |
Looks like here in StackOveflow there is a group of **F#** enthusiasts.
I'd like to know better this language, so, apart from the [functional programming theory][1], can you point me to the better starting points to start using the F# language? I mean, tutorials, how-tos, but first of all working samples to have th... |
It's called lazy loading because, like a lazy person, you are putting off doing something you don't want to. The opposite is Eager Loading, where you load something right away, long before you need it.
If you are curious why people might use lazy loading, consider an application that takes a LOOOOONG time to start.... |
There's an XNA specific tutorial on [flocking][1].
[1]: http://creators.xna.com/en-us/sample/flocking |
To stop weird russian and chinese spams, I use this procmail configuration.
UNREADABLE='[^?"]*big5|iso-2022-jp|ISO-2022-KR|euc-kr|gb2312|ks_c_5601-1987'
:0:
* ^Content-Type:.*multipart
* B ?? $ ^Content-Type:.*^?.*charset="?($UNREADABLE)
spam-unreadable
|
Well, based on the 332 pattern you pointed out and the fact that the number of numbers is divisible by 3, and that several of the first 3 digit groups have matches... it might be that each 3 digits represents a character. Get a distribution of the number matches for all the 3 digit groups, then see if that distributio... |
**Note:** This is demonstration-quality code that makes several assumptions about the format of the accessor. Proper error checking, handling of static events, events on nested members, events on return types, etc, etc, is left as an exercise to the reader ;)
public sealed class EventWatcher : IDisposable {
... |
**Edit:** As [Curt](http://stackoverflow.com/questions/35211/identify-an-event-via-a-linq-expression-tree#36255) has pointed out, my implementation is rather flawed in that it can only be used from within the class that declares the event :) Instead of "`x => x.MyEvent`" returning the event, it was returning the backin... |
**Note:** This is demonstration-quality code that makes several assumptions about the format of the accessor. Proper error checking, handling of static events, etc, is left as an exercise to the reader ;)
public sealed class EventWatcher : IDisposable {
private readonly object target_;
private read... |
Looks like the docs are wrong (and have continued to be wrong for the last 3+ years!). I found this snippet with [Reflector][1] in [Microsoft.SqlServer.Management.Common.ConnectionManager][2], Microsoft.SqlServer.ConnectionInfo
protected void CheckServerVersion(ServerVersion version) {
if ((version.Majo... |
Is this link related?
<http://blenderartists.org/forum/showthread.php?t=77794>
To generate terrain (height map) the algorithm is pretty simple (fractal plasma), something like this algorithm (Java):
<http://www.sinc.stonybrook.edu/stu/jseyster/plasma/>
If you Google search for "fractal plasma python" you mi... |
Functors are pretty cool. They are pretty close to a function pointer, which everyone is usually quick to say is impossible in Java.
[Functors in Java][1]
[1]: http://chaoticjava.com/posts/functors-in-java-and-beyond/ |
This should do the trick
Dim jsonSerialiser As New System.Web.Script.Serialization.JavaScriptSerializer
Dim jsonString as String = jsonSerialiser.Serialize(yourObject)
|
I think what you're looking for is this class:
System.ServiceModel.Web.DataContractJsonSerializer
Here's an example from Rick Strahl: [DataContractJsonSerializer in .NET 3.5](http://www.west-wind.com/WebLog/posts/218001.aspx) |
I know this doesn't directly answer your question, but what if you do all of the clipping on the client side to crop the image, then send the server the original image and the coordinates for clipping. Then on the server side, which will probably more suited for image manipulation like this (e.g. PHP it's very easy) yo... |
In the System.Web.Extensions assembly, version 3.5.0.0, there's a [JavaScriptSerializer][1] class that should handle what you want.
[1]: http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx |
Try
System.Web.Script.Serialization.JavaScriptSerializer
or Check out [JSON.org][1] there is a whole list of libraries written to do exactly what you want.
[1]: http://www.json.org/ |
Since the JavaScriptSerializer class is technically being deprecated, I believe [DataContractJsonSerializer][1] is the preferable way to go if you're using 3.0+.
[1]: http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer.aspx |
Well, I am currently using the following extension methods to serialize and deserialize objects:
using System.Web.Script.Serialization;
public static string ToJSON(this object objectToSerialize)
{
JavaScriptSerializer jss = new JavaScriptSerializer();
return jss.Serialize(objectToSerial... |
This morning, I was reading [Steve Yegge's: When Polymorphism Fails][1], when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon.
> As an example of polymorphism in
> action, let's look at the classic
> "eval" interview question, which (... |
This morning, I was reading [Steve Yegge's: When Polymorphism Fails][1], when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon.
> As an example of polymorphism in
> action, let's look at the classic
> "eval" interview question, which (as... |
Two ways:
Embed *$Id$* or *$Revision$* within the code. Then set *svn:keywords="Id Revision"* property on the file. This will give you the last modified revision of that source file. Good for smaller projects and scripts.
Alternatively, use a Makefile driven process and the command line tool svnversion. (Language... |
Two ways:
Embed *$Id$* or *$Revision$* within the code. Then set *svn:keywords="Id Revision"* property on the file. This will give you the last modified revision of that source file. Good for smaller projects and scripts.
Alternatively, use a Makefile driven process and the command line tool svnversion. (Language... |
You need to be wary of [XSS][1] when doing stuff like this:
document.getElementById('<%= Label1.ClientID %>').style.display
The chances are that no-one will be able to tamper with the ClientID of Label1 in this instance, but just to be on the safe side you might want pass it's value through one of the [AntiXs... |
@Kev, really like your solution. Thanks for the help.
Using the registry the code would look something like this:
RegistryKey key = Registry
.LocalMachine
.OpenSubKey("Software\\Microsoft\\NET Framework Setup\\NDP\\v3.5");
return (key != null);
I would be curious if either of... |
I have been looking at this kind of functionality myself recently and have decided on using jQuery with the help of [jQuery UI][3]. I came across a large amount of information that also suggested [Yahoo UI][1] (YUI), I had already started learning [jQuery][2] due to the AJAX support that it offers, so I stuck with it.
... |
I've also since discovered that DXCore from DevExpress is a tool that simplifies plugin development. The default implementation wouldn't let me dock as document (central) but regardless one can still easily generate a plugin with it that can compile a file on the fly and render the contents of it which may well do the ... |
@Roddy - Synchronous sockets are not what I'm after. Burning a whole thread for the sake of a possibly long-lived connection means you limit the amount of concurrent connections to the number of threads that your process can contain. Since threads use a lot of resources - reserved stack address space, committed stack m... |
TrueType Fonts (TTF) will generally work on Windows, Mac, and Linux platforms.
[http://en.wikipedia.org/wiki/TrueType][1]
[1]: http://en.wikipedia.org/wiki/TrueType |
@Tynan The system can be described (somewhat over simplified) as a systems of rules describing categorizations. "Things are in category A if they are in B but not in C", "Nodes connected to nodes in Z are also in Z", "Every category in M is connected to a node N and has 'child' categories, also in M for every node conn... |
@Tynan The system can be described (somewhat over simplified) as a systems of rules describing categorizations. "Things are in category A if they are in B but not in C", "Nodes connected to nodes in Z are also in Z", "Every category in M is connected to a node N and has 'child' categories, also in M for every node conn... |
I prefer TextMate on OS X. But Netbeans (multi-platform) is coming along quite nicely. Plus it comes with its IDE fully functional debugger. |
I work on a large ASP.net application where we recently started to use NHibernate. We moved a large number of domain objects that we had been persisting manually to Sql Server over to NHibernate instead. It simplified things quite a bit and made it much easier to change things over time. We're glad we made the changes ... |
I'd recommend NetBeans 6.1 too. Very nice IDE and makes working with Ruby a pleasure. |
Unicode vs UTF-8 confusion in Python / Django? |
|python|django|unicode| |
I stumbled over this passage in the [Django tutorial][1]:
> Django models have a default __str__() method that calls __unicode__() and converts the result to a UTF-8 bytestring. This means that unicode(p) will return a Unicode string, and str(p) will return a normal string, with characters encoded as UTF-8.
Now, ... |
What is the difference between HttpHandler and a Web User Control and when to use each one? |
|asp.net| |
I've been using user controls extensively but never use a HttpHandler and was wondering if I am doing something suboptimal or wrong |
Python stores Unicode as UTF-16. str() will return the UTF-8 representation of the UTF-16 string. |
On stackoverflow podcast 11:
>Spolsky: Yep. There's a new product also, if you don't want to use the Team System there our friends at Redgate have a product called SQL Data Generator [http://www.red-gate.com/products/sql_data_generator/index.htm]. It's $295, and it just generates some realistic test data. And it d... |
I just added RSS feeds to the ticketing system I use at work ([TicketDesk][1]) and that feature should be in the next release of the product.
It's nice because it basically provides me a custom search view of outstanding trouble tickets or work requests that comes to me rather then me having to go to the applicati... |
It sounds like the web server on hosttwo.com doesn't allow undefined domains to be passed through. You also said you wanted to do a redirect, this isn't actually a method for redirecting. If you bought this domain through GoDaddy you may just want to use their redirection service. |
It's probably best/easiest to set up a [301 redirect][1]. No DNS hacking required.
[1]: http://www.webconfs.com/how-to-redirect-a-webpage.php |
Try changing it to sudomain -> subdomain.hosttwo.com
The cname is an alias for a certain domain, so when you go to the control panel for hostone.com, you shouldn't have to enter the whole name into the cname alias.
As far as the error you are getting, can you log onto subdomain.hostwo.com and check the logs? |
The program probably needs some more info put into its properties. It needs to "Run As", instead of just running.
Maybe this application should be developed as a service, instead of a program to be launched, or you could have service that launches the program when its determined the best window of opportunity. |
Since the forward slash is not allowed in the filename, one simple way is to divide the SaveFileDialog.Filename using String.LastIndexOf; for example:
string filename = dialog.Filename;
string path = filename.Substring(0, filename.LastIndexOf("\"));
string file = filename.Substring(filename.LastIndexOf... |
The Path object in System.IO parses it pretty nicely. |
You could construct a FileInfo object. It has a Name, FullName, and DirectoryName property.
var file = new FileInfo(saveFileDialog.FileName);
Console.WriteLine("File is: " + file.Name);
Console.WriteLine("Directory is: " + file.DirectoryName);
|
Creating test data in a database |
|database|integration-testing| |
I'm aware of some of the test data generators out there, but most seem to just fill name and address style databases [feel free to correct me].
We have a large integrated and normalised application - e.g. invoices have part numbers linked to stocking tables, customer numbers linked to customer tables, change logs li... |
If I am not mistaken you need to swap the
mParent.layout();
and
mParent.setSize(mParent.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
so that you have:
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
ScrolledComposite scrollBox = new Scroll... |
The **Chain of Command** pattern is implemented in the handling of DOM events. For example, (and simplifying slightly) when an element is clicked on, that element gets the first opportunity to handle the event, and then each ancestor in tern until the top level **document** is reached or one of them explicity stops the... |
[I mention some in a review on Boagworld][1], I find the snippets, project manager, columnar editing (hold down option while selecting stuff or push it after having selected stuff) and CSS scopes for syntax.
[1]: http://boagworld.com/podcast/123/ |
Do you want the schema, but have it generated, or do you actually want **NO schema**?
For the former I'd go with nhibernate as @tom-carter said. Have it generate your schema for you, and you are all good (atleast until you roll your app out, then look at something like Tarantino and RedGate SQL Diff or whatever it's... |
Don't neglect the 'mate' command line tool. You can use it to pipe output into TextMate, so if you do the following...
diff file1.py file2.py | mate
...it will not only open in TextMate, but it is smart enough to know that you're looking at a diff and highlight lines on screen.
TextMate's SVN integration i... |
Currying is when you break down a function that takes multiple arguments into a series of functions that take part of the arguments. Here's an example in Scheme
(define (add a b)
(+ a b))
(add 3 4) returns 7
This is a function that takes two arguments, a and b, and returns their sum. We will now... |
This morning, I was reading [Steve Yegge's: When Polymorphism Fails][1], when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon.
> As an example of polymorphism in
> action, let's look at the classic
> "eval" interview question, which (as... |
This morning, I was reading [Steve Yegge's: When Polymorphism Fails][1], when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon.
> As an example of polymorphism in
> action, let's look at the classic
> "eval" interview question, which (as... |
I'm happy with Oracle XE for development purposes.
I do have this piece of wisdow to share; if you're having problems like ORA-12519: TNS:no appropriate service handler found or ORA-12560: TNS:protocol adapter error from time to time then try to change your PROCESSES parameter, logon to Oracle using sys as sysdba an... |
> TrueType Fonts (TTF) will generally work on Windows, Mac, and Linux platforms.
Thanks Jason, but this isn't the answer I'm looking for. Many Linux distributions come with their own fonts that are different *in name* to the Mac/Windows versions - presumably because of font licensing issues.
I'd like a response f... |
Address book DB schema |