//API
class Node
class Person extends Node
object Finder
{
def find[T <: Node](name: String): T = doFind(name).asInstanceOf[T]
}
//Call site (correct)
val person = find[Person]("joe")
//Call site (dies with a ClassCast inside b/c inferred type is Nothing)
val person = find("joe")
In the code above the client site "forgot" to specify the type parameter, as the API writer I want that to mean "just return Node". Is there any way to define a generic method (not a class) to achieve this (or equivalent). Note: using a manifest inside the implementation to do the cast if (manifest != scala.reflect.Manifest.Nothing) won't compile ... I have a nagging feeling that some Scala Wizard knows how to use Predef.<:< for this :-)
Ideas ?
Usually I would have a table field called ID on auto increment. That way I could order using this field etc.
However I have no control over the structure of a table, and wondered how to get the results in reverse order to default.
I'm currently using
$q = mysql_query("SELECT * FROM ServerChat LIMIT 15");
However like I said there is no field I can order on, so is there a way to tell mysql to reverse the order it gets the results? I.e last row to first row instead of the default.
in R , when i use "print", i can see all the values, but how can i save this as a vector
for example, in for loop,
for (i in 1:10), i want the value of A , when i= 1,2,3,4..... but if i use the x=A, it only have the final value of A which is the value when i = 10. so , how can i save the vaule in print(A)
I am writing an abstract matrix class (and some concrete subclasses) for use on very differing hardwares/architectures, etc. and I want to write a row and column type that provides a transparent reference to the rows and columns of the matrix.
However, I want to tune for performance, so I'd like this class to be essentially a compiler construct. In other words, I'm willing to sacrifice some dev time to making the overhead of these classes as small as possible.
I assume all (small) methods would want to be virtual? Keep the structure small? Any other suggestions?
Is there a simple :) and efficient way or reading very large number of rows sequentially using Zend_Db?
Basically I need to process entire table, row by row. Table is large, primary key sequence is not guaranteed(i.e. not an autoincrement, but is UNSIGNED INT).
What's the best way to approach this?
Environment: PHP 5.2, Zend Framework 1.10, MySQL 5.1
Are unused CSS images downloaded by the browser or ignored?
Eg. in CSS rules which don't match any elements.
.nothingHasThisClass{background:url(hugefile.png);}
Or would this be browser-dependant?
I get this message at runtime of ASP.NET 2 page :
The page 'MyFolder/blabla.aspx' cannot use the user control 'MyFolder/MyControl.ascx', because it is registered in web.config and lives in the same directory as the page.
Of course I can separate them to 2 different folders and thus solve the problem, but the question is :
WTF !?!?! Why I can't put them in the same folder ?!
Why can't they all .. get along !?! :)
Thanks
I know there are many settings for a language for a table and a database.
I already created the database. I believe when I created it, it was default/LATIN. I want to change everything-I mean...both the table and the database, to UTF-8.
How can I do that? thanks.
i had string like this in javascript
var str = "This is my test string is Ingrédients";
the substring "Ingrédients" can be also as "Ingredients"
how to get the index of substring "Ingrédients" from the above string
by applying regular expression ( Ingr[ée]dients )
I have a very big table with a lot of rows, every row has stats for every user for certain days. And obviously I don't have any stats for future. So to update the stats I use
UPDATE Stats SET Visits=@val WHERE ... a lot of conditions ... AND Date=@Today
But what if the row doesn't exist? I'd have to use
INSERT INTO Stats (...) VALUES (Visits=@val, ..., Date=@Today)
How can I check if the row exists or not? Is there any way different from doing the COUNT(*)?
If I fill the table with empty cells, it'd take hundreds of thousands of rows taking megabytes and storing no data.
I have a C# security/monitoring application that I need to have running no matter what. However, I can not remove privileges or restrict access to parts of the OS (Windows).
I thought of having a protection service running which monitors continuously if an application is running, and starts it back up when the application is killed somehow, while the application monitors the protection service and starts the service if the service is killed. To my knowledge you can't simultaneously kill multiple processes at the same time.
Any better idea to guarantee that an application is always running?
Suppose I have this:
<select id="myselect">
<option rel="a">1</option>
<option rel="b">2</option>
<select>
How do I use JQuery so that onchange $("#myselect"), I alert the "rel" part of the option (not 1 or 2)
This is probably a really simple question, but how do I go about getting the right offset of an element in jQuery?
I can do:
$("#whatever").offset().left;
and it is valid.
But it seems that:
$("#whatever").offset().right
is undefined.
So how does one accomplish this in jQuery?
Thanks!!
Hi,
I have a problem with JQuery Context Menu ( link text ) and iframe.
If i use it inside, the context menu is naturaly shown inside. But it will be partialy shown.
I am searching how to resolve it.
Please note that the context menu only appear when i click on specific iframe's elements.
thanks :)
My Zend application is going to get an command line php script that should email reports. There generation depends on Zend_View, Zend_Layout and is currently already working fine in the web interface.
How can I reuse this whole MVC functionality in the command line?
Should I add a new controller CommandLineController and call this somehow from the commandline?
How can I kick of such a Controller manually, without having a HTTP request?
I like using LINQ to SQL. The only problem is that I don't like the default way of updating tables.
Let's say I have the following table with the following columns:
ID (primary key), value1, value2, value3, value4, value5
When I need to update something I call
UPDATE ... WHERE ID=@id
LINQ to SQL call
UPDATE ... WHERE ID=@id and value1=@value1 and value2=@value2 and value3=@value3 and value4=@value4 and value5=@value5
I can override this behavior by adding
UpdateCheck=UpdateCheck.Never
to every column, but with every update of the DataContext class with the GUI, this will be erased. Is there any way to tell LINQ to use this way of updating data?
Hi. I've been looking at the various JavaScript UI libraries and am wondering if there's one that can add some styling to page elements. I'm currently adding rounded corners, shadows, borders, and gradients via my own CSS + hacks to get it working on IE.
I'm using jQuery for a number of tasks and wondered if there's a plugin that can add these design flairs more easily to DIVs. Not that you want to go overboard with this stuff, but when you need to use it, you'd like to depend on cross-browser and tried-and-tested solutions. Thanks.
First up, I should let you know that I am learning C, so my apologies if this question seems stupid to a more advanced developer.
I know you can print with printf() and puts(). I can also see that printf() allows you to embed variables inside and do some stuff like formatting.
Is puts() merely a primitive version of printf(). Should it be used for every possible printf() without string interpolation?
Thanks
I have the following dilemma: I have a list of strings, and I want to find the set of string which start with a certain prefix. The list is sorted, so the naive solution is this:
Perform binary search on the prefixes of the set, and when you find an element that starts with the prefix, traverse up linearly until you hit the top of the subset.
This runs in linear time, however, and I was wondering if anyone can suggest a more efficient way to do it.
I'd like everything to function correctly, except when it's mobile, the entire site will used a set of specific templates.
Also, I'd like to autodetect if it's mobile. If so, then use that set of templates throughout the entire site.
How would i get the current URL with Python,
I need to grab the current URL so i can check it for query strings e.g
requested_url = "URL_HERE"
url = urlparse(requested_url)
if url[4]:
params = dict([part.split('=') for part in url[4].split('&')])
also this is running in Google App Engine
I am interested in the following features: Code highlighting, Intellisense, Refactorings, Code navigation (Go to Definition etc.).
If this functionality is missing from Visual Studio 2010 maybe Microsoft is planning to add these features in the future or there are community project to develop IronRuby tooling add-in?
| random_code | varchar(200) | YES | UNI | NULL | |
MyTable.objects.filter(random_code = None)
Is this correct? Will this SELECT where there is no random code set? Above is my table.