I've got a few DOM elements, say text-field input A, B, C, and all of them have the property of 'onclick'. How do I find to which object a particular 'onclick' belongs?
I need to initialise a set of vals, where the code to initialise them might throw an exception. I'd love to write:
try {
val x = ... generate x value ...
val y = ... generate y value ...
} catch { ... exception handling ... }
... use x and y ...
But this (obviously) doesn't work because x and y aren't in scope outside of the try.
It's easy to solve the problem by using mutable variables:
var x: Whatever = _
var y: Whatever = _
try {
x = ... generate x value ...
y = ... generate y value ...
} catch { ... exception handling ... }
... use x and y ...
But that's not exactly very nice.
It's also easy to solve the problem by duplicating the exception handling:
val x = try { ... generate x value ... } catch { ... exception handling ... }
val y = try { ... generate y value ... } catch { ... exception handling ... }
... use x and y ...
But that involves duplicating the exception handling.
There must be a "nice" way, but it's eluding me.
In an iPhone app, when I compile for simulator everything is OK. However, when I compile for device, I get error on lines where I declare uint8 variables.
How is that possible?
This is the code I use to display images.
<t:dataList var="item" value="#{occasionBean.messageInfo}" layout="simple">
<h:commandLink action="#{occasionBean.selectedImage}" >
<h:graphicImage styleClass="thumbnail" width="100" height="100"
url="#{item.imageSnapUrl}"
onclick="return setMsgId(this.id,#{item.img_id},'#{item.imageUrl}');"
id="test" onmouseover="" onmouseout="">
</h:graphicImage>
</h:commandLink>
</t:dataList>
Please give some solution.
I feel like this should be fairly obvious, or easy, but I just can't get it. What I want to do is apply a function to a list (using map) but only if a condition is held. Imagine you only wanted to divide the numbers which were even:
map (`div` 2) (even) [1,2,3,4]
And that would give out [1,1,3,2] since only the even numbers would have the function applied to them. Obviously this doesn't work, but is there a way to make this work without having to write a seperate function that you can give to map? Filter is almost there, except I also want to keep the elements which the condition doesn't hold for, and just not apply the function to them.
Thanks
I'm using the following for $headers:
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "CC: [email protected]\r\n";
My html looks fine in Gmail, however, it appears as raw html in outlook.
Did I forget something in the header?
So I endeavor to spend most of time on the app server side of things but time to time I need to get my hands dirty and generate markup/css/js from a wireframe or mockup.
As far as tools go, Ive found browsershots and Litmus app helpful and of course, vm's as well for checking things out live in ie-{6,7,8}. Otherwise I do the heavy lifting in vim.
For generating new markup thats not tied to a target design I think some of the css frameworks & tools like sass look useful but Im skeptical of their utility when needing to generate markup to match a photoshop design.
So what tips / tools do you keep in your markup generating utility belt when building solid markup from designs?
My list so far:
Browsershots
Browserlab.adobe.com
Haml / Less / Sass (not used but will probably explore)
Any tips or best practices for unit testing Google Wave robots written in Java? I'm expecting to deploy on AppEngine, if that helps. I'm a fan of TDD but new to both Wave Robots and AppEngine, so I'm hoping to use TDD to help me explore the design space.
Apologies if this is a stupid question - I'm an Android and Ant newbie.
I have utf8 encoded source files that I need to compile with the Android Ant build system. By default, the encoding is set to ascii. I'd be very grateful for a pointer to whatever I need to do to let the build system know that my files are utf8.
Incidentally, it works fine if I build in Eclipse, but I need to build from the command line.
Thanks!
I have the following route:
routes.MapRoute(
"Search", // Route name
"Search/{affiliateId}", // URL with parameters
new { controller = "Syndication", action = "Search" } // Parameter defaults
);
Is there a way I can ensure "affiliateId" is a valid Guid? I'm using MVCContrib elsewhere in my site and I'm fairly it provides a way to implement this kind of constraint.... I just don't know what it is!
I want to be able to provide a URL to a music track, and when that track is played on an iPhone, to show the cover art.
I've tried embedding the cover art as an ID3 v2.3 tag, and while desktop players like VLC and Windows Media Player can see it, it seems the iPhone doesn't.
Is this possible? Does anyone know of a way to achieve this - preferably a method which can be automated?
Edit: this may not be possible - even if I add cover art with iTunes, the resulting file will still not have the coverart displayed when played as a download :(
We're about to embark on some ASP.NET MVC development and have been using our own entity framework for years. However we need to support more than our entity framework is capable of and so I'd like to get some opinions about using MVC with a more robust framework. We have narrowed down or choices to either NHibernate (with the Fluent APIs) or LINQ to SQL.
Which framework lends itself best to MVC style development (I know SO uses LINQ to SQL)?
If we want to support SQL Server, Oracle, MySQL - does that exclude LINQ to SQL?
I have a button on my main form which calls a method to serialize some objects to disk. I am trying to add these objects to an ArrayList and then serialize them using a BinaryFormatter and a FileStream.
public void SerializeGAToDisk(string GenAlgName)
{
// Let's make a list that includes all the objects we
// need to store a GA instance
ArrayList GAContents = new ArrayList();
GAContents.Add(GenAlgInstances[GenAlgName]); // Structure and info for a GA
GAContents.Add(RunningGAs[GenAlgName]); // There may be several running GA's
using (FileStream fStream = new FileStream(GenAlgName + ".ga",
FileMode.Create, FileAccess.Write, FileShare.None))
{
BinaryFormatter binFormat = new BinaryFormatter();
binFormat.Serialize(fStream, GAContents);
}
}
When running the above code I get the following exception:
System.Runtime.Serialization.SerializationException was unhandled
Message=Type 'WindowsFormsApplication1.Form1' in Assembly 'GeneticAlgApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
So that means that somewhere in the objects I'm trying to save there must be a reference to the main form. The only possible references I can see are 3 delegates which all point to methods in the main form code. Do delegates get serialized as well? I can't seem to apply the [NonSerialized] attribute to them.
Is there anything else I might be missing? Even better, is there a quick method to find the reference(s) that are causing the problem?
I have a html page with 10 columns but I don't have show all in same page instead I have to show only 4 column moreover I have to render those column on a button click call add column.
What is the best approach to render 1-4 column first ? Fist column render first and on clicking button say add will render 2nd column , than 3rd and fourth. Now when i will load 5th column ...I will have to hide 1st column so that i will accommodate 4 columns but data inside that column will stay ....my limit is to show 4 column at a time and hiding leftmost ....
any helpful javascript or jquery advice will be appreciated ..thanks!
Hi, is it possible to access the InfoMessage event handler in a Linq2SQL data context? All of our code uses these messages to display useful information to the end user and since moving to Linq2SQL I cannot figure out how to show these messages. I have checked the connection object of the data context as well as the classes properties with no luck so I'm wondering if it is possible.
Thanks in advance.
This is weird. I have a class that inherits from IEnumrable whose Count property is reporting 0 (zero) elements but the For Each loop steps into the loop body and tries to use the variable where it should just be moving on. My code:
On Error Resume Next
Dim d As Foo
For Each d In fooCollection
' use d and throws an exception
Next d
Weirder still, every time d is accessed i get an exception thrown in the output window:
A first chance exception of type
'System.NullReferenceException'
but i'm not stopping on the exception (not in a try/catch block).
Is "On Error Resume Next" causing this weirdness?
Weirdness found:
Per Rowland's and JohnH's comments i checked the Foo class:
The GetEnumerator method inside of Foo didn't actually return anything! It had an empty body. That coupled with the On Error Resume Next before the loop caused the havoc! Wow this was ugly. Thanks for the clues guys!
I'd like to parse an incoming URL into it's component parts for some pre-processing before passing it into the standard MVC routing logic. For example given your standard route
{controller}/{action}/{id}
and the URL
/user/show/10
Is there a way to have the Routing system return a dictionary containing controller, action and id keys with their corresponding values?
Problem:
I want to do this operation
select name from pragma table_info(my_awesome_table)
However, it yields a syntax error. I have the sneaking suspicion this is possible, but it doesn't seem to be documented as usable in the SELECT docs with sqlite.
Open a file in the Visual Studio binary editor that contains a null byte (0x00), then use the Quick Find feature (Ctrl +F) to find null bytes.
I would have thought I could use a regular expression such as \x00 to match null bytes but it doesn't work. Searching for any other hex value using this method works fine.
Is this a VS bug, 'feature', or am I just missing something? Is there a work around?
I'm looking for a way with no side effects.
Ideally, the following code would do the trick:
long currentCount = 0;
::ReleaseSemaphore(h, 0, ¤tCount);
But unfortunately 0 is not allowed as the value of lReleaseCount, so the call returns FALSE.
I have a project folder called XSL which contains xsl files used for transforming xml. I use the following code to fetch an xsl file:
string html = @"c:\temp\export.html";
XslCompiledTransform transform = new XslCompiledTransform();
Uri uri = new Uri(@"XSL\ToHtml.xsl", UriKind.Relative);
transform.Transform(CurrentXmlFile, html);
System.Diagnostics.Process.Start(html);
This works ok when debugging but when I deploy using clickonce and install it, I get an error - 'Could not find part of the path {my user path}\XSL\ToHtml.xsl'
What must I do to correctly reference this path?
When putting a favicon on your site, you can apparently use an animated gif, just by changing the gif file’s extension to .ico.
http://www.k-director.com/blog/how-to-add-an-animated-faviconico/
Have you encountered any problems doing this? Have you seen a browser get confused by a gif file with a .ico extension?
Hello all!
I´m developing a Book Trading System...
The user will input your Book to trading...
I already have a table tblBook with "all" existing books ...
So the user will select one book from that list and fill the book´s CONDITIONS and Edition...
So, what is a good Database design to tha case?
tblBook = All books
tblUserBook = All User Books
And making tblUserBook to inheritance tblBook?
Thanks
I am building a framework where people will be able to save items that the created by inheriting a class of mine. I will be iterating over every type in the appdomain to find classes that I want to map to nhibernate. Every class that I find will be a subclass of the inherited type.
I know how to create sub types in FluentNhibernate, but every sub type requires its own ClassMap class. Since I won't know these untill runtime, there is no way I can do that.
Is there a way that I can add mappings to fluent nhibernate?
Note, I know this is possible without fluent nhibernate using the Cfg class, but I don't want to manage the same code two different ways.