Why I should define a JLabel before a addActionListener?
I have one JLabel and one JButton into JFrame. I write code for
actionPerformed event of JButton like following:
btnOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
lblA.setText("Hello"); // error here
}
});
final JLabel lblA = new JLabel("");
but i get following error:
lblA cannot be resolved
however if I placed define of JLabel before addActionListener like
following my problem solved:
final JLabel lblA = new JLabel("");
btnOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
lblA.setText("Hello"); // error here
}
});
Thursday, 3 October 2013
Wednesday, 2 October 2013
Create class that reads in two names and outputs
Create class that reads in two names and outputs
Create a new program Reverse.java by creating a new class that reads in
two names and outputs them in reverse order. You will need two String
variables name0 and name1 and you will need to use two input dialog boxes.
Don't forget to add a space between the names in the output.
how can i do this?
ThX
Create a new program Reverse.java by creating a new class that reads in
two names and outputs them in reverse order. You will need two String
variables name0 and name1 and you will need to use two input dialog boxes.
Don't forget to add a space between the names in the output.
how can i do this?
ThX
Get value with jsoup from webpage
Get value with jsoup from webpage
I am new with Jsoup Current i want to get value of option but i can not.
Here is source of html page:
<div class="entrypost">
Xem nhanh:
<select onchange="window.location.href=this.value;">
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-1.html"
selected="selected"> Kim chi và củ cải phần
1</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-2.html"
>Kim chi và củ cải
phần 2</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-3.html"
>Kim chi và củ cải
phần 3</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-4.html"
>Kim chi và củ cải
phần 4</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-5.html"
>Kim chi và củ cải
phần 5</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-6.html"
>Kim chi và củ cải
phần 6</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-7.html"
>Kim chi và củ cải
phần 7</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-8.html"
>Kim chi và củ cải
phần 8</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-9.html"
>Kim chi và củ cải
phần 9</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-10.html"
>Kim Chi và Củ Cải
Phần 10</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-11.html"
>Kim Chi và Củ Cải
Phần 11</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-12.html"
>Kim Chi và Củ Cải
Phần 12</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-13.html"
>Kim Chi và Củ Cải
Phần 13</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-14.html"
>Kim Chi và Củ Cải
Phần 14</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-15.html"
>Kim Chi và Củ Cải
Phần 15</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-16.html"
>Kim Chi và Củ Cải
Phần 16</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-17.html"
>Kim Chi và Củ Cải
Phần 17</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-18.html"
>Kim Chi và Củ Cải
Phần 18</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-19.html"
>Kim Chi và Củ Cải
Phần 19</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-20.html"
>Kim Chi và Củ Cải
Phần 20</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-21.html"
>Kim Chi và Củ Cải
Phần 21</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-22.html"
>Kim Chi và Củ Cải
Phần 22</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-23.html"
>Kim Chi và Củ Cải
Phần 23</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-24.html"
>Kim Chi và Củ Cải
Phần 24</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-25.html"
>Kim Chi và Củ Cải
Phần 25</option>
Here is my code: Document doc =
Jsoup.parse("http://truyenhay.vn/kim-chi-va-cu-cai-phan-1.html");
// get all link
Elements elements1 = doc.select("option[value]");
Elements elements2 = elements1.select("value");
System.out.println("DDDDDDD " +elements1.size());
please help me if you can thanks a lot!
I am new with Jsoup Current i want to get value of option but i can not.
Here is source of html page:
<div class="entrypost">
Xem nhanh:
<select onchange="window.location.href=this.value;">
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-1.html"
selected="selected"> Kim chi và củ cải phần
1</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-2.html"
>Kim chi và củ cải
phần 2</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-3.html"
>Kim chi và củ cải
phần 3</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-4.html"
>Kim chi và củ cải
phần 4</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-5.html"
>Kim chi và củ cải
phần 5</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-6.html"
>Kim chi và củ cải
phần 6</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-7.html"
>Kim chi và củ cải
phần 7</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-8.html"
>Kim chi và củ cải
phần 8</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-9.html"
>Kim chi và củ cải
phần 9</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-10.html"
>Kim Chi và Củ Cải
Phần 10</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-11.html"
>Kim Chi và Củ Cải
Phần 11</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-12.html"
>Kim Chi và Củ Cải
Phần 12</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-13.html"
>Kim Chi và Củ Cải
Phần 13</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-14.html"
>Kim Chi và Củ Cải
Phần 14</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-15.html"
>Kim Chi và Củ Cải
Phần 15</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-16.html"
>Kim Chi và Củ Cải
Phần 16</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-17.html"
>Kim Chi và Củ Cải
Phần 17</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-18.html"
>Kim Chi và Củ Cải
Phần 18</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-19.html"
>Kim Chi và Củ Cải
Phần 19</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-20.html"
>Kim Chi và Củ Cải
Phần 20</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-21.html"
>Kim Chi và Củ Cải
Phần 21</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-22.html"
>Kim Chi và Củ Cải
Phần 22</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-23.html"
>Kim Chi và Củ Cải
Phần 23</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-24.html"
>Kim Chi và Củ Cải
Phần 24</option>
<option
value="http://truyenhay.vn/kim-chi-va-cu-cai-phan-25.html"
>Kim Chi và Củ Cải
Phần 25</option>
Here is my code: Document doc =
Jsoup.parse("http://truyenhay.vn/kim-chi-va-cu-cai-phan-1.html");
// get all link
Elements elements1 = doc.select("option[value]");
Elements elements2 = elements1.select("value");
System.out.println("DDDDDDD " +elements1.size());
please help me if you can thanks a lot!
HTTP status error
HTTP status error
I am using Eclipse Kepler wit Tom cat 7.0.12. I created a dynamic web
project consisting of a jsp named as index.jsp and it was working fine
before i renamed the index.jsp as oldindex.jsp and created one another
index.jsp. however since than I am in problem. each time i run my web
application within the eclipse using run at server i received following
error: HTTP status 404 /(name of folder of my created web project) type
status report description the requested resource (/my web project folder
name) is not available. I have created a new project from scratch even
than it returns same. than i delete the tom server and created new server
within the eclipse and created a new web dynamic project. however it did
n't work either. I can see the inside the eclipse the tomcat server is
running. any help as i have spent two days without any luck.
I am using Eclipse Kepler wit Tom cat 7.0.12. I created a dynamic web
project consisting of a jsp named as index.jsp and it was working fine
before i renamed the index.jsp as oldindex.jsp and created one another
index.jsp. however since than I am in problem. each time i run my web
application within the eclipse using run at server i received following
error: HTTP status 404 /(name of folder of my created web project) type
status report description the requested resource (/my web project folder
name) is not available. I have created a new project from scratch even
than it returns same. than i delete the tom server and created new server
within the eclipse and created a new web dynamic project. however it did
n't work either. I can see the inside the eclipse the tomcat server is
running. any help as i have spent two days without any luck.
Tuesday, 1 October 2013
horizontal layout Website like Myspace.com
horizontal layout Website like Myspace.com
I want to develop a horizontal layout Website like Myspace.com but for
each picture when you click on it, it does not go to another page but goes
to another section of this page ( it must be one page website)I need
advise for hoe i can handle that with css Html and jQuery ? I tried this
code :
<div id="menu">
<ul>
<li><a href="#home">Home</a>
</li>
<li><a href="#box1">History</a>
</li>
<li><a href="#box2">gallery</a>
</li>
</ul>
</div>
<div id="container">
<div id="header">
<h1>Burnham Beeches</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
eget eros libero. Fusce tempus quam sit amet erat mollis a
fermentum nibh imperdiet. Fusce iaculis sapien in turpis aliquet
porta. Donec tincidunt gravida tortor, vel dignissim augue
convallis sit amet. Aliquam auctor ornare accumsan.</p>
</div>
<div id="box1" class="box">
<h2><a name="box1">History</a></h2>
<img src="images/burnham-beeches-history-fullpage.jpg" />
</div>
<div id="box2" class="box">
<h2><a name="box2">Second Box</a></h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
eget eros libero. Fusce tempus quam sit amet erat mollis a
fermentum nibh imperdiet. Fusce iaculis sapien in turpis aliquet
porta. Donec tincidunt gravida tortor, vel dignissim augue
convallis sit amet. Aliquam auctor ornare accumsan. Cras convallis
elit tincidunt arcu semper egestas. Mauris interdum fringilla
nisi. Cras a dapibus lectus. Praesent blandit ullamcorper ornare.
Nam hendrerit sollicitudin urna non ultricies. Phasellus
condimentum auctor risus, at accumsan tellus tempor vel. Nunc
mattis eleifend dolor at adipiscing.</p>
</div>
</div>
but ineed to have pictures not text
I want to develop a horizontal layout Website like Myspace.com but for
each picture when you click on it, it does not go to another page but goes
to another section of this page ( it must be one page website)I need
advise for hoe i can handle that with css Html and jQuery ? I tried this
code :
<div id="menu">
<ul>
<li><a href="#home">Home</a>
</li>
<li><a href="#box1">History</a>
</li>
<li><a href="#box2">gallery</a>
</li>
</ul>
</div>
<div id="container">
<div id="header">
<h1>Burnham Beeches</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
eget eros libero. Fusce tempus quam sit amet erat mollis a
fermentum nibh imperdiet. Fusce iaculis sapien in turpis aliquet
porta. Donec tincidunt gravida tortor, vel dignissim augue
convallis sit amet. Aliquam auctor ornare accumsan.</p>
</div>
<div id="box1" class="box">
<h2><a name="box1">History</a></h2>
<img src="images/burnham-beeches-history-fullpage.jpg" />
</div>
<div id="box2" class="box">
<h2><a name="box2">Second Box</a></h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
eget eros libero. Fusce tempus quam sit amet erat mollis a
fermentum nibh imperdiet. Fusce iaculis sapien in turpis aliquet
porta. Donec tincidunt gravida tortor, vel dignissim augue
convallis sit amet. Aliquam auctor ornare accumsan. Cras convallis
elit tincidunt arcu semper egestas. Mauris interdum fringilla
nisi. Cras a dapibus lectus. Praesent blandit ullamcorper ornare.
Nam hendrerit sollicitudin urna non ultricies. Phasellus
condimentum auctor risus, at accumsan tellus tempor vel. Nunc
mattis eleifend dolor at adipiscing.</p>
</div>
</div>
but ineed to have pictures not text
Injecting html snippet with JQuery into existing html page
Injecting html snippet with JQuery into existing html page
I want to inject certain html snippet with JQuery into existing html page.
Existing snippet:
<table class="course hoverHighlight">
<tbody>...</tbody>
...
</table>
I want to inject:
<thead>
<tr>
<th class="title">Course</th>
<th class="author">Author</th>
<th class="level">Level</th>
<th class="rating">Rating</th>
<th class="duration">Duration</th>
<th class="releaseDate">Released</th>
</tr>
</thead>
before tbody tag.
<table class="course hoverHighlight">
<thead>...</thead>
<tbody>...</tbody>
</table>
I have tried this code but it didn`t work:
function() {
var theadInjection= $("<thead>
<tr>
<th class="title">course</th>
<th class="author">author</th>
<th class="level">level</th>
<th class="rating">rating</th>
<th class="duration">duration</th>
<th class="releasedate">released</th>
</tr>
</thead>");
$( '.course' ).prepend(theadInjection);
}
Simple injection like this one did work:
function() {
var theadInjection= $("<thead></thead>");
$( '.course' ).prepend(theadInjection);
Thanks.
I want to inject certain html snippet with JQuery into existing html page.
Existing snippet:
<table class="course hoverHighlight">
<tbody>...</tbody>
...
</table>
I want to inject:
<thead>
<tr>
<th class="title">Course</th>
<th class="author">Author</th>
<th class="level">Level</th>
<th class="rating">Rating</th>
<th class="duration">Duration</th>
<th class="releaseDate">Released</th>
</tr>
</thead>
before tbody tag.
<table class="course hoverHighlight">
<thead>...</thead>
<tbody>...</tbody>
</table>
I have tried this code but it didn`t work:
function() {
var theadInjection= $("<thead>
<tr>
<th class="title">course</th>
<th class="author">author</th>
<th class="level">level</th>
<th class="rating">rating</th>
<th class="duration">duration</th>
<th class="releasedate">released</th>
</tr>
</thead>");
$( '.course' ).prepend(theadInjection);
}
Simple injection like this one did work:
function() {
var theadInjection= $("<thead></thead>");
$( '.course' ).prepend(theadInjection);
Thanks.
Passing PCI Scan on apache 2.2.22
Passing PCI Scan on apache 2.2.22
We are on Ubuntu 12.04 and apache 2.2.2 version. We had PCI scan done on
our site and 2 vulnerabilities came out that we can not get under control.
First one is BEAST attack and other one SSL RC4 Cipher Suites Supported.
So far I have tried following that looks promising. I tried with few more
changes after searching for help, but those changes in turn started
breaking browsers and were discarded.
SSLProtocol -SSLv2 -TLSv1 +SSLv3
SSLHonorCipherOrder On
SSLCipherSuite
ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-RC4-SHA:ECDHE-RSA-RC4-SHA:ECDH-ECDSA-RC4-SHA:ECDH-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:!MD5:!aNULL:!EDH
SSLCompression off
or
SSLProtocol ALL -SSLv2
SSLHonorCipherOrder On
SSLCipherSuite
ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS
SSLCompression off
Based on scan results on ssllabs, I am able to get only one of the
vulnerability mitigated. What changes I need to do so that both
vulnerabilities are addressed and does support current version of
browsers?
We are on Ubuntu 12.04 and apache 2.2.2 version. We had PCI scan done on
our site and 2 vulnerabilities came out that we can not get under control.
First one is BEAST attack and other one SSL RC4 Cipher Suites Supported.
So far I have tried following that looks promising. I tried with few more
changes after searching for help, but those changes in turn started
breaking browsers and were discarded.
SSLProtocol -SSLv2 -TLSv1 +SSLv3
SSLHonorCipherOrder On
SSLCipherSuite
ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-RC4-SHA:ECDHE-RSA-RC4-SHA:ECDH-ECDSA-RC4-SHA:ECDH-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:!MD5:!aNULL:!EDH
SSLCompression off
or
SSLProtocol ALL -SSLv2
SSLHonorCipherOrder On
SSLCipherSuite
ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS
SSLCompression off
Based on scan results on ssllabs, I am able to get only one of the
vulnerability mitigated. What changes I need to do so that both
vulnerabilities are addressed and does support current version of
browsers?
Can I change notification dialog text?
Can I change notification dialog text?
I am using the latest Xubuntu 13.04. When I go to shut down, I receive the
confirmation notification stating "Are you sure you want to shut down?" I
would like to keep this dialog box, but I want to customize the message it
displays. Can this be done?
I am using the latest Xubuntu 13.04. When I go to shut down, I receive the
confirmation notification stating "Are you sure you want to shut down?" I
would like to keep this dialog box, but I want to customize the message it
displays. Can this be done?
Monday, 30 September 2013
Disable Password Authentication for Remote Users Only
Disable Password Authentication for Remote Users Only
I've read how it is possible to disable password authentication on an
Ubuntu server. However, is it possible to disable this for remote users
only?
I'm afraid that, if I enable this both locally and remotely (as designed),
I will ultimately lose the key and lock myself out (over time). If I were
able to disable password authentication for remote users only, losing the
key wouldn't be so tragic; I could simply go to the LAN and login with a
password and create a new key.
I've read how it is possible to disable password authentication on an
Ubuntu server. However, is it possible to disable this for remote users
only?
I'm afraid that, if I enable this both locally and remotely (as designed),
I will ultimately lose the key and lock myself out (over time). If I were
able to disable password authentication for remote users only, losing the
key wouldn't be so tragic; I could simply go to the LAN and login with a
password and create a new key.
Wanting an explanation to the solution method of the system of differential equations.
Wanting an explanation to the solution method of the system of
differential equations.
Please can anybody help me with explaining, in detail, why and how the
author solves the system of differential equations by such a step (see
below)? How the equation 6.3 is formed step by step? Why such a column
basis is valid? It would be extremely helpful if someone knows the name of
the method or could give an exemplification.
differential equations.
Please can anybody help me with explaining, in detail, why and how the
author solves the system of differential equations by such a step (see
below)? How the equation 6.3 is formed step by step? Why such a column
basis is valid? It would be extremely helpful if someone knows the name of
the method or could give an exemplification.
ngResource retrive unique ID from POST response after $save()
ngResource retrive unique ID from POST response after $save()
So I have a Resource defined as follows:
angular.module('questionService', ['ngResource'])
.factory('QuestionService', function($http, $resource) {
var QuestionService = $resource('/api/questions/:key', {}, {
query: {
method:'GET',
isArray:true,
},
save: {
method: 'POST',
}
});
return QuestionService
});
And later on I take some form input and do the following
var newQ = {
txt: $scope.addTxt
};
QuestionService.save(newQ)
The server responds to the POST request both by reissuing the JSON for the
object and setting the location header with the new unique ID. The problem
is that Angular is not saving that returned JSON or the location header
into the object and it is not getting set with the ID from the server for
future operations. I've tried a number of things such as:
transformResponse: function(data, headersGetter) {
locationHeader = headersGetter().location;
key = locationHeader.split('/').slice(-1)[0];
data.key = key;
return data;
}
However the returned data item doesn't seem to be getting used. Am I
missing something? This seems like a pretty common use case for
interacting with a REST api.
Thanks!
So I have a Resource defined as follows:
angular.module('questionService', ['ngResource'])
.factory('QuestionService', function($http, $resource) {
var QuestionService = $resource('/api/questions/:key', {}, {
query: {
method:'GET',
isArray:true,
},
save: {
method: 'POST',
}
});
return QuestionService
});
And later on I take some form input and do the following
var newQ = {
txt: $scope.addTxt
};
QuestionService.save(newQ)
The server responds to the POST request both by reissuing the JSON for the
object and setting the location header with the new unique ID. The problem
is that Angular is not saving that returned JSON or the location header
into the object and it is not getting set with the ID from the server for
future operations. I've tried a number of things such as:
transformResponse: function(data, headersGetter) {
locationHeader = headersGetter().location;
key = locationHeader.split('/').slice(-1)[0];
data.key = key;
return data;
}
However the returned data item doesn't seem to be getting used. Am I
missing something? This seems like a pretty common use case for
interacting with a REST api.
Thanks!
Using nested if statements to structure code
Using nested if statements to structure code
I'm trying to structure my code in a readable way. I've read that one way
of doing it is as follows:
if(Init1() == TRUE)
{
if(Init2() == TRUE)
{
if(Init3() == TRUE)
{
...
Free3();
}
Free2();
}
Free(1);
}
I like this way of doing things, because it keeps each FreeX inside its
matching InitX loop, but if the nesting goes beyond three levels it
quickly becomes unreadable and goes way beyond 80 columns. Many functions
can be broken up into multiple functions so that this doesn't happen, but
it seems dumb to break up a function just to avoid too many levels of
nesting. In particular, consider a function that does the initialization
for a whole class, where that initialization requires ten or more function
calls. That's ten or more levels of nesting.
I'm sure I'm overthinking this, but is there something fundamental I'm
missing in the above? Can deep nesting be done in a readable way? Or else
restructured somehow whilst keeping each FreeX inside its own InitX loop?
By the way, I realise that the above code can be compacted to if(Init1()
&& Init2()..., but the code is just an example. There would be other code
between each InitX call that would prevent such a compaction.
I'm trying to structure my code in a readable way. I've read that one way
of doing it is as follows:
if(Init1() == TRUE)
{
if(Init2() == TRUE)
{
if(Init3() == TRUE)
{
...
Free3();
}
Free2();
}
Free(1);
}
I like this way of doing things, because it keeps each FreeX inside its
matching InitX loop, but if the nesting goes beyond three levels it
quickly becomes unreadable and goes way beyond 80 columns. Many functions
can be broken up into multiple functions so that this doesn't happen, but
it seems dumb to break up a function just to avoid too many levels of
nesting. In particular, consider a function that does the initialization
for a whole class, where that initialization requires ten or more function
calls. That's ten or more levels of nesting.
I'm sure I'm overthinking this, but is there something fundamental I'm
missing in the above? Can deep nesting be done in a readable way? Or else
restructured somehow whilst keeping each FreeX inside its own InitX loop?
By the way, I realise that the above code can be compacted to if(Init1()
&& Init2()..., but the code is just an example. There would be other code
between each InitX call that would prevent such a compaction.
Sunday, 29 September 2013
Implementing IFB_LLLLCHAR
Implementing IFB_LLLLCHAR
We are using jpos server with ASCIChannel and custom package which
contains one field with max length 9999 to do this we implemented
IFB_LLLLCHAR as follow
public class IFB_LLLLCHAR extends ISOStringFieldPackager {
public IFB_LLLLCHAR() {
super(NullPadder.INSTANCE, AsciiInterpreter.INSTANCE,
BcdPrefixer.LLLL);
}
public IFB_LLLLCHAR(int len, String description) {
super(len, description, NullPadder.INSTANCE,
AsciiInterpreter.INSTANCE, BcdPrefixer.LLLL);
checkLength(len, 9999);
}
public void setLength(int len)
{
checkLength(len, 9999);
super.setLength(len);
}
}
Problem is that i couldn't use the whole 9999 because if the size of whole
message goes over 9999 it throws following exception while sending it
<exception name="len exceeded">
java.io.IOException: len exceeded
at
org.jpos.iso.channel.ASCIIChannel.sendMessageLength(ASCIIChannel.java:80)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:528)
at
com.advam.gateway.terminalmanagementserver.gateway.LogUploadFuncTest.testLogUpload(LogUploadFuncTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
</exception>
Can anybody tell me why i am getting this exception and how to fix it.
Kindly keep in mind while answering that I don't have much knowledge about
inside of jpos. Thanks
We are using jpos server with ASCIChannel and custom package which
contains one field with max length 9999 to do this we implemented
IFB_LLLLCHAR as follow
public class IFB_LLLLCHAR extends ISOStringFieldPackager {
public IFB_LLLLCHAR() {
super(NullPadder.INSTANCE, AsciiInterpreter.INSTANCE,
BcdPrefixer.LLLL);
}
public IFB_LLLLCHAR(int len, String description) {
super(len, description, NullPadder.INSTANCE,
AsciiInterpreter.INSTANCE, BcdPrefixer.LLLL);
checkLength(len, 9999);
}
public void setLength(int len)
{
checkLength(len, 9999);
super.setLength(len);
}
}
Problem is that i couldn't use the whole 9999 because if the size of whole
message goes over 9999 it throws following exception while sending it
<exception name="len exceeded">
java.io.IOException: len exceeded
at
org.jpos.iso.channel.ASCIIChannel.sendMessageLength(ASCIIChannel.java:80)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:528)
at
com.advam.gateway.terminalmanagementserver.gateway.LogUploadFuncTest.testLogUpload(LogUploadFuncTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
</exception>
Can anybody tell me why i am getting this exception and how to fix it.
Kindly keep in mind while answering that I don't have much knowledge about
inside of jpos. Thanks
triangle numbers in java
triangle numbers in java
I am new to Java and now I want to learn better for loop. I made some
examples , but I don't know how to do a triangle that look like this: for
n=6:
111111
22222
3333
222
11
6
My code until now:
class Pyramid
{
public static void main (String[] args)
{
int i,n=9,j;
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++) {
System.out.print(i); }
System.out.print("\n");
}}}
But what I managed to do it looks like this:
666666
55555
4444
333
22
1
How to make it in reverse order and to print the given number n when just
one character has to be print?
I am new to Java and now I want to learn better for loop. I made some
examples , but I don't know how to do a triangle that look like this: for
n=6:
111111
22222
3333
222
11
6
My code until now:
class Pyramid
{
public static void main (String[] args)
{
int i,n=9,j;
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++) {
System.out.print(i); }
System.out.print("\n");
}}}
But what I managed to do it looks like this:
666666
55555
4444
333
22
1
How to make it in reverse order and to print the given number n when just
one character has to be print?
Airspeed conversion in Matlab
Airspeed conversion in Matlab
I am trying to convert True Airspeed (TAS) to Calibrated Airspeed (CAS) in
MATLAB using the function "correctairspeed", but it gives me an error
because my speeds are in the supersonic regime.
I can always use the formulae to convert the speed but I was wondering if
there is an easier way to do it, since I have a bunch of different speeds
(supersonic as well as subsonic). Something like "correctairspeed" for
super-sonic would be really helpful.
Any ideas?
I am trying to convert True Airspeed (TAS) to Calibrated Airspeed (CAS) in
MATLAB using the function "correctairspeed", but it gives me an error
because my speeds are in the supersonic regime.
I can always use the formulae to convert the speed but I was wondering if
there is an easier way to do it, since I have a bunch of different speeds
(supersonic as well as subsonic). Something like "correctairspeed" for
super-sonic would be really helpful.
Any ideas?
Saturday, 28 September 2013
Cannot evaluate script arguments from function
Cannot evaluate script arguments from function
I've started writing shell scripts again and I've found myself in a
situation where I frequently have to write debug echo's to trace what the
script is doing. The, easy, way I used to do this right was to write
something like this :
#!/bin/bash
myVar = 'Erractic Nonesense'
echo "myVar: $myVar"
==> myVar: Erractic Nonesense
This worked great and was fairly simple but, having to write this for
every variable I wished to trace was tiring and as a person who thinks
that having less code to do more stuff is great, I wrote myself a
function:
#!/bin/bash
function dbg # $msg
{
echo "$@: ${!@}"
}
myVar = 'Erractic Nonesense'
dbg myVar
==> myVar: Erractic Nonesense
This works great for regular variables but, for the scripts arguments ($1,
$2, etc.), does not work. Why?
==> $ ./myScript 123
#!/bin/bash
...
dbg 1 # This is the bugger in question.
==> 1: 1
I've started writing shell scripts again and I've found myself in a
situation where I frequently have to write debug echo's to trace what the
script is doing. The, easy, way I used to do this right was to write
something like this :
#!/bin/bash
myVar = 'Erractic Nonesense'
echo "myVar: $myVar"
==> myVar: Erractic Nonesense
This worked great and was fairly simple but, having to write this for
every variable I wished to trace was tiring and as a person who thinks
that having less code to do more stuff is great, I wrote myself a
function:
#!/bin/bash
function dbg # $msg
{
echo "$@: ${!@}"
}
myVar = 'Erractic Nonesense'
dbg myVar
==> myVar: Erractic Nonesense
This works great for regular variables but, for the scripts arguments ($1,
$2, etc.), does not work. Why?
==> $ ./myScript 123
#!/bin/bash
...
dbg 1 # This is the bugger in question.
==> 1: 1
Python3, Gtk3 - GtkGrid expanding
Python3, Gtk3 - GtkGrid expanding
A GtkWindow containing a GtkGrid containing some GtkLabels won't expand
when the window is grown. I want the grid to expand horizontally.
grid.set_hexpand(True) #No result
grid.expand = True #No result
The GtkLabel in the rightmost column is set to align right so I can
accurately see if it's being expanded or not:
label.set_halign(Gtk.Align.END)
Am I misunderstanding how a grid works? (A GtkTable had a set amount of
columns, perhaps the GtkGrid doesn't and relies on it's sub elements being
set to expand?)
A GtkWindow containing a GtkGrid containing some GtkLabels won't expand
when the window is grown. I want the grid to expand horizontally.
grid.set_hexpand(True) #No result
grid.expand = True #No result
The GtkLabel in the rightmost column is set to align right so I can
accurately see if it's being expanded or not:
label.set_halign(Gtk.Align.END)
Am I misunderstanding how a grid works? (A GtkTable had a set amount of
columns, perhaps the GtkGrid doesn't and relies on it's sub elements being
set to expand?)
New Sequence Points in C++11
New Sequence Points in C++11
With the new college year upon us.
We have started to receive the standard why does ++ i ++ not work as
expected questions.
After just answering one of these type of questions I was told that the
new C++11 standard has changed and this is no longer undefined behavior. I
have heard that sequence points have been replaced by sequenced before and
sequenced after but have not read deep (or at all) into the subject.
So the question I was just answering had:
k = ++ (++ i);
So the question is:
How has the sequence points changes in C++11 and how does it affect
questions like the above. Is it still undefined behavior or is this now
well defined?
With the new college year upon us.
We have started to receive the standard why does ++ i ++ not work as
expected questions.
After just answering one of these type of questions I was told that the
new C++11 standard has changed and this is no longer undefined behavior. I
have heard that sequence points have been replaced by sequenced before and
sequenced after but have not read deep (or at all) into the subject.
So the question I was just answering had:
k = ++ (++ i);
So the question is:
How has the sequence points changes in C++11 and how does it affect
questions like the above. Is it still undefined behavior or is this now
well defined?
How to make JFrame wait for input before the user can proceed?
How to make JFrame wait for input before the user can proceed?
I'm making a question and answer game. The user must first pick a category
in a JFrame then another Jframe would pop up with the question. What i
want is to prevent the user from choosing another category without first
answering the question.
I'm making a question and answer game. The user must first pick a category
in a JFrame then another Jframe would pop up with the question. What i
want is to prevent the user from choosing another category without first
answering the question.
Friday, 27 September 2013
How can you tell an Asset Catalog (.xcassets) to use the same image for multiple settings?
How can you tell an Asset Catalog (.xcassets) to use the same image for
multiple settings?
We have several Xcode app projects, and we're upgrading all of them to use
the latest Xcode 5 features, including Asset Catalogs (.xcassets).
All of our default (launch) images already include spacing for the status
bar, and we want to use these images for both the iOS 5,6 and iOS 7 launch
images. Further, we don't want to include multiple copies of these images.
One of our projects is correctly set to use the same image for both of
these sets. However, this was setup more so by accident.
Besides editing the Contents.json file directly (which, I suppose, is a
workaround if need be), how can we do this using the Xcode GUI editor for
Asset Catalog?
What we've already tried
1) Dragging and dropping the file to a different position... just moves
the image to the other set
2) Dragging and dropping the same file from Finder to the Asset Catalog...
creates a new copy of the image
multiple settings?
We have several Xcode app projects, and we're upgrading all of them to use
the latest Xcode 5 features, including Asset Catalogs (.xcassets).
All of our default (launch) images already include spacing for the status
bar, and we want to use these images for both the iOS 5,6 and iOS 7 launch
images. Further, we don't want to include multiple copies of these images.
One of our projects is correctly set to use the same image for both of
these sets. However, this was setup more so by accident.
Besides editing the Contents.json file directly (which, I suppose, is a
workaround if need be), how can we do this using the Xcode GUI editor for
Asset Catalog?
What we've already tried
1) Dragging and dropping the file to a different position... just moves
the image to the other set
2) Dragging and dropping the same file from Finder to the Asset Catalog...
creates a new copy of the image
How to add json data to mysql with php with cUrl or file_get_content?
How to add json data to mysql with php with cUrl or file_get_content?
Example Json URL
$url = "somewebsites.com/json.php?id=abc";
Example json data returns
{
"disclaimer": "here comes disclaimer text ",
"license": "Licence details",
"timestamp": 1380312059,
"base": "USD",
"rates": {
"AED": 3.672992,
"AFN": 56.700925,
"ALL": 104.531199,
"AMD": 409.085999,
"ANG": 1.782483
}
}
how can we call & insert this data to 2 mysql tables through cUrl or
file_get_contents
1st table = disclaimer | licence | timestamp | base
2nd table = currencycode (AED) | rate (3.672992)
I am new to php so sorry if its a silly question..
Example Json URL
$url = "somewebsites.com/json.php?id=abc";
Example json data returns
{
"disclaimer": "here comes disclaimer text ",
"license": "Licence details",
"timestamp": 1380312059,
"base": "USD",
"rates": {
"AED": 3.672992,
"AFN": 56.700925,
"ALL": 104.531199,
"AMD": 409.085999,
"ANG": 1.782483
}
}
how can we call & insert this data to 2 mysql tables through cUrl or
file_get_contents
1st table = disclaimer | licence | timestamp | base
2nd table = currencycode (AED) | rate (3.672992)
I am new to php so sorry if its a silly question..
PHP "or" syntax statement
PHP "or" syntax statement
Moving over to PHP from another language and still getting used to the
syntax...
What's the proper way to write this statement? The manual on logical
operators leaves something to be desired..
if($var !== '5283180' or '1234567')
Moving over to PHP from another language and still getting used to the
syntax...
What's the proper way to write this statement? The manual on logical
operators leaves something to be desired..
if($var !== '5283180' or '1234567')
No python executable could be found on your system , Titanium
No python executable could be found on your system , Titanium
I am using eclipse to make titanium module, but whenever I use Ant build i
get error
No python executable could be found on your system
i have installed
Titanium SDK. All of the prerequisites for developing Android
applications. Android NDK. Add an ANDROID_NDK environment variable
pointing to the NDK folder. Eclipse and ADT. gperf e installed and in your
system PATH.
I also checked my bulid.properties which is like this:
titanium.platform=C:\\Users\\Titanium\\mobilesdk\\win32\\3.1.1.GA\\android
android.platform=C:\\AndroidSDK\\platforms\\android-10
google.apis=C:\\AndroidSDK\\add-ons\\addon-google_apis-google-10
android.ndk = C:\\android-ndk-r9
What is wrong with mine?
I am using eclipse to make titanium module, but whenever I use Ant build i
get error
No python executable could be found on your system
i have installed
Titanium SDK. All of the prerequisites for developing Android
applications. Android NDK. Add an ANDROID_NDK environment variable
pointing to the NDK folder. Eclipse and ADT. gperf e installed and in your
system PATH.
I also checked my bulid.properties which is like this:
titanium.platform=C:\\Users\\Titanium\\mobilesdk\\win32\\3.1.1.GA\\android
android.platform=C:\\AndroidSDK\\platforms\\android-10
google.apis=C:\\AndroidSDK\\add-ons\\addon-google_apis-google-10
android.ndk = C:\\android-ndk-r9
What is wrong with mine?
WPF datagrid binding issue: first row bound but doesn't update selected item in two-way fashion
WPF datagrid binding issue: first row bound but doesn't update selected
item in two-way fashion
The Setup
I have a DataGrid that holds a list of custom types ("Previous Documents")
and binds to them. That part works correctly.
I have bound the SelectedItemProperty of the datagrid to a property on my
ViewModel called CurrentlySelectedPreviousDocument
I have the left-click action of the datagrid bound to a command called
OpenPreviousDocumentCommand
The OpenPreviousDocumentCommand runs a method called
OpenSelectedPreviousDocument()
OpenSelectedPreviousDocument() uses the CurrentlySelectedPreviousDocument
property to copy a file to the temporary directory and open it.
The Problem
This code works, but only if you click on the first item in the datagrid.
For every other item in the datagrid, it appears that
CurrentlySelectedPreviousDocument is shown as null, so all of the
properties are null.
The Code
XAML DataGrid bindings:
<DataGrid
x:Name="PreviousDocumentsDataGrid"
ItemsSource="{Binding PreviousDocumentsList}"
SelectedItem="{Binding CurrentlySelectedPreviousDocument,
Mode=OneWayToSource}"
SelectionMode="Single"
SelectionUnit="FullRow"
AutoGenerateColumns="False"
IsReadOnly="True"
HorizontalGridLinesBrush="LightGray"
VerticalGridLinesBrush="LightGray"
BorderBrush="Transparent"
Visibility="{Binding PreviousDocumentsFound, Converter={StaticResource
BoolToVisConverter}}">
<DataGrid.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding
OpenPreviousDocumentCommand}"/>
</DataGrid.InputBindings>
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
<DataGridTextColumn Header="Reference Type" Binding="{Binding
ReferenceType}"/>
<DataGridTextColumn Header="Category ID" Binding="{Binding
Category}"/>
<DataGridTextColumn Header="Description" Binding="{Binding
Description}"/>
<DataGridTextColumn Header="Document Timestamp" Binding="{Binding
Timestamp}"/>
</DataGrid.Columns>
</DataGrid>
The ViewModel definition of CurrentlySelectedPreviousDocument:
public VEDocument CurrentlySelectedPreviousDocument
{
get { return _currentlySelectedPreviousDocument; }
set { _currentlySelectedPreviousDocument = value;
OnPropertyChanged("CurrentlySelectedPreviousDocument");} //TODO: Is
the on propertychanged actually necessary here?
}
Command Definition:
public ICommand OpenPreviousDocumentCommand
{
get
{
return _openPreviousDocumentCommand ??
(new CommandHandler(OpenSelectedPreviousDocument,
_canExecuteCommands));
}
}
Method in the ViewModel to open the document (uses the viewmodel property)
public void OpenSelectedPreviousDocument()
{
var docToOpen = CurrentlySelectedPreviousDocument;
...etc. etc.
}
item in two-way fashion
The Setup
I have a DataGrid that holds a list of custom types ("Previous Documents")
and binds to them. That part works correctly.
I have bound the SelectedItemProperty of the datagrid to a property on my
ViewModel called CurrentlySelectedPreviousDocument
I have the left-click action of the datagrid bound to a command called
OpenPreviousDocumentCommand
The OpenPreviousDocumentCommand runs a method called
OpenSelectedPreviousDocument()
OpenSelectedPreviousDocument() uses the CurrentlySelectedPreviousDocument
property to copy a file to the temporary directory and open it.
The Problem
This code works, but only if you click on the first item in the datagrid.
For every other item in the datagrid, it appears that
CurrentlySelectedPreviousDocument is shown as null, so all of the
properties are null.
The Code
XAML DataGrid bindings:
<DataGrid
x:Name="PreviousDocumentsDataGrid"
ItemsSource="{Binding PreviousDocumentsList}"
SelectedItem="{Binding CurrentlySelectedPreviousDocument,
Mode=OneWayToSource}"
SelectionMode="Single"
SelectionUnit="FullRow"
AutoGenerateColumns="False"
IsReadOnly="True"
HorizontalGridLinesBrush="LightGray"
VerticalGridLinesBrush="LightGray"
BorderBrush="Transparent"
Visibility="{Binding PreviousDocumentsFound, Converter={StaticResource
BoolToVisConverter}}">
<DataGrid.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding
OpenPreviousDocumentCommand}"/>
</DataGrid.InputBindings>
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
<DataGridTextColumn Header="Reference Type" Binding="{Binding
ReferenceType}"/>
<DataGridTextColumn Header="Category ID" Binding="{Binding
Category}"/>
<DataGridTextColumn Header="Description" Binding="{Binding
Description}"/>
<DataGridTextColumn Header="Document Timestamp" Binding="{Binding
Timestamp}"/>
</DataGrid.Columns>
</DataGrid>
The ViewModel definition of CurrentlySelectedPreviousDocument:
public VEDocument CurrentlySelectedPreviousDocument
{
get { return _currentlySelectedPreviousDocument; }
set { _currentlySelectedPreviousDocument = value;
OnPropertyChanged("CurrentlySelectedPreviousDocument");} //TODO: Is
the on propertychanged actually necessary here?
}
Command Definition:
public ICommand OpenPreviousDocumentCommand
{
get
{
return _openPreviousDocumentCommand ??
(new CommandHandler(OpenSelectedPreviousDocument,
_canExecuteCommands));
}
}
Method in the ViewModel to open the document (uses the viewmodel property)
public void OpenSelectedPreviousDocument()
{
var docToOpen = CurrentlySelectedPreviousDocument;
...etc. etc.
}
Which is the safest way to discriminate 0 from empty string in JavaScript?
Which is the safest way to discriminate 0 from empty string in JavaScript?
From user input, I receive a string which must contain numbers. 0 and
empty string must be treated differently.
I've made this brief case study
0 == "" // true
parseInt(0) == "" // true
parseInt("") // NaN
parseInt("") == "NaN" // false
parseInt("") == NaN // false
typeof parseInt("") // "number"
With a bit of extra research I've made up this solution (considering
uInput the user input)
function userInput(uInput){
var n = parseInt(uInput);
if (isNan(n))
// empty string
else
// 0 or number
}
It looks like it is able to distinguish 0 from empty string correctly in
Google Chrome.
What I'd like to know is:
Is this the best/most efficient solution?
Is this solution compatible in any browser?
Is this even a solution at all? Is there any way n can become something
other than a number (considering uInput could be any kind of string)?
I wouldn't be asking this, but since empty string can become 0 (?!) I
don't know to which kind of holes I'm exposed.
From user input, I receive a string which must contain numbers. 0 and
empty string must be treated differently.
I've made this brief case study
0 == "" // true
parseInt(0) == "" // true
parseInt("") // NaN
parseInt("") == "NaN" // false
parseInt("") == NaN // false
typeof parseInt("") // "number"
With a bit of extra research I've made up this solution (considering
uInput the user input)
function userInput(uInput){
var n = parseInt(uInput);
if (isNan(n))
// empty string
else
// 0 or number
}
It looks like it is able to distinguish 0 from empty string correctly in
Google Chrome.
What I'd like to know is:
Is this the best/most efficient solution?
Is this solution compatible in any browser?
Is this even a solution at all? Is there any way n can become something
other than a number (considering uInput could be any kind of string)?
I wouldn't be asking this, but since empty string can become 0 (?!) I
don't know to which kind of holes I'm exposed.
Thursday, 19 September 2013
Beginner C Conundrum. why doesn't 25 == 25?
Beginner C Conundrum. why doesn't 25 == 25?
I have a simple task for my first lab in my intermediate C programming
class. I'm taking an array of 8 doubles from the user, and then 1
additional double. I then check the square of one double from the array
plus the square of other doubles in the array to see if they are
equivalent to the square of the last input given to the program (the
additional double).
My problem is that for some reason, when my two inputs squared equal the
additional input squared, my compiler doesn't think so.
Please let me know what I'm doing wrong here; I'm using Codelite with the
gnu gdb debugger and gcc compiler.
Sample input: 4 3 3 3 3 3 3 3 5
#include <stdio.h>
#include <math.h>
int main(int argc, char **argv)
{
int input[8];
double inputSquared[8];
int pairs[16];
int i, j, k; //i and j are for loop workers.
double x;
int numPairs = 0;
printf("Welcome to Lab 1.\nEnter 8 integers. After each entry, press the
enter button.\n");
printf("---------------------------------------\n");
for(i=0; i<8; i++){
printf("Enter integer %d:", i+1);
scanf("%d", &input[i]);
printf("\n");
}
//printf("Now enter one more integer.\n The sum of the squares of the
following o this integer squared.\n");
printf("Enter an integer: ");
scanf("%lf", &x);
for(k = 0; k<8; k++){
inputSquared[k] = pow((double)input[k], 2);
}
for(i = 0; i<8; i++){
for(j = i + 1; j<8-1; j++){ //does not check for pairs reflexively.
If 1 is in the array, it does not check 1^2 + 1^2.
printf("%lf, %lf; %lf; %lf, %d \n", inputSquared[i],
inputSquared[j], pow(x, 2.0), inputSquared[i] + inputSquared[j],
((inputSquared[i] + inputSquared[j]) == ((pow(x, 2.0)))));
if(inputSquared[i] + inputSquared[j] == pow(x, 2.0)){
pairs[2 * numPairs] = input[i];
pairs[2 * numPairs + 1] = input[j];
numPairs++;
}
}
}
if(numPairs == 1)
printf("\nYou have %d pair:", numPairs); // grammar condition for
having 1 pair
else
printf("\nYou have %d pairs:\n", numPairs);
for(i = 0; i < numPairs; i++)
printf("(%d,%d)", pairs[2 * i], pairs[2 * i + 1]);
scanf("%lf", &x);
return 0;
}
I have a simple task for my first lab in my intermediate C programming
class. I'm taking an array of 8 doubles from the user, and then 1
additional double. I then check the square of one double from the array
plus the square of other doubles in the array to see if they are
equivalent to the square of the last input given to the program (the
additional double).
My problem is that for some reason, when my two inputs squared equal the
additional input squared, my compiler doesn't think so.
Please let me know what I'm doing wrong here; I'm using Codelite with the
gnu gdb debugger and gcc compiler.
Sample input: 4 3 3 3 3 3 3 3 5
#include <stdio.h>
#include <math.h>
int main(int argc, char **argv)
{
int input[8];
double inputSquared[8];
int pairs[16];
int i, j, k; //i and j are for loop workers.
double x;
int numPairs = 0;
printf("Welcome to Lab 1.\nEnter 8 integers. After each entry, press the
enter button.\n");
printf("---------------------------------------\n");
for(i=0; i<8; i++){
printf("Enter integer %d:", i+1);
scanf("%d", &input[i]);
printf("\n");
}
//printf("Now enter one more integer.\n The sum of the squares of the
following o this integer squared.\n");
printf("Enter an integer: ");
scanf("%lf", &x);
for(k = 0; k<8; k++){
inputSquared[k] = pow((double)input[k], 2);
}
for(i = 0; i<8; i++){
for(j = i + 1; j<8-1; j++){ //does not check for pairs reflexively.
If 1 is in the array, it does not check 1^2 + 1^2.
printf("%lf, %lf; %lf; %lf, %d \n", inputSquared[i],
inputSquared[j], pow(x, 2.0), inputSquared[i] + inputSquared[j],
((inputSquared[i] + inputSquared[j]) == ((pow(x, 2.0)))));
if(inputSquared[i] + inputSquared[j] == pow(x, 2.0)){
pairs[2 * numPairs] = input[i];
pairs[2 * numPairs + 1] = input[j];
numPairs++;
}
}
}
if(numPairs == 1)
printf("\nYou have %d pair:", numPairs); // grammar condition for
having 1 pair
else
printf("\nYou have %d pairs:\n", numPairs);
for(i = 0; i < numPairs; i++)
printf("(%d,%d)", pairs[2 * i], pairs[2 * i + 1]);
scanf("%lf", &x);
return 0;
}
Word VBA - Symbol on the textbox does being added to the document?
Word VBA - Symbol on the textbox does being added to the document?
Hello,
How are you? This is in Word for MAC. I can copy symbols to the textbox in
the userform. But when I try to add the contents of the textbox via macro
code, the special symbols does not get added. Instead some other character
is shown. This works fine on Windows but not in MAC. How can I fix this?
Hello,
How are you? This is in Word for MAC. I can copy symbols to the textbox in
the userform. But when I try to add the contents of the textbox via macro
code, the special symbols does not get added. Instead some other character
is shown. This works fine on Windows but not in MAC. How can I fix this?
LIKE And AS Text Results
LIKE And AS Text Results
I am trying to figure out how to run a query in MySQL that will do the
following:
Search for any number that begins with 5 and have the result in a column
labeled classRef and the resulting text be FOO
If that number begins with anything other than 5 have it output to the
column classRef and the resulting text be BAR.
This is what I have so far:
SELECT
ara.AddressNumber AS ExternalID,
ara.AddressNumber as tranId,
cus.Name AS customerRef,
cus.ExternalID LIKE '5%' AS classRef,
cus.ExternalID NOT LIKE '5%' AS classRef2,
'1' AS itemLine_quantity,
'0' AS itemLine_salesPrice
FROM
adrun_copy ara,
customers_copy cus
WHERE
ara.AAccountNumber = cus.ExternalID
I am trying to figure out how to run a query in MySQL that will do the
following:
Search for any number that begins with 5 and have the result in a column
labeled classRef and the resulting text be FOO
If that number begins with anything other than 5 have it output to the
column classRef and the resulting text be BAR.
This is what I have so far:
SELECT
ara.AddressNumber AS ExternalID,
ara.AddressNumber as tranId,
cus.Name AS customerRef,
cus.ExternalID LIKE '5%' AS classRef,
cus.ExternalID NOT LIKE '5%' AS classRef2,
'1' AS itemLine_quantity,
'0' AS itemLine_salesPrice
FROM
adrun_copy ara,
customers_copy cus
WHERE
ara.AAccountNumber = cus.ExternalID
Combining data files with Querying? Manual Coding, Xml or SQL from VB.NEt
Combining data files with Querying? Manual Coding, Xml or SQL from VB.NEt
I am looking to combine huge CSV file together (+150 megs x9), apply a
simple query and remove data from the archive, and repeat the exercise. I
don't know much about SQL yet, thus I have stayed from it(time has always
been a factor). However with large Excel documents > 1 gig. which take
forever to load and edit, I am rethinking my approach. I would like to do
something in VB.Net
I have rather enjoyed the XML database system, however not sure how it is
going to cope with copious amounts of data?? Something I might test if I
don't get any feedback.
My question would be is it possible to package in a single exe, a SQLCE
database, with type of functionality?
It is something I can manually code into memory, but then the querying I
would have to manually code the process as well.
Any comments or suggestions?
I am looking to combine huge CSV file together (+150 megs x9), apply a
simple query and remove data from the archive, and repeat the exercise. I
don't know much about SQL yet, thus I have stayed from it(time has always
been a factor). However with large Excel documents > 1 gig. which take
forever to load and edit, I am rethinking my approach. I would like to do
something in VB.Net
I have rather enjoyed the XML database system, however not sure how it is
going to cope with copious amounts of data?? Something I might test if I
don't get any feedback.
My question would be is it possible to package in a single exe, a SQLCE
database, with type of functionality?
It is something I can manually code into memory, but then the querying I
would have to manually code the process as well.
Any comments or suggestions?
Function declarators in C
Function declarators in C
6.7.6.3 Function declarators
2)The only storage-class specifier that shall occur in a parameter
declaration
is register.
6.7.6.3 Function declarators
13) The storage-class specifier in the declaration specifiers for a parameter
declaration, if present, is ignored unless the declared parameter is one
of the
members of the parameter type list for a function definition.
I have declared and defined like this...
int function(static int param)
{
return param;
}
Visual Studio is throwing a warning. What I understood is, if we use
register as a parameter type in the declaration of a function, it should
compile without warning. Other than register, it will ignore the storage
class and throw a warning message to user. Is my understanding proper?
Thanks
6.7.6.3 Function declarators
2)The only storage-class specifier that shall occur in a parameter
declaration
is register.
6.7.6.3 Function declarators
13) The storage-class specifier in the declaration specifiers for a parameter
declaration, if present, is ignored unless the declared parameter is one
of the
members of the parameter type list for a function definition.
I have declared and defined like this...
int function(static int param)
{
return param;
}
Visual Studio is throwing a warning. What I understood is, if we use
register as a parameter type in the declaration of a function, it should
compile without warning. Other than register, it will ignore the storage
class and throw a warning message to user. Is my understanding proper?
Thanks
Integration of Testlink with Sahi in Windows
Integration of Testlink with Sahi in Windows
We are trying to integrate Sahi with Testlink, but unable to find the
integration points. Any help appreciated.
We are trying to integrate Sahi with Testlink, but unable to find the
integration points. Any help appreciated.
Passing multiple parameters in htacess and including files based on them
Passing multiple parameters in htacess and including files based on them
I currently am working on a project where I have to pass three parameters
in the url. My url looks like -
localhost/newproject/index.php?file_name=clients&mode=edit&id=1
The functions that I perform when passing different parameters are listed
below
1) url - localhost/newproject/index.php?file_name=clients
Function - include the file templates/modules/clients/clients.php
2) url - localhost/newproject/index.php?file_name=clients&mode=edit
Function - include the file template/modules/clients/cliemts-edit.php. And
the clients-edit screen will be used to add a new client as the client id
is not set.
3) url - localhost/newproject/index.php?file_name=clients&mode=edit&id=1
Function - include the file template/modules/clients/cliemts-edit.php. And
the clients-edit screen will be used to update the client whose client_id
is 1. Now, I am trying to convert this url to this
localhost/newproject/clients/edit/1
I have the following code in my htaccess
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ index.php?file_name=$1&mode=$2&id=$3
[L]
RewriteRule ^([^/\.]+)$ index.php?file_name=$1 [L]
The problem that I am facing is that whenever the clients-edit screen gets
included, the path of the css files, javascript files and the images get
changed. How can I overcome this?
I currently am working on a project where I have to pass three parameters
in the url. My url looks like -
localhost/newproject/index.php?file_name=clients&mode=edit&id=1
The functions that I perform when passing different parameters are listed
below
1) url - localhost/newproject/index.php?file_name=clients
Function - include the file templates/modules/clients/clients.php
2) url - localhost/newproject/index.php?file_name=clients&mode=edit
Function - include the file template/modules/clients/cliemts-edit.php. And
the clients-edit screen will be used to add a new client as the client id
is not set.
3) url - localhost/newproject/index.php?file_name=clients&mode=edit&id=1
Function - include the file template/modules/clients/cliemts-edit.php. And
the clients-edit screen will be used to update the client whose client_id
is 1. Now, I am trying to convert this url to this
localhost/newproject/clients/edit/1
I have the following code in my htaccess
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ index.php?file_name=$1&mode=$2&id=$3
[L]
RewriteRule ^([^/\.]+)$ index.php?file_name=$1 [L]
The problem that I am facing is that whenever the clients-edit screen gets
included, the path of the css files, javascript files and the images get
changed. How can I overcome this?
Wednesday, 18 September 2013
awk or sed , whichever is more apt
awk or sed , whichever is more apt
reading a csv file in unix and, doing some substitution on some of the
columns. like 2nd column(string type) should be replaced by value of (2nd
column itself + value of the 1st column(integer)), then 5th column by
$5+$4 and so on. Below is the sample I/O. and the first line which is
Description must be left as is .
sample Input
EmpID|Empname|Empadd|roleId|roleDesc|Dept
100|mst|Del|20|SD|DA
101|ms|Del|21|XS|DA
Sample output
EmpID|Empname|Empadd|roleId|roleDesc|Dept
100|mst100|Del|20|SD20|DA
101|ms101|Del|21|XS21|DA
empname has been concatenated with empid & the role desc with roleID.Hope
that's helpful :)
reading a csv file in unix and, doing some substitution on some of the
columns. like 2nd column(string type) should be replaced by value of (2nd
column itself + value of the 1st column(integer)), then 5th column by
$5+$4 and so on. Below is the sample I/O. and the first line which is
Description must be left as is .
sample Input
EmpID|Empname|Empadd|roleId|roleDesc|Dept
100|mst|Del|20|SD|DA
101|ms|Del|21|XS|DA
Sample output
EmpID|Empname|Empadd|roleId|roleDesc|Dept
100|mst100|Del|20|SD20|DA
101|ms101|Del|21|XS21|DA
empname has been concatenated with empid & the role desc with roleID.Hope
that's helpful :)
SpriteKit: Passing data between scenes
SpriteKit: Passing data between scenes
I am stuck trying to pass data between scenes "SKScene" in SpriteKit. For
instance I would like to pass the score from level A to Level B.
Maybe the solution is archiving but I would like to implement something
more simpler like the way we use with view controllers.
Any clue in this regard will be very much appreciated.
I am stuck trying to pass data between scenes "SKScene" in SpriteKit. For
instance I would like to pass the score from level A to Level B.
Maybe the solution is archiving but I would like to implement something
more simpler like the way we use with view controllers.
Any clue in this regard will be very much appreciated.
How do the "max" and "min" blocks in the MIT App Inventor work?
How do the "max" and "min" blocks in the MIT App Inventor work?
I am trying to create an app in the MIT App Inventor that is able to
discover the smallest and largest number within a set given by the user.
I saw that the App Inventor has blocks that do just this, aptly called
"max" and "min", but I cannot figure out how to use them. I'd appreciate
it if someone could explain this to me.
I am trying to create an app in the MIT App Inventor that is able to
discover the smallest and largest number within a set given by the user.
I saw that the App Inventor has blocks that do just this, aptly called
"max" and "min", but I cannot figure out how to use them. I'd appreciate
it if someone could explain this to me.
JSON data querying by breeze
JSON data querying by breeze
I attempting my first SPA.
It will be a HTML representation of the model of our database structure to
give to clients to look through the model and do queries of the model (not
the database).
The requirement is then for no updates and the SPA will be shipped with
the release (no server\offline).
My question is - is there a way to use breeze to query the json file I've
created that describes the model? All I've seen are examples of the
EntityManager being initialised with a service URL - that will return the
data.
I attempting my first SPA.
It will be a HTML representation of the model of our database structure to
give to clients to look through the model and do queries of the model (not
the database).
The requirement is then for no updates and the SPA will be shipped with
the release (no server\offline).
My question is - is there a way to use breeze to query the json file I've
created that describes the model? All I've seen are examples of the
EntityManager being initialised with a service URL - that will return the
data.
Partial View not Passing Model
Partial View not Passing Model
ViewModelProspectUsers
public class ViewModelProspectUsers
{
public int Id { get; set; }
public string User { get; set; }
public IEnumerable<ViewModelProspectSelect> Prospects { get; set; }
}
ViewModelProspectSelect
public class ViewModelProspectSelect
{
public int ProspectID { get; set; }
public string Name { get; set; }
public bool IsSelected { get; set; }
}
I'm calling my Partial from the main view
@Html.Partial("_ShowProspectCheckedForUser", Model.Prospects)
This is my partial view
@model IEnumerable<OG.ModelView.ViewModelProspectSelect>
@using (Html.BeginForm())
{
foreach (var item in Model)
{
... do stuff ( everything here is done with @Html.LabelFor( or EditFor( -
so it should save it to my ModelBinder?
PostMethod
[HttpPost]
public ActionResult UsersInProspect(ViewModelProspectUsers viewModel,
ViewModelProspectSelect select)
My viewmodel Variableis showing Data, however Select variable is not
showing me anything.
How can i pass the partial views model the correct way?
ViewModelProspectUsers
public class ViewModelProspectUsers
{
public int Id { get; set; }
public string User { get; set; }
public IEnumerable<ViewModelProspectSelect> Prospects { get; set; }
}
ViewModelProspectSelect
public class ViewModelProspectSelect
{
public int ProspectID { get; set; }
public string Name { get; set; }
public bool IsSelected { get; set; }
}
I'm calling my Partial from the main view
@Html.Partial("_ShowProspectCheckedForUser", Model.Prospects)
This is my partial view
@model IEnumerable<OG.ModelView.ViewModelProspectSelect>
@using (Html.BeginForm())
{
foreach (var item in Model)
{
... do stuff ( everything here is done with @Html.LabelFor( or EditFor( -
so it should save it to my ModelBinder?
PostMethod
[HttpPost]
public ActionResult UsersInProspect(ViewModelProspectUsers viewModel,
ViewModelProspectSelect select)
My viewmodel Variableis showing Data, however Select variable is not
showing me anything.
How can i pass the partial views model the correct way?
EXC_BAD_ACCESS when using FFI to launch objc_sendmessagesuper
EXC_BAD_ACCESS when using FFI to launch objc_sendmessagesuper
id verify_object(id self, SEL _cmd, ...){
Class objectClass = object_getClass(self);
Class super = class_getSuperclass(objectClass);
Method method;
if ((method = class_getClassMethod(super, _cmd)) != NULL) {
NSLog(@"Verifying +[%s %s]", class_getName(objectClass),
sel_getName(_cmd));
} else {
method = class_getInstanceMethod(super, _cmd);
NSLog(@"Verifying -[%s %s]", class_getName(objectClass),
sel_getName(_cmd));
}
//Verfication Code Goes Here
int numberOfArgs = method_getNumberOfArguments(method);
ffi_cif cif;
ffi_type * args[numberOfArgs];
void * values[numberOfArgs];
int i = 1;
id vaarg;
va_list vaargs;
va_start(vaargs, _cmd);
struct objc_super superStruct = {self, super};
args[0] = &ffi_type_pointer;
values[0] = &superStruct;
while ((vaarg = va_arg(vaargs, id)) != nil) {
args[i] = &ffi_type_pointer;
values[i] = &vaarg;
i++;
}
char methodType[256];
method_getReturnType(method, methodType, 256);
NSLog( @"Return type: <%s>", methodType);
ffi_type * typePointer = NULL;
if (!strcmp( methodType, "v" )){
NSLog(@"Calling Void Function");
typePointer = &ffi_type_void;
} else {
NSLog(@"Calling Object Returning Function");
typePointer = &ffi_type_pointer;
}
id ret;
/* Initialize the cif */
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, numberOfArgs, typePointer, args)
== FFI_OK)
{
ffi_call(&cif, FFI_FN(objc_msgSendSuper), &ret, values);
}
va_end(vaargs);
free(methodType);
return ret;
}
id verify_object(id self, SEL _cmd, ...){
Class objectClass = object_getClass(self);
Class super = class_getSuperclass(objectClass);
Method method;
if ((method = class_getClassMethod(super, _cmd)) != NULL) {
NSLog(@"Verifying +[%s %s]", class_getName(objectClass),
sel_getName(_cmd));
} else {
method = class_getInstanceMethod(super, _cmd);
NSLog(@"Verifying -[%s %s]", class_getName(objectClass),
sel_getName(_cmd));
}
//Verfication Code Goes Here
int numberOfArgs = method_getNumberOfArguments(method);
ffi_cif cif;
ffi_type * args[numberOfArgs];
void * values[numberOfArgs];
int i = 1;
id vaarg;
va_list vaargs;
va_start(vaargs, _cmd);
struct objc_super superStruct = {self, super};
args[0] = &ffi_type_pointer;
values[0] = &superStruct;
while ((vaarg = va_arg(vaargs, id)) != nil) {
args[i] = &ffi_type_pointer;
values[i] = &vaarg;
i++;
}
char methodType[256];
method_getReturnType(method, methodType, 256);
NSLog( @"Return type: <%s>", methodType);
ffi_type * typePointer = NULL;
if (!strcmp( methodType, "v" )){
NSLog(@"Calling Void Function");
typePointer = &ffi_type_void;
} else {
NSLog(@"Calling Object Returning Function");
typePointer = &ffi_type_pointer;
}
id ret;
/* Initialize the cif */
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, numberOfArgs, typePointer, args)
== FFI_OK)
{
ffi_call(&cif, FFI_FN(objc_msgSendSuper), &ret, values);
}
va_end(vaargs);
free(methodType);
return ret;
}
using set and pairs solve container handling two values but manipulating one
using set and pairs solve container handling two values but manipulating one
//2 boxers with max. strength in league need 2 fight in a match. One will
max strength will win the match with remaining strength of difference
between two boxer strength. The boxers with 0 difference in strength will
get eliminated. The loser will be eliminated. find winner?
typedef pair pairs; //pair of boxer's strngth and index (tydef for
declairing pairs at default data type) pairs boxer[4]; set s;
set :: iterator it; //iterator to do operation of set elements pairs max,
min, v; //pairs to save min and second max strength
boxer[0].first= (22); //boxer 1's strength = 23
boxer[0].second = (1); //boxer 1's index =1
boxer[1].first= (20); //boxer 2's strength = 20
boxer[1].second = (2); //boxer 2's index = 2
boxer[2].first= (44); //boxer 3's strength
boxer[2].second = (3); //boxer 3's index
boxer[3].first= (84); //boxer 4's strength
boxer[3].second = (4); //boxer 4's index
//you can add more
int size = sizeof(boxer)/sizeof(boxer[0]); //getting size of boxers
for (int i =0; i<size; i++){
s.insert(boxer[i]); //inserting boxers' identity in set // set always
sort while insertinf
}
while (s.size()!=1){ //terminate when only one boxer left in league
min = *(--(--s.end())); //boxer with second max strength in set
max = *(--(s.end())); //boxer with max strngth in set
s.erase(--(--s.end()), s.end()); //erase last two enteries (which is max,
and second max)
max.first -= min.first;
if (max.first ==0){
continue;// escpae to next operation as boxers with same strength will
get eliminated
}
s.insert(max); //again insert winner of the match in the set
}
for (it = s.begin(); it!=s.end(); it++){
v = *it; //save set element in pair object
cout<<"Boxer with index " <<v.second<<" won the league with remaining
strength " << v.first << endl;
}
//2 boxers with max. strength in league need 2 fight in a match. One will
max strength will win the match with remaining strength of difference
between two boxer strength. The boxers with 0 difference in strength will
get eliminated. The loser will be eliminated. find winner?
typedef pair pairs; //pair of boxer's strngth and index (tydef for
declairing pairs at default data type) pairs boxer[4]; set s;
set :: iterator it; //iterator to do operation of set elements pairs max,
min, v; //pairs to save min and second max strength
boxer[0].first= (22); //boxer 1's strength = 23
boxer[0].second = (1); //boxer 1's index =1
boxer[1].first= (20); //boxer 2's strength = 20
boxer[1].second = (2); //boxer 2's index = 2
boxer[2].first= (44); //boxer 3's strength
boxer[2].second = (3); //boxer 3's index
boxer[3].first= (84); //boxer 4's strength
boxer[3].second = (4); //boxer 4's index
//you can add more
int size = sizeof(boxer)/sizeof(boxer[0]); //getting size of boxers
for (int i =0; i<size; i++){
s.insert(boxer[i]); //inserting boxers' identity in set // set always
sort while insertinf
}
while (s.size()!=1){ //terminate when only one boxer left in league
min = *(--(--s.end())); //boxer with second max strength in set
max = *(--(s.end())); //boxer with max strngth in set
s.erase(--(--s.end()), s.end()); //erase last two enteries (which is max,
and second max)
max.first -= min.first;
if (max.first ==0){
continue;// escpae to next operation as boxers with same strength will
get eliminated
}
s.insert(max); //again insert winner of the match in the set
}
for (it = s.begin(); it!=s.end(); it++){
v = *it; //save set element in pair object
cout<<"Boxer with index " <<v.second<<" won the league with remaining
strength " << v.first << endl;
}
Is it still possible to submit apps targeted for iOS5 or iOS6 to the App Store after the release of iOS7
Is it still possible to submit apps targeted for iOS5 or iOS6 to the App
Store after the release of iOS7
Like the question says, will I be able to submit iOS5/iOS6 apps to the App
Store given that iOS7 is rolled out now? Or do I have to target iOS7 for
my builds?
I understand that there is a great amount of UI changes, new features, not
looking good, etc involved but I just want to know if it is still possible
to submit old targets
Cheers
Store after the release of iOS7
Like the question says, will I be able to submit iOS5/iOS6 apps to the App
Store given that iOS7 is rolled out now? Or do I have to target iOS7 for
my builds?
I understand that there is a great amount of UI changes, new features, not
looking good, etc involved but I just want to know if it is still possible
to submit old targets
Cheers
ios 7 typography on labels and UIFont
ios 7 typography on labels and UIFont
I have the following code:
UILabel *registerLabel = [ [UILabel alloc ] initWithFrame:CGRectMake(20.0,
90.0, [self screenWidth], 43.0) ];
registerLabel.textAlignment = NSTextAlignmentLeft;
registerLabel.textColor = [UIColor whiteColor];
registerLabel.backgroundColor = [UIColor blackColor];
registerLabel.font = [UIFont fontWithName:@"Helvetica Neue" size:(20.0)];
//registerLabel.adjustsFontSizeToFitWidth = YES;
registerLabel.text = @"Register";
But I see in some of the ios 7 demo apps (like calendar) the font is large
but much thinner. I tried using Helevetica Neue Light but that doesn't
work. Is there a way to make the font thinner or what font are they using?
I have the following code:
UILabel *registerLabel = [ [UILabel alloc ] initWithFrame:CGRectMake(20.0,
90.0, [self screenWidth], 43.0) ];
registerLabel.textAlignment = NSTextAlignmentLeft;
registerLabel.textColor = [UIColor whiteColor];
registerLabel.backgroundColor = [UIColor blackColor];
registerLabel.font = [UIFont fontWithName:@"Helvetica Neue" size:(20.0)];
//registerLabel.adjustsFontSizeToFitWidth = YES;
registerLabel.text = @"Register";
But I see in some of the ios 7 demo apps (like calendar) the font is large
but much thinner. I tried using Helevetica Neue Light but that doesn't
work. Is there a way to make the font thinner or what font are they using?
Tuesday, 17 September 2013
Insert Multi Row Data into Multi Column Database Table
Insert Multi Row Data into Multi Column Database Table
Text file containing sets of three data items delimited by ; to be
inserted in three columns of mysql database table is being inserted in a
single column. Found a snippet of code on SO and modified it according to
requirement, but still doesn't work as required. Any idea what could be
wrong? Thanks!
mem.txt
one
two
three;
four
five
six;
...
test.php
<?php
$db = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$db) {
die('Could not connect: ' . mysql_error());
}
$filename = "mem.txt";
$handle = fopen($filename, 'r');
$data = fread($handle, filesize($filename));
$rowsArr = explodeRows($data);
function explodeRows($data) {
$rowsArr = explode(";", $data);
return $rowsArr;
}
for($i=0;$i<count($rowsArr);$i++) {
$cols = explodeRows($rowsArr[$i]);
mysql_select_db("test", $db);
$query = sprintf('INSERT INTO voter (fname, lname, add) VALUES ("%s",
"%s", "%s")', $cols[0], $cols[1], $cols[2]);
if (!mysql_query($query,$db))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
}
fclose($handle);
mysql_close($db);
?>
output with above :
fname | lname | add
one | |
two | |
three | |
---------------------
four | |
five | |
six | |
---------------------
...
error with above code
Notice: Undefined offset: 1 in C:\xampp\htdocs\test.php on line 20
Notice: Undefined offset: 2 in C:\xampp\htdocs\test.php on line 20
1 record added
output required
fname |lname |add
one | two |three
---------------------
four | five |six
---------------------
...
Text file containing sets of three data items delimited by ; to be
inserted in three columns of mysql database table is being inserted in a
single column. Found a snippet of code on SO and modified it according to
requirement, but still doesn't work as required. Any idea what could be
wrong? Thanks!
mem.txt
one
two
three;
four
five
six;
...
test.php
<?php
$db = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$db) {
die('Could not connect: ' . mysql_error());
}
$filename = "mem.txt";
$handle = fopen($filename, 'r');
$data = fread($handle, filesize($filename));
$rowsArr = explodeRows($data);
function explodeRows($data) {
$rowsArr = explode(";", $data);
return $rowsArr;
}
for($i=0;$i<count($rowsArr);$i++) {
$cols = explodeRows($rowsArr[$i]);
mysql_select_db("test", $db);
$query = sprintf('INSERT INTO voter (fname, lname, add) VALUES ("%s",
"%s", "%s")', $cols[0], $cols[1], $cols[2]);
if (!mysql_query($query,$db))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
}
fclose($handle);
mysql_close($db);
?>
output with above :
fname | lname | add
one | |
two | |
three | |
---------------------
four | |
five | |
six | |
---------------------
...
error with above code
Notice: Undefined offset: 1 in C:\xampp\htdocs\test.php on line 20
Notice: Undefined offset: 2 in C:\xampp\htdocs\test.php on line 20
1 record added
output required
fname |lname |add
one | two |three
---------------------
four | five |six
---------------------
...
Wrapping rows in Telerik MVC grid
Wrapping rows in Telerik MVC grid
I have an application with a number of grids based on Telerik MVC
controls. It works wonderfully, however at low resolutions or low browser
widths, I cannot get the grids to be responsive as I need them to be.
I would like to start wrapping the rows onto multiple lines when the user
decides to resize down the browser (or has low res). I prefer to NOT have
the horizontal scrollbars show up as my users frequently do not see them
or use them.
Can anyone provide any suggestions if this is possible to do with Telerik
MVC grids?
Thanks!
I have an application with a number of grids based on Telerik MVC
controls. It works wonderfully, however at low resolutions or low browser
widths, I cannot get the grids to be responsive as I need them to be.
I would like to start wrapping the rows onto multiple lines when the user
decides to resize down the browser (or has low res). I prefer to NOT have
the horizontal scrollbars show up as my users frequently do not see them
or use them.
Can anyone provide any suggestions if this is possible to do with Telerik
MVC grids?
Thanks!
How to call method from driver?
How to call method from driver?
How would I call this method from my driver. Ive tried a couple different
ways.. but I cannot seem to get it.
public CoinJar(Coin[] coins)
{
//...initialize all variables, etc
for (int i = 0; i <10; i++)
{
coins[i] = new Coin(Coin.getDenomination(), Coin.getYear());
}
}
How would I call this method from my driver. Ive tried a couple different
ways.. but I cannot seem to get it.
public CoinJar(Coin[] coins)
{
//...initialize all variables, etc
for (int i = 0; i <10; i++)
{
coins[i] = new Coin(Coin.getDenomination(), Coin.getYear());
}
}
Application crashes when using FragmentManager
Application crashes when using FragmentManager
I'm new at adroid, and right now I'm trying to create an Navigation
drawer. Everything goes well until I try to link then to fragments, when I
do that and try to run at AVD or my HTC it crashes.
Here's the code:
{ package com.medicocontableV1.medicocontable;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.app.FragmentActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends FragmentActivity {
private DrawerLayout drawerLayout;
private ListView drawer;
private ActionBarDrawerToggle toggle;
private static final String[] opciones = {"Inicio","Sobre los
pacientes", "Usuarios", "Multimedia", "Administrador","Módulo
Contable"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Rescatamos el Action Bar y activamos el boton Home
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
// Declarar e inicializar componentes para el Navigation Drawer
drawer = (ListView) findViewById(R.id.drawer);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
// Declarar adapter y eventos al hacer click
drawer.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1,
opciones));
drawer.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
//Toast.makeText(MainActivity.this, "Pulsado: " +
opciones[position], Toast.LENGTH_SHORT).show();
FragmentManager fragmentManager =
getSupportFragmentManager();
switch (position) {
case 1:
fragmentManager.beginTransaction().replace(R.id.texto,
new Fragment1()).commit();
break;
}
drawer.setItemChecked(position, true);
drawerLayout.closeDrawers();
}
});
// Sombra del panel Navigation Drawer
drawerLayout.setDrawerShadow(R.drawable.drawer_shadow,
GravityCompat.START);
// Integracion boton oficial
toggle = new ActionBarDrawerToggle(
this, // Activity
drawerLayout, // Panel del Navigation Drawer
R.drawable.ic_drawer, // Icono que va a utilizar
R.string.app_name, // Descripcion al abrir el drawer
R.string.hello_world // Descripcion al cerrar el drawer
){
public void onDrawerClosed(View view) {
// Drawer cerrado
getActionBar().setTitle(getResources().getString(R.string.app_name));
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
// Drawer abierto
getActionBar().setTitle("Meú");
invalidateOptionsMenu();
}
};
drawerLayout.setDrawerListener(toggle);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (toggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}
// Activamos el toggle con el icono
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
toggle.syncState();
}
}
}
and it crashes in this line:
fragmentManager.beginTransaction().replace(R.id.texto, new
Fragment1()).commit(); break;
I hope you guys can help me
I'm new at adroid, and right now I'm trying to create an Navigation
drawer. Everything goes well until I try to link then to fragments, when I
do that and try to run at AVD or my HTC it crashes.
Here's the code:
{ package com.medicocontableV1.medicocontable;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.app.FragmentActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends FragmentActivity {
private DrawerLayout drawerLayout;
private ListView drawer;
private ActionBarDrawerToggle toggle;
private static final String[] opciones = {"Inicio","Sobre los
pacientes", "Usuarios", "Multimedia", "Administrador","Módulo
Contable"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Rescatamos el Action Bar y activamos el boton Home
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
// Declarar e inicializar componentes para el Navigation Drawer
drawer = (ListView) findViewById(R.id.drawer);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
// Declarar adapter y eventos al hacer click
drawer.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1,
opciones));
drawer.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
//Toast.makeText(MainActivity.this, "Pulsado: " +
opciones[position], Toast.LENGTH_SHORT).show();
FragmentManager fragmentManager =
getSupportFragmentManager();
switch (position) {
case 1:
fragmentManager.beginTransaction().replace(R.id.texto,
new Fragment1()).commit();
break;
}
drawer.setItemChecked(position, true);
drawerLayout.closeDrawers();
}
});
// Sombra del panel Navigation Drawer
drawerLayout.setDrawerShadow(R.drawable.drawer_shadow,
GravityCompat.START);
// Integracion boton oficial
toggle = new ActionBarDrawerToggle(
this, // Activity
drawerLayout, // Panel del Navigation Drawer
R.drawable.ic_drawer, // Icono que va a utilizar
R.string.app_name, // Descripcion al abrir el drawer
R.string.hello_world // Descripcion al cerrar el drawer
){
public void onDrawerClosed(View view) {
// Drawer cerrado
getActionBar().setTitle(getResources().getString(R.string.app_name));
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
// Drawer abierto
getActionBar().setTitle("Meú");
invalidateOptionsMenu();
}
};
drawerLayout.setDrawerListener(toggle);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (toggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}
// Activamos el toggle con el icono
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
toggle.syncState();
}
}
}
and it crashes in this line:
fragmentManager.beginTransaction().replace(R.id.texto, new
Fragment1()).commit(); break;
I hope you guys can help me
script not redirecting when query fails
script not redirecting when query fails
I have the following lines of code
if(isset($_GET['course_id'])) {
$data_id = mysql_real_escape_string($_GET['course_id']);
$subscriptionVerification = "SELECT `user_id`, `course_id` FROM
subscriptions WHERE `user_id` = '".$user_id."' and
`course_id`='".$data_id."'";
$subscriptionResult = mysql_query($subscriptionVerification);
if(!mysql_num_rows($subscriptionResult)===1)
{
header("location:login.php");
die(); // sends user to the login page if their userID and
subscription code do not match the page they are trying to
retrieve
}
}
the problem is that when i get the course_id from
chapters.php?course_id=1234 and if that id doesnt exist in the mysql db,
it still loads the page instead of redirecting.
if I write if(mysql_num_rows($subscriptionResult)===1) without the ! then
it does work and it directs all traffic (including the correct course ids)
over.
I'm wondering if there's something I'm doing wrong. I've tried the
following two variations as well if(!$subscriptionResult) and
if($subscriptionResult===FALSE) but neither have worked.
the purpose of this is to avoid having people try to manually put in
course_id (especially ones that don't exist) and load the page with
content in it.
I have the following lines of code
if(isset($_GET['course_id'])) {
$data_id = mysql_real_escape_string($_GET['course_id']);
$subscriptionVerification = "SELECT `user_id`, `course_id` FROM
subscriptions WHERE `user_id` = '".$user_id."' and
`course_id`='".$data_id."'";
$subscriptionResult = mysql_query($subscriptionVerification);
if(!mysql_num_rows($subscriptionResult)===1)
{
header("location:login.php");
die(); // sends user to the login page if their userID and
subscription code do not match the page they are trying to
retrieve
}
}
the problem is that when i get the course_id from
chapters.php?course_id=1234 and if that id doesnt exist in the mysql db,
it still loads the page instead of redirecting.
if I write if(mysql_num_rows($subscriptionResult)===1) without the ! then
it does work and it directs all traffic (including the correct course ids)
over.
I'm wondering if there's something I'm doing wrong. I've tried the
following two variations as well if(!$subscriptionResult) and
if($subscriptionResult===FALSE) but neither have worked.
the purpose of this is to avoid having people try to manually put in
course_id (especially ones that don't exist) and load the page with
content in it.
Coldfusion - Dynamic Page Break
Coldfusion - Dynamic Page Break
I have a form which has a table which may contain 0 rows or several rows.
The problem is that if there are several rows I want close the table on
the first page before the content spills over to the next page. Then
create another table for the rest of the rows on the next page along with
a nice header and table headings. The hard part is, because characters
have different widths and I can't predict what the user will type, it's
hard to calculate how many characters can fit on a row and how many rows
can fit on a page. Also if the user types something in some of the row
data, it wraps to a 2nd row. The printout looks bad when the row has only
a few rows because there is a lot of whitespace on the bottom so I was
thinking of adding in blank rows to fill it up. But again, I won't exactly
know how many rows I need to fill before it spills onto the next page.
Does anyone have a solution to this?
I have a form which has a table which may contain 0 rows or several rows.
The problem is that if there are several rows I want close the table on
the first page before the content spills over to the next page. Then
create another table for the rest of the rows on the next page along with
a nice header and table headings. The hard part is, because characters
have different widths and I can't predict what the user will type, it's
hard to calculate how many characters can fit on a row and how many rows
can fit on a page. Also if the user types something in some of the row
data, it wraps to a 2nd row. The printout looks bad when the row has only
a few rows because there is a lot of whitespace on the bottom so I was
thinking of adding in blank rows to fill it up. But again, I won't exactly
know how many rows I need to fill before it spills onto the next page.
Does anyone have a solution to this?
Sunday, 15 September 2013
How to signup Enhanced Recurring Payments on the new Paypal Sandbox?
How to signup Enhanced Recurring Payments on the new Paypal Sandbox?
I tried to sign up Recurring Payment using this url:
https://www.sandbox.paypal.com/us/cgi-bin/?cmd=_product-go&product=premium_services
but I always got error of 3005 like this:
Sorry — your last action could not be completed We are sorry, we are
experiencing temporary difficulties. Please try again later. If this error
occurred while making a payment, avoid duplicate payments by checking your
Account Overview before resending a payment.
For some browsers, this problem can be resolved by clearing or deleting
cookies.
Message 3005
How to test enhanced recurring payment on sandbox? How to create a
Automatic Billing button on sandbox? Any help or advice would be
appreciated. Thanks in advance.
I tried to sign up Recurring Payment using this url:
https://www.sandbox.paypal.com/us/cgi-bin/?cmd=_product-go&product=premium_services
but I always got error of 3005 like this:
Sorry — your last action could not be completed We are sorry, we are
experiencing temporary difficulties. Please try again later. If this error
occurred while making a payment, avoid duplicate payments by checking your
Account Overview before resending a payment.
For some browsers, this problem can be resolved by clearing or deleting
cookies.
Message 3005
How to test enhanced recurring payment on sandbox? How to create a
Automatic Billing button on sandbox? Any help or advice would be
appreciated. Thanks in advance.
AS3 - KeyboardEvent.KEY_DOWN event not firing in AIR project with preventDefault()
AS3 - KeyboardEvent.KEY_DOWN event not firing in AIR project with
preventDefault()
I am developing an kiosk-like application (a game) which needs to be
locked in full screen all the time. I am using as3/flash/AIR for it.
Things started well at first, and for the most part all works fine.. but
there is a mystery brewing somewhere which I haven't been able to figure
out... That's where your help would be greatly appreciated!
The way I handled this problem is by adding at the very beginning of the app:
stage.addEventListener(KeyboardEvent.KEY_DOWN, playerOnKeyDown);
Then, on my playerOnKeyDown function:
function playerOnKeyDown(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.ESCAPE)
{
event.preventDefault();
//More code here opening out menus, etc, etc.)
}
}
So, all of this worked just fine, but of course I needed to also bring along:
stage.focus = stage;
into the party, otherwise, when removing objects - as in removeChild() -
the event firing wouldn't behave as I wanted, because flash changed the
focus elsewhere in the display list.
I have been careful to add the focus to the stage every time a remove a
"child", and it works great everywhere, except for one time in the entire
run, right after I remove an object from an externally loaded swf.
I still add the lines as it should be expected to work:
removeChild(ChildFromLoadedSWF);
stage.focus = stage;
except that when I hit the ESC key, it takes me out of full screen (its
default behavior) circumventing completely my listener function
playerOnKeyDown.
The strange thing is that right before doing this, the line:
stage.hasEventListener(KeyboardEvent.KEY_DOWN))
traces true!
The focus is on the stage, the listener is on, and yet when pressing the
ESC key the default behavior is ignoring my function completely....
What could be causing this?
THANK YOU!!
preventDefault()
I am developing an kiosk-like application (a game) which needs to be
locked in full screen all the time. I am using as3/flash/AIR for it.
Things started well at first, and for the most part all works fine.. but
there is a mystery brewing somewhere which I haven't been able to figure
out... That's where your help would be greatly appreciated!
The way I handled this problem is by adding at the very beginning of the app:
stage.addEventListener(KeyboardEvent.KEY_DOWN, playerOnKeyDown);
Then, on my playerOnKeyDown function:
function playerOnKeyDown(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.ESCAPE)
{
event.preventDefault();
//More code here opening out menus, etc, etc.)
}
}
So, all of this worked just fine, but of course I needed to also bring along:
stage.focus = stage;
into the party, otherwise, when removing objects - as in removeChild() -
the event firing wouldn't behave as I wanted, because flash changed the
focus elsewhere in the display list.
I have been careful to add the focus to the stage every time a remove a
"child", and it works great everywhere, except for one time in the entire
run, right after I remove an object from an externally loaded swf.
I still add the lines as it should be expected to work:
removeChild(ChildFromLoadedSWF);
stage.focus = stage;
except that when I hit the ESC key, it takes me out of full screen (its
default behavior) circumventing completely my listener function
playerOnKeyDown.
The strange thing is that right before doing this, the line:
stage.hasEventListener(KeyboardEvent.KEY_DOWN))
traces true!
The focus is on the stage, the listener is on, and yet when pressing the
ESC key the default behavior is ignoring my function completely....
What could be causing this?
THANK YOU!!
Change MySQL auto_increment value without affecting existing rows
Change MySQL auto_increment value without affecting existing rows
Is this possible? Everything I find suggests that it will affect all
existing rows if I use alter table and if that happened in my case it
would do a lot of damage.
Can someone point me in the right direction here?
Is this possible? Everything I find suggests that it will affect all
existing rows if I use alter table and if that happened in my case it
would do a lot of damage.
Can someone point me in the right direction here?
Deploying application addin for Word 2007 made in VS 2010 SP1 via WiX
Deploying application addin for Word 2007 made in VS 2010 SP1 via WiX
I made an addin for Word 2007 in Visual Studio 2010 SP1, and have since
hit a brick wall in terms of deployment. I would like to deploy this addin
via Active Directory and that requires MSI installer. Now MSDN and other
resources on the Internet say that in order to add the addin properly you
need to install it in Program Files (with WiX this is child's play) and
add some keys to the Registry.
In the registry among other things I need to add the location of the
Manifests of the add in. Problem lies here in that due to being developed
by Visual Studio 2010 SP1, this address can NOT be in the form of:
C:\Program Files\\MyAddin.vsto|vstolocal
but must start with: file:/// and thus must be in the form of URI, like so:
file:///C:/Program Files//MyAddin.vsto|vstolocal
So my question is, is there a macro command or something that can get me
the address of the install directory in the above form with the forward
slashes?
Failing that anybody have any ideas how do I deploy the addin short of
doing it manually by installing it by hand (and that might fail since I
need it to be installed for ALL directory users on ALL computers)?
I made an addin for Word 2007 in Visual Studio 2010 SP1, and have since
hit a brick wall in terms of deployment. I would like to deploy this addin
via Active Directory and that requires MSI installer. Now MSDN and other
resources on the Internet say that in order to add the addin properly you
need to install it in Program Files (with WiX this is child's play) and
add some keys to the Registry.
In the registry among other things I need to add the location of the
Manifests of the add in. Problem lies here in that due to being developed
by Visual Studio 2010 SP1, this address can NOT be in the form of:
C:\Program Files\\MyAddin.vsto|vstolocal
but must start with: file:/// and thus must be in the form of URI, like so:
file:///C:/Program Files//MyAddin.vsto|vstolocal
So my question is, is there a macro command or something that can get me
the address of the install directory in the above form with the forward
slashes?
Failing that anybody have any ideas how do I deploy the addin short of
doing it manually by installing it by hand (and that might fail since I
need it to be installed for ALL directory users on ALL computers)?
How to select count and max using Linq
How to select count and max using Linq
in SQL I have the following statement that instances of errors in log
files. Can someone help me convert this into Linq?
select * from (select distinct bucket, count(bucket) as count,
max(error) as error from logs group by bucket) a order by count desc
in SQL I have the following statement that instances of errors in log
files. Can someone help me convert this into Linq?
select * from (select distinct bucket, count(bucket) as count,
max(error) as error from logs group by bucket) a order by count desc
mouse coordinates inside of one div displayed in another div - jquery
mouse coordinates inside of one div displayed in another div - jquery
So I have 2 divs:
<div class="ccc" style="position: relative; left: 100px; top: 50px; width:
200px; height: 150px; border: solid 1px;" oncontextmenu="return
false;"></div>
<div class="ddd" style="position: relative; left: 200px; top: 100px;
width: 100px; height: 40px; border: solid 1px;" oncontextmenu="return
false;"></div>
http://jsfiddle.net/n8rna/
And I need the following:
I need to track the mouse position / movement inside of the div with
class="ccc" (coordinates should be relative to this div, not to the page)
those coordinates needs to be displayed inside of the div with class="ddd"
if possible the coordinates should be registered at every 10th pixel
(10,10 - 20,10 etc instead of 1,1 - 2,1 - 3,1...)
I would prefer jquery function for this, but I am also open for other
approaches (javascript or something else).
So I have 2 divs:
<div class="ccc" style="position: relative; left: 100px; top: 50px; width:
200px; height: 150px; border: solid 1px;" oncontextmenu="return
false;"></div>
<div class="ddd" style="position: relative; left: 200px; top: 100px;
width: 100px; height: 40px; border: solid 1px;" oncontextmenu="return
false;"></div>
http://jsfiddle.net/n8rna/
And I need the following:
I need to track the mouse position / movement inside of the div with
class="ccc" (coordinates should be relative to this div, not to the page)
those coordinates needs to be displayed inside of the div with class="ddd"
if possible the coordinates should be registered at every 10th pixel
(10,10 - 20,10 etc instead of 1,1 - 2,1 - 3,1...)
I would prefer jquery function for this, but I am also open for other
approaches (javascript or something else).
HTML body onload() property
HTML body onload() property
I wrote the following functions:
function fill(value) {
return (value > 9) ? "" + value : "0" + value;
}
function fillMili(value) {
value %= 1000;
return (value <= 9) ? "00" + value :
(value <= 99) ? "0" + value :
"" + value;
};
function showClock() {
var now = new Date;
time = fill(now.getHours()) + " : " + fill(now.getMinutes()) + " : " +
fill(now.getSeconds()) + " : " + fill(now.getMilliseconds());
document.getElementById("clock").innerHTML = time;
setTimeout("showClock()",1);
}
And then put the function into the body tag and create a div tag:
<body onload="showClock()">
<div id="clock">
</div>
The page will show a fine clock. But if I change this line of code
setTimeout("showClock()",1);
to
setInterval("showClock()",1);
The browser will freeze on loading this page.
I know that the function setTimeout() will execute the assigned function
once and the function setInterval() will execute the assigned function
several times.
I have 2 questions: how does the onload property of the body work and why
doesn't the function setInterval() work in this code?
I wrote the following functions:
function fill(value) {
return (value > 9) ? "" + value : "0" + value;
}
function fillMili(value) {
value %= 1000;
return (value <= 9) ? "00" + value :
(value <= 99) ? "0" + value :
"" + value;
};
function showClock() {
var now = new Date;
time = fill(now.getHours()) + " : " + fill(now.getMinutes()) + " : " +
fill(now.getSeconds()) + " : " + fill(now.getMilliseconds());
document.getElementById("clock").innerHTML = time;
setTimeout("showClock()",1);
}
And then put the function into the body tag and create a div tag:
<body onload="showClock()">
<div id="clock">
</div>
The page will show a fine clock. But if I change this line of code
setTimeout("showClock()",1);
to
setInterval("showClock()",1);
The browser will freeze on loading this page.
I know that the function setTimeout() will execute the assigned function
once and the function setInterval() will execute the assigned function
several times.
I have 2 questions: how does the onload property of the body work and why
doesn't the function setInterval() work in this code?
Saturday, 14 September 2013
auto add 2 time after click add
auto add 2 time after click add
i try to make a simple note. after i click save in add new note, they save
as 2 note same content. it's mean they save 2 time. i dont know why.
maybe problem here, when i try to get rowID:
mRowId = (savedInstanceState == null) ? null :
(Long) savedInstanceState.getSerializable(NotesDbAdapter.KEY_ROWID);
if (mRowId == null) {
Bundle extras = getIntent().getExtras();
mRowId = extras != null ? extras.getLong(NotesDbAdapter.KEY_ROWID)
: null;
}
my code here: http://www.mediafire.com/download/w1kyy7spc522za9/Notepad.zip
i try to make a simple note. after i click save in add new note, they save
as 2 note same content. it's mean they save 2 time. i dont know why.
maybe problem here, when i try to get rowID:
mRowId = (savedInstanceState == null) ? null :
(Long) savedInstanceState.getSerializable(NotesDbAdapter.KEY_ROWID);
if (mRowId == null) {
Bundle extras = getIntent().getExtras();
mRowId = extras != null ? extras.getLong(NotesDbAdapter.KEY_ROWID)
: null;
}
my code here: http://www.mediafire.com/download/w1kyy7spc522za9/Notepad.zip
All pushed back values in vector changing to default value
All pushed back values in vector changing to default value
In an effort to reduce multiple functions (that were nearly identical) in
my code, I decided to consolidate them all into one function which takes
an additional parameter (a class with multiple parameters, actually), and
then uses those values to imitate what the multiple functions would have
done. Then, long story short, I put each of those class declarations into
a vector, and now my program seems dysfunctional.
My multiple instances of a class:
FragmentCostParameters commonFCP = FragmentCostParameters(.05, 0);
FragmentCostParameters rareFCP = FragmentCostParameters(.05, 50);
FragmentCostParameters uniqueFCP = FragmentCostParameters(.05, 125);
FragmentCostParameters legendaryFCP = FragmentCostParameters(.02, 175);
FragmentCostParameters crystallineFCP = FragmentCostParameters(.02, 250);
FragmentCostParameters superEliteFCP = FragmentCostParameters(.02, 300);
Which get placed into a vector by:
vector<FragmentCostParameters> FCPs(6);
FCPs.push_back(FragmentCostParameters(.05, 0));
FCPs.push_back(FragmentCostParameters(.05, 50));
FCPs.push_back(FragmentCostParameters(.05, 125));
FCPs.push_back(FragmentCostParameters(.02, 175));
FCPs.push_back(FragmentCostParameters(.02, 250));
FCPs.push_back(FragmentCostParameters(.02, 300));
Additionally, that class is defined below:
class FragmentCostParameters {
public:
double multFactor;
double subtractFactor;
FragmentCostParameters(double _multFactor, double _subtractFactor){
multFactor = _multFactor;
subtractFactor = _subtractFactor;
}
FragmentCostParameters(){
multFactor = .05;
subtractFactor = 0;
}
};
Now, you'll notice that the default constructor for the
FragmentCostParameters involves setting multFactor = .05 and
subtractFactor = 0. However, it seems that no matter what I push back,
each of the values in my vector become mutated into those values. At
least, that's what VS 2011 tells me the values are equal to when I'm
looking at them in a local scope in the following function (which is the
only place they're used).
int FragmentCost(double skillLevel, int duration, FragmentCostParameters
FCP){
return
max((int)(ceil(FCP.multFactor*(skillLevel-FCP.subtractFactor))*ceil(duration/30.0))
, 0);
}
And the only place that FragmentCost is called is from this function
below, which is supposed to pass different values .. but somewhere in the
process, when I look at locals in FragmentCost, they're always the default
values in the constructor for the class.
//given a skill level + duration, will return an array with the fragment
usage
int* regularTotalFragCost(int skillLevel, int duration){
int fragments[7] = {0,0,0,0,0,0,0};
fragments[0]+= FragmentCost(skillLevel,duration, FCPs[0]);
fragments[1]+= FragmentCost(skillLevel,duration, FCPs[0]);
fragments[0]+= FragmentCost(skillLevel,duration, FCPs[1]);
fragments[2]+= FragmentCost(skillLevel,duration, FCPs[1]);
fragments[0]+= FragmentCost(skillLevel,duration, FCPs[2]);
fragments[3]+= FragmentCost(skillLevel,duration, FCPs[2]);
fragments[0]+= FragmentCost(skillLevel,duration, FCPs[3]);
fragments[4]+= FragmentCost(skillLevel,duration, FCPs[3]);
fragments[0]+= FragmentCost(skillLevel,duration, FCPs[4]);
fragments[5]+= FragmentCost(skillLevel,duration, FCPs[4]);
fragments[0]+= FragmentCost(skillLevel,duration, FCPs[5]);
fragments[6]+= FragmentCost(skillLevel,duration, FCPs[5]);
return fragments;
}
For some reason I feel that I'm making a really stupid mistake somewhere,
but for the life of me I can't seem to figure it out. I would appreciate
any help and/or advice anyone could offer.
In an effort to reduce multiple functions (that were nearly identical) in
my code, I decided to consolidate them all into one function which takes
an additional parameter (a class with multiple parameters, actually), and
then uses those values to imitate what the multiple functions would have
done. Then, long story short, I put each of those class declarations into
a vector, and now my program seems dysfunctional.
My multiple instances of a class:
FragmentCostParameters commonFCP = FragmentCostParameters(.05, 0);
FragmentCostParameters rareFCP = FragmentCostParameters(.05, 50);
FragmentCostParameters uniqueFCP = FragmentCostParameters(.05, 125);
FragmentCostParameters legendaryFCP = FragmentCostParameters(.02, 175);
FragmentCostParameters crystallineFCP = FragmentCostParameters(.02, 250);
FragmentCostParameters superEliteFCP = FragmentCostParameters(.02, 300);
Which get placed into a vector by:
vector<FragmentCostParameters> FCPs(6);
FCPs.push_back(FragmentCostParameters(.05, 0));
FCPs.push_back(FragmentCostParameters(.05, 50));
FCPs.push_back(FragmentCostParameters(.05, 125));
FCPs.push_back(FragmentCostParameters(.02, 175));
FCPs.push_back(FragmentCostParameters(.02, 250));
FCPs.push_back(FragmentCostParameters(.02, 300));
Additionally, that class is defined below:
class FragmentCostParameters {
public:
double multFactor;
double subtractFactor;
FragmentCostParameters(double _multFactor, double _subtractFactor){
multFactor = _multFactor;
subtractFactor = _subtractFactor;
}
FragmentCostParameters(){
multFactor = .05;
subtractFactor = 0;
}
};
Now, you'll notice that the default constructor for the
FragmentCostParameters involves setting multFactor = .05 and
subtractFactor = 0. However, it seems that no matter what I push back,
each of the values in my vector become mutated into those values. At
least, that's what VS 2011 tells me the values are equal to when I'm
looking at them in a local scope in the following function (which is the
only place they're used).
int FragmentCost(double skillLevel, int duration, FragmentCostParameters
FCP){
return
max((int)(ceil(FCP.multFactor*(skillLevel-FCP.subtractFactor))*ceil(duration/30.0))
, 0);
}
And the only place that FragmentCost is called is from this function
below, which is supposed to pass different values .. but somewhere in the
process, when I look at locals in FragmentCost, they're always the default
values in the constructor for the class.
//given a skill level + duration, will return an array with the fragment
usage
int* regularTotalFragCost(int skillLevel, int duration){
int fragments[7] = {0,0,0,0,0,0,0};
fragments[0]+= FragmentCost(skillLevel,duration, FCPs[0]);
fragments[1]+= FragmentCost(skillLevel,duration, FCPs[0]);
fragments[0]+= FragmentCost(skillLevel,duration, FCPs[1]);
fragments[2]+= FragmentCost(skillLevel,duration, FCPs[1]);
fragments[0]+= FragmentCost(skillLevel,duration, FCPs[2]);
fragments[3]+= FragmentCost(skillLevel,duration, FCPs[2]);
fragments[0]+= FragmentCost(skillLevel,duration, FCPs[3]);
fragments[4]+= FragmentCost(skillLevel,duration, FCPs[3]);
fragments[0]+= FragmentCost(skillLevel,duration, FCPs[4]);
fragments[5]+= FragmentCost(skillLevel,duration, FCPs[4]);
fragments[0]+= FragmentCost(skillLevel,duration, FCPs[5]);
fragments[6]+= FragmentCost(skillLevel,duration, FCPs[5]);
return fragments;
}
For some reason I feel that I'm making a really stupid mistake somewhere,
but for the life of me I can't seem to figure it out. I would appreciate
any help and/or advice anyone could offer.
Centered perspective in css
Centered perspective in css
is there any way to make the perspective of an element in HTML centered in
the middle of the screen, so that the perspective point is not moved when
you are scrolling...?
Thanks
is there any way to make the perspective of an element in HTML centered in
the middle of the screen, so that the perspective point is not moved when
you are scrolling...?
Thanks
Invalid column name 'ISBN'
Invalid column name 'ISBN'
Ive created an update command but it has an error. My code is this.
cmd.CommandText = ("UPDATE Penalty SET [Due Date] = '"+ duedate +"' WHERE
ISBN = '" + textBox4.Text + "'");
cmd.ExecuteNonQuery();
it said that Invalid column name 'ISBN' . I cant figure out the error.
Ive created an update command but it has an error. My code is this.
cmd.CommandText = ("UPDATE Penalty SET [Due Date] = '"+ duedate +"' WHERE
ISBN = '" + textBox4.Text + "'");
cmd.ExecuteNonQuery();
it said that Invalid column name 'ISBN' . I cant figure out the error.
Will this leak?
Will this leak?
calculate2 essentially does matrix calculation based on neighbors. I
haven't written C in a while and I was wondering if the memcpy at every
iteration was going to be a problem for memory or if I should free the
tmpMatrix after every k iteration before doing a new memcpy?
void transform2(int *pMatrix, int iteration)
{
if(iteration == 0)
return;
int fullLength = MATRIX_DIM * MATRIX_DIM;
int tmpMatrix[fullLength];
int start;
int row;
int col;
for(start = 0; start < iteration ; start++)
{
memcpy(tmpMatrix, pMatrix, sizeof(pMatrix[0]) * (fullLength));
for(row = 0; row < MATRIX_DIM ; row++)
{
for(col = 0; col < MATRIX_DIM ; col++)
{
int res = calculate2(pMatrix, tmpMatrix, row, col , iteration);
set_at(pMatrix, res, row, col);
}
}
}
}
Also, I'm open to suggestions if you guys think there's a cleaner way of
handling this. Essentially the tmpMatrix is the previous matrix at
iteration-1.
P.S pMatrix is a global int *_Matrix declaration and I use free() at the
end of my main for that one.
calculate2 essentially does matrix calculation based on neighbors. I
haven't written C in a while and I was wondering if the memcpy at every
iteration was going to be a problem for memory or if I should free the
tmpMatrix after every k iteration before doing a new memcpy?
void transform2(int *pMatrix, int iteration)
{
if(iteration == 0)
return;
int fullLength = MATRIX_DIM * MATRIX_DIM;
int tmpMatrix[fullLength];
int start;
int row;
int col;
for(start = 0; start < iteration ; start++)
{
memcpy(tmpMatrix, pMatrix, sizeof(pMatrix[0]) * (fullLength));
for(row = 0; row < MATRIX_DIM ; row++)
{
for(col = 0; col < MATRIX_DIM ; col++)
{
int res = calculate2(pMatrix, tmpMatrix, row, col , iteration);
set_at(pMatrix, res, row, col);
}
}
}
}
Also, I'm open to suggestions if you guys think there's a cleaner way of
handling this. Essentially the tmpMatrix is the previous matrix at
iteration-1.
P.S pMatrix is a global int *_Matrix declaration and I use free() at the
end of my main for that one.
How to update field through Ajax in Ruby on Rails form?
How to update field through Ajax in Ruby on Rails form?
In my form I am trying to update the exchange_rate field when the user
changes the currency select box.
application.js:
$("#invoice_currency").change(function() {
$.ajax({
url: '/invoices/get_exchange_rate',
dataType: 'script'
})
});
invoices_controller.rb:
def get_exchange_rate
from = current_user.base_currency
to = params[:currency]
@exchange_rate = GoogleCurrency.get_exchange_rate(from, to)
end
get_exchange_rate.js.erb:
$('#invoice_exchange_rate').val('<%= @exchange_rate %>');
google_currency.rb:
module GoogleCurrency
def self.get_exchange_rate(from, to)
....
end
end
This isn't working yet because, for some reason, params[:currency] can't
be evaluated dynamically through Ajax.
Can anybody tell me how it's done?
Thanks for any help.
In my form I am trying to update the exchange_rate field when the user
changes the currency select box.
application.js:
$("#invoice_currency").change(function() {
$.ajax({
url: '/invoices/get_exchange_rate',
dataType: 'script'
})
});
invoices_controller.rb:
def get_exchange_rate
from = current_user.base_currency
to = params[:currency]
@exchange_rate = GoogleCurrency.get_exchange_rate(from, to)
end
get_exchange_rate.js.erb:
$('#invoice_exchange_rate').val('<%= @exchange_rate %>');
google_currency.rb:
module GoogleCurrency
def self.get_exchange_rate(from, to)
....
end
end
This isn't working yet because, for some reason, params[:currency] can't
be evaluated dynamically through Ajax.
Can anybody tell me how it's done?
Thanks for any help.
Disable partial text selection in phonegap web app (android)
Disable partial text selection in phonegap web app (android)
I want to disable the text selection effect (the popup tool for
copy/paste/select-all on Andorid) on some DOM elements of a phonegap web
app. Mostly, I want to enable text selection in textarea and input.
I read a solution that totally disable text selection at
disabling-text-selection-in-phonegap. How can I just disable it for
elements besides textarea and input?
I want to disable the text selection effect (the popup tool for
copy/paste/select-all on Andorid) on some DOM elements of a phonegap web
app. Mostly, I want to enable text selection in textarea and input.
I read a solution that totally disable text selection at
disabling-text-selection-in-phonegap. How can I just disable it for
elements besides textarea and input?
Friday, 13 September 2013
How to check Whether ASP.NET button is Clicked or Not on Page_Load
How to check Whether ASP.NET button is Clicked or Not on Page_Load
May I know if you guys have any suggestions on How to Check Whether the
button is Click or Not in ASP.NET, Because when it's clicked then I need
to perform some operation on Page_Load, This shouldn't be entering to
Button_Click Event to Find. Is there any way that I can find where its
click or not on Client Side and Take it to Page_Load.
Thanks!
May I know if you guys have any suggestions on How to Check Whether the
button is Click or Not in ASP.NET, Because when it's clicked then I need
to perform some operation on Page_Load, This shouldn't be entering to
Button_Click Event to Find. Is there any way that I can find where its
click or not on Client Side and Take it to Page_Load.
Thanks!
How to send IOS Camara video live to server
How to send IOS Camara video live to server
In my application I need to upload a live video from my ios device to
server and also I need to play that video in some other device.I found
only talks about streaming videos from server to iPhone. But I need a help
to upload a live streaming video form iphone to scerver. Please suggest me
some ideas and source code to implement this concept
Thanks in advance
In my application I need to upload a live video from my ios device to
server and also I need to play that video in some other device.I found
only talks about streaming videos from server to iPhone. But I need a help
to upload a live streaming video form iphone to scerver. Please suggest me
some ideas and source code to implement this concept
Thanks in advance
assigning multiple varables with one call to single-output MATLAB function
assigning multiple varables with one call to single-output MATLAB function
I want to take the simple example code and make the assignment on one line:
X = rand();
Y = rand();
possible? thanks!
I want to take the simple example code and make the assignment on one line:
X = rand();
Y = rand();
possible? thanks!
how to make openldap search from root of directory tree
how to make openldap search from root of directory tree
I am new to this site. Please help me with a query on openldap search. I
dont want to provide info like "base dc=example, dc=com" in ldap.conf. I
want to give only host and port info in ldap.conf Can we make openldap
client to search from root of the directory tree?
If I dont add any line for "base" in ldap.conf, and search for a valid
user, the Active server gives search response as "no such object"
Is there some other way to acieve always search from root, without filling
explicitly "base dc=xxx, dc=yyy" in ldap.conf on client side?
I am new to this site. Please help me with a query on openldap search. I
dont want to provide info like "base dc=example, dc=com" in ldap.conf. I
want to give only host and port info in ldap.conf Can we make openldap
client to search from root of the directory tree?
If I dont add any line for "base" in ldap.conf, and search for a valid
user, the Active server gives search response as "no such object"
Is there some other way to acieve always search from root, without filling
explicitly "base dc=xxx, dc=yyy" in ldap.conf on client side?
rendering .hbs templates in Ember
rendering .hbs templates in Ember
I'm looking at an Ember demo project
https://github.com/kagemusha/ember-rails-devise-demo that uses templates
endeding in .hbs. Normally in Ember, you declare the template by
attaching, for example, id='about' for the about route. However, none of
the templates ending in .hbs in this project use an id. How does Ember
know which template to render?
Example template
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<div class="brand strong">{{#linkTo
'home'}}Ember-Rails-Devise{{/linkTo}}</div>
<ul class="nav">
<li>{{#linkTo help}}Help{{/linkTo}}</li>
</ul>
<div class="btn-group pull-right">
{{#if isAuthenticated}}
<button class="btn" {{action logout}}>Logout</button>
{{else}}
{{view App.MenuItem href="#/login" label="Login" }}
{{view App.MenuItem href="#/registration" label="Register"}}
{{/if}}
</div>
</div>
</div>
</div>
I'm looking at an Ember demo project
https://github.com/kagemusha/ember-rails-devise-demo that uses templates
endeding in .hbs. Normally in Ember, you declare the template by
attaching, for example, id='about' for the about route. However, none of
the templates ending in .hbs in this project use an id. How does Ember
know which template to render?
Example template
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<div class="brand strong">{{#linkTo
'home'}}Ember-Rails-Devise{{/linkTo}}</div>
<ul class="nav">
<li>{{#linkTo help}}Help{{/linkTo}}</li>
</ul>
<div class="btn-group pull-right">
{{#if isAuthenticated}}
<button class="btn" {{action logout}}>Logout</button>
{{else}}
{{view App.MenuItem href="#/login" label="Login" }}
{{view App.MenuItem href="#/registration" label="Register"}}
{{/if}}
</div>
</div>
</div>
</div>
Java Server and Client Time
Java Server and Client Time
Please can any body help me I have been faced time related problem
regarding client and server time display issue since 1 week.
Description: Actually server is located in Germany when client (example :
india) try to send any message to his contacts it will show the message
sending time is server time (means Germany time).But I should say local
specific time.I user send any then I show message sending time like this.
public static String retrieveFullDateFromDateinAMPM ( Date date ) {
SimpleDateFormat sdf =
new SimpleDateFormat("dd/MM/yy hh:mm a", Locale.getDefault())
;
return sdf.format(date);
}
Here I send date value to my helper method
retrieveFullDateFromDateinAMPM(Date date) and I will return the message
sending time like this : return sdf.format(date); to the web page. But it
shows server located time but I should need to show locale specific time.
Please help me. Advanced Thanks.
Please can any body help me I have been faced time related problem
regarding client and server time display issue since 1 week.
Description: Actually server is located in Germany when client (example :
india) try to send any message to his contacts it will show the message
sending time is server time (means Germany time).But I should say local
specific time.I user send any then I show message sending time like this.
public static String retrieveFullDateFromDateinAMPM ( Date date ) {
SimpleDateFormat sdf =
new SimpleDateFormat("dd/MM/yy hh:mm a", Locale.getDefault())
;
return sdf.format(date);
}
Here I send date value to my helper method
retrieveFullDateFromDateinAMPM(Date date) and I will return the message
sending time like this : return sdf.format(date); to the web page. But it
shows server located time but I should need to show locale specific time.
Please help me. Advanced Thanks.
Error when I populate a gridcontrol with entity Framework
Error when I populate a gridcontrol with entity Framework
I have a desktop application in C#. I want to populate a grid with some
lines from database(SQL Server).I want to use 3 separation layers: - 3
projects(UI,BL,DB).In DB project I used entity framework 4.4 for creating
the DB model .I wrote in designer the details for database connection and
in the model now I have all my tables with their columns and
relasionships.In this project DB ,I added a class DataSource:
public class DataSource : Component, IListSource
{
#region Declarations
private static DataSource instance;
public SalesEntities context;
I have a desktop application in C#. I want to populate a grid with some
lines from database(SQL Server).I want to use 3 separation layers: - 3
projects(UI,BL,DB).In DB project I used entity framework 4.4 for creating
the DB model .I wrote in designer the details for database connection and
in the model now I have all my tables with their columns and
relasionships.In this project DB ,I added a class DataSource:
public class DataSource : Component, IListSource
{
#region Declarations
private static DataSource instance;
public SalesEntities context;
Thursday, 12 September 2013
How can I save the value of a grid cell in a size(n) grivdiew?
How can I save the value of a grid cell in a size(n) grivdiew?
I have a gridview that is populated from a custom binding to a excel
spreadsheet the sheet would have varying columns and rows and editing is
triggered by on row select. I would like to update the a cell and post the
updated data back to the DataTable for export via excel.
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server" />
<asp:UpdatePanel ID="grdUpdatePanel" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gridViewTest" runat="server"
OnRowDataBound="gv_RowDataBound"
OnRowEditing="gv_RowEditing"
OnRowUpdated="gv_RowUpdating">
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<br/>
<div>
<asp:Button ID="btnExport" runat="server" Text="Export"
onclick="btnExport_Click" />
</div>
</form>
public partial class ExportAndImportExcel : System.Web.UI.Page
{
private DataTable dt;
private DataTable dtab
{
get { return dt; }
set
{
if (dt == null)
{
dt = new DataTable();
}
dt = Session["dt"] as DataTable;
}
}
protected void Page_Load(object sender, EventArgs e)
{
// Disable Export button
this.btnExport.Enabled = false;
loadSpreadsheet(); //Bind data to gridview
}
#region Serialize operation
/// <summary>
/// Serialize excel data stored in datable
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Serializer() {
JavaScriptSerializer serializer = new JavaScriptSerializer();
String strSerializedText = serializer.Serialize(from a in
dt.AsEnumerable() select a.ItemArray);
}
I have a gridview that is populated from a custom binding to a excel
spreadsheet the sheet would have varying columns and rows and editing is
triggered by on row select. I would like to update the a cell and post the
updated data back to the DataTable for export via excel.
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server" />
<asp:UpdatePanel ID="grdUpdatePanel" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gridViewTest" runat="server"
OnRowDataBound="gv_RowDataBound"
OnRowEditing="gv_RowEditing"
OnRowUpdated="gv_RowUpdating">
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<br/>
<div>
<asp:Button ID="btnExport" runat="server" Text="Export"
onclick="btnExport_Click" />
</div>
</form>
public partial class ExportAndImportExcel : System.Web.UI.Page
{
private DataTable dt;
private DataTable dtab
{
get { return dt; }
set
{
if (dt == null)
{
dt = new DataTable();
}
dt = Session["dt"] as DataTable;
}
}
protected void Page_Load(object sender, EventArgs e)
{
// Disable Export button
this.btnExport.Enabled = false;
loadSpreadsheet(); //Bind data to gridview
}
#region Serialize operation
/// <summary>
/// Serialize excel data stored in datable
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Serializer() {
JavaScriptSerializer serializer = new JavaScriptSerializer();
String strSerializedText = serializer.Serialize(from a in
dt.AsEnumerable() select a.ItemArray);
}
How java casting work, is it change the state of Object or create new Object?
How java casting work, is it change the state of Object or create new Object?
I have a method dummy with A as class parameter, but i need to pass
instance of subclasses B to that method. I know from: Does Java casting
introduce overhead? Why? that downcasting in java have overhead. Most of
my code deal with subclass B so i dont use downcasting for this purpose.
Instead i use temporal instance variable cc for that purpose. But this is
not make a change for object of subclass m. I need change in variable cc
avaliable too for instance variable m. This is my code:
public class TestExtends {
public TestExtends() {
SubTypeA m = new SubTypeA(12, 3);
dummy(m);
MainType cc = m;
dummy(cc);
System.out.println(m.a);
System.out.println(cc.a);
}
public void dummy(MainType t) {
t.a = 22222;
}
public static void main(String[] args) {
new TestExtends();
}
}
class MainType {
public int a = 0;
public MainType(int a) {
this.a = a;
}
}
class SubTypeA extends MainType {
public int a;
public int b;
public SubTypeA(int a, int b) {
super(a);
this.a = a;
this.b = b;
}
}
with output
12
22222
I have a method dummy with A as class parameter, but i need to pass
instance of subclasses B to that method. I know from: Does Java casting
introduce overhead? Why? that downcasting in java have overhead. Most of
my code deal with subclass B so i dont use downcasting for this purpose.
Instead i use temporal instance variable cc for that purpose. But this is
not make a change for object of subclass m. I need change in variable cc
avaliable too for instance variable m. This is my code:
public class TestExtends {
public TestExtends() {
SubTypeA m = new SubTypeA(12, 3);
dummy(m);
MainType cc = m;
dummy(cc);
System.out.println(m.a);
System.out.println(cc.a);
}
public void dummy(MainType t) {
t.a = 22222;
}
public static void main(String[] args) {
new TestExtends();
}
}
class MainType {
public int a = 0;
public MainType(int a) {
this.a = a;
}
}
class SubTypeA extends MainType {
public int a;
public int b;
public SubTypeA(int a, int b) {
super(a);
this.a = a;
this.b = b;
}
}
with output
12
22222
data frame to structured list
data frame to structured list
This is an interesting question that I can't seem to find the answer to.
Let me just jump right in. I need to take a data frame created from:
TPA <- ddply(MT,~plot,summarise,TPA=length(unique(tree.number))*50)
> TPA
plot TPA
1 10A 700
2 10B 1000
3 1A 900
4 1B 950
5 2A 950
6 2B 650
7 3A 650
8 3B 1350
9 4A 1450
10 4B 1350
11 5A 850
12 5B 1100
13 6A 1050
14 6B 550
15 7A 850
16 7B 800
17 8A 2450
18 8B 950
19 9A 1150
20 9B 1000
and convert this to:
y <- list(one=c(900,950), two=c(950,650), three=c(650,1350),
four=c(1450,1350), five=c(850,1100), six=c(1050,550),
seven=c(850,800), eight=c(2450,950), nine=c(1150,1000), ten=c(700,1000))
> y
$one
[1] 900 950
$two
[1] 950 650
$three
[1] 650 1350
$four
[1] 1450 1350
$five
[1] 850 1100
$six
[1] 1050 550
$seven
[1] 850 800
$eight
[1] 2450 950
$nine
[1] 1150 1000
$ten
[1] 700 1000
Notice that 1A in the data frame corresponds to "one" in the list. I know
how to go the other way from a list to a data frame, but I can't figure
out how to go from a data frame to a list. I have a function that requires
a list to feed into the function. For completeness, here is the part that
uses the list:
yi.bar <- unlist(lapply(y,mean))
s2i <- unlist(lapply(y,var))
Any suggestions?
Thank you!
This is an interesting question that I can't seem to find the answer to.
Let me just jump right in. I need to take a data frame created from:
TPA <- ddply(MT,~plot,summarise,TPA=length(unique(tree.number))*50)
> TPA
plot TPA
1 10A 700
2 10B 1000
3 1A 900
4 1B 950
5 2A 950
6 2B 650
7 3A 650
8 3B 1350
9 4A 1450
10 4B 1350
11 5A 850
12 5B 1100
13 6A 1050
14 6B 550
15 7A 850
16 7B 800
17 8A 2450
18 8B 950
19 9A 1150
20 9B 1000
and convert this to:
y <- list(one=c(900,950), two=c(950,650), three=c(650,1350),
four=c(1450,1350), five=c(850,1100), six=c(1050,550),
seven=c(850,800), eight=c(2450,950), nine=c(1150,1000), ten=c(700,1000))
> y
$one
[1] 900 950
$two
[1] 950 650
$three
[1] 650 1350
$four
[1] 1450 1350
$five
[1] 850 1100
$six
[1] 1050 550
$seven
[1] 850 800
$eight
[1] 2450 950
$nine
[1] 1150 1000
$ten
[1] 700 1000
Notice that 1A in the data frame corresponds to "one" in the list. I know
how to go the other way from a list to a data frame, but I can't figure
out how to go from a data frame to a list. I have a function that requires
a list to feed into the function. For completeness, here is the part that
uses the list:
yi.bar <- unlist(lapply(y,mean))
s2i <- unlist(lapply(y,var))
Any suggestions?
Thank you!
More pythonic way to manage a list of callbacks
More pythonic way to manage a list of callbacks
I'm writing a multi-threaded Python application with serial IO, and I have
this construct in the IO class:
def __init__(self):
# Register these with thread-safe functions having the arguments listed
self.callbacks_status = [] # args: (pod_index, message, color)
self.callbacks_conn = [] # args: (pod_index, message, color)
self.callbacks_angle = [] # args: (pod_index, angle_deg)
self.callbacks_brake = [] # args: (brake_on)
Then, when one of my updating threads gets a new status, I'm doing
something like this every time:
for func in self.callbacks_conn:
func(i, "Open", "yellow")
Needless to say, this is ugly and feels non-pythonic. Is there a more
elegant way to call a list of functions with the same arguments? Basically
I am looking for the map function in reverse.
I'm writing a multi-threaded Python application with serial IO, and I have
this construct in the IO class:
def __init__(self):
# Register these with thread-safe functions having the arguments listed
self.callbacks_status = [] # args: (pod_index, message, color)
self.callbacks_conn = [] # args: (pod_index, message, color)
self.callbacks_angle = [] # args: (pod_index, angle_deg)
self.callbacks_brake = [] # args: (brake_on)
Then, when one of my updating threads gets a new status, I'm doing
something like this every time:
for func in self.callbacks_conn:
func(i, "Open", "yellow")
Needless to say, this is ugly and feels non-pythonic. Is there a more
elegant way to call a list of functions with the same arguments? Basically
I am looking for the map function in reverse.
Changing variable (array of structs) from global to local (simple C program)
Changing variable (array of structs) from global to local (simple C program)
This is my code that I am compiling in C. Currently I have a global
variable 'code' that is an array of structs(struct instruction). I've been
trying to instead make this a local variable in main and pass it as a
parameter. Also I believe this means I will need to have read file return
a struct instruction*. I would greatly appreciate it if someone could
explain, or show me how to properly use 'code' as a local variable. Also I
am interested in what makes local variables better or more efficient than
global variables. Thanks!
#include<stdio.h>
#include <stdlib.h>
typedef struct instruction{
int op; //opcode
int l; // L
int m; // M
} instr;
FILE * ifp; //input file pointer
FILE * ofp; //output file pointer
instr code[501];
void read_file(instr code[]);
char* lookup_OP(int OP);
void print_program(instr code[]);
void print_input_list(instr code[]);
int main(){
read_file(code);
print_input_list(code);//used for debugging
print_program(code);
}
void read_file(instr code[]){
int i = 0;
ifp = fopen("input.txt", "r");
while(!feof(ifp)){
fscanf(ifp,"%d%d%d",&code[i].op, &code[i].l, &code[i].m);
i++;
}
code[i].op = -1; //identifies the end of the code in the array
fclose(ifp);
}
This is my code that I am compiling in C. Currently I have a global
variable 'code' that is an array of structs(struct instruction). I've been
trying to instead make this a local variable in main and pass it as a
parameter. Also I believe this means I will need to have read file return
a struct instruction*. I would greatly appreciate it if someone could
explain, or show me how to properly use 'code' as a local variable. Also I
am interested in what makes local variables better or more efficient than
global variables. Thanks!
#include<stdio.h>
#include <stdlib.h>
typedef struct instruction{
int op; //opcode
int l; // L
int m; // M
} instr;
FILE * ifp; //input file pointer
FILE * ofp; //output file pointer
instr code[501];
void read_file(instr code[]);
char* lookup_OP(int OP);
void print_program(instr code[]);
void print_input_list(instr code[]);
int main(){
read_file(code);
print_input_list(code);//used for debugging
print_program(code);
}
void read_file(instr code[]){
int i = 0;
ifp = fopen("input.txt", "r");
while(!feof(ifp)){
fscanf(ifp,"%d%d%d",&code[i].op, &code[i].l, &code[i].m);
i++;
}
code[i].op = -1; //identifies the end of the code in the array
fclose(ifp);
}
How can I make sure I received whole file through socket stream?
How can I make sure I received whole file through socket stream?
Ok, So I'm making a Java program that has a server and client and I'm
sending a Zip file from server to client. I have sending the file down,
almost. But recieving I've found some inconsistency. My code isn't always
getting the full archive. I'm guessing it's terminating before the
BufferedReader has the full thing. Here's the code for the client:
public void run(String[] args) {
try {
clientSocket = new Socket("jacob-custom-pc", 4444);
out = new PrintWriter(clientSocket.getOutputStream(), true);
in = new BufferedInputStream(clientSocket.getInputStream());
BufferedReader inRead = new BufferedReader(new
InputStreamReader(in));
int size = 0;
while(true) {
if(in.available() > 0) {
byte[] array = new byte[in.available()];
in.read(array);
System.out.println(array.length);
System.out.println("recieved file!");
FileOutputStream fileOut = new
FileOutputStream("out.zip");
fileOut.write(array);
fileOut.close();
break;
}
}
}
} catch(IOException e) {
e.printStackTrace();
System.exit(-1);
}
}
So how can I be sure the full archive is there before it writes the file?
Ok, So I'm making a Java program that has a server and client and I'm
sending a Zip file from server to client. I have sending the file down,
almost. But recieving I've found some inconsistency. My code isn't always
getting the full archive. I'm guessing it's terminating before the
BufferedReader has the full thing. Here's the code for the client:
public void run(String[] args) {
try {
clientSocket = new Socket("jacob-custom-pc", 4444);
out = new PrintWriter(clientSocket.getOutputStream(), true);
in = new BufferedInputStream(clientSocket.getInputStream());
BufferedReader inRead = new BufferedReader(new
InputStreamReader(in));
int size = 0;
while(true) {
if(in.available() > 0) {
byte[] array = new byte[in.available()];
in.read(array);
System.out.println(array.length);
System.out.println("recieved file!");
FileOutputStream fileOut = new
FileOutputStream("out.zip");
fileOut.write(array);
fileOut.close();
break;
}
}
}
} catch(IOException e) {
e.printStackTrace();
System.exit(-1);
}
}
So how can I be sure the full archive is there before it writes the file?
SQL for message inbox
SQL for message inbox
I have an inbox of messages for my users, I have a 'messages' table and a
'users' table. Messages table has to and from fields which contain the
user IDs.
I want to select the latest message from every user, where the to field is
the current user ID, i.e.
"select (latest Message, by Message.ID) from (unique users) where
Message.to = $currentUserID (and left join User where UserID =
Message.from)"
I want to end up with something like this:
http://www.innerfence.com/blog/wp-content/uploads/screenshot-iphone-inbox-thumb.png
I can't figure out the query I need for this, please help..!
I have an inbox of messages for my users, I have a 'messages' table and a
'users' table. Messages table has to and from fields which contain the
user IDs.
I want to select the latest message from every user, where the to field is
the current user ID, i.e.
"select (latest Message, by Message.ID) from (unique users) where
Message.to = $currentUserID (and left join User where UserID =
Message.from)"
I want to end up with something like this:
http://www.innerfence.com/blog/wp-content/uploads/screenshot-iphone-inbox-thumb.png
I can't figure out the query I need for this, please help..!
Wednesday, 11 September 2013
twitter bootstrap 3 tab view fade does not work properly
twitter bootstrap 3 tab view fade does not work properly
I use twitter bootstrap 3 applying .fade to show tabs with fade. That's
fine except for the first tab's content is not shown for the first time:
http://jsfiddle.net/tVSv9/
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#home" data-toggle="tab">Home</a></li>
<li><a href="#profile" data-toggle="tab">Profile</a></li>
<li><a href="#messages" data-toggle="tab">Messages</a></li>
</ul>
<div id='content' class="tab-content">
<div class="tab-pane fade active" id="home">
<ul>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
</ul>
</div>
<div class="tab-pane fade" id="profile">
<ul>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
</ul>
</div>
<div class="tab-pane fade" id="messages">
this is my message
</div>
<div class="tab-pane fade" id="settings"></div>
</div>
Where is the problem inside the code?
I use twitter bootstrap 3 applying .fade to show tabs with fade. That's
fine except for the first tab's content is not shown for the first time:
http://jsfiddle.net/tVSv9/
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#home" data-toggle="tab">Home</a></li>
<li><a href="#profile" data-toggle="tab">Profile</a></li>
<li><a href="#messages" data-toggle="tab">Messages</a></li>
</ul>
<div id='content' class="tab-content">
<div class="tab-pane fade active" id="home">
<ul>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
</ul>
</div>
<div class="tab-pane fade" id="profile">
<ul>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
</ul>
</div>
<div class="tab-pane fade" id="messages">
this is my message
</div>
<div class="tab-pane fade" id="settings"></div>
</div>
Where is the problem inside the code?
Calabash-android : rake build error
Calabash-android : rake build error
I am new to calabash-android , i am getting the following error while
executing "rake build " command .
C:\calabash-android\ruby-gem>rake build
rake aborted!
cannot load such file --
C:/Ruby193/lib/ruby/gems/1.9.1/gems/popen4-0.1.2/lib/op en3
lib/calabash-android/helpers.rb:6:in `'
C:/calabash-android/ruby-gem/Rakefile:2:in `load'
C:/calabash-android/ruby-gem/Rakefile:2:in `'
(See full trace by running task with --trace)
These are the steps i have followed
git clone https://github.com/calabash/calabash-android.git
git submodule init
git submodule update
i used gem install popen4 but i again same error Please help me .
I am new to calabash-android , i am getting the following error while
executing "rake build " command .
C:\calabash-android\ruby-gem>rake build
rake aborted!
cannot load such file --
C:/Ruby193/lib/ruby/gems/1.9.1/gems/popen4-0.1.2/lib/op en3
lib/calabash-android/helpers.rb:6:in `'
C:/calabash-android/ruby-gem/Rakefile:2:in `load'
C:/calabash-android/ruby-gem/Rakefile:2:in `'
(See full trace by running task with --trace)
These are the steps i have followed
git clone https://github.com/calabash/calabash-android.git
git submodule init
git submodule update
i used gem install popen4 but i again same error Please help me .
php adding up checkboxs
php adding up checkboxs
I have a list of check boxs that are displaying right and retunring the
values of all that are checked. I use that in one part of my code but
would also like to get the number or boxes check. The checkboxes are like
so:
<div id="ironSet">
Include in Set
<input type="checkbox" name="iron[]" value="3" />
<span class="smallfont">3</span>
<input type="checkbox" name="iron[]" value="4" />
<span class="smallfont">4</span>
<input type="checkbox" name="iron[]" value="5" />
<span class="smallfont">5</span>
<input type="checkbox" name="iron[]" value="6" />
<span class="smallfont">6</span>
<input type="checkbox" name="iron[]" value="7" />
<span class="smallfont">7</span>
<input type="checkbox" name="iron[]" value="8" />
<span class="smallfont">8</span>
<input type="checkbox" name="iron[]" value="9" />
<span class="smallfont">9</span>
<input type="checkbox" name="iron[]" value="PW" />
<span class="smallfont">PW</span>
<input type="checkbox" name="iron[]" value="TW" />
<span class="smallfont">TW</span>
<input type="checkbox" name="iron[]" value="SW" />
<span class="smallfont">SW</span>
</div>
I echo these values in a php review form like so
$iron = join(", ", $_REQUEST["iron"]);
echo (!empty($_REQUEST['iron'])) ? "<div class='reviewItem'><span
class='reviewTitle'>In Set:</span>{$iron}</div>" : "";
This would return the values, if any, for all that are checked. Is there a
way I can get the number of "iron[]" boxes check as will and store it in
another variable? I am trying to multiply the number of boxes checked by a
price variable.
I have a list of check boxs that are displaying right and retunring the
values of all that are checked. I use that in one part of my code but
would also like to get the number or boxes check. The checkboxes are like
so:
<div id="ironSet">
Include in Set
<input type="checkbox" name="iron[]" value="3" />
<span class="smallfont">3</span>
<input type="checkbox" name="iron[]" value="4" />
<span class="smallfont">4</span>
<input type="checkbox" name="iron[]" value="5" />
<span class="smallfont">5</span>
<input type="checkbox" name="iron[]" value="6" />
<span class="smallfont">6</span>
<input type="checkbox" name="iron[]" value="7" />
<span class="smallfont">7</span>
<input type="checkbox" name="iron[]" value="8" />
<span class="smallfont">8</span>
<input type="checkbox" name="iron[]" value="9" />
<span class="smallfont">9</span>
<input type="checkbox" name="iron[]" value="PW" />
<span class="smallfont">PW</span>
<input type="checkbox" name="iron[]" value="TW" />
<span class="smallfont">TW</span>
<input type="checkbox" name="iron[]" value="SW" />
<span class="smallfont">SW</span>
</div>
I echo these values in a php review form like so
$iron = join(", ", $_REQUEST["iron"]);
echo (!empty($_REQUEST['iron'])) ? "<div class='reviewItem'><span
class='reviewTitle'>In Set:</span>{$iron}</div>" : "";
This would return the values, if any, for all that are checked. Is there a
way I can get the number of "iron[]" boxes check as will and store it in
another variable? I am trying to multiply the number of boxes checked by a
price variable.
R#: On format - page scrolls to top and regions expand
R#: On format - page scrolls to top and regions expand
I have recently started using Visual Studio 2012 with Resharper 8 (Full
Edition) and discovered a very peculiar bug that happens only under
certain circumstances.
Whenever I use Resharper's code cleanup on some of my C# files the view in
the text editor scrolls to the top of the file and all the collapsed
regions and blocks expand. An extremely annoying problem, since I use the
'silent cleanup' of Resharper quite a lot.
It is worth mentioning that the code still gets formatted correctly.
After spending quite some time testing and trying to find the source of
the problem, it seems that I have finally found the cause:
Whenever there are more than 13 <summary> tags in a file this issue will
appear, but if there are 13 or less it won't. Also, it can only happen if
the Reformat embedded XML doc comments option is enabled.
Why this arbitrary number of <summary> tags creates this issue is beyond
me, but I would like to find a solution.
I use the silent cleanup (entire file) option of R# quite often when
writing code and as such the problem has become a big nuisance. Right now
I am forced to circumvent the problem by simply selecting the code that I
have created/edited and formatting it alone, but it is extremely annoying
to do that on a regular basis as all I want to do is click a simple key
combination.
Does anyone else with VS2012 + R# 8 have this problem?
I would like to find a solution to this annoying issue, but I have no idea
what could be causing this.
I have recently started using Visual Studio 2012 with Resharper 8 (Full
Edition) and discovered a very peculiar bug that happens only under
certain circumstances.
Whenever I use Resharper's code cleanup on some of my C# files the view in
the text editor scrolls to the top of the file and all the collapsed
regions and blocks expand. An extremely annoying problem, since I use the
'silent cleanup' of Resharper quite a lot.
It is worth mentioning that the code still gets formatted correctly.
After spending quite some time testing and trying to find the source of
the problem, it seems that I have finally found the cause:
Whenever there are more than 13 <summary> tags in a file this issue will
appear, but if there are 13 or less it won't. Also, it can only happen if
the Reformat embedded XML doc comments option is enabled.
Why this arbitrary number of <summary> tags creates this issue is beyond
me, but I would like to find a solution.
I use the silent cleanup (entire file) option of R# quite often when
writing code and as such the problem has become a big nuisance. Right now
I am forced to circumvent the problem by simply selecting the code that I
have created/edited and formatting it alone, but it is extremely annoying
to do that on a regular basis as all I want to do is click a simple key
combination.
Does anyone else with VS2012 + R# 8 have this problem?
I would like to find a solution to this annoying issue, but I have no idea
what could be causing this.
Find who stopped the service
Find who stopped the service
My application is installed on a customer linux machine as a service.
From time to time he complains that the application stops.
The thing is that I can see from my application logs that the service is
stopped gracefully (not crashed), but he's saying he didn't stopped it.
How can I tell who caused my service to stop?
My application listen to a configured port via socket, if someone writes
to this socket - the application stops.
The customer say that there's no automated process that might cause the
service to stop.
My application is installed on a customer linux machine as a service.
From time to time he complains that the application stops.
The thing is that I can see from my application logs that the service is
stopped gracefully (not crashed), but he's saying he didn't stopped it.
How can I tell who caused my service to stop?
My application listen to a configured port via socket, if someone writes
to this socket - the application stops.
The customer say that there's no automated process that might cause the
service to stop.
can't access user info in sharekit iphone sdk
can't access user info in sharekit iphone sdk
I am using ShareKit iPhone SDK for Facebook, Twitter, Tumblr sharing
functionalities. But in my app I require to log into the app using
Facebook, Tumblr, Twitter (i.e. By selecting any of the option given here,
user can be logged into their perspective account using ShareKit interface
and then directly goes to the main screen in the app). It's same
functionality, like, any web service allows to "Login with Facebook or
Twitter or Tumblr". And then, in Main screen, I will display user info.
(like, email, username, first and last names, birthday, etc.). And when
anyone changes password for any of these account, login screen will be
displayed for the same.
Can anyone guide me for the same? I have searched through some blogs, they
told to change or override base classes of ShareKit, like, SHKFacebook,
SHKTwitter, etc. but in my system I find them locked, so, I can't modify
them.
I am using ShareKit iPhone SDK for Facebook, Twitter, Tumblr sharing
functionalities. But in my app I require to log into the app using
Facebook, Tumblr, Twitter (i.e. By selecting any of the option given here,
user can be logged into their perspective account using ShareKit interface
and then directly goes to the main screen in the app). It's same
functionality, like, any web service allows to "Login with Facebook or
Twitter or Tumblr". And then, in Main screen, I will display user info.
(like, email, username, first and last names, birthday, etc.). And when
anyone changes password for any of these account, login screen will be
displayed for the same.
Can anyone guide me for the same? I have searched through some blogs, they
told to change or override base classes of ShareKit, like, SHKFacebook,
SHKTwitter, etc. but in my system I find them locked, so, I can't modify
them.
Subscribe to:
Posts (Atom)