Two coulmns can not be null at the same time in sql
Suppose there a table called
Employee
ID number, name varchar(24 char), address varchar2(100 char),
alternateAddress(100 char), sex varchar2(10 char)
Now I want to put constraint such that both address and alternateAddress
cannot be null i.e possible cases are:
address is null and alternateAddress is not null
alternateAddress is null and address is not null
alternateAddress is not null and address is not null
But cannot happen that any record in Employee table inserted with
alternateAddress and address both null
Thursday, 3 October 2013
Wednesday, 2 October 2013
String to Integer Mapping
String to Integer Mapping
Does any one have algorithm or logic to Convert A to 1 ,B to 2, ... ,Z to
26 and then ,AA to 27, AB to 28 and so on BUT BA or cb or cbe or any
string which has letters in descending order should not be numbered a for
eg: BB should be 53 as BA is not numbered .this question is very similar
to Convert A to 1 B to 2 ... Z to 26 and then AA to 27 AB to 28 (column
indexes to column references in Excel) but with a slight difference as
mentioned above
Does any one have algorithm or logic to Convert A to 1 ,B to 2, ... ,Z to
26 and then ,AA to 27, AB to 28 and so on BUT BA or cb or cbe or any
string which has letters in descending order should not be numbered a for
eg: BB should be 53 as BA is not numbered .this question is very similar
to Convert A to 1 B to 2 ... Z to 26 and then AA to 27 AB to 28 (column
indexes to column references in Excel) but with a slight difference as
mentioned above
Ñ# modPow negative exponent trick
Ñ# modPow negative exponent trick
I try to use using System.Numerics.BigInteger; and perfom modPow with
negative exponent, I read documentation about Exception, that's why I did
some trick
//a^(-x) mod n == (a^(-1))^x mod n
BigInteger tmp = BigInteger.ModPow(BigInteger.Divide(BigInteger.One, a),
secretKey, pCommon);
BigInteger resBigInteger = BigInteger.Multiply(b, tmp);
But tmp is 0. How I can resolve that problem?
I try to use using System.Numerics.BigInteger; and perfom modPow with
negative exponent, I read documentation about Exception, that's why I did
some trick
//a^(-x) mod n == (a^(-1))^x mod n
BigInteger tmp = BigInteger.ModPow(BigInteger.Divide(BigInteger.One, a),
secretKey, pCommon);
BigInteger resBigInteger = BigInteger.Multiply(b, tmp);
But tmp is 0. How I can resolve that problem?
how to sort names and numbers?
how to sort names and numbers?
After completing my school assignment on simple array sorts I came up with
this question. Say I have a textbox with a name in it. Right beside that I
have a textbox with number in it. Exp txtBox1 = "John Doe", txtBox2 = 8.
Lets say I have 10 rows. that would be 20 text boxes. How could I randomly
sort these by name keeping all like numbers together in sequential order.
Output should look something like this. The key here is to randomly sort
the names within the same number group.
John Doe 3
Mary Jane 3
name 4
name 4
name 4
name 5
name 7
name 7
name 8
name 8
After completing my school assignment on simple array sorts I came up with
this question. Say I have a textbox with a name in it. Right beside that I
have a textbox with number in it. Exp txtBox1 = "John Doe", txtBox2 = 8.
Lets say I have 10 rows. that would be 20 text boxes. How could I randomly
sort these by name keeping all like numbers together in sequential order.
Output should look something like this. The key here is to randomly sort
the names within the same number group.
John Doe 3
Mary Jane 3
name 4
name 4
name 4
name 5
name 7
name 7
name 8
name 8
Ampersand encoding in img src
Ampersand encoding in img src
I am trying to display an image (gravatar), but the ampersand in its link
seem to be problematic.
At first, I had:
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>& in url</title>
</head>
<body>
<a
href="http://www.gravatar.com/avatar/f14e8ce12e7d7ffc11fe8a29127030da.jpg?d=mm&r=r">Link
to image</a>
<img
src="http://www.gravatar.com/avatar/f14e8ce12e7d7ffc11fe8a29127030da.jpg?d=mm&r=r"
alt="display image">
</body>
</html>
The link (<a>) works fine this way, but the image (<img>) won't show. And
of course it doesn't pass the w3c validation.
I encoded the ampersand to &, but the result stays the same (except
for the w3c validation which is OK). I even tried a urlencoded version
(via PHP) with no luck.
Any idea on what I am missing?
I am trying to display an image (gravatar), but the ampersand in its link
seem to be problematic.
At first, I had:
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>& in url</title>
</head>
<body>
<a
href="http://www.gravatar.com/avatar/f14e8ce12e7d7ffc11fe8a29127030da.jpg?d=mm&r=r">Link
to image</a>
<img
src="http://www.gravatar.com/avatar/f14e8ce12e7d7ffc11fe8a29127030da.jpg?d=mm&r=r"
alt="display image">
</body>
</html>
The link (<a>) works fine this way, but the image (<img>) won't show. And
of course it doesn't pass the w3c validation.
I encoded the ampersand to &, but the result stays the same (except
for the w3c validation which is OK). I even tried a urlencoded version
(via PHP) with no luck.
Any idea on what I am missing?
Tuesday, 1 October 2013
Setting up a Daemon in Unix
Setting up a Daemon in Unix
I have scheduled a crontab job in AIX 6.1 OS to run twice in an hour which
runs for the whole day to process a load.
The load which crontab kicks off needs files to arrive at a particular
directory and if the files arrive, I process them.
It so happens that for the 24 times the crontab kicks off my load there
would be only 7 times I actually receive the files and for the rest of the
times I receive no files and the load reports saying that no files
received and I cannot preict when files arrive as it can arrive anytime.
I heard that a DAEMON can be setup in Unix which can monitor for files
arriving at a particular destination and call other scripts after that.
I was thinking if it were possible to create a daemon to monitor a
particular destination and if files are present, It can call a shell
script.
Is this possible, if yes how can I code the daemon. I have no prior
experience with daemons. Can anyone clarify.
I have scheduled a crontab job in AIX 6.1 OS to run twice in an hour which
runs for the whole day to process a load.
The load which crontab kicks off needs files to arrive at a particular
directory and if the files arrive, I process them.
It so happens that for the 24 times the crontab kicks off my load there
would be only 7 times I actually receive the files and for the rest of the
times I receive no files and the load reports saying that no files
received and I cannot preict when files arrive as it can arrive anytime.
I heard that a DAEMON can be setup in Unix which can monitor for files
arriving at a particular destination and call other scripts after that.
I was thinking if it were possible to create a daemon to monitor a
particular destination and if files are present, It can call a shell
script.
Is this possible, if yes how can I code the daemon. I have no prior
experience with daemons. Can anyone clarify.
Search a table based on multiple rows in another table
Search a table based on multiple rows in another table
Basically I have three MySQL tables:
Users - contains base information on users
Fields - describes additional fields for said users (e.g. location, dob etc.)
Data - Contains user data described via links to the fields table
With the basic design as follows (the below is a stripped down version)
Users:
ID | username | password | email | registered_date
Fields
ID | name | type
Data:
ID | User_ID | Field_ID | value
what I want to do is search Users by the values for the fields they have,
e.g. example fields might be:
Full Name
Town/City
Postcode
etc.
I've got the following, which works when you're only wanting to search by
one field:
SELECT `users`.`ID`,
`users`.`username`,
`users`.`email`,
`data`.`value`,
`fields`.`name`
FROM `users`,
`fields`,
`data`
WHERE `data`.`Field_ID` = '2'
AND `data`.`value` LIKE 'london'
AND `users`.`ID` = `data`.`User_ID`
AND `data`.`Field_ID` = `fields`.`ID`
GROUP BY `users`.`ID`
But what about if you want to search for Multiple fields? e.g. say I want
to search for Full Name "Joe Bloggs" With Town/City set to "London"? This
is the real sticking point for me.
Is something like this possible with MySQL?
Basically I have three MySQL tables:
Users - contains base information on users
Fields - describes additional fields for said users (e.g. location, dob etc.)
Data - Contains user data described via links to the fields table
With the basic design as follows (the below is a stripped down version)
Users:
ID | username | password | email | registered_date
Fields
ID | name | type
Data:
ID | User_ID | Field_ID | value
what I want to do is search Users by the values for the fields they have,
e.g. example fields might be:
Full Name
Town/City
Postcode
etc.
I've got the following, which works when you're only wanting to search by
one field:
SELECT `users`.`ID`,
`users`.`username`,
`users`.`email`,
`data`.`value`,
`fields`.`name`
FROM `users`,
`fields`,
`data`
WHERE `data`.`Field_ID` = '2'
AND `data`.`value` LIKE 'london'
AND `users`.`ID` = `data`.`User_ID`
AND `data`.`Field_ID` = `fields`.`ID`
GROUP BY `users`.`ID`
But what about if you want to search for Multiple fields? e.g. say I want
to search for Full Name "Joe Bloggs" With Town/City set to "London"? This
is the real sticking point for me.
Is something like this possible with MySQL?
I cannot find my schedule for system shut down
I cannot find my schedule for system shut down
Long time ago I set a schedule for shutting down the system at a
particular time. Now I need to change this time but I cannot find this
schedule anywhere.
I checked crontab and gnome-schedule
Does anyone know other places or software in which I might have this
schedule on ?
Long time ago I set a schedule for shutting down the system at a
particular time. Now I need to change this time but I cannot find this
schedule anywhere.
I checked crontab and gnome-schedule
Does anyone know other places or software in which I might have this
schedule on ?
Laptop display settings change when I plug the laptop in
Laptop display settings change when I plug the laptop in
my laptop behaves annoyingly when I'm using another display (laptop screen
+ another monitor, so in total two displays) with it. If I first connect
the other monitor, and then the power cable, Ubuntu mirrors the two
screens. Also, if I disconnect the second display, any applications whose
windows where on the second screen are "left there", i.e. if I click their
icon on the launcher they become active, but I cannot see them. They are
returned to the laptop screen only when I unplug my laptop.
My laptop is HP 635 and I'm using Ubuntu 12.04 LTS. I would like that the
display settings do not change in any way whether my laptop is plugged in
or not.
my laptop behaves annoyingly when I'm using another display (laptop screen
+ another monitor, so in total two displays) with it. If I first connect
the other monitor, and then the power cable, Ubuntu mirrors the two
screens. Also, if I disconnect the second display, any applications whose
windows where on the second screen are "left there", i.e. if I click their
icon on the launcher they become active, but I cannot see them. They are
returned to the laptop screen only when I unplug my laptop.
My laptop is HP 635 and I'm using Ubuntu 12.04 LTS. I would like that the
display settings do not change in any way whether my laptop is plugged in
or not.
Monday, 30 September 2013
is it true that $\det(I+A)=?iso-8859-1?Q?=3E0$_=2C_if_$\det?=(A)=?iso-8859-1?Q?=3E0$=3F_=96_math.stackexchange.com?=
is it true that $\det(I+A)>0$ , if $\det(A)>0$? – math.stackexchange.com
I saw an inequality for $n\times n$ matrices. I was wondering if the
inequality is true or not? Does $\det(A)>0$ imply $\det(I+A)>0$?
I saw an inequality for $n\times n$ matrices. I was wondering if the
inequality is true or not? Does $\det(A)>0$ imply $\det(I+A)>0$?
Can I use a written out logical connective=?iso-8859-1?Q?=2C_rather_than_a_symbol=3F_=96_tex.stackexchange.com?=
Can I use a written out logical connective, rather than a symbol? –
tex.stackexchange.com
My professor uses these really nice, written out, AND and IMPLIES, etc.,
symbols and I can't seem to figure out or find how he does it. I would
love to use them, rather than \wedge or \land. Is it …
tex.stackexchange.com
My professor uses these really nice, written out, AND and IMPLIES, etc.,
symbols and I can't seem to figure out or find how he does it. I would
love to use them, rather than \wedge or \land. Is it …
Showing a DIV only the first time a website is loaded with localStorage
Showing a DIV only the first time a website is loaded with localStorage
I am trying to make this work but I have some problems.. Like the title
says, I want a DIV to be showed only the first time a website is loaded. I
know how to do with PHP and Cookies, but I want it with the localStorage
function.
Here is my code:
<div id="loading_bg">
...
</div>
$(document).ready(function() {
localStorage.setItem('wasVisited', 1);
if (localStorage.wasVisidet !== undefined ) {
$("#loading_bg").css('display','none');
} else {
$("#loading_bg").delay(5000).fadeOut(500);
}
});
TY!
I am trying to make this work but I have some problems.. Like the title
says, I want a DIV to be showed only the first time a website is loaded. I
know how to do with PHP and Cookies, but I want it with the localStorage
function.
Here is my code:
<div id="loading_bg">
...
</div>
$(document).ready(function() {
localStorage.setItem('wasVisited', 1);
if (localStorage.wasVisidet !== undefined ) {
$("#loading_bg").css('display','none');
} else {
$("#loading_bg").delay(5000).fadeOut(500);
}
});
TY!
jquery mobile - json load image
jquery mobile - json load image
Hi very much a newbie to jquery. I am wnating to load a image as part of
my directory however struggling to get an idea of images to show that in
my sub directory ie images. Can this be done or should I restart!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery Mobile Web App</title>
<link href="jquery-mobile/jquery.mobile.structure-1.3.2.min.css"
rel="stylesheet" type="text/css"/>
<link href="jquery-mobile/jquery.mobile.theme-1.3.2.min.css"
rel="stylesheet" type="text/css"/>
<link href="jquery-mobile/jquery.mobile-1.3.2.min.css"
rel="stylesheet" type="text/css"/>
<script src="jquery-mobile/jquery-1.8.3.min.js"
type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.3.2.min.js"
type="text/javascript"></script>
<body>
<!-- Glossary -->
<div data-role="page" id="glossary" data-theme="b">
<div data-role="header">
<h3>Glossary</h3>
</div>
<div data-role="content">
<ul data-role='listview' data-inset='true' data-filter="true"
id='resultsList'>
<!-- keep empty for dynamically added items -->
</ul>
</div>
</div>
<!-- display -->
<div data-role="page" id="display">
<div data-role="header">
<h3>Name Goes Here</h3>
<a data-role="button" data-rel="back" data-icon="back">Back</a>
</div>
<div data-role="content" align="center" >
<div img id="image"> image</div>
<br>
<div id="definition">def should display</div>
<br>
<div id="ph">Ph should display</div>
<br>
<div id="website">website should display</div>
</div>
<script>
var json = {
"results": [{
"bus": "bus 1",
"image": "images\IMG_5831",
"definition": "def 1",
"ph": "phone 1",
"website": "https://www.google.com.au/",
"googlemap":"google 1"
}, {
"bus": "bus 2",
"image": "image",
"definition": "bus One",
"ph": "This is the definition for bus One",
"website": "00000000000",
"googlemap":"googlemap"
}, {
"bus": "bus 3",
"image": "image",
"definition": "bus One",
"ph": "This is the definition for bus One",
"website": "00000000000",
"googlemap":"googlemap"
}],
"ok": "true"
};
var currentItem = 0;
$('#glossary').on('pageinit', function() {
$.each(json.results, function(i, bus) {
$('#resultsList').append('<li><a href="#display">' +
bus.bus +'</a></li>')
});
$('#resultsList').listview('refresh');
$('#resultsList li').click(function() {
currentItem = $(this).index();
});
});
$('#display').on('pagebeforeshow', function() {
$(this).find('[data-role=header]
.ui-title').text(json.results[currentItem].bus);
$('#image').html(json.results[currentItem].image);
$('#definition').html(json.results[currentItem].definition);
$('#ph').html(json.results[currentItem].ph);
});
</script>
</body>
</html>
Hi very much a newbie to jquery. I am wnating to load a image as part of
my directory however struggling to get an idea of images to show that in
my sub directory ie images. Can this be done or should I restart!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery Mobile Web App</title>
<link href="jquery-mobile/jquery.mobile.structure-1.3.2.min.css"
rel="stylesheet" type="text/css"/>
<link href="jquery-mobile/jquery.mobile.theme-1.3.2.min.css"
rel="stylesheet" type="text/css"/>
<link href="jquery-mobile/jquery.mobile-1.3.2.min.css"
rel="stylesheet" type="text/css"/>
<script src="jquery-mobile/jquery-1.8.3.min.js"
type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.3.2.min.js"
type="text/javascript"></script>
<body>
<!-- Glossary -->
<div data-role="page" id="glossary" data-theme="b">
<div data-role="header">
<h3>Glossary</h3>
</div>
<div data-role="content">
<ul data-role='listview' data-inset='true' data-filter="true"
id='resultsList'>
<!-- keep empty for dynamically added items -->
</ul>
</div>
</div>
<!-- display -->
<div data-role="page" id="display">
<div data-role="header">
<h3>Name Goes Here</h3>
<a data-role="button" data-rel="back" data-icon="back">Back</a>
</div>
<div data-role="content" align="center" >
<div img id="image"> image</div>
<br>
<div id="definition">def should display</div>
<br>
<div id="ph">Ph should display</div>
<br>
<div id="website">website should display</div>
</div>
<script>
var json = {
"results": [{
"bus": "bus 1",
"image": "images\IMG_5831",
"definition": "def 1",
"ph": "phone 1",
"website": "https://www.google.com.au/",
"googlemap":"google 1"
}, {
"bus": "bus 2",
"image": "image",
"definition": "bus One",
"ph": "This is the definition for bus One",
"website": "00000000000",
"googlemap":"googlemap"
}, {
"bus": "bus 3",
"image": "image",
"definition": "bus One",
"ph": "This is the definition for bus One",
"website": "00000000000",
"googlemap":"googlemap"
}],
"ok": "true"
};
var currentItem = 0;
$('#glossary').on('pageinit', function() {
$.each(json.results, function(i, bus) {
$('#resultsList').append('<li><a href="#display">' +
bus.bus +'</a></li>')
});
$('#resultsList').listview('refresh');
$('#resultsList li').click(function() {
currentItem = $(this).index();
});
});
$('#display').on('pagebeforeshow', function() {
$(this).find('[data-role=header]
.ui-title').text(json.results[currentItem].bus);
$('#image').html(json.results[currentItem].image);
$('#definition').html(json.results[currentItem].definition);
$('#ph').html(json.results[currentItem].ph);
});
</script>
</body>
</html>
Sunday, 29 September 2013
Hide taxonomy from side panel
Hide taxonomy from side panel
Does anybody know how to hide a custom taxonomy from under the post type?
I have tried the following. 'public' => false 'show_ui' => false
While I can remove both with the above I cannot remove just the sidebar
taxonomy. I want the taxonomy to be available when adding a new post just
removed from the sidebar. Any help would be appreciated.
Does anybody know how to hide a custom taxonomy from under the post type?
I have tried the following. 'public' => false 'show_ui' => false
While I can remove both with the above I cannot remove just the sidebar
taxonomy. I want the taxonomy to be available when adding a new post just
removed from the sidebar. Any help would be appreciated.
Printing values in lists, and printing them reversed with spacing, intro to programming class
Printing values in lists, and printing them reversed with spacing, intro
to programming class
im doing my homework and ive for the most part accomplished what my
teacher asked for which is the following "Program #1: Write a program that
does the following in the order given:
On a single line, print the data values in reverse order.
On a single line, print the values in the list of divisor sums in reverse
order.
On a single line, print the values in the list of averages in reverse
order to 1 decimal place."
I did the main part of the homework but printing them in reverse, only
numbers, and with certain spacing is confusing me. Heres my code just in
case you wanna see, but i dont think its required, you can skip through
all this :
data = [12, 3, 24, 30, 9, 11, 21, 8] #Hard Coded
sumofdivisors = [ ] #Created empty list to
fill
averageofdivisorpairs = [ ] #Another Empty List
dn = 1 # this is just the
code i wrote so it will
i = 1 # fill the emptylist
titled sumofdivisors
print data # which takes the
divisors of each value
for numbers in data: # and sums them,
adding the total to
sum1 = 0 # the list, printing
the list at the end.
dn = 1 # how do i make the
list print these values
while dn <= numbers: # in reverse and only
the numbers? Im
if numbers % dn == 0 : # thinking it has to
do with negative
sum1 = sum1 + dn # indencies. but im
not sure
dn = dn + 1 #
sumofdivisors.append(sum1) #
print sumofdivisors
i = 0
size = len(sumofdivisors)
truesize = size - 1
sum2 = 0
while i < truesize :
sum2 = sumofdivisors[i] + sumofdivisors[i + 1]
avg = sum2 / float(2)
averageofdivisorpairs.append(avg)
i = i + 1
print averageofdivisorpairs # same here, how do
only the values in reverse
totalsum = 0
size = len(sumofdivisors)
i = 0
while i <= size-1 :
sum3 = sumofdivisors[i]
totalsum = totalsum + sum3
i = i + 1
print "total sum = ", totalsum
totalsum2 = 0
size = len(averageofdivisorpairs)
i = 0
while i <= size - 1 :
sum4 = averageofdivisorpairs[i]
totalsum2 = totalsum2 + sum4
avg2 = float(totalsum2) / size
i = i + 1
print "average of averages = %.2f" % (avg2)
We can only use the len() function and .append() function, no reverse sort
or any of that. The target output is supposed to look like : Your output
should look like this:
8 21 11 9 30 24 3 12
15 32 12 13 72 60 4 28
23.5 22.0 12.5 42.5 66.0 32.0 16.0
total sum = 236
average of averages = 30.64
Mines looks like this, its not reversed, its not only values, and its not
spaced correctly:
[12, 3, 24, 30, 9, 11, 21, 8]
[28, 4, 60, 72, 13, 12, 32, 15]
[16.0, 32.0, 66.0, 42.5, 12.5, 22.0, 23.5]
total sum = 236
average of averages = 30.64
Help would be appreciated. Thanks
to programming class
im doing my homework and ive for the most part accomplished what my
teacher asked for which is the following "Program #1: Write a program that
does the following in the order given:
On a single line, print the data values in reverse order.
On a single line, print the values in the list of divisor sums in reverse
order.
On a single line, print the values in the list of averages in reverse
order to 1 decimal place."
I did the main part of the homework but printing them in reverse, only
numbers, and with certain spacing is confusing me. Heres my code just in
case you wanna see, but i dont think its required, you can skip through
all this :
data = [12, 3, 24, 30, 9, 11, 21, 8] #Hard Coded
sumofdivisors = [ ] #Created empty list to
fill
averageofdivisorpairs = [ ] #Another Empty List
dn = 1 # this is just the
code i wrote so it will
i = 1 # fill the emptylist
titled sumofdivisors
print data # which takes the
divisors of each value
for numbers in data: # and sums them,
adding the total to
sum1 = 0 # the list, printing
the list at the end.
dn = 1 # how do i make the
list print these values
while dn <= numbers: # in reverse and only
the numbers? Im
if numbers % dn == 0 : # thinking it has to
do with negative
sum1 = sum1 + dn # indencies. but im
not sure
dn = dn + 1 #
sumofdivisors.append(sum1) #
print sumofdivisors
i = 0
size = len(sumofdivisors)
truesize = size - 1
sum2 = 0
while i < truesize :
sum2 = sumofdivisors[i] + sumofdivisors[i + 1]
avg = sum2 / float(2)
averageofdivisorpairs.append(avg)
i = i + 1
print averageofdivisorpairs # same here, how do
only the values in reverse
totalsum = 0
size = len(sumofdivisors)
i = 0
while i <= size-1 :
sum3 = sumofdivisors[i]
totalsum = totalsum + sum3
i = i + 1
print "total sum = ", totalsum
totalsum2 = 0
size = len(averageofdivisorpairs)
i = 0
while i <= size - 1 :
sum4 = averageofdivisorpairs[i]
totalsum2 = totalsum2 + sum4
avg2 = float(totalsum2) / size
i = i + 1
print "average of averages = %.2f" % (avg2)
We can only use the len() function and .append() function, no reverse sort
or any of that. The target output is supposed to look like : Your output
should look like this:
8 21 11 9 30 24 3 12
15 32 12 13 72 60 4 28
23.5 22.0 12.5 42.5 66.0 32.0 16.0
total sum = 236
average of averages = 30.64
Mines looks like this, its not reversed, its not only values, and its not
spaced correctly:
[12, 3, 24, 30, 9, 11, 21, 8]
[28, 4, 60, 72, 13, 12, 32, 15]
[16.0, 32.0, 66.0, 42.5, 12.5, 22.0, 23.5]
total sum = 236
average of averages = 30.64
Help would be appreciated. Thanks
error: expected primary-expression before ')' when passing function-pointer to a function
error: expected primary-expression before ')' when passing
function-pointer to a function
Following is the function that takes function prototype as an argument:
void callAdded(void (*unitAdded)(rates));
When I do:
callAdded((&ConverterProxy::unitAdded)(rates));
ConverterProxy::unitAdded is a static function and rates is a struct.
Why do I get that error?
function-pointer to a function
Following is the function that takes function prototype as an argument:
void callAdded(void (*unitAdded)(rates));
When I do:
callAdded((&ConverterProxy::unitAdded)(rates));
ConverterProxy::unitAdded is a static function and rates is a struct.
Why do I get that error?
Value of member of composite class using Reflection
Value of member of composite class using Reflection
I have a class which compose of multiple other classes.
class X
{
public string str;
}
class Y
{
public X x;
}
Now I know that using reflection you can get the value a direct member of
class Y but my doubt is that whether using reflection, can I get the value
of member of composite class i.e. str? Something like
y.GetType().GetProperty("x.str")
I have also tried y.GetType().GetNestedType("X") but it is giving me null
as output.
I have a class which compose of multiple other classes.
class X
{
public string str;
}
class Y
{
public X x;
}
Now I know that using reflection you can get the value a direct member of
class Y but my doubt is that whether using reflection, can I get the value
of member of composite class i.e. str? Something like
y.GetType().GetProperty("x.str")
I have also tried y.GetType().GetNestedType("X") but it is giving me null
as output.
Saturday, 28 September 2013
Page Refreshes even with a return false
Page Refreshes even with a return false
I am working on a simple HTML5 canvas exercise and ran into a bit of a
snag. I cannot get the page to stop refreshing even after a return false
in the checkAnswer function. I have searched high and low for the answer
and have tried a few different things, but nothing seems to work. Any
assistance would be greatly appreciated. I have created a JSFiddle here
http://jsfiddle.net/geekch1ck/ezSyf/
I also don't understand the "{"error": "Please use POST request"}" on
JSFiddle.
Thank you in advance for your help. I'm sure I'm missing something rather
simple, but I can't find it in any of the books or sites I've combed over.
Here is the code for those who don't want to mess with JSFiddle
function getRandInt (min, max){
return Math.floor(Math.random()*(max-min+1)) + min;
}
function checkAnswer(guess, answer){
if (guess == answer){
alert("Correct");
setTimeout(drawText(equation),3000);
return true;
}
else{
alert("Try Again");
return false;
}
}
function drawCanvas(equation){
//draw the Canvas
canvas = document.getElementById('myCanvas');
context = canvas.getContext('2d');
drawText(equation);
}
function drawText(equation){
//add the text to the canvas
context.font = '40pt Veranda';
context.fillText(equation, 50, 100);
}
$(document).ready(function(){
drawCanvas(equation);
$("form").submit(function(){
guess = document.getElementById("guess").value;
checkAnswer(guess, answer);
});
});
</script>
</head>
<body>
<canvas id = "myCanvas" width = "200" height = "200" style =
"border:1px solid #000000;">
</canvas>
<form action="">
<p>What is the answer? <input type = "text" id = "guess" name = "guess"></p>
</form>
</body>
</html>
I am working on a simple HTML5 canvas exercise and ran into a bit of a
snag. I cannot get the page to stop refreshing even after a return false
in the checkAnswer function. I have searched high and low for the answer
and have tried a few different things, but nothing seems to work. Any
assistance would be greatly appreciated. I have created a JSFiddle here
http://jsfiddle.net/geekch1ck/ezSyf/
I also don't understand the "{"error": "Please use POST request"}" on
JSFiddle.
Thank you in advance for your help. I'm sure I'm missing something rather
simple, but I can't find it in any of the books or sites I've combed over.
Here is the code for those who don't want to mess with JSFiddle
function getRandInt (min, max){
return Math.floor(Math.random()*(max-min+1)) + min;
}
function checkAnswer(guess, answer){
if (guess == answer){
alert("Correct");
setTimeout(drawText(equation),3000);
return true;
}
else{
alert("Try Again");
return false;
}
}
function drawCanvas(equation){
//draw the Canvas
canvas = document.getElementById('myCanvas');
context = canvas.getContext('2d');
drawText(equation);
}
function drawText(equation){
//add the text to the canvas
context.font = '40pt Veranda';
context.fillText(equation, 50, 100);
}
$(document).ready(function(){
drawCanvas(equation);
$("form").submit(function(){
guess = document.getElementById("guess").value;
checkAnswer(guess, answer);
});
});
</script>
</head>
<body>
<canvas id = "myCanvas" width = "200" height = "200" style =
"border:1px solid #000000;">
</canvas>
<form action="">
<p>What is the answer? <input type = "text" id = "guess" name = "guess"></p>
</form>
</body>
</html>
How write java batchprocess running from tomcat
How write java batchprocess running from tomcat
I'm writing spring web application that is running on TomCat.7 and one of
functionality will be a processing data from db using java.concurrency.
I expect that db processing will be a very time dealing because of
calculations, and I need high performance for this process.
My question is if it is good idea (or maybe only possibility) to run that
thread in TomCat container?
@RequestMapping(value = "run_process", method = RequestMethod.GET)
public RequestWrapper runProcess(ModelMap model) {
Runnable runCrawler = new Crawler();
runCrawler.run();
System.out.println("##run_process!");
return new RequestWrapper();
}
My project structure is like:
-src
-com.scanner.batchprocess
-com.scanner.crawler
-com.scanner.webapp.controllers
I don't have any experience in creating programs that are challenging
computationally, so I'm afraid that maybe I should create new clean java
project with main class that will be called from webapp whenever user run
BatchProcess. Can be a significant time difference in execution time
application from Tomcat than True java application?
I'm writing spring web application that is running on TomCat.7 and one of
functionality will be a processing data from db using java.concurrency.
I expect that db processing will be a very time dealing because of
calculations, and I need high performance for this process.
My question is if it is good idea (or maybe only possibility) to run that
thread in TomCat container?
@RequestMapping(value = "run_process", method = RequestMethod.GET)
public RequestWrapper runProcess(ModelMap model) {
Runnable runCrawler = new Crawler();
runCrawler.run();
System.out.println("##run_process!");
return new RequestWrapper();
}
My project structure is like:
-src
-com.scanner.batchprocess
-com.scanner.crawler
-com.scanner.webapp.controllers
I don't have any experience in creating programs that are challenging
computationally, so I'm afraid that maybe I should create new clean java
project with main class that will be called from webapp whenever user run
BatchProcess. Can be a significant time difference in execution time
application from Tomcat than True java application?
Spring+hiberntae java.lang.StackOverflowError
Spring+hiberntae java.lang.StackOverflowError
I'm new in Hibernate and facing the problem:
@Transactional(readOnly=true)
@Override
public List<User> fetchListUsers() {
return sessionFactory.getCurrentSession().createQuery("select u from
User u").list();
}
My use.hbm.xml
<hibernate-mapping>
<class name="demidov.pkg.domain.User" table="USER_DESC">
<!-- Primary key ID will be generated depends on database
configuration -->
<id name="userId" column="ID">
<generator class="native"></generator>
</id>
<property name="userName" column="USER_NAME" unique="true" />
<property name="userPassword" column="USER_PASS" />
<property name="userPriveleges" column="USER_PRIVLG" />
<property name="userEmale" column="USER_EMALE" unique="true"/>
<property name="userGender" column="USER_GENDER" />
<!-- User is owner of relationships, all changes on user will
effect UserMessage entity -->
<set name="userMessageList" inverse="true" lazy="false"
fetch="select">
<key>
<column name="USER_ID" not-null="true"/>
</key>
<one-to-many class="demidov.pkg.domain.UserMessage" />
</set>
</class>
</hibernate-mapping>
UserMessage.hbm.xml
<hibernate-mapping>
<class name="demidov.pkg.domain.UserMessage" table="MESSAGES_CONTENT">
<id name="messageId" column="ID">
<generator class="native"></generator>
</id>
<property name="theMessage" column="MESSAGE" length="400"/>
<many-to-one name="theUser" class="demidov.pkg.domain.User"
lazy="false" fetch="select" cascade="all">
<column name="USER_ID" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>
Class with Main:
public static void main(String[] args) {
ApplicationContext context = new
ClassPathXmlApplicationContext("classpath:spring-context.xml");
GuestBookDAOIF gustDAO = (GuestBookDAOIF)
context.getBean("guestBookDAOImpl", GuestBookDAOIF.class);
List<User> uList = gustDAO.fetchListUsers();
for(User u : uList)
System.out.println(u);
}
Error stack:
Hibernate: select usermessag0_.ID as ID1_0_, usermessag0_.MESSAGE as
MESSAGE2_0_, usermessag0_.USER_ID as USER_ID3_0_ from MESSAGES_CONTENT
usermessag0_
Hibernate: select user0_.ID as ID1_1_0_, user0_.USER_NAME as
USER_NAM2_1_0_, user0_.USER_PASS as USER_PAS3_1_0_, user0_.USER_PRIVLG as
USER_PRI4_1_0_, user0_.USER_EMALE as USER_EMA5_1_0_, user0_.USER_GENDER as
USER_GEN6_1_0_ from USER_DESC user0_ where user0_.ID=?
Hibernate: select user0_.ID as ID1_1_0_, user0_.USER_NAME as
USER_NAM2_1_0_, user0_.USER_PASS as USER_PAS3_1_0_, user0_.USER_PRIVLG as
USER_PRI4_1_0_, user0_.USER_EMALE as USER_EMA5_1_0_, user0_.USER_GENDER as
USER_GEN6_1_0_ from USER_DESC user0_ where user0_.ID=?
Hibernate: select user0_.ID as ID1_1_0_, user0_.USER_NAME as
USER_NAM2_1_0_, user0_.USER_PASS as USER_PAS3_1_0_, user0_.USER_PRIVLG as
USER_PRI4_1_0_, user0_.USER_EMALE as USER_EMA5_1_0_, user0_.USER_GENDER as
USER_GEN6_1_0_ from USER_DESC user0_ where user0_.ID=?
Hibernate: select usermessag0_.USER_ID as USER_ID3_1_1_, usermessag0_.ID
as ID1_0_1_, usermessag0_.ID as ID1_0_0_, usermessag0_.MESSAGE as
MESSAGE2_0_0_, usermessag0_.USER_ID as USER_ID3_0_0_ from MESSAGES_CONTENT
usermessag0_ where usermessag0_.USER_ID=?
Hibernate: select usermessag0_.USER_ID as USER_ID3_1_1_, usermessag0_.ID
as ID1_0_1_, usermessag0_.ID as ID1_0_0_, usermessag0_.MESSAGE as
MESSAGE2_0_0_, usermessag0_.USER_ID as USER_ID3_0_0_ from MESSAGES_CONTENT
usermessag0_ where usermessag0_.USER_ID=?
Hibernate: select usermessag0_.USER_ID as USER_ID3_1_1_, usermessag0_.ID
as ID1_0_1_, usermessag0_.ID as ID1_0_0_, usermessag0_.MESSAGE as
MESSAGE2_0_0_, usermessag0_.USER_ID as USER_ID3_0_0_ from MESSAGES_CONTENT
usermessag0_ where usermessag0_.USER_ID=?
Exception in thread "main" java.lang.StackOverflowError
at java.util.HashMap.keySet(HashMap.java:1000)
at java.util.HashSet.iterator(HashSet.java:170)
at java.util.AbstractCollection.toString(AbstractCollection.java:450)
at
org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:327)
at java.lang.String.valueOf(String.java:2854)
at java.lang.StringBuilder.append(StringBuilder.java:128)
at demidov.pkg.domain.User.toString(User.java:95)
at java.lang.String.valueOf(String.java:2854) ....
My toString from UserMessage
@Override
public String toString() {
return "UserMessage [messageId=" + messageId + ", theMessage="
+ theMessage + ", theUser=" + theUser + "]";
}
My toString from User
@Override
public String toString() {
return "User [userId=" + userId + ", userName=" + userName
+ ", userPassword=" + userPassword + ", userPriveleges="
+ userPriveleges + ", userEmale=" + userEmale + ",
userGender="
+ userGender + ", userMessageList=" + userMessageList + "]";
}
Please help me to understand why I'm having this error. Some time I have
failed to lazily initialize a collection of role:
demidov.pkg.domain.User.userMessageList, could not initialize proxy - no
Session if i switch lazy to true. Please help me to understand what's
going on.
Thank you.
I'm new in Hibernate and facing the problem:
@Transactional(readOnly=true)
@Override
public List<User> fetchListUsers() {
return sessionFactory.getCurrentSession().createQuery("select u from
User u").list();
}
My use.hbm.xml
<hibernate-mapping>
<class name="demidov.pkg.domain.User" table="USER_DESC">
<!-- Primary key ID will be generated depends on database
configuration -->
<id name="userId" column="ID">
<generator class="native"></generator>
</id>
<property name="userName" column="USER_NAME" unique="true" />
<property name="userPassword" column="USER_PASS" />
<property name="userPriveleges" column="USER_PRIVLG" />
<property name="userEmale" column="USER_EMALE" unique="true"/>
<property name="userGender" column="USER_GENDER" />
<!-- User is owner of relationships, all changes on user will
effect UserMessage entity -->
<set name="userMessageList" inverse="true" lazy="false"
fetch="select">
<key>
<column name="USER_ID" not-null="true"/>
</key>
<one-to-many class="demidov.pkg.domain.UserMessage" />
</set>
</class>
</hibernate-mapping>
UserMessage.hbm.xml
<hibernate-mapping>
<class name="demidov.pkg.domain.UserMessage" table="MESSAGES_CONTENT">
<id name="messageId" column="ID">
<generator class="native"></generator>
</id>
<property name="theMessage" column="MESSAGE" length="400"/>
<many-to-one name="theUser" class="demidov.pkg.domain.User"
lazy="false" fetch="select" cascade="all">
<column name="USER_ID" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>
Class with Main:
public static void main(String[] args) {
ApplicationContext context = new
ClassPathXmlApplicationContext("classpath:spring-context.xml");
GuestBookDAOIF gustDAO = (GuestBookDAOIF)
context.getBean("guestBookDAOImpl", GuestBookDAOIF.class);
List<User> uList = gustDAO.fetchListUsers();
for(User u : uList)
System.out.println(u);
}
Error stack:
Hibernate: select usermessag0_.ID as ID1_0_, usermessag0_.MESSAGE as
MESSAGE2_0_, usermessag0_.USER_ID as USER_ID3_0_ from MESSAGES_CONTENT
usermessag0_
Hibernate: select user0_.ID as ID1_1_0_, user0_.USER_NAME as
USER_NAM2_1_0_, user0_.USER_PASS as USER_PAS3_1_0_, user0_.USER_PRIVLG as
USER_PRI4_1_0_, user0_.USER_EMALE as USER_EMA5_1_0_, user0_.USER_GENDER as
USER_GEN6_1_0_ from USER_DESC user0_ where user0_.ID=?
Hibernate: select user0_.ID as ID1_1_0_, user0_.USER_NAME as
USER_NAM2_1_0_, user0_.USER_PASS as USER_PAS3_1_0_, user0_.USER_PRIVLG as
USER_PRI4_1_0_, user0_.USER_EMALE as USER_EMA5_1_0_, user0_.USER_GENDER as
USER_GEN6_1_0_ from USER_DESC user0_ where user0_.ID=?
Hibernate: select user0_.ID as ID1_1_0_, user0_.USER_NAME as
USER_NAM2_1_0_, user0_.USER_PASS as USER_PAS3_1_0_, user0_.USER_PRIVLG as
USER_PRI4_1_0_, user0_.USER_EMALE as USER_EMA5_1_0_, user0_.USER_GENDER as
USER_GEN6_1_0_ from USER_DESC user0_ where user0_.ID=?
Hibernate: select usermessag0_.USER_ID as USER_ID3_1_1_, usermessag0_.ID
as ID1_0_1_, usermessag0_.ID as ID1_0_0_, usermessag0_.MESSAGE as
MESSAGE2_0_0_, usermessag0_.USER_ID as USER_ID3_0_0_ from MESSAGES_CONTENT
usermessag0_ where usermessag0_.USER_ID=?
Hibernate: select usermessag0_.USER_ID as USER_ID3_1_1_, usermessag0_.ID
as ID1_0_1_, usermessag0_.ID as ID1_0_0_, usermessag0_.MESSAGE as
MESSAGE2_0_0_, usermessag0_.USER_ID as USER_ID3_0_0_ from MESSAGES_CONTENT
usermessag0_ where usermessag0_.USER_ID=?
Hibernate: select usermessag0_.USER_ID as USER_ID3_1_1_, usermessag0_.ID
as ID1_0_1_, usermessag0_.ID as ID1_0_0_, usermessag0_.MESSAGE as
MESSAGE2_0_0_, usermessag0_.USER_ID as USER_ID3_0_0_ from MESSAGES_CONTENT
usermessag0_ where usermessag0_.USER_ID=?
Exception in thread "main" java.lang.StackOverflowError
at java.util.HashMap.keySet(HashMap.java:1000)
at java.util.HashSet.iterator(HashSet.java:170)
at java.util.AbstractCollection.toString(AbstractCollection.java:450)
at
org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:327)
at java.lang.String.valueOf(String.java:2854)
at java.lang.StringBuilder.append(StringBuilder.java:128)
at demidov.pkg.domain.User.toString(User.java:95)
at java.lang.String.valueOf(String.java:2854) ....
My toString from UserMessage
@Override
public String toString() {
return "UserMessage [messageId=" + messageId + ", theMessage="
+ theMessage + ", theUser=" + theUser + "]";
}
My toString from User
@Override
public String toString() {
return "User [userId=" + userId + ", userName=" + userName
+ ", userPassword=" + userPassword + ", userPriveleges="
+ userPriveleges + ", userEmale=" + userEmale + ",
userGender="
+ userGender + ", userMessageList=" + userMessageList + "]";
}
Please help me to understand why I'm having this error. Some time I have
failed to lazily initialize a collection of role:
demidov.pkg.domain.User.userMessageList, could not initialize proxy - no
Session if i switch lazy to true. Please help me to understand what's
going on.
Thank you.
Html.lablefor to display empty instead of column name in case model.Columnname value is NULL
Html.lablefor to display empty instead of column name in case
model.Columnname value is NULL
Am trying to display the value in razor view from model using the below code
@Html.LabelFor(m=>m.testId, Model.testId)
Which displays the value of testId from DB which renders as
<label for="LeadTimeText_DTD">12</label>
But incase the testID is null am getting the column name in label display
<label for="LeadTimeText_DTD">testId</label>
Where i want to display nothing like below in case if testID is null
<label for="LeadTimeText_DTD"></label>
is there any other way i do with HTML helper ? what i am doing wrong ?
model.Columnname value is NULL
Am trying to display the value in razor view from model using the below code
@Html.LabelFor(m=>m.testId, Model.testId)
Which displays the value of testId from DB which renders as
<label for="LeadTimeText_DTD">12</label>
But incase the testID is null am getting the column name in label display
<label for="LeadTimeText_DTD">testId</label>
Where i want to display nothing like below in case if testID is null
<label for="LeadTimeText_DTD"></label>
is there any other way i do with HTML helper ? what i am doing wrong ?
Friday, 27 September 2013
extending Google Maps v3 Marker class
extending Google Maps v3 Marker class
I need some advice on how to add custom markers to google maps.. Not those
static.. Red pins.. I want to add divs that have a mouse over behavior. I
see few websites that have fully customized the maps including map
controller icons also. Please advice me on this.
I need some advice on how to add custom markers to google maps.. Not those
static.. Red pins.. I want to add divs that have a mouse over behavior. I
see few websites that have fully customized the maps including map
controller icons also. Please advice me on this.
Error (NoClassDefFoundErro) loading applet
Error (NoClassDefFoundErro) loading applet
I am using Netbeans 7.3, JRE 1.7.0_11, Java SE 7 update 40, on Mac 10.8.5.
I have created a JApplet GUI form which I have embedded in a applet tag
within a HTML doc, which I have created in a Java Wed application. We I
try to run in Safari I get the following error:
java.lang.NoClassDefFoundError org/jdesktop/layout/GroupLayout$Group
I have searched the net, it seems a common issue, ive found that some
people resolved this error by changing : Prefernecs-Java-GUI Builder -
Layout Generation Style from Automatic to Swing Layout Extension Library.
(from Automatic) & also tried importing swing.groupLayout but netbeans
flags as a unused import.
But I am still getting the same error. Any feedback appreciated.
I have also posted this same question on code ranch and submitted it to
netbeans forum but have had no luck to date.
Cheers
I am using Netbeans 7.3, JRE 1.7.0_11, Java SE 7 update 40, on Mac 10.8.5.
I have created a JApplet GUI form which I have embedded in a applet tag
within a HTML doc, which I have created in a Java Wed application. We I
try to run in Safari I get the following error:
java.lang.NoClassDefFoundError org/jdesktop/layout/GroupLayout$Group
I have searched the net, it seems a common issue, ive found that some
people resolved this error by changing : Prefernecs-Java-GUI Builder -
Layout Generation Style from Automatic to Swing Layout Extension Library.
(from Automatic) & also tried importing swing.groupLayout but netbeans
flags as a unused import.
But I am still getting the same error. Any feedback appreciated.
I have also posted this same question on code ranch and submitted it to
netbeans forum but have had no luck to date.
Cheers
Parsing nested Json objects without keys using Gson
Parsing nested Json objects without keys using Gson
I have a json with this format
{
"lines" : {
"0" : "Hammersmith & City",
"1" : "Circle"
},
"id" : "233",
"name" : "Shepherd's Bush Market"
}, {
"lines" : {
"0" : "Hammersmith & City",
"1" : "Circle"
},
"id" : "233",
"name" : "Shepherd's Bush Market"
}, {
"lines" : {
"0" : "Hammersmith & City",
"1" : "Circle"
},
"id" : "233",
"name" : "Shepherd's Bush Market"
}
Normally I could create an object like this
public class MyObject {
public String id;
public String name;
public Line[] lines;
public class Line {
public String key;
public String value;
}
}
And the Gson serializer would handle the parsing but in this case the
lines object doesn't have any keys/ids. I have tried using HashMaps and
Maps instead of inner classes but it doesn't work. Is there a way I can
parse this using Gson?
I have a json with this format
{
"lines" : {
"0" : "Hammersmith & City",
"1" : "Circle"
},
"id" : "233",
"name" : "Shepherd's Bush Market"
}, {
"lines" : {
"0" : "Hammersmith & City",
"1" : "Circle"
},
"id" : "233",
"name" : "Shepherd's Bush Market"
}, {
"lines" : {
"0" : "Hammersmith & City",
"1" : "Circle"
},
"id" : "233",
"name" : "Shepherd's Bush Market"
}
Normally I could create an object like this
public class MyObject {
public String id;
public String name;
public Line[] lines;
public class Line {
public String key;
public String value;
}
}
And the Gson serializer would handle the parsing but in this case the
lines object doesn't have any keys/ids. I have tried using HashMaps and
Maps instead of inner classes but it doesn't work. Is there a way I can
parse this using Gson?
Mutiple Dailog Box Prompts Depending On User Input
Mutiple Dailog Box Prompts Depending On User Input
Here's what I need to do: Ask the user how many quizzes he took. Then,
prompt the user for that many grades. When the user is done entering the
grades, tell him his average grade for all his quizzes. You don't know
what number the user will enter
For example, if the user says he took 3 quizzes, the prompts should say:
"Enter quiz grade 1: ", then "Enter quiz grade 2: ", then "Enter quiz
grade 3: "
This is as far I've gotten..I'm not sure how to prompt the user mutiple
times depending on how many quizzes the user took...
int numQuiz;
count = 1;
numQuiz = Integer.parseInt(JOptionPane.showInputDialog("How many quizzes
did you take?"));
do
{
} while (count != 0);
Here's what I need to do: Ask the user how many quizzes he took. Then,
prompt the user for that many grades. When the user is done entering the
grades, tell him his average grade for all his quizzes. You don't know
what number the user will enter
For example, if the user says he took 3 quizzes, the prompts should say:
"Enter quiz grade 1: ", then "Enter quiz grade 2: ", then "Enter quiz
grade 3: "
This is as far I've gotten..I'm not sure how to prompt the user mutiple
times depending on how many quizzes the user took...
int numQuiz;
count = 1;
numQuiz = Integer.parseInt(JOptionPane.showInputDialog("How many quizzes
did you take?"));
do
{
} while (count != 0);
DaoExample , Android Studio: R package does not exisists
DaoExample , Android Studio: R package does not exisists
I've just downloaded DaoExample from
https://github.com/greenrobot/greenDAO. After that, I copy grade/ and
gradlew/ from a HelloWorld project of Android Studio into DaoExample/
folder, then: ./gradlew build in my terminal.
but I get the error: R package does not exisists. Please, help me with
this problem.
I've just downloaded DaoExample from
https://github.com/greenrobot/greenDAO. After that, I copy grade/ and
gradlew/ from a HelloWorld project of Android Studio into DaoExample/
folder, then: ./gradlew build in my terminal.
but I get the error: R package does not exisists. Please, help me with
this problem.
Derby authentication fails with JPA project
Derby authentication fails with JPA project
Environment
A fresh install of :
Eclipse Kepler
GlassFish 3.1.2.2
Problem
I want to deploy a JPA web project to GlassFish. I have set up the
appropriate JDBC connection pool and resource to access a MySQL database.
I can ping both my pool and DerbyPool. I am also able to connect to Java
DB from inside Eclipse. However when I try to deploy my project, I get:
WARNING: RAR5038:Unexpected exception while creating resource for pool
DerbyPool. Exception : javax.resource.spi.ResourceAllocationException:
Connection could not be allocated because: Connection authentication
failure occurred. Reason: userid or password invalid.
WARNING: RAR5117 : Failed to obtain/create connection from connection pool
[ DerbyPool ]. Reason :
com.sun.appserv.connectors.internal.api.PoolingException: Connection could
not be allocated because: Connection authentication failure occurred.
Reason: userid or password invalid.
WARNING: RAR5114 : Error allocating connection : [Error in allocating a
connection. Cause: Connection could not be allocated because: Connection
authentication failure occurred. Reason: userid or password invalid.]
What could be the problem?
Environment
A fresh install of :
Eclipse Kepler
GlassFish 3.1.2.2
Problem
I want to deploy a JPA web project to GlassFish. I have set up the
appropriate JDBC connection pool and resource to access a MySQL database.
I can ping both my pool and DerbyPool. I am also able to connect to Java
DB from inside Eclipse. However when I try to deploy my project, I get:
WARNING: RAR5038:Unexpected exception while creating resource for pool
DerbyPool. Exception : javax.resource.spi.ResourceAllocationException:
Connection could not be allocated because: Connection authentication
failure occurred. Reason: userid or password invalid.
WARNING: RAR5117 : Failed to obtain/create connection from connection pool
[ DerbyPool ]. Reason :
com.sun.appserv.connectors.internal.api.PoolingException: Connection could
not be allocated because: Connection authentication failure occurred.
Reason: userid or password invalid.
WARNING: RAR5114 : Error allocating connection : [Error in allocating a
connection. Cause: Connection could not be allocated because: Connection
authentication failure occurred. Reason: userid or password invalid.]
What could be the problem?
Thursday, 26 September 2013
Using shell script store POSTGRESQL query on a variable
Using shell script store POSTGRESQL query on a variable
I want to store following postgreSQL query result in a variable. I am
writing command on the shell script.
psql -p $port -c "select pg_relation_size ('tableName')" postgres
I need variable to save the result on a file. I have tried following but
it is not working
var= 'psql -p $port -c "select pg_relation_size ('tableName')" '
I want to store following postgreSQL query result in a variable. I am
writing command on the shell script.
psql -p $port -c "select pg_relation_size ('tableName')" postgres
I need variable to save the result on a file. I have tried following but
it is not working
var= 'psql -p $port -c "select pg_relation_size ('tableName')" '
Wednesday, 25 September 2013
Hoe to Send Image taken from Android app to Django Server
Hoe to Send Image taken from Android app to Django Server
I have an Android app that is capturing photo and putting it in SD card
Now i want to send this picture to my Django Server through HTTP post i am
not getting how to convert this image to String(BASE 64) Format. any help
is appreciated. THanks in advance
I have an Android app that is capturing photo and putting it in SD card
Now i want to send this picture to my Django Server through HTTP post i am
not getting how to convert this image to String(BASE 64) Format. any help
is appreciated. THanks in advance
Thursday, 19 September 2013
Issue with git pull master is out of sync with origin master
Issue with git pull master is out of sync with origin master
These are the sequence of steps i have performed 1. committed my changes
in branch to local master (commit id dc9afg2k) 2. git fetch origin master
&& git merge origin master 3. git checkout master 4. git pull (this pulled
all recent changes) 5. git fetch origin master && git merge origin master
6. git reset --hard origin/master 7. git checkout branch 8. git blog
These are the sequence of steps i have performed 1. committed my changes
in branch to local master (commit id dc9afg2k) 2. git fetch origin master
&& git merge origin master 3. git checkout master 4. git pull (this pulled
all recent changes) 5. git fetch origin master && git merge origin master
6. git reset --hard origin/master 7. git checkout branch 8. git blog
Multiple submit buttons in partial view MVC3
Multiple submit buttons in partial view MVC3
I use a partial view. In it I have:
@using (Html.BeginForm("MyMethod", "MyController", FormMethod.Post))
{
<input type="submit" id="btn1" name="btnSubmit" value="Add record" />
<input type="submit" id="btn2" name="btnSubmit" value="Use record" />
}
Then in the Controller [HttpPost] method I have:
[HttpPost]
public ActionResult MyMethod(string btnSubmit)
{
...
}
The problem is the btnSubmit is always null. I tried calling this partial
view directly and it returns the right value.
Any idea how to fix this? Thanks in advance.
I use a partial view. In it I have:
@using (Html.BeginForm("MyMethod", "MyController", FormMethod.Post))
{
<input type="submit" id="btn1" name="btnSubmit" value="Add record" />
<input type="submit" id="btn2" name="btnSubmit" value="Use record" />
}
Then in the Controller [HttpPost] method I have:
[HttpPost]
public ActionResult MyMethod(string btnSubmit)
{
...
}
The problem is the btnSubmit is always null. I tried calling this partial
view directly and it returns the right value.
Any idea how to fix this? Thanks in advance.
IE and Firefox Displays Navigation Menu Differently
IE and Firefox Displays Navigation Menu Differently
I can not figure out why this page's navigation menu displays differently
in IE than Firefox and Chrome. I tried playing with the font color
importance levels and that helped, but then it had an adverse effect in
Chrome/Firefox. Can anyone help me diagnose or narrow down the problem?
This site is based off of a WordPress theme and runs on WP.
http://rolesvillees.wcpss.net/
I can not figure out why this page's navigation menu displays differently
in IE than Firefox and Chrome. I tried playing with the font color
importance levels and that helped, but then it had an adverse effect in
Chrome/Firefox. Can anyone help me diagnose or narrow down the problem?
This site is based off of a WordPress theme and runs on WP.
http://rolesvillees.wcpss.net/
Assembly instruction confusion, rrux.w and rrum.w
Assembly instruction confusion, rrux.w and rrum.w
I am currently reading a piece of assembly instructions and I see a
instruction: rrum.w and rrux.w keep coming up. I googled these two and did
not find anything on it. Can someone tell me what they do and how they are
used?
I am currently reading a piece of assembly instructions and I see a
instruction: rrum.w and rrux.w keep coming up. I googled these two and did
not find anything on it. Can someone tell me what they do and how they are
used?
How to change Magento's Soap Address Location to HTTPS
How to change Magento's Soap Address Location to HTTPS
I am trying to change our wsdl to use a secure URL as the end point. We
are using the V2, WSI Compliant API and this is the line I am trying to
change:
<soap:address location="http://mydomain.com/index.php/api/v2_soap/index/"/>
I want to change it to:
<soap:address location="https://mydomain.com/index.php/api/v2_soap/index/"/>
I really need to find out where the {{var wsdl}} is being passed in. I
have tried hard coding it in one place, but the way the wsdl is being
compiled (much like the config is generated), it appends the soap address
(and has both the secure and unsecure in the final product). That's not
really the way I wanted to do it, anyway. I'm wondering if there's a
design template that's driving all of this where I could declare a new
variable or reset the wsdl.url bit. I've tried changing some code (just to
see if this was the origin of the url) in
Mage_Api_Model_Server_V2_Adapter_Soap and
Mage_Api_Model_Server_Adapter_Soap to no avail. Does anybody have any
advice?
I am trying to change our wsdl to use a secure URL as the end point. We
are using the V2, WSI Compliant API and this is the line I am trying to
change:
<soap:address location="http://mydomain.com/index.php/api/v2_soap/index/"/>
I want to change it to:
<soap:address location="https://mydomain.com/index.php/api/v2_soap/index/"/>
I really need to find out where the {{var wsdl}} is being passed in. I
have tried hard coding it in one place, but the way the wsdl is being
compiled (much like the config is generated), it appends the soap address
(and has both the secure and unsecure in the final product). That's not
really the way I wanted to do it, anyway. I'm wondering if there's a
design template that's driving all of this where I could declare a new
variable or reset the wsdl.url bit. I've tried changing some code (just to
see if this was the origin of the url) in
Mage_Api_Model_Server_V2_Adapter_Soap and
Mage_Api_Model_Server_Adapter_Soap to no avail. Does anybody have any
advice?
KendoUI Hierarchy Grid shows wrong data
KendoUI Hierarchy Grid shows wrong data
I had a json, similar to the following:
$("#grid").kendoGrid({
editable:true,
columns: [
{ field: "name" },
{ field: "address" }
],
[
{
name: "Beverages",
address: "street 1",
products: [
{ name: "Tea", price: 20 },
{ name: "Coffee", price: 23 }
]
},
{
name: "Food",
address: "street 2",
products: [
{ name: "Ham", price: 32 },
{ name: "Bread", price:34 }
]
}
],
detailInit: function (e) {
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: e.data.products,
editable:true,
});
}
});
Those data I bring from sql server database. The master data load
correctly, but not the details. I do just what you see above. The first
record I select go well (any record I select first, doesn't matter it's de
first or last record in the grid). Then, any other go bad, or don't expand
or show this error message "Uncaught TypeError: undefined has no
properties". I could do a new database query and I guess that all be
working fine, but is more efficient if I bring all data in the first
request.
Any help it's welcome. Bye, Thx.
I had a json, similar to the following:
$("#grid").kendoGrid({
editable:true,
columns: [
{ field: "name" },
{ field: "address" }
],
[
{
name: "Beverages",
address: "street 1",
products: [
{ name: "Tea", price: 20 },
{ name: "Coffee", price: 23 }
]
},
{
name: "Food",
address: "street 2",
products: [
{ name: "Ham", price: 32 },
{ name: "Bread", price:34 }
]
}
],
detailInit: function (e) {
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: e.data.products,
editable:true,
});
}
});
Those data I bring from sql server database. The master data load
correctly, but not the details. I do just what you see above. The first
record I select go well (any record I select first, doesn't matter it's de
first or last record in the grid). Then, any other go bad, or don't expand
or show this error message "Uncaught TypeError: undefined has no
properties". I could do a new database query and I guess that all be
working fine, but is more efficient if I bring all data in the first
request.
Any help it's welcome. Bye, Thx.
AppDomain info from an assembly
AppDomain info from an assembly
I am trying to get an AppDomain's info for one of my reference assemblies.
I am aware of the fact that we can load an assembly at runtime and then
get that assembly to run in a separate AppDomain which we create. But, in
my case, there is a referred assembly (actually an AddIn) that runs in its
own domain. Please let me know, if I can get a reference to an existing
assembly and AppDomain for the referenced assembly using
System.Reflection.Assembly and System.AppDomain or Similar classes?
I am trying to get an AppDomain's info for one of my reference assemblies.
I am aware of the fact that we can load an assembly at runtime and then
get that assembly to run in a separate AppDomain which we create. But, in
my case, there is a referred assembly (actually an AddIn) that runs in its
own domain. Please let me know, if I can get a reference to an existing
assembly and AppDomain for the referenced assembly using
System.Reflection.Assembly and System.AppDomain or Similar classes?
Wednesday, 18 September 2013
what sip libraries are required for making a VoIP sip application for audio calling in ios
what sip libraries are required for making a VoIP sip application for
audio calling in ios
I wanted to develop a sip application to make calls through the server.I
don't have much idea how to implement libraries and use them and what all
libraries are easy to access in sip.Please help me
audio calling in ios
I wanted to develop a sip application to make calls through the server.I
don't have much idea how to implement libraries and use them and what all
libraries are easy to access in sip.Please help me
R- Several min values using ddply
R- Several min values using ddply
I have a df like this:
> head(datamelt)
TIMESTAMP ring dendro diameter ID Rain_mm_Tot year DOY
1373635 2013-05-02 00:00:00 1 1 3405 r1_1 0 2013 122
1373672 2013-05-02 00:15:00 1 1 3417 r1_1 0 2013 122
1373735 2013-05-02 00:30:00 1 1 3417 r1_1 0 2013 122
1373777 2013-05-02 00:45:00 1 1 3426 r1_1 0 2013 122
1373826 2013-05-02 01:00:00 1 1 3438 r1_1 0 2013 122
1373873 2013-05-02 01:15:00 1 1 3444 r1_1 0 2013 122
I used ddply to get the min diameter value for each of the year (DOY) in
each dendro (dendrometers) in two different ways: i) The first one do its
job, giving one value for each day and dendro. nrow(dailymin)=5784.
However, I don't know what it does when there are several min values in
one day, but in those cases it is not the result I need:
library(plyr)
dailymin <- ddply(datamelt, .(year,DOY,ring,dendro),
function(x)x[which.min(x$diameter), ])
ii) The second way returns several rows for each day if there are several
min values, which is OK. nrow(dailymin)=12634:
dailymin <- ddply(datamelt, .(year,DOY,ring,dendro),
function(x)x[x$diameter==min(x$diameter), ])
Here are my questions: - How is the i) way working when there are several
min values? - And more importantly, in the ii) way, when there are several
min values, how can I only have the min that happen further in time? For
example, image that for dendro #5 in ring #2 there are 3 min values in
3598mm diameter, happening at 13:15, 13:30 and 13:45. I would like to have
only the last one (13:45) and remove the others.
> str(dailymin$TIMESTAMP)
POSIXct[1:12634], format: "2013-05-02 13:45:00" "2013-05-02 08:45:00"
"2013-05-02 14:00:00" "2013-05-02 13:45:00" "2013-05-02 14:45:00" ...
Thanks
I have a df like this:
> head(datamelt)
TIMESTAMP ring dendro diameter ID Rain_mm_Tot year DOY
1373635 2013-05-02 00:00:00 1 1 3405 r1_1 0 2013 122
1373672 2013-05-02 00:15:00 1 1 3417 r1_1 0 2013 122
1373735 2013-05-02 00:30:00 1 1 3417 r1_1 0 2013 122
1373777 2013-05-02 00:45:00 1 1 3426 r1_1 0 2013 122
1373826 2013-05-02 01:00:00 1 1 3438 r1_1 0 2013 122
1373873 2013-05-02 01:15:00 1 1 3444 r1_1 0 2013 122
I used ddply to get the min diameter value for each of the year (DOY) in
each dendro (dendrometers) in two different ways: i) The first one do its
job, giving one value for each day and dendro. nrow(dailymin)=5784.
However, I don't know what it does when there are several min values in
one day, but in those cases it is not the result I need:
library(plyr)
dailymin <- ddply(datamelt, .(year,DOY,ring,dendro),
function(x)x[which.min(x$diameter), ])
ii) The second way returns several rows for each day if there are several
min values, which is OK. nrow(dailymin)=12634:
dailymin <- ddply(datamelt, .(year,DOY,ring,dendro),
function(x)x[x$diameter==min(x$diameter), ])
Here are my questions: - How is the i) way working when there are several
min values? - And more importantly, in the ii) way, when there are several
min values, how can I only have the min that happen further in time? For
example, image that for dendro #5 in ring #2 there are 3 min values in
3598mm diameter, happening at 13:15, 13:30 and 13:45. I would like to have
only the last one (13:45) and remove the others.
> str(dailymin$TIMESTAMP)
POSIXct[1:12634], format: "2013-05-02 13:45:00" "2013-05-02 08:45:00"
"2013-05-02 14:00:00" "2013-05-02 13:45:00" "2013-05-02 14:45:00" ...
Thanks
Adding buttons dynamically to JFrame or a layeredPane
Adding buttons dynamically to JFrame or a layeredPane
public ChessGameDemo(){
Dimension boardSize = new Dimension(600, 600);
// Using a Layered Pane
layeredPane = new JLayeredPane();
add(layeredPane);
layeredPane.setPreferredSize(new Dimension(700,700));
//Create a reset button that will reset the game
JButton button = new JButton("Reset");
button.setPreferredSize(new Dimension(50,50));
add(button,BorderLayout.EAST);
//Add the chessboard to the Layered Pane
chessBoard = new JPanel();
layeredPane.add(chessBoard, JLayeredPane.DEFAULT_LAYER);
chessBoard.setLayout( new GridLayout(8, 8) );
chessBoard.setPreferredSize( boardSize );
chessBoard.setBounds(0, 0, boardSize.width, boardSize.height);
for (int i = 0; i < 64; i++) {
JPanel square = new JPanel( new BorderLayout() );
chessBoard.add( square );
int row = (i / 8) % 2;
if (row == 0)
square.setBackground( i % 2 == 0 ? Color.blue : Color.white );
else
square.setBackground( i % 2 == 0 ? Color.white : Color.blue );
}
As you can see here, I am creating a chess board in a panel and adding
that to a layered pane, which in turn is part of the frame. The idea is to
have a menu bar and a couple of buttons to make it all look more
presentable. But when I try to add the button it captures the entire
height of the frame ignoring the dimension I have specified. I just see
one tall button stretching the entire height of the window/frame. What is
the mistake here? How do I add normal sized buttons dynamically here? that
sits well next to the chessboard?
public ChessGameDemo(){
Dimension boardSize = new Dimension(600, 600);
// Using a Layered Pane
layeredPane = new JLayeredPane();
add(layeredPane);
layeredPane.setPreferredSize(new Dimension(700,700));
//Create a reset button that will reset the game
JButton button = new JButton("Reset");
button.setPreferredSize(new Dimension(50,50));
add(button,BorderLayout.EAST);
//Add the chessboard to the Layered Pane
chessBoard = new JPanel();
layeredPane.add(chessBoard, JLayeredPane.DEFAULT_LAYER);
chessBoard.setLayout( new GridLayout(8, 8) );
chessBoard.setPreferredSize( boardSize );
chessBoard.setBounds(0, 0, boardSize.width, boardSize.height);
for (int i = 0; i < 64; i++) {
JPanel square = new JPanel( new BorderLayout() );
chessBoard.add( square );
int row = (i / 8) % 2;
if (row == 0)
square.setBackground( i % 2 == 0 ? Color.blue : Color.white );
else
square.setBackground( i % 2 == 0 ? Color.white : Color.blue );
}
As you can see here, I am creating a chess board in a panel and adding
that to a layered pane, which in turn is part of the frame. The idea is to
have a menu bar and a couple of buttons to make it all look more
presentable. But when I try to add the button it captures the entire
height of the frame ignoring the dimension I have specified. I just see
one tall button stretching the entire height of the window/frame. What is
the mistake here? How do I add normal sized buttons dynamically here? that
sits well next to the chessboard?
CSS 3 Level Dropdown Menu
CSS 3 Level Dropdown Menu
so I've having problems with a 3-layer css dropdown menu. Levels 1 and 2
work just fine, but three is not showing up properly, I would like level
three to branch to the right. Level three is the Anti-Matter and Deuterium
tabs that should come from the "Fuel" link.
I have a jsfiddle with my problem. For those of you who cannot get it to
work my code is below. http://jsfiddle.net/IanLueninghoener/fD9eF/
Thanks everyone!
Here's my html:
<div id="nav">
<ul>
<li id="firstNavItem"><a href="index.html">Home</li>
<li><a href="Warp.html">Warp</a>
<ul>
<li><a href="Warp-how-it-works.html">How it
works</a></li>
<li><a href="Warp-Engine.html">Warp Engine</a></li>
<li><a href="WarpFactors.html">Warp Factors</a></li>
<li><a href="">Fuel</a>
<ul>
<li><a
href="Anti-Matter.html">Anti-Matter</a></li>
<li><a
href="Deuterium.html">Deuterium</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="Fact-or-Fiction.html">Fact or Fiction</li>
<li><a href="StarTrek.html">Star Trek</a>
<ul>
<li><a href="Enterprise.html">Enterprise</a></li>
<li><a href="Voyager.html">Voyager</a></li>
</ul>
</li>
<li><a href="about.html">About</a></li>
</ul>
</div>
CSS:
/* Reset */
* {
margin:0px;
padding:0px;
}
.clearFix {
clear: both;
}
/* Container */
#container {
width: 960px;
margin: 50px auto;
}
/* Red */
/* Navigation First Level */
#nav{
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica
Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
font-size:15px;
}
#nav ul{
background:#000000;
height:35px;
list-style:none;
border: 3px solid #000000;
-webkit-border-radius: 6px;
}
#nav li{
float:left;
padding:0px;
}
#nav li a{
background:#000000;
display:block;
text-align:center;
text-decoration:none;
color:#fff;
line-height:35px;
padding:0px 25px;
-webkit-border-radius: 6px;
}
#nav li a:hover{
text-decoration:none;
background: #4873b1;
color:#FFFFFF;
-webkit-border-radius: 3px;
}
/* Navigation Second Level */
#nav li ul{
position:absolute;
background:#000000;
display:none;
height:auto;
width:210px;
-webkit-border-top-left-radius: 0px;
-webkit-border-top-right-radius: 0px;
margin-left:-3px;
}
#nav li:hover ul{
display:block;
}
#nav li li:hover {
font-weight: 800;
}
#nav li li {
display:block;
float:none;
width:210px;
}
#nav li ul a{
text-align:left;
display:block;
height:35px;
padding:0px 10px 0px 25px;
}
/* Red */
/* Navigation First Level */
#nav_red{
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica
Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
font-size:15px;
}
#nav_red ul{
background:#cfcfcf;
height:40px;
list-style:none;
}
#nav_red li{
float:left;
padding:0px;
}
#nav_red li a{
background:#cfcfcf;
display:block;
text-align:center;
text-decoration:none;
color:#333;
line-height:40px;
padding:0px 25px;
}
#nav_red li a:hover{
text-decoration:none;
background: #915fa6;
color:#FFFFFF;
}
/* Navigation Second Level */
#nav_red li ul{
position:absolute;
background:#000000;
display:none;
height:auto;
width:210px;
}
#nav_red li:hover ul{
display:block;
}
#nav_red li li:hover {
font-weight: 800;
}
#nav_red li li {
display:block;
float:none;
width:210px;
}
#nav_red li ul a{
text-align:left;
display:block;
height:40px;
padding:0px 10px 0px 25px;
}
/* Slim */
/* Navigation First Level */
#nav_slim{
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica
Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
font-size:14px;
}
#nav_slim ul{
background:#84b41f;
height:25px;
list-style:none;
border: 3px solid #84b41f;
-webkit-border-radius: 4px;
}
#nav_slim li{
float:left;
padding:0px;
}
#nav_slim li a{
background:#84b41f;
display:block;
text-align:center;
text-decoration:none;
color:#333;
line-height:25px;
padding:0px 25px;
-webkit-border-radius: 4px;
}
#nav_slim li a:hover{
text-decoration:none;
background: #315907;
color:#FFFFFF;
-webkit-border-radius: 2px;
}
/* Navigation Second Level */
#nav_slim li ul{
position:absolute;
background:#84b41f;
display:none;
height:auto;
width:210px;
-webkit-border-top-left-radius: 0px;
-webkit-border-top-right-radius: 0px;
margin-left:-3px;
}
#nav_slim li:hover ul{
display:block;
}
#nav_slim li li:hover {
font-weight: 800;
}
#nav_slim li li {
display:block;
float:none;
width:210px;
}
#nav_slim li ul a{
text-align:left;
display:block;
height:25px;
padding:0px 10px 0px 25px;
}
so I've having problems with a 3-layer css dropdown menu. Levels 1 and 2
work just fine, but three is not showing up properly, I would like level
three to branch to the right. Level three is the Anti-Matter and Deuterium
tabs that should come from the "Fuel" link.
I have a jsfiddle with my problem. For those of you who cannot get it to
work my code is below. http://jsfiddle.net/IanLueninghoener/fD9eF/
Thanks everyone!
Here's my html:
<div id="nav">
<ul>
<li id="firstNavItem"><a href="index.html">Home</li>
<li><a href="Warp.html">Warp</a>
<ul>
<li><a href="Warp-how-it-works.html">How it
works</a></li>
<li><a href="Warp-Engine.html">Warp Engine</a></li>
<li><a href="WarpFactors.html">Warp Factors</a></li>
<li><a href="">Fuel</a>
<ul>
<li><a
href="Anti-Matter.html">Anti-Matter</a></li>
<li><a
href="Deuterium.html">Deuterium</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="Fact-or-Fiction.html">Fact or Fiction</li>
<li><a href="StarTrek.html">Star Trek</a>
<ul>
<li><a href="Enterprise.html">Enterprise</a></li>
<li><a href="Voyager.html">Voyager</a></li>
</ul>
</li>
<li><a href="about.html">About</a></li>
</ul>
</div>
CSS:
/* Reset */
* {
margin:0px;
padding:0px;
}
.clearFix {
clear: both;
}
/* Container */
#container {
width: 960px;
margin: 50px auto;
}
/* Red */
/* Navigation First Level */
#nav{
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica
Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
font-size:15px;
}
#nav ul{
background:#000000;
height:35px;
list-style:none;
border: 3px solid #000000;
-webkit-border-radius: 6px;
}
#nav li{
float:left;
padding:0px;
}
#nav li a{
background:#000000;
display:block;
text-align:center;
text-decoration:none;
color:#fff;
line-height:35px;
padding:0px 25px;
-webkit-border-radius: 6px;
}
#nav li a:hover{
text-decoration:none;
background: #4873b1;
color:#FFFFFF;
-webkit-border-radius: 3px;
}
/* Navigation Second Level */
#nav li ul{
position:absolute;
background:#000000;
display:none;
height:auto;
width:210px;
-webkit-border-top-left-radius: 0px;
-webkit-border-top-right-radius: 0px;
margin-left:-3px;
}
#nav li:hover ul{
display:block;
}
#nav li li:hover {
font-weight: 800;
}
#nav li li {
display:block;
float:none;
width:210px;
}
#nav li ul a{
text-align:left;
display:block;
height:35px;
padding:0px 10px 0px 25px;
}
/* Red */
/* Navigation First Level */
#nav_red{
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica
Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
font-size:15px;
}
#nav_red ul{
background:#cfcfcf;
height:40px;
list-style:none;
}
#nav_red li{
float:left;
padding:0px;
}
#nav_red li a{
background:#cfcfcf;
display:block;
text-align:center;
text-decoration:none;
color:#333;
line-height:40px;
padding:0px 25px;
}
#nav_red li a:hover{
text-decoration:none;
background: #915fa6;
color:#FFFFFF;
}
/* Navigation Second Level */
#nav_red li ul{
position:absolute;
background:#000000;
display:none;
height:auto;
width:210px;
}
#nav_red li:hover ul{
display:block;
}
#nav_red li li:hover {
font-weight: 800;
}
#nav_red li li {
display:block;
float:none;
width:210px;
}
#nav_red li ul a{
text-align:left;
display:block;
height:40px;
padding:0px 10px 0px 25px;
}
/* Slim */
/* Navigation First Level */
#nav_slim{
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica
Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
font-size:14px;
}
#nav_slim ul{
background:#84b41f;
height:25px;
list-style:none;
border: 3px solid #84b41f;
-webkit-border-radius: 4px;
}
#nav_slim li{
float:left;
padding:0px;
}
#nav_slim li a{
background:#84b41f;
display:block;
text-align:center;
text-decoration:none;
color:#333;
line-height:25px;
padding:0px 25px;
-webkit-border-radius: 4px;
}
#nav_slim li a:hover{
text-decoration:none;
background: #315907;
color:#FFFFFF;
-webkit-border-radius: 2px;
}
/* Navigation Second Level */
#nav_slim li ul{
position:absolute;
background:#84b41f;
display:none;
height:auto;
width:210px;
-webkit-border-top-left-radius: 0px;
-webkit-border-top-right-radius: 0px;
margin-left:-3px;
}
#nav_slim li:hover ul{
display:block;
}
#nav_slim li li:hover {
font-weight: 800;
}
#nav_slim li li {
display:block;
float:none;
width:210px;
}
#nav_slim li ul a{
text-align:left;
display:block;
height:25px;
padding:0px 10px 0px 25px;
}
XTK - Add scalar field to vtk mesh
XTK - Add scalar field to vtk mesh
We want to associate scalars values to VTK mesh read from file. We know
that is possible to do this using FreeSurfer different curvature files -
CRV (as shown in example 12 -http://lessons.goxtk.com/12/ )
How to set the scalars from the vtk files (blocks PointData and CellData)?
If this is not possible, is there a way of directly setting the the scalar
array to the X.mesh (any examples) ?
Thanks and sorry for the bad english Paulo
We want to associate scalars values to VTK mesh read from file. We know
that is possible to do this using FreeSurfer different curvature files -
CRV (as shown in example 12 -http://lessons.goxtk.com/12/ )
How to set the scalars from the vtk files (blocks PointData and CellData)?
If this is not possible, is there a way of directly setting the the scalar
array to the X.mesh (any examples) ?
Thanks and sorry for the bad english Paulo
jQuery not showing image on click
jQuery not showing image on click
Can anyone advise on whats wrong here? all the images appear after button
click apart from div6 which doesnt show at all? Have I got code wrong on
dix6 somewhere, any help much appreciated!
Many thanks!
<!DOCTYPE html>
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(window).load(function () {
$("button").click(function () {
$("#div1").fadeIn();
$("#div2").fadeIn(2000);
$("#div3").fadeIn(3000);
$("#div4").fadeIn(5000);
$("#div5").fadeIn(7000);
$("#div6").animate({ left: '250px' });
});
});
</script>
</head>
<body>
<p>Demonstrate fadeIn() with different parameters.</p>
<button>Click to fade in boxes</button>
<br />
<br />
<div id="div1"style="display: none">
<a href="http://www.stackoverflow.com" title="go to link">
<img src="/images/myimage1.png" alt="about" width="150" height="75"
/></a>
</div>
<div id="div2" style="display: none">
<a href="http://www.stackoverflow.com" title="go to link">
<img src="/images/myimage2.png" alt="about" width="150" height="75"/></a>
</div>
<div id="div3" style="display: none">
<a href="http://www.stackoverflow.com" title="go to link">
<img src="/images/myimage3.png" alt="about" width="150" height="75"/></a>
</div>
<div id="div4" style="display: none">
<a href="http://www.stackoverflow.com" title="go to link">
<img src="/images/myimage4.png" alt="about" width="150" height="74"/></a>
</div>
<div id="div5" style="display: none">
<a href="http://www.stackoverflow.com" title="go to link">
<img src="/images/myimage5.png" alt="about" width="150" height="75"/></a>
</div>
<div id="div6" style="display: none">
<a href="http://www.stackoverflow.com" title="go to link">
<img src="/images/myimage6.png" alt="about" width="150" height="75"/></a>
</div>
</body>
Can anyone advise on whats wrong here? all the images appear after button
click apart from div6 which doesnt show at all? Have I got code wrong on
dix6 somewhere, any help much appreciated!
Many thanks!
<!DOCTYPE html>
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(window).load(function () {
$("button").click(function () {
$("#div1").fadeIn();
$("#div2").fadeIn(2000);
$("#div3").fadeIn(3000);
$("#div4").fadeIn(5000);
$("#div5").fadeIn(7000);
$("#div6").animate({ left: '250px' });
});
});
</script>
</head>
<body>
<p>Demonstrate fadeIn() with different parameters.</p>
<button>Click to fade in boxes</button>
<br />
<br />
<div id="div1"style="display: none">
<a href="http://www.stackoverflow.com" title="go to link">
<img src="/images/myimage1.png" alt="about" width="150" height="75"
/></a>
</div>
<div id="div2" style="display: none">
<a href="http://www.stackoverflow.com" title="go to link">
<img src="/images/myimage2.png" alt="about" width="150" height="75"/></a>
</div>
<div id="div3" style="display: none">
<a href="http://www.stackoverflow.com" title="go to link">
<img src="/images/myimage3.png" alt="about" width="150" height="75"/></a>
</div>
<div id="div4" style="display: none">
<a href="http://www.stackoverflow.com" title="go to link">
<img src="/images/myimage4.png" alt="about" width="150" height="74"/></a>
</div>
<div id="div5" style="display: none">
<a href="http://www.stackoverflow.com" title="go to link">
<img src="/images/myimage5.png" alt="about" width="150" height="75"/></a>
</div>
<div id="div6" style="display: none">
<a href="http://www.stackoverflow.com" title="go to link">
<img src="/images/myimage6.png" alt="about" width="150" height="75"/></a>
</div>
</body>
FileSharing Open, Edit and Save Only from mounted drive via localhost asp.net
FileSharing Open, Edit and Save Only from mounted drive via localhost asp.net
I need to create an asp.net application which can open files from a
mounted drive or folder on windows server, these file directory structure
should be viewed by accessing the server-url in ie or chrome etc... the
files should not be allowed to copy but should be able to opened by a
locally installed app for editing and the saved to the same location,
saveas option should be disabled Please let me know your suggestions..
Programming languages c#, asp.net
I need to create an asp.net application which can open files from a
mounted drive or folder on windows server, these file directory structure
should be viewed by accessing the server-url in ie or chrome etc... the
files should not be allowed to copy but should be able to opened by a
locally installed app for editing and the saved to the same location,
saveas option should be disabled Please let me know your suggestions..
Programming languages c#, asp.net
Tuesday, 17 September 2013
Focus on Modal Dialog (MFC)
Focus on Modal Dialog (MFC)
I create modal dialog like this :
CDialog dlg;
dlg.DoModal();
but when window opens I can access background windows of my program (move
them and close them) but I need focus only on my curent window. (I think
modal dialog shouldn't behave like this)
How can I do this?
I create modal dialog like this :
CDialog dlg;
dlg.DoModal();
but when window opens I can access background windows of my program (move
them and close them) but I need focus only on my curent window. (I think
modal dialog shouldn't behave like this)
How can I do this?
How to separate table rows with horizontal line programmatic-ally in android
How to separate table rows with horizontal line programmatic-ally in android
Created a table layout programmatically .it looks like this.
here i want to add horizontal line after each row,how to do it
programmatically. sample code to create table layout
ScrollView scrollView = new ScrollView(this);
TableLayout resultLayout = new TableLayout(this);
resultLayout.setStretchAllColumns(true);
resultLayout.setShrinkAllColumns(true);
TableRow tablerowMostRecentVehicle = new TableRow(this);
tablerowMostRecentVehicle.setGravity(Gravity.CENTER_HORIZONTAL);
TextView textViewMostRecentVehicle = new TextView(this);
textViewMostRecentVehicle.setText("Most Recent Vehicle Details");
textViewMostRecentVehicle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
textViewMostRecentVehicle.setTypeface(Typeface.SERIF, Typeface.BOLD);
tablerowMostRecentVehicle.addView(textViewMostRecentVehicle);
// ...
resultLayout.addView(tablerowMostRecentVehicle);
resultLayout.addView(tableRowRegistrationMark);
resultLayout.addView(tableRowMakeModel);
resultLayout.addView(tableRowColour);
resultLayout.addView(tableRowChasisNo);
resultLayout.addView(tableRowDateofFirstUse);
resultLayout.addView(tableRowTypeofFuel);
// ...
Created a table layout programmatically .it looks like this.
here i want to add horizontal line after each row,how to do it
programmatically. sample code to create table layout
ScrollView scrollView = new ScrollView(this);
TableLayout resultLayout = new TableLayout(this);
resultLayout.setStretchAllColumns(true);
resultLayout.setShrinkAllColumns(true);
TableRow tablerowMostRecentVehicle = new TableRow(this);
tablerowMostRecentVehicle.setGravity(Gravity.CENTER_HORIZONTAL);
TextView textViewMostRecentVehicle = new TextView(this);
textViewMostRecentVehicle.setText("Most Recent Vehicle Details");
textViewMostRecentVehicle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
textViewMostRecentVehicle.setTypeface(Typeface.SERIF, Typeface.BOLD);
tablerowMostRecentVehicle.addView(textViewMostRecentVehicle);
// ...
resultLayout.addView(tablerowMostRecentVehicle);
resultLayout.addView(tableRowRegistrationMark);
resultLayout.addView(tableRowMakeModel);
resultLayout.addView(tableRowColour);
resultLayout.addView(tableRowChasisNo);
resultLayout.addView(tableRowDateofFirstUse);
resultLayout.addView(tableRowTypeofFuel);
// ...
add value into NSMutableArray from UILabel
add value into NSMutableArray from UILabel
I don't know why I can't add value into NSMutableArray from UILabel.
I have this:
ViewController.h
- (IBAction)addPedido:(id)sender;
@property (strong, nonatomic) NSMutableArray *pedidoArray;
@property (strong, nonatomic) IBOutlet UIButton *btnBebida3;
@property (retain, nonatomic) IBOutlet UILabel *txtBebida3;
ViewController.m
@synthesize pedidoArray,btnBebida3,txtBebida3;
- (IBAction)addPedido:(id)sender {
NSString *teste = self.txtBebida3.text;
[pedidoArray addObject:teste];
NSLog(@"todos os valores: %@", pedidoArray);
}
Why when I click on the button my array is null?
tks
I don't know why I can't add value into NSMutableArray from UILabel.
I have this:
ViewController.h
- (IBAction)addPedido:(id)sender;
@property (strong, nonatomic) NSMutableArray *pedidoArray;
@property (strong, nonatomic) IBOutlet UIButton *btnBebida3;
@property (retain, nonatomic) IBOutlet UILabel *txtBebida3;
ViewController.m
@synthesize pedidoArray,btnBebida3,txtBebida3;
- (IBAction)addPedido:(id)sender {
NSString *teste = self.txtBebida3.text;
[pedidoArray addObject:teste];
NSLog(@"todos os valores: %@", pedidoArray);
}
Why when I click on the button my array is null?
tks
How to set a child association template using acts_as_api gem in Rails
How to set a child association template using acts_as_api gem in Rails
I'm working on a project that deals with Users and Events. An user can
create one or more events. Besides, several users can attend to one or
more events. My problem comes with this many-to-many relationship. I'm
using a join table to keep this. The entity is called Attenders and keeps
the id of a User and the corresponding Event which he/she is attending. Mi
problem comes when I try to send a JSON response through the index or show
controller in Rails. My (simplified) models are like this:
Event
class Event include Mongoid::Document
field :title, type: String
field :date, type: String
field :place, type: String
field :description, type: String
acts_as_api
include Templates::Event
include Templates::Attender
# ...
# VALIDATIONS
# ...
belongs_to :user
has_many :attendings, class_name: "Attender", inverse_of: :attendingTo
end
User
class User
include Mongoid::Document
authenticates_with_sorcery!
field :name, type: String
field :surname, type: String
field :email, type: String
field :gender, type: String
field :age, type: Integer
field :crypted_password, type: String
field :salt, type: String
field :password, type: String
field :password_confirmation, type: String
acts_as_api
include Templates::User
include Templates::Attender
# ...
# VALIDATIONS
# ...
has_many :events
has_many :attendances, class_name: "Attender", inverse_of: :attendanceOf
end
Attender
class Attender
include Mongoid::Document
acts_as_api
include Templates::User
include Templates::Event
include Templates::Attender
belongs_to :attendanceOf, class_name: "User", inverse_of: :attendances
belongs_to :attendingTo, class_name: "Event", inverse_of: :attendings
end
And now, my acts_as_api templates, separated in different files, are like
these:
Event
module Templates::Event
extend ActiveSupport::Concern
included do
api_accessible :embedded_event do |response|
response.add :id
response.add :title
response.add :date
response.add :place
response.add :description
end
api_accessible :general_event, :extend => :embedded_event do |response|
response.add :user_id
response.add :attendings, :template => :attender_event
end
end
end
User (counterpart)
Attender
module Templates::Attender
extend ActiveSupport::Concern
included do
api_accessible :attender_user do |response|
response.add :attendanceOf
end
api_accessible :attender_event do |response|
response.add :attendingTo
end
end
end
My index action of Rails controller is like this:
Events_controller
class EventsController < ApplicationController
self.responder = ActsAsApi::Responder
respond_to :json
def index
e = Event.all
respond_with e, :api_template => :general_event, status: :ok
end
# ...
# OTHER ACTIONS
# ...
end
Well, with all these, when I call my index action from my Ember
application (which except for this is working fine), the response that
Firefox console is returning me says:
NoMethodError in EventsController#index
undefined method `attendingTo' for #<Event:0xb61ac924>
I have tried several different combinations of my templates but I'm really
stuck on here. Any hand would be really useful on this. Thank you guys a
lot in advance.
I'm working on a project that deals with Users and Events. An user can
create one or more events. Besides, several users can attend to one or
more events. My problem comes with this many-to-many relationship. I'm
using a join table to keep this. The entity is called Attenders and keeps
the id of a User and the corresponding Event which he/she is attending. Mi
problem comes when I try to send a JSON response through the index or show
controller in Rails. My (simplified) models are like this:
Event
class Event include Mongoid::Document
field :title, type: String
field :date, type: String
field :place, type: String
field :description, type: String
acts_as_api
include Templates::Event
include Templates::Attender
# ...
# VALIDATIONS
# ...
belongs_to :user
has_many :attendings, class_name: "Attender", inverse_of: :attendingTo
end
User
class User
include Mongoid::Document
authenticates_with_sorcery!
field :name, type: String
field :surname, type: String
field :email, type: String
field :gender, type: String
field :age, type: Integer
field :crypted_password, type: String
field :salt, type: String
field :password, type: String
field :password_confirmation, type: String
acts_as_api
include Templates::User
include Templates::Attender
# ...
# VALIDATIONS
# ...
has_many :events
has_many :attendances, class_name: "Attender", inverse_of: :attendanceOf
end
Attender
class Attender
include Mongoid::Document
acts_as_api
include Templates::User
include Templates::Event
include Templates::Attender
belongs_to :attendanceOf, class_name: "User", inverse_of: :attendances
belongs_to :attendingTo, class_name: "Event", inverse_of: :attendings
end
And now, my acts_as_api templates, separated in different files, are like
these:
Event
module Templates::Event
extend ActiveSupport::Concern
included do
api_accessible :embedded_event do |response|
response.add :id
response.add :title
response.add :date
response.add :place
response.add :description
end
api_accessible :general_event, :extend => :embedded_event do |response|
response.add :user_id
response.add :attendings, :template => :attender_event
end
end
end
User (counterpart)
Attender
module Templates::Attender
extend ActiveSupport::Concern
included do
api_accessible :attender_user do |response|
response.add :attendanceOf
end
api_accessible :attender_event do |response|
response.add :attendingTo
end
end
end
My index action of Rails controller is like this:
Events_controller
class EventsController < ApplicationController
self.responder = ActsAsApi::Responder
respond_to :json
def index
e = Event.all
respond_with e, :api_template => :general_event, status: :ok
end
# ...
# OTHER ACTIONS
# ...
end
Well, with all these, when I call my index action from my Ember
application (which except for this is working fine), the response that
Firefox console is returning me says:
NoMethodError in EventsController#index
undefined method `attendingTo' for #<Event:0xb61ac924>
I have tried several different combinations of my templates but I'm really
stuck on here. Any hand would be really useful on this. Thank you guys a
lot in advance.
Keep search history (using JSON API)?
Keep search history (using JSON API)?
I have a search page, using a Json API. If the user runs many searches, I
want that when they press back the previous searches are still there. Like
using Google for example.
The search functionality is in a partial. This is the relevant part from
routeProvider:
$routeProvider. when('/', {templateUrl: '/partials/search.html',
reloadOnSearch: false}) ...
I had to add reloadOnSearch:false because of this.
So, well, now when I press back, the url in the navigation bar is updated
but the page is not updated.
Anyways, reloadOnSearch:true - given the case that I get that working -
would run the search again. I inspected the web traffic from Google and
they are not running the search again when I press back.
So... what do I have to do to keep these results in the navigation history?
I also found this thread about storing model data using a service. I think
this could be usable but I have no idea if it's a correct approach. Search
history sounds like something that should be built in. Maybe my code is
incorrect and it's not working because of that.
Thanks in advance.
I have a search page, using a Json API. If the user runs many searches, I
want that when they press back the previous searches are still there. Like
using Google for example.
The search functionality is in a partial. This is the relevant part from
routeProvider:
$routeProvider. when('/', {templateUrl: '/partials/search.html',
reloadOnSearch: false}) ...
I had to add reloadOnSearch:false because of this.
So, well, now when I press back, the url in the navigation bar is updated
but the page is not updated.
Anyways, reloadOnSearch:true - given the case that I get that working -
would run the search again. I inspected the web traffic from Google and
they are not running the search again when I press back.
So... what do I have to do to keep these results in the navigation history?
I also found this thread about storing model data using a service. I think
this could be usable but I have no idea if it's a correct approach. Search
history sounds like something that should be built in. Maybe my code is
incorrect and it's not working because of that.
Thanks in advance.
Code is not working when only one checkbox is checked
Code is not working when only one checkbox is checked
I'm trying to generate possible variations based on inputs element. This
is the HTML code I've:
<section id="choices_picker">
<ul>
<li><input type="checkbox" name="color" id="color_choice"
value="5"> Color</li>
<li><input type="checkbox" name="talla" id="talla_choice"
value="6"> Size</li>
</ul>
<div id="color_choice_5" style="">
<button type="button" class="button color">Add color</button>
</div>
<div id="talla_choice_6" style="display: none">
<button type="button" class="button talla">Add size</button>
</div>
<button type="button" class="button create-variation"
id="create-variation" style="">Create variation</button>
<section id="variations_holder" style="display: none">
</section>
</section>
I created this jsFiddle for testing purpose. The code works fine if I
check both color and size but if I mark just one it fails and I can't find
where the problem is, it's supposed that if I have two colors then I
should create variations for those two colors the same for size but isn't
working, any help? What I miss?
PS: Any improvement on code is welcome, I'm still learning jQuery
I'm trying to generate possible variations based on inputs element. This
is the HTML code I've:
<section id="choices_picker">
<ul>
<li><input type="checkbox" name="color" id="color_choice"
value="5"> Color</li>
<li><input type="checkbox" name="talla" id="talla_choice"
value="6"> Size</li>
</ul>
<div id="color_choice_5" style="">
<button type="button" class="button color">Add color</button>
</div>
<div id="talla_choice_6" style="display: none">
<button type="button" class="button talla">Add size</button>
</div>
<button type="button" class="button create-variation"
id="create-variation" style="">Create variation</button>
<section id="variations_holder" style="display: none">
</section>
</section>
I created this jsFiddle for testing purpose. The code works fine if I
check both color and size but if I mark just one it fails and I can't find
where the problem is, it's supposed that if I have two colors then I
should create variations for those two colors the same for size but isn't
working, any help? What I miss?
PS: Any improvement on code is welcome, I'm still learning jQuery
how to get the location and the color of a pixel in workspace by clicking with the mouse - Matlab
how to get the location and the color of a pixel in workspace by clicking
with the mouse - Matlab
I have some fiducial points in an image and I need the user to select the
first point and get the coordinates of that point and the colour vector in
workspace.
At the moment I have only found:
Data cursor, but it only gives the location, not the colour Impixel,
apparently should give both, but it is a bit confusing and it's not
working very well imroi only gives location too from what I've read
Can you please help me with this? Also, can the colour vector be in the
Lab colorspace? (transform the image first, and then click in the point?)
Many thanks! Hector
with the mouse - Matlab
I have some fiducial points in an image and I need the user to select the
first point and get the coordinates of that point and the colour vector in
workspace.
At the moment I have only found:
Data cursor, but it only gives the location, not the colour Impixel,
apparently should give both, but it is a bit confusing and it's not
working very well imroi only gives location too from what I've read
Can you please help me with this? Also, can the colour vector be in the
Lab colorspace? (transform the image first, and then click in the point?)
Many thanks! Hector
Sunday, 15 September 2013
Changing Zurb Foundation grid columns so padding is only on one side
Changing Zurb Foundation grid columns so padding is only on one side
Does anyone know if there is a setting to put the column-gutter to only
one side? Currently it adds half to each side of the column, so for
instance if you wanted a 14px column gutter, it would add 7px on each
side. This causes the first column in a row to have a 7px indentation.
I could hack it with extra CSS, but I would prefer to change it in default
settings if I can.
Thanks for any help.
Does anyone know if there is a setting to put the column-gutter to only
one side? Currently it adds half to each side of the column, so for
instance if you wanted a 14px column gutter, it would add 7px on each
side. This causes the first column in a row to have a 7px indentation.
I could hack it with extra CSS, but I would prefer to change it in default
settings if I can.
Thanks for any help.
How do I install pygame?
How do I install pygame?
I am using python 3.3.2 Shell.
I would like to know how to install pygame, there is something about
having to have the same version as your python compiler? There is no
pygame 3.3.2, and when i import pygame there is no module named pygame.
Thanks for helping out!
I am using python 3.3.2 Shell.
I would like to know how to install pygame, there is something about
having to have the same version as your python compiler? There is no
pygame 3.3.2, and when i import pygame there is no module named pygame.
Thanks for helping out!
NullReferenceException on downloading file from SkyDrive at Windows Phone 7 app
NullReferenceException on downloading file from SkyDrive at Windows Phone
7 app
I have app that should backup and restore it's database to SkyDrive. But
if I close app on uploading or downloading backup to/from SkyDrive using
"start" button (Fast Application Switching) and then return to app using
"back" button I catch unhandled NullReferenceException:
void RestoreFromSkyDrive() {
ShowProgress();
LiveConnectClient client = new LiveConnectClient(App.Session);
string id = string.Empty;
if (client != null) {
client.GetCompleted += (obj, args) => {
try {
List<object> items;
if (args != null && args.Result != null && args.Result["data"] !=
null)
items = args.Result["data"] as List<object>;
else
return;
foreach (object item in items) {
Dictionary<string, object> file = item as Dictionary<string,
object>;
// fileName is a name of backup-file
if (file != null && file["name"] != null &&
file["name"].ToString() == fileName) {
id = file["id"].ToString();
if (client != null) client.DownloadCompleted += new
EventHandler<LiveDownloadCompletedEventArgs>(client_DownloadCompleted);
if (client != null)
client.DownloadAsync(String.Format("{0}/content", id));
break;
}
}
}
catch (Exception ex) {
MessageBox.Show(ex.Message + " restore");
}
};
if (client != null) {
client.GetAsync("me/skydrive/files");
}
}
}
void client_DownloadCompleted(object sender,
LiveDownloadCompletedEventArgs e) {
try {
if (e.Error == null) {
Stream stream = e.Result;
using (IsolatedStorageFile storage =
IsolatedStorageFile.GetUserStoreForApplication()) {
var fileToSave = new IsolatedStorageFileStream(Constants.dbName,
FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None,
storage);
stream.CopyTo(fileToSave);
stream.Flush();
stream.Close();
fileToSave.Close();
}
}
else {
MessageBox.Show(e.Error.Message + " dcompleted mb");
}
}
catch (WebException ex) { MessageBox.Show(ex.Message + " dcompleted ex"); }
HideProgress();
}
I insert lot of checks for null but anyway I catch NullReferenceException.
I don't know what I can do with that.
PS: StackTrace with enabled CLR Exceptions:
System.Net.WebException occurred
Message=WebException
StackTrace:
at
System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult
asyncResult)
at
System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass2.<EndGetResponse>b__1(Object
sendState)
at
System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__0(Object
sendState)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo
rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object
parameters, CultureInfo culture, Boolean isBinderDefault, Assembly
caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at
System.Windows.Threading.Dispatcher.<>c__DisplayClass4.<FastInvoke>b__3()
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo
rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object
parameters, CultureInfo culture, Boolean isBinderDefault, Assembly
caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority
priority)
at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr
pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam&
pResult)
StackTrace with disabled CLR Exceptions:
System.NullReferenceException was unhandled
Message=NullReferenceException
StackTrace:
at
Microsoft.Live.Operations.DownloadOperation.CompleteOperation(Exception
error)
at Microsoft.Live.Operations.DownloadOperation.OnCancel()
at Microsoft.Live.Operations.WebOperation.OnGetWebResponse(IAsyncResult
ar)
at
System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassa.<InvokeGetResponseCallback>b__8(Object
state2)
at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPool.WorkItem.doWork(Object o)
at System.Threading.Timer.ring()
7 app
I have app that should backup and restore it's database to SkyDrive. But
if I close app on uploading or downloading backup to/from SkyDrive using
"start" button (Fast Application Switching) and then return to app using
"back" button I catch unhandled NullReferenceException:
void RestoreFromSkyDrive() {
ShowProgress();
LiveConnectClient client = new LiveConnectClient(App.Session);
string id = string.Empty;
if (client != null) {
client.GetCompleted += (obj, args) => {
try {
List<object> items;
if (args != null && args.Result != null && args.Result["data"] !=
null)
items = args.Result["data"] as List<object>;
else
return;
foreach (object item in items) {
Dictionary<string, object> file = item as Dictionary<string,
object>;
// fileName is a name of backup-file
if (file != null && file["name"] != null &&
file["name"].ToString() == fileName) {
id = file["id"].ToString();
if (client != null) client.DownloadCompleted += new
EventHandler<LiveDownloadCompletedEventArgs>(client_DownloadCompleted);
if (client != null)
client.DownloadAsync(String.Format("{0}/content", id));
break;
}
}
}
catch (Exception ex) {
MessageBox.Show(ex.Message + " restore");
}
};
if (client != null) {
client.GetAsync("me/skydrive/files");
}
}
}
void client_DownloadCompleted(object sender,
LiveDownloadCompletedEventArgs e) {
try {
if (e.Error == null) {
Stream stream = e.Result;
using (IsolatedStorageFile storage =
IsolatedStorageFile.GetUserStoreForApplication()) {
var fileToSave = new IsolatedStorageFileStream(Constants.dbName,
FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None,
storage);
stream.CopyTo(fileToSave);
stream.Flush();
stream.Close();
fileToSave.Close();
}
}
else {
MessageBox.Show(e.Error.Message + " dcompleted mb");
}
}
catch (WebException ex) { MessageBox.Show(ex.Message + " dcompleted ex"); }
HideProgress();
}
I insert lot of checks for null but anyway I catch NullReferenceException.
I don't know what I can do with that.
PS: StackTrace with enabled CLR Exceptions:
System.Net.WebException occurred
Message=WebException
StackTrace:
at
System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult
asyncResult)
at
System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass2.<EndGetResponse>b__1(Object
sendState)
at
System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__0(Object
sendState)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo
rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object
parameters, CultureInfo culture, Boolean isBinderDefault, Assembly
caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at
System.Windows.Threading.Dispatcher.<>c__DisplayClass4.<FastInvoke>b__3()
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo
rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object
parameters, CultureInfo culture, Boolean isBinderDefault, Assembly
caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority
priority)
at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr
pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam&
pResult)
StackTrace with disabled CLR Exceptions:
System.NullReferenceException was unhandled
Message=NullReferenceException
StackTrace:
at
Microsoft.Live.Operations.DownloadOperation.CompleteOperation(Exception
error)
at Microsoft.Live.Operations.DownloadOperation.OnCancel()
at Microsoft.Live.Operations.WebOperation.OnGetWebResponse(IAsyncResult
ar)
at
System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassa.<InvokeGetResponseCallback>b__8(Object
state2)
at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPool.WorkItem.doWork(Object o)
at System.Threading.Timer.ring()
How do I save a input String into a textfile with output messages?
How do I save a input String into a textfile with output messages?
Im trying to get 4 strings on terminal as output where you have to input
text and that text will be saved in a .txt file, but what happens is that
the strings which are supposed to output on terminal gets inputted in the
txt file. Here is my code
import easyIO.*;
class Birds {
public static void main(String[] args) {
In press = new In();
Out birds = new Out("birdfile.txt", true);
birds.out("Birds name: ");
String biName = press.inLine();
birds.out("Sex: ");
String biSex = press.inLine();
birds.out("Place for observation: ");
String plObs = press.inLine();
birds.out("Date of observation: ");
int date = press.inInt();
birds.close();
}
}
Does anyone know how i can get the Strings Birds name, Sex, Place for
observation, Date of observation as output on terminal then what you input
in the output gets saved in the textfile?
Because now the output messages gets saved in the textfile.
Not sure what i'm doing wrong here.
Thanks alot for help!
Im trying to get 4 strings on terminal as output where you have to input
text and that text will be saved in a .txt file, but what happens is that
the strings which are supposed to output on terminal gets inputted in the
txt file. Here is my code
import easyIO.*;
class Birds {
public static void main(String[] args) {
In press = new In();
Out birds = new Out("birdfile.txt", true);
birds.out("Birds name: ");
String biName = press.inLine();
birds.out("Sex: ");
String biSex = press.inLine();
birds.out("Place for observation: ");
String plObs = press.inLine();
birds.out("Date of observation: ");
int date = press.inInt();
birds.close();
}
}
Does anyone know how i can get the Strings Birds name, Sex, Place for
observation, Date of observation as output on terminal then what you input
in the output gets saved in the textfile?
Because now the output messages gets saved in the textfile.
Not sure what i'm doing wrong here.
Thanks alot for help!
Set different display rule for nested list
Set different display rule for nested list
(Hopefully) quick question:
I have an unordered list set to display:table and li set to display:table
cell, as I want the list to take up entire width of container div
regardless of how many list items there are. The problem is I want a
nested drop-down list to have a block display, so the items are under each
other. I've done this before by setting parent list to Block, floating
left, then setting the nested list to float:none.
I've tried a few things to set the nested list from table to block, but
it's not doing it for me!
And I missing something simple, or is this going to work the way I want?
Here's the HTML
<div id = "headernavcontainer">
<div id = "headernav">
<ul id = "mainnav">
<li><a class = "mainnav" href="index.html">Home</a></li>
<li><a class = "mainnav" href="#">Company</a>
<ul>
<li><a class = "subnav"
href="index.html">About Us</a></li>
<li><a class = "subnav"
href="#">Location</a></li>
<li><a class = "subnav"
href="#">Services</a></li>
</ul>
</li>
<li><a class = "mainnav" href="#">Employment</a></li>
<li><a class = "mainnav" href="#">Gallery</a></li>
<li><a class = "mainnav" href="#">Contact Us</a></li>
</ul>
</div>
</div>
And here's the CSS:
#headernavcontainer
{
width:100%;
height:50px;
background-color:gray;
margin:0;
padding:0;
}
#headernav
{
position:relative;
margin:0 auto;
padding:0;
width:960px;
background-color:gray;
}
#mainnav
{
list-style:none;
//float:left;
width:100%;
position:relative;
margin:0 auto;
padding:0;
display:table;
font-family:Century Gothic, sans-serif;
font-weight:bold;
font-size: .8em;
}
#mainnav li
{
//float:left;
margin:0;
padding:0;
position:relative;
line-height:50px;
margin-right:0;
display:table-cell;
border-right:1px #000 solid;
}
#mainnav li:nth-child(10)
{
border-right:none;
}
#mainnav a.mainnav
{
display:block;
color:#000;
background:#333;
text-decoration:none;
text-align:center;
//vertical-align:middle;
}
#mainnav a:hover
{
color:#fff;
background:red;
}
#mainnav ul
{
display:block !important;
//overflow:hidden;
background:#fff;
list-style:none;
position:absolute;
left:-9999px;
//vertical-align:middle;
background:green;
}
#mainanv ul li
{
//float:none;
//display:block;
display:block !important;
}
#mainnav li:hover ul
{
left:0;
//display:block;
}
And here's a jfiddle to help illustrate what I'm up to!
http://jsfiddle.net/cEw5k/
Thanks.
(Hopefully) quick question:
I have an unordered list set to display:table and li set to display:table
cell, as I want the list to take up entire width of container div
regardless of how many list items there are. The problem is I want a
nested drop-down list to have a block display, so the items are under each
other. I've done this before by setting parent list to Block, floating
left, then setting the nested list to float:none.
I've tried a few things to set the nested list from table to block, but
it's not doing it for me!
And I missing something simple, or is this going to work the way I want?
Here's the HTML
<div id = "headernavcontainer">
<div id = "headernav">
<ul id = "mainnav">
<li><a class = "mainnav" href="index.html">Home</a></li>
<li><a class = "mainnav" href="#">Company</a>
<ul>
<li><a class = "subnav"
href="index.html">About Us</a></li>
<li><a class = "subnav"
href="#">Location</a></li>
<li><a class = "subnav"
href="#">Services</a></li>
</ul>
</li>
<li><a class = "mainnav" href="#">Employment</a></li>
<li><a class = "mainnav" href="#">Gallery</a></li>
<li><a class = "mainnav" href="#">Contact Us</a></li>
</ul>
</div>
</div>
And here's the CSS:
#headernavcontainer
{
width:100%;
height:50px;
background-color:gray;
margin:0;
padding:0;
}
#headernav
{
position:relative;
margin:0 auto;
padding:0;
width:960px;
background-color:gray;
}
#mainnav
{
list-style:none;
//float:left;
width:100%;
position:relative;
margin:0 auto;
padding:0;
display:table;
font-family:Century Gothic, sans-serif;
font-weight:bold;
font-size: .8em;
}
#mainnav li
{
//float:left;
margin:0;
padding:0;
position:relative;
line-height:50px;
margin-right:0;
display:table-cell;
border-right:1px #000 solid;
}
#mainnav li:nth-child(10)
{
border-right:none;
}
#mainnav a.mainnav
{
display:block;
color:#000;
background:#333;
text-decoration:none;
text-align:center;
//vertical-align:middle;
}
#mainnav a:hover
{
color:#fff;
background:red;
}
#mainnav ul
{
display:block !important;
//overflow:hidden;
background:#fff;
list-style:none;
position:absolute;
left:-9999px;
//vertical-align:middle;
background:green;
}
#mainanv ul li
{
//float:none;
//display:block;
display:block !important;
}
#mainnav li:hover ul
{
left:0;
//display:block;
}
And here's a jfiddle to help illustrate what I'm up to!
http://jsfiddle.net/cEw5k/
Thanks.
How to get the message for audio that browser is not supported
How to get the message for audio that browser is not supported
I am using html5 audio. I have defined the audio tag from the below link.
when you open the below link in safari it will show the message browser is
not supported and when you open the link in ie it is showing differently.
I want the same message for ie also
http://jsfiddle.net/WMSsh/?
i have defined the code in html as
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
I am using html5 audio. I have defined the audio tag from the below link.
when you open the below link in safari it will show the message browser is
not supported and when you open the link in ie it is showing differently.
I want the same message for ie also
http://jsfiddle.net/WMSsh/?
i have defined the code in html as
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
Follow a javascript link with mechanize and python
Follow a javascript link with mechanize and python
I'm doing some web scraping and the project is almost done, except for I
need to click a javascript link and I can't work out how to with Python
and mechanize.
On one of the pages, a list of javascript links appear and I want to
follow them in turn, scrape some data, and repeat. I know mechanize
doesn't work with javascript but does anyone know a workaround? Here's the
code I use to isolate the links:
for Auth in iterAuths:
Auth = str(Auth.contents[0]).strip()
br.find_link(text=Auth)
now if I do 'br.follow_link(text=Auth)', I get an error 'urllib2.URLError: '.
If I do 'print br.click_link(text=Auth'), I get: ''
I just need to get through the link. Can anyone help?
I'm doing some web scraping and the project is almost done, except for I
need to click a javascript link and I can't work out how to with Python
and mechanize.
On one of the pages, a list of javascript links appear and I want to
follow them in turn, scrape some data, and repeat. I know mechanize
doesn't work with javascript but does anyone know a workaround? Here's the
code I use to isolate the links:
for Auth in iterAuths:
Auth = str(Auth.contents[0]).strip()
br.find_link(text=Auth)
now if I do 'br.follow_link(text=Auth)', I get an error 'urllib2.URLError: '.
If I do 'print br.click_link(text=Auth'), I get: ''
I just need to get through the link. Can anyone help?
Saturday, 14 September 2013
Normalizing audio signal
Normalizing audio signal
I want to reliably convert both recorded audio (through microphone) and
processed audio (WAV file) to the same discretized representations in
Python using specgram.
My process is as follows:
get raw samples (read from file or stream from mic)
perform some normalization (???)
perform FFT with windowing to generate spectrogram (plotting freq vs. time
with amplitude peaks)
discretize peaks in audio then memorize
Basically, by the time I get to the last discretization process I want to
as reliably as possible come to the same value in freq/time/amplitude
space for same song.
My problem is how do I account for volume (ie, the amplitudes of the
samples) being different in recorded and WAV-read audio?
My options for normalization (maybe?):
Divide all samples in window by mean before FFT
Detrend all samples in window before FFT
Divide all samples in window by max amplitude sample value (sensitive to
noise and outliers) before FFT
Divide all amplitudes in spectrogram by mean
How should I tackle this problem? I have almost no signal processing
knowledge or experience.
I want to reliably convert both recorded audio (through microphone) and
processed audio (WAV file) to the same discretized representations in
Python using specgram.
My process is as follows:
get raw samples (read from file or stream from mic)
perform some normalization (???)
perform FFT with windowing to generate spectrogram (plotting freq vs. time
with amplitude peaks)
discretize peaks in audio then memorize
Basically, by the time I get to the last discretization process I want to
as reliably as possible come to the same value in freq/time/amplitude
space for same song.
My problem is how do I account for volume (ie, the amplitudes of the
samples) being different in recorded and WAV-read audio?
My options for normalization (maybe?):
Divide all samples in window by mean before FFT
Detrend all samples in window before FFT
Divide all samples in window by max amplitude sample value (sensitive to
noise and outliers) before FFT
Divide all amplitudes in spectrogram by mean
How should I tackle this problem? I have almost no signal processing
knowledge or experience.
Grab the first word in a list that is found in a string. ( Python )
Grab the first word in a list that is found in a string. ( Python )
So, I have a list of words like so:
activationWords = ['cactus', 'cacti', 'rofl']
And I want to find any of those words and return the first word of any of
those words appearing in a random string. I'll use this string as an
example:
str = "Wow, rofl I found a cactus in a cacti pile."
As you can see with the above example string, the first instance of a word
in the list is "rofl". I want to be able to detect that and return the
word into a string that I can use to my discretion. How would I do this?
Keep in mind that that string is just an example. Each time I run this it
will be using a different string.
So, I have a list of words like so:
activationWords = ['cactus', 'cacti', 'rofl']
And I want to find any of those words and return the first word of any of
those words appearing in a random string. I'll use this string as an
example:
str = "Wow, rofl I found a cactus in a cacti pile."
As you can see with the above example string, the first instance of a word
in the list is "rofl". I want to be able to detect that and return the
word into a string that I can use to my discretion. How would I do this?
Keep in mind that that string is just an example. Each time I run this it
will be using a different string.
Android LinearLayout dynamic text struggle
Android LinearLayout dynamic text struggle
I want to achieve displaying 3 items next to each other
[ICON-and-text-inside] [Dynamic Text] [Dynamic List with dynamic width]
The following is my source
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:id="@+id/imageView"
android:src="@drawable/bullet_bg_36px"
android:scaleType="centerInside"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10."
android:id="@+id/textView"
android:layout_gravity="center"
android:textColor="#ffffff"
android:textStyle="bold"
android:textSize="14dp"/>
</FrameLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LongText1 - LongText2 - LongText3 - LongText4"
android:paddingLeft="10dp"
android:layout_gravity="center_vertical"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginTop="6dp"
android:measureWithLargestChild="false"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="??? reps"
android:textColor="#c2df00"
android:background="#000000"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:singleLine="true"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="with ??? lbs"
android:textColor="#c2df00"
android:background="#000000"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:singleLine="true"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
Which currently behaves like the following screenshot:
I want the middle [dynamic text] to wrap ONLY, while the first
(icon+textinside) and last (list) to display fully and properly.
Also if the middle text is not wide enough, then I want the list to be
displayed right after it.
I want to achieve displaying 3 items next to each other
[ICON-and-text-inside] [Dynamic Text] [Dynamic List with dynamic width]
The following is my source
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:id="@+id/imageView"
android:src="@drawable/bullet_bg_36px"
android:scaleType="centerInside"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10."
android:id="@+id/textView"
android:layout_gravity="center"
android:textColor="#ffffff"
android:textStyle="bold"
android:textSize="14dp"/>
</FrameLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LongText1 - LongText2 - LongText3 - LongText4"
android:paddingLeft="10dp"
android:layout_gravity="center_vertical"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginTop="6dp"
android:measureWithLargestChild="false"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="??? reps"
android:textColor="#c2df00"
android:background="#000000"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:singleLine="true"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="with ??? lbs"
android:textColor="#c2df00"
android:background="#000000"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:singleLine="true"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
Which currently behaves like the following screenshot:
I want the middle [dynamic text] to wrap ONLY, while the first
(icon+textinside) and last (list) to display fully and properly.
Also if the middle text is not wide enough, then I want the list to be
displayed right after it.
Using watch programs like Yeoman, CodeKit, LiveReload, etc. on enterprise level
Using watch programs like Yeoman, CodeKit, LiveReload, etc. on enterprise
level
I am trying to figure out how to use live refresh features such as Yeoman,
LiveReload, and Codekit do but on an actual live server.
My situation is that my team and I manage over 800+ websites and so as you
can imagine we don't keep local instances of each of these sites (except
for the files we are currently working on such as the LESS, CSS, JS etc.)
since we work on so many. Our process is to work Live on our staging
environment and then push to production when we are finished.
Another thing to note is that since we have such a large amount of sites
that we build/manage, we of course keep a "Core" logic base that houses
our frameworks of code for all sites to pull from. It's hard to explain
how we are doing things without showing, but the main thing i wanted to
impart was that we have much of our code packaged into dynamic sections
for reusability, so even though we all keep a local instance of our "Core"
code (that we manage with SmartSVN) it's not possible for me to run a
localhost instance of a site I'm working on since the HTML/JS/etc. is
loaded and parsed using our CMS's language (Velocity).
All this to say that.. is it possible for one of these mentioned programs
(Yeoman etc.) to communicate with our staging environment?..to watch files
that are not local to my computer? Or perhaps watch those files and auto
upload to our staging environment?
The CMS we use is called dotCMS, and it runs Apache.
I'm sorry if this was confusing. any info is welcome even if it's a
"You're an idiot" type of answer, I'd prefer to know if I'm being one or
not, but please at least explain why.
thanks
level
I am trying to figure out how to use live refresh features such as Yeoman,
LiveReload, and Codekit do but on an actual live server.
My situation is that my team and I manage over 800+ websites and so as you
can imagine we don't keep local instances of each of these sites (except
for the files we are currently working on such as the LESS, CSS, JS etc.)
since we work on so many. Our process is to work Live on our staging
environment and then push to production when we are finished.
Another thing to note is that since we have such a large amount of sites
that we build/manage, we of course keep a "Core" logic base that houses
our frameworks of code for all sites to pull from. It's hard to explain
how we are doing things without showing, but the main thing i wanted to
impart was that we have much of our code packaged into dynamic sections
for reusability, so even though we all keep a local instance of our "Core"
code (that we manage with SmartSVN) it's not possible for me to run a
localhost instance of a site I'm working on since the HTML/JS/etc. is
loaded and parsed using our CMS's language (Velocity).
All this to say that.. is it possible for one of these mentioned programs
(Yeoman etc.) to communicate with our staging environment?..to watch files
that are not local to my computer? Or perhaps watch those files and auto
upload to our staging environment?
The CMS we use is called dotCMS, and it runs Apache.
I'm sorry if this was confusing. any info is welcome even if it's a
"You're an idiot" type of answer, I'd prefer to know if I'm being one or
not, but please at least explain why.
thanks
How to use a notepad without listing notes in android?
How to use a notepad without listing notes in android?
I am looking for to create a notepad in android. But unlike other
available notepads for android, I want to create only one notepad with
only one text editing option. This notepad will have not title, just the
text editing section. Since there is only one note, there will be no list
of notes, and so there will be no ListActivity.
In the opening page, I want a button that will take the user to the note
editing page. This is the only way to view previously saved note as well
as adding/editing the note. There should be a save button which will
return to the opening page. No part of the original note will be displayed
in the opening page.
All the notepad samples use onListItemClick for editing notes. But since I
do not have more than one note, I do not have any list of notes, and so I
cannot use this.
I am new at android. Please help.
Thanks
I am looking for to create a notepad in android. But unlike other
available notepads for android, I want to create only one notepad with
only one text editing option. This notepad will have not title, just the
text editing section. Since there is only one note, there will be no list
of notes, and so there will be no ListActivity.
In the opening page, I want a button that will take the user to the note
editing page. This is the only way to view previously saved note as well
as adding/editing the note. There should be a save button which will
return to the opening page. No part of the original note will be displayed
in the opening page.
All the notepad samples use onListItemClick for editing notes. But since I
do not have more than one note, I do not have any list of notes, and so I
cannot use this.
I am new at android. Please help.
Thanks
passing different int value to BroadcastReceiver
passing different int value to BroadcastReceiver
i am new to Android and working on a app which take a int value from "if
statements".Now the 1st prob is m not getting how to send value to
broadcastReceiver and second is int value changes on "if " condition, now
how can i send the value that is stored according to the condition
i am new to Android and working on a app which take a int value from "if
statements".Now the 1st prob is m not getting how to send value to
broadcastReceiver and second is int value changes on "if " condition, now
how can i send the value that is stored according to the condition
Does the suffix L after a number always have the same effect as placing a parenthesis with "long" in it before the number?
Does the suffix L after a number always have the same effect as placing a
parenthesis with "long" in it before the number?
For instance, suppose int is 32 bits, is the type of 0xffffffffL really long?
The type of 0xffffffff is unsigned int, so I guess 0xffffffffL is unsigned
long rather than signed long.
Does it depend on whether long is 32 or 64 bits?
parenthesis with "long" in it before the number?
For instance, suppose int is 32 bits, is the type of 0xffffffffL really long?
The type of 0xffffffff is unsigned int, so I guess 0xffffffffL is unsigned
long rather than signed long.
Does it depend on whether long is 32 or 64 bits?
Friday, 13 September 2013
How to add element in element using jquery
How to add element in element using jquery
I have a code like this:
<p>Nuno</p>
<p>Eimes</p>
How i manipulate into like this:
<p><a href="name/Nuno">Nuno</a></p>
<p><a href="name/Eimes">Eimes</a></p>
i tried
var name=$(this).text();
$( "p" ).each(function() {
$(this).prepend('<a href="id/'+ $(this).text() +'"> ');
$(this).append("</a>");
});
but it result:
<p><a href="id/Nuno"> </a>Nuno</p>
<p><a href="id/Eimes"> </a>Eimes</p>
the <a> is not inside $('p').text(); also if i change to name. it didn't
show the value.
I have a code like this:
<p>Nuno</p>
<p>Eimes</p>
How i manipulate into like this:
<p><a href="name/Nuno">Nuno</a></p>
<p><a href="name/Eimes">Eimes</a></p>
i tried
var name=$(this).text();
$( "p" ).each(function() {
$(this).prepend('<a href="id/'+ $(this).text() +'"> ');
$(this).append("</a>");
});
but it result:
<p><a href="id/Nuno"> </a>Nuno</p>
<p><a href="id/Eimes"> </a>Eimes</p>
the <a> is not inside $('p').text(); also if i change to name. it didn't
show the value.
Maven dependency issue - artifact not found in central repo
Maven dependency issue - artifact not found in central repo
I'm trying to build the project from this site
-http://www.joptimizer.com/usage.html. I downloaded the sources jar file,
unpacked it and ran maven package in the root folder. maven fails at the
last minute saying it couldn't resolve the dependency.. could not find
artifact seventytwomiles:architecture-rules:jar:3.0.0-M1 in central repo -
repo.maven.apache.org/maven2 .. I have a feeling I might need to change
some thing in the pom.xml file for this to work, but have no idea what.
Googling for this missing dependency led me no where. In general, how
would one know what to do to handle such errors (and also please help with
this specific case).
I'm trying to build the project from this site
-http://www.joptimizer.com/usage.html. I downloaded the sources jar file,
unpacked it and ran maven package in the root folder. maven fails at the
last minute saying it couldn't resolve the dependency.. could not find
artifact seventytwomiles:architecture-rules:jar:3.0.0-M1 in central repo -
repo.maven.apache.org/maven2 .. I have a feeling I might need to change
some thing in the pom.xml file for this to work, but have no idea what.
Googling for this missing dependency led me no where. In general, how
would one know what to do to handle such errors (and also please help with
this specific case).
HttpWebRequest.Headers[HttpRequestHeader.Referer] failed with error
HttpWebRequest.Headers[HttpRequestHeader.Referer] failed with error
When I'm trying to set Referer header I'm getting the following error:
var request = (HttpWebRequest) WebRequest.Create(url);
request.Headers[HttpRequestHeader.Referer] = "http://somesite.com/";
"This header must be modified with the appropriate property"
But there is no "appropriate" property for Referer. What could be the reason?
TIA
When I'm trying to set Referer header I'm getting the following error:
var request = (HttpWebRequest) WebRequest.Create(url);
request.Headers[HttpRequestHeader.Referer] = "http://somesite.com/";
"This header must be modified with the appropriate property"
But there is no "appropriate" property for Referer. What could be the reason?
TIA
Please help me urgent.Microsoft.inertope.excel
Please help me urgent.Microsoft.inertope.excel
Please help me urgent. I have built window service in C#.net to read excel
file and store data into sql server. I have used
Micosoft.interop.excel.Now i install this on live server but there is no
office on live server .How i install PIA on live server without installing
Office 2007?
Please help me urgent. I have built window service in C#.net to read excel
file and store data into sql server. I have used
Micosoft.interop.excel.Now i install this on live server but there is no
office on live server .How i install PIA on live server without installing
Office 2007?
nested iterator struts2 - global variable
nested iterator struts2 - global variable
Hi I want to submit my form using struts2 hibernate 3 who contain nested
iterator but I can't diference between all attribute name i m traying to
use a global variable in my jsp lik that :
<% int i=0; %>
<form name="evalform" action="saveOrUpdateSousEval" method="post" >
<s:iterator value="CategListGrille" status="catgStatus">
<s:iterator value="type" status="typeStatus">
<s:iterator value="item" status="itemstatus" >
<s:textfield value="66"
name="%{'souseval[#i].SousEval_Note'}" />
<% i++; %>
</s:iterator>
</s:iterator>
</s:iterator>
<s:submit value="Evaluer" cssClass="btnsubmit" />
</div>
</form>
in my class Action i have this :
private ArrayList<SousEvaluation> souseval= new ArrayList<SousEvaluation>();
public String saveOrUpdate(){
System.out.println("enter saveOrUpdateEvalNote ok");
sousevaldao.saveOrUpdateSousEvaluation(souseval);
return SUCCESS;
}
and in my class Dao i have :
@Override
public void saveOrUpdateSousEvaluationNote(ArrayList<SousEvaluation>
sousevalnote) {
try {
for (Iterator<SousEvaluation> it = sousevalnote.iterator();
it.hasNext();) {
session.saveOrUpdate(it.next());
}
} catch (Exception e) {
transaction.rollback();
e.printStackTrace();
}
}
my goal is to submit many obect at once using my form
I can submit many record at once when i only use one iterator like that :
i make this exmape i's work fine
<form action="saveOrUpdateSousEval" method="post" >
<s:iterator begin="1" end="2" status="status">
<s:textfield
name="%{'souseval['+#status.index+'].SousEval_Note'}" />
<s:textfield
name="%{'souseval['+#status.index+'].evalglb.Eval_ID'}" />
<s:textfield
name="%{'souseval['+#status.index+'].sousEvalItem.SousItem_ID'}"
/>
</s:iterator>
<s:submit value="Evaluer" cssClass="btnsubmit" />
</form>
Hi I want to submit my form using struts2 hibernate 3 who contain nested
iterator but I can't diference between all attribute name i m traying to
use a global variable in my jsp lik that :
<% int i=0; %>
<form name="evalform" action="saveOrUpdateSousEval" method="post" >
<s:iterator value="CategListGrille" status="catgStatus">
<s:iterator value="type" status="typeStatus">
<s:iterator value="item" status="itemstatus" >
<s:textfield value="66"
name="%{'souseval[#i].SousEval_Note'}" />
<% i++; %>
</s:iterator>
</s:iterator>
</s:iterator>
<s:submit value="Evaluer" cssClass="btnsubmit" />
</div>
</form>
in my class Action i have this :
private ArrayList<SousEvaluation> souseval= new ArrayList<SousEvaluation>();
public String saveOrUpdate(){
System.out.println("enter saveOrUpdateEvalNote ok");
sousevaldao.saveOrUpdateSousEvaluation(souseval);
return SUCCESS;
}
and in my class Dao i have :
@Override
public void saveOrUpdateSousEvaluationNote(ArrayList<SousEvaluation>
sousevalnote) {
try {
for (Iterator<SousEvaluation> it = sousevalnote.iterator();
it.hasNext();) {
session.saveOrUpdate(it.next());
}
} catch (Exception e) {
transaction.rollback();
e.printStackTrace();
}
}
my goal is to submit many obect at once using my form
I can submit many record at once when i only use one iterator like that :
i make this exmape i's work fine
<form action="saveOrUpdateSousEval" method="post" >
<s:iterator begin="1" end="2" status="status">
<s:textfield
name="%{'souseval['+#status.index+'].SousEval_Note'}" />
<s:textfield
name="%{'souseval['+#status.index+'].evalglb.Eval_ID'}" />
<s:textfield
name="%{'souseval['+#status.index+'].sousEvalItem.SousItem_ID'}"
/>
</s:iterator>
<s:submit value="Evaluer" cssClass="btnsubmit" />
</form>
Doctest failed with zero exit code
Doctest failed with zero exit code
In my test code, my doctest fails but the script exit with a zero returns
value, which causes the CI run to pass and is not intended.
Is this the correct behavior of doctest module?
My script ends with:
if __name__ == '__main__':
import doctest
doctest.testmod()
In my test code, my doctest fails but the script exit with a zero returns
value, which causes the CI run to pass and is not intended.
Is this the correct behavior of doctest module?
My script ends with:
if __name__ == '__main__':
import doctest
doctest.testmod()
Thursday, 12 September 2013
how to display list of item under using tag
how to display list of item under using tag
I have emp list and which contain sub list called contactlist with one to
many mapping. I need to display list of items(contacts) under single tag
using for each like below:
the out should like below sample
Emp Name Emp email Contact Details
emp1 emp1.gmail.com 232323232 232323232 8999999999
emp2 emp2.gmail.com 232323232 232323232 8999999999
code below not working.it is not displaying under single column instead
displaying under multiple columns. as result disturbing layout.
<c:forEach items="${empmodel.contactList}" var="contacts">
<c:out value="${contacts.contactDetails}/><br/>
</c:forEach>
thank you...
I have emp list and which contain sub list called contactlist with one to
many mapping. I need to display list of items(contacts) under single tag
using for each like below:
the out should like below sample
Emp Name Emp email Contact Details
emp1 emp1.gmail.com 232323232 232323232 8999999999
emp2 emp2.gmail.com 232323232 232323232 8999999999
code below not working.it is not displaying under single column instead
displaying under multiple columns. as result disturbing layout.
<c:forEach items="${empmodel.contactList}" var="contacts">
<c:out value="${contacts.contactDetails}/><br/>
</c:forEach>
thank you...
ant: running phpcb after phpunit fails
ant: running phpcb after phpunit fails
In the recommended ant script for php, phpcb is given at the end since it
uses all log files made by phpcs, phpmd, phpunit, phpcpd etc. The issue is
my phpunit is not passing these days and phpcb wont run without all
previous processes are returning true and the build fails without phpcb.
So how to make phpcb run after all tools regardless of exit code?
In the recommended ant script for php, phpcb is given at the end since it
uses all log files made by phpcs, phpmd, phpunit, phpcpd etc. The issue is
my phpunit is not passing these days and phpcb wont run without all
previous processes are returning true and the build fails without phpcb.
So how to make phpcb run after all tools regardless of exit code?
Mapping together symbols to values then returning a procedure to look up a value ( racket )
Mapping together symbols to values then returning a procedure to look up a
value ( racket )
I have been stumped with this for a few days now. Here is what I'm trying
to do:
Let's say I have some list of symbols. Eg. '(A B C D). I want to map those
symbols to values. Let's say my values are '(1 2 3 4).
Alright now here's the goal. I want to write a procedure that will return
a procedure I can call again later. This is what I mean:
(define get-mapped-value (map-together symbols values))
(get-mapped-value 'A)
should return '1.
So far I have written a procedure to take two lists and "zip" them
together, basically mapping values. So given '(A B C D) and '(1 2 3 4) it
will return ((A 1)(B 2)(C 3) and so on.
And I also wrote a procedure that given a symbol will return its mapped
value. But I am having trouble tying this all up and being able to make
that definition. My most recent attempt was:
(define map-together
(case-lambda
[(symbols vals) (lambda (cons lst (zip-together keys vals))]
[(symbol) (find-mapped-value symbol)]
)
)
)
but that just returns the zipped list.
value ( racket )
I have been stumped with this for a few days now. Here is what I'm trying
to do:
Let's say I have some list of symbols. Eg. '(A B C D). I want to map those
symbols to values. Let's say my values are '(1 2 3 4).
Alright now here's the goal. I want to write a procedure that will return
a procedure I can call again later. This is what I mean:
(define get-mapped-value (map-together symbols values))
(get-mapped-value 'A)
should return '1.
So far I have written a procedure to take two lists and "zip" them
together, basically mapping values. So given '(A B C D) and '(1 2 3 4) it
will return ((A 1)(B 2)(C 3) and so on.
And I also wrote a procedure that given a symbol will return its mapped
value. But I am having trouble tying this all up and being able to make
that definition. My most recent attempt was:
(define map-together
(case-lambda
[(symbols vals) (lambda (cons lst (zip-together keys vals))]
[(symbol) (find-mapped-value symbol)]
)
)
)
but that just returns the zipped list.
AngularJS with $resource and custom formatter/parser directive not working
AngularJS with $resource and custom formatter/parser directive not working
Here's an example:
http://plnkr.co/edit/ezTUdoDKhCUGX3848VLp
HTML:
<p>Hello {{data | json}}!</p>
<div>
<textarea myconverter ng-model="data"></textarea>
</div>
JavaScript:
var app = angular.module('plunker', ['ngResource']);
app.controller('MainCtrl', function($scope, $resource) {
$scope.data = $resource('some-data.json').get({});
})
.directive('myconverter', function() {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, element, attr, ngModel) {
function fromJson(json) {
var out = JSON.stringify(json, null, 2);
return out;
}
function toJson(text) {
return JSON.parse(text);
}
ngModel.$parsers.push(toJson);
ngModel.$formatters.push(fromJson);
}
};
})
;
The simple Hello part works fine, when the AJAX call returns, it is
updated with the correct data. But the textarea is never updated. If I set
a breakpoint, it appears that it is given an object with no data (but I
can see the $resource methods). If I change the textarea to point to a
field of the "data" object, it works as expected.
Here's an example:
http://plnkr.co/edit/ezTUdoDKhCUGX3848VLp
HTML:
<p>Hello {{data | json}}!</p>
<div>
<textarea myconverter ng-model="data"></textarea>
</div>
JavaScript:
var app = angular.module('plunker', ['ngResource']);
app.controller('MainCtrl', function($scope, $resource) {
$scope.data = $resource('some-data.json').get({});
})
.directive('myconverter', function() {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, element, attr, ngModel) {
function fromJson(json) {
var out = JSON.stringify(json, null, 2);
return out;
}
function toJson(text) {
return JSON.parse(text);
}
ngModel.$parsers.push(toJson);
ngModel.$formatters.push(fromJson);
}
};
})
;
The simple Hello part works fine, when the AJAX call returns, it is
updated with the correct data. But the textarea is never updated. If I set
a breakpoint, it appears that it is given an object with no data (but I
can see the $resource methods). If I change the textarea to point to a
field of the "data" object, it works as expected.
null pointer exception calling a method
null pointer exception calling a method
I have 2 activities in my app, in the second one I have the code to run
when the "about" android action bar icon is clicked. In the first activity
I have the same action bar menu items and I want to call this "about"
method again, however when I click that, I have null Pointer exception.
Anyone help ?
this is the method defined in the second activity - JokeDetailsActivity
public void aboutMe(){
AlertDialog.Builder dialog = new
AlertDialog.Builder(JokeDetailsActivity.this);
dialog.setTitle("About");
dialog.setMessage("Hello! I'm ..., the creator of this application."
+"If there is any bug found please freely e-mail me. "+
"\n ...."
);
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
dialog.show();
}
when I call it in the first activity
case R.id.action_about:
JokeDetailsActivity jd = new JokeDetailsActivity();
jd.aboutMe();
return true;
}
thats the error I'm getting
09-12 20:11:42.748: E/AndroidRuntime(1032): FATAL EXCEPTION: main
09-12 20:11:42.748: E/AndroidRuntime(1032): java.lang.NullPointerException
09-12 20:11:42.748: E/AndroidRuntime(1032): at
android.content.ContextWrapper.getApplicationInfo(ContextWrapper.java:140)
09-12 20:11:42.748: E/AndroidRuntime(1032): at
android.view.ContextThemeWrapper.getTheme(ContextThemeWrapper.java:103)
09-12 20:11:42.748: E/AndroidRuntime(1032): at
android.app.AlertDialog.resolveDialogTheme(AlertDialog.java:143)
09-12 20:11:42.748: E/AndroidRuntime(1032): at
android.app.AlertDialog$Builder.<init>(AlertDialog.java:360)
09-12 20:11:42.748: E/AndroidRuntime(1032): at
ie.myjokes.JokeDetailsActivity.aboutMe(JokeDetailsActivity.java:293)
09-12 20:11:42.748: E/AndroidRuntime(1032): at
ie.myjokes.CategoryActivity.onOptionsItemSelected(CategoryActivity.java:140)
09-12 20:11:42.748: E/AndroidRuntime(1032): at
android.app.Activity.onMenuItemSelected(Activity.java:2548)
I have 2 activities in my app, in the second one I have the code to run
when the "about" android action bar icon is clicked. In the first activity
I have the same action bar menu items and I want to call this "about"
method again, however when I click that, I have null Pointer exception.
Anyone help ?
this is the method defined in the second activity - JokeDetailsActivity
public void aboutMe(){
AlertDialog.Builder dialog = new
AlertDialog.Builder(JokeDetailsActivity.this);
dialog.setTitle("About");
dialog.setMessage("Hello! I'm ..., the creator of this application."
+"If there is any bug found please freely e-mail me. "+
"\n ...."
);
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
dialog.show();
}
when I call it in the first activity
case R.id.action_about:
JokeDetailsActivity jd = new JokeDetailsActivity();
jd.aboutMe();
return true;
}
thats the error I'm getting
09-12 20:11:42.748: E/AndroidRuntime(1032): FATAL EXCEPTION: main
09-12 20:11:42.748: E/AndroidRuntime(1032): java.lang.NullPointerException
09-12 20:11:42.748: E/AndroidRuntime(1032): at
android.content.ContextWrapper.getApplicationInfo(ContextWrapper.java:140)
09-12 20:11:42.748: E/AndroidRuntime(1032): at
android.view.ContextThemeWrapper.getTheme(ContextThemeWrapper.java:103)
09-12 20:11:42.748: E/AndroidRuntime(1032): at
android.app.AlertDialog.resolveDialogTheme(AlertDialog.java:143)
09-12 20:11:42.748: E/AndroidRuntime(1032): at
android.app.AlertDialog$Builder.<init>(AlertDialog.java:360)
09-12 20:11:42.748: E/AndroidRuntime(1032): at
ie.myjokes.JokeDetailsActivity.aboutMe(JokeDetailsActivity.java:293)
09-12 20:11:42.748: E/AndroidRuntime(1032): at
ie.myjokes.CategoryActivity.onOptionsItemSelected(CategoryActivity.java:140)
09-12 20:11:42.748: E/AndroidRuntime(1032): at
android.app.Activity.onMenuItemSelected(Activity.java:2548)
Subscribe to:
Posts (Atom)