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?
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
Why are my App tests not being recognized by Django tests?
Why are my App tests not being recognized by Django tests?
Background:
I have the following django project setup:
>TopLevel:
> - App1:
> * models.py
> * forms.py
> * views.py
> * __init__.py
> * Tests/
> * __init__.py
> * test_simple.py
Here is the code in test_simple.py:
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
Now, when I run:
> python manage.py test app1
I get the following output:
>Creating test database for alias 'default'...
>
>----------------------------------------------------------------------
>Ran 0 tests in 0.000s
>
>OK
>Destroying test database for alias 'default'...
But, if I instead use the following project structure:
>TopLevel:
> - App1:
> * models.py
> * forms.py
> * views.py
> * __init__.py
> * tests.py
Where tests.py has the following code:
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
Now, when I run:
> python manage.py test app1
I get:
>Creating test database for alias 'default'...
>.
>----------------------------------------------------------------------
>Ran 1 test in 0.002s
>
>OK
>Destroying test database for alias 'default'...
Question:
Why does Django not recognize my Tests directory && why won't any tests
listed inside Tests/ be picked up by Django's unittest structure to run?
Background:
I have the following django project setup:
>TopLevel:
> - App1:
> * models.py
> * forms.py
> * views.py
> * __init__.py
> * Tests/
> * __init__.py
> * test_simple.py
Here is the code in test_simple.py:
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
Now, when I run:
> python manage.py test app1
I get the following output:
>Creating test database for alias 'default'...
>
>----------------------------------------------------------------------
>Ran 0 tests in 0.000s
>
>OK
>Destroying test database for alias 'default'...
But, if I instead use the following project structure:
>TopLevel:
> - App1:
> * models.py
> * forms.py
> * views.py
> * __init__.py
> * tests.py
Where tests.py has the following code:
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
Now, when I run:
> python manage.py test app1
I get:
>Creating test database for alias 'default'...
>.
>----------------------------------------------------------------------
>Ran 1 test in 0.002s
>
>OK
>Destroying test database for alias 'default'...
Question:
Why does Django not recognize my Tests directory && why won't any tests
listed inside Tests/ be picked up by Django's unittest structure to run?
GetJson parse function
GetJson parse function
here is my code for parsing JSON data of geolocation api of google
var url = "http://maps.googleapis.com/maps/api/geocode/json?address=" +
input.value + "&sensor=false";
var check = $.getJSON(url, function (data) {
console.log("inside getjson");
$.each(data.results.address_components, function(){
if(this.types[0]=="route"){
$("#results").append('<p> route : '+this.long_name +'</p>');
}
if(this.types[0]=="locality"){
$("#results").append('<p> locality : '+this.long_name +'</p>');
}
if(this.types[0]=="administrative_area_level_2"){
$("#results").append('<p> administrative area 2 : '+this.long_name
+'</p>');
}
if(this.types[0]=="administrative_area_level_1"){
$("#results").append('<p> administrative area 1 : '+this.long_name
+'</p>');
}
if(this.types[0]=="country"){
$("#results").append('<p> country : '+this.long_name +'</p>');
}
// latitude1 = data.results[0].geometry.location.lat;
// longitude1 = data.results[0].geometry.location.lng;
//alert(data.results[0].geometry.location.lat);
});
});
but unfortunately it doesn't parse the data properly...firebug throws the
error as e not defined. can you please look into it
here is my code for parsing JSON data of geolocation api of google
var url = "http://maps.googleapis.com/maps/api/geocode/json?address=" +
input.value + "&sensor=false";
var check = $.getJSON(url, function (data) {
console.log("inside getjson");
$.each(data.results.address_components, function(){
if(this.types[0]=="route"){
$("#results").append('<p> route : '+this.long_name +'</p>');
}
if(this.types[0]=="locality"){
$("#results").append('<p> locality : '+this.long_name +'</p>');
}
if(this.types[0]=="administrative_area_level_2"){
$("#results").append('<p> administrative area 2 : '+this.long_name
+'</p>');
}
if(this.types[0]=="administrative_area_level_1"){
$("#results").append('<p> administrative area 1 : '+this.long_name
+'</p>');
}
if(this.types[0]=="country"){
$("#results").append('<p> country : '+this.long_name +'</p>');
}
// latitude1 = data.results[0].geometry.location.lat;
// longitude1 = data.results[0].geometry.location.lng;
//alert(data.results[0].geometry.location.lat);
});
});
but unfortunately it doesn't parse the data properly...firebug throws the
error as e not defined. can you please look into it
How do you uninstall the package manager "pip", if installed from source?
How do you uninstall the package manager "pip", if installed from source?
I was unaware that pip could be installed via my operating system's
package manager, so I compiled and installed pip via source with the
following command:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O -
| sudo python
I would like to uninstall pip, and instead install it from my operating
system's package manager. How would I go about completely undoing the work
of the installation script?
I was unaware that pip could be installed via my operating system's
package manager, so I compiled and installed pip via source with the
following command:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O -
| sudo python
I would like to uninstall pip, and instead install it from my operating
system's package manager. How would I go about completely undoing the work
of the installation script?
Friday, 30 August 2013
HTML Checkbox selected Element keep tick after submit
HTML Checkbox selected Element keep tick after submit
I have check box set when i submit it, i want keep tick what i selected, I
have wrote a code but I want to know any easiest way to do it
<form action="" method="post">
<input type="checkbox" name="car[]"
<?php
if(isset($_POST['submit'])){
if(isset($_POST['car'])){
if(in_array('Bus',$_POST['car']))
{
echo ' checked="checked"" ';
}
}
}
?> value="Bus" />Bus
<input type="checkbox" name="car[]" value="Van"
<?php
if(isset($_POST['submit']))
{
if(isset($_POST['car'])){
if(in_array('Van',$_POST['car']))
{
echo ' checked="checked"" ';
}
}
} ?> />Van
<input type="submit" name="submit" value="Submit" />
</form>
I have check box set when i submit it, i want keep tick what i selected, I
have wrote a code but I want to know any easiest way to do it
<form action="" method="post">
<input type="checkbox" name="car[]"
<?php
if(isset($_POST['submit'])){
if(isset($_POST['car'])){
if(in_array('Bus',$_POST['car']))
{
echo ' checked="checked"" ';
}
}
}
?> value="Bus" />Bus
<input type="checkbox" name="car[]" value="Van"
<?php
if(isset($_POST['submit']))
{
if(isset($_POST['car'])){
if(in_array('Van',$_POST['car']))
{
echo ' checked="checked"" ';
}
}
} ?> />Van
<input type="submit" name="submit" value="Submit" />
</form>
Thursday, 29 August 2013
How to make Dynamic TextBox in C#
How to make Dynamic TextBox in C#
I have simple FormApplication script that contains button and some
TextBoxs. I want when click on button, one textbox shows some numbers. How
I can make that dynamic.
private void button1_Click(object sender, EventArgs e)
{
txt3.Text = "";
for (int i = 0; i <50; i++)
{
Random random = new Random();
int randomNumber = random.Next(100, 150);
txt3.Text = randomNumber.ToString();
}
}
Now it waits to loop finished and shows latest number. I want it shows
each number during loop in TextBox seperatly. Seems using Dynamic TextBox
is a bit hard, is there any other solution to show this numbers in main
form? Regards,
I have simple FormApplication script that contains button and some
TextBoxs. I want when click on button, one textbox shows some numbers. How
I can make that dynamic.
private void button1_Click(object sender, EventArgs e)
{
txt3.Text = "";
for (int i = 0; i <50; i++)
{
Random random = new Random();
int randomNumber = random.Next(100, 150);
txt3.Text = randomNumber.ToString();
}
}
Now it waits to loop finished and shows latest number. I want it shows
each number during loop in TextBox seperatly. Seems using Dynamic TextBox
is a bit hard, is there any other solution to show this numbers in main
form? Regards,
password for Login Application in c# windows form
password for Login Application in c# windows form
How to display password as "**" in the text box instead of displaying real
password on text box? Is it possible in c#
Thanks
How to display password as "**" in the text box instead of displaying real
password on text box? Is it possible in c#
Thanks
clang -cc1 and system includes
clang -cc1 and system includes
I have the following file foo.cpp:
#include <vector>
struct MyClass
{
std::vector<int> v;
};
It can be successfully compiled with clang (I'm using clang 3.3 on Ubuntu
13.04 32bit):
clang++ -c foo.cpp
Now I want to print AST:
clang++ -cc1 -ast-print foo.cpp
and I've got the following error
foo.cpp:1:10: fatal error: 'vector' file not found
#include <vector>
^
struct MyClass {
};
1 error generated.
It looks like clang++ -cc1 doesn't know about system include files etc.
I'm wondering how to set up includes for clang++ -cc1?
I have the following file foo.cpp:
#include <vector>
struct MyClass
{
std::vector<int> v;
};
It can be successfully compiled with clang (I'm using clang 3.3 on Ubuntu
13.04 32bit):
clang++ -c foo.cpp
Now I want to print AST:
clang++ -cc1 -ast-print foo.cpp
and I've got the following error
foo.cpp:1:10: fatal error: 'vector' file not found
#include <vector>
^
struct MyClass {
};
1 error generated.
It looks like clang++ -cc1 doesn't know about system include files etc.
I'm wondering how to set up includes for clang++ -cc1?
Wednesday, 28 August 2013
Load all resources before loading Activity?
Load all resources before loading Activity?
I have an activity which has to grab heavy images, resize them and loads
into GridView. Since all this process of fetching, resizing is time
consuming, when I try to load this screen from another ACtivity, I get a
delay.
How can I first load the content of this "grid activity" and open it only
after all images have been loaded?
Using startActivityForResult? If this is a solution, how can I detect that
all images have been loaded since GridView load images on scroll.
I have an activity which has to grab heavy images, resize them and loads
into GridView. Since all this process of fetching, resizing is time
consuming, when I try to load this screen from another ACtivity, I get a
delay.
How can I first load the content of this "grid activity" and open it only
after all images have been loaded?
Using startActivityForResult? If this is a solution, how can I detect that
all images have been loaded since GridView load images on scroll.
Building gvim 7.4 on CentOS 6.4
Building gvim 7.4 on CentOS 6.4
Am trying to build gvim7.4 from source on a box running CentOS 6.4. I
followed the instructions mentioned here to build vim locally. The
executable 'vim' gets built just fine, but 'gvim' is nowhere to be seen. I
tried everything that I could find on google but doesn't seem to be
helping.
Should 'gvim' be built using any other method (other than the usual
configure/make way)? Or is there any obscure trick to build the executable
for gvim?
My OS: CentOS 6.4. Has all X/devel stuff that's required. Command used is:
./configure --prefix=/usr --with-compiledby="megazoe" \
--with-features=huge --enable-rubyinterp \
--enable-pythoninterp --enable-python3interp \
--enable-gui=gnome2 --enable-luainterp \
--enable-perlinterp --enable-cscope
The stdout from configure has below stuff related to X:
checking if X11 header files can be found... yes
checking for _XdmcpAuthDoIt in -lXdmcp... no
checking for IceOpenConnection in -lICE... yes
checking for XpmCreatePixmapFromData in -lXpm... yes
checking if X11 header files implicitly declare return values... no
checking size of wchar_t is 2 bytes... no
checking --enable-gui argument... GNOME 2.x GUI support
checking --disable-gtktest argument... gtk test enabled
checking for pkg-config... /usr/bin/pkg-config
checking for GTK - version >= 2.2.0... yes; found version 2.18.9
checking for libgnomeui-2.0... yes
checking for FreeBSD... no
checking X11/SM/SMlib.h usability... yes
checking X11/SM/SMlib.h presence... yes
checking for X11/SM/SMlib.h... yes
checking X11/xpm.h usability... yes
checking X11/xpm.h presence... yes
checking for X11/xpm.h... yes
checking X11/Sunkeysym.h usability... yes
checking X11/Sunkeysym.h presence... yes
checking for X11/Sunkeysym.h... yes
checking for XIMText in X11/Xlib.h... yes
X GUI selected; xim has been enabled
checking for CYGWIN environment... no
Make doesn't throw any error , 'vim' gets built just fine. Only, there's
no gvim to be seen anywhere! I can use the -g switch with vim for a GUI
instance [vim -g] but that isn't gvim, with the GNOME menubar and the
works, which is what I want. Shouldn't 'gvim' get built since
--enable-gui=gnome2 is used? Or is gvim a totally different beast
altogether?
Any suggestions on how to get around this problem?
Thanks!
Am trying to build gvim7.4 from source on a box running CentOS 6.4. I
followed the instructions mentioned here to build vim locally. The
executable 'vim' gets built just fine, but 'gvim' is nowhere to be seen. I
tried everything that I could find on google but doesn't seem to be
helping.
Should 'gvim' be built using any other method (other than the usual
configure/make way)? Or is there any obscure trick to build the executable
for gvim?
My OS: CentOS 6.4. Has all X/devel stuff that's required. Command used is:
./configure --prefix=/usr --with-compiledby="megazoe" \
--with-features=huge --enable-rubyinterp \
--enable-pythoninterp --enable-python3interp \
--enable-gui=gnome2 --enable-luainterp \
--enable-perlinterp --enable-cscope
The stdout from configure has below stuff related to X:
checking if X11 header files can be found... yes
checking for _XdmcpAuthDoIt in -lXdmcp... no
checking for IceOpenConnection in -lICE... yes
checking for XpmCreatePixmapFromData in -lXpm... yes
checking if X11 header files implicitly declare return values... no
checking size of wchar_t is 2 bytes... no
checking --enable-gui argument... GNOME 2.x GUI support
checking --disable-gtktest argument... gtk test enabled
checking for pkg-config... /usr/bin/pkg-config
checking for GTK - version >= 2.2.0... yes; found version 2.18.9
checking for libgnomeui-2.0... yes
checking for FreeBSD... no
checking X11/SM/SMlib.h usability... yes
checking X11/SM/SMlib.h presence... yes
checking for X11/SM/SMlib.h... yes
checking X11/xpm.h usability... yes
checking X11/xpm.h presence... yes
checking for X11/xpm.h... yes
checking X11/Sunkeysym.h usability... yes
checking X11/Sunkeysym.h presence... yes
checking for X11/Sunkeysym.h... yes
checking for XIMText in X11/Xlib.h... yes
X GUI selected; xim has been enabled
checking for CYGWIN environment... no
Make doesn't throw any error , 'vim' gets built just fine. Only, there's
no gvim to be seen anywhere! I can use the -g switch with vim for a GUI
instance [vim -g] but that isn't gvim, with the GNOME menubar and the
works, which is what I want. Shouldn't 'gvim' get built since
--enable-gui=gnome2 is used? Or is gvim a totally different beast
altogether?
Any suggestions on how to get around this problem?
Thanks!
Cepstrum analysis: how to find quefrency step?
Cepstrum analysis: how to find quefrency step?
I'm newbie in cepstrum analysis. So that's the question.
I have signal with the length 4096 and sample rate 8000 Hz. I make FFT and
get the array with the length 4096*2 (2*i position is for cosinus coeff,
2*i+1 position is for sinus coeff). Frequency step is
(sampleRate/signalLength == 8000/4096). So, I can calculate frequency at i
position this way: i*sampleRate/signalLength.
Then, I make the cepstrum transformation. I can't understand how to find
quefrency step and how to find frequency for given quefrency.
I'm newbie in cepstrum analysis. So that's the question.
I have signal with the length 4096 and sample rate 8000 Hz. I make FFT and
get the array with the length 4096*2 (2*i position is for cosinus coeff,
2*i+1 position is for sinus coeff). Frequency step is
(sampleRate/signalLength == 8000/4096). So, I can calculate frequency at i
position this way: i*sampleRate/signalLength.
Then, I make the cepstrum transformation. I can't understand how to find
quefrency step and how to find frequency for given quefrency.
Tuesday, 27 August 2013
Matplotlib imshow() too many objects for cmap
Matplotlib imshow() too many objects for cmap
I'm trying to create a simple imshow() plot (matplotlib v.1.2.1) of a 2D
gaussian function:
import matplotlib.pyplot as plt
import numpy as np
from pylab import *
def gaussian(x,y,stdx,stdy):
return 1.0/(2*np.pi*stdx*stdy) * (np.exp(-0.5*(x**2/stdx**2 +
y**2/stdy**2)))
coords = np.linspace(-1,1,100)
X,Y = np.meshgrid(coords,coords)
std_list = np.linspace(1,2,20)
output = [gaussian(X,Y,std_list[i],std_list[i]) for i in
range(len(std_list))]
for i in range(len(output)):
plt.imshow(X,Y,np.array(output[i]),cmap='bone')
plt.show()
And I get the following error:
Traceback (most recent call last):
File "blur.py", line 14, in <module>
plt.imshow(X,Y,np.array(output[i]),cmap='bone')
TypeError: imshow() got multiple values for keyword argument 'cmap'
In fact, to make sure I wasn't crazy, I took out the cmap argument
altogether, and now I'm getting the following error:
Traceback (most recent call last):
File "blur.py", line 14, in <module>
plt.imshow(X,Y,np.array(output[i]))
File
"/home/username/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py",
line 2737, in imshow
imlim=imlim, resample=resample, url=url, **kwargs)
File
"/home/username/anaconda/lib/python2.7/site-packages/matplotlib/axes.py",
line 7098, in imshow
if norm is not None: assert(isinstance(norm, mcolors.Normalize))
AssertionError
I've made sure that the arguments of imshow( ) all have the same shape, so
I'm not entirely sure what I'm doing wrong. Could this be a bug?
I'm trying to create a simple imshow() plot (matplotlib v.1.2.1) of a 2D
gaussian function:
import matplotlib.pyplot as plt
import numpy as np
from pylab import *
def gaussian(x,y,stdx,stdy):
return 1.0/(2*np.pi*stdx*stdy) * (np.exp(-0.5*(x**2/stdx**2 +
y**2/stdy**2)))
coords = np.linspace(-1,1,100)
X,Y = np.meshgrid(coords,coords)
std_list = np.linspace(1,2,20)
output = [gaussian(X,Y,std_list[i],std_list[i]) for i in
range(len(std_list))]
for i in range(len(output)):
plt.imshow(X,Y,np.array(output[i]),cmap='bone')
plt.show()
And I get the following error:
Traceback (most recent call last):
File "blur.py", line 14, in <module>
plt.imshow(X,Y,np.array(output[i]),cmap='bone')
TypeError: imshow() got multiple values for keyword argument 'cmap'
In fact, to make sure I wasn't crazy, I took out the cmap argument
altogether, and now I'm getting the following error:
Traceback (most recent call last):
File "blur.py", line 14, in <module>
plt.imshow(X,Y,np.array(output[i]))
File
"/home/username/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py",
line 2737, in imshow
imlim=imlim, resample=resample, url=url, **kwargs)
File
"/home/username/anaconda/lib/python2.7/site-packages/matplotlib/axes.py",
line 7098, in imshow
if norm is not None: assert(isinstance(norm, mcolors.Normalize))
AssertionError
I've made sure that the arguments of imshow( ) all have the same shape, so
I'm not entirely sure what I'm doing wrong. Could this be a bug?
Input control type Checkbox always true
Input control type Checkbox always true
I have searched all the topics discussing this issue and cant seem to find
one that explains the issue using Asp.net C#, everything is either
javascript or MVC or PHP my reasoning for opening a new question regarding
this.
I have 2 input control type checkbox
<input runat="server" type="checkbox" name="chkChildSexMale"
id="chkChildSexMale" />
<input runat="server" type="checkbox" name="chkChildSexFemale"
id="chkChildSexFemale" />
My CodeBehind is
if (chkChildSexMale.Checked)
{
do something
}
else if (chkChildSexFemale.Checked)
{
do something else
}
The issue is that no matter what is checked the
if(chkChildSexMale.Checked) is always true even though it is not checked.
What am I doing wrong?
I have searched all the topics discussing this issue and cant seem to find
one that explains the issue using Asp.net C#, everything is either
javascript or MVC or PHP my reasoning for opening a new question regarding
this.
I have 2 input control type checkbox
<input runat="server" type="checkbox" name="chkChildSexMale"
id="chkChildSexMale" />
<input runat="server" type="checkbox" name="chkChildSexFemale"
id="chkChildSexFemale" />
My CodeBehind is
if (chkChildSexMale.Checked)
{
do something
}
else if (chkChildSexFemale.Checked)
{
do something else
}
The issue is that no matter what is checked the
if(chkChildSexMale.Checked) is always true even though it is not checked.
What am I doing wrong?
Create an array of arrays from a bigger array in javascript
Create an array of arrays from a bigger array in javascript
I have a single dimension array of objects:
var myArray = [ { record : "value" ,
recod2 : "value" ,
record3 : "value"
} ,
{ record : "value" ,
record2 : "value"
record3 : "value"
} ,
.
.
.
] ;
From this, I want to construct a jagged 2-dimensional array (array of
arrays) like so:
var result = [ [ {} , {} , {} , {} ] ,
[ {} , {} , {} , {} ] ,
[ {} , {} , {} , {} ] ,
.
.
.
] ;
For example, If my first array contains 8 objects, The result array should
look like this:
var result = [ [ obj1 , obj2 , obj3 , obj4 ] ,
[ obj5 , obj6 , obj7 , obj8 ] ,
] ;
How can I achieve this with a for loop ?
I have a single dimension array of objects:
var myArray = [ { record : "value" ,
recod2 : "value" ,
record3 : "value"
} ,
{ record : "value" ,
record2 : "value"
record3 : "value"
} ,
.
.
.
] ;
From this, I want to construct a jagged 2-dimensional array (array of
arrays) like so:
var result = [ [ {} , {} , {} , {} ] ,
[ {} , {} , {} , {} ] ,
[ {} , {} , {} , {} ] ,
.
.
.
] ;
For example, If my first array contains 8 objects, The result array should
look like this:
var result = [ [ obj1 , obj2 , obj3 , obj4 ] ,
[ obj5 , obj6 , obj7 , obj8 ] ,
] ;
How can I achieve this with a for loop ?
Subscribe to:
Posts (Atom)