GetWindowRect() fails, but IsWindow() is not
I am trying to get the size of an external window:
POINT point;
point.x = 100;
point.y = 100;
HWND hwnd = WindowFromPoint(point);
LPRECT pRect = {0};
bool ret1 = IsWindow(hwnd);
bool ret = GetWindowRect(hwnd, pRect);
The return value of IsWindow is true, but GetWindowRect fails with the
following error:
1400: Invalid window handle
What can be wrong?
Buttitta
Sunday, 1 September 2013
NoMethodError in Posts#new
NoMethodError in Posts#new
im doing the getting started with Rails tutorial on:
http://guides.rubyonrails.org/getting_started.html when i run the local
server from shell i got this:
NoMethodError in Posts#new /_form.html.erb where line #1 raised: undefined
method `model_name' for NilClass:Class
That is the extracted source(arround line #1):
1: <%= form_for @post do |f| %>
2: <% if @post.errors.any? %>
3: <div id="errorExplanation">
4: <h2><%= pluralize(@post.errors.count, "error") %> prohibited
I just started on Ruby on rails and i can' figure it out what is
happening. Some help must be apreciated. Thanks.
im doing the getting started with Rails tutorial on:
http://guides.rubyonrails.org/getting_started.html when i run the local
server from shell i got this:
NoMethodError in Posts#new /_form.html.erb where line #1 raised: undefined
method `model_name' for NilClass:Class
That is the extracted source(arround line #1):
1: <%= form_for @post do |f| %>
2: <% if @post.errors.any? %>
3: <div id="errorExplanation">
4: <h2><%= pluralize(@post.errors.count, "error") %> prohibited
I just started on Ruby on rails and i can' figure it out what is
happening. Some help must be apreciated. Thanks.
Django Filter by Foreign Key
Django Filter by Foreign Key
class UserTomonotomo(models.Model):
userid= models.BigIntegerField(null=False, unique=True, db_index=True)
email= models.CharField(max_length=100L, null=True)
######################
########
class UserFriends(models.Model):
userid= models.ForeignKey('UserTomonotomo', to_field='userid',
null=False)
friendid = models.BigIntegerField(null=False)
I need to search for UserFriends whose userid > 0,
UserFriends.objects.filter( userid__userid > 0 )
does not work as posted in Django - filtering on foreign key properties !!
What's the fix. I am using django version 1.5.2
Thanks
class UserTomonotomo(models.Model):
userid= models.BigIntegerField(null=False, unique=True, db_index=True)
email= models.CharField(max_length=100L, null=True)
######################
########
class UserFriends(models.Model):
userid= models.ForeignKey('UserTomonotomo', to_field='userid',
null=False)
friendid = models.BigIntegerField(null=False)
I need to search for UserFriends whose userid > 0,
UserFriends.objects.filter( userid__userid > 0 )
does not work as posted in Django - filtering on foreign key properties !!
What's the fix. I am using django version 1.5.2
Thanks
Saturday, 31 August 2013
Using ConcurrentHashMap efficiently?
Using ConcurrentHashMap efficiently?
I have a Android Application whose core component is a
HashMap<String,float[]>. The System is having high concurrency. e.g here
are the following three situations I have which occur frequently and they
are highly overlapping in nature
Iterate through all the keys in the hashmap and do some operation on its
value(read only operations).
Add new key,value pairs in the Hashmap.
Remove Certain keys from the Hashmap.
I do all these operations in different threads and thus am using a
ConcurrentHashMap since some inconsistency in retrievals doesnt matter.
e.g While iterating the map,if new entries are added then it doesnt matter
to not read in those new values immediately as I ensure that next time
they are read .
Also while removing the entries I am recreating the iterator everytime to
avoid "ConcurrentModificationException"
Suppose , there is a following hashmap(i.e ConcurrentHashmap)
ConcurrentHashMap<String,float[]> test=new ConcurrentHashMap<String,
float[]>(200);
Now for Retrieval I do the following
Iterator<String> reader=test.keySet().iterator();
while(reader.hasNext())
{
String s=reader.next();
float[] temp=test.get(s);
//do some operation with float[] temp here(read only
operation)
}
and for removal I do the following
boolean temp = true;
while (temp) {
for (String key : test.keySet()) {
temp = false;
if (key.equals("abc")) {
test.remove(key);
temp = true;
break;
}
}
}
and when inserting in new values I simply do
test.put("temp value", new float[10]);
I am not sure if its a very efficient utilisation. Also it does matter not
to read in removed values(however I need efficiency ,and since the
iterator is again created during the function call,its guaranteed that in
the next time I don't get the removed values)so that much inconsistency
can be tolerated?
Could someone please tell me an efficient way to do it?
I have a Android Application whose core component is a
HashMap<String,float[]>. The System is having high concurrency. e.g here
are the following three situations I have which occur frequently and they
are highly overlapping in nature
Iterate through all the keys in the hashmap and do some operation on its
value(read only operations).
Add new key,value pairs in the Hashmap.
Remove Certain keys from the Hashmap.
I do all these operations in different threads and thus am using a
ConcurrentHashMap since some inconsistency in retrievals doesnt matter.
e.g While iterating the map,if new entries are added then it doesnt matter
to not read in those new values immediately as I ensure that next time
they are read .
Also while removing the entries I am recreating the iterator everytime to
avoid "ConcurrentModificationException"
Suppose , there is a following hashmap(i.e ConcurrentHashmap)
ConcurrentHashMap<String,float[]> test=new ConcurrentHashMap<String,
float[]>(200);
Now for Retrieval I do the following
Iterator<String> reader=test.keySet().iterator();
while(reader.hasNext())
{
String s=reader.next();
float[] temp=test.get(s);
//do some operation with float[] temp here(read only
operation)
}
and for removal I do the following
boolean temp = true;
while (temp) {
for (String key : test.keySet()) {
temp = false;
if (key.equals("abc")) {
test.remove(key);
temp = true;
break;
}
}
}
and when inserting in new values I simply do
test.put("temp value", new float[10]);
I am not sure if its a very efficient utilisation. Also it does matter not
to read in removed values(however I need efficiency ,and since the
iterator is again created during the function call,its guaranteed that in
the next time I don't get the removed values)so that much inconsistency
can be tolerated?
Could someone please tell me an efficient way to do it?
MetaController should Observe three objects
MetaController should Observe three objects
I'm caught in a mental loop, or at least a lack of understanding of how to
implement the observer pattern. My intended Controller implements Observer
because it's meant to, literally, observe the instances it, literally,
controls.
The observed objects extend Observable because they are meant to be
observed, literally, by the Controller. What do I invoke
.addObserver(responseHandler); on? Another class adds an observer to the
instance which, literally, implements the `Observer' interface? That can't
be right.
As an aside, is there a naming problem in this pattern as implemented in
Java, or just a lack of understanding on my part?
Here's the Controller, which has now morphed into a Controller of a
Controller:
public class MetaController implements Observer {
private final static Logger LOG =
Logger.getLogger(MetaController.class.getName());
private Printer telnetPrinter = new Printer();
private telnetDataProcessor telnetDataProcessor = new
telnetDataProcessor();
private StringReader stringReader = new StringReader();
private final ConcurrentLinkedQueue<Character> telnetData = new
ConcurrentLinkedQueue();
public MetaController() {
}
//the printer and processor each spawn their own thread so that they
don't
//block each other waiting for each other
public void readPrintParse(final InputStream inputStream) throws
SocketException, IOException {
telnetPrinter.print(inputStream, telnetData); //populate
telnetData in its own thread
telnetDataProcessor.read(telnetData); //process telnetData in its
own thread
}
//the StringReader just looks for particular keywords like "press
enter to continue"
//so that some phrases will trigger a response
//commands may also be typed manually by the user (not implemented yet)
@Override
public void update(Observable o, Object arg) {
//when telnetDataProcessor sends a String, send that String on to
stringReader
String cmd = stringReader.parse(null); //parse what and how?
//send the command string back to the telnetClient
}
}
Reading the API directly, unfortunately, is not illuminating for me.
This is an extension of an Apache WeatherTelnet example, a sort of
poor-mans Netty to allow concurrent scripted telnet and live telnet
responses for a simple MUD client, which requires live processing of a
non-terminated telnet data stream, as well as live output and user input.
I'm caught in a mental loop, or at least a lack of understanding of how to
implement the observer pattern. My intended Controller implements Observer
because it's meant to, literally, observe the instances it, literally,
controls.
The observed objects extend Observable because they are meant to be
observed, literally, by the Controller. What do I invoke
.addObserver(responseHandler); on? Another class adds an observer to the
instance which, literally, implements the `Observer' interface? That can't
be right.
As an aside, is there a naming problem in this pattern as implemented in
Java, or just a lack of understanding on my part?
Here's the Controller, which has now morphed into a Controller of a
Controller:
public class MetaController implements Observer {
private final static Logger LOG =
Logger.getLogger(MetaController.class.getName());
private Printer telnetPrinter = new Printer();
private telnetDataProcessor telnetDataProcessor = new
telnetDataProcessor();
private StringReader stringReader = new StringReader();
private final ConcurrentLinkedQueue<Character> telnetData = new
ConcurrentLinkedQueue();
public MetaController() {
}
//the printer and processor each spawn their own thread so that they
don't
//block each other waiting for each other
public void readPrintParse(final InputStream inputStream) throws
SocketException, IOException {
telnetPrinter.print(inputStream, telnetData); //populate
telnetData in its own thread
telnetDataProcessor.read(telnetData); //process telnetData in its
own thread
}
//the StringReader just looks for particular keywords like "press
enter to continue"
//so that some phrases will trigger a response
//commands may also be typed manually by the user (not implemented yet)
@Override
public void update(Observable o, Object arg) {
//when telnetDataProcessor sends a String, send that String on to
stringReader
String cmd = stringReader.parse(null); //parse what and how?
//send the command string back to the telnetClient
}
}
Reading the API directly, unfortunately, is not illuminating for me.
This is an extension of an Apache WeatherTelnet example, a sort of
poor-mans Netty to allow concurrent scripted telnet and live telnet
responses for a simple MUD client, which requires live processing of a
non-terminated telnet data stream, as well as live output and user input.
Difference between Kivy and Java for android apps
Difference between Kivy and Java for android apps
For a python developer that has some experience creating android apps with
java. I want to create a small app that access my university portal and
retrieve some data to easy access it on android.
1) Which one its easier and faster to develop android apps?
2) Does Kivy has limitations to access certain parts of android (like not
fully integrated with its api)?
3) And finally, an android app developed using kivy would run as fast as
one developed using java?
For a python developer that has some experience creating android apps with
java. I want to create a small app that access my university portal and
retrieve some data to easy access it on android.
1) Which one its easier and faster to develop android apps?
2) Does Kivy has limitations to access certain parts of android (like not
fully integrated with its api)?
3) And finally, an android app developed using kivy would run as fast as
one developed using java?
This code is printing array 0 0 0 0 0 5 and not the actual array
This code is printing array 0 0 0 0 0 5 and not the actual array
class ArrayPrint {
static void arrayPrinter(int[] x) {
for(int i=0;i<x.length;i++) {
System.out.println(x[i]);
}
}
public static void main(String...S) {
int[] x = {3,3,4,2,7};
x = new int[5];
arrayPrinter(x);
System.out.println(x.length);
}
}
Actual array is not printing, it is printing 0 0 0 0 0. Please help
correct the error
class ArrayPrint {
static void arrayPrinter(int[] x) {
for(int i=0;i<x.length;i++) {
System.out.println(x[i]);
}
}
public static void main(String...S) {
int[] x = {3,3,4,2,7};
x = new int[5];
arrayPrinter(x);
System.out.println(x.length);
}
}
Actual array is not printing, it is printing 0 0 0 0 0. Please help
correct the error
Subscribe to:
Comments (Atom)