instruction
stringlengths
0
30k
### I always do it this way if I'm only expecting a single line of output or want to split the result on something other than a newline: my $result = qx( command args 2>&1 ); my $rc=$?; ### $rc >> 8 is the exit code of the called program. if ($rc != 0 ) { > error(); } If you want to deal with a m...
If you don't mind paying, there's FarPoint Spread: http://www.componentsource.com/selec/products/farpoint-spread/summary.html
There is a difference between authentication and authorization/profiling so don't force both necessarily into a single tool. Your second solution of using LDAP for authentication and a DB for authorization seems more robust as the LDAP data is controlled by the user and the DB would be controlled by an admin. The lat...
Stored procedures get 1 file per sp with the standard if exist drop/create statements at the top. Views and functions also get their own files so they are easier to version and reuse. Schema is all 1 script to begin with then we'll do version changes. All of this is stored in a visual studio database project conn...
A quick way to find the template files you can create and modify for a view in Views 2.0 is to: 1. Edit the view 2. Select the style (e.g. page, block, default) 3. In the 'Basic Settings' block click on 'Theme: Information' to see all the different templates you can modify.
I'm kind of interested in getting some feedback about this technique I picked up from somewhere. I use this when a function can either succeed or fail, but you'd like to get more information about why it failed. A standard way to do this same thing would be with exception handling, but I often find it a bit over the...
There are more than a few ways to do it, but you have to ask yourself first what are your assumptions and conditions. So, assuming that your space is limited in size and you know what is the maximum accuracy, then you can form a function that given (x,y,z) will convert them to a unique number or string -this can be ...
You can easily use a set as follows: #include <set> #include <cassert> const double epsilon(1e-8); class Coordinate { public: Coordinate(double x, double y, double z) : x_(x), y_(y), z_(z) {} private: double x_; double y_; double z_; ...
One way to do it is to set the image you want to display as a background in a container (td, div, span etc) and the size the container as you want. This technique is shown on the following url: <http://www.guistuff.com/css/css_imagetech1.html>
[http://www.json.org/java/index.html][1] has what you need. [1]: http://www.json.org/java/index.html
If you want to be really pedantic, there is one thing you can do with a reference that you can't do with a pointer: extend the lifetime of a temporary object. In c++ if you bind a const reference to a temporary object, the lifetime of that object becomes the lifetime of the reference. std::string s1 = "123"; ...
Answer is [here][1] > If *.mvc extension is not registered > to the hosting , it will give 404 > exception. The working way of hosting > MVC apps in that case is to modify > global.asax routing caluse in the > following way. > > routes.Add(new > Route("{controller}.mvc.aspx/{action}", > new MvcRouteHandler...
I think **either way you'll have to do Solution 1**. Consider the HTTP Request pipeline. 1. A request comes into IIS. 2. IIS checks port/host header to see if it has a web site set up to capture requests for that host header/port. 3. **IIS investigates the file extension of the request (.php, .asp, .aspx) and h...
Best build process solution to manage build versions
|build-process|msbuild|version-control|cruisecontrol.net|
I run a rather complex project with several independent applications. These use however a couple of shared components. So I have a source tree looking something like the below. * My Project * Application * Shared1 * Shared2 * Application B * Application C All applications have their own MSBuild scri...
When I had to deal with this problem, to fill in missing dates I actually created a reference table that just contained all dates I'm interested in and joined the data table on the date field. It's crude, but it works. SELECT DATE(r.date),count(d.date) FROM dates AS r LEFT JOIN table AS d ON d.date ...
I'll assume you want to check a string value. One nice way is the REGEXP operator, matching the string to a regular expression. Simply do select field from table where field REGEXP '^-?[0-9]+$'; this is reasonably fast. If your field is numeric, just test for ceil(field) = field instead.
Databinding ApplicationSettings to Custom Components
|c#|data-binding|custom-component|
I have a custom component where I have implemented INotifyPropertyChanged and IBindableComponent. However, when I try to databind a property, the designer adds this line: this.component11.TestString = global::WindowsFormsApplication2.Properties.Settings.Default.Setting; instead of creating a binding as it d...
it's in there by default. It's the id field.
Not sure about the best practices, but in my experience multiple panels work well, and reduce the amount of data being sent at one time - resulting in an increase in response time overall. Multiple panels also reduce the complexity of each server call.
You can technically use colons and periods in id/name attributes, but I would strongly suggest avoiding both. In CSS (and several JavaScript libraries like jQuery), both the period and the colon have special meaning and you will run into problems if you're not careful. Periods are class selectors and colons are pseu...
**Collaboration Tools** [Skype][1] = Free - If you can't work face-to-face a tool like Skype can get you pretty close for no cost assuming everybody already has broadband. The mac client works great and since most modern macs have a camera already you should be mostly set. [1]: http://www.skype.com/
require 'RMagick' Magick::Image.new(110, 30){self.background_color = 'white'}.write('/tmp/test.jpg')
You can't add a new unique auto-generated ID to a SharePoint list, but there already is one there! If you edit the "All Items" view you will see a list of columns that do not have the display option checked. There are quite a few of these columns that exist but that are never displayed, like "Created By" and "Create...
"Object-Oriented Analysis and Design with Applications" by Grady Booch. I read this a long time ago and it showed me that there could be a methodology to developing Object Oriented Software. Since then many other books have had an impact on me but this one got me started.
I have found that the eclipse plugin for EMMA is quite buggy, and have had similar experiences to the one you describe. Better to just use EMMA on its own (via ANT if required). Make sure you always regenerate the metadata files produced by EMMA, to avoid merging confusion (which I suspect is the problem with the ecl...
This code gets a cryptographically strong random number that is 20 bytes in length, then Base64 encodes it. There's a lot of Java library code here, so your guess is as good as mine as to how to do it in VB. SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); byte[] bytes = new byte[20]; synch...
JPA Multiple Transaction Managers
|jpatransactionmanager|
i have one applicationContext.xml file, and it has two org.springframework.orm.jpa.JpaTransactionManager (each with its own persistence unit, different databases) configured in a Spring middleware custom application. i want to use annotation based transactions (@Transactional), to not mess around with TransactionStatu...
|java|spring|jpa|jpatransactionmanager|
I would say there are no hard and fast rules on when to use exceptions. However there are good reasons for using or not using them: Reasons to use exceptions: - The code flow for the common case is clearer - Can return complex error information as an object (although this can also be achieved using error "o...
How do I create RAW TCP/IP packets in C++?
|version-control|build-process|msbuild|cruisecontrol.net|
I run a rather complex project with several independent applications. These use however a couple of shared components. So I have a source tree looking something like the below. * My Project * Application A * Shared1 * Shared2 * Application B * Application C All applications have their own MSBuild scr...
Well, Josh Block said himself in [Effective Java 2d][1]: ## Prefer interfaces over abstract classes Some main points: > - **Existing classes can be easily retrofitted to implement a new > interface**. All you have to do is add > the required methods if they don’t yet > exist and add an implements clause t...
Well, Josh Block said himself in [Effective Java 2d][1]: ## Prefer interfaces over abstract classes Some main points: > - **Existing classes can be easily retrofitted to implement a new > interface**. All you have to do is add > the required methods if they don’t yet > exist and add an implements clause t...
I have a custom component where I have implemented INotifyPropertyChanged and IBindableComponent. However, when I try to databind a property, the designer adds this line: this.component11.TestString = global::WindowsFormsApplication2.Properties.Settings.Default.Setting; instead of creating a binding...
How do I get sun webserver to redirect from /
|webserver|sun|http-redirect|
I have Sun webserver iws6 (iplanet 6) proxying my bea cluster. My cluster is under /portal/yadda. I want anyone who goes to http://the.domain.com/ to be quickly redirected to http://the.domain.com/portal/ . I have and index.html that does a post and redirect, but the user sometimes sees it. Does anyone have a bette...
IIS configurable http-headers for caching
|iis|configuration|caching|iis-6|
How would one configurably set http-headers to cache files in IIS >= 6? Example: - `*.cache.*` => cache nearly forever - `*.nocache.*` => never cache An example framework using this naming would be the GWT framework.
The LCC compiler ([wikipedia][1]) ([project homepage][2]) of Fraser and Hanson is described in their book "A Retargetable C Compiler: Design and Implementation". It is quite readable and explains the whole compiler, down to code generation. [1]: http://en.wikipedia.org/wiki/Local_C_compiler [2]: http://www.cs....
Use xml (something open, descriptive, and validatable), and stick with the text. There are standards for this sort of thing as well, including [ODF][1] [1]: http://en.wikipedia.org/wiki/OpenDocument
You can open the file as binary, instead of text (how one does this depends somewhat on the platform), from there you can write the data directly out to disk. The only real caveat to this is [endianess][1], which can become an issue when moving the files from one architecture to another (x86 to PPC for instance). W...
String stringrep = myintvar.ToString("X"); int num = int.Parse("FF", System.Globalization.NumberStyles.HexNumber);
looks like you can say: Convert.ToInt64(value, 16) To get the Decimal from Hex, and the other way around: otherVar.ToString("X");
WPF ListBox WrapPanel clips long groups
|wpf|listbox|scroll|grouping|wrappanel|
I've created a ListBox to display items in groups, where the groups are wrapped right to left when they can no longer fit within the height of the ListBox's panel. So, the groups would appear similar to this in the listbox, where each group's height is arbitrary (group 1, for instance, is twice as tall as group 2): ...
Well, Josh Bloch said himself in [Effective Java 2d][1]: ## Prefer interfaces over abstract classes Some main points: > - **Existing classes can be easily retrofitted to implement a new > interface**. All you have to do is add > the required methods if they don’t yet > exist and add an implements clause t...
Sounds like another query is running in the background that has locked the table and your innocent query is simply waiting for it to finish
For human-readable passwords, I recently used a PHP script very similar to the one below. It worked well. Granted, the passwords aren't going to be incredibly secure (as they're prone to dictionary attacks), but for memorisable, or at least readable, passwords it works well: function generatePassword($syllable...
|sockets|tcp|
I'm a beginning C++ programmer / network admin, but I figure I can learn how to do this if someone points me in the right direction. Most of the tutorials are demonstrated using old code that no longer works for some reason. Since I'm on Linux, all I need is an explanation on how to write raw Berkeley sockets. Can ...
|sockets|tcp|c++|c|
|c++|c|sockets|tcp|bsd-sockets|
Does Vista do stricter checking or Interface Ids in DCOM calls? (the Stub received bad Data)?
|dcom|
I hope everyone will pardon the length, and narrative fashion, of this question. I decided to describe the situation in some detail in my blog. I later saw Joel's invitation to this site, and I thought I'd paste it here to see if anyone has any insight into the situation. I wrote, and now support, an application t...
I hope everyone will pardon the length, and narrative fashion, of this question. I decided to describe the situation in some detail in my blog. I later saw Joel's invitation to this site, and I thought I'd paste it here to see if anyone has any insight into the situation. I wrote, and now support, an application t...
Does Vista do stricter checking of Interface Ids in DCOM calls? (the Stub received bad Data)?
|windows-vista|dcom|
Use LDAP/AD for authentication only, tie LDAP users to a most robust profile/authorization server using some sort of traditional database (MSSQL/PostgreSQL/MySQL) or document based DB (CouchDB, SimpleDB, et cetera). Use LDAP for authorization, then hit the DB for more advanced stuff.
Personally I would use a classmethod whenever I needed a static method. Mainly because I get the class as an argument. class myObj(object): def myMethod(cls) ... myMethod = classmethod(myMethod) or use a decorator class myObj(object): @classmethod def myMethod...
Personally I would use a classmethod whenever I needed a static method. Mainly because I get the class as an argument. class myObj(object): def myMethod(cls) ... myMethod = classmethod(myMethod) or use a decorator class myObj(object): @classmethod def myMethod...
This seems to be a bug in SSRS 2005 Excel rendering. I've been able to fix this by explicitly setting all sides of the matrix BorderStyle property (Left, Right, Top, Bottom) to Solid. Also, when you do this, it seems like setting the BorderStyle.Default property to Solid or None doesn't matter. The value explicitly ...
For human-readable passwords, I recently used a PHP script very similar to the one below. It worked well. Granted, the passwords aren't going to be incredibly secure (as they're prone to dictionary attacks), but for memorisable, or at least readable, passwords it works well. However, this function shouldn't be used ...
Is it possible that you need to cast $esi? p (NSUInteger)[(NSArray *)$esi count]
Is it possible that you need to cast `$esi`? p (NSUInteger)[(NSArray *)$esi count]
Is there any resources for becoming a Cygwin "power user"?
|cygwin|windows|nix|
I've got it configured, but I want more from it...maybe Cygwin isn't the right tool, but I like how it provides a *nix-like environment within Windows.
|webserver|http-redirect|sun|
I have Sun webserver iws6 (iplanet 6) proxying my bea cluster. My cluster is under /portal/yadda. I want anyone who goes to http://the.domain.com/ to be quickly redirected to http://the.domain.com/portal/ . I have and index.html that does a post and redirect, but the user sometimes sees it. Does anyone have a bette...
unsigned char is the heart of all bit trickery. In almost ALL compiler for ALL platform an unsigned char is simply a BYTE. An unsigned integer of (usually) 8 bits. that can be treated as a small integer or a pack of bits. In addiction, as someone else has said, the standard doesn't define the sign of a char. so you...
using TSQL, run an exact match, check for num of rows == 0, if so, run the like, otherwise don't run the like or add the like results below the exact matches.
http://directwebremoting.org/ I use this to dynamically populate drop downs, and even filter them on the fly based on user input in other places on the form.
<a href="http://directwebremoting.org/">DWR</a> I use this to dynamically populate drop downs, and even filter them on the fly based on user input in other places on the form.
- +1 for [LORI][1] ("life-of-request-info"). It's a very convenient alternative for rough measurements of the load time of a particular web page -- the kind of thing that you might otherwise use an external stopwatch for. - [New Tab Homepage][2]. Combined with a "speed dial"-type homepage (a personal, fast-loa...
C# driver development?
|c#|kernel|drivers|device|
Before I jump headlong into C#... I've always felt that C, or maybe C++, was best for developing drivers on Windows. I'm not keen on the idea of developing a driver on a .NET machine. But .NET seems to be the way MS is heading for applications development, and so I'm now wondering: - Are people are using C#...
As long as it's documented and contracted, and not too WTFy, then there shouldn't be a problem. Then again, I would recommend using exceptions for something like this. It makes more sense. If you can use PHP5, then that would be the way to go. Otherwise you don't have much choice.
Using code snippets you can get to something like this <pre> Dim randomNumGen As RandomNumberGenerator = RNGCryptoServiceProvider.Create() Dim randomBytes(20) As Byte randomNumGen.GetBytes(randomBytes) return Convert.ToBase64String(randomBytes) </pre>
When using a gridview without a datasource control (i.e. binding a dataset straight to the control) you need to manually implement sorting and paging events as shown here: [http://ryanolshan.com/technology/gridview-without-datasourcecontrol-datasource/][1] [1]: http://ryanolshan.com/technology/gridview-withou...
Temp tables and SQL SELECT performance
|sql|performance|
Why does the use of temp tables with a SELECT statement improve the logical I/O count? Wouldn't it increase the amount of hits to a database instead of decreasing it. Is this because the 'problem' is broken down into sections? I'd like to know what's going on behind the scenes.
The [Interpretation of Object-Oriented Programming Languages][1] by Ian Craig Because it showed me how much more there was to OO than standard C++/Java idioms [1]: http://www.amazon.co.uk/Interpretation-Object-oriented-Programming-Languages/dp/1852335475/ref=sr_1_1?ie=UTF8&s=books&qid=1221573489&sr=8-1
How do I implement a Linked List in Java?
|homework|java|linkedlist|
So I got this as a homework question, and I was wondering if you pros could do it for me. KTHXBYE!
|java|linkedlist|homework|
What's the best way to make a linked list in Java?