#EANF#
I got like;
<p>Hello World</p>
And I want to it to be;
<p>Hello <span>World</span></p>
Is this possible by a javascript function? / or jQuery.
Oh yeah, and the p-element got an ID and the text inside the p-element is
variable but always consists of 2 words. I want a span around the last
word of the text by a javascript function.
Thursday, 3 October 2013
Wednesday, 2 October 2013
Django's testserver returns JSON ok, but nginx returns junk
Django's testserver returns JSON ok, but nginx returns junk
i have nginx as a proxy to django default fcgi server.
The problem is django default server(manage runserver) works ok, but nginx
+ fcgi connection doesnt on returning JSON.Other types are ok - js,css,img
ok headers returned and json are.
default-
headers:
Content-Type:application/json
Date:Thu, 03 Oct 2013 01:02:05 GMT
Server:WSGIServer/0.1 Python/2.7.3
json:{"amount": 3000.0, "limit": 0.0,etc....}
nginx:
headers:
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=utf-8
Date:Thu, 03 Oct 2013 01:04:03 GMT
Server:nginx/1.1.19
Transfer-Encoding:chunked
json - Ð'аланÑ
What or where can be the problem? Nginx config or may be
i have nginx as a proxy to django default fcgi server.
The problem is django default server(manage runserver) works ok, but nginx
+ fcgi connection doesnt on returning JSON.Other types are ok - js,css,img
ok headers returned and json are.
default-
headers:
Content-Type:application/json
Date:Thu, 03 Oct 2013 01:02:05 GMT
Server:WSGIServer/0.1 Python/2.7.3
json:{"amount": 3000.0, "limit": 0.0,etc....}
nginx:
headers:
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=utf-8
Date:Thu, 03 Oct 2013 01:04:03 GMT
Server:nginx/1.1.19
Transfer-Encoding:chunked
json - Ð'аланÑ
What or where can be the problem? Nginx config or may be
Sorting a file then storing that into a new file using Python
Sorting a file then storing that into a new file using Python
so I have to sort a file in alphabetical order which isn't my problem. I
can do that, but my problem is writing that sorted list into a new file.
Here is what I have.
import os
os.chdir("/Users/User/Documents") #(I put my name where it says "User")
user_file = open("info.txt", "r")
file = user_file.read()
file_string = file.split("\n")
file_string.sort()
print(file_string) #This is here just so I can see that it sorted correctly
end_file = open("write.txt", "w")
for item in file_string:
end = end_file.write(str(item))
print(end)
Ok, so my info.txt is what needs to be alphabetized and it is just a list
of colors. So my last 4 lines is where I'm struggling. I'm trying to take
each item in the file_string and write those into a new file, but
print(end) gives me how many characters they are. What am I doing wrong?
Thanks
so I have to sort a file in alphabetical order which isn't my problem. I
can do that, but my problem is writing that sorted list into a new file.
Here is what I have.
import os
os.chdir("/Users/User/Documents") #(I put my name where it says "User")
user_file = open("info.txt", "r")
file = user_file.read()
file_string = file.split("\n")
file_string.sort()
print(file_string) #This is here just so I can see that it sorted correctly
end_file = open("write.txt", "w")
for item in file_string:
end = end_file.write(str(item))
print(end)
Ok, so my info.txt is what needs to be alphabetized and it is just a list
of colors. So my last 4 lines is where I'm struggling. I'm trying to take
each item in the file_string and write those into a new file, but
print(end) gives me how many characters they are. What am I doing wrong?
Thanks
Display change hyper reference link in address bar
Display change hyper reference link in address bar
I have a link in my project and want to click on that link but in the
address bar don't want to display that link, want to display url which i
want. example: site name electronixzone Products but I want to display as
electronixzone/products instead of electronixzone/index.php?page=products.
how?
I have a link in my project and want to click on that link but in the
address bar don't want to display that link, want to display url which i
want. example: site name electronixzone Products but I want to display as
electronixzone/products instead of electronixzone/index.php?page=products.
how?
How to not make a pop up scroll the window down using css3
How to not make a pop up scroll the window down using css3
I'm working on a pop up code right now... This is what I have so far
http://jsfiddle.net/3EuZM/
<a href="#pop2">Pop-up Two</a>
<br /> <Br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/><br /><br
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/><br />
<br /><br /><br /><br />
<div id="pop2" class="pop-up">
<div class="popBox">
<div class="popScroll">
<h2>Pop-up Two</h2>
<div class="article-image"><img src="images/slow-moving-stock.png"></div>
<div class="article-word">autem</div>
<div class="article-def">Nam a justo vulputate, interdum quam
nec, auctor turpis. Nulla dapibus, lectus a aliquet lacinia,
turpis dui feugiat dolor</div>
<div class="article-samp">Donec faucibus pulvinar magna, vel
convallis ipsum interdum at.</div>
</div>
<a href="" class="close"><img src="images/close.png" width="20px" ></a>
</div>
<a href="#links" class="lightbox">Back to links</a>
</div>
Now, you see... when I click on the link and the pop-up appears, the whole
window scrolls down to the bottom of the page :( I don't know how to stop
this. any ideas?
*note, i added the
to empasize the scrolling down...
I'm working on a pop up code right now... This is what I have so far
http://jsfiddle.net/3EuZM/
<a href="#pop2">Pop-up Two</a>
<br /> <Br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/><br /><br
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/><br />
<br /><br /><br /><br />
<div id="pop2" class="pop-up">
<div class="popBox">
<div class="popScroll">
<h2>Pop-up Two</h2>
<div class="article-image"><img src="images/slow-moving-stock.png"></div>
<div class="article-word">autem</div>
<div class="article-def">Nam a justo vulputate, interdum quam
nec, auctor turpis. Nulla dapibus, lectus a aliquet lacinia,
turpis dui feugiat dolor</div>
<div class="article-samp">Donec faucibus pulvinar magna, vel
convallis ipsum interdum at.</div>
</div>
<a href="" class="close"><img src="images/close.png" width="20px" ></a>
</div>
<a href="#links" class="lightbox">Back to links</a>
</div>
Now, you see... when I click on the link and the pop-up appears, the whole
window scrolls down to the bottom of the page :( I don't know how to stop
this. any ideas?
*note, i added the
to empasize the scrolling down...
Tuesday, 1 October 2013
Print a Google Maps API v4 map with polygon
Print a Google Maps API v4 map with polygon
I am trying to print a map I have created with Google Maps API v3. The map
contains a polygon. I am using the pop-up method to try to print it:
var gmapPrint = function() {
var content = window.document.getElementById('map-canvas') // get you
map details
var newWindow = window.open(); // open a new window
newWindow.document.write(content.innerHTML); // write the map into the
new window
newWindow.print(); // print the new window
}
The map prints just fine, but the polygon is missing. At first, it seemed
as though the print dialog was popping up before the polygon was drawn on
the map, so I added a setTimeout. This did not fix the issue. I have also
tried using the static maps API, but the number of points in the boundary
of my polygon exceed the maximum URL size, even when encoded.
Has anyone had any success with this?
I am trying to print a map I have created with Google Maps API v3. The map
contains a polygon. I am using the pop-up method to try to print it:
var gmapPrint = function() {
var content = window.document.getElementById('map-canvas') // get you
map details
var newWindow = window.open(); // open a new window
newWindow.document.write(content.innerHTML); // write the map into the
new window
newWindow.print(); // print the new window
}
The map prints just fine, but the polygon is missing. At first, it seemed
as though the print dialog was popping up before the polygon was drawn on
the map, so I added a setTimeout. This did not fix the issue. I have also
tried using the static maps API, but the number of points in the boundary
of my polygon exceed the maximum URL size, even when encoded.
Has anyone had any success with this?
Error TF31004 connecting VS2012 to TFS
Error TF31004 connecting VS2012 to TFS
I am trying to setup a new connection to TFS with VS2012. Early on I was
able to add my TFS server and, using the Microsoft Git Provider, clone a
copy of the remote repository from within Visual Studio. Later, as I was
fiddling with things in Team Explorer trying to find the branch I wanted
to use, something broke. My local repository remains, but my connection to
the remote repository was somehow corrupted, as evidenced with this error:
TF31004: Unexpected error encountered while connecting to Team Foundation
Server at http: //my.server.com:8080/tfs. Wait a few minutes and try
again. If the problem persists, contact the server administrator ok help
Things I have tried to resolve this:
Wait and try again (as the error message suggested).
Restart Visual Studio.
Reboot my machine.
Reboot TFS server.
Use system restore to revert back before I installed msysgit and Microsoft
Git Provider, or had attempted to connect to the TFS server.
Review the MSDN help for the error (see below).
Search Stack Overflow (found one other related issue but did not seem to
apply).
The help page offers these tidbits, but none of them seem likely given
that I had, as I said, the connection working at one point:
The version of Team Foundation running on the local computer does not
match the version running on the Team Foundation Server server {name}.
The server returned HTML content instead of XML content.
The required Web service on the server could not be found.
Any ideas would be appreciated!
I am trying to setup a new connection to TFS with VS2012. Early on I was
able to add my TFS server and, using the Microsoft Git Provider, clone a
copy of the remote repository from within Visual Studio. Later, as I was
fiddling with things in Team Explorer trying to find the branch I wanted
to use, something broke. My local repository remains, but my connection to
the remote repository was somehow corrupted, as evidenced with this error:
TF31004: Unexpected error encountered while connecting to Team Foundation
Server at http: //my.server.com:8080/tfs. Wait a few minutes and try
again. If the problem persists, contact the server administrator ok help
Things I have tried to resolve this:
Wait and try again (as the error message suggested).
Restart Visual Studio.
Reboot my machine.
Reboot TFS server.
Use system restore to revert back before I installed msysgit and Microsoft
Git Provider, or had attempted to connect to the TFS server.
Review the MSDN help for the error (see below).
Search Stack Overflow (found one other related issue but did not seem to
apply).
The help page offers these tidbits, but none of them seem likely given
that I had, as I said, the connection working at one point:
The version of Team Foundation running on the local computer does not
match the version running on the Team Foundation Server server {name}.
The server returned HTML content instead of XML content.
The required Web service on the server could not be found.
Any ideas would be appreciated!
pick point on parabola so 2 conditions are true
pick point on parabola so 2 conditions are true
You have a parabola y=ax^2+bx+c. We know a,b & c. On this parabola you
have to pick a point A where the following conditions are true:
1) if you draw a tangent line in this point to the parabola, then the
middle point of the following 3 points has to be the midpoint of the other
two points (same distance):
-the point where the parabola touches the tangent line (point A)
-the intersection of the tangent line with the horizontal line drawn
through the vertex: y=(4ac-b^2)/4a.
-the intersection of the tangent line with the axis of symmetry = vertical
line through the vertex: x=-b/2a.
2) Normally, then also for the following 3 points the middle point is on
the same distance to the first and to the third point (all be it on a
different distance as Condition 1, depending on the shape of the
parabola).
-the intersection point of the horizontal line through point A and the
axis of symmetry
-the vertex
-the intersection point of the tangent line to the parabola in point A,
with the axis of symmetry
I know that the slope of the tangent line in a certain Ax will be 2a*Ax+b,
so you can calculate the tangent line through A to be equal to
y=(2aAx+b)(x-Ax)+Ay, but I'm not sure how to move from there to pick point
A so all conditions are still true.
All help is truly appreciated. These things can be pretty frustrating if
you're not mathematically inclined..
In this image, pick point A such that |AF| = |FE| and |ED| =|DB|. I can do
it geometrically, but apparently not algebraically.
You have a parabola y=ax^2+bx+c. We know a,b & c. On this parabola you
have to pick a point A where the following conditions are true:
1) if you draw a tangent line in this point to the parabola, then the
middle point of the following 3 points has to be the midpoint of the other
two points (same distance):
-the point where the parabola touches the tangent line (point A)
-the intersection of the tangent line with the horizontal line drawn
through the vertex: y=(4ac-b^2)/4a.
-the intersection of the tangent line with the axis of symmetry = vertical
line through the vertex: x=-b/2a.
2) Normally, then also for the following 3 points the middle point is on
the same distance to the first and to the third point (all be it on a
different distance as Condition 1, depending on the shape of the
parabola).
-the intersection point of the horizontal line through point A and the
axis of symmetry
-the vertex
-the intersection point of the tangent line to the parabola in point A,
with the axis of symmetry
I know that the slope of the tangent line in a certain Ax will be 2a*Ax+b,
so you can calculate the tangent line through A to be equal to
y=(2aAx+b)(x-Ax)+Ay, but I'm not sure how to move from there to pick point
A so all conditions are still true.
All help is truly appreciated. These things can be pretty frustrating if
you're not mathematically inclined..
In this image, pick point A such that |AF| = |FE| and |ED| =|DB|. I can do
it geometrically, but apparently not algebraically.
Is there a way to run a script on gimp startup?
Is there a way to run a script on gimp startup?
Now that I know how to play with python fu, there are certain things I
want gimp to do when started, in there a way to do this via python script?
Now that I know how to play with python fu, there are certain things I
want gimp to do when started, in there a way to do this via python script?
Monday, 30 September 2013
Extracting a zip file in my machne givs me CRC error?
Extracting a zip file in my machne givs me CRC error?
I have a large zip that contain hundreds of file. I've unzip'ed it in more
than one machine and didn't have any problem before. However, for this
particular machine (Ubuntu Server 12.04) I keep getting CRC error for some
of the files inside my zip. I've unzip'ed the same file it on anther
machine just to and its fine.
Any clue?
I have a large zip that contain hundreds of file. I've unzip'ed it in more
than one machine and didn't have any problem before. However, for this
particular machine (Ubuntu Server 12.04) I keep getting CRC error for some
of the files inside my zip. I've unzip'ed the same file it on anther
machine just to and its fine.
Any clue?
What kind of dock hardware will Ubuntu Touch use?
What kind of dock hardware will Ubuntu Touch use?
We've seen that Ubuntu Touch will be able to be used as a desktop when
docked with a keyboard and mouse. This is an extremely appealing future,
but what I'm wondering is where do you find that kind of hardware? Since
Ubuntu Touch is being designed for Android phones, it would make sense
that such a dock already exists for them, but I haven't seen any. Maybe I
haven't been looking hard enough. Will that be something that is released
after the official launch of Ubuntu Touch?
We've seen that Ubuntu Touch will be able to be used as a desktop when
docked with a keyboard and mouse. This is an extremely appealing future,
but what I'm wondering is where do you find that kind of hardware? Since
Ubuntu Touch is being designed for Android phones, it would make sense
that such a dock already exists for them, but I haven't seen any. Maybe I
haven't been looking hard enough. Will that be something that is released
after the official launch of Ubuntu Touch?
jQuery css transition toggle fix
jQuery css transition toggle fix
I have a little problem with jquery toggle function. Sometimes i can fix
it very fast but now im totally crazy about this. Im using jquery transit
plugin to animate a DIV
The code:
$(".grid-1").toggle( function() {
$(this).transition({ perspective: '170px', rotateY: '180deg' },
function() {
$(this).transition({ perspective: '170px', rotateY: '0deg' });
});
});
If i refresh the page this DIV (.grid-1) just disappear... where i make a
mistake ?
Thank you!
I have a little problem with jquery toggle function. Sometimes i can fix
it very fast but now im totally crazy about this. Im using jquery transit
plugin to animate a DIV
The code:
$(".grid-1").toggle( function() {
$(this).transition({ perspective: '170px', rotateY: '180deg' },
function() {
$(this).transition({ perspective: '170px', rotateY: '0deg' });
});
});
If i refresh the page this DIV (.grid-1) just disappear... where i make a
mistake ?
Thank you!
Google maps link is opening in webview
Google maps link is opening in webview
I have made an android app in WebView. When I open a Google maps link,
it's opening in WebView and not in the Google app. How can I fix this? I
have searched on Google and on Stack Overflow but can't find the any
solution.
Code:
public class FullscreenActivity extends Activity {
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen);
webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new myWebClient());
webView.loadUrl("http://m.neshaniha.org/");
webView.setVerticalScrollBarEnabled(false);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
}
public class myWebClient extends WebViewClient
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL,
Uri.parse(url));
startActivity(intent);
}else if(url.startsWith("http:") || url.startsWith("https:")) {
view.loadUrl(url);
}
return true;
}
}
I have made an android app in WebView. When I open a Google maps link,
it's opening in WebView and not in the Google app. How can I fix this? I
have searched on Google and on Stack Overflow but can't find the any
solution.
Code:
public class FullscreenActivity extends Activity {
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen);
webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new myWebClient());
webView.loadUrl("http://m.neshaniha.org/");
webView.setVerticalScrollBarEnabled(false);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
}
public class myWebClient extends WebViewClient
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL,
Uri.parse(url));
startActivity(intent);
}else if(url.startsWith("http:") || url.startsWith("https:")) {
view.loadUrl(url);
}
return true;
}
}
Sunday, 29 September 2013
Confusion related to derivative of a vector
Confusion related to derivative of a vector
What is the derivative of
$\frac{d}{d \theta} \theta^T$
I am a bit confused what it will be. Is it $[ 1 1 1 1]^T$ if $\theta$ is a
vector with four elements
What is the derivative of
$\frac{d}{d \theta} \theta^T$
I am a bit confused what it will be. Is it $[ 1 1 1 1]^T$ if $\theta$ is a
vector with four elements
How to register a bulk device
How to register a bulk device
I'm very new to kernel programming. i created a simple USB driver by
reading greg's code
"http://www.cs.fsu.edu/~baker/devices/lxr/http/source/ldd-examples/usb/usb-skeleton.c"
My code is at http://kgcorner.som/code/simusb.c
As far as i thought, this code can read data and write data from and to
usb device. But when i attached my pendrive i saw dmesg trace i found
everything okay but unable to my my device in output of lsblk. As it's not
there i'm not able to mount it and hence unable to test my driver. Here's
dmesg trace ===========================================
[20073.437683] [SIMUSB]:Module Loaded
[20073.437730] [SIMUSB] USB Detected
[20073.437734] [SIMUSB] USB Vendor ID=1008 and Product ID=22023
[20073.437737] [SIMUSB] endpoint->bEndpointAddress=1
[20073.437740] [SIMUSB] Result of endpoint->bEndpointAddress & USB_DIR_OUT
is 0
[20073.437743] [SIMUSB] ENDPOINT WITH OUT DIRECTION FOUND
[20073.437746] [SIMUSB] Result of endpoint->bmAddress &
USB_ENDPOINT_XFERTYPE_MASK is 2
[20073.437749] [SIMUSB] OUT ENDPOINT adress set
[20073.437752] [SIMUSB] endpoint->bEndpointAddress=130
[20073.437755] [SIMUSB] Result of endpoint->bEndpointAddress & USB_DIR_IN
is 128
[20073.437757] [SIMUSB] ENDPOINT WITH IN DIRECTION FOUND
[20073.437760] [SIMUSB] Result of endpoint->bmAddress &
USB_ENDPOINT_XFERTYPE_MASK is 2
[20073.437763] [SIMUSB] IN ENDPOINT adress set
[20073.437910] [SIMUSB] status=0
[20073.437914] [SIMUSB] USB Registered Successfully
Please help. thanks in advance
I'm very new to kernel programming. i created a simple USB driver by
reading greg's code
"http://www.cs.fsu.edu/~baker/devices/lxr/http/source/ldd-examples/usb/usb-skeleton.c"
My code is at http://kgcorner.som/code/simusb.c
As far as i thought, this code can read data and write data from and to
usb device. But when i attached my pendrive i saw dmesg trace i found
everything okay but unable to my my device in output of lsblk. As it's not
there i'm not able to mount it and hence unable to test my driver. Here's
dmesg trace ===========================================
[20073.437683] [SIMUSB]:Module Loaded
[20073.437730] [SIMUSB] USB Detected
[20073.437734] [SIMUSB] USB Vendor ID=1008 and Product ID=22023
[20073.437737] [SIMUSB] endpoint->bEndpointAddress=1
[20073.437740] [SIMUSB] Result of endpoint->bEndpointAddress & USB_DIR_OUT
is 0
[20073.437743] [SIMUSB] ENDPOINT WITH OUT DIRECTION FOUND
[20073.437746] [SIMUSB] Result of endpoint->bmAddress &
USB_ENDPOINT_XFERTYPE_MASK is 2
[20073.437749] [SIMUSB] OUT ENDPOINT adress set
[20073.437752] [SIMUSB] endpoint->bEndpointAddress=130
[20073.437755] [SIMUSB] Result of endpoint->bEndpointAddress & USB_DIR_IN
is 128
[20073.437757] [SIMUSB] ENDPOINT WITH IN DIRECTION FOUND
[20073.437760] [SIMUSB] Result of endpoint->bmAddress &
USB_ENDPOINT_XFERTYPE_MASK is 2
[20073.437763] [SIMUSB] IN ENDPOINT adress set
[20073.437910] [SIMUSB] status=0
[20073.437914] [SIMUSB] USB Registered Successfully
Please help. thanks in advance
How can I convert "Mon, 23 Sep 2013 07:00:00 GMT" as a string into "2013-09-23" using STR_TO_DATE in MySQL?
How can I convert "Mon, 23 Sep 2013 07:00:00 GMT" as a string into
"2013-09-23" using STR_TO_DATE in MySQL?
I've got a long query with comparisons between tables, and one table has
this format:
"Mon, 23 Sep 2013 07:00:00 GMT"
And another table has this format:
"2013-09-23"
How can I do a query where I can essentially do a
SELECT * from table1, table2
WHERE table1.date = table2.date
"2013-09-23" using STR_TO_DATE in MySQL?
I've got a long query with comparisons between tables, and one table has
this format:
"Mon, 23 Sep 2013 07:00:00 GMT"
And another table has this format:
"2013-09-23"
How can I do a query where I can essentially do a
SELECT * from table1, table2
WHERE table1.date = table2.date
How to use KeyPressEvent in correct way
How to use KeyPressEvent in correct way
try to create HotKeys for my forms
code
private void FormMain_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
MessageBox.Show("e");
}
}
works for one key, but if I whant to use combination of keys like CTRL+N,
try to use if (e.KeyChar == (char)Keys.Enter && e.KeyChar == (char)Keys.N)
- but it's not working. I'm I right - using such code for keys
combination?
try to create HotKeys for my forms
code
private void FormMain_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
MessageBox.Show("e");
}
}
works for one key, but if I whant to use combination of keys like CTRL+N,
try to use if (e.KeyChar == (char)Keys.Enter && e.KeyChar == (char)Keys.N)
- but it's not working. I'm I right - using such code for keys
combination?
Saturday, 28 September 2013
c++: vector of vector issue
c++: vector of vector issue
pI wrote a c++ code where i'm testing the running time of vector
push_back. I have a vector of vector. I called my main vector, mainVec,
and embedded vector, subVec. So, I push backed 2^20 elements into subVec
and then push backed subVec 2^20 times into mainVec. However, in the loop
of subVec-push_back I have a cout command which doesn't get executed. I
was hoping you can point out my mistake. /p pHere is the code (There is no
error in the code, though):/p precodevectorlt;intgt; subVec; vectorlt;
vectorlt;intgt; gt; mainVec; //Fills the subvector with 2^20 elements for(
size_t i = 0; i lt; (pow(2,20)+1); ++i) subVec.push_back(i); //Filling of
the maiVec with 2^20 subVec for( size_t j = 10; j lt; 21; ++j) { cout
lt;lt; pow(2,j) lt;lt; endl; clock_t t1 = clock(); //2^j times subVec is
push_backed for j lt; 21 for( size_t k = 0; k lt; pow(2,j); ++k )
mainVec.push_back( subVec ); t1 = clock()-t1; //Outputting to file cout
lt;lt; \t lt;lt; (float(t1) / CLOCKS_PER_SEC) lt;lt; endl; //ofs lt;lt;
pow(2,j) lt;lt; \t\t lt;lt; (float(t1) / CLOCKS_PER_SEC) lt;lt; endl; }
/code/pre
pI wrote a c++ code where i'm testing the running time of vector
push_back. I have a vector of vector. I called my main vector, mainVec,
and embedded vector, subVec. So, I push backed 2^20 elements into subVec
and then push backed subVec 2^20 times into mainVec. However, in the loop
of subVec-push_back I have a cout command which doesn't get executed. I
was hoping you can point out my mistake. /p pHere is the code (There is no
error in the code, though):/p precodevectorlt;intgt; subVec; vectorlt;
vectorlt;intgt; gt; mainVec; //Fills the subvector with 2^20 elements for(
size_t i = 0; i lt; (pow(2,20)+1); ++i) subVec.push_back(i); //Filling of
the maiVec with 2^20 subVec for( size_t j = 10; j lt; 21; ++j) { cout
lt;lt; pow(2,j) lt;lt; endl; clock_t t1 = clock(); //2^j times subVec is
push_backed for j lt; 21 for( size_t k = 0; k lt; pow(2,j); ++k )
mainVec.push_back( subVec ); t1 = clock()-t1; //Outputting to file cout
lt;lt; \t lt;lt; (float(t1) / CLOCKS_PER_SEC) lt;lt; endl; //ofs lt;lt;
pow(2,j) lt;lt; \t\t lt;lt; (float(t1) / CLOCKS_PER_SEC) lt;lt; endl; }
/code/pre
Wrong scope for my nested classes?
Wrong scope for my nested classes?
I'm fairly new to C# and programming in general. At work I monitor a very
large list of servers and websites associated with the application running
on the servers. Generally each application has a cluster of servers behind
it and roughly 6-10 different web-pages. So what I did was I created a
Servers class that will take in a server's name(s) and control the urls
that are associated with it. Now here's the part I'm struggling with. Each
url is going to have two values associated with it: the physical url and
the status of the url (online/offline). I came up with two ways of
handling this: either I create a 2D array (or list) OR create a url
subclass. The subclass method seemed like it would be better since I
thought accessing all the methods of the subclass would be easy... Well
right now I can't call them at all outside of the Servers class. This
makes me think I have an issue with the scope of the classes/methods.
Here's my Servers.cs code... What am I doing wrong?
public class Server
{
public List<string> serverNames = new List<string>();
public List<object> urlList = new List<object>();
public string[][] urlArr = new string[1][];
public Server()
{
}
public Server(string nm)
{
serverNames.Add(nm);
}
public void setName(string newName)
{
serverNames.Add(newName);
}
public void addUrl(string newUrl)
{
Server.Url url = new Server.Url(newUrl);
urlList.Add(url);
url.SetStatus(false);
}
protected class Url
{
public string url;
public bool status;
public Url()
{
}
public Url(string URL)
{
url = URL;
}
public void SetStatus(bool stat)
{
status = stat;
}
public bool ReturnStatus()
{
return status;
}
}
}
I'm fairly new to C# and programming in general. At work I monitor a very
large list of servers and websites associated with the application running
on the servers. Generally each application has a cluster of servers behind
it and roughly 6-10 different web-pages. So what I did was I created a
Servers class that will take in a server's name(s) and control the urls
that are associated with it. Now here's the part I'm struggling with. Each
url is going to have two values associated with it: the physical url and
the status of the url (online/offline). I came up with two ways of
handling this: either I create a 2D array (or list) OR create a url
subclass. The subclass method seemed like it would be better since I
thought accessing all the methods of the subclass would be easy... Well
right now I can't call them at all outside of the Servers class. This
makes me think I have an issue with the scope of the classes/methods.
Here's my Servers.cs code... What am I doing wrong?
public class Server
{
public List<string> serverNames = new List<string>();
public List<object> urlList = new List<object>();
public string[][] urlArr = new string[1][];
public Server()
{
}
public Server(string nm)
{
serverNames.Add(nm);
}
public void setName(string newName)
{
serverNames.Add(newName);
}
public void addUrl(string newUrl)
{
Server.Url url = new Server.Url(newUrl);
urlList.Add(url);
url.SetStatus(false);
}
protected class Url
{
public string url;
public bool status;
public Url()
{
}
public Url(string URL)
{
url = URL;
}
public void SetStatus(bool stat)
{
status = stat;
}
public bool ReturnStatus()
{
return status;
}
}
}
javascrpit - show hide button
javascrpit - show hide button
i have a problem in code JavaScript/jquery .. i am aclick in button and
content hide faster
<div class='show_hide' id='slidingDiv'>
<br/>
<input class='show_hide' href='javascript:void(0);' type='button'
value='show post'/>
</div>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js'
type='text/javascript'/>
<script
type='text/javascript'>$(document).ready(function(){$(".slidingDiv").hide();$(".show_hide").show();$('.show_hide').click(function(){$(".slidingDiv").slideToggle();});});</script>
i have a problem in code JavaScript/jquery .. i am aclick in button and
content hide faster
<div class='show_hide' id='slidingDiv'>
<br/>
<input class='show_hide' href='javascript:void(0);' type='button'
value='show post'/>
</div>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js'
type='text/javascript'/>
<script
type='text/javascript'>$(document).ready(function(){$(".slidingDiv").hide();$(".show_hide").show();$('.show_hide').click(function(){$(".slidingDiv").slideToggle();});});</script>
Subscribe to:
Posts (Atom)