I am trying to come up with a validation for a nullable property, like int?
Example
[RangeValidator(0, RangeBoundaryType.Inclusive, 1, RangeBoundaryType.Inclusive)]
int? Age { get; set; }
However if I set Age to null validation fails because it doesn't fall in the range, I know I need an [ValidatorComposition(CompositionType.Or)] as well, but what else should I use?
I'm not quite sure why I can't do
double a = (float) my_Function(45) / 2048 / 2340 / 90;
printf("%.4",a); // prints out 0.00
But instead I have to use one more variable as:
double a = (float) my_Function(45);
double b = (float) a / 2048 / 2340 / 90;
printf("%.4",b); // prints out the correct value
hi,
I've a sequence of elements and the last one has css "float:left".
I would like to display it at the same height of the first element and not on the bottom of the list. (I cannot change the html code, so it is the last in the list).
At the same time, I would like to keep it on the right. How can I make it wich CSS ?
thanks
Code:
<div class="field field-type-text field-field-year">
<div class="field-items">
<div class="field-item odd">
<div class="field-label-inline-first">
Year: </div>
2009 </div>
</div>
</div>
<div class="field field-type-text field-field-where">
<div class="field-items">
<div class="field-item odd">
<div class="field-label-inline-first">
Where: </div>
Musée Rath, Geneva </div>
</div>
</div>
<div class="field field-type-text field-field-when">
<div class="field-items">
<div class="field-item odd">
<div class="field-label-inline-first">
When: </div>
25.8 – 27.9.2009 </div>
</div>
</div>
<div class="field field-type-text field-field-editor">
<div class="field-items">
<div class="field-item odd">
<div class="field-label-inline-first">
Editor: </div>
Blabla Blabla </div>
</div>
</div>
<div class="field field-type-text field-field-material">
<div class="field-items">
<div class="field-item odd">
<div class="field-label-inline-first">
Material/techniques: </div>
contemporary art installations </div>
</div>
</div>
<div class="field field-type-text field-field-dimension">
<div class="field-items">
<div class="field-item odd">
<div class="field-label-inline-first">
Dimension: </div>
2 floors in a neoclassical building </div>
</div>
</div>
<div class="field field-type-text field-field-artists">
<div class="field-items">
<div class="field-item odd">
<div class="field-label-inline-first">
Artists: </div>
Blablablabla balbalbalbalba
</div>
</div>
</div>
.field-field-year, .field-field-where, .field-field-when, .field-field-editor, .field-field-material, .field-field-dimension {
width:300px;
}
.field-field-artists {
width:400px;
float:right;
clear:right;
top-margin: -200px;
}
I've written a regular expression that automatically detects URLs in free text that users enter. This is not such a simple task as it may seem at first. Jeff Atwood writes about it in his post.
His regular expression works, but needs extra code after detection is done.
I've managed to write a regular expression that does everything in a single go. This is how it looks like (I've broken it down into separate lines to make it more understandable what it does):
1 (?<outer>\()?
2 (?<scheme>http(?<secure>s)?://)?
3 (?<url>
4 (?(scheme)
5 (?:www\.)?
6 |
7 www\.
8 )
9 [a-z0-9]
10 (?(outer)
11 [-a-z0-9/+&@#/%?=~_()|!:,.;cšžcd]+(?=\))
12 |
13 [-a-z0-9/+&@#/%?=~_()|!:,.;cšžcd]+
14 )
15 )
16 (?<ending>(?(outer)\)))
As you may see, I'm using named capture groups (used later in Regex.Replace()) and I've also included some local characters (cšžcd), that allow our localised URLs to be parsed as well. You can easily omit them if you'd like.
Anyway. Here's what it does (referring to line numbers):
1 - detects if URL starts with open braces (is contained inside braces) and stores it in "outer" named capture group
2 - checks if it starts with URL scheme also detecting whether scheme is SSL or not
3 - start parsing URL itself (will store it in "url" named capture group)
4-8 - if statement that says: if "sheme" was present then www. part is optional, otherwise mandatory for a string to be a link (so this regular expression detects all strings that start with either http or www)
9 - first character after http:// or www. should be either a letter or a number (this can be extended if you'd like to cover even more links, but I've decided not to because I can't think of a link that would start with some obscure character)
10-14 - if statement that says: if "outer" (braces) was present capture everything up to the last closing braces otherwise capture all
15 - closes the named capture group for URL
16 - if open braces were present, capture closing braces as well and store it in "ending" named capture group
First and last line used to have \s* in them as well, so user could also write open braces and put a space inside before pasting link.
Anyway. My code that does link replacement with actual anchor HTML elements looks exactly like this:
value = Regex.Replace(
value,
@"(?<outer>\()?(?<scheme>http(?<secure>s)?://)?(?<url>(?(scheme)(?:www\.)?|www\.)[a-z0-9](?(outer)[-a-z0-9/+&@#/%?=~_()|!:,.;cšžcd]+(?=\))|[-a-z0-9/+&@#/%?=~_()|!:,.;cšžcd]+))(?<ending>(?(outer)\)))",
"${outer}<a href=\"http${secure}://${url}\">http${secure}://${url}</a>${ending}",
RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
As you can see I'm using named capture groups to replace link with an Anchor tag:
"${outer}<a href=\"http${secure}://${url}\">http${secure}://${url}</a>${ending}"
I could as well omit the http(s) part in anchor display to make links look friendlier, but for now I decided not to.
Question
I would like my links to be replaced with shortenings as well. So when user copies a very long link (for instance if they would copy a link from google maps that usually generates long links) I would like to shorten the visible part of the anchor tag. Link would work, but visible part of an anchor tag would be shortened to some number of characters. I could as well append ellipsis at the end of at all possible (and make things even more perfect).
Does Regex.Replace() method support replacement notations so that I can still use a single call? Something similar as string.Format() method does when you'd like to format values in string format (decimals, dates etc...).
I generate a dynamic assembly with CSharpCodeProvider, from a C# source saved into a string.
I can run the synamic code at runtime, but if I pause the execution Visual Studio doesn't show me the dinamic source code in the call stack. It says "External code" and I can't step into that source code.
I think VS can't find PDB or other debug info. Can you help me?
I created an extension method called HasContentPermission on the System.Security.Principal.IIdentity interface:
namespace System.Security.Principal
{
public static bool HasContentPermission
(this IIdentity itentity, int contentID)
{
// I do stuff here
return result;
}
}
And I call it like this:
bool hasPermission = User.Identity.HasPermission(contentID);
Works like a charm. Now I want to unit test it. To do that, all I really need to do is call the extension method directly, so:
using System.Security.Principal;
namespace MyUnitTests
{
[TestMethod]
public void HasContentPermission_PermissionRecordExists_ReturnsTrue()
{
IIdentity identity;
bool result = identity.HasContentPermission(...
But HasContentPermission won't intellisense. I tried creating a stub class that inherits from IIdentity, but that didn't work either. Why?
Or am I going about this the wrong way?
Over the years my application has grown from 1MB to 25MB and I expect it to grow further to 40, 50 MB. I don't use DLL's, but put everything in this one big executable.
Having one big executable has certain advantages:
Installing my application at the customer is really: copy and run.
Upgrades can be easily zipped and sent to the customer
There is no risk of having conflicting DLL's (where the customer has version X of the EXE, but version Y of the DLL)
The big disadvantage of the big EXE is that linking times seem to grow exponentially.
Additional problem is that a part of the code (let's say about 40%) is shared with another application. Again, the advantages are that:
There is no risk on having a mix of incorrect DLL versions
Every developer can make changes on the common code which speeds up developments.
But again, this has a serious impact on compilation times (everyone compiles the common code again on his PC) and on linking times.
The question http://stackoverflow.com/questions/2387908/grouping-dlls-for-use-in-executable mentions the possibility of mixing DLL's in one executable, but it looks like this still requires you to link all functions manually in your application (using LoadLibrary, GetProcAddress, ...).
What is your opinion on executable sizes, the use of DLL's and the best 'balance' between easy deployment and easy/fast development?
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
C:\Documents and Settings\Administrator>bcp "SELECT TOP 1000 * FROM SOData.dbo.E
xperts" queryout c:\customer3.txt -n -t -UAdministrator -P -SDNAWINDEV
SQLState = 28000, NativeError = 18456
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for u
ser 'Administrator'.
or.. without -P flag
C:\Documents and Settings\Administrator>bcp "SELECT TOP 1000 * FROM SOData.dbo.E
xperts" queryout c:\customer3.txt -n -t -UAdministrator -P -SDNAWINDEV
SQLState = 28000, NativeError = 18456
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for u
ser 'Administrator'.
or, without -P flag, and typing the password.. is the same
C:\Documents and Settings\Administrator>bcp "SELECT TOP 1000 * FROM SOData.dbo.E
xperts" queryout c:\customer3.txt -n -t -UAdministrator -SDNAWINDEV
Password:
SQLState = 28000, NativeError = 18456
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for u
ser 'Administrator'.
I'm having huge performance issues when I add RMI proxy references to a Java Swing JList-component.
I'm retrieving a list of user Profiles with RMI from a server. The retrieval itself takes just a second or so, so that's acceptable under the circumstances. However, when I try to add these proxies to a JList, with the help of a custom ListModel and a CellRenderer, it takes between 30-60 seconds to add about 180 objects. Since it is a list of users' names, it's preferrable to present them alphabetically.
The biggest performance hit is when I sort the elements as they get added to the ListModel. Since the list will always be sorted, I opted to use the built-in Collections.binarySearch() to find the correct position for the next element to be added, and the comparator uses two methods that are defined by the Profile interface, namely getFirstName() and getLastName().
Is there any way to speed this process up, or am I simply implementing it the wrong way? Or is this a "feature" of RMI? I'd really love to be able to cache some of the data of the remote objects locally, to minimize the remote method calls.
Hi guys needing a bit of help.
I am creating a one page personal site.
Each section has a menu in it to jump to another section, however i want to have a class added to menu for the current section:
i.e. if you are in about the about link would have a class 'current'.
This is how it looks.
<section id="about">
<nav>
<li><a href="#" id ="about">About</a></li>
<li><a href="#" id ="contact">About</a></li>
<li><a href="#" id ="blog">About</a></li>
</nav>
New to jquery so i am struggling to find out how to do this.
Any help will be greatly appreciated.
Thanks
hi,
I cannot center the components in my VBox. I would like to set the standard css element "align: center". How can I do that in Flex ?
<mx:VBox>
<mx:LinkButton label="Tag1" />
<mx:Image source="@Embed(source='../icons/userIcon.png')" />
<mx:Label id="username" text="Nickname" visible="false" fontWeight="bold" />
</mx:VBox>
thanks
I am saving a reference to an RSS Feed in MongoDB, each Feed has an ever growing list of Entries. As I'm designing my schema, I'm concerned about this statement from the MongoDB Schema Design - Embed vs. Reference Documentation:
If the amount of data to embed is huge
(many megabytes), you may read the
limit on size of a single object.
This will surely happen if I understand the statement correctly. So the question is, I am correct to assume that I should not embed the Feed Entries within a Feed because I'll eventually reach the limit on size of a single object?
hi,
I'm using FUpload module to upload multiple images together from my CCK Image field.
It perfectly works, however if I use it when I'm creating a new node, the other CCK Image fields stop to work and the images (from these fields) are not stored at all.
The error I get is "path doesn't exist"...
It sounds like fUpload force the other CCK fields to store the content before the node is saved and the folders are created. (I'm using path auto, to create folders accordingly to node title).
Could you give me some tips ?
Thanks
Hi. I'm using the ASP.NET 3.5 SP1 System.Web.Routing with classic WebForms, as described in http://chriscavanagh.wordpress.com/2008/04/25/systemwebrouting-with-webforms-sample/
All works fine, I have custom SEO urls and even the postback works. But there is a case where the postback always fails and I get a:
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Here is the scenario to reproduce the error:
Create a standard webform mypage.aspx with a button
Create a Route that maps "a/b/{id}" to "~/mypage.aspx"
When you execute the site, you can navigate http://localhost:XXXX/a/b/something the page works. But when you press the button you get the error. The error doen't happen when the Route is just "a/{id}".
It seems to be related to the number of sub-paths in the url. If there are at least 2 sub-paths the viewstate validation fails.
You get the error even with EnableViewStateMac="false".
Any ideas? Is it a bug?
Thanks
Hi! I need to post a status update of one of my facebook page when I create a model into my django project, but I don't know how to do it using the new facebook graph api:
http://github.com/facebook/python-sdk/blob/master/src/facebook.py
can you explain to me how to do it?
Thanks in advance :)
I have multiple image galleries that use the following code (simply view the demo at the following link).
http://www.sohtanaka.com/web-design/fancy-thumbnail-hover-effect-w-jquery/
However, when one clicks on the thumbnails of one gallery to change the large image preview - all the galleries change automatically to that large preview as well.
In short, the question is:
"How do I seperate each gallery from each other so when the user clicks on the thumbnails of one specific gallery the large image preview of that gallery changes and not any other?"
I currently have a PHP form that uses AJAX to connect to MySQL and display records matching a user's selection (http://stackoverflow.com/questions/2593317/ajax-display-mysql-data-with-value-from-multiple-select-boxes)
As well as displaying the data, I also place an 'Edit' button next to each result which displays a form where the data can be edited. My problem is editing unique records since currently I only use the selected values for 'name' and 'age' to find the record. If two (or more) records share the same name and age, I am only able to edit the first result.
By counter it could be pageviews, downloads, number of votes etc. Basically, not very 'critical' data.
What is the 'best' way to store those information? Mysql is not a good option. What do you guys use?
Hello. I wrote a test dll in C++ to make sure things work before I start using a more important dll that I need. Basically it takes two doubles and adds them, then returns the result. I've been playing around and with other test functions I've gotten returns to work, I just can't pass an argument due to errors.
My code is:
import ctypes
import string
nDLL = ctypes.WinDLL('test.dll')
func = nDLL['haloshg_add']
func.restype = ctypes.c_double
func.argtypes = (ctypes.c_double,ctypes.c_double)
print(func(5.0,5.0))
It returns the error for the line that called "func":
ValueError: Procedure probably called with too many arguments (8 bytes in excess)
What am I doing wrong? Thanks.
Hello!
Is there an option in the reportfiles for BIRT to enforce a locale? I want my reports to have a german number formating no matter what.
Thanks in advance!:-)
Do the client's SYN and the servers SYN+ACK get delayed by Nagle? Will the client's ACK of the server's SYN get delayed?
Will connect return after rtt+spt or will it take rtt + spt + 2x Nagle Delay?
Or more generally, how do the Nagle Algorith and Delayed ACK's affect TCP Connection Setup?
hi, I'm using jquery-plugin columnizer
http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=columnizer
for this website: http://donatellabernardi.ch/drupal
It is sometimes very slow to create the columns (you can try changing the browser window size, or selecting a filter.
Sometimes Firefox gives the error message: "Unresponsive Javascript script" and I have to press on continue to continue the navigation.
thanks
say ive got a matrix that looks like:
[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
how can i make it on seperate lines:
[[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]]
and then remove commas etc:
0 0 0 0 0
And also to make it blank instead of 0's, so that numbers can be put in later, so in the end it will be like:
_ 1 2 _ 1 _ 1
(spaces not underscores)
thanks