Is there a way to call a method inside the controller from our view using codeigniter.I know it is a bad practice but, now I force to do this.Thank you
By best I mean most efficient.
So don't go on about subjectiveness.
I have a list of websites and I want to store the list on the iphone locally, there must be an URL, title and a small image (like 32x32 max image size). I don't think I should be using CoreData for this. Should I be using a plist?
Lets say I have a simple Enum called Animal defined as:
public enum Animal {
CAT, DOG
}
and I have a method like:
private static Object valueOf(String value, Class<?> classType) {
if (classType == String.class) {
return value;
}
if (classType == Integer.class) {
return Integer.parseInt(value);
}
if (classType == Long.class) {
return Long.parseLong(value);
}
if (classType == Boolean.class) {
return Boolean.parseBoolean(value);
}
// Enum resolution here
}
What can I put inside this method to return an instance of my enum where the value is of the classType?
I have looked at trying:
if (classType == Enum.class) {
return Enum.valueOf((Class<Enum>)classType, value);
}
But that doesn't work.
Google webfonts look horrible on windows.
What is going on? Is this a temporary problem that will be fixed, or is this just a windows problem that will forever persist? If the latter, doesn't that mean the entire project is sort of useless?
Thanks in advance.
I am having a gridview with an object datasource binded in the markup(aspx page).
When page loads it directly works fine with all sorting and paging properties.
However, i need to filter display on gridview so i have to change the datasource of the gridview on the code behind.
It works fine.. i mean the filtering and displaying is good but paging and sorting doesnt work. Did you have a problem something like this?
I have a base class MessageHandler and 2 derived classes, MessageHandler_CB and MessageHandler_DQ.
The derived classes redefine the handleMessage(...) method. MH_DQ processes a message and puts the result in a deque while MH_CB processes the message and then executes a callback function.
The base class has a static callback function that I pass along with a this pointer to a library which calls the static callback when a new message is available for processing.
My problem comes when I am in the static callback with a void * pointing to either a MH_DQ or a MH_CB. If I cast it to the base class the empty MessageHandler::handleMessage(...) method is called, rather than the version in the appropriate derived class.
What is the best way to address this situation from a design perspective and/or what language features might help me to implement a solution to my problem?
Thanks in advance!
I'm quite new to Scala and struggling with the following:
I have database objects (type of BaseDoc) and value objects (type of BaseVO). Now there are multiple convert methods (all called 'convert') that take an instance of an object and convert it to the other type accordingly - like this:
def convert(doc: ClickDoc): ClickVO = ...
def convert(doc: PointDoc): PointVO = ...
def convert(doc: WindowDoc): WindowVO = ...
Now I sometimes need to convert a list of objects. How would I do this - I tried:
def convert[D <: BaseDoc, V <: BaseVO](docs: List[D]):List[V] = docs match {
case List() => List()
case xs => xs.map(doc => convert(doc))
}
Which results in 'overloaded method value convert with alternatives ...'. I tried to add manifest information to it, but couldn't make it work.
I couldn't even create one method for each because it'd say that they have the same parameter type after type erasure (List).
Ideas welcome!
I just started using mysql and I just can see myself woking with strings!
I mean the compiler cant catch errors like this... and its just a mess!
is there a wrapper or some kind of class i can add that does something as simple as making a function that adds a table and asks for args?
I'm sure there is a tool like that but i cant find it or know its name.
plz help.
Hello Guys,
I want to implement registration module in my android application.
Can anyone please let me know the procedure.
I mean, how can I use HttpRequestHandlerRegistry, SQLite connectivity etc
Thanks in advance.
Regards,
serenity.
I have a Web Application and I want to get a confirmation from users when they are closing the application no matter what.
I mean I'm looking for a way to display a message touser whenever user try to close the application.
In my java project, almost every non-static method I've written is synchronized. I've decided to fix up some code today, by removing most of the synchronized keywords. Right there I created several threading issues that took quite a while to fix, with no increase in performance. In the end I reverted everything.
I don't see anyone else writing code with "synchronized" everywhere. So is there any reason I shouldn't have "synchronized" everywhere?
What if I don't care too much about performance (ie. the method isn't called more than once every few seconds)?
I need a way to see all the defined variables of the current PHP instance.
By currently defined I mean all the globals, all the local to THIS scope and all the locals to other scopes.
Is there something built in?
How do I remove the numbers on the x-axis only not the y-axis?
Is it possible to shift the y-axis without shifting the functions? What I mean is, instead of having the y-axis at x = 0, could I have it at x = -5?
When you need to obsolete a section of code (say either the business rules changed, or the old system has been reworked to use a new framework or something) do you delete it from the file or do you comment it out and then put in the new functionality? If you comment it out, do you leave a note stating why it was removed and what it was originally intended to do?
I ask mainly because I've done a lot of contract work for different places over the years and sometimes it's like excavating a tomb to find the actual code that is still being used. Why comment it out and leave it in the file if source control has a record of what used to be there? If you comment out a method do you also comment out/delete any methods that were exclusively used by that method?
What do you think the best practices for this should be?
Hi,
I think I get what unchecked cast means (casting from one to another of a different type), but what does it mean to "Check" the cast? How can I check the cast so that I can avoid this warning in Eclipse?
Thanks,
I am using express.js. I have a need to be able to log certain request data whenever someone tries to log a message. For this I would like to create a helper method like so
function log_message(level, message){
winston.log(level, req.path + "" + message);
}
I would then use the method like so.
exports.index = function(req, res){
log_message("info", "I'm here");
}
Note that I am not passing the req object to the log_message function. I want that to be transparently done so that the log_message API user does not need to be aware of the common data that is being logged.
Is there a way to achieve this with express.js/node.js. Is the request object available from a global variable of some sort?
What does that mean ?
public bool? Verbose { get; set; }
When applied to string? , there is an error
Error 11 The type 'string' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'System.Nullable'
I've been reading all over the place (including here) about when exception should / shouldn't be used.
I now want to change my code that would throw to make the method return false and handle it like that, but my question is: Is it the throwing or try..catch-ing that can hinder performance...?
What I mean is, would this be acceptable:
bool method someMmethod()
{
try
{
// ...Do something
catch (Exception ex) // Don't care too much what at the moment...
{
// Output error
// Return false
}
return true // No errors
Or would there be a better way to do it?
(I'm bloody sick of seeing "Unhandled exception..." LOL!)
I'm having trouble figuring out the scope method for all the Foos that have no Bars. That is:
class Foo < ActiveRecord::Base
has_may :bars
end
class Bar < ActiveRecord::Base
belongs_to :foo
end
I'd like to write a scope method that returns me all the foos that have no bars. Something like:
class Foo < ActiveRecord::Base
has_may :bars
scope :has_no_bars, includes(:bars).where("COUNT(foo.bars) = 0")
end
But I don't understand the appropriate syntax. Any help? Happy to use a MetaWhere solution if easier.
My question is simple (I think it is silly too) ,how can I start the index in an ArrayList from 1 instead of 0 ? is this possible directly (I mean is there a code for this ) ?.
Actually a friend asked me this question today, first I thought that it is a silly question but after a while I thought if there is a direct way to do that and decided to ask it to you (maybe you have some brilliant ideas :) )
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.
All are from this post.
What does these statement mean:
error(nargchk(5, 6, nargin));
plot(p(:,1), p(:,2), '.-'), axis equal
And what's this kinda syntax which I haven't quite often seen:
if nargin<6, steps = 36; end