How do I write Perl objects with extensible code? Im thinking drivers, or some configuation, where the user can pass in a string "Classname::Class" or something. Thanks.
I get a JSON response as
{
"edges": [],
"nodes": []
}
how to check if the objects has null values and handle the case??
JSONObject jobj = new JSONObject(line);
JSONArray jArray = jobj.getJSONArray("edges");
if(jArray.length()!=0)
{
for(int i=0;i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
x.add((float) json_data.getInt("x"));
y.add((float) json_data.getInt("y"));
end
This retrurns me : org.json.JSONException: end of input at character 0 of
Say I have one class ClassBig with 100 methods inside, and a second with only 10 methods ClassSmall
When I have objects at runtime
ClassBig big = new ClassBig();
ClassSmall small = new ClassSmall();
Does the larger class take up more memory space?
If both classes contained an identical method, does the larger class take longer to execute it?
Isn't
A a = new A(); // A is a class name
supposed to work in C++?
I am getting:
conversion from 'A*' to non-scalar
type 'A' requested
Whats wrong with that line of code?
In a spring mvc + spring core app, we have have a view layers, a facade, a service layer, a dao layer and a stored-proc based persistance layer.
The service layer is unaware of the clients that utilitize its methods. Is it fine to propagate raw http requests into the service layer? Or is it bad practice and a violation of the loose coupling principles?
If it is, then what's a clean workaround?
See following class:
function availItem(xs, s, m, l, xl) {
this.xs = xs;
this.s = s;
this.m = m;
this.l = l;
this.xl = xl;
}
How can I declare the above class using JSON? I think It should be in following manner but problem is to pass argument.
var availItem = {
xs : xs,
s : s,
m : m,
l : l,
xl : xl
}
I want to use both in same manner like
var obj =new availItem(xs,s,b,l,xl);
i am making a simple javascript login form for wordpress. i have the form submitting to the following bit of php to handle the login:
<?php
get_header();
global $user_ID;
if (!$user_ID) {
if($_POST){
//We shall SQL escape all inputs
$username = $wpdb->escape($_REQUEST['username']);
$password = $wpdb->escape($_REQUEST['password']);
$remember = $wpdb->escape($_REQUEST['rememberme']);
if($remember) $remember = "true";
else $remember = "false";
$login_data = array();
$login_data['user_login'] = $username;
$login_data['user_password'] = $password;
$login_data['remember'] = $remember;
$user_verify = wp_signon( $login_data, false );
//wp_signon is a wordpress function which authenticates a user. It accepts user info parameters as an array.
if ( is_wp_error($user_verify) )
{
echo "<span class='error'>Invalid username or password. Please try again!</span>";
exit();
} else
{
echo "<script type='text/javascript'>window.location='". get_bloginfo('url') ."'</script>";
exit();
}
} else {
//get_header();
?>
any ideas on why i am getting the error?
Cheers, Dan
I have this:
<div id="taglist">
<input type="checkbox" name="chkB1" id="chkB1" value="Mon" /> Monday
<input type="checkbox" name="chkB2" id="chkB2" value="Tue" /> Tuesday
<input type="checkbox" name="chkB3" id="chkB3" value="Wed" /> Wednesday
<input type="checkbox" name="chkB4" id="chkB4" value="Thu" /> Thursday <br />
<input type="checkbox" name="chkB5" id="chkB5" value="Fri" /> Friday
<input type="checkbox" name="chkB6" id="chkB6" value="Sat" /> Saturday
<input type="checkbox" name="chkB7" id="chkB7" value="Sun" /> Sunday
<input type="hidden" name="source_frequency" id="source_frequency" value="" />
</div>
And this:
var days = ["Mon","Tue","Wed","Sun"];
I want the values from days make the corresponding check boxes checked. How would one do such a thing :-)
Hello,
$.Comment = function() {
this.alertme = "Alert!";
}
$.Comment.prototype.send = function() {
var self = this;
$.post(
self.url,
{
'somedata' : self.somedata
},
function(data, self) {
self.callback(data);
}
);
}
$.Comment.prototype.callback = function(data) {
alert(this.alertme);
}
When I'm calling $.Comment.send() debugger is saying to me that self.callback(data) is not a function
What am I doing wrong?
Thank you
Model Item belongs_to User.
In my controller I have code like this:
@items = Item.find(:all)
I need to have a corresponding User models for each item in my View templates.
it works in controller(but not in View template):
@items.each { |item| item.user }
But manual looping just to build associations for View template kinda smells.
How can I do this not in a creepy way?
Suppose I have two lists that holds the list of source file names and destination file names respectively.
The Sourcefilenamelist has files as 1.txt, 2.txt,3.txt, 4.txt
while the Destinaitonlist has 1.txt,2.txt.
I ned to write a linq query to find out which files are in SourceList that are absent in DestinationFile list.
e.g. here the out put will be 3.txt and 4.txt.
I have done this by a foreach statement.. but now I want to do the same by using LINQ(C#).
Help needed.
Thanks
I'm trying to build a voip application on a new android device, i use AudioRecorder to read the microphone but I'm getting no valid results, just white noise.
This happen only on this new device(other work well) and this is probably because this device has PTT ability.
Is there some workaround to avoid using AudioRecoder to receive streaming data from the microphone?
Thanks.
supersk.
I am currently working on a ASP.NET MVC reporting application using C#. This is a redesign from a PHP application that was just initially thrown together and is now starting to gain some more traction. SowWe are in the process of reworking the backend to have a more OO approach. One of the descisions I am currently wrestling with is how to structure the domain objects. Since 95% of the site is readonly I am not sure if the typical approaches are practical.
Should I create domain objects for the primary pieces of the application (ticket, assignment, assignee) and then create static methods off of these areas to pull the reporting data? Or should I just skip that part and create the chart data classes and have some get method off of these classes? It's not a real big application and currenlty I am the only one developing on it. But I feel torn as to which approach. I feel that the first one is the better choice but maybe overkill given that the majority of uses is for aggregate reporting.
Anybody have some good insight on why I should go one way or another?
It's been a few years since I've been heavily into Java. Coming back to it I'm seeing this pattern all over the place:
ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
// do work
}
});
This looks more like Functional programming to me. It's a nice pattern but how is it possible to pass a method like this? In the old days a class was a class, and once compiled there was little you could do to it.
My questions are:
Can anyone let me know what this pattern is called?
How can I write a class that can be instantiated in this way.
Are there any other useful examples of functional patterns that have made their way into Java?
What do I need to Google to read more about this?
Thanks.
Hi
I want to add "Sharing documents" feature to my app, like in google documents service. As i see:
User can:
can list/view/create/edit/delete own documents
share own document to everyone - its a public document
share own document to another user with read-only access
share own document to another user with read-write access
view list of own documents and users to whom he gave permission to read and write
view list of foreign documents
view/edit foreign document with read/write permissions
Please tell me, which permission/authorization solution is preffered for my task?
I am trying to create a UIImageView called theImageView in the touchesBegan method that I can then then move to a new location in touchesMoved. Currently I am receiving an "undeclared" error in touchesMoved where I set the new location for theImageView.
What can I do to keep theImageView in memory between these two methods?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
...
UIImageView *theImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
theImageView.frame = CGRectMake(263, 228, 193, 300);
[theImageView retain];
...
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
...
theImageView.frame = CGRectMake(300, 300, 193, 300);
...
}
Im currently optimizing a PHP application and found one function being called around 10-20k times, so I'd thought I'd start optimization there.
function keysToLower($obj)
{
if(!is_object($obj) && !is_array($obj)) return $obj;
foreach($obj as $key=>$element)
{
$element=keysToLower($element);
if(is_object($obj))
{
$obj->{strtolower($key)}=$element;
if(!ctype_lower($key)) unset($obj->{$key});
}
else if(is_array($obj) && ctype_upper($key))
{
$obj[strtolower($key)]=$element;
unset($obj[$key]);
}
}
return $obj;
}
Most of the time is spent in recursive calls (which are quite slow in PHP), but I don't see any way to convert it to a loop.
What would you do?
I have a class
class ChartLine{
protected:
vector<Point> line; // points connecting the line
CString name; //line name for legend
CPen pen; //color, size and style properties of the line
};
where Point is a structure
struct Point{
CString x;
double y;
};
In main() I dynamically allocate objects of type ChartLine with new operator.
If I use delete afterwards, will default destructor ~ChartLine() properly dealocate (or clear) member ChartLine::line(which is vector btw) or I would have to clear that vector in ~ChartLine() manually?
Thanks in advance.
Cheers.
Basically I need to hover over an anchor to display the "data-meta" div. Works just fine but when there's multiple td and divs, one hover displays all of them. My question is how can I show/hide them individually? Code snippets below.
<td>
<a href="#">Item</a>
<div class="data-meta">
<a href="#">Edit</a> | <a href="#">Disable</a> | <a href="#">Delete</a>
</div>
$(document).ready(function(){
$("td").hover(
function () {
$('.data-meta').show();
},
function () {
$('.data-meta').hide();
});
});
Events are really awesome, and I wouldn't know what I would do without them, but they're a mystery to me.
I'm talking about events in a sense, a function(s) is called if a property, or value, a special event happens.
I have only the vaguest idea how these actually work. I know it's an observer pattern, but I don't truly know how it works and/or how to implement it.
Can someone explain that to me?
Hello,
I have this code in a class:
private static MyObject _locker = new MyObject();
...
lock (_locker)
{
...
_locker = new MyObject();
...
}
Will it keep the lock on _locker ?
Hi All,
I want to create presentation like Google does with a costumed character objects.
for example visit following link
http://www.youtube.com/watch?v=m4Q9MJdT5Ds&feature=player_embedded