I know JavaScript regular expressions can ignore case for the entire match, but what about just the first character? Then tuesday would match Tuesday but not TUESDAY.
Every now and then (once every day or so) we're seeing the following types of errors in our logs for an ASP.NET 3.5 application
Invalid viewstate
Invalid postback or callback argument
Are these something that "just happens" from time-to-time with an ASP.NET application? Would anyone recommend we spend a lot of time trying to diagnose what's causing the issues?
Seaside is known as "the heretical web framework". One of the points that make it heretical is that it has much shared state. That however is something which, in my current understanding, hinders easy scaling.
Ruby on rails on the other hand shares as less state as possible. It has been known to scale pretty well, even if it is dog slow compared to modern smalltalk vms. flickr uses php and has scaled to an extremly big infrastructure...
So has anybody some experience in the scaling of Seaside?
My maven module A has a dependency on another maven module B provided by other people. When I run "mvn install" under A for the first time, maven downloads B-1.0.jar from a remote repository to my local maven repository. My module A builds fine.
In the mean time, other people are deploying newer B-1.0.jar to the remote repository. When I run "mvn install" under A again, maven does not download the newer B-1.0.jar from the remote repository to my local repository. As a result, my module A build fails due to API changes in B-1.0.jar.
I could manually delete B-1.0.jar from my local repository. Then maven would download the latest B-1.0.jar from the remote repository the next time when I run "mvn install".
My question is how I can automatically let maven download the latest artifacts from a remote repository. I tried to set updatePolicy to "always". But that did not do the trick.
I have a wxPython application with the various GUI classes in their own modules in a package called gui. With this setup, importing the main window would be done as follows:
from gui.mainwindow import MainWindow
This looked messy to me so I changed the __init__.py file for the gui package to import the class directly into the package namespace:
from mainwindow import MainWindow
This allows me to import the main window like this:
from gui import MainWindow
This looks better to me aesthetically and I think it also more closely represents what I'm doing (importing the MainWindow class from the gui "namespace"). The reason I made the gui package was to keep all the GUI stuff together. I could have just as easily made a single gui module and stuffed all the GUI classes in it, but I think that would have been unmanageable. The package now appears to work like a module, but allows me to separate the classes into their own modules (along with helper functions, etc.).
This whole thing strikes me as somewhat petty, I just thought I'd throw it out there to see what others think about the idea.
I'm using the JQuery validation plug to validate my entire form. I also have a dynamic table on my registration page where the user can register more people. I can validate the rest of the form fine but my goal is to validate the table inputs just the same. Here is my jfiddle code: tables
I don't know why the add line won't work there but it definitely works on my page. Anyway, that code ends up validate ONLY the first row of my table, but I want it to validate every single row. Can anyone see any problems with the code?
In an ASP.NET WebForms 2.0 site we are encountering an intermittent bug in IE6 whereby a file download attempt results in the contents of the being shown directly in the browser as text, rather than the file save dialog being displayed. Our application allows the user to download both PDF and CSV files.
The code we're using is:
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.AddHeader("Content-Disposition", "attachment;filename=\"theFilename.pdf\"");
response.ContentType = "application/pdf";
response.BinaryWrite(MethodThatReturnsFileContents());
response.End();
This is called from the code-behind click event handler of a button server control.
Where are we going wrong with this approach?
Edit
Following James' answer to this posting, the code I'm using now looks like this:
HttpResponse response = HttpContext.Current.Response;
response.ClearHeaders();
// Setting cache to NoCache was recommended, but doing so results in a security
// warning in IE6
//response.Cache.SetCacheability(HttpCacheability.NoCache);
response.AppendHeader("Content-Disposition", "attachment; filename=\"theFilename.pdf\"");
response.ContentType = "application/pdf";
response.BinaryWrite(MethodThatReturnsFileContents());
response.Flush();
response.End();
However, I don't believe that any of the changes made will fix the issue.
I'm working on some tools to enable high throughput data-oriented development, and one thing that I've not got an immediate answer for is how you go about allocating strings quickly. On risc processors you've got another problem of implementation that the CPU doesn't like branching, which is what I'm trying to minimise or avoid. Also, cache coherence is important on most CPUs, so that's gotta be influential in the design too.
So, how would you go about reducing the overhead for a generic string allocator?
Sometimes it's easier to solve a more explicit problem, so any ideas for string sizes of 5-30?
Hi,
I currently have an array, created from a database, an example of which looks like the following:
Array(
[0] => Array (
objectid => 2,
name => title,
value => apple
),
[1] => Array (
objectid => 2,
name => colour,
value => red
),
[2] => Array (
objectid => 3,
name => title,
value => pear
),
[3] => Array (
objectid => 3,
name => colour,
value => green
)
)
What I would like to do is group all the items in the array by their objectid, and convert the 'name' values into keys and 'value' values into values of an associative array....like below:
Array (
[0] => Array (
objectid => 2,
title => apple,
colour => red
),
[1] => Array (
objectid => 3,
title => pear,
colour => green
)
)
I've tried a few things but haven't really got anywhere.. Any ideas?
Thanks in advance
in JavaScript, the typical way to round a number to N decimal places is something like:
function round_number(num, dec) {
return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
}
However this approach will round to a maximum of N decimal places while I want to always round to N decimal places. For example "2.0" would be rounded to "2".
Any ideas?
Hi
Our company uses some third party vendors to write some of our external facing web sites, however with one vendor we keep experiencing over inflated charges for simple changes and it has been decided to bring the product in-house.
I have been tasked to provide a list of deliverables/checkpoints that would form a part of the agreement.
what is the minimum you would expect if you are purchasing the source code of a product that you have paid for the development of, should we expect code for any custom libraries they may be using that were written not for us etc..
This is all written in .net so i am well aware we could just get the code via reflector, however i dont think my boss would go for this ;-)
I'm attempting to add a method to a grails domain class, e.g.
class Item {
String name
String getReversedName() {
name.reverse()
}
}
When I attempt to load the application using grails console I get the following error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory':Invocation of init method failed; nested exception is org.hibernate.PropertyNotFoundException: Could not find a setter for property reversedName in class Item
... 18 more
It looks like Hibernate is interpreting getReversedName() as a getter for a property, however in this case it is a derived field and hence should not be persisted. Obviously in my actual code the business logic I'm exposing is more complex but it isn't relevant to this question. I want to be able to call item.reversedName in my code/gsps.
How can I provide property (getter) access to a method in a Grails domain class without Grails attempting to map it with Hibernate?
I want to check that two passwords are the same using Dojo.
Here is the HTML I have:
<form id="form" action="." dojoType="dijit.form.Form" /
<pPassword: <input type="password"
name="password1"
id="password1"
dojoType="dijit.form.ValidationTextBox"
required="true"
invalidMessage="Please type a password" /</p
<pConfirm: <input type="password"
name="password2"
id="password2"
dojoType="dijit.form.ValidationTextBox"
required="true"
invalidMessage="This password doesn't match your first password" /</p
<div dojoType="dijit.form.Button" onClick="onSave"Save</div
</form
Here is the JavaScript I have so far:
var onSave = function() {
if(dijit.byId('form').validate()) { alert('Good form'); }
else { alert('Bad form'); }
}
Thanks for your help. I could do this in pure JavaScript, but I'm trying to find the Dojo way of doing it.
Somewhat straightforward: will asp:Validators still perform validation when they're in invisible containers? How about if their ControlToValidate target is invisible?
For example:
<asp:Panel id="myPanel" runat="server" visible="false">
<asp:Textbox id="myTextbox" runat="server" />
<asp:RequiredFieldValidator id="myRfv" runat="server"
controltovalidate="myTextbox" />
</asp:Panel>
Above is a Validator in an invisible Panel. Would myRfv still perform validation? How about if myTextbox is invisible instead?
I'm asking this because I have very specialized Validators in my ASPX, wherein I also have Panels which are hidden/shown dynamically. While I'm all for disabling the validators themselves, I'm just curious whether they'll automatically disable anyway.
Thanks guys! :D
I'm using ASP.NET MVC with XmlResult from MVCContrib.
I have an array of Xxxx objects, which I pass into XmlResult.
This gets serialized as:
<ArrayOfXxxx>
<Xxxx />
<Xxxx />
<ArrayOfXxxx>
I would like this to look like:
<Xxxxs>
<Xxxx />
<Xxxx />
<Xxxxs>
Is there a way to specify how a class gets serialized when it is part of array?
I'm already using XmlType to change the display name, is there something similar that lets you set its group name when in an array.
[XmlType(TypeName="Xxxx")]
public class SomeClass
Or, will I need to add a wrapper class for this collection?
hi,
I'm using GNAT Programming Studio to update some ada files. I have a style check, which for these old files produces literally thousands of warnings. Helpfully GPS has a little auto fix 'wrench' icon in the locations view, that's great but I don't want to go through and click the wrench ten thousand times.
Is there a way to have it correct these errors automatically without me having to click each wrench? They are all right so I want to be changed automatically.
I saw some documentation saying you could do it:
http://www.adacore.com/wp-content/files/auto_update/gps-docs/Code-Fixing.html
But I don't get the auto fix option when I right click. Maybe you need the pro version? I've tried everything I can think of.
This would save hours of work, so it's really appreciated if someone could help on this.
Thanks!
Hi,
I am struggling with the correct design for the delegates of nsxmlparser.
In order to build my table of Foos, I need to make two types of webservice calls; one for the whole table and one for each row. It's essentially a master-query then detail-query, except the master-query-result-xml doesn't return enough information so i then need to query the detail for each row. I'm not dealing with enormous amounts of data.
Anyway - previously I've just used
NSXMLParser *parser = [[NSXMLParser alloc]init];
[parser setDelegate:self];
[parser parse];
and implemented all the appropriate delegate methods in whatever class i'm in.
In attempt at cleanliness, I've now created two separate delegate classes and done something like:
NSXMLParser *xp = [[NSXMLParser alloc]init];
MyMasterXMLParserDelegate *masterParserDelegate = [[MyMasterXMLParser]alloc]init];
[xp setDelegate:masterParserDelegate];
[xp parse];
In addition to being cleaner (in my opinion, at least), it also means each of the -parser:didStartElement implementations don't spend most of the time trying to figure out which xml they're parsing.
So now the real crux of the problem.
Before i split out the delegates, i had in the main class that was also implementing the delegate methods, a class-level NSMutableArray that I would just put my objects-created-from-xml in when -parser:didEndElement found the 'end' of each record.
Now the delegates are in separate classes, I can't figure out how to have the -parser:didEndElement in the 'detail' delegate class "return" the created object to the calling class. At least, not in a clean OO way. I'm sure i could do it with all sorts of nasty class methods.
Does the question make sense?
Thanks.
Can a PowerShell function determine if it is being run as part of a pipeline? I have a function which populates an array with instances of FileInfo which I would like to "yield" to the pipeline if the function is being run this way or produce some pretty output if the function is being invoked by itself from the command line.
function Do-Something {
$file_infos = @()
# Populate $file_infos with FileInfo instances...
if (INVOKED_IN_PIPELINE) {
return $file_infos
}
else {
foreach ($file_info in $file_infos) {
write-host -foregroundcolor yellow $file_info.fullname
}
}
}
Basically, I'm trying to figure out how to implement INVOKED_IN_PIPELINE. If it is run in a pipeline (e.g. Do-Something | format-table fullname), I would simply yield the array, but if run directly (e.g. Do-Something), it would simply pretty-print the output.
Is there a way to do this? If there is a more "idiomatic" way to achieve this kind of thing, I would also be interested to know.
I have found this function which uses libjpeg to write to a file:
int write_jpeg_file( char *filename )
{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
/* this is a pointer to one row of image data */
JSAMPROW row_pointer[1];
FILE *outfile = fopen( filename, "wb" );
if ( !outfile )
{
printf("Error opening output jpeg file %s\n!", filename );
return -1;
}
cinfo.err = jpeg_std_error( &jerr );
jpeg_create_compress(&cinfo);
jpeg_stdio_dest(&cinfo, outfile);
/* Setting the parameters of the output file here */
cinfo.image_width = width;
cinfo.image_height = height;
cinfo.input_components = bytes_per_pixel;
cinfo.in_color_space = color_space;
/* default compression parameters, we shouldn't be worried about these */
jpeg_set_defaults( &cinfo );
/* Now do the compression .. */
jpeg_start_compress( &cinfo, TRUE );
/* like reading a file, this time write one row at a time */
while( cinfo.next_scanline < cinfo.image_height )
{
row_pointer[0] = &raw_image[ cinfo.next_scanline * cinfo.image_width * cinfo.input_components];
jpeg_write_scanlines( &cinfo, row_pointer, 1 );
}
/* similar to read file, clean up after we're done compressing */
jpeg_finish_compress( &cinfo );
jpeg_destroy_compress( &cinfo );
fclose( outfile );
/* success code is 1! */
return 1;
}
I would actually need to write the jpeg compressed image just to memory buffer, without saving it to a file, to save time. Could somebody give me an example how to do it?
I have been searching the web for a while but the documentation is very rare if any and examples are also difficult to come by.
Hi,
This is a quick question. I have the following ruby code, which works fine.
def add_zeros number, zeros
number = number.to_s
zeros_to_add = zeros - number.length
zeros_to_add.times do
number = "0#{number}"
end
number
end
But if I replace
number = "0#{number}"
With
number.insert(0, "0")
Then I get TypeError: can't modify frozen string, does anyone know why this is?
Hi,
I am calling google maps within a for loop in my javascript as I have mulitple routes that need to be costed separately based on distances.
Everything works great except that the distance is only returned for one of the routes.
I have a feeling that it is something to do with the way I have the items declared within the ajax call for the maps. Any ideas what could be the issue from the code below?
for (var i = 1; i <= numJourneys; i++) {
var mapContainer = 'directionsMap' + i;
var directionContainer = $('#getDistance' + i);
$.ajax({
async: false,
type: "POST",
url: "Journey/LoadWayPoints",
data: "{'args': '" + i + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d != '[]') {
var map = new GMap2(document.getElementById(mapContainer));
var distance = directionContainer;
var wp = new Array();
//routes
var counter = 0;
$.each(content, function () {
wp[counter] = new GLatLng(this['Lat'], this['Long']);
counter = counter + 1;
});
map.clearOverlays();
map.setCenter(wp[0], 14);
// load directions
directions = new GDirections(map);
GEvent.addListener(directions, "load", function () {
alert(directions.getDistance());
//directionContainer.html(directions.getDistance().html);
});
directions.loadFromWaypoints(wp, { getSteps: true });
}
}
});
}
When I write the following code I get garbage for an output. It is just a simple program to find prime numbers. It works when the first for loops range only goes up to 1000 but once the range becomes large the program fail's to output meaningful data
output = open("output.dat", 'w')
for i in range(2, 10000):
prime = 1
for j in range(2, i-1):
if i%j == 0:
prime = 0
j = i-1
if prime == 1:
output.write(str(i) + " " )
output.close()
print "writing finished"
I'm adding a control (linkbutton) dynamically using ParseControl and it's fine except when I specify an event handler.
If I use:
Dim c As Control = ParseControl("<asp:LinkButton id=""btnHide"" runat=""server"" text=""Hide"" OnClick="btnHide_Click" />")
it correctly adds the control to the page but the click event doesn't fire. If instead I find the control in the controls collection and manually wire up the event it works fine. I've tried loading in both Page_Init and Page_Load and it's the same thing either way.
Any ideas?
ok I know that this should be simple... anyways say:
line = "$W5M5A,100527,142500,730301c44892fd1c,2,686.5 4,333.96,0,0,28.6,123,75,-0.4,1.4*49"
I want to strip out the spaces. I thought you would just do this
line = line.strip()
but now line is still '$W5M5A,100527,142500,730301c44892fd1c,2,686.5 4,333.96,0,0,28.6,123,75,-0.4,1.4*49' instead of '$W5M5A,100527,142500,730301c44892fd1c,2,686.54,333.96,0,0,28.6,123,75,-0.4,1.4*49'
any thoughts?