I want to cancel out key press event when my textarea field gets n number of characters from user. At that point i dont want user to enter any more characters. What to do?
I have a JQuery dialog box on a page that calls something like this:
$.post("/MyController/MyAction", { myKey: key} //...
And this successfully gets here:
[HttpPost]
public ActionResult MyAction(int myKey)
{
//do some stuff
return RedirectToAction("AnotherAction");
}
The problem is that the RedirectToAction has no effect on the webbrowser. I am guessing this is because the JQuery post is kinda on a different 'tread' so it doesn't know where to send the response? How do I get the browser to load the new response?
Imagine I create and execute an NSThread object using detachNewThreadSelector:toTarget:withObject:. The method executed by the thread might look like this:
- (void)search {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// perform a lengthy search here.
[pool release];
}
I then might use the cancel method to kill the thread while it's running, before the pool gets released. What happens to the NSAutoreleasePool object? I suppose it will leak, won't it?
Looking for quick, simple way in Java to change this string
" hello there "
to something that looks like this
"hello there"
where I replace all those multiple spaces with a single space, except I also want the one or more spaces at the beginning of string to be gone.
Something like this gets me partly there
String mytext = " hello there ";
mytext = mytext.replaceAll("( )+", " ");
but not quite.
Hi there,
Recently I installed in Visual Studio 2010 the Power Tools Extension It's working great, however I have problems with my text coloring theme (Nightfall), and the extension's Colorized Parameter feature.
Since the theme text fore color is grey, when the Power Tools Extensions shows the Parameter Help tooltip using my text colors, it gets unreadable:
Is there a way to change Parameter Help background color?
Hi
I have used AJAXToolkit AutoComplete extender in my project.It works fines.But the issue is with the form of the page.
when i type in the AutoComplete, i get list of suggestions.When i click on the page other than the Autocomplete, the form gets submitted.
any suggestions how to stop submission of entire form whenever i click on the page?I use .net 2.0
I use TortoiseSVN and frequently switch between a branch and the trunk, using the switch command.
I noticed that if I don't commit before the switch, local modified copy gets merged. Is there a way to customize the tool to, say, warn me to commit local changes before switch?
I am making a button invisible once it gets clicked. Is there any nice animation (programmably from code behind) code that fade the button away instead of sudden disappearance?
Hello I have a Flex datagrid linked to an array collection that gets filled from a FileReferenceList for uploading images to a server. I want to show a thumbnail of the image in one of the grid columns as a preview. I have seen a lot of examples of doing this with an Item Render but those examples where using images on the server. These images are on the client pc waiting to be uploaded?
I'm using Flash Builder 4.6. As a simple example, say I have the following application:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:sdk="services.sdk.*">
<fx:Script>
<![CDATA[
private function btnGetValue_clickHandler():void
{
getValueResult.token = sdk.getValue();
}
private function getValueResultHandler():void
{
// ...
}
]]>
</fx:Script>
<fx:Declarations>
<sdk:SDK id="sdk" fault="{Alert.show(event.fault.faultString +'\n\n'+ event.fault.faultDetail, 'SDK ERROR');}" showBusyCursor="false"/>
<s:CallResponder id="getValueResult" result="getValueResultHandler()"/>
</fx:Declarations>
<s:Button id="btnGetValue" click="btnGetValue_clickHandler()" label="Get Value" />
</s:Application>
So when you click on the button, it calls a PHP file and when it gets a result, it calls getValueResultHandler(). Easy enough.
But what if the response from the PHP file takes a second or two and the user clicks the button rapidly? Then the result handler function may not get called every time, since the call responder gets a new token before it received the last response.
Is there a standard way of resolving this issue? I came up with the following workaround, and it works fine, but it seems like this issue would be common enough to have a more built-in solution.
My workaround is:
var getValueResultProcessing:Boolean = false;
private function btnGetValue_clickHandler():void
{
var interval:uint = setInterval(function():void
{
if (!getValueResultProcessing)
{
getValueResultProcessing = true;
getValueResult.token = sdk.getValue();
clearInterval(interval);
}
}, 100);
getValueResult.token = sdk.getValue();
}
private function getValueResultHandler():void
{
getValueResultProcessing = false;
// ...
}
Any better way of resolving this issue?
When I have to write methods which return two values, I usually go about it as in the following code which returns a List<string>. Or if I have to return e.g. a id and string, then I return a List<object> and then pick them out with index number and recast the values.
This recasting and referencing by index seems inelegant so I want to develop a new habit for methods that return two values. What is the best pattern for this?
using System;
using System.Collections.Generic;
using System.Linq;
namespace MultipleReturns
{
class Program
{
static void Main(string[] args)
{
string extension = "txt";
{
List<string> entries = GetIdCodeAndFileName("first.txt", extension);
Console.WriteLine("{0}, {1}", entries[0], entries[1]);
}
{
List<string> entries = GetIdCodeAndFileName("first", extension);
Console.WriteLine("{0}, {1}", entries[0], entries[1]);
}
Console.ReadLine();
}
/// <summary>
/// gets "first.txt", "txt" and returns "first", "first.txt"
/// gets "first", "txt" and returns "first", "first.txt"
/// it is assumed that extensions will always match
/// </summary>
/// <param name="line"></param>
public static List<string> GetIdCodeAndFileName(string line, string extension)
{
if (line.Contains("."))
{
List<string> parts = line.BreakIntoParts(".");
List<string> returnItems = new List<string>();
returnItems.Add(parts[0]);
returnItems.Add(line);
return returnItems;
}
else
{
List<string> returnItems = new List<string>();
returnItems.Add(line);
returnItems.Add(line + "." + extension);
return returnItems;
}
}
}
public static class StringHelpers
{
public static List<string> BreakIntoParts(this string line, string separator)
{
if (String.IsNullOrEmpty(line))
return null;
else
{
return line.Split(new string[] { separator }, StringSplitOptions.None).Select(p => p.Trim()).ToList();
}
}
}
}
I have a floating div that gets displayed, and I want it to be hidden when the user clicks off the div. This would be similar to the .hover() funtion callback when hovering off an element. Only I want to do this for click.
I tried just setting a click event for the body, which would hide the div, but that gave unexpected results.
Anyone have ideas on how I could easily do this?
what are the best books to learn about junit, jmock and testing generally? Currently I'm reading pragmatic unit testing in Java, I'm on chapter 6 its good but it gets complicated.. is there a book for a bottom up? from your expirience which helped you get the testing concept
Hello Folks,
I am trying to develop a application where
The user 'X' has logged into Facebook
app has a set of email addresses (possible friends of user 'X')
app gets the list of friends of user 'X' (uids)
Want to check if user with email address [email protected] is a valid facebook user by using email address and is user X's friend (basically a uid to email mapping)
Thanks!
I have a web application running on LAMP with a testing server and a production server. Is there a standard practice for keeping the data on the testing server in sync with the production server? The data on the testing server gets out of date pretty quick and I feel like there must be an easier way than just dumping the production server and copying it onto the testing server every so often. It's not important that the data is in total sync, just that the testing server represents the production enviornment as accurately as possible.
I have a grid with an image in it. Initially, the image is larger than the grid, so it gets cropped which is fine, but if I apply a scaling transform to causing the image to shrink, the portion that was initally cropped remains cropped, but I want it displayed now, because it would fit in the grid.
I concidered putting my image in a canvas, but I want it centered vertically and horizontally, which is giving me trouble, so I switched to a grid.
I am trying to use a formula to get a letter of the alphabet.
Formula:
=Keytable(RANDOM,ROW())
Function:
Function KeyTable(seed As Long, position As Long) As String
Dim i As Long
Stop
Dim calpha(1 To 26) As String
Dim alpha(1 To 26) As String
For i = 1 To 26
alpha(i) = Chr(i + UPPER_CASE - 1)
Next i
For i = 1 To 26
calpha(i) = alpha(seed Mod 27 - i)
Next i
Stop
KeyTable = calpha(position)
End Function
Result:
#Value!
When I step through the function, it never gets to the second stop.
I try to make a UIImageView open like a hatch, and under the "hatchView" its anoter imageView
but when I start the animation its like the view under gets over and cover the animation,
When the animation gets over the imageView the its getting visibel.
its works fine if a remove the imageView thats under.
Here is the code for animation view.
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *) event {
if (!isHatchOpen) {
if (hatchView.layer.anchorPoint.x != 0.0f) {
hatchView.layer.anchorPoint = CGPointMake(0.0f, 0.5f);
hatchView.center = CGPointMake(hatchView.center.x - hatchView.bounds.size.width/2.0f, hatchView.center.y);
}
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:hatchView];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationBeginsFromCurrentState:YES];
float pct = location.x / 320.0f;
float rad = acosf(pct);
CATransform3D transform = CATransform3DMakeRotation(-rad+5, 0.0f, -1.0f, 0.0f);
transform.m14 = (1.0 / -2000) * acosf(pct);
hatchView.layer.transform = transform;
[UIView commitAnimations];
isHatchOpen = YES;
} else {
if (hatchView.layer.anchorPoint.x != 0.0f) {
hatchView.layer.anchorPoint = CGPointMake(0.0f, 0.5f);
hatchView.center = CGPointMake(hatchView.center.x - hatchView.bounds.size.width/2.0f, hatchView.center.y);
}
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationBeginsFromCurrentState:YES];
CATransform3D transform = CATransform3DMakeRotation(0, 0.0f, -1.0f, 0.0f);
transform.m14 = 0;
hatchView.layer.transform = transform;
// Commit the changes
[UIView commitAnimations];
isHatchOpen = NO;
}
}
And here a add the Views
hatchView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 1, frame.size.width-1, frame.size.height-2)];
[self addSubview:hatchView];
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(1, 1, frame.size.width-2, frame.size.height-2)];
imageView.contentMode = UIViewContentModeScaleAspectFit;
[self insertSubview:imageView belowSubview:hatchView];
In Display tag, on giving a property in the display:column tag, that property gets printed as a column. What should I do if we want to fix the table header as it's dont scroll with the column?
Good afternoon
is there anyone who noticed that Find and Replace window each time is getting wider when coding and compiling?
Even when I resize this window in Visual Studio 2010, it gets wider again... :-(
Perhaphs is there a way to fix its size?
I don't want to use flash. I've found multiple jquery libraries that do this. Right now I'm using this one: http://demo.webdeveloperplus.com/ajax-file-upload/
The problem is they all use PHP. I tried just pointing it at my servlet instead of the PHP file, but it never gets called.
I have an unknown number of functions in my python script (well, it is known, but not constant) that start with site_...
I was wondering if there's a way to go through all of these functions in some main function that calls for them.
something like:
foreach function_that_has_site_ as coolfunc
if coolfunc(blabla,yada) == true:
return coolfunc(blabla,yada)
so it would go through them all until it gets something that's true.
thanks!
Would it be wise to use ROWLOCK on an insert statement that is copying large amounts of data and inserting it into the same table?
Ex)
INSERT INTO TABLE with (rowlock) (id, name)
SELECT newid, name
FROM TABLE with (nolock)
WHERE id = 1
Does anybody have recommendations on how to improve this statement, as I see when SQL Server gets busy it will end in Timeout Query returned for SQL Server.