How do I safely add a variable to JSON data with C#? For instance I might have [{"data": "data"}, {"data": "data"}] or I might have {"data": "data"}. How do I add a new variable "newdata": "newdata" to the structure?
Want something inexpensive that just tells me how many calls a number gets, id like a different # for different sources of users and want to track volume from each source
Any ideas?
Thanks
Aaron
I'm using vb.net 2008 edition and i was wondering if there a way to convert an array type to another array type. For instance say i dim an array as string and then want to convert the array to the integer data type for sorting, how would i go about this?
Data validation, whether it be domain object, form, or any other type of input validation, could theoretically be part of any development effort, no matter its size or complexity. I sometimes find myself writing informational or error messages that might seem harsh or demanding to unsuspecting users, and frankly I feel like there must be a better way to describe the validation problem to the user.
I know that this topic is subjective and argumentative. StackOverflow might not be the proper channel for diving into this subject, but like I've mentioned, we all run into this at some point or another. There are so many StackExchange sites now; if there is a better one, feel free to share!
Basically, I'm looking for good resources on data validation and user feedback that results from it at a theoretical level. Topics and questions I'm interested in are:
Content
Should I be describing what the user did correctly or incorrectly, or simply what was expected?
How much detail can the user read before they get annoyed? (e.g. Is "Username cannot exceed 20 characters." enough, or should it be described more fully, such as "The username cannot be empty, and must be at least 6 characters but cannot exceed 30 characters."?)
Grammar
How do I decide between phrases like "must not," "may not," or "cannot"?
Delivery
This can depend on the project, but how should the information be delivered to the user?
Should it be obtrusive (e.g. JavaScript alerts) or friendly?
Should they be displayed prominently? Immediately (i.e. without confirmation steps, etc.)?
Logging
Do you bother logging validation errors?
Internationalization
Some cultures prefer or better understand directness over subtlety and vice-versa (e.g. "Don't do that!" vs. "Please check what you've done."). How do I cater to the majority of users?
I may edit this list as I think more about the topic, but I'm genuinely interest in proper user feedback techniques. I'm looking for things like research results, poll results, etc.
I've developed and refined my own techniques over the years that users seem to be okay with, but I work in an environment where the users prefer to adapt to what you give them over speaking up about things they don't like.
I'm interested in hearing your experiences in addition to any resources to which you may be able to point me.
I need to read data from a single WorkSheet in an Excel 2007 WorkBook using the OpenXML Format SDK v2.0. I have spent some not insignificant time searching for basic guidelines to doing this, but I have only found help on creating spreadsheets.
How do I iterate rows in a WorkSheet and then iterate the cells in each row, using this SDK?
If I have the following two tables :
Employes
Bob
Gina
John
Customers
Sandra
Pete
Mom
I will do a UNION for having :
Everyone
Bob
Gina
John
Sandra
Pete
Mom
The question is :
In my result, how can I creat a dumn column of differenciate the data from my tables ?
Everyone
Bob (Emp)
Gina (Emp)
John (Emp
Sandra (Cus)
Pete (Cus)
Mom (Cus)
I want to know from with table the entry is from withouth adding a new column in the database...
SELECT Employes.name
FROM Employes
UNION
SELECT Customers.name
FROM Customers;
Hi,
See the following Mock Test by using Spring/Spring-MVC
public class OrderTest {
// SimpleFormController
private OrderController controller;
private OrderService service;
private MockHttpServletRequest request;
@BeforeMethod
public void setUp() {
request = new MockHttpServletRequest();
request.setMethod("POST");
Integer orderNumber = 421;
Order order = new Order(orderNumber);
// Set up a Mock serviceservice = createMock(OrderService.class);
service.save(order);
replay(service);
controller = new OrderController();
controller.setService(service);
controller.setValidator(new OrderValidator());
request.addParameter("orderNumber", String.valueOf(orderNumber));
}
@Test
public void successSave() {
controller.handleRequest(request, new MockHttpServletResponse());
// Our OrderService has been called by our controller
verify(service);
}
@Test
public void failureSave() {
// Ops... our orderNumber is required
request.removeAllParameters();
ModelAndView mav = controller.handleRequest(request, new MockHttpServletResponse());
BindingResult bindException = (BindingResult) mav.getModel().get(BindingResult.MODEL_KEY_PREFIX + "command");
assertEquals("Our Validator has thrown one FieldError", bindException.getAllErrors(), 1);
}
}
As you can see, i do as proposed by Triple A pattern
Arrange (setUp method)
Act (controller.handleRequest)
Assert (verify and assertEquals)
But i would like to test both Mock and Implementation class (OrderService) by using this single Test class. So in order to retrieve my Implementation, i re-write my class as follows
@ContextConfiguration(locations="/app.xml")
public class OrderTest extends AbstractTestNGSpringContextTests {
}
So how should i write my single test to Arrange both Mock and Implementation OrderService without change my Test method (sucessSave and failureSave)
I am using TestNG, but you can show in JUnit if you want
regards,
Title says it all. I have some sensitive data that is stored in SQLite for an Android app. I need to be able to encrypt when persisting but then also decrypting when deserializing from the database too. Not sure what my options are on Android for doing this?
I am reading a open source project, and I found there is a function which read 3D data(let's say a character) from obj file, and draw it .
the source code:
List<Vertex3f> verts=new List<Vertex3f>();
List<Vertex3f> norms=new List<Vertex3f>();
Groups=new List<ToothGroup>();
//ArrayList ALf=new ArrayList();//faces always part of a group
List<Face> faces=new List<Face>();
MemoryStream stream=new MemoryStream(buffer);
using(StreamReader sr = new StreamReader(stream)){
String line;
Vertex3f vertex;
string[] items;
string[] subitems;
Face face;
ToothGroup group=null;
while((line = sr.ReadLine()) != null) {
if(line.StartsWith("#")//comment
|| line.StartsWith("mtllib")//material library. We build our own.
|| line.StartsWith("usemtl")//use material
|| line.StartsWith("o")) {//object. There's only one object
continue;
}
if(line.StartsWith("v ")) {//vertex
items=line.Split(new char[] { ' ' });
vertex=new Vertex3f();//float[3];
if(flipHorizontally) {
vertex.X=-Convert.ToSingle(items[1],CultureInfo.InvariantCulture);
}
else {
vertex.X=Convert.ToSingle(items[1],CultureInfo.InvariantCulture);
}
vertex.Y=Convert.ToSingle(items[2],CultureInfo.InvariantCulture);
vertex.Z=Convert.ToSingle(items[3],CultureInfo.InvariantCulture);
verts.Add(vertex);
continue;
}
And why it need to read the data manually in directX? As far as I know, in XDA programming, we just need to call a function a load the resource.
Is this because it is in DirectX, there is no function to read resource?
If yes, then how to prepare the 3D resource ? in XDA we just need to use other software draw the 3D picture and then export. but what should I do in DirectX?
I am using sqlite database to store data. I have three tables: Invoice, InvRow, Invdetails.
Relationsip between the tables are:
Invoice.Id = InvRow.InvId
InvRow.Id = Invdetails.RowId
I need to delete related entries from three tables using a single query. How can I do that?
Any help?
I have a MySQL table where all the data in one column was entered in UPPERCASE, but I need to convert in to Title Case, with recognition of "small words" akin to the Daring Fireball Title Case script.
I found this excellent solution for transforming strings to lowercase, but the Title Case function seems to have been left out of my version of MySQL. Is there an elegant way to do this?
I am building a custom module that will allow my users to do a simple query against an MS SQL database. I've built the form using hook_form() and have gotten validation to work.
I'm planning on retrieving the data from hook_form_submit(), but once I've done that, how do I append it below the form? It does not appear that I have access to $output from hook_form_submit(). I'm at a loss as to what to do next.
Thanks
Dana
emulator: ERROR: the user data image is used by another emulator. aborting
most of the time i face this problem..I restart Eclipse even..and restart emulator also..but still problem remain as it is.Why?
pls reply
Thanx
Maybe I just haven't figured out the InfoPath paradigm yet, but any links, or answers would be extremely grateful.
Here is my intent: Publish an Access Database on MOSS 2007, and then have InfoPath forms submit and retrieve data from that Access database. How is this achieved?
I'll let users register their [email protected] ,,, they enter their members area where they can :
1- send emails ( easy to do)
2- receive emails ..
for receiving emails , I'll use a catch all email account , read the email and figure to whom it's sent (username), and then I save it on the database with userid of the username who has registerd !
Do I miss something here ... is it really this simple (if I don't have an email server) ?
Hi,
I'm writing a C# program to get FoxPro database into datatable everything works except the memo field is blank or some strange character.
I'm using C# .Net 2.0.
I tried the code posted by Jonathan Demarks dated Jan 12. I am able to get the index but i don't know how to use this index to fetch the data from memo file.
Pleaese help me.
Thanks
Madhu
i am a newbie to JSf and Tomahawk Technology. In application i am having a datatable, i want store the information from he data table into a PDF format on a click of a button using Tomahawk and SandBox.Kindly Help.
During the installation of Apache2 I got the following message into cmd window:
Installing the Apache2.2 service The
Apache2.2 service is successfully
installed. Testing httpd.conf....
Errors reported here must be corrected
before the service can be started.
httpd.exe: Could not reliably
determine the server's fully qualified
domain name , using 192.168.1.3 for
ServerName (OS 10048)Only one usage of
each socket address (protocol/network
address/port) is normally permitted.
: make_sock: could not bind to address
0.0.0.0:80 no listening sockets available, shutting down Unable to
open logs Note the errors or messages
above, and press the key to
exit. 24...
and after installing everything look fine, but it isn't. If I try to start service I got the following message:
Windows could not start the Apache2 on
Local Computer. For more information,
review the System Event Log. If this
is a non-Micorsoft service, contact
the service vendor, and refer to
service-specific error code 1.
Apach2 version is 2.2.9
Does anyone have the same problem, or could help me.
Hello Everyone
I'm playing around with Entity Framework 4 and code only. The tutorial I'm following is using the Beta-Version of Visual Studio 2010 and is referring to Microsoft.Data.Entity.Ctp.
Since I'm working with the final release of Visual Studio the name of the dll must have changed.
Can somebody tell me how its name is now?
Cheers, AC
The standard HTTP Authentication for SOAP passed the password etc in cleartext,and I'm looking for an alternative, possibly a key based mechanism to authenticate web services in lieu of the password.
OAuth is gaining a lot of popularity; would it be appropriate, and how would I implement it? Or perhaps there are other methods I should use.
The project itself is relatively simple, with just a one or two methods to be exposed, but security is of the utmost importance.
The idea is to allow to peer processes to exchange messages (packets) over tcp as much asynchronously as possible.
The way I'd like it to work is each process to have an outbox and an inbox. The send operation is just a push on the outbox. The receive operation is just a pop on the inbox. Underlying protocol would take care of the communication details.
Is there a way to implement such mechanism using a single TCP connection?
How would that be implemented using BSD sockets and modern OO Socket APIs (like Java or C# socket API)?
Since Snow Leopard, QTKit is now returning color corrected image data from functions like QTMovies frameImageAtTime:withAttributes:error:. Given an uncompressed AVI file, the same image data is displayed with larger pixel values in Snow Leopard vs. Leopard.
Currently I'm using frameImageAtTime to get an NSImage, then ask for the tiffRepresentation of that image. After doing this, pixel values are slightly higher in Snow Leopard.
For example, a file with the following pixel value in Leopard:
[0 180 0]
Now has a pixel value like:
[0 192 0]
Is there any way to ask a QTMovie for video frames that are not color corrected? Should I be asking for a CGImageRef, CIImage, or CVPixelBufferRef instead? Is there a way to disable color correction altogether prior to reading in the video files?
I've attempted to work around this issue by drawing into a NSBitmapImageRep with the NSCalibratedColroSpace, but that only gets my part of the way there:
// Create a movie
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys :
nsFileName, QTMovieFileNameAttribute,
[NSNumber numberWithBool:NO], QTMovieOpenAsyncOKAttribute,
[NSNumber numberWithBool:NO], QTMovieLoopsAttribute,
[NSNumber numberWithBool:NO], QTMovieLoopsBackAndForthAttribute,
(id)nil];
_theMovie = [[QTMovie alloc] initWithAttributes:dict error:&error];
// ....
NSMutableDictionary *imageAttributes = [NSMutableDictionary dictionary];
[imageAttributes setObject:QTMovieFrameImageTypeNSImage forKey:QTMovieFrameImageType];
[imageAttributes setObject:[NSArray arrayWithObject:@"NSBitmapImageRep"] forKey: QTMovieFrameImageRepresentationsType];
[imageAttributes setObject:[NSNumber numberWithBool:YES] forKey:QTMovieFrameImageHighQuality];
NSError* err = nil;
NSImage* image = (NSImage*)[_theMovie frameImageAtTime:frameTime withAttributes:imageAttributes error:&err];
// copy NSImage into an NSBitmapImageRep (Objective-C)
NSBitmapImageRep* bitmap = [[image representations] objectAtIndex:0];
// Draw into a colorspace we know about
NSBitmapImageRep *bitmapWhoseFormatIKnow = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:getWidth()
pixelsHigh:getHeight()
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:0
bytesPerRow:(getWidth() * 4)
bitsPerPixel:32];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:bitmapWhoseFormatIKnow]];
[bitmap draw];
[NSGraphicsContext restoreGraphicsState];
This does convert back to a 'Non color corrected' colorspace, but the color values NOT are exactly the same as what is stored in the Uncompressed AVI files we are testing with. Also this is much less efficient because it is converting from RGB - "Device RGB" - RGB.
Also, I am working in a 64-bit application, so dropping down to the Quicktime-C API is not an option.
Thanks for your help.