How to make a button loose focus when page is loaded
When my JSP page gets loaded, the button (actually an image button with
onfocus property) gets focused. So, on pressing enter it gets clicked. It
is a small, part of a bigger problem. How can I make the button lose focus
when page is loaded?
<html>
<head>
</head>
<body>
<div onkeypress =handleEnter()>
name <input type="text" src='Create.gif' >
</br>
<input type="image" src='Create.gif' onclick="alert('not done')">
<input type="image" src='Create.gif' onclick="alert('done')">
</div>
</body>
<script>
function handleEnter()
{
if(window.event.keyCode==13)
{
alert('nothing');
event.cancelBubble=true;
}
}
</script>
</html>
both the alert box for nothing and not done has been show
Thursday, 3 October 2013
Wednesday, 2 October 2013
Solve 4 A (L^(3/4)) - wL (((24 - L) w)^(-3/4)) = -(((24 - L) w)^(1/4)) for L? Using Mathematica
Solve 4 A (L^(3/4)) - wL (((24 - L) w)^(-3/4)) = -(((24 - L) w)^(1/4)) for
L? Using Mathematica
I'm trying to solve 4 A (L^(3/4)) - wL (((24 - L) w)^(-3/4)) = -(((24 - L)
w)^(1/4)) for L using Mathematica and it spits the following out: Solve[4
A (L^(3/4)) - wL (((24 - L) w)^(-3/4)) = -(((24 - L) w)^(1/4)), L]
Set::write: Tag Plus in 4 A L^(3/4)-wL/((24-L) w)^(3/4) is Protected. >>
Solve::naqs: ((24-L) w)^(1/4) is not a quantified system of equations and
inequalities. >>
What does this mean and how do I solve it?!
L? Using Mathematica
I'm trying to solve 4 A (L^(3/4)) - wL (((24 - L) w)^(-3/4)) = -(((24 - L)
w)^(1/4)) for L using Mathematica and it spits the following out: Solve[4
A (L^(3/4)) - wL (((24 - L) w)^(-3/4)) = -(((24 - L) w)^(1/4)), L]
Set::write: Tag Plus in 4 A L^(3/4)-wL/((24-L) w)^(3/4) is Protected. >>
Solve::naqs: ((24-L) w)^(1/4) is not a quantified system of equations and
inequalities. >>
What does this mean and how do I solve it?!
Get item from PHP array without loop
Get item from PHP array without loop
In JavaScript, if I have object or array from JSON
var arr = ["one", "two", "three"];
var obj = {"hello": "dolly", "jurassic": "park"}
I can get any individual item from it easily without looping:
alert(arr[1]); // outputs "two"
alert(obj["hello"]); // outputs "dolly"
Is there a similar way to do this in PHP?
echo arr[1];
echo obj["hello"];
echo arr->1
echo obj->"hello"
In JavaScript, if I have object or array from JSON
var arr = ["one", "two", "three"];
var obj = {"hello": "dolly", "jurassic": "park"}
I can get any individual item from it easily without looping:
alert(arr[1]); // outputs "two"
alert(obj["hello"]); // outputs "dolly"
Is there a similar way to do this in PHP?
echo arr[1];
echo obj["hello"];
echo arr->1
echo obj->"hello"
Use HTML Form Select On Click with PHP
Use HTML Form Select On Click with PHP
I have been searching all day for a solution to my latest problem.
I am using PHP to dynaically create select form options. What I want to be
able to do is use the onclick function to pass a variable to PHP and then
use it later on. I have seen many posts referring to AJAX which is
something I am not familiar with at all.
My current thinking is to have the onclick post data to the server and set
a variable.
The other thing I should mention is that I am using JQuery to hide
elements of the page based on the selection.
This is my code:
<div class="span5">
<form method="post" action="index.php">
<fieldset>
<label>Instances</label>
<select name="inst">
<option value="pleaseSel"
onclick="$('#lsList').hide('fast');
$('#newSpecDetails').hide('fast');">Please
Select...</option>
<?php
$instSelect = $dbObj->select("*", "inst_reg");
foreach ($instSelect as $value){
echo "<option name=\"spec_name\" value=\"" .
$value['spec_name'] . "\"
onclick=\"$('#lsList').show('fast');
$('#newSpecDetails').hide('fast'); \">" .
$value['spec_name'] . "</option>";
};
?>
<option value="newSpec"
onclick="$('#newSpecDetails').show('fast');
$('#lsList').hide('fast');">New...</option>
</select>
<div class="csvUp hide">
<label>Please select a CSV file for upload</label>
<input name="csvFile" type="file" placeholder="Path to
file..." required><br><br>
<button class="btn btn-success" type="submit" value="go"
name="gobabygo" class="btn">Go Baby Go...</button><br>
</div>
</div>
<div class="7 hide" id="lsList">
<p>List of landscapes</p>
<?php
echo "The currently selected instance is: $spec_name"; <!-- This
is where I want to use the variable set above using the onclick
functionality. -->
?>
</div>
<div class="7 hide" id="newSpecDetails">
<p>Form for new details</p>
</div>
</fieldset>
</form>
Any thoughts???
I have been searching all day for a solution to my latest problem.
I am using PHP to dynaically create select form options. What I want to be
able to do is use the onclick function to pass a variable to PHP and then
use it later on. I have seen many posts referring to AJAX which is
something I am not familiar with at all.
My current thinking is to have the onclick post data to the server and set
a variable.
The other thing I should mention is that I am using JQuery to hide
elements of the page based on the selection.
This is my code:
<div class="span5">
<form method="post" action="index.php">
<fieldset>
<label>Instances</label>
<select name="inst">
<option value="pleaseSel"
onclick="$('#lsList').hide('fast');
$('#newSpecDetails').hide('fast');">Please
Select...</option>
<?php
$instSelect = $dbObj->select("*", "inst_reg");
foreach ($instSelect as $value){
echo "<option name=\"spec_name\" value=\"" .
$value['spec_name'] . "\"
onclick=\"$('#lsList').show('fast');
$('#newSpecDetails').hide('fast'); \">" .
$value['spec_name'] . "</option>";
};
?>
<option value="newSpec"
onclick="$('#newSpecDetails').show('fast');
$('#lsList').hide('fast');">New...</option>
</select>
<div class="csvUp hide">
<label>Please select a CSV file for upload</label>
<input name="csvFile" type="file" placeholder="Path to
file..." required><br><br>
<button class="btn btn-success" type="submit" value="go"
name="gobabygo" class="btn">Go Baby Go...</button><br>
</div>
</div>
<div class="7 hide" id="lsList">
<p>List of landscapes</p>
<?php
echo "The currently selected instance is: $spec_name"; <!-- This
is where I want to use the variable set above using the onclick
functionality. -->
?>
</div>
<div class="7 hide" id="newSpecDetails">
<p>Form for new details</p>
</div>
</fieldset>
</form>
Any thoughts???
Tuesday, 1 October 2013
How do I correctly download a CSV with my own data?
How do I correctly download a CSV with my own data?
I have a little plugin I'm writing, which basically pulls information from
the facebook API, loops over, creates a formatted string from the data
that I want, and the forces a download once it's run, however, to my
knowledge, I'm formatting the string correctly, but I can't open the csv
(unless I'm being stupid, most likely the case...).
DEMO: http://jsfiddle.net/shannonhochkins/vUnF9/848/
However, here's a very simple example, how I'm formatting my response I'm
formatting my response:
var string = "a","b","c","d","e","f","etc";
To my knowledge, that is how the csv file expects it, yet it won't even
work when I force that information into my window.open command near the
top of the fiddle rather than pass it my custom string.
I know it's quite a big chunk of code, but I'm not sure what else I can do
here?
Even if I run :window.open("data:text/csv;charset=utf-8," +
escape("a","b","c","d","e","f","etc")) directly, the csv downloads
properly and opens, but there's no data..
Any help would be great!
I have a little plugin I'm writing, which basically pulls information from
the facebook API, loops over, creates a formatted string from the data
that I want, and the forces a download once it's run, however, to my
knowledge, I'm formatting the string correctly, but I can't open the csv
(unless I'm being stupid, most likely the case...).
DEMO: http://jsfiddle.net/shannonhochkins/vUnF9/848/
However, here's a very simple example, how I'm formatting my response I'm
formatting my response:
var string = "a","b","c","d","e","f","etc";
To my knowledge, that is how the csv file expects it, yet it won't even
work when I force that information into my window.open command near the
top of the fiddle rather than pass it my custom string.
I know it's quite a big chunk of code, but I'm not sure what else I can do
here?
Even if I run :window.open("data:text/csv;charset=utf-8," +
escape("a","b","c","d","e","f","etc")) directly, the csv downloads
properly and opens, but there's no data..
Any help would be great!
Python, review and speed up A* algorithm
Python, review and speed up A* algorithm
I have implemented an A* algorithm to find the shortest path between two
points in a grid world. For large path lengths the algorithm takes a very
long time. I was first wondering if my implementation is correct, and if
any optimization could take place?
The arguments for the aStar algorithm, are the current position of you and
the position you desire to travel to as (x,y) tuples.
The Node.value of a node is a direction to travel (NSEW),
getAdjacentNodes() returns a list of nodes directly adjacent to this one
that we can travel to.
#Perform an A* search to find the best path to the dirt
def aStar(self, current, end):
openSet = set() #Set of explorable nodes
openHeap = [] #All paths heap, lowest cost on top
closedSet = set() #Best path so far
curNode = Node(0, current, self.manHatDist(current, end))
openSet.add(curNode)
openHeap.append((curNode.cost,curNode))
while openSet:
curNode = heapq.heappop(openHeap)[1]
if curNode.pos == end:
return self.getDirections(curNode)
openSet.remove(curNode)
closedSet.add(curNode)
for tile in self.getAdjacentNodes(curNode.pos):
if tile not in closedSet:
tile.parent = curNode
tile.cost = self.manHatDist(curNode.pos, end) +
self.euclidDist(curNode.pos, current) + curNode.cost
if tile not in openSet:
openSet.add(tile)
heapq.heappush(openHeap, (tile.cost,tile))
return []
#Get the moves made to get to this endNode
def getDirections(self, endNode):
moves = []
tmpNode = endNode
while tmpNode.parent is not None:
moves.append(tmpNode.value)
tmpNode = tmpNode.parent
moves.reverse()
return moves
Node class
# Node class for A* search
class Node:
def __init__(self, value, pos, cost):
self.pos = pos
self.cost = cost
self.value = value
self.parent = None
def __lt__(a, b):
if(a.cost < b.cost):
return 1
return 0
def __gt__(a, b):
if(a.cost > b.cost):
return 1
return 0
I have implemented an A* algorithm to find the shortest path between two
points in a grid world. For large path lengths the algorithm takes a very
long time. I was first wondering if my implementation is correct, and if
any optimization could take place?
The arguments for the aStar algorithm, are the current position of you and
the position you desire to travel to as (x,y) tuples.
The Node.value of a node is a direction to travel (NSEW),
getAdjacentNodes() returns a list of nodes directly adjacent to this one
that we can travel to.
#Perform an A* search to find the best path to the dirt
def aStar(self, current, end):
openSet = set() #Set of explorable nodes
openHeap = [] #All paths heap, lowest cost on top
closedSet = set() #Best path so far
curNode = Node(0, current, self.manHatDist(current, end))
openSet.add(curNode)
openHeap.append((curNode.cost,curNode))
while openSet:
curNode = heapq.heappop(openHeap)[1]
if curNode.pos == end:
return self.getDirections(curNode)
openSet.remove(curNode)
closedSet.add(curNode)
for tile in self.getAdjacentNodes(curNode.pos):
if tile not in closedSet:
tile.parent = curNode
tile.cost = self.manHatDist(curNode.pos, end) +
self.euclidDist(curNode.pos, current) + curNode.cost
if tile not in openSet:
openSet.add(tile)
heapq.heappush(openHeap, (tile.cost,tile))
return []
#Get the moves made to get to this endNode
def getDirections(self, endNode):
moves = []
tmpNode = endNode
while tmpNode.parent is not None:
moves.append(tmpNode.value)
tmpNode = tmpNode.parent
moves.reverse()
return moves
Node class
# Node class for A* search
class Node:
def __init__(self, value, pos, cost):
self.pos = pos
self.cost = cost
self.value = value
self.parent = None
def __lt__(a, b):
if(a.cost < b.cost):
return 1
return 0
def __gt__(a, b):
if(a.cost > b.cost):
return 1
return 0
Adding a servers to a domain affects GUI performance of the Server
Adding a servers to a domain affects GUI performance of the Server
A very strange situation, we have the following setup.
3 x Terminal servers ( two are 2003 and one 2008R2) 1 x App Server 1 X DC
AD 1 X SQL
Here's the funny part, all the servers seem to have performance issues
with the GUI, Even from the physical server it self, if you work in the OS
it is incredibly slow, click and wait for responses up to 2 minutes,
( the hardware is not an issue there is ample resources and the
performance is isolated to the OS, as SQL and APPS run fine and no
performance issues but the OS is dog slow.
I have tried re-installs and virus scanning, i took a new server running
perfectly and added it to the domain within 4-6 days the server slowed
down exactly like the rest.
The GPO's are simple and mainly domain default.
Any help would be highly appreciated
A very strange situation, we have the following setup.
3 x Terminal servers ( two are 2003 and one 2008R2) 1 x App Server 1 X DC
AD 1 X SQL
Here's the funny part, all the servers seem to have performance issues
with the GUI, Even from the physical server it self, if you work in the OS
it is incredibly slow, click and wait for responses up to 2 minutes,
( the hardware is not an issue there is ample resources and the
performance is isolated to the OS, as SQL and APPS run fine and no
performance issues but the OS is dog slow.
I have tried re-installs and virus scanning, i took a new server running
perfectly and added it to the domain within 4-6 days the server slowed
down exactly like the rest.
The GPO's are simple and mainly domain default.
Any help would be highly appreciated
Unable to ping Active Directory Server with Domain Name
Unable to ping Active Directory Server with Domain Name
Domain Controller - Windows Server 2008 R2 Standard
Client OS - Window Server 2003 ( Terminal Server )
I am unable to ping my Active Directory Domain Name i.e corp.abc.com. (
Please see the print-screen )
I am successfully able to nslookup & ping my DC server ip address ( Please
see the print-screen )
I am also attaching print-screen of IP configuration.
Can you tell me why i am unable to ping, but successfully able to resolve
through nslookup command and also able to ping with DC server ip address
Domain Controller - Windows Server 2008 R2 Standard
Client OS - Window Server 2003 ( Terminal Server )
I am unable to ping my Active Directory Domain Name i.e corp.abc.com. (
Please see the print-screen )
I am successfully able to nslookup & ping my DC server ip address ( Please
see the print-screen )
I am also attaching print-screen of IP configuration.
Can you tell me why i am unable to ping, but successfully able to resolve
through nslookup command and also able to ping with DC server ip address
Subscribe to:
Comments (Atom)