instruction stringlengths 0 30k ⌀ |
|---|
|asp.net| |
Can I get a when to use for these and others?
<% %>
<%# EVAL() %>
Thanks |
It may not be feasible in your case, but I've seen people employ a little preprocessor-foo to massage the types into compatibility.
Even this assumes that you are building one or both libraries.
It is also possible that you don't want to do this at all, but want to re-evaulate some early decision. Or not.
Good... |
If the structs were the same internally, you could do a reinterpret_cast; however, since it looks like you have 16-bit vs 32-bit fields, you're probably stuck converting on each call, or writing wrappers for all functions of one of the libraries. |
Good 15 minute Java question to ask recent college graduate |
|java| |
When interviewing college coops/interns or recent graduates it helps to have a Java programming question that they can do on a white board in 15 minutes. Does anyone have examples of good questions like this? A C++ question I was once asked in an interview was to write a string to integer function which is along the ... |
# Lambda Calculus
- input and output are Church numerals (i.e. natural number `k` is `\f n. f^k n`; so `3 = \f n. f (f (f n))`)
(\x. x x) (\y f. f (y y f)) (\y n. n (\x y z. z) (\x y. x) (\f n. f n) (\f. n (y (\f m. n (\g h. h (g f)) (\x. m) (\x. x)) f)))
|
Here is a trick for TortoiseSVN:
[How to turn off “auto-merge” in Subversion][1]
Trick for svn.exe:
Set svn external diff tool to a program that will constantly fail.
svn --diff-cmd=/bin/false
If external diff program fails, svn concludes that conflict is unresolvable and wouldn't merge it.
[1]: h... |
Create a daily tag of your current source control trunk? |
What's the problem with adding the indexes after you put data into the temp table?
One thing you need to be mindful of is the visibility of the index to other instances of the procedure that might be running at the same time.
I like to add a guid to these kinds of temp tables (and to the indexes), to make sure th... |
It's not difficult to find out what the compiler is doing with your code (I'm using DevStudio 2005 here). Write a simple program with the following code:
int i = 45, j, k;
j = i * 3;
k = i + (i * 2);
Place a breakpoint on the middle line and run the code using the debugger. When the breakpoint is tr... |
As mentioned by everyone else, you're safe as long as you encode *all* user input before displaying it. This includes all request parameters and data retrieved from the database that can be changed by user input.
As [mentioned by Pat][1] you'll sometimes want to display some tags, just not all tags. One common way t... |
Absolute positioning is messing you up. Try something like this:
HTML:
<div id="wrapper">
<div id="header">
header
</div>
<div id="content">
content
</div>
<div id="footer">
footer
</div>
</div>
CSS:
#wrapper {
width: 200px;
b... |
Absolute positioning is messing you up. Try something like this:
HTML:
<div id="wrapper">
<div id="header">
header
</div>
<div id="content">
content
</div>
<div id="footer">
footer
</div>
</div>
CSS:
#wrapper {
width: 200px;
h... |
The best approach I know is to check if specific API is exported from some DLL. Each new Windows version adds new functions and by checking the existance of those functions one can tell which OS the application is running on. For example, Vista exports [GetLocaleInfoEx][1] from kernel32.dll while previous Windowses did... |
I am a big fan of [DB4O for both .Net and Java][1].
Performance has become much better since the early releases. The licensing model isnt too bad, either. I particularly like the options available for querying your objects. Query by example is very powerful and easy to get used to.
[1]: http://www.db4o.com/De... |
We use HSQLDB in production as a "no-configuration" option for our application. It allows people to trial without the hassle of setting up a real database.
However we do *not* support it for normal use. The reasons are several:
1. Slows down proportionally to the size of the data.
2. Difficult to access outs... |
Why the map/lamda magic? Doesn't this work?
>>>foo = [ 'a', 'b', 'c' ]
>>>print ",".join(foo)
a,b,c
>>>print ",".join([])
>>>print ",".join(['a'])
a
|
Why the map/lamda magic? Doesn't this work?
>>>foo = [ 'a', 'b', 'c' ]
>>>print ",".join(foo)
a,b,c
>>>print ",".join([])
>>>print ",".join(['a'])
a
Edit: @mark-biek points out the case for numbers.
Perhaps the list comprehension:
>>>','.join([str(x) for x in foo])
is m... |
Why the map/lamda magic? Doesn't this work?
>>>foo = [ 'a', 'b', 'c' ]
>>>print ",".join(foo)
a,b,c
>>>print ",".join([])
>>>print ",".join(['a'])
a
Edit: @mark-biek points out the case for numbers.
Perhaps the list comprehension:
>>>','.join([str(x) for x in foo])
is... |
While in general I would stay away from non-semantic tags like `b` and `i`, `strong` and `em` are not direct replacements for `b` and `i`.
I would use `b` or `i` when it's only presentation you're going for, and what you're marking up has no semantic meaning. For example, a logo like stackoverflow could be marked up... |
Backporting a VB.Net 2008 app to target .Net 1.1 |
|vb.net| |
I have a small diagnostic VB.Net application ( 2 forms, 20 subs & functions) written using VB.Net 2008 that targets Framework 2.0 and higher, but now I realize I need to support Framework 1.1. I'm looking for the most efficient way to accomplish this given these constraints:
. I don't know which parts of the applic... |
Use the Font-property on the gridview. See MSDN for details and samples:
<http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.font.aspx>
|
If you were to think of an event as a subscriber list, in your code all you are doing is registering a subscriber. The number of instructions needed to achieve that is likely to be minimal at the CLR level.
If you want your code to be generic or dynamic, then you're need to check if something is subscribed prior to... |
This particular hash functions XORs all of the characters in a string. Unfortunately XOR is associative:
(a XOR b) XOR c = a XOR (b XOR c)
So any strings with the same input characters will result in the same hash code. The two strings provided are the same, except for the location of two characters, theref... |
There is truth in that if you hash something, yes, there will be collisions so it would be possible for two different passwords to unlock the same account.
From a practical standpoint though, that's a poor argument - A good hashing function (md5 or sha1 would be fine) can pretty much guarantee that for all meaningfu... |
It depends on what you're defending against. If it's an attacker pulling down your database (or tricking your application into displaying the database), then plaintext passwords are useless. There are many attacks that rely on convincing the application to disgorge it's private data- SQL injection, session hijack, etc.... |
example, this will replace all the a characters with b
UPDATE YourTable
SET Column1 = REPLACE(Column1,'a','b')
WHERE Column1 LIKE '%a%'
Btw there is no SQL server 2003 |
I encountered this exact same issue in my workplace. What I did to convince him that hashing was more secure was to write a SQL injection that returned the list of users and passwords from the public section of our site. It was escalated right away as a major security issue :)
To prevent against dictionary/hash at... |
You could try mmm-mode and multi-mode. I haven't tried them: I'm happy with nxhtml for now. What sort of problems did you encounter? |
Put something like this in your application controller. I'm using the subdomain plus "_clientdb" to pick the name of the database. I have all the databases using the same username and password, so I can grab that from the db config file.
Hope this helps!
class ApplicationController < ActionController::Base
... |
It is worth mentioning that not calling inherited in Destroy of any object can cause memory leaks. There are tools available to check for this in your source code. |
In my opinion every programmer has his or her own "words" that is used every time you need an arbitrary word when programming.
For some people it's the first words from a childs song, for other it's names and for other its something completely different.
Now for the programmer community there are these "words" as we... |
We always use maximize for optimal speed but then, all the code I write in C++ is somehow related to bioinformatics algorithms and speed is crucial while the code size is relatively small. |
Why does windows XP minimize my swing full screen window on my second screen ? |
|java|windows|swing| |
In the application I'm developping (in Java/swing), I have to show a full screen window on the *second* screen of the user.
I did this using a code similar to the one you'll find below...
Be, as soon as I click in a window opened by windows explorer, or as soon as I open windows explorer (i'm using windows XP), the f... |
1. Write a function to swap variable values using pointers (Really poor ones will fall for this)
2. Write a program to find the distance between two points in the XY plane. Make use of a class to store the points.
3. Demonstrate the use of polymorphism in java using as simple program.
4. Write a program to print... |
Semantically speaking I think option 1 makes the most sense, if you're treating DB as a resource then the DB_Connectioin is an object that it uses but not necessarily the object itself.
However, several things I caution you against. First, don't make your DB class have all static methods as it will strongly impact ... |
How do you capture mouse events in FF, over Shockwave Object |
|shockwave|firefox|javscript| |
How do you capture the mouse events, move and click over top of a shockwave object in Firefox, via Javascript. The code works in IE but not in FF. |
|shockwave|firefox|javascript| |
|javascript|firefox|shockwave| |
How do you capture the mouse events, move and click over top of a Shockwave object in Firefox, via JavaScript. The code works in IE but not in FF.
The script works on the document body of both IE and Moz, but mouse events do not fire when mouse is over a shockwave director object embed.
Update:
functio... |
How do you capture the mouse events, move and click over top of a Shockwave Director Object (not flash) in Firefox, via JavaScript. The code works in IE but not in FF.
The script works on the document body of both IE and Moz, but mouse events do not fire when mouse is over a shockwave director object embed.
Upda... |
Criteria API does not provide all functionality avaiable in HQL. For example, you cannot do more than one join over the same column.
Why don't you use **[NAMED QUERIES][1]**? The look much more clean:
Person person = session.getNamedQuery("Person.findByName")
.setString(0, "M... |
[Java DB][1] (Sun's distribution of Apache Derby) now ships *in* JDK 6!
I've been wanted to do something like Jason Cohen and have been thinking this looks like the easiest way being in the JDK distro (which of last week is now a requirement for my app). Or maybe I am just lazy that way.
[1]: http://develo... |
Nathan, under what circumstances in a segment base non-zero? I've never seen that occur in my 5 years of Linux application development.
Thanks.
|
Using Small (1-10 Items) Instance-Level Collections in Java |
|java|collections| |
You could call during init or whatever [Locale.setDefault()][1] or -Duser.language=, -Duser.country=, and -Duser.variant= at the command line. [Here's something on Sun's site][2].
[1]: http://java.sun.com/javase/6/docs/api/java/util/Locale.html#setDefault(java.util.Locale)
[2]: http://java.sun.com/developer/t... |
I am not sure about what you mean about declared classes not existing between evals, the following two scripts work as expected when evaled one after another:
class C {{println 'hi'}}
new C()
...
new C()
However methods become bound to the class that declared them, and GroovyShell creates a new ... |
I believe java gleans this from the environment variables in which it was launched, so you'll need to make sure your LANG and LC_* environment variables are set appropriately. |
In the upcoming Velocity 1.6 release, you will be able to do #if( $car == $null ) without error messages. This will allow you to distinguish easily between when $car is null and when it is false. To do that now requires #if( $car && $car != false ), which just isn't as friendly. |
A safe way is to serialize the object, then deserialize. This ensures everything is a brand new reference.
[Here's an article][1] about how to do this efficiently.
Caveats: It's possible for classes to override serialization such that new instances are *not* created, e.g. for singletons. Also this of course doe... |
In my extra time away from real work, I've been learning XNA too.
IMHO (or not so humble if you ask my coworkers) is that the overhead of the event handles will be overwhelmed by other elements in the game such as rendering. Given the heavy use of events in normal .Net programming I would be the underlying code is ... |
More specifically than DaveK, it usually means that if you want to add additional functionality, or change the functionality of a class, create a subclass instead of changing the original. This way, anyone using the parent class does not have to worry about it changing later on. Basically, it's all about backwards comp... |
You can set it in the thread context in which your code is executing.
System.Threading.Thread.CurrentThread.CurrentCulture |
I'm afraid I don't know any answer other than to start looking around in your area for old hardware. The CPU isn't the only variable that can (usually) affect things. L1/L2 cache size, memory bus speed, memory speed/latency, hard drive speed, etc. are all significant factors in many applications. |
If you do not salt your Password, you're suspect to Rainbow Table attacks (precompiled Dictionaries that have valid inputs for a given hash)
The other developer should stop talking about security if you're storing passwords in plaintext and start reading about security.
Collisions are possible, but not a big prob... |
If you do not salt your Password, you're suspect to Rainbow Table attacks (precompiled Dictionaries that have valid inputs for a given hash)
The other developer should stop talking about security if you're storing passwords in plaintext and start reading about security.
Collisions are possible, but not a big prob... |
And here's my solution should work with Excel > 2000, but tested only on 2007:
Private Sub SaveAllSheetsAsCSV()
On Error GoTo Heaven
' each sheet reference
Dim Sheet As Worksheet
' path to output to
Dim OutputPath As String
' name of each csv
Dim OutputFile As String
... |
Memory is cheap now days :) So it can be meaningful to set compiler settings to max speed unless you work with embedded systems. Of course answer depends on concrete situation. |
How to specify accepted certificates for Client Authentication in .NET SslStream |
|c#|.net|ssl|sspi| |
I am attempting to use the .Net System.Security.SslStream class to process the server side of a SSL/TLS stream with client authentication.
To perform the handshake, I am using this code:
SslStream sslStream = new SslStream(innerStream, false, RemoteCertificateValidation, LocalCertificateSelectionCallback);
... |
For me it depends on what platform I'm using. For some embedded platforms or when I worked on the Cell processor you have restraints such as a very small cache or minimal space provided for code.
I use GCC and tend to leave it on "-O2" which is the "safest" level of optimisation and favours speed over a minimal size... |
How to support multiple languages on a microcontroller? |
|translation|microcontroller|localization| |
I'm currently working on upgrading a product for the Chinese market. The target is a ARMTDMI7 with a QVGA display. Most resources I've located on the net are targeted at desktop or web programming rather than embedded devices.
- Can anyone suggest some tools and
resources that might be useful?
- What are t... |
Some stuff that has showed up on SO:
* IsPalindrome(string s)
* ReverseWordsInString(string s): "I know java" --> "java know I"
Other stuff that springs to mind:
* multiply a Vector with a Matrix (can this be done OO-Style?)
* `echo` (yes, a simple clone of the unix tool)
* `cat` (15 min should be enough, s... |
Usually when an application is in "full screen" mode it will take over the entire desktop. For a user to get to another window they would have to alt-tab to it. At that point windows would minimize the full screen app so that the other application could come to the front.
This sounds like it may be a bug (undocum... |
While creating classes in Java I often find myself creating instance-level collections that I know ahead of time will be very small - less than 10 items in the collection. But I don't know the number of items ahead of time so I typically opt for a dynamic collection (ArrayList, Vector, etc).
class Foo
{
... |
<p>As a general point, I'd recommend abstracting the implementation of your settings into a 'Settings Provider' and provide different providers for each platform. That way, you can implement the storage of the settings in the manner that best suits the target platforms (for example, a file on Linux or the Windows Regis... |
Answering my own question:
Apparently my SVN URL had the wrong case! A google search turned up [this article][1] that explained what was going on. My URL was of the form http://svn.foobar.com/foobar but the actual repository was called http://svn.foobar.com/fooBar.
I use TortoiseSVN, so the fix was to use the Rel... |
If you are using SQL Server 2005 or greater, depending on the size of the data in the Notes field, you may want to consider casting to nvarchar(max) as casting to a specific length could result in string truncation.
Select Cast(notes as nvarchar(max)) + 'SomeText' From NotesTable a |
If you are using SQL Server 2005 or greater, depending on the size of the data in the Notes field, you may want to consider casting to nvarchar(max) instead of casting to a specific length which could result in string truncation.
Select Cast(notes as nvarchar(max)) + 'SomeText' From NotesTable a
|
I'm going to get downmodded for this, but this sounds like a job for a table.
What you're trying to do is to set the total height of three contiguous divs as a unit, and a 1x3 table with height 100% is actually a cleaner solution. |
If you're working with a compiler that will support it, I would suggest taking a look at <http://www.openmp.org> for a way of annotating your code in such a way that
certain loops will be parallelized.
It does a lot more as well, and you might find it very helpful.
Their web page reports that gcc4.2 will support... |
Problems with migrating Cardspace cards between computers |
|openid|cardspace| |
Here's the scenario. I'm using myopenid for, among other things, StackOverflow. When I initially set up my openid account with myopenid, I decided to try out Cardspace because they had support.
I later wanted to access Stackoverflow from another machine so I chose to back up my card. I gave it a password and a filen... |
Rather than a rails/mongrel problem, it sounds more likely that there's an issue either with your XML file or with the way REXML handles it. You can check this by writing a short script to read your XML file directly (rather than within a request) and seeing if it still fails.
Assuming it does, there are a couple o... |
One way to control the locale settings is to set the java system properties user.language and user.region. |
Homework? :-)
I would think that a simple pipe with sed (to split each line into two) and split (to split things up into multiple files) would be enough.
The man command is your friend. |
Homework? :-)
I would think that a simple pipe with sed (to split each line into two) and split (to split things up into multiple files) would be enough.
The man command is your friend.
--------------
Added after confirmation that it is not homework:
How about
sed 's/\(.....\)\(.....\)/\1\n\2/'... |
The [ModNTLM][1] source for Apache may provide you with the right pointers.
If possible, you should consider using [Kerberos][2] instead. It lets you authenticate Apache against AD, and it's a more active project space than NTLM.
[1]: http://modntlm.sourceforge.net/
[2]: http://grolmsnet.de/kerbtut/ |
Currently the best technique for making an RIA indexable by search engines is called [progressive enhancement][1] (or graceful degradation, depending on which way you see it). Basically you create a simple HTML version of the application using the same data as the application loads. This version should be dynamically g... |
like so:
<code>
BEGIN TRANSACTION; UPDATE table_name
SET title=REPLACE(column_name,'text_to_find','replace_with_this'); COMMIT TRANSACTION;
</code>
Example: Replaces <script... with <a ... to eliminate javascript vulnerabilities
<code>
BEGIN TRANSACTION; UPDATE testdb
SET title=REPLACE(title,'script... |
like so:
<code>
BEGIN TRANSACTION; UPDATE table_name
SET column_name=REPLACE(column_name,'text_to_find','replace_with_this'); COMMIT TRANSACTION;
</code>
Example: Replaces <script... with <a ... to eliminate javascript vulnerabilities
<code>
BEGIN TRANSACTION; UPDATE testdb
SET title=REPLACE(title,'... |
What is the Interface Segregation Principle and why is it important? |
|oop| |
The Interface Segregation Principle says that many client specific interfaces are better than one general purpose interface. Why? |
The Interface Segregation Principle |
The Interface Segregation Principle says that many client specific interfaces are better than one general purpose interface. Why is this important? |
|oop| |