instruction
stringlengths
0
30k
How can I use the PHP File api to write raw bytes?
|php|file-io|
I want to write a raw byte/byte stream to a position in a file. This is what I have currently: <pre> <code> $fpr = fopen($out, 'r+'); fseek($fpr, 1); //seek to second byte fwrite($fpr, 0x63); fclose($fpr); </code> </pre> This currently writes the actually string value of "99" starting at byte offset 1. ...
Because it's the name of a builtin function.
The main advantage is access to the API's and language features not found in PL/SQL. For example, I have used them for regular expression processing, file/directory manipulation and XML parsing. There are a number of disadvantages: <ul> <li>Poor tool support <li>Lack of control over the JVM <li>DBA's often aren'...
If you are looking simply to see if all lines in FileA are included in FileB you could read it in and just compare streams inside a loop. File 1 Entry1 Entry2 Entry3 File 2 Entry1 Entry3 You could loop through with two counters and find omissions, going line by line through each file and see if you get wh...
I guess I'll repost my answer here. See also [your previous post][1]. If you're using gcc, or any compiler that uses glibc, you can use the backtrace() functions in execinfo.h to print a stacktrace and exit gracefully when you get a segmentation fault. Documentation is here: [http://www.delorie.com/gnu/docs/gli...
Right-click the class name (in the source code) and choose Refactor -> Convert Member Type to Top Level. It doesn't let you choose the package, though.
How can I make Windows software run as a different user within a script?
|windows|build-process|scripting|wise|
I'm using a build script that calls Wise to create some install files. The problem is that the Wise license only allows it to be run under one particular user account, which is not the same account that my build script will run under. I know Windows has the **runas** command but this won't work for an automated script ...
How do I use Django templates without the rest of Django?
|python|django|templates|template-engine|
I want to use the Django template engine in my (Python) code, but I'm not building a Django-based web site. How do I use it without having a settings.py file (and others) and having to set the DJANGO\_SETTINGS\_MODULE environment variable? If I run the following code: >>> import django.template >>> from...
The [Display Tag Library][1] is very good at presenting paginated result sets in servlets or portlets. But it normally works with the whole list loaded into memory. So you will have to do a little work to get it to work with paginated result sets by implementing the <code>org.displaytag.pagination.PaginatedList</code> ...
I don't know of an existing class but something like: public class MyComparer<T> : IEqualityComparer<T> { private Func<T, T, bool> _compare; MyComparer(Func<T, T, bool> compare) { _compare = compare; } public bool Equals(T x, Ty) { return _compar...
it is returning 4 digit year - 1900, which may have been cool 9+ years ago, but is pretty retarded now. Java's java.util.Date also does this.
Internet Explorer's default privacy setting means that 3rd-party cookies (e.g. those in iframes) are treated differently to 1st party cookies. (by default, 3rd party cookies are silently rejected). For IE6 to accept cookies in an iframe, you need to ensure your site is delivering a P3P compact header. See http://...
I will get lynched for saying this answer, but it works under Windows: [RCS](http://www.cs.purdue.edu/homes/trinkle/RCS/). You simply make an `RCS` directory in each of the directories with your code. When time comes to check things in, `ci -u $FILE`. (Binary files also require you to run `rcs -i -kb $FILE` before t...
The #region *{string}* and #endregion pair is very neat for grouping code (outlining). #region Using statements using System; using System.IO; using ....; using ....; #endregion The code block can be compressed to a single describing line of text. Works inside functions aswell.
You will probably get more usable results from ini_get_all() http://us.php.net/manual/en/function.ini-get-all.php You could then traverse the associated array to reconstruct an ini file without the hassle of interpreting the output of phpinfo()
Check [this][1] example of [SWFUpload][2], the source code is available in PHP. [1]: http://demo.swfupload.org/applicationdemo/index.php [2]: http://code.google.com/p/swfupload/
Selenium is good, but kindof slow. Since unit tests should rarely (if ever) go out of process, they should be much faster than your selenium tests. If you do use it for automated UI testing, I would put them all in a separate build which can run in parallel with your unit tests. I prefer to treat my automated ...
We know that the absolute best case runtime is O(m+n) this is due to the fact that you at least have to scan over all of the data in order to be able to merge the lists. Given this, your second method should give you that type of behavior. Have you profiled your second method to find out what the bottlenecks are? I...
We know that the absolute best case runtime is O(m+n) this is due to the fact that you at least have to scan over all of the data in order to be able to merge the lists. Given this, your second method should give you that type of behavior. Have you profiled your second method to find out what the bottlenecks are? I...
One thing to remeber, not all companies end thier quarters on the last day of a month.
The question would need more details. Do you want just to look at a file (eg. a log file) or to edit it? Do you have more memory than the size of the file you want to load or less? For example, [TheGun](http://www.movsd.com/thegun.htm "TheGun"), a very small text editor written in assembly language, claims to ...
> so probably it won't be aware of the hash codes of it's "children". Your example seems to prove otherwise :-) The hash code for the key `MyClass` and the value `1` is the same for both `KeyValuePair`'s . The KeyValuePair implementation must be using both its `Key` and `Value` for its own hash code Moving up...
How do I convert a System.Type to it's nullable version?
|.net|
Once again one of those: "Is there an easier built-in way of doing things instead of my helper method?" So it's easy to get the underlying type from a nullable type, but how do I get the nullable version of a .NET type? So I have typeof(int) typeof(DateTime) System.Type t = something; and I wa...
|.net|c#|
How do I convert a System.Type to its nullable version?
|c#|.net|
you can find useful information about how to modifying the guidance package in the [Modifying the Guidance Package](http://msdn.microsoft.com/en-us/library/cc304884.aspx) topic of the [WCSF Documentation](http://msdn.microsoft.com/en-us/library/bb264518.aspx). There you will find guidelines about how to create/update t...
Instead of trying to copy-paste, can't you just export the query to Excel?
Parse multiple XML files with ASP.NET (C#) and return those with particular element
|asp.net|c#|xml|
Greetings. I'm looking for a way to parse a number of XML files in a particular directory with ASP.NET (C#). I'd like to be able to return content from particular elements, but before that, need to find those that have a certain value between an element. Example XML file 1: <file> <title>Title 1<...
|c#|asp.net|xml|
Greetings. I'm looking for a way to parse a number of XML files in a particular directory with ASP.NET (C#). I'd like to be able to return content from particular elements, but before that, need to find those that have a certain value between an element. Example XML file 1: <file> <title>Title 1<...
@Thomas Owens > I don't find code formatted like that easier to read. That's fine, it is just a personal preference and we can disagree. Format it the way you think is best and I'll respect it. I frequently ask myself 'how should I format this or that thing?' My answer is always to format it to improve readabili...
We use Quest's [Spotlight](http://www.quest.com/spotlight-on-sql-server-enterprise/) product. Obviously it's an investment in time and money so it might not help you out in the short term but if you are have a large SQL environment it's pretty useful.
For MySQL I like this talk: [Real World Web: Performance & Scalability, MySQL Edition](http://develooper.com/talks/rww-mysql-2008.pdf). This contains a lot of different pieces of advice for getting more speed out of MySQL.
Is it possible to disable command input in the toolbar search box?
|visual-studio|
In the Visual Studio toolbar, you can enter commands into the search box by prefixing them with a > symbol. Is there any way to disable this? I've never used the feature, and it's slightly annoying when trying to actually search for something that you know is prefixed by greater-than in the code. It's particularly anno...
This will give you the top 50 statements by average CPU time, check here for other scripts: [http://www.microsoft.com/technet/scriptcenter/scripts/sql/sql2005/default.mspx?mfr=true][1] SELECT TOP 50 qs.total_worker_time/qs.execution_count as [Avg CPU Time], SUBSTRING(qt.text,qs.statemen...
Any particular reason you want to use Django's templates? Both [Jinja](http://jinja.pocoo.org/) and [Genshi](http://genshi.edgewall.org/) are, in my opinion, superior. --- If you really want to, then see the [Django documentation on `settings.py`](http://docs.djangoproject.com/en/dev/topics/settings/#topics-setti...
If we ignore the scoping-block issue for a moment, the complier would have to work a lot harder in a situation that's not well defined. While this is not impossible, the scoping error also forces you, the author of the code, to realise the implication of the code you write (that the string s may be null in the catch bl...
Google AppEngine uses the Django templating engine, have you taken a look at how they do it? You could possibly just use that.
Eclipse is the best IDE I've used, even considering its quite large footprint and sluggishness on slow computers (like my work machine... Pentium III!). Rather than trying to 'ease the transition', I think it's better to jump right in and let yourself be overwhelmed by the bells and whistles and truly useful refacto...
try: svn list -R
try: svn list -R from the root of the branch you're trying to list.
try: svn list -R with the root of the branch you're trying to list.
What's a good f/oss GDI+ (System.Drawing) based graphing and charting component for .NET?
|c#|.net|vb.net|graph|gdi+|
I want to create basic line, bar, pie and area charts for .NET 3.5 WinForms and I'm interested in finding a free, mature, open-source .NET (preferably C# based) project to help me accomplish that. I would consider a WPF based project, however I'm more comfortable in GDI+ so I'd rather it used System.Drawing and/or GDI...
For things like this, RTL clarity trumps all by a wide margin. MUXes are practically the most common construct besides gates, and synthesis tools are extremely effective at ferreting out when you're describing a MUX. SystemVerilog has special always block directives to make it clear when a design should synthesize to...
For things like this, RTL clarity trumps all by a wide margin. SystemVerilog has special always block directives to make it clear when the block should synthesize to combinational logic, latches, or flops (and your synthesis tool should throw an error if you've written RTL that conflicts with that (e.g. not including ...
Found this: [http://snippets.dzone.com/posts/show/3339][1] [1]: http://snippets.dzone.com/posts/show/3339
This might help: [Why doesn't the RunAs program accept a password on the command line?][1] [1]: http://blogs.msdn.com/oldnewthing/archive/2004/11/29/271551.aspx
It's dumb. It [dates to pre-Y2K days][1], and now just returns the number of years since 1900 for legacy reasons. Use getFullYear() to get the actual year. [1]: http://www.irt.org/articles/js199/index.htm
This is the sort of use-case that <A HREF="http://www.stunnel.org/">stunnel</A> is designed for. There is a specific <A HREF="http://www.stunnel.org/examples/https_windows.html">example</A> of using stunnel to wrap an HTTP server. You should consider whether this is really a good idea, though. Web applications desig...
As others have said, it returns the number of years since 1900. The reason why it does *that* is that when JavaScript was invented in the mid-90s, that behaviour was both convenient and consistent with date-time APIs in other languages. Particularly C. And, of course, once the API was established they couldn't chang...
Can eclipse extract a second class in class file to its own file
|java|refactoring|eclipse|
I often refactor code first by creating an inner class inside the class I'm working on--When I'm done, I move the entire thing into a new class file. This makes refactoring code into the new class extremely easy because A) I'm only dealing with a single file, and B) I don't create new files until I have a pretty good ...
|java|eclipse|refactoring|
I often refactor code first by creating an inner class inside the class I'm working on--When I'm done, I move the entire thing into a new class file. This makes refactoring code into the new class extremely easy because A) I'm only dealing with a single file, and B) I don't create new files until I have a pretty good ...
Assuming that you have a safe way of sharing a key (whether RSA encryption of it, retrieval over an SSH or HTTPS link, or callling the other developer on a secured phone line), any of the major modern encryptions (like AES, as mentioned by @Ed Haber) would be suitable. I would second his suggestion of AES. There shou...
Incremental File Copy Tool and NIH
|diff|utilities|
For years, one of my most important tools has been incremental copy utility that compares the contents of two directories and shows me which files are newer / older / added / deleted. Every day I find myself copying folders of source code between my two desktop machines and the server, and such a utility is critical t...
Can I get the old full screen scaling with FLVPlayback and flash 9.0.115+?
|flash|flv|flvplayback|fullscreen|scaling|
With previous versions of flash, entering the full screen mode increased the height and width of the stage to the dimensions of the screen. Now that hardware scaling has arrived, the height and width are set to the dimensions of the video (plus borders if the aspect ratio is different). That's fine, unless you have...
|flash|video|scaling|flv|fullscreen|
How do I figure out who has a SQL Server 2005 database in Single User Mode?
|sql-server-2005|
I have a database in single user mode and I am trying to drop it so I can re-run the creation scripts on it, but I'm being locked out from it. 1. How do I figure out who has the lock on it? 2. How do I disable that lock?
I keep them the same. But then, I don't have multifile assemblies, which is when the AssemblyVersion number becomes important. I use Microsoft-style date encoding for my build numbers, rather than auto-incrementing (I don't find the number of times that something has been built to be all that important).
Web page field validation
|html|fieldvalidation|
I need to validate a date/time field on a webpage but want it to do it without reloading the page and would like 'instant' feedback for the users. What's the best/easiest solution. BTW: easiest scores 65% of total points
|fieldvalidation|html|
I need to validate a date/time field on a webpage but want it to do it without reloading the page and would like 'instant' feedback for the users. What's the best/easiest solution. BTW: easiest scores 65% of total points Edit: What if best was 65% of total points?
|html|
As Yaakov says, run profiler for a few minutes under typical load and save the results to a table which will allow you to run queries against the results making it much easier to spot any resource hogging queries.
I've used UrlRewriting.NET before on a very high-traffic site - it worked great for us. I believe the developers are German, so the English documentation is probably not as good as it could be. I'd highly recommend it.
As I recall, running a website uses the Network User account, which may not have permission to view local printers. There was a page on MSDN that said how you can impersonate another user that might have access to the printers, but I've not been able to find it. Edit: I posted too soon. [Here's the page][1]. H...
I think the truth will-out on this: I'm a software developer, the syntax of the language is the final part of the puzzle. By employing me, you're getting someone with demonstrable experience of problem solving and logic. I'm experienced with the .NET environment, the CLR and the associated Windows stack, including S...
In Matlab 7.1 (the version I have) there is an undocumented command line option -wait in matlab.bat. If it doesn't work for your version, you could probably add it in. Here's what I found. The command at the bottom that finally launches matlab is (line 153): start "MATLAB" %START_WAIT% "%MATLAB_BIN_DIR%\%MATLAB_...
I remember actually running into this limit once in a complex JSP page in Tomcat 4 (way in the past when people were still using JSPs). The java file generated from the JSP had a method that was too big to compile, I think I had to split up the file or do some other stunt, which of course was a good idea in terms of re...
I've introduced it into our code base because we needed a bettor malloc to use when we moved to a 16 core machine. With 8 and under it wasn't a significant issue. It has worked well for us. We plan on using the fine grained concurrent containers next. Ideally we can make use of the real meat of the product, but that re...
What is the bast way to replace browse button in html?
|css|html|input|browse|
I know that it's possible to replace browse button, which is generated in html, when you use input tag with type="file". I'm not sure what is the best way, so if someone have experience with these please contribute.
What is the best way to replace the file browse button in html?
|html|css|input|browse|