instruction
stringlengths
0
30k
You can use const variables as input to attribute constructors but not readonly variables. Example: public static class Text { public const string ConstDescription = "This can be used."; public readonly static string ReadonlyDescription = "Cannot be used."; } public class Foo ...
I would use [simpleXML](http://www.php.net/simplexml) to create the required structure and export the XML. Then I'd cache it to disk with file_put_contents().
How to find header dependencies for large scale projects on linux
|c++|software-tools|
I'm working an a very large scale projects, where the compilation time is **very** long. What tools can I use (preferably open source) on Linux, to find the most heavily included files and that optimize their useages?
I'm working an a very large scale projects, where the compilation time is **very** long. What tools can I use (preferably open source) on Linux, to find the most heavily included files and that optimize their useages? Just to be clearer, I need a tool which will, given the dependencies, show me which headers are the m...
A dictionary or any other form of hashtable has no ordering. So what you are trying to do is pointless :)
You shouldn't care. You should use *int* most of the time. It will help the porting of your program to a wider architecture in the future (currently *int* is an alias to *System.Int32* but that could change). Only when the bit width of the variable matters (for instance: to control the layout in memory of a *struct*) y...
You shouldn't care. You should use *int* most of the time. It will help the porting of your program to a wider architecture in the future (currently *int* is an alias to *System.Int32* but that could change). Only when the bit width of the variable matters (for instance: to control the layout in memory of a *struct*) y...
Technically I believe it could cause a problem with mismatched allocators, though in practice I don't know of any compiler that would not do the right thing with this example. More importantly if STRUCT where to have (or ever be given) a destructor then it would invoke the destructor without having invoked the corre...
Thanks Matt, your solution worked great for me. Here's my version of your code... private const uint EM_SETTABSTOPS = 0x00CB; [DllImport("User32.dll")] public static extern uint SendMessageA(IntPtr hWnd, uint wMsg, int wParam, int[] lParam); private static void SetTabStops(TextBox textBox, int tabPos1, ...
Thanks Matt, your solution worked great for me. Here's my version of your code... // This is a better way to pass in what tab stops I want... SetTabStops(textBox, new int[] { 12,120 }); // And the code for the SetTabsStops method itself... private const uint EM_SETTABSTOPS = 0x00CB; [DllImport("User32...
How about: <pre> <code> ordered_list = [[1, 2], [1, 1], [2, 1]] ordered_list.sort do |a,b| [a[0],b[1]] &lt;=&gt; [b[0], a[1]] end </code> </pre>
How about: <pre> <code> ordered_list = [[1, "b"], [1, "a"], [2, "a"]] ordered_list.sort! do |a,b| [a[0],b[1]] &lt;=&gt; [b[0], a[1]] end </code> </pre>
An approach I've found helpful for procedural code is to use TextTest. It's not so much about unit testing, but it helps you do automated regression testing. The idea is that you have your application write a log then use texttest to compare the log before and after your changes.
We had a similar issue and solved it by starting the work via an asychronous web service call (which meant that the user did not have to wait for the work to finish). The web service then started a SQL Job which performed the work and periodically updated a table with the status of the work. We provided a UI which al...
You can create another thread and store a reference to the thread in the session or application state, depending on wether the thread can run only once per website, or once per user session.<br /> You can then redirect the user to a page where he can monitor the threads progress. You can set the page to refresh automa...
I think a better SQL would be: select * from t1, t2 where t1.id=t2.id and t1.country ='US' There's no need to use the second comparison to 'US' unless it's possisble that the country in t2 could be different than t1 for the same id.
TotoiseSVN by default looks at file changes in the background and I have seen that slow down my machine. I changed the config to exclude everything and then only include the directories where I have checkouts. You can also turn off the background checks. Both of these settings are in the Icon Overlays settings node.
why might my pyglet vertex lists and batches be very slow on Windows?
|python|opengl|pyglet|
I'm writing opengl code in python using the library pyglet. When I draw to the screen using pyglet.graphics.vertex_list or pyglet.graphics.batch objects, they are very slow (~0.1 fps) compared to plain old pyglet.graphics.draw() or just glVertex() calls, which are about 40fps for the same geometry. In Linux the vertex...
A source control system is generally a storage place for your files and their history and usually separate from the files you're currently working on. It depends a bit on the type of version control system but suppose you're using something CVS-like (like subversion), then all your files will live in two (or more) plac...
in our company we use alienbrain but we are migrating to Perforce. Perforce has everything you want: it hadles code and data, he integrates tools for continuous integration, it handles local (per developer) repository so you can check-in in your local repository before committing on server. I vote for Perforce
The .NET design guidelines provide some answers to this question in the <a href="http://msdn.microsoft.com/en-us/library/bzwdh01d(VS.71).aspx#cpconpropertyusageguidelinesanchor1">Properties vs. Methods</a> section. Basically, properties have the same semantics as a field. You shouldn't let a property throw exceptio...
You could create an Autohotkey script that does that. When you ctrl-click a word, send a doubleclick then a F12. I don't have AHK handy so I can't try and sketch some code but it should be pretty easy; the AHK recorder should have enough features to let you create it in a point 'n' click fashion and IIRC it is smart...
Is the logic inside each of those methods largely the same? If so, the single method with identifier parameter may make more sense (simple and reducing repeated code). If the logic/procedures vary greatly between types, a method per type may be preferred.
For many pieces of software performance isn't the problem, it's time to market. This is often the case 'in-house' where a team may care much more about getting an initial version of an app in front of the users quickly than about how fast (or even how stable) it is. Add to this the fact that a well written framework wi...
How to specify an authenticated proxy for a python http connection?
|python|http|proxy|
What's the best way to specify a proxy with username and password for an http connection in python?
|python|https|proxy|
|python|http|proxy|
Is anyone using XForms in their web applications?
|w3c|xforms|
A few years ago we started playing around with [XForms][1] from the W3C for a web app which required hundreds of custom forms. As they aren't currently supported natively by the major browsers, what parsers/tools are you using on your projects today? I'm not really interested in plugins - this needs to be somethi...
@Stephan: it is difficult to overload a case like this (in general) because the parameter types might not be discriminative, e.g., * getEmployeeNameByBatchId(int batchId) * getEmployeeNameByRoomNumber(int roomNumber) See also the two methods getEmployeeNameBySSN, getEmployeeNameByEmailId in the original posting.
Is it feasible/sensible to wrap an InnoSetup installer inside an MSI for easier distribution via AD?
|inno-setup|msi|
Our installer is written with InnoSetup and we are actually quite happy with it. Yet some customers keep asking for an MSI installer which they could more easily distribute via Active Directory. We have already gone to some lengths to make the installer deal really well with automated and unattended installations by ex...
|msi|inno-setup|
Our installer is written with InnoSetup and we are actually quite happy with it. Yet some customers keep asking for an MSI installer which they could more easily distribute via Active Directory. We have already gone to some lengths to make the installer deal really well with automated and unattended installations by ex...
Use the System.ComponentModel.Browsable attribute to > ' VB > > <System.ComponentModel.Browsable(False)> or // C# [System.ComponentModel.Browsable(false)]
The best way to get through a big chunk of work while staying focused is to list your priorities on paper before you start. Trying to keep a big list in your head is a sure path to procrastination. Plus, it's a great feeling to tick off items as you finish them. Put on some music, close down your email, and get busy...
Found the following: http://www.google.be/search?q=firefox%20switch%20flash%20version http://www.sephiroth.it/weblog/archives/2006/10/flash_switcher_for_firefox.php (seems nice) http://www.communitymx.com/content/article.cfm?page=2&cid=6FBA7 (seems nicely integrated as well) https://addons.mozilla.org/nl/firef...
I will second (or is it third) [MadExcept][1]. I have been using it successfully in several commercial applications without any problems. The nice thing about MadExcept is that it will generate a report for you with a full stack trace that will generally point you in the right direction as to what went wrong, and can...
My solution to this, has been an out of band service that does these and caches them in db. When the person asks for something the first time, they get a bit of a wait, and then it shows up but if they refresh, its immediate, and then, because its int he db, its now part of the hourly update for the next 24 hours fr...
A very interesting game idea. I think you are right that parrellel computing would be benefical to this design, but no more then any other high resource program. The question is a bit ambigous. I see that you are going to write this in C++ but what OS are you coding it for? Do you intend on it being cross platform ...
I had (have) a similar problem in a Java application. I wrote a JDBC driver wrapper around the Oracle driver so all output is sent to a log file.
Is there a reason why you cannot use the "is" keyword itself? foreach(object obj in myObjects) { if (obj is type) { return obj; } }
Is there a reason why you cannot use the "is" keyword itself? foreach(object obj in myObjects) { if (obj is type) { return obj; } } EDIT - I see what I was missing. Isak's suggestion is the correct one; I have tested and confirmed it. class Level1 { ...
Even if it's safe, but it's not the best practice to use shared data between threads without synchronizing the access to those fields. It doesn't matter which thread created the object, but if more than one line of execution (thread/process) is accessing the object at the same time, since it can lead to data inconsiste...
I've used [this site][1] for a while now for some of my smaller conversions. It has been quite reliable. According to the site, their converter is based off an [open source IDE][2] that has the converter built in, so you might try the "source site" as well. [1]: http://labs.developerfusion.co.uk/convert/vb-to...
When working with Hibernate, I use an installer class that runs from the command-line and has options for creating database schema, inserting base data, and dynamically updating the database schema using [SchemaUpdate][1]. I find it to be extremely useful. [1]: http://www.hibernate.org/hib_docs/v3/api/org/hibern...
When working with Hibernate, I use an installer class that runs from the command-line and has options for creating database schema, inserting base data, and dynamically updating the database schema using [SchemaUpdate][1]. I find it to be extremely useful. It also gives me a place to put one-off scripts that will be ru...
This is all very subjective depending on the the source control solution that you decide to use. One that you will definitely want to look into is Subversion. You mentioned that you're doing PHP, but are you doing it in a Linux environment or Windows? It's not really important, but what I typically did when I work...
Using extended inserts in dumps should make imports faster.
You could use a custom comparison function, or you could pass in a function that calculates a custom sort key. That's usually more efficient as the key is only calculated once per item, while the comparison function would be called many more times. You could do it this way: def mykey(adict): return adict['nam...
How do I create a custom font for a blackberry application
|blackberry|fonts|
I want to use a specific foreign language font for a Blackberry application. How is such a font created and loaded onto the Blackberry device? For example: ਪੰਜਾਬੀ
You'd could cast back to a BYTE * and the delete: delete[] (BYTE*)pStruct;
Update: I have decided to abandon this approach, and instead just present the user with a link to the actual file. My reasoning is this: My initial attempts at a server-initiated download were blocked by the browser. That got me thinking: "the browser is right. How does **it** know that this is a legitimate download...
Can you do this in .NET/C#? Yes you certainly can but it takes a little bit of effort. I would recommend the following approach. Create a top level Form that has no border or titlebar area and then give make sure it draws no client area background by setting the TransparencyKey and BackColor to the same value. So y...
I'd make sure you don't keep files open. This leads to weird stuff if your app crashes for example. What I'd do: 1. Abstract (reading / writing / rolling over to a new file) into one class, and arrange closing of the file when you want to roll over to a new one in that class. (this is the neatest way, and since yo...
> How do you react when you find yourself being the only one who listenes, while other team members just **sit** there and maybe even fall asleep? Hmm, are you actually having stand-up meetings? It may sound hokey, but aside from making it harder for people to fall asleep, it also helps foster the feeling of a quick...
GDI is faster at drawing in general that GDI+. I worked on a project that had to draw thousands of lines and text strings and switching from GDI+ to GDI made a significant performance improvement. That was using Windows XP so I cannot comment on Vista. I would also recommend using double buffering for your drawing to a...
You could rewrite your insert statement to only allow votes to be inserted based on your contrainsts: Insert Into Votes (Choice, Timestamp, IP, Email) Select Top 1 @Choice, @Timestamp, @IP, @Email From Votes Where (Select Count(*) From Votes Where IP = @IP ...
I'm not sure I would agree with that VisualSVN recommendation. I have always set up separate repositories per project, and I've never run into a situation where I wish I could have merged across projects or something. If there is a chunk of common code that is shared among projects at your company, it should become ...
The following is a discussion of how darcs (<http://darcs.net>) deals with patches - <http://darcs.net/manual/node9.html>.
Which connection library are you using? OO4O, ODP, Other? I'm working from memories of old issues here, so the details are a little fuzzy. With OO4O there are two different ways to initialize the library. One tries to re-use connections more than the other. In ODP the default is to use connection pooling. ...
What you save in typing, you lose in readability. Many debuggers won't have a clue what you're referring to either so debugging is more difficult. It doesn't make programs run faster. Consider making the code within your with statement a method of the object that you're refering to.
How do I determine using TSQL what roles are granted execute permissions on a specific stored procedure?
|sql-server|t-sql|stored-procedures|
Is there a system stored procedure or a system view I can use?
Maybe you shouldn't? It all depends on what kind of application(s) you're building. If you are building GUI intensive applications, something like, say, Yahoo! Mail, then maybe you should consider using YUI or Mootools over jquery. Personally I'm a huge jQuery fan, but it is definitely best for adding a touch of intera...
I did it ones in a real project: The database consisted of one table with one field which was an array of 50. It had a 'word' index set on it. All the data was typeless so the 'word index' worked as expected. Numeric fields were represented as characters and the actual sorting had been done at client side. (It still...
I did it ones in a real project: The database consisted of one table with one field which was an array of 50. It had a 'word' index set on it. All the data was typeless so the 'word index' worked as expected. Numeric fields were represented as characters and the actual sorting had been done at client side. (It still...
What happens when you try to build it from the command line? (i.e., \Program Files\Borland\Delphi7\Bin\dcc32.exe) Also, have you build any custom .RES files for this project? If not, try deleting the default .RES that Delphi created for you, and let it get re-created by the project. You can also force an update...
if (typeof(IEnumerable).IsAssignableFrom(typeof(V))) {
what is the flex (ActionScript3) syntax for a function valued function's type?
|apache-flex|actionscript-3|
What is the syntax to declare a type for my compare-function generator in code like the following? var colName:String = ""; // actually assigned in a loop gc.sortCompareFunction = function() : ??WHAT_GOES_HERE?? { var tmp:String = colName; return function(a:Object,b:Object):int { retu...
The simplest way to *force* yourself might be just to remove all the other editors from your machine. Get rid of temptation :)
To add to your list, aku, I would put **explorability** as one of my highest priorities. Basically, I want the user to feel safe trying out the features. They should never back away from using something for fear that their action might be irreversible. Most commonly, this is implemented using undo/redo commands, but ot...
Make sure you don't duplicate the resource inclusion, like having multiple {$R *.dfm} lines in a unit or multiple {$R *.res} for the project. Could also be included anywhere in a unit like {$R MyProject.res} as well...
delete notepad.exe and create a shortcut to vim called notepad instead :) or do all your coding via ssh or on a machine that has no GUI ;)
I've tried keeping a small cheat sheet or sticky notes of common vi commands. I do the same thing for an IDE I use. I find if I put sticky notes of keyboard shortcuts or commands on my monitor(s) it helps me learn them. Once I've used the shortcut enough and think I remember it well, I'll remove the sticky note.
D Programming Language in the real world?
|d|real-world|
Is anyone out there using D for real world applications? If so, what are you using it for? I can't seem to find anything big on the web written in D.
Is anyone out there using D for real world applications? If so, what are you using it for? I can't seem to find anything big on the web written in D. Despite the lack of known big users, D seems like a very promissing language to me, and according to [TIOBE](http://www.tiobe.com/index.php/content/paperinfo/tpci/inde...
|d|real-world|
Just a thought... Any chance there's a deadlock issue here? You're calling TreeView.Invoke, which is a blocking call. If a filesystem change happens just as you're clicking whatever button causes the FileSystemWatcher.Dispose() call, your FileWatcherFileChanged method will get called on a background thread and call...
I have a small VB.Net app that executes system commands like that. To capture error or success conditions I define regular expressions to match the error text output from the command and I capture the output like this: myprocess.Start() procReader = myprocess.StandardOutput() ...
How Does Listening to a Multicast Hurt Me?
|language-agnostic|networking|network-programming|udp|boost-asio|
I'm receiving a recovery feed from an exchange for recovering data missed from their primary feed. The exchange __strongly__ recommends listening to the recovery feed only when data is needed, and leaving the multicast once I have recovered the data I need. My question is, if I am using asio, and not reading from...
I tend to use following pattern: * public static final variables * static functions, static blocks * variables * constructors * functions that do something related to logic * getters and setters (are uninteresing mostly so there is no need to read them) I'm have no pattern of including local classes, and ...
As others suggested the first option seems to be the good one. The second might make sense when you're writing a code, but when someone else comes along later on, it's harder to figure out how to use code. ( I know, you have comments and you can always dig deep into the code, but GetemployeeNameById is more self-explan...