Tinymce url needs to be versatile
I need relative path in links which don't have full url and i don't need
relative path in url which have full url.
When i insert in tinymce:
1. I need full url(non-relative path) in:
"http://dignepal.com/images/logo.png"
2. But i don't need full url (relative path) in: "javascript:"
While initializing tinymce i am currently using relative_urls as false and
it is causing problem in number 2 problem as mentioned above. And main
problem is i need it in same page and in same textarea.
Saturday, August 31, 2013
Team Foundation Service UnavailableException when migrating from premise 2010 to TFS Service
Team Foundation Service UnavailableException when migrating from premise
2010 to TFS Service
When doing a migration from a TFS 2010 on premise to a new empty TFS on
the cloud, I get this error : TeamFoundationServiceUnavailableException.
The source is only source control with a large history I can't lose and
the target is an empty new TFS Team Project.
For what I read, this happens when a changeset is too big, and we have
quite some of those because we needed to re-organize the project two or
three times in the 5 years period and ** I think ** that may be the
problem because those changeset are huge.
What can I do to fix this and do the migration ?
2010 to TFS Service
When doing a migration from a TFS 2010 on premise to a new empty TFS on
the cloud, I get this error : TeamFoundationServiceUnavailableException.
The source is only source control with a large history I can't lose and
the target is an empty new TFS Team Project.
For what I read, this happens when a changeset is too big, and we have
quite some of those because we needed to re-organize the project two or
three times in the 5 years period and ** I think ** that may be the
problem because those changeset are huge.
What can I do to fix this and do the migration ?
Scala: Convert if to case
Scala: Convert if to case
I have following code segment I am still learning Scala and haven't really
use case within-case: but I want to convert the if statement that I have
to more scala way of doing things:
...
.flatMap {
case(a, b, c, d, e, f, g, h) =>
val tiitleSubTitle = (title + " " + subtitle).split("\\s").toSet.toList
tiitleSubTitle.map(term => (
if (a contains term)
{
Some(query, term, List(item_id).mkString(","))
} else {
None
}))
}
I have following code segment I am still learning Scala and haven't really
use case within-case: but I want to convert the if statement that I have
to more scala way of doing things:
...
.flatMap {
case(a, b, c, d, e, f, g, h) =>
val tiitleSubTitle = (title + " " + subtitle).split("\\s").toSet.toList
tiitleSubTitle.map(term => (
if (a contains term)
{
Some(query, term, List(item_id).mkString(","))
} else {
None
}))
}
Spring + Hibernate Not able to address issue
Spring + Hibernate Not able to address issue
i am using spring 3.2.4 (latest stable version) with hibernate i have
added all the dependencies but still i am getting the error which is below
java.lang.NoClassDefFoundError:
org/springframework/transaction/interceptor/TransactionInterceptor
if i use maven then i get too many errors like Failed to Autowired (in
both service and DAO),
org.springframework.beans.factory.BeanCreationException:
java.lang.ClassNotFoundException: org.hibernate.cache.CacheProvider
please help me to solve problem for one of above. i want to create an
application (spring + Hibernate) any of way (with maven or without maven)
i am using spring 3.2.4 (latest stable version) with hibernate i have
added all the dependencies but still i am getting the error which is below
java.lang.NoClassDefFoundError:
org/springframework/transaction/interceptor/TransactionInterceptor
if i use maven then i get too many errors like Failed to Autowired (in
both service and DAO),
org.springframework.beans.factory.BeanCreationException:
java.lang.ClassNotFoundException: org.hibernate.cache.CacheProvider
please help me to solve problem for one of above. i want to create an
application (spring + Hibernate) any of way (with maven or without maven)
twisted: test my service's stop sequence
twisted: test my service's stop sequence
We have a complex multiservice that needs to do some fairly intricate
accounting when shutting down in order to implement a "graceful" shutdown.
I'm trying to write tests for this under trial. The issue is that the
reactor is effectively a process-global resource, and shutting down my
service means that trial's reactor is also stopped, which (of course)
makes it explode.
This is documented to be a no-no in trial, but I need some kind of
workaround that allows me to write my tests. My first thought was to use a
mock.Mock, but this means we're not really using a reactor that's shutting
down, which isn't going to give me behavior that's faithful to the actual
shutdown process.
I believe what I need is a way to separate trial's reactor from the
reactor of my service-under-test. Sharing a mutable resource between the
test system and the system under test is surely an anti-pattern.
We have a complex multiservice that needs to do some fairly intricate
accounting when shutting down in order to implement a "graceful" shutdown.
I'm trying to write tests for this under trial. The issue is that the
reactor is effectively a process-global resource, and shutting down my
service means that trial's reactor is also stopped, which (of course)
makes it explode.
This is documented to be a no-no in trial, but I need some kind of
workaround that allows me to write my tests. My first thought was to use a
mock.Mock, but this means we're not really using a reactor that's shutting
down, which isn't going to give me behavior that's faithful to the actual
shutdown process.
I believe what I need is a way to separate trial's reactor from the
reactor of my service-under-test. Sharing a mutable resource between the
test system and the system under test is surely an anti-pattern.
What is wrong in this C code?
What is wrong in this C code?
I am new to C and have just started to learn it so any help will be
appreciated
here is code i was trying to compile
#include <stdio.h>
int main(void)
{int n;
printf("Enter the value for the nuber to be tested\n");
scanf("%d, &n");
if
(n >= 1 <= 10)
printf("n is between 1 to 10\n");
}
So when i compile it and run it it print's the first statement to enter
the value of n. Then i enter the value, now here come the problem no
matter what value i enter output is always the same that "n is between 1
to 10". i am not able to figure out the problem please help
Thank's
user2735787
I am new to C and have just started to learn it so any help will be
appreciated
here is code i was trying to compile
#include <stdio.h>
int main(void)
{int n;
printf("Enter the value for the nuber to be tested\n");
scanf("%d, &n");
if
(n >= 1 <= 10)
printf("n is between 1 to 10\n");
}
So when i compile it and run it it print's the first statement to enter
the value of n. Then i enter the value, now here come the problem no
matter what value i enter output is always the same that "n is between 1
to 10". i am not able to figure out the problem please help
Thank's
user2735787
How do I make my footer background full screen? (HTML / CSS site)
How do I make my footer background full screen? (HTML / CSS site)
I've been trying to solve this for a couple of hours, but I haven't found
a good solution in this forum.
So, how do I make the footer background here stretch all the way to the
left and right, the way my header does?
I want the text to remain in four columns in the center of the screen with
its current width (950px), but the background to fill the viewer's screen,
whichever width that may be.
Thanks.
Maria
I've been trying to solve this for a couple of hours, but I haven't found
a good solution in this forum.
So, how do I make the footer background here stretch all the way to the
left and right, the way my header does?
I want the text to remain in four columns in the center of the screen with
its current width (950px), but the background to fill the viewer's screen,
whichever width that may be.
Thanks.
Maria
NSManagedObject - relationship fault
NSManagedObject - relationship fault
I have two entities correlated (E1,E2) with a one to many relationship E1
<--->> E2 (relationship name: pictures)
E1 also has other relationships one to many with different Entities (E3,E4)
When I retrieve the E1 from coredata E1.pictures result:
pictures = "<relationship fault: 0x1d5a8c60 'pictures'>";
Now,
I know that this kind of message is not an error :)
E1.pictures is not empty.
When I save a new picture and I provide to refresh the E1 managed object (
[E1.managedObjectContext refreshObject:E1 mergeChanges:YES]; ) the
E1.pictures is returned back correctly and I can show the images.
I try to make the refreshObject:E1 before to take the count, but it
doesn't work
I assume that I retrieved the object correctly. I would like to know
before save a new picture how many pictures have the E1 and obviously show
the pictures (but without a picture count... I don't go anywhere)
Could I be missing something? Can somebody help me?
I have two entities correlated (E1,E2) with a one to many relationship E1
<--->> E2 (relationship name: pictures)
E1 also has other relationships one to many with different Entities (E3,E4)
When I retrieve the E1 from coredata E1.pictures result:
pictures = "<relationship fault: 0x1d5a8c60 'pictures'>";
Now,
I know that this kind of message is not an error :)
E1.pictures is not empty.
When I save a new picture and I provide to refresh the E1 managed object (
[E1.managedObjectContext refreshObject:E1 mergeChanges:YES]; ) the
E1.pictures is returned back correctly and I can show the images.
I try to make the refreshObject:E1 before to take the count, but it
doesn't work
I assume that I retrieved the object correctly. I would like to know
before save a new picture how many pictures have the E1 and obviously show
the pictures (but without a picture count... I don't go anywhere)
Could I be missing something? Can somebody help me?
Friday, August 30, 2013
How do I store the contents of tables rows and use them on another page?
How do I store the contents of tables rows and use them on another page?
I am a beginner to web development and am just wondering how I can store
the values of a table row and use them on another page.
At the moment I am retrieving values from a database and putting them into
a table. Each row has a submit button which should take them to a pay.php
page where it should list the details of the particular row that they
selected to pay.
while($row = mysql_fetch_array($result))
{
echo "<td>" . $row['P_name'] . "</td>";
echo "<td>" . $row['P_amount'] . "</td>";
echo "<td>" . $row['P_dateStart'] . "</td>";
if(is_null($row['P_datePaid'])){
echo "<td>Not Paid</td>";
}
else{
echo "<td>" . $row['P_datePaid'] . "</td>";
}
if($row['P_status'] == 0){
echo "<td bgcolor='#FF0000'>" . $row['P_status'] . "</td>";
}
else{
echo "<td bgcolor='#00FF00'>" . $row['P_status'] . "</td>";
}
echo "<td><form name = 'viewMore' action = 'viewMore.php'><input
type = 'submit' value = 'View More'></form></td>";
echo "<td><form name = 'pay' action = 'pay.php'><input type =
'submit' value = 'Pay'></form></td>";
echo "</tr>";
}
echo "</table>";
?>
I am a beginner to web development and am just wondering how I can store
the values of a table row and use them on another page.
At the moment I am retrieving values from a database and putting them into
a table. Each row has a submit button which should take them to a pay.php
page where it should list the details of the particular row that they
selected to pay.
while($row = mysql_fetch_array($result))
{
echo "<td>" . $row['P_name'] . "</td>";
echo "<td>" . $row['P_amount'] . "</td>";
echo "<td>" . $row['P_dateStart'] . "</td>";
if(is_null($row['P_datePaid'])){
echo "<td>Not Paid</td>";
}
else{
echo "<td>" . $row['P_datePaid'] . "</td>";
}
if($row['P_status'] == 0){
echo "<td bgcolor='#FF0000'>" . $row['P_status'] . "</td>";
}
else{
echo "<td bgcolor='#00FF00'>" . $row['P_status'] . "</td>";
}
echo "<td><form name = 'viewMore' action = 'viewMore.php'><input
type = 'submit' value = 'View More'></form></td>";
echo "<td><form name = 'pay' action = 'pay.php'><input type =
'submit' value = 'Pay'></form></td>";
echo "</tr>";
}
echo "</table>";
?>
Thursday, August 29, 2013
mysql trigger to update table when update another table
mysql trigger to update table when update another table
I'd like to use a mysql trigger to update field (data=enddata-value) in
tab1 when update field enddata in tab2. so far I have done only update on
the same table. How I could do this? Thanks.
I'd like to use a mysql trigger to update field (data=enddata-value) in
tab1 when update field enddata in tab2. so far I have done only update on
the same table. How I could do this? Thanks.
Wednesday, August 28, 2013
Leaflet points from mysql database: .php 'json_encode' working but .js 'getJson' not
Leaflet points from mysql database: .php 'json_encode' working but .js
'getJson' not
I have an issue that I have tried to solve for a couple of days now. Went
through all similar issues that I could find on the internet, and still no
result. On stackoverflow have also been posted similar questions, but none
seems to help or give me an alternative. I want to generate points in a
Leaflet map, from the data saved in a mysql (xampp) database called poi,
table called users. the db contains for test, only one record:
ID | name | lat | lng
1 | john | 45.654500 | 25.609037
representing the point ID, a description and a couple of coordinates
latitude/longitude
usin a PHP script called get_info.php, i get the data from the db and
encode it as JSON using the code:
<?php
$db = new PDO('mysql:host=localhost;dbname=poi', 'john', 'skilla');
$sql = "SELECT id, name, lat, lng FROM users;";
$rs = $db->query($sql);
if (!$rs) {
echo "SQL error\n";
exit;
}
$rows = array();
while($r = $rs->fetch(PDO::FETCH_ASSOC)) {
$rows[] = $r;
}
print json_encode($rows);
$db = NULL;
?>
when calling get_info.php separatelly from the browser, it returns the
following:
[{"id":"1","name":"john","lat":"45.654500","lng":"25.609037"}]
so, it is encodeing the database records to JSON format but when calling
it from a .js script, there is no result the script is called JSON.js:
$.getJSON("get_info.php", function(data) {
for (var i = 0; i < data.length; i++) {
var location = new L.LatLng(data[i].lat, data[i].lng);
var name = data[i].name;
var marker = new L.Marker(location);
marker.bindPopup("<div style='text-align: center; margin-left: auto;
margin-right: auto;'>"+ title +"</div>", {maxWidth:'200'});
users.addLayer(marker);
}
})
JSON.js is called in the index.html file as such:
<script src="src/JSON.js"></script>
also in index are other .js called in order to generate the map:
Leaflet map generated by properly interpreting the rest of the .js
all the other .js work properly. I have tried to test JSON.js by calling
it in another .html file. I am not sure that this is correct, but if it
is, it is still not giving any sign of the data being received:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript"
src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
$("#demo").live("click", function () {
$.getJSON("src/get_info.php", function(data) {
var name = data[i].name
if (data.length) {
$("#dv").html(name);
} else {
html = r.error.message
$("#dv").html(html);
}
}
)}
);
</script>
</head>
<body>
<form id="test">
<div id = "dv"></div>
<input type = "button" value = "GET" id = "demo" />
</form>
</body>
</html>
Can you please help me in solveing the problem and generateing points from
the database? Thank you
'getJson' not
I have an issue that I have tried to solve for a couple of days now. Went
through all similar issues that I could find on the internet, and still no
result. On stackoverflow have also been posted similar questions, but none
seems to help or give me an alternative. I want to generate points in a
Leaflet map, from the data saved in a mysql (xampp) database called poi,
table called users. the db contains for test, only one record:
ID | name | lat | lng
1 | john | 45.654500 | 25.609037
representing the point ID, a description and a couple of coordinates
latitude/longitude
usin a PHP script called get_info.php, i get the data from the db and
encode it as JSON using the code:
<?php
$db = new PDO('mysql:host=localhost;dbname=poi', 'john', 'skilla');
$sql = "SELECT id, name, lat, lng FROM users;";
$rs = $db->query($sql);
if (!$rs) {
echo "SQL error\n";
exit;
}
$rows = array();
while($r = $rs->fetch(PDO::FETCH_ASSOC)) {
$rows[] = $r;
}
print json_encode($rows);
$db = NULL;
?>
when calling get_info.php separatelly from the browser, it returns the
following:
[{"id":"1","name":"john","lat":"45.654500","lng":"25.609037"}]
so, it is encodeing the database records to JSON format but when calling
it from a .js script, there is no result the script is called JSON.js:
$.getJSON("get_info.php", function(data) {
for (var i = 0; i < data.length; i++) {
var location = new L.LatLng(data[i].lat, data[i].lng);
var name = data[i].name;
var marker = new L.Marker(location);
marker.bindPopup("<div style='text-align: center; margin-left: auto;
margin-right: auto;'>"+ title +"</div>", {maxWidth:'200'});
users.addLayer(marker);
}
})
JSON.js is called in the index.html file as such:
<script src="src/JSON.js"></script>
also in index are other .js called in order to generate the map:
Leaflet map generated by properly interpreting the rest of the .js
all the other .js work properly. I have tried to test JSON.js by calling
it in another .html file. I am not sure that this is correct, but if it
is, it is still not giving any sign of the data being received:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript"
src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
$("#demo").live("click", function () {
$.getJSON("src/get_info.php", function(data) {
var name = data[i].name
if (data.length) {
$("#dv").html(name);
} else {
html = r.error.message
$("#dv").html(html);
}
}
)}
);
</script>
</head>
<body>
<form id="test">
<div id = "dv"></div>
<input type = "button" value = "GET" id = "demo" />
</form>
</body>
</html>
Can you please help me in solveing the problem and generateing points from
the database? Thank you
eth0 not appearing. Tried everything that seemed to work for other people
eth0 not appearing. Tried everything that seemed to work for other people
Firstly let me say I am completely new to linux so if you're going to tell
me to check something or do something, please give me a vague idea how.
Installed Ubuntu Server (newest download I could) and now struggling to
get eth0 to even be detected. The only interface being displayed is the
loopback interface, and eth0 (which should be a wired PCI ethernet card)
is nowhere to be found.
ifconfig shows only the loopback device, /etc/network/interfaces has only
these two lines in:
auto lo
iface lo inet loopback
I tried opening the file in nano (using sudo) and adding the lines
auto eth0
iface eth0 inet dhcp
but no luck. Ctrl+O should save according to the web but every time I go
back to check the file the two lines I added are gone.
Tried going to /etc/udev/rules.d/70-persistent-net.rules, however all it
says is:
# This file maintains persistent names for network interfaces.
# See udev(7) for syntax.
#
# Entries are automatically added by the 75-persistent-net-generator.rules
# file; however you are free to add your own entries.
That is all it says.
It worked fine in Windows, and I desperately need to get some actual work
done on Linux. Can anyone please shed any light on this issue? Every other
forum entry I have read has a suggested solution that works and then
everyone goes "oh great thanks" and I'm stuck here not having a clue.
Firstly let me say I am completely new to linux so if you're going to tell
me to check something or do something, please give me a vague idea how.
Installed Ubuntu Server (newest download I could) and now struggling to
get eth0 to even be detected. The only interface being displayed is the
loopback interface, and eth0 (which should be a wired PCI ethernet card)
is nowhere to be found.
ifconfig shows only the loopback device, /etc/network/interfaces has only
these two lines in:
auto lo
iface lo inet loopback
I tried opening the file in nano (using sudo) and adding the lines
auto eth0
iface eth0 inet dhcp
but no luck. Ctrl+O should save according to the web but every time I go
back to check the file the two lines I added are gone.
Tried going to /etc/udev/rules.d/70-persistent-net.rules, however all it
says is:
# This file maintains persistent names for network interfaces.
# See udev(7) for syntax.
#
# Entries are automatically added by the 75-persistent-net-generator.rules
# file; however you are free to add your own entries.
That is all it says.
It worked fine in Windows, and I desperately need to get some actual work
done on Linux. Can anyone please shed any light on this issue? Every other
forum entry I have read has a suggested solution that works and then
everyone goes "oh great thanks" and I'm stuck here not having a clue.
C# Reading only specific lines without reading line by line
C# Reading only specific lines without reading line by line
I been googling for the last hour and can not find an answer to this.
I have a large text file (1GB) and I also have a file which has this all
mapped so I know that on line x to line y it contains the data I am after.
My question is how do I take only the lines I am interested in without
iterating through all the lines in the file?
The main reason I am interested in doing it this way is for performance
reasons, I imagine it be quicker to take rows 503,432 to row 504,432 than
cycle from row 1 to 504,432 to find these rows.
Any tips much appreciated
I been googling for the last hour and can not find an answer to this.
I have a large text file (1GB) and I also have a file which has this all
mapped so I know that on line x to line y it contains the data I am after.
My question is how do I take only the lines I am interested in without
iterating through all the lines in the file?
The main reason I am interested in doing it this way is for performance
reasons, I imagine it be quicker to take rows 503,432 to row 504,432 than
cycle from row 1 to 504,432 to find these rows.
Any tips much appreciated
Tuesday, August 27, 2013
How to show user image and name in html dynamically
How to show user image and name in html dynamically
Below is my code i want to show user image and name assign to it.which is
array coming from controller so i iterate it and put it in td of table.The
records coming from database are not fixed(it can be 5 or 10 and many
more).The problem is that when it shows image and name assign to it is
coming in same row irrespective of users.i want to break td after some
record from foreach. for example:
image1 image2 image3 image4 image5 image6 image7 image8
name1 name2 name3 name4 nam5 nam6 name7 name8
but i want it like this
image1 image2 image3 image4
name1 name2 name3 name4
image5 image6 image7 image8
nam5 nam6 name7 name8
Thanks.
<table>
<?php
$userid=$this->id;
$namearray=$this->name;
$imagearray=$this->image;
$length=$this->length;
?>
<tr>
<?php
for($i=0;$i<$length;$i++) {
?>
<td>
<a href="<?php echo
$this->url(array('username' => $userid[$i]),
'user') ?>"><img src="<?php echo
$imagearray[$i];?>" height="100"
width="100"></img></a>
</td>
<?php
}
?>
</tr>
<tr>
<?php
for($i=0;$i<$length;$i++) {
?>
<td>
<a href="<?php echo
$this->url(array('username' => $userid[$i]),
'user') ?>"><?php echo $namearray[$i];?></a>
</td>
<?php
}
?>
</tr>
</table>
Below is my code i want to show user image and name assign to it.which is
array coming from controller so i iterate it and put it in td of table.The
records coming from database are not fixed(it can be 5 or 10 and many
more).The problem is that when it shows image and name assign to it is
coming in same row irrespective of users.i want to break td after some
record from foreach. for example:
image1 image2 image3 image4 image5 image6 image7 image8
name1 name2 name3 name4 nam5 nam6 name7 name8
but i want it like this
image1 image2 image3 image4
name1 name2 name3 name4
image5 image6 image7 image8
nam5 nam6 name7 name8
Thanks.
<table>
<?php
$userid=$this->id;
$namearray=$this->name;
$imagearray=$this->image;
$length=$this->length;
?>
<tr>
<?php
for($i=0;$i<$length;$i++) {
?>
<td>
<a href="<?php echo
$this->url(array('username' => $userid[$i]),
'user') ?>"><img src="<?php echo
$imagearray[$i];?>" height="100"
width="100"></img></a>
</td>
<?php
}
?>
</tr>
<tr>
<?php
for($i=0;$i<$length;$i++) {
?>
<td>
<a href="<?php echo
$this->url(array('username' => $userid[$i]),
'user') ?>"><?php echo $namearray[$i];?></a>
</td>
<?php
}
?>
</tr>
</table>
What is the minimum number of times should a player throw the die before his/her probability of getting two consecutive sixes is greater...
What is the minimum number of times should a player throw the die before
his/her probability of getting two consecutive sixes is greater...
Consider a fair die with 6 faces - the probability of each number
appearing on any throw is equal to 1/6. What is the minimum number of
times should a player throw the die before his/her probability of getting
two consecutive sixes is greater than 1/2? A sequence of throws T0,
T1,..... is said to have two consecutive sixes if for some natural number
i, both Ti and Ti+1 are sixes. For example, 1;6;6 and 1;2;6;6 both have
two consecutive sixes.
his/her probability of getting two consecutive sixes is greater...
Consider a fair die with 6 faces - the probability of each number
appearing on any throw is equal to 1/6. What is the minimum number of
times should a player throw the die before his/her probability of getting
two consecutive sixes is greater than 1/2? A sequence of throws T0,
T1,..... is said to have two consecutive sixes if for some natural number
i, both Ti and Ti+1 are sixes. For example, 1;6;6 and 1;2;6;6 both have
two consecutive sixes.
Could someone tell me what the problem it?
Could someone tell me what the problem it?
Warning: Displayed transactions may not be correct! You may need to
upgrade, or other nodes may need to upgrade.
Warning: Displayed transactions may not be correct! You may need to
upgrade, or other nodes may need to upgrade.
How to preserve current font/style while making changes to RTF text in C# Windows Forms?
How to preserve current font/style while making changes to RTF text in C#
Windows Forms?
Using Visual Studio to create a Windows Forms application, using C#. I
have a RichTextBox. This box supports formatting like colours, bold, and
underline.
I've added buttons such that people can format their text right in the
box. For example, the Bold button does this:
if (!message.SelectionFont.Bold)
message.SelectionFont = new Font(message.Font, FontStyle.Bold);
else
message.SelectionFont = new Font(message.Font, FontStyle.Regular);
This works fine for bolding and unbolding regular text. The issue is when
it is combined with other formatting. The creation of a new Font wipes
away the original formatting, and leaves me with pure bold or pure regular
text.
How can I preserve original formatting, while changing text to bold?
It shouldn't be hard-coded. I shouldn't be checking if(bold), if(italics),
if(underline) for every option, as ideally I'll be adding more options
later (colour, font, font size, etc).
Windows Forms?
Using Visual Studio to create a Windows Forms application, using C#. I
have a RichTextBox. This box supports formatting like colours, bold, and
underline.
I've added buttons such that people can format their text right in the
box. For example, the Bold button does this:
if (!message.SelectionFont.Bold)
message.SelectionFont = new Font(message.Font, FontStyle.Bold);
else
message.SelectionFont = new Font(message.Font, FontStyle.Regular);
This works fine for bolding and unbolding regular text. The issue is when
it is combined with other formatting. The creation of a new Font wipes
away the original formatting, and leaves me with pure bold or pure regular
text.
How can I preserve original formatting, while changing text to bold?
It shouldn't be hard-coded. I shouldn't be checking if(bold), if(italics),
if(underline) for every option, as ideally I'll be adding more options
later (colour, font, font size, etc).
I do not understand my output. Why am I getting the same thing twice?
I do not understand my output. Why am I getting the same thing twice?
The following program maintains 2 data structures named:
map of type HashMap
map_1 also of type HashMap
At the beginning map is populated with key : 1 and value : suhail. Then
this map is inserted into map_1 with key 20.
Again the map is populated with key : 1 and another value : CSE. This map
is again inserted into map_1.
import java.util.*;
class KeyTest {
public static void main(String args[]) {
Map<Integer,String> map = new HashMap<Integer,String>();
Map<Integer,Object> map_1 = new HashMap<Integer,Object>();
map.put(1,"suhail");
map_1.put(20,map);
map.put(1,"CSE");
map_1.put(21,map);
Set<Integer> keys = map_1.keySet();
Iterator i = keys.iterator();
while(i.hasNext()) {
System.out.println(map_1.get((Integer)i.next()));
}
}
}
This is what I get, when I print map_1 values :
{1=CSE}
{1=CSE}
But this is not, what I expected.According to me this is how the program
should have been running :
[1,suhail]--> map
[20,[1,suhail]]---> map_1
[1,CSE]--> map (A replace, because of the same keys)
[21,[1,CSE]]--->map_1
So the output should have been :
[1,suhail]
[1,CSE]
Can anyone please explain me, why don't I get this output
The following program maintains 2 data structures named:
map of type HashMap
map_1 also of type HashMap
At the beginning map is populated with key : 1 and value : suhail. Then
this map is inserted into map_1 with key 20.
Again the map is populated with key : 1 and another value : CSE. This map
is again inserted into map_1.
import java.util.*;
class KeyTest {
public static void main(String args[]) {
Map<Integer,String> map = new HashMap<Integer,String>();
Map<Integer,Object> map_1 = new HashMap<Integer,Object>();
map.put(1,"suhail");
map_1.put(20,map);
map.put(1,"CSE");
map_1.put(21,map);
Set<Integer> keys = map_1.keySet();
Iterator i = keys.iterator();
while(i.hasNext()) {
System.out.println(map_1.get((Integer)i.next()));
}
}
}
This is what I get, when I print map_1 values :
{1=CSE}
{1=CSE}
But this is not, what I expected.According to me this is how the program
should have been running :
[1,suhail]--> map
[20,[1,suhail]]---> map_1
[1,CSE]--> map (A replace, because of the same keys)
[21,[1,CSE]]--->map_1
So the output should have been :
[1,suhail]
[1,CSE]
Can anyone please explain me, why don't I get this output
java mysql java.lang.OutOfMemoryError: Java heap space
java mysql java.lang.OutOfMemoryError: Java heap space
I developed a web scraper. The Web scraper uses 6 threads, each thread
opens a web page, gets the text of an article, than writes (using a
driver) each single word of the text in a mysql database.
During the execution of the program i get a java mysql
java.lang.OutOfMemoryError: Java heap space. I installed Memory Analyzer
on Eclipse and i found that the problem is caused by the mysql driver
connection: i start a program and after 5 minutes the ram occupied by the
driver is 6 MB, after another 5 minutes 200MB, after other 5 minutes 500Mb
and then i get the java error heap space.
I don't understand why this happens.
Here is the code i use for the model (to access mysql DB)
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class model {
private Connection connect = null;
public model(){
try {
Class.forName("com.mysql.jdbc.Driver");
connect =
DriverManager.getConnection("jdbc:mysql://localhost/system?user=keyword_tool&password=l0gripp0");
} catch (Exception e) {
System.out.println(e);
}
}
public synchronized void insertCat(String parola, String categoria){
try{
PreparedStatement statement = connect.prepareStatement("insert
into sostantivi (nome, categoria) values (?, ?)");
statement.setString(1, parola);
statement.setString(2, categoria);
statement.executeUpdate();
statement.close();
} catch (Exception e){
//System.out.println(e);
}
}
public void closeDBConnection() {
try {
connect.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
Each thread simply call the method insertCat and insert a word with a
category in the database.
The Memory Analyzer plugin of Eclipse says:
I developed a web scraper. The Web scraper uses 6 threads, each thread
opens a web page, gets the text of an article, than writes (using a
driver) each single word of the text in a mysql database.
During the execution of the program i get a java mysql
java.lang.OutOfMemoryError: Java heap space. I installed Memory Analyzer
on Eclipse and i found that the problem is caused by the mysql driver
connection: i start a program and after 5 minutes the ram occupied by the
driver is 6 MB, after another 5 minutes 200MB, after other 5 minutes 500Mb
and then i get the java error heap space.
I don't understand why this happens.
Here is the code i use for the model (to access mysql DB)
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class model {
private Connection connect = null;
public model(){
try {
Class.forName("com.mysql.jdbc.Driver");
connect =
DriverManager.getConnection("jdbc:mysql://localhost/system?user=keyword_tool&password=l0gripp0");
} catch (Exception e) {
System.out.println(e);
}
}
public synchronized void insertCat(String parola, String categoria){
try{
PreparedStatement statement = connect.prepareStatement("insert
into sostantivi (nome, categoria) values (?, ?)");
statement.setString(1, parola);
statement.setString(2, categoria);
statement.executeUpdate();
statement.close();
} catch (Exception e){
//System.out.println(e);
}
}
public void closeDBConnection() {
try {
connect.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
Each thread simply call the method insertCat and insert a word with a
category in the database.
The Memory Analyzer plugin of Eclipse says:
Monday, August 26, 2013
Touch Up Outside event recorded when pressed a UIImageView
Touch Up Outside event recorded when pressed a UIImageView
I have a UIButton, I have added a action Touch up outside. I have a
UIImageView. I want the following action: when the user touches the button
and releases at the UIImageView, I want someAction to be performed.
If the user touches the button and releases in the other view not in the
UIImageView, someAction shouldn't be performed.
Thank You
I have a UIButton, I have added a action Touch up outside. I have a
UIImageView. I want the following action: when the user touches the button
and releases at the UIImageView, I want someAction to be performed.
If the user touches the button and releases in the other view not in the
UIImageView, someAction shouldn't be performed.
Thank You
What is the antonym of terminal?
What is the antonym of terminal?
This question arises when I try to describe my itinerary to ticket service
in the UK. Take for example, I plan to buy a ticket from A to B. B is the
terminal. How to say its counter part A? I cannot find a proper term. I
have to say "I will depart from A" or "I plan to go to B from A". Or I
even use "departure place" to refer to B.
This question arises when I try to describe my itinerary to ticket service
in the UK. Take for example, I plan to buy a ticket from A to B. B is the
terminal. How to say its counter part A? I cannot find a proper term. I
have to say "I will depart from A" or "I plan to go to B from A". Or I
even use "departure place" to refer to B.
Custom form posting Array rather than user input values
Custom form posting Array rather than user input values
pWe are using the Aheadworks Helpdesk Module and are trying to create a
second form to capture specific information and use the form to create a
ticket where all of the form content gets posted to the content section of
Helpdesk./p pThe problem is, if I use the name=content, what gets posted
into the content section is simply Array/p pI have tried using
name=content[] but it also returned Array/p pThe module looks to be using
this post method:/p precodepublic function newAction() { if
(!$this-gt;_getCustomerSession()-gt;getCustomerId()) {
$this-gt;_getCustomerSession()-gt;authenticate($this); return; } $session
= Mage::getSingleton('core/session'); $customer =
$this-gt;_getCustomerSession()-gt;getCustomer(); $Proto =
Mage::getModel('helpdeskultimate/proto'); $postData =
$this-gt;getRequest()-gt;getPost(); if (isset($postData['department_id']))
{ $Proto-gt;setDepartmentId($postData['department_id']); } try { $Proto
-gt;setSubject(@$postData['title']) -gt;setContent(@$postData['content'])
-gt;setPriority(@$postData['priority'])
-gt;setStoreId(Mage::app()-gt;getStore()-gt;getId())
-gt;setFrom(Mage::getSingleton('customer/customer')-gt;getId())
-gt;setSource('web'); /code/pre pI am not sure how to actually transform
the @$postData['content'] into a foreach statement, or similar. Any help
would be greatly appreciated! /p
pWe are using the Aheadworks Helpdesk Module and are trying to create a
second form to capture specific information and use the form to create a
ticket where all of the form content gets posted to the content section of
Helpdesk./p pThe problem is, if I use the name=content, what gets posted
into the content section is simply Array/p pI have tried using
name=content[] but it also returned Array/p pThe module looks to be using
this post method:/p precodepublic function newAction() { if
(!$this-gt;_getCustomerSession()-gt;getCustomerId()) {
$this-gt;_getCustomerSession()-gt;authenticate($this); return; } $session
= Mage::getSingleton('core/session'); $customer =
$this-gt;_getCustomerSession()-gt;getCustomer(); $Proto =
Mage::getModel('helpdeskultimate/proto'); $postData =
$this-gt;getRequest()-gt;getPost(); if (isset($postData['department_id']))
{ $Proto-gt;setDepartmentId($postData['department_id']); } try { $Proto
-gt;setSubject(@$postData['title']) -gt;setContent(@$postData['content'])
-gt;setPriority(@$postData['priority'])
-gt;setStoreId(Mage::app()-gt;getStore()-gt;getId())
-gt;setFrom(Mage::getSingleton('customer/customer')-gt;getId())
-gt;setSource('web'); /code/pre pI am not sure how to actually transform
the @$postData['content'] into a foreach statement, or similar. Any help
would be greatly appreciated! /p
Radix sorting code confusion
Radix sorting code confusion
I have a question about this algo:
(Slide taken from here.)
int N = a.length;
int[] count = new int[R];
for (int i = 0; i < N; i++)
count[a[i]+1]++;
for (int k = 1; k < 256; k++)
count[k] += count[k-1];
for (int i = 0; i < N; i++)
temp[count[a[i]++]] = a[i]
for (int i = 0; i < N; i++)
a[i] = temp[i];
Can someone elaborate about the 3rd for loop where we move the records
from a[] to temp[]?
I know after we accumulate counts they're supposed to be some sort of
offset. So we can insert the letters in proper place in temp[].
I'm just not sure what the a[i]++ is doing in there. (<-main question) I
know where referencing the letter in the count array, but why do we
increment the letter too? Did we change letters? Thanks.
Grateful for any help.
I have a question about this algo:
(Slide taken from here.)
int N = a.length;
int[] count = new int[R];
for (int i = 0; i < N; i++)
count[a[i]+1]++;
for (int k = 1; k < 256; k++)
count[k] += count[k-1];
for (int i = 0; i < N; i++)
temp[count[a[i]++]] = a[i]
for (int i = 0; i < N; i++)
a[i] = temp[i];
Can someone elaborate about the 3rd for loop where we move the records
from a[] to temp[]?
I know after we accumulate counts they're supposed to be some sort of
offset. So we can insert the letters in proper place in temp[].
I'm just not sure what the a[i]++ is doing in there. (<-main question) I
know where referencing the letter in the count array, but why do we
increment the letter too? Did we change letters? Thanks.
Grateful for any help.
Webdeploy permission issue
Webdeploy permission issue
I have 3 web deploy (visual studio publish project to package) packages
for which I use msdeploy command to sync with a server. One of the package
was newly added. The other two packages work fine except for the newly
added one. I see the following error in the log. I am not sure where to
set the permission for this since the permissions for iisApp provider are
already set in IIS Manager Delegation settings. I am new to IIS
configuration and .net development. Can anyone provide info on why I am
getting this error?
Here is the command used:
PS D:\Deployment> &'C:\Program Files\IIS\Microsoft Web Deploy
V3\msdeploy.exe' -verb:sync
-source:package='D:\temp\CI.Web.Pack_20130824.1\_PublishedWebsites\ProjectXYZ_Package\
ProjectXYZ.zip'
-dest="auto,computerName='https://localhost:8172/msdeploy.axd?site=siteName',username
='deployUserName',password='deployPassword',authType=basic,includeAcls='False'"
-skip:objectName=createApp -disableLink:AppPoolExtens
ion -disableLink:ContentExtension -disableLink:CertificateExtension
-allowUntrusted
Info: Using ID '2b0c6151-a2b0-4a87-9135-263330c5e619' for connections to
the remote server.
Info: Object createApp
(D:\Builds\2\Mayo.KCMS\CI.Web.Pack\Sources\DEV\Web\ProjectXYZ\obj\Rele
ase\Package\PackageTmp) skipped due to skip directive
'CommandLineSkipDirective 1'.
Info: Adding sitemanifest (sitemanifest).
Info: Adding IIS Application (Default Web Site/ProjectXYZ_deploy)
Error Code: ERROR_USER_NOT_AUTHORIZED_FOR_IISAPP
More Information: Could not complete an operation with the specified
provider ("iisApp") when connecting using the Web M
anagement Service. This can occur if the server administrator has not
authorized the user for this operation. iisApp htt
p://go.microsoft.com/fwlink/?LinkId=178034 Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_
AUTHORIZED_FOR_IISAPP.
Error count: 1.
Error on server:
wmsvc.exe Error: 0 : User:
Client IP: ::1
Content-Type: application/msdeploy
Version: 9.0.0.0
MSDeploy.VersionMin: 7.1.600.0
MSDeploy.VersionMax: 9.0.1631.0
MSDeploy.Method: Sync
MSDeploy.RequestId: 6b694745-0024-416c-9439-3e97608417b9
MSDeploy.RequestCulture: en-US
MSDeploy.RequestUICulture: en-US
ServerVersion: 9.0.1631.0
Skip: objectName="^configProtectedData$"objectName="createApp"
Provider: auto, Path:
A tracing deployment agent exception occurred that was propagated to the
client. Request ID '6b694745-0024-416c-9439-3e97608417b9'. Request
Timestamp: '8/26/2013 2:01:55 PM'. Error Details:
ERROR_USER_NOT_AUTHORIZED_FOR_IISAPP
Microsoft.Web.Deployment.DeploymentDetailedUnauthorizedAccessException:
Could not complete an operation with the specified provider ("iisApp")
when connecting using the Web Management Service. This can occur if the
server administrator has not authorized the user for this operation.
iisApp http://go.microsoft.com/fwlink/?LinkId=178034 Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_AUTHORIZED_FOR_IISAPP.
at
Microsoft.Web.Deployment.DelegationHelper.ImpersonateForOperation(String
deploymentAction, String deploymentProvider, String deploymentPath,
DelegationContextCache cache)
at
Microsoft.Web.Deployment.DelegationHelper.ImpersonateForOperation(String
deploymentAction, DeploymentObject deploymentObject)
at Microsoft.Web.Deployment.DeploymentObject.Add(DeploymentObject
source, DeploymentSyncContext syncContext)
at
Microsoft.Web.Deployment.DeploymentSyncContext.HandleAdd(DeploymentObject
destObject, DeploymentObject sourceObject)
at
Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildren(DeploymentObject
dest, DeploymentObject source)
at
Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject
dest, DeploymentObject source)
at
Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject
destinationObject, DeploymentObject sourceObject)
at
Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject
destObject, DeploymentSyncOptions syncOptions, PayloadTable
payloadTable, ContentRootTable contentRootTable, Nullable`1 syncPassId)
at
Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentAsyncData
asyncData, Nullable`1 passId)
at
Microsoft.Web.Deployment.DeploymentAgent.HandleRequestWorker(DeploymentAgentAsyncData
asyncData)
at
Microsoft.Web.Deployment.DeploymentAgent.HandleRequest(DeploymentAgentAsyncData
asyncData)
I have 3 web deploy (visual studio publish project to package) packages
for which I use msdeploy command to sync with a server. One of the package
was newly added. The other two packages work fine except for the newly
added one. I see the following error in the log. I am not sure where to
set the permission for this since the permissions for iisApp provider are
already set in IIS Manager Delegation settings. I am new to IIS
configuration and .net development. Can anyone provide info on why I am
getting this error?
Here is the command used:
PS D:\Deployment> &'C:\Program Files\IIS\Microsoft Web Deploy
V3\msdeploy.exe' -verb:sync
-source:package='D:\temp\CI.Web.Pack_20130824.1\_PublishedWebsites\ProjectXYZ_Package\
ProjectXYZ.zip'
-dest="auto,computerName='https://localhost:8172/msdeploy.axd?site=siteName',username
='deployUserName',password='deployPassword',authType=basic,includeAcls='False'"
-skip:objectName=createApp -disableLink:AppPoolExtens
ion -disableLink:ContentExtension -disableLink:CertificateExtension
-allowUntrusted
Info: Using ID '2b0c6151-a2b0-4a87-9135-263330c5e619' for connections to
the remote server.
Info: Object createApp
(D:\Builds\2\Mayo.KCMS\CI.Web.Pack\Sources\DEV\Web\ProjectXYZ\obj\Rele
ase\Package\PackageTmp) skipped due to skip directive
'CommandLineSkipDirective 1'.
Info: Adding sitemanifest (sitemanifest).
Info: Adding IIS Application (Default Web Site/ProjectXYZ_deploy)
Error Code: ERROR_USER_NOT_AUTHORIZED_FOR_IISAPP
More Information: Could not complete an operation with the specified
provider ("iisApp") when connecting using the Web M
anagement Service. This can occur if the server administrator has not
authorized the user for this operation. iisApp htt
p://go.microsoft.com/fwlink/?LinkId=178034 Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_
AUTHORIZED_FOR_IISAPP.
Error count: 1.
Error on server:
wmsvc.exe Error: 0 : User:
Client IP: ::1
Content-Type: application/msdeploy
Version: 9.0.0.0
MSDeploy.VersionMin: 7.1.600.0
MSDeploy.VersionMax: 9.0.1631.0
MSDeploy.Method: Sync
MSDeploy.RequestId: 6b694745-0024-416c-9439-3e97608417b9
MSDeploy.RequestCulture: en-US
MSDeploy.RequestUICulture: en-US
ServerVersion: 9.0.1631.0
Skip: objectName="^configProtectedData$"objectName="createApp"
Provider: auto, Path:
A tracing deployment agent exception occurred that was propagated to the
client. Request ID '6b694745-0024-416c-9439-3e97608417b9'. Request
Timestamp: '8/26/2013 2:01:55 PM'. Error Details:
ERROR_USER_NOT_AUTHORIZED_FOR_IISAPP
Microsoft.Web.Deployment.DeploymentDetailedUnauthorizedAccessException:
Could not complete an operation with the specified provider ("iisApp")
when connecting using the Web Management Service. This can occur if the
server administrator has not authorized the user for this operation.
iisApp http://go.microsoft.com/fwlink/?LinkId=178034 Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_AUTHORIZED_FOR_IISAPP.
at
Microsoft.Web.Deployment.DelegationHelper.ImpersonateForOperation(String
deploymentAction, String deploymentProvider, String deploymentPath,
DelegationContextCache cache)
at
Microsoft.Web.Deployment.DelegationHelper.ImpersonateForOperation(String
deploymentAction, DeploymentObject deploymentObject)
at Microsoft.Web.Deployment.DeploymentObject.Add(DeploymentObject
source, DeploymentSyncContext syncContext)
at
Microsoft.Web.Deployment.DeploymentSyncContext.HandleAdd(DeploymentObject
destObject, DeploymentObject sourceObject)
at
Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildren(DeploymentObject
dest, DeploymentObject source)
at
Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject
dest, DeploymentObject source)
at
Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject
destinationObject, DeploymentObject sourceObject)
at
Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject
destObject, DeploymentSyncOptions syncOptions, PayloadTable
payloadTable, ContentRootTable contentRootTable, Nullable`1 syncPassId)
at
Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentAsyncData
asyncData, Nullable`1 passId)
at
Microsoft.Web.Deployment.DeploymentAgent.HandleRequestWorker(DeploymentAgentAsyncData
asyncData)
at
Microsoft.Web.Deployment.DeploymentAgent.HandleRequest(DeploymentAgentAsyncData
asyncData)
How do I get a previous version of a file with libgit2sharp
How do I get a previous version of a file with libgit2sharp
I'm trying to use libgit2sharp to get a previous version of a file. I
would prefer the working directory to remain as is, at the very least
restored to previous condition.
My initial approach was to try to stash, checkout path on the file I want,
save that to a string variable, then stash pop. Is there a way to stash
pop? I can't find it easily. Here's the code I have so far:
using (var repo = new Repository(DirectoryPath, null))
{
var currentCommit = repo.Head.Tip.Sha;
var commit = repo.Commits.Where(c => c.Sha ==
commitHash).FirstOrDefault();
if (commit == null)
return null;
var sn = "Stash Name";
var now = new DateTimeOffset(DateTime.Now);
var diffCount = repo.Diff.Compare().Count();
if(diffCount > 0)
repo.Stashes.Add(new Signature(sn, "x@y.com", now),
options: StashModifiers.Default);
repo.CheckoutPaths(commit.Sha, new List<string>{ path },
CheckoutModifiers.None, null, null);
var fileText = File.ReadAllText(path);
repo.CheckoutPaths(currentCommit, new List<string>{path},
CheckoutModifiers.None, null, null);
if(diffCount > 0)
; // stash Pop?
}
If there's an easier approach than using Stash, that would work great also.
I'm trying to use libgit2sharp to get a previous version of a file. I
would prefer the working directory to remain as is, at the very least
restored to previous condition.
My initial approach was to try to stash, checkout path on the file I want,
save that to a string variable, then stash pop. Is there a way to stash
pop? I can't find it easily. Here's the code I have so far:
using (var repo = new Repository(DirectoryPath, null))
{
var currentCommit = repo.Head.Tip.Sha;
var commit = repo.Commits.Where(c => c.Sha ==
commitHash).FirstOrDefault();
if (commit == null)
return null;
var sn = "Stash Name";
var now = new DateTimeOffset(DateTime.Now);
var diffCount = repo.Diff.Compare().Count();
if(diffCount > 0)
repo.Stashes.Add(new Signature(sn, "x@y.com", now),
options: StashModifiers.Default);
repo.CheckoutPaths(commit.Sha, new List<string>{ path },
CheckoutModifiers.None, null, null);
var fileText = File.ReadAllText(path);
repo.CheckoutPaths(currentCommit, new List<string>{path},
CheckoutModifiers.None, null, null);
if(diffCount > 0)
; // stash Pop?
}
If there's an easier approach than using Stash, that would work great also.
Amazon OpsWorks Custom Cookbooks not updating when using Load-based instances
Amazon OpsWorks Custom Cookbooks not updating when using Load-based instances
I've deployed a stack in Amazon OpsWorks, and I extensively use custom
cookbooks to deploy my application. I have a number of instances in my
stack that are load-based (they only boot up when needed).
Anytime I make changes to my custom cookbooks, I have to manually update
the cookbooks on any running instances (by navigating to Deployments > Run
Command). The problem is that any non-booted instances are not updated,
and they don't automatically update at their next boot.
I've figured out that I can delete and then recreate all my load-based
instances, forcing them to be completely re-setup when they're next
needed, but there must be a better way to deploy updated custom cookbooks.
How can I force my offline load-based instances to update their cookbooks
at the next boot (even every boot would be fine)?
I've deployed a stack in Amazon OpsWorks, and I extensively use custom
cookbooks to deploy my application. I have a number of instances in my
stack that are load-based (they only boot up when needed).
Anytime I make changes to my custom cookbooks, I have to manually update
the cookbooks on any running instances (by navigating to Deployments > Run
Command). The problem is that any non-booted instances are not updated,
and they don't automatically update at their next boot.
I've figured out that I can delete and then recreate all my load-based
instances, forcing them to be completely re-setup when they're next
needed, but there must be a better way to deploy updated custom cookbooks.
How can I force my offline load-based instances to update their cookbooks
at the next boot (even every boot would be fine)?
c# autoamtic properties with null value
c# autoamtic properties with null value
I have following Problem.
My Auto Properties SearchedObjClass,SearchedProp ,SearchedPropValue result
into null value although i assigned values in main program to them: Can
some one help me to find out what the Problem is:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.DirectoryServices
namespace Server_Management_Tool
{
class ADClassNew
{
public static DirectoryEntry createDirectoryEntry()
{
string ldapusername = "Username";
string ldapuserpass = "Password";
using (DirectoryEntry root =new DirectoryEntry())
{
ADClassNew adclass = new ADClassNew();
root.Path = adclass.LdapPath;
root.Username = ldapusername;
root.Password = ldapuserpass;
root.AuthenticationType = AuthenticationTypes.Secure;
return root;
}
}
public string SearchedObjClass { get; set; }
public string SearchedProp { get; set; }
public string SearchedPropValue { get; set; }
public string LdapPath { get; set; }
public StringCollection LoadProperties { get; set; }
public SearchResult searchDirectory()
{
DirectoryEntry searchEntry =
ADClassNew.createDirectoryEntry();
DirectorySearcher search = new DirectorySearcher();
search.SearchRoot = searchEntry;
ADClassNew adclassnew = new ADClassNew();
//string _searchedObjClass = SearchedObjClass;
//string _searchedProp = SearchedProp;
//string _searchedPropValue = SearchedPropValue;
search.Filter =
string.Format("(&(ObjectClass={0})({1}={2}))",
adclassnew.SearchedObjClass, adclassnew.SearchedProp,
adclassnew.SearchedPropValue);
//search.Filter = "(&(objectClass=user)(cn=administrator))";
search.PropertiesToLoad.Add("memberof");
SearchResult result = search.FindOne();
return result;
}
}
}
namespace Server_Management_Tool
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ADClassNew adclassnew = new ADClassNew();
adclassnew.LdapPath = "LDAP://MyDomain";
adclassnew.SearchedObjClass = "User";
adclassnew.SearchedProp = "Displayname";
adclassnew.SearchedPropValue = "administrator";
}
}
}
I have following Problem.
My Auto Properties SearchedObjClass,SearchedProp ,SearchedPropValue result
into null value although i assigned values in main program to them: Can
some one help me to find out what the Problem is:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.DirectoryServices
namespace Server_Management_Tool
{
class ADClassNew
{
public static DirectoryEntry createDirectoryEntry()
{
string ldapusername = "Username";
string ldapuserpass = "Password";
using (DirectoryEntry root =new DirectoryEntry())
{
ADClassNew adclass = new ADClassNew();
root.Path = adclass.LdapPath;
root.Username = ldapusername;
root.Password = ldapuserpass;
root.AuthenticationType = AuthenticationTypes.Secure;
return root;
}
}
public string SearchedObjClass { get; set; }
public string SearchedProp { get; set; }
public string SearchedPropValue { get; set; }
public string LdapPath { get; set; }
public StringCollection LoadProperties { get; set; }
public SearchResult searchDirectory()
{
DirectoryEntry searchEntry =
ADClassNew.createDirectoryEntry();
DirectorySearcher search = new DirectorySearcher();
search.SearchRoot = searchEntry;
ADClassNew adclassnew = new ADClassNew();
//string _searchedObjClass = SearchedObjClass;
//string _searchedProp = SearchedProp;
//string _searchedPropValue = SearchedPropValue;
search.Filter =
string.Format("(&(ObjectClass={0})({1}={2}))",
adclassnew.SearchedObjClass, adclassnew.SearchedProp,
adclassnew.SearchedPropValue);
//search.Filter = "(&(objectClass=user)(cn=administrator))";
search.PropertiesToLoad.Add("memberof");
SearchResult result = search.FindOne();
return result;
}
}
}
namespace Server_Management_Tool
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ADClassNew adclassnew = new ADClassNew();
adclassnew.LdapPath = "LDAP://MyDomain";
adclassnew.SearchedObjClass = "User";
adclassnew.SearchedProp = "Displayname";
adclassnew.SearchedPropValue = "administrator";
}
}
}
Run App Engine development server with modules in PyCharm
Run App Engine development server with modules in PyCharm
Since the latest release of the Google App Engine Python SDK, it's
possible to use modules. I have a Python application with a default module
and another module. To start the module in the development server, the
development server has to be run like this:
dev_appserver.py app.yaml othermodule.yaml
When I add app.yaml othermodule.yaml to "Additional options" in the
Run/Debug configuration of PyCharm and then run the development server, I
get the following error message:
google.appengine.tools.devappserver2.errors.InvalidAppConfigError: "." is
a directory and a yaml configuration file is required
This is because PyCharm adds a dot at the end of the command to run the
development server, like this:
dev_appserver.py app.yaml othermodule.yaml .
Is it possible to remove the dot, or do I have to wait until this is fixed
in PyCharm? Before there were modules, there was no need for this.
Since the latest release of the Google App Engine Python SDK, it's
possible to use modules. I have a Python application with a default module
and another module. To start the module in the development server, the
development server has to be run like this:
dev_appserver.py app.yaml othermodule.yaml
When I add app.yaml othermodule.yaml to "Additional options" in the
Run/Debug configuration of PyCharm and then run the development server, I
get the following error message:
google.appengine.tools.devappserver2.errors.InvalidAppConfigError: "." is
a directory and a yaml configuration file is required
This is because PyCharm adds a dot at the end of the command to run the
development server, like this:
dev_appserver.py app.yaml othermodule.yaml .
Is it possible to remove the dot, or do I have to wait until this is fixed
in PyCharm? Before there were modules, there was no need for this.
cluster validation and determining number of clusters
cluster validation and determining number of clusters
I want to find number of cluster in the real world data set. So, I
validate the spectral clustering by using some indexes as shown in figures
below? But as you seen in figures the results are very different from one
index to other. How to determine the good number of clusters in the
spectral clustering method? If u don't have complete answer give me any
suggestion or idea that may help me.
Thanks
I want to find number of cluster in the real world data set. So, I
validate the spectral clustering by using some indexes as shown in figures
below? But as you seen in figures the results are very different from one
index to other. How to determine the good number of clusters in the
spectral clustering method? If u don't have complete answer give me any
suggestion or idea that may help me.
Thanks
Sunday, August 25, 2013
Backbone Js - parse data issue
Backbone Js - parse data issue
I'm trying to parse data to a collection view from a json file that has
number key for each group of data within it. The JSON looks like this:
{
"0": {
"artifact_id": "36",
"timestamp": "2013-08-20 11:59:00",
"modified": "2013-08-20 11:59:00",
"text": "Why did the last one duplicate? I don't think I clicked
it twice...",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
"1": {
"artifact_id": "35",
"timestamp": "2013-08-20 11:57:51",
"modified": "2013-08-20 11:57:51",
"text": "This is a new artifact for a new day.",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
"2": {
"artifact_id": "34",
"timestamp": "2013-08-20 11:57:50",
"modified": "2013-08-20 11:57:50",
"text": "This is a new artifact for a new day.",
"author_desc": "",
"object_type": "artifact",
"comments": []
}
}
How do I write a model parse to take each one of the entries (0, 1, 2...
etc) as each model from within the data?
I'm trying to parse data to a collection view from a json file that has
number key for each group of data within it. The JSON looks like this:
{
"0": {
"artifact_id": "36",
"timestamp": "2013-08-20 11:59:00",
"modified": "2013-08-20 11:59:00",
"text": "Why did the last one duplicate? I don't think I clicked
it twice...",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
"1": {
"artifact_id": "35",
"timestamp": "2013-08-20 11:57:51",
"modified": "2013-08-20 11:57:51",
"text": "This is a new artifact for a new day.",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
"2": {
"artifact_id": "34",
"timestamp": "2013-08-20 11:57:50",
"modified": "2013-08-20 11:57:50",
"text": "This is a new artifact for a new day.",
"author_desc": "",
"object_type": "artifact",
"comments": []
}
}
How do I write a model parse to take each one of the entries (0, 1, 2...
etc) as each model from within the data?
Web API OData inlinecount not mapped
Web API OData inlinecount not mapped
My question is similar to: web-api-odata-inlinecount-not-working
I have installed the following packages:
<packages>
<package id="Microsoft.AspNet.Cors" version="5.0.0-rc1"
targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.0.0-rc1"
targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.0.0-rc1"
targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Cors" version="5.0.0-rc1"
targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.OData" version="5.0.0-rc1"
targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.SelfHost" version="5.0.0-rc1"
targetFramework="net45" />
<package id="Microsoft.Data.Edm" version="5.6.0" targetFramework="net45" />
<package id="Microsoft.Data.OData" version="5.6.0"
targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net45" />
<package id="System.Spatial" version="5.6.0" targetFramework="net45" />
</packages>
The api is selfhosted with cors and attribute routing enabled.
// used for development purpose only
var cors = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(cors);
// enables attribute routing
config.MapHttpAttributeRoutes();
The method GetAllProducts of the ProductController:
[Queryable]
[HttpGet("products")]
public PageResult<ProductViewModel>
GetAllProducts(ODataQueryOptions<ProductViewModel> options)
{
//return products.AsQueryable();
ODataQuerySettings settings = new ODataQuerySettings()
{
PageSize = 2
};
IQueryable results = options.ApplyTo(products.AsQueryable(), settings);
Uri uri = Request.GetNextPageLink();
long? inlineCount = Request.GetInlineCount();
PageResult<ProductViewModel> response = new PageResult<ProductViewModel>(
results as IEnumerable<ProductViewModel>,
uri,
inlineCount);
return response;
}
The output by querying
http://localhost/api/products
is as follows:
If I'm appending ?$inlinecount=allpages the output by querying
http://localhost/api/products?$inlinecount=allpages
is as follows:
During debugging the uri and count are properly set but not mapped in the
json response:
What I'm missing?
My question is similar to: web-api-odata-inlinecount-not-working
I have installed the following packages:
<packages>
<package id="Microsoft.AspNet.Cors" version="5.0.0-rc1"
targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.0.0-rc1"
targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.0.0-rc1"
targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Cors" version="5.0.0-rc1"
targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.OData" version="5.0.0-rc1"
targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.SelfHost" version="5.0.0-rc1"
targetFramework="net45" />
<package id="Microsoft.Data.Edm" version="5.6.0" targetFramework="net45" />
<package id="Microsoft.Data.OData" version="5.6.0"
targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net45" />
<package id="System.Spatial" version="5.6.0" targetFramework="net45" />
</packages>
The api is selfhosted with cors and attribute routing enabled.
// used for development purpose only
var cors = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(cors);
// enables attribute routing
config.MapHttpAttributeRoutes();
The method GetAllProducts of the ProductController:
[Queryable]
[HttpGet("products")]
public PageResult<ProductViewModel>
GetAllProducts(ODataQueryOptions<ProductViewModel> options)
{
//return products.AsQueryable();
ODataQuerySettings settings = new ODataQuerySettings()
{
PageSize = 2
};
IQueryable results = options.ApplyTo(products.AsQueryable(), settings);
Uri uri = Request.GetNextPageLink();
long? inlineCount = Request.GetInlineCount();
PageResult<ProductViewModel> response = new PageResult<ProductViewModel>(
results as IEnumerable<ProductViewModel>,
uri,
inlineCount);
return response;
}
The output by querying
http://localhost/api/products
is as follows:
If I'm appending ?$inlinecount=allpages the output by querying
http://localhost/api/products?$inlinecount=allpages
is as follows:
During debugging the uri and count are properly set but not mapped in the
json response:
What I'm missing?
Printing data from multiple AJAX requests using JS
Printing data from multiple AJAX requests using JS
I am using the following JS code for a login system.
var ProgramFiles_Login_HomePageNew = {
LoginDetails:function(strLoginId,strPassword,callback,context) {
return new ajax_request (
this.url + '?_method=LoginDetails&_session=rw','strLoginId=' +
members[i] + '\r\nstrPassword=' + members[i], callback, context);
}
If I have an array, say
var members ["a","b","c"];
Assuming that the username and password are the same (strLoginId and
strPassword), how can I print the data returned for multiple AJAX requests
with the login credentials a, b and c?
Is there a way to loop the AJAX request from members[0] to members[i] such
that each request is sent, and the page loaded is printed on the HTML page
containing this script?
I am using the following JS code for a login system.
var ProgramFiles_Login_HomePageNew = {
LoginDetails:function(strLoginId,strPassword,callback,context) {
return new ajax_request (
this.url + '?_method=LoginDetails&_session=rw','strLoginId=' +
members[i] + '\r\nstrPassword=' + members[i], callback, context);
}
If I have an array, say
var members ["a","b","c"];
Assuming that the username and password are the same (strLoginId and
strPassword), how can I print the data returned for multiple AJAX requests
with the login credentials a, b and c?
Is there a way to loop the AJAX request from members[0] to members[i] such
that each request is sent, and the page loaded is printed on the HTML page
containing this script?
Distributive Property - A Converse Theorem
Distributive Property - A Converse Theorem
Suppose that $\ast$ distributes over $+$, where $0$ is the additive
identity. We can conclude the following.
$a \ast b = a \ast \left( b + 0\right)$
$a \ast b = a \ast b + a \ast 0$
$\therefore a \ast 0 = 0$
In other words, the additive identity and multiplicative 'annihilator'
become equivalent under the distributive property. However, the converse
is not true. Equating the two $0$'s is a necessary but insufficient
condition to establish distributivity.
My question: suppose we know that the following two statements are true
for any element $a$.
$a+0=a$
$a \ast 0 = 0$
What other conditions (in addition to the above) are sufficient to imply a
distributive property?
Suppose that $\ast$ distributes over $+$, where $0$ is the additive
identity. We can conclude the following.
$a \ast b = a \ast \left( b + 0\right)$
$a \ast b = a \ast b + a \ast 0$
$\therefore a \ast 0 = 0$
In other words, the additive identity and multiplicative 'annihilator'
become equivalent under the distributive property. However, the converse
is not true. Equating the two $0$'s is a necessary but insufficient
condition to establish distributivity.
My question: suppose we know that the following two statements are true
for any element $a$.
$a+0=a$
$a \ast 0 = 0$
What other conditions (in addition to the above) are sufficient to imply a
distributive property?
Saturday, August 24, 2013
Title and author in header without fancyhdr
Title and author in header without fancyhdr
I'm trying to have the author names and title appear on alternating pages,
respectively, in the center of the header. In addition I would like to
have even numbered pages on the left in the header and odd numbered pages
on the right in the header - Starting from page 2. I would like to avoid
using the package fancyhdr as I do no want any line separating the header
from the body.
I'm trying to have the author names and title appear on alternating pages,
respectively, in the center of the header. In addition I would like to
have even numbered pages on the left in the header and odd numbered pages
on the right in the header - Starting from page 2. I would like to avoid
using the package fancyhdr as I do no want any line separating the header
from the body.
Spock integration test in Grails not running
Spock integration test in Grails not running
I am trying to write a Grail integration test using Spock. Here is my test...
class UserControllerIntegrationSpec extends
grails.plugin.spock.IntegrationSpec {
def "test user login" () {
setup:
def mc = new UserController()
mc.request.parameters = [username:'tester@gmail.com',
password:'stav'];
when:
mc.login()
then:
def responseString = mc.response.contentAsString
responseString.indexOf("transaction") > 0
}
}
The test is in the correct integration folder.
To run, I do
grails test-app integration:spock
The command line tells me test passes but there is no details of any test
in the test-reports.
What stupid thing are my doing wrong?
Thanks
I am trying to write a Grail integration test using Spock. Here is my test...
class UserControllerIntegrationSpec extends
grails.plugin.spock.IntegrationSpec {
def "test user login" () {
setup:
def mc = new UserController()
mc.request.parameters = [username:'tester@gmail.com',
password:'stav'];
when:
mc.login()
then:
def responseString = mc.response.contentAsString
responseString.indexOf("transaction") > 0
}
}
The test is in the correct integration folder.
To run, I do
grails test-app integration:spock
The command line tells me test passes but there is no details of any test
in the test-reports.
What stupid thing are my doing wrong?
Thanks
Windows server farm on AWS/EC2
Windows server farm on AWS/EC2
We'll be deploying our application infrastructure (primarly Windows with
some Linux components) on AWS/EC2 VPC. We'll be using Chef to handle
provisioning and administration.
However, unlike Linux machines, Windows machines don't have SSH built-in
and one is forced to resort to other methods of authenticating to get
administrator access.
What's the best way to automatically grant our Chef server access to the
Windows box? Some of the methods I found:
Include a default password in the user-data script of the instance
This seems insecure, then again, these computers are inside a private
subnet of a VPC
Setup a domain controller server to manage all the computers
Research should that managing a Windows domain on EC2 can be a headache
due to the possibility of losing EC2 machines randomly. This also seems
like an unnecessary overhead for managing credentials of machines that
will be added/removed frequently.
We'll be deploying our application infrastructure (primarly Windows with
some Linux components) on AWS/EC2 VPC. We'll be using Chef to handle
provisioning and administration.
However, unlike Linux machines, Windows machines don't have SSH built-in
and one is forced to resort to other methods of authenticating to get
administrator access.
What's the best way to automatically grant our Chef server access to the
Windows box? Some of the methods I found:
Include a default password in the user-data script of the instance
This seems insecure, then again, these computers are inside a private
subnet of a VPC
Setup a domain controller server to manage all the computers
Research should that managing a Windows domain on EC2 can be a headache
due to the possibility of losing EC2 machines randomly. This also seems
like an unnecessary overhead for managing credentials of machines that
will be added/removed frequently.
How to remove the below error while running junit in eclipse with Maven
How to remove the below error while running junit in eclipse with Maven
Class not found mavenproject.MyFirstProject
java.lang.ClassNotFoundException: mavenproject.MyFirstProject
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
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)
Class not found mavenproject.MyFirstProject
java.lang.ClassNotFoundException: mavenproject.MyFirstProject
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
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)
Can you print the index of an array? c++ [on hold]
Can you print the index of an array? c++ [on hold]
Is it possible to print the index of an element in an array?
Ive been looking around for a while but cant seem to find an answer, sorry
if question seems overly noob.
Is it possible to print the index of an element in an array?
Ive been looking around for a while but cant seem to find an answer, sorry
if question seems overly noob.
From a high level programming perspective, what is the major difference between C# and F#?
From a high level programming perspective, what is the major difference
between C# and F#?
I'm aware that they both use different programming paradigms, but from a
high level perspective apart from differing syntax it seems most basic
tasks can be achieved in similar fashion.
I only say this because when I've previously touched functional
programming languages such as Haskell, writing code for basics tasks was
(at first) difficult, frustrating, and required a completely different
mindset.
For example the following took some time to get to grips with using
recursive syntax:
loop :: Int -> IO ()
loop n = if 0 == n then return () else loop (n-1)
Where as an F# loop is recognisable and understable almost immediately:
let list1 = [ 1; 5; 100; 450; 788 ]
for i in list1 do
printfn "%d" i
When C# programmers start learning F# they are advised to completely
re-think their thought pattern (which was definitely required for
Haskell), but I've now written several F# programs dealing with
conditions, loops, data sets etc to perform practical tasks, and I'm
wondering where the 'different-paradigm' barrier really kicks in?
Hopefully someone will be able to solve my confusion.
between C# and F#?
I'm aware that they both use different programming paradigms, but from a
high level perspective apart from differing syntax it seems most basic
tasks can be achieved in similar fashion.
I only say this because when I've previously touched functional
programming languages such as Haskell, writing code for basics tasks was
(at first) difficult, frustrating, and required a completely different
mindset.
For example the following took some time to get to grips with using
recursive syntax:
loop :: Int -> IO ()
loop n = if 0 == n then return () else loop (n-1)
Where as an F# loop is recognisable and understable almost immediately:
let list1 = [ 1; 5; 100; 450; 788 ]
for i in list1 do
printfn "%d" i
When C# programmers start learning F# they are advised to completely
re-think their thought pattern (which was definitely required for
Haskell), but I've now written several F# programs dealing with
conditions, loops, data sets etc to perform practical tasks, and I'm
wondering where the 'different-paradigm' barrier really kicks in?
Hopefully someone will be able to solve my confusion.
emulate android browser on PC
emulate android browser on PC
Is there a way to test your website on a simulated Android browser if you
haven't any Android device at hand?
Here I can see how the website looks like in the size of the different
devices:
http://www.responsinator.com/ (only simulated sizes with iframes)
http://fsb-welfenburg.de/responsive/ (site send through a proxy with the
correct useragent)
But I would like to be able to select the emulated device and then really
see the site on a simulated browser (maybe flash)
Is there a way to test your website on a simulated Android browser if you
haven't any Android device at hand?
Here I can see how the website looks like in the size of the different
devices:
http://www.responsinator.com/ (only simulated sizes with iframes)
http://fsb-welfenburg.de/responsive/ (site send through a proxy with the
correct useragent)
But I would like to be able to select the emulated device and then really
see the site on a simulated browser (maybe flash)
Multicast data overhead?
Multicast data overhead?
My application uses multicast capability of UDP.
In short I am using java and wish to transmit all data using a single
multicast address and port. Although the multicast listeners will be
logically divided into subgroups which can change in runtime and may not
wish to process data that comes from outside of their group.
To make this happen I have made the code so that all the running instances
of application will join the same multicast group and port but will
carefully observe the packet's sender to determine if it belongs to their
sub-group.
Warning minimum packet size for my application is 30000-60000 bytes!!!!!
Will reading every packet using MulticastSocket.receive(DatagramPacket)
and determining if its the required packet cause too much overhead (even
buffer overflow).
Would it generate massive traffic leading to congestion in the network
because every packet is sent to everyone ?
My application uses multicast capability of UDP.
In short I am using java and wish to transmit all data using a single
multicast address and port. Although the multicast listeners will be
logically divided into subgroups which can change in runtime and may not
wish to process data that comes from outside of their group.
To make this happen I have made the code so that all the running instances
of application will join the same multicast group and port but will
carefully observe the packet's sender to determine if it belongs to their
sub-group.
Warning minimum packet size for my application is 30000-60000 bytes!!!!!
Will reading every packet using MulticastSocket.receive(DatagramPacket)
and determining if its the required packet cause too much overhead (even
buffer overflow).
Would it generate massive traffic leading to congestion in the network
because every packet is sent to everyone ?
Friday, August 23, 2013
How do multiple target painters stack?
How do multiple target painters stack?
If I apply two or more target painters to the same target, is their bonus
stacked additively or multiplicatively?
For example, the M4 target painter provides a signature bonus of 30%
without training Signature Focusing. If I apply two of these to a frigate
with a base signature of 100m, is the resulting signature bonus 160m or
139m?
If I apply two or more target painters to the same target, is their bonus
stacked additively or multiplicatively?
For example, the M4 target painter provides a signature bonus of 30%
without training Signature Focusing. If I apply two of these to a frigate
with a base signature of 100m, is the resulting signature bonus 160m or
139m?
.align directive proper usage with .align(5) and 0x90
.align directive proper usage with .align(5) and 0x90
I am attempting to learn some assembly programming.I came across this
code.The macro ENTRY used in the asm file.But I cannot understand what
this code actually means?.
#define ALIGN(log) .align(log) ,0x90;
what does 0x90 mean? I am quite new to assembly.and why is ALIGN(5) used
instead of typical ALIGN(4) or ALIGN(8)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) ||
defined(__OpenBSD__)
# define ALIGN_LOG
I am attempting to learn some assembly programming.I came across this
code.The macro ENTRY used in the asm file.But I cannot understand what
this code actually means?.
#define ALIGN(log) .align(log) ,0x90;
what does 0x90 mean? I am quite new to assembly.and why is ALIGN(5) used
instead of typical ALIGN(4) or ALIGN(8)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) ||
defined(__OpenBSD__)
# define ALIGN_LOG
Nested NSArray filtering
Nested NSArray filtering
I have the need to obtain the maximum value of a property of a collection
of custom objects of the same class. The objects are stored in a NSArray,
and the property happens to be another NSArray of numbers.
Let me explain in detail:
NSArray *samples; // of CMData, 4000 elements
CMData is a class that models a sample, for a specific moment in time, of
a set of different channels that can have different values.
@interface CMData : NSObject
@property (nonatomic) NSUInteger timeStamp;
@property (nonatomic, strong) NSArray *analogChannelData; // of NSNumber,
128 elements
@end
(I have stripped other properties of the class not relevant to the question)
So for example, sample[1970] could be:
sample.timeStamp = 970800
sample.analogChannelData = <NSArray>
[
[0] = @(153.27)
[1] = @(345.35)
[2] = @(701.02)
...
[127] = @(-234.45)
]
Where each element [i] in the analogChannelData represents the value of
that specific channel i for the timeStamp 970800
Now I want to obtain the maximum value for all the 4000 samples for
channel 31. I use the following code:
NSUInteger channelIndex = 31;
NSMutableArray *values = [[NSMutableArray alloc] init]; // of NSNumber
// iterate the array of samples and for each one obtain the value for a
// specific channel and store the value in a new array
for (CMData *sample in samples) {
[values addObject:sample.analogChannelData[channelIndex]];
}
// sort the array of values
[values sortUsingSelector:@selector(compare:)];
// the maximum is the last object
NSNumber *maxValue = [values lastObject];
I want to replace this programming structure by a filter through an
NSPredcicate or use valueForKeyPath: to obtain the maximum of the data I
need.
Anyone knows how to do this without a for loop? Just using NSPredicates
and/or valueForKeyPath?
Thank you very much in advance for your help.
I have the need to obtain the maximum value of a property of a collection
of custom objects of the same class. The objects are stored in a NSArray,
and the property happens to be another NSArray of numbers.
Let me explain in detail:
NSArray *samples; // of CMData, 4000 elements
CMData is a class that models a sample, for a specific moment in time, of
a set of different channels that can have different values.
@interface CMData : NSObject
@property (nonatomic) NSUInteger timeStamp;
@property (nonatomic, strong) NSArray *analogChannelData; // of NSNumber,
128 elements
@end
(I have stripped other properties of the class not relevant to the question)
So for example, sample[1970] could be:
sample.timeStamp = 970800
sample.analogChannelData = <NSArray>
[
[0] = @(153.27)
[1] = @(345.35)
[2] = @(701.02)
...
[127] = @(-234.45)
]
Where each element [i] in the analogChannelData represents the value of
that specific channel i for the timeStamp 970800
Now I want to obtain the maximum value for all the 4000 samples for
channel 31. I use the following code:
NSUInteger channelIndex = 31;
NSMutableArray *values = [[NSMutableArray alloc] init]; // of NSNumber
// iterate the array of samples and for each one obtain the value for a
// specific channel and store the value in a new array
for (CMData *sample in samples) {
[values addObject:sample.analogChannelData[channelIndex]];
}
// sort the array of values
[values sortUsingSelector:@selector(compare:)];
// the maximum is the last object
NSNumber *maxValue = [values lastObject];
I want to replace this programming structure by a filter through an
NSPredcicate or use valueForKeyPath: to obtain the maximum of the data I
need.
Anyone knows how to do this without a for loop? Just using NSPredicates
and/or valueForKeyPath?
Thank you very much in advance for your help.
MySQL lookup joining 3 tables
MySQL lookup joining 3 tables
I have 3 tables, location, lookup and exclude with the following info...
location table
+----+--------------+
| id | location |
+----+--------------+
| 1 | Location a |
| 2 | Location b |
| 3 | Location c |
| 5 | Location d |
| 6 | Location e |
| 7 | Location f |
| 8 | Location g |
| 9 | Location h |
+----+--------------+
lookup table
+----+-------------+------+
| id | location_id | code |
+----+-------------+------+
| 1 | 2 | PR6 |
| 2 | 2 | PR7 |
| 3 | 2 | PR9 |
| 4 | 5 | WA2 |
| 6 | 8 | WA3 |
+----+-------------+------+
exclude table
+----+-------------+------+
| id | location_id | code |
+----+-------------+------+
| 1 | 2 | PR5 |
| 2 | 2 | PR8 |
+----+-------------+------+
These tables exist for a basic postcode lookup. I need to create some SQL
so a search can be done using the postcode but I need to take into account
any excluded postcodes so for example... If I was to search for "PR7" I
would get "Location B" as the result but if I was to search for PR5 or
PR8, I would not get "Location B" as these are in the exclude table. Here
is what I have so far....
SELECT
lookup.*, exclude.`code` as exclude, location.location
FROM lookup
LEFT JOIN
exclude
ON lookup.location_id = exclude.location_id
LEFT JOIN
location
ON location.location = lookup.location_id
WHERE lookup.`code` LIKE 'PR%' AND (exclude.`code` NOT LIKE 'PR8%' OR
ISNULL(exclude.`code`))
GROUP BY location.location
ORDER BY location.id
In my SQL above, the user typed "PR8" which is being sent to the where
clause using PHP variables, I look for the 1st 2 letters of the postcode
in the lookup table and then I am also trying to look for what the user
entered in the exclude table to omit this from the results. Unfortunately
I cant tell where I am going wrong, I am getting the following results
where as based on the above tables I should be getting no results due to
the exclusion...
+----+-------------+------+---------+
| id | location | code | exclude |
+----+-------------+------+---------+
| 1 | Location b | PR8 | PR5 |
+----+-------------+------+---------+
I hope I have explained this well enough but please tell me if I need to
add more detail.
I would really appreciate some guidance on this, thanks so much in advance :)
I have 3 tables, location, lookup and exclude with the following info...
location table
+----+--------------+
| id | location |
+----+--------------+
| 1 | Location a |
| 2 | Location b |
| 3 | Location c |
| 5 | Location d |
| 6 | Location e |
| 7 | Location f |
| 8 | Location g |
| 9 | Location h |
+----+--------------+
lookup table
+----+-------------+------+
| id | location_id | code |
+----+-------------+------+
| 1 | 2 | PR6 |
| 2 | 2 | PR7 |
| 3 | 2 | PR9 |
| 4 | 5 | WA2 |
| 6 | 8 | WA3 |
+----+-------------+------+
exclude table
+----+-------------+------+
| id | location_id | code |
+----+-------------+------+
| 1 | 2 | PR5 |
| 2 | 2 | PR8 |
+----+-------------+------+
These tables exist for a basic postcode lookup. I need to create some SQL
so a search can be done using the postcode but I need to take into account
any excluded postcodes so for example... If I was to search for "PR7" I
would get "Location B" as the result but if I was to search for PR5 or
PR8, I would not get "Location B" as these are in the exclude table. Here
is what I have so far....
SELECT
lookup.*, exclude.`code` as exclude, location.location
FROM lookup
LEFT JOIN
exclude
ON lookup.location_id = exclude.location_id
LEFT JOIN
location
ON location.location = lookup.location_id
WHERE lookup.`code` LIKE 'PR%' AND (exclude.`code` NOT LIKE 'PR8%' OR
ISNULL(exclude.`code`))
GROUP BY location.location
ORDER BY location.id
In my SQL above, the user typed "PR8" which is being sent to the where
clause using PHP variables, I look for the 1st 2 letters of the postcode
in the lookup table and then I am also trying to look for what the user
entered in the exclude table to omit this from the results. Unfortunately
I cant tell where I am going wrong, I am getting the following results
where as based on the above tables I should be getting no results due to
the exclusion...
+----+-------------+------+---------+
| id | location | code | exclude |
+----+-------------+------+---------+
| 1 | Location b | PR8 | PR5 |
+----+-------------+------+---------+
I hope I have explained this well enough but please tell me if I need to
add more detail.
I would really appreciate some guidance on this, thanks so much in advance :)
Whats the difference between using {{STATIC_URL}} and {% static %}
Whats the difference between using {{STATIC_URL}} and {% static %}
Throughout the django documentation and a lot of tutorials people seem to
pick freely between using the {% static %} tag, and using {{ STATIC_URL }}
with the correct context processor.
Can someone explain what the difference between them is, and any
advantages there might be to using on over the other.
Throughout the django documentation and a lot of tutorials people seem to
pick freely between using the {% static %} tag, and using {{ STATIC_URL }}
with the correct context processor.
Can someone explain what the difference between them is, and any
advantages there might be to using on over the other.
Why is Ubuntu so slow on my laptop? (13.04)
Why is Ubuntu so slow on my laptop? (13.04)
I have put Ubuntu on my Asus x401u laptop and it's been pretty slow; I've
installed the classic Gnome desktop and that's been acting odd. I've been
having to push the close button like 4 times before it responds, and it
just has been very slow. I've also tried to backup Firefox with FEBE and
it's not working. If somebody could help me with these that'd be great.
(Nothing else is slow; and I have 4 gigs of ram..)
I have put Ubuntu on my Asus x401u laptop and it's been pretty slow; I've
installed the classic Gnome desktop and that's been acting odd. I've been
having to push the close button like 4 times before it responds, and it
just has been very slow. I've also tried to backup Firefox with FEBE and
it's not working. If somebody could help me with these that'd be great.
(Nothing else is slow; and I have 4 gigs of ram..)
Thursday, August 22, 2013
My web application is not working on IE10
My web application is not working on IE10
My web application which was working fine till now (on server), suddenly
stopped working after IE is upgraded to IE10 version. It seems postback
code is not at all getting called and hence nothing is happening.
I tried Hotfix as suggested in many place
(http://support.microsoft.com/kb/2600088) but it has no effect. Also i
tried creating App_Browsers folder in my application and adding the
browser definition files manually there but to no effect.
Same application is working fine in my development machine with IE 10 ,
but not on production server.
Guys please advice what could be wrong and why this hotfix has not worked
for me. Also what can i try to make this application working.
Regards, Arpan
My web application which was working fine till now (on server), suddenly
stopped working after IE is upgraded to IE10 version. It seems postback
code is not at all getting called and hence nothing is happening.
I tried Hotfix as suggested in many place
(http://support.microsoft.com/kb/2600088) but it has no effect. Also i
tried creating App_Browsers folder in my application and adding the
browser definition files manually there but to no effect.
Same application is working fine in my development machine with IE 10 ,
but not on production server.
Guys please advice what could be wrong and why this hotfix has not worked
for me. Also what can i try to make this application working.
Regards, Arpan
90 degrees rotated text, flush to page top-right with CSS
90 degrees rotated text, flush to page top-right with CSS
I know how to rotate text 90 degrees using CSS, but I'm trying to align
the text to the top-right of the page (or a parent element) as its
90-degree-rotated self. Is this possible?
Example:
I know how to rotate text 90 degrees using CSS, but I'm trying to align
the text to the top-right of the page (or a parent element) as its
90-degree-rotated self. Is this possible?
Example:
Is it possible to specify schema.data in a Kendo.Mvc.UI.Fluent.MultiSelectBuilder
Is it possible to specify schema.data in a
Kendo.Mvc.UI.Fluent.MultiSelectBuilder
Using server-side filtering, I would like to respond to each request from
a kendo MultiSelect widget with an object comprised of multiple properties
one of which is the data items to be enumerated in the drop down list.
It looks like I need to specify schema.data. But I haven't figured out how
to specify schema.data using the MVC wrappers. Is this possible or is
there another way to do this?
Here's my custom MultiSelectBuilder code:
MultiSelectBuilder BuildSelector(HubAssemblyFieldEnums.FilterFields field,
string placeHolder, string dataValueField, string dataTextField =
default(string), string itemTemplate = default(string), string tagTemplate
= default(string)) {
var name =
System.Enum.GetName(typeof(HubAssemblyFieldEnums.FilterFields),
field);
var multiSelect = Html.Kendo().MultiSelect()
.Name(name)
.Placeholder(placeHolder)
.HighlightFirst(true)
.Filter(FilterType.Contains)
.AutoBind(false)
.DataSource(_ => _.Read(read => {
read.Action("getFilterValues", "api/hubassembly")
.Type(HttpVerbs.Post)
.Data("function(e) { return getFilters(e,
filterEnum." + name + "); }");
})
.ServerFiltering(true));
if (dataValueField != default(string)) {
multiSelect.DataValueField(dataValueField); }
if (dataTextField != default(string)) {
multiSelect.DataTextField(dataTextField); }
if (itemTemplate != default(string)) {
multiSelect.ItemTemplate(itemTemplate); }
if (tagTemplate != default(string)) {
multiSelect.TagTemplate(tagTemplate); }
return multiSelect;
}
thanks!
Kendo.Mvc.UI.Fluent.MultiSelectBuilder
Using server-side filtering, I would like to respond to each request from
a kendo MultiSelect widget with an object comprised of multiple properties
one of which is the data items to be enumerated in the drop down list.
It looks like I need to specify schema.data. But I haven't figured out how
to specify schema.data using the MVC wrappers. Is this possible or is
there another way to do this?
Here's my custom MultiSelectBuilder code:
MultiSelectBuilder BuildSelector(HubAssemblyFieldEnums.FilterFields field,
string placeHolder, string dataValueField, string dataTextField =
default(string), string itemTemplate = default(string), string tagTemplate
= default(string)) {
var name =
System.Enum.GetName(typeof(HubAssemblyFieldEnums.FilterFields),
field);
var multiSelect = Html.Kendo().MultiSelect()
.Name(name)
.Placeholder(placeHolder)
.HighlightFirst(true)
.Filter(FilterType.Contains)
.AutoBind(false)
.DataSource(_ => _.Read(read => {
read.Action("getFilterValues", "api/hubassembly")
.Type(HttpVerbs.Post)
.Data("function(e) { return getFilters(e,
filterEnum." + name + "); }");
})
.ServerFiltering(true));
if (dataValueField != default(string)) {
multiSelect.DataValueField(dataValueField); }
if (dataTextField != default(string)) {
multiSelect.DataTextField(dataTextField); }
if (itemTemplate != default(string)) {
multiSelect.ItemTemplate(itemTemplate); }
if (tagTemplate != default(string)) {
multiSelect.TagTemplate(tagTemplate); }
return multiSelect;
}
thanks!
Flask-Login - id Length Restriction
Flask-Login - id Length Restriction
I have a generic Question, Does Flask-Login - id has any length
restriction? When i try with IDs like 1,2,3 etc, it works fine, but it
throws error, when i hardcode id as 32432,56453,5656743
I have a generic Question, Does Flask-Login - id has any length
restriction? When i try with IDs like 1,2,3 etc, it works fine, but it
throws error, when i hardcode id as 32432,56453,5656743
How to get name of a document imported into your iOS app
How to get name of a document imported into your iOS app
I have an app that gets its data (CSV file) from an external source such
as email or Dropbox.
I would like to ask if there is a way to get the name of the file in the
app directory because I want to display it in an alert view.
I have an app that gets its data (CSV file) from an external source such
as email or Dropbox.
I would like to ask if there is a way to get the name of the file in the
app directory because I want to display it in an alert view.
Wednesday, August 21, 2013
Alternating colors in HTML table with not working
Alternating colors in HTML table with not working
I've created a JSP that has the following style,
<style type="css/text">
tr.color1{background-color:#00FCFF;}
tr.color2{background-color:#c1bfbb;}
</style>
I model an attribute in the JSP and render a table. Since I iterate over
the List that is modelled in my JSP, I have to set up a logic for
alternating HTML table rows.
I have used JSTL and have the following code:
<c:forEach items="${rSList}" var="rS" varStatus="rowCounter">
<tr class="${rowCounter.index % 2 == 0 ? 'color2':'color1'}">
<td style="padding-left: 4px;" >
<font face="verdana"><c:out value="${rS.NAME}" /></font>
</td>
<td style="padding-left: 4px;" >
<font face="verdana"><c:out value="${rS.AVAILABLE}"
/></font>
</td>
<td style="padding-left: 4px;" >
<font face="verdana"><c:out value="${rS.OWNER}" /></font>
</td>
I used Firebug and saw that indeed the class get alternated as :
<tr class="color2">
<!- td data gets displayed here without color2 background-->
<tr class="color1">
<!- td data gets displayed here without color1 background-->
<tr class="color2">
<tr class="color1">
<tr class="color2">
This means that the class is getting picked but the background color
doesn't change. Appreciate any help.
I've created a JSP that has the following style,
<style type="css/text">
tr.color1{background-color:#00FCFF;}
tr.color2{background-color:#c1bfbb;}
</style>
I model an attribute in the JSP and render a table. Since I iterate over
the List that is modelled in my JSP, I have to set up a logic for
alternating HTML table rows.
I have used JSTL and have the following code:
<c:forEach items="${rSList}" var="rS" varStatus="rowCounter">
<tr class="${rowCounter.index % 2 == 0 ? 'color2':'color1'}">
<td style="padding-left: 4px;" >
<font face="verdana"><c:out value="${rS.NAME}" /></font>
</td>
<td style="padding-left: 4px;" >
<font face="verdana"><c:out value="${rS.AVAILABLE}"
/></font>
</td>
<td style="padding-left: 4px;" >
<font face="verdana"><c:out value="${rS.OWNER}" /></font>
</td>
I used Firebug and saw that indeed the class get alternated as :
<tr class="color2">
<!- td data gets displayed here without color2 background-->
<tr class="color1">
<!- td data gets displayed here without color1 background-->
<tr class="color2">
<tr class="color1">
<tr class="color2">
This means that the class is getting picked but the background color
doesn't change. Appreciate any help.
Randomly named assemblies (.NET)
Randomly named assemblies (.NET)
When a .NET application (in my case it's SQL Management Studio, but I
think, it's more general issue) fails due to unhandled exception, I
receive a popup with a call stack and a list of loaded assemblies.
Among them I see 2 or 3 randomly named assemblies, which in all other
aspects look like copies of System.dll:
epovwbjf Assembly Version: 10.0.0.0 Win32 Version: 2.0.50727.5467
(Win7SP1GDR.050727-5400)
CodeBase:
file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
l3kwu1p5 Assembly Version: 10.0.0.0 Win32 Version: 2.0.50727.5467
(Win7SP1GDR.050727-5400)
CodeBase:
file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
9wpjdbe7 Assembly Version: 10.0.0.0 Win32 Version: 2.0.50727.5467
(Win7SP1GDR.050727-5400)
CodeBase:
file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
Is this a normal behaviour or a sign of malware infection ? (I've tested
that dll via virustotal.com, it detected 0/46). Why does it happen (if
it's expected) and where can I learn more on it ?
When a .NET application (in my case it's SQL Management Studio, but I
think, it's more general issue) fails due to unhandled exception, I
receive a popup with a call stack and a list of loaded assemblies.
Among them I see 2 or 3 randomly named assemblies, which in all other
aspects look like copies of System.dll:
epovwbjf Assembly Version: 10.0.0.0 Win32 Version: 2.0.50727.5467
(Win7SP1GDR.050727-5400)
CodeBase:
file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
l3kwu1p5 Assembly Version: 10.0.0.0 Win32 Version: 2.0.50727.5467
(Win7SP1GDR.050727-5400)
CodeBase:
file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
9wpjdbe7 Assembly Version: 10.0.0.0 Win32 Version: 2.0.50727.5467
(Win7SP1GDR.050727-5400)
CodeBase:
file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
Is this a normal behaviour or a sign of malware infection ? (I've tested
that dll via virustotal.com, it detected 0/46). Why does it happen (if
it's expected) and where can I learn more on it ?
How do you loop through and print a multidimensional array in a Rails view?
How do you loop through and print a multidimensional array in a Rails view?
I'm using the ancestry gem, and would like to print out an entire tree
into a table. The object I'm working with is groups, so it'd look
something like this.
Group A
|__ Group A 1
|__ Group A 1 A
|__ Group A 2
|__ Group A 2 A
|__ Group A 2 B
Group B
Group C
|__ Group C 1
Typically, I'd create a method and call itself within the loop, but that
would seem to break MVC convention. Within the view, how would I output
the object/hash?
Note: Ancestry has a method to convert the ActiveModel group to a hash, so
that is an option rather than iterating through the ActiveModel object
itself.
I'm using the ancestry gem, and would like to print out an entire tree
into a table. The object I'm working with is groups, so it'd look
something like this.
Group A
|__ Group A 1
|__ Group A 1 A
|__ Group A 2
|__ Group A 2 A
|__ Group A 2 B
Group B
Group C
|__ Group C 1
Typically, I'd create a method and call itself within the loop, but that
would seem to break MVC convention. Within the view, how would I output
the object/hash?
Note: Ancestry has a method to convert the ActiveModel group to a hash, so
that is an option rather than iterating through the ActiveModel object
itself.
Proof that 2 funtion of the type $f=?iso-8859-1?Q?=5Ft?=(x) = \frac{1}{t} \cdot e^{-tx²} $ don't intersect
Proof that 2 funtion of the type $f_t(x) = \frac{1}{t} \cdot e^{-tx²} $
don't intersect
so as the titles states I wan't to proof that no two functions $f_t$ of
type $$f_t(x) = \frac{1}{t} \cdot e^{-tx²} \; \text{given that} \; t>0$$
share a point. This is a question from my textbook. However I come to the
conclusion that there should be 2 functions should share some point.
$$f_a(x) = \frac{1}{a} \cdot e^{-ax²}$$ $$f_b(x) = \frac{1}{b} \cdot
e^{-bx²}$$ Let $f_a(x) = f_b(x)$
$$\frac{1}{a} \cdot e^{-ax²} = \frac{1}{b} \cdot e^{-bx²}$$ $$\frac{1}{a}
\cdot e^{a} = \frac{1}{b} \cdot e^{b}$$ $$ae^{-a}=be^{b}$$ In order to
proof that the 2 functions don't share a point I would need to proof that
a=b This would mean that the function $g(x)=xe^x$ is a one to one
function. However this is not true!
Now, all continuous one-one functions have to be monotonic (strictly
increasing or decreasing). But we know that this is not the case for
$g(x)$ since $\lim_{x \to 0} g(x)=\lim_{x \to +\infty}f(x)=0$ whereas
$f(1)>0$
Where is my mistake?
don't intersect
so as the titles states I wan't to proof that no two functions $f_t$ of
type $$f_t(x) = \frac{1}{t} \cdot e^{-tx²} \; \text{given that} \; t>0$$
share a point. This is a question from my textbook. However I come to the
conclusion that there should be 2 functions should share some point.
$$f_a(x) = \frac{1}{a} \cdot e^{-ax²}$$ $$f_b(x) = \frac{1}{b} \cdot
e^{-bx²}$$ Let $f_a(x) = f_b(x)$
$$\frac{1}{a} \cdot e^{-ax²} = \frac{1}{b} \cdot e^{-bx²}$$ $$\frac{1}{a}
\cdot e^{a} = \frac{1}{b} \cdot e^{b}$$ $$ae^{-a}=be^{b}$$ In order to
proof that the 2 functions don't share a point I would need to proof that
a=b This would mean that the function $g(x)=xe^x$ is a one to one
function. However this is not true!
Now, all continuous one-one functions have to be monotonic (strictly
increasing or decreasing). But we know that this is not the case for
$g(x)$ since $\lim_{x \to 0} g(x)=\lim_{x \to +\infty}f(x)=0$ whereas
$f(1)>0$
Where is my mistake?
NET STOP - domino as service and interactive window
NET STOP - domino as service and interactive window
1) i have domino running as service .
2) i have java console running to monitor server
3) i want to stop domino using NET STOP but without interactive message on
java console
"are you sure you want quit the Domino Server Controller and/or Domino
Server running (if running)?"
Press 'Y' to continue and 'N' to cancell
Q: how can i disable or bypass this message ?
thanks for your help.
1) i have domino running as service .
2) i have java console running to monitor server
3) i want to stop domino using NET STOP but without interactive message on
java console
"are you sure you want quit the Domino Server Controller and/or Domino
Server running (if running)?"
Press 'Y' to continue and 'N' to cancell
Q: how can i disable or bypass this message ?
thanks for your help.
PHP Currency display
PHP Currency display
I am trying to display a £ sign and commas with in a number to show
currency but i'm not sure how to, here is the code i have that echo's it
as 8999999 instead of £8,999,999
<div id="form">
<form action="index.php" method="post">
<center> <input type="text" name="percent" id="percent" />
<input type="submit" /> </center>
</form>
<center>
<?php
$percent=$_POST['percent'];
$total = 8999999;
/*calculation for discounted price */
$discount_value=$total/100*$percent;
$final_price = $total - $discount_value;
echo $final_price;
?>
</center>
</div>
I am trying to display a £ sign and commas with in a number to show
currency but i'm not sure how to, here is the code i have that echo's it
as 8999999 instead of £8,999,999
<div id="form">
<form action="index.php" method="post">
<center> <input type="text" name="percent" id="percent" />
<input type="submit" /> </center>
</form>
<center>
<?php
$percent=$_POST['percent'];
$total = 8999999;
/*calculation for discounted price */
$discount_value=$total/100*$percent;
$final_price = $total - $discount_value;
echo $final_price;
?>
</center>
</div>
Tuesday, August 20, 2013
DetachedCriteria: Initialize Child's child
DetachedCriteria: Initialize Child's child
I have a report with a section and each section have children.
And they are all set to lazy loaded.
May I know how to initialize those section's children?
I know how to initialize section
by using
.setFetchMode("section", FetchModel.JOIN)
but what about section's children?
I have a report with a section and each section have children.
And they are all set to lazy loaded.
May I know how to initialize those section's children?
I know how to initialize section
by using
.setFetchMode("section", FetchModel.JOIN)
but what about section's children?
Visual Basic open program
Visual Basic open program
I want to put a zip file in my application. And i want to add a folder to
the application and have buttons that will extract some of the contents of
the folder to the current directory.
I do not know how to add files to it, Or get it to run them.
I want to put a zip file in my application. And i want to add a folder to
the application and have buttons that will extract some of the contents of
the folder to the current directory.
I do not know how to add files to it, Or get it to run them.
ITU-T G.711 C source code to Java JNI
ITU-T G.711 C source code to Java JNI
Bit of backstory, I'm developing a Java softphone with a variety of audio
codecs, and after some answers here and there, I've learned that it's
better to do the audio decoding in native code due to speed.
So my first big step is to implement the PCMU G.711 audio codec in C and
link it into my Java application, which already has a Java-based PCMU
implementation.
I could rewrite it in C, but I want to have a bit of standardization, so
I'm pulling the ITU-T G.191 Software Tools Library source code
(http://www.itu.int/rec/T-REC-G.191/en). This is done with the intention
that I will also use the G.191 STL for other G-series codecs.
This is how they've written the u-law encoder:
void ulaw_compress(lseg, linbuf, logbuf)
long lseg;
short *linbuf;
short *logbuf;
{
long n; /* samples's count */
short i; /* aux.var. */
short absno; /* absolute value of linear (input) sample */
short segno; /* segment (Table 2/G711, column 1) */
short low_nibble; /* low nibble of log companded sample */
short high_nibble; /* high nibble of log companded sample */
for (n = 0; n < lseg; n++)
{
/*
--------------------------------------------------------------------
*/
/* Change from 14 bit left justified to 14 bit right justified */
/* Compute absolute value; adjust for easy processing */
/*
--------------------------------------------------------------------
*/
absno = linbuf[n] < 0 /* compute 1's complement in case of */
? ((~linbuf[n]) >> 2) + 33/* negative samples */
: ((linbuf[n]) >> 2) + 33;/* NB: 33 is the difference value */
/* between the thresholds for */
/* A-law and u-law. */
if (absno > (0x1FFF)) /* limitation to "absno" < 8192 */
absno = (0x1FFF);
/* Determination of sample's segment */
i = absno >> 6;
segno = 1;
while (i != 0)
{
segno++;
i >>= 1;
}
/* Mounting the high-nibble of the log-PCM sample */
high_nibble = (0x0008) - segno;
/* Mounting the low-nibble of the log PCM sample */
low_nibble = (absno >> segno) /* right shift of mantissa and */
& (0x000F); /* masking away leading '1' */
low_nibble = (0x000F) - low_nibble;
/* Joining the high-nibble and the low-nibble of the log PCM sample */
logbuf[n] = (high_nibble << 4) | low_nibble;
/* Add sign bit */
if (linbuf[n] >= 0)
logbuf[n] = logbuf[n] | (0x0080);
}
}
From Java to JNI, I will be passing a byte[] array of PCM linear data and
be returning a byte[] array of encoded PCMU data. Assuming I convert Java
byte[] to jbyte* to char* to short* for the ITU-T's above method, I
thought that it was supposed to take a 16-bit code word and compress it
down to an 8-bit code word.
In the above example, both linbuf (in) and logbuf (out) are short arrays.
I understand most of what is going on, but shouldn't each short (signed
16-bit number) in the linbuf short* array be compressed into a char
(signed 8-bit number) and put into logbuf as a char* array?
So when I get the returned encoded short* array, can I just cast the
logbuf short* array to a char* array and then in JNI return it back as a
Java byte[] array?
If you're familiar with JNI and can quickly write up some pseudo code that
would show me where to begin with the conversions, I'd greatly appreciate
it!
Bit of backstory, I'm developing a Java softphone with a variety of audio
codecs, and after some answers here and there, I've learned that it's
better to do the audio decoding in native code due to speed.
So my first big step is to implement the PCMU G.711 audio codec in C and
link it into my Java application, which already has a Java-based PCMU
implementation.
I could rewrite it in C, but I want to have a bit of standardization, so
I'm pulling the ITU-T G.191 Software Tools Library source code
(http://www.itu.int/rec/T-REC-G.191/en). This is done with the intention
that I will also use the G.191 STL for other G-series codecs.
This is how they've written the u-law encoder:
void ulaw_compress(lseg, linbuf, logbuf)
long lseg;
short *linbuf;
short *logbuf;
{
long n; /* samples's count */
short i; /* aux.var. */
short absno; /* absolute value of linear (input) sample */
short segno; /* segment (Table 2/G711, column 1) */
short low_nibble; /* low nibble of log companded sample */
short high_nibble; /* high nibble of log companded sample */
for (n = 0; n < lseg; n++)
{
/*
--------------------------------------------------------------------
*/
/* Change from 14 bit left justified to 14 bit right justified */
/* Compute absolute value; adjust for easy processing */
/*
--------------------------------------------------------------------
*/
absno = linbuf[n] < 0 /* compute 1's complement in case of */
? ((~linbuf[n]) >> 2) + 33/* negative samples */
: ((linbuf[n]) >> 2) + 33;/* NB: 33 is the difference value */
/* between the thresholds for */
/* A-law and u-law. */
if (absno > (0x1FFF)) /* limitation to "absno" < 8192 */
absno = (0x1FFF);
/* Determination of sample's segment */
i = absno >> 6;
segno = 1;
while (i != 0)
{
segno++;
i >>= 1;
}
/* Mounting the high-nibble of the log-PCM sample */
high_nibble = (0x0008) - segno;
/* Mounting the low-nibble of the log PCM sample */
low_nibble = (absno >> segno) /* right shift of mantissa and */
& (0x000F); /* masking away leading '1' */
low_nibble = (0x000F) - low_nibble;
/* Joining the high-nibble and the low-nibble of the log PCM sample */
logbuf[n] = (high_nibble << 4) | low_nibble;
/* Add sign bit */
if (linbuf[n] >= 0)
logbuf[n] = logbuf[n] | (0x0080);
}
}
From Java to JNI, I will be passing a byte[] array of PCM linear data and
be returning a byte[] array of encoded PCMU data. Assuming I convert Java
byte[] to jbyte* to char* to short* for the ITU-T's above method, I
thought that it was supposed to take a 16-bit code word and compress it
down to an 8-bit code word.
In the above example, both linbuf (in) and logbuf (out) are short arrays.
I understand most of what is going on, but shouldn't each short (signed
16-bit number) in the linbuf short* array be compressed into a char
(signed 8-bit number) and put into logbuf as a char* array?
So when I get the returned encoded short* array, can I just cast the
logbuf short* array to a char* array and then in JNI return it back as a
Java byte[] array?
If you're familiar with JNI and can quickly write up some pseudo code that
would show me where to begin with the conversions, I'd greatly appreciate
it!
Check array for partial match (PHP)
Check array for partial match (PHP)
I have an array of filenames which I need to check against a code, for
example
array("120_120_435645.jpg","150_150_312312.jpg","250_250_1232327.jpg");
the string is "312312" so it would match "150_150_312312.jpg" as it
contains that string.
I tried in_array but this seems to any return true if it is an exact match.
Thanks for any advice...perhaps I have been staring at it too long and a
coffee may help :)
I have an array of filenames which I need to check against a code, for
example
array("120_120_435645.jpg","150_150_312312.jpg","250_250_1232327.jpg");
the string is "312312" so it would match "150_150_312312.jpg" as it
contains that string.
I tried in_array but this seems to any return true if it is an exact match.
Thanks for any advice...perhaps I have been staring at it too long and a
coffee may help :)
compare old value and new value
compare old value and new value
I have a trigger. I want to do insert changed values after every update.
But I get syntax error on line IF .. THEN, and I can't find example.
IF (IFNULL(NEW.symbol,'') <> IFNULL(OLD.symbol,'')) THEN
INSERT INTO LOG(old_value, new_value, DATA, user)
VALUES ('Symbol: '|| IFNULL(OLD.symbol,''), 'Symbol: '
(IFNULL(NEW.symbol,''), CURRENT_TIMESTAMP, id_user)
Can You help me?
I have a trigger. I want to do insert changed values after every update.
But I get syntax error on line IF .. THEN, and I can't find example.
IF (IFNULL(NEW.symbol,'') <> IFNULL(OLD.symbol,'')) THEN
INSERT INTO LOG(old_value, new_value, DATA, user)
VALUES ('Symbol: '|| IFNULL(OLD.symbol,''), 'Symbol: '
(IFNULL(NEW.symbol,''), CURRENT_TIMESTAMP, id_user)
Can You help me?
Issue showing mobile version in iframe
Issue showing mobile version in iframe
I'm trying to use "container" attribute pointing to iframe in mobile site
version, but inkfilepicker sends desktop content in this case for both
desktop and mobile devices. In attribute "container" is removed, I'm
getting a new tab with mobile content. Please advice.
I'm trying to use "container" attribute pointing to iframe in mobile site
version, but inkfilepicker sends desktop content in this case for both
desktop and mobile devices. In attribute "container" is removed, I'm
getting a new tab with mobile content. Please advice.
Monday, August 19, 2013
NSNumber in NSDictionary is always null
NSNumber in NSDictionary is always null
I'm building a project and want to add a NSNumber into a NSDictionary. But
the it crashed because of the null value. So, I created another small
program to check what happened. As you can see in the snapshot: Why the
the value of NSNumber in NSDictionary is null?
I'm building a project and want to add a NSNumber into a NSDictionary. But
the it crashed because of the null value. So, I created another small
program to check what happened. As you can see in the snapshot: Why the
the value of NSNumber in NSDictionary is null?
How does the NES Zapper work?
How does the NES Zapper work?
You may have played NES Console games when you were younger -- I know I
did. I remember playing Duck Hunt, for one:
Duck Hunt came with a peripheral called the NES Zapper:
How does it work? How did the NES, which was far less advanced than modern
pointing consoles like the Wii, know where we were aiming?
You may have played NES Console games when you were younger -- I know I
did. I remember playing Duck Hunt, for one:
Duck Hunt came with a peripheral called the NES Zapper:
How does it work? How did the NES, which was far less advanced than modern
pointing consoles like the Wii, know where we were aiming?
Fast pseudorandom number generator for cryptography in C
Fast pseudorandom number generator for cryptography in C
I was using the following code to generate sequence of pseudo-random
numbers that was used for cryptographic purposes, but then I read
somewhere that it may not be very secure. Can someone give me C
implementation of a better generator -- the main goal is for this method
to be fast. For instance, I did some research and came across Blum Blum
Shub method, which would totally kill performance by doing pow(N)
calculations.
PS. And please don't quote Wikipedia articles w/o C/C++ code. I'm looking
for C or C++ code sample of what I'm showing below.
#define ROL(v, shift) ((((v) >> ((sizeof(v) * 8) - (shift))) | ((v) <<
(shift))))
ULONGLONG uiPSN = doSeed(); //64-bit unsigned integer
for(int i = 0; i < sizeOfArray; i++)
{
uiPSN = uiPSN * 214013L + 2531011L;
uiPSN = ROL(uiPSN, 16);
//Apply 'uiPSN'
}
I was using the following code to generate sequence of pseudo-random
numbers that was used for cryptographic purposes, but then I read
somewhere that it may not be very secure. Can someone give me C
implementation of a better generator -- the main goal is for this method
to be fast. For instance, I did some research and came across Blum Blum
Shub method, which would totally kill performance by doing pow(N)
calculations.
PS. And please don't quote Wikipedia articles w/o C/C++ code. I'm looking
for C or C++ code sample of what I'm showing below.
#define ROL(v, shift) ((((v) >> ((sizeof(v) * 8) - (shift))) | ((v) <<
(shift))))
ULONGLONG uiPSN = doSeed(); //64-bit unsigned integer
for(int i = 0; i < sizeOfArray; i++)
{
uiPSN = uiPSN * 214013L + 2531011L;
uiPSN = ROL(uiPSN, 16);
//Apply 'uiPSN'
}
How do I kill all open powerpoint process?
How do I kill all open powerpoint process?
I am trying to kill all open powerpoint processes but the code I wrote
kills only one open process.
'-- get a collection of processes running
Dim foo() As System.Diagnostics.Process =
System.Diagnostics.Process.GetProcesses
'-- go through each one looking for the internet explorer name
For Each temp As Diagnostics.Process In foo
'For Word Files opened in Office
If temp.ProcessName = "POWERPNT" Then
temp.Kill() '-- if I find it, kill it.
' Exit For '-- exit the for loop
End If
I am trying to kill all open powerpoint processes but the code I wrote
kills only one open process.
'-- get a collection of processes running
Dim foo() As System.Diagnostics.Process =
System.Diagnostics.Process.GetProcesses
'-- go through each one looking for the internet explorer name
For Each temp As Diagnostics.Process In foo
'For Word Files opened in Office
If temp.ProcessName = "POWERPNT" Then
temp.Kill() '-- if I find it, kill it.
' Exit For '-- exit the for loop
End If
Ruby YAML force double quotes when dumping
Ruby YAML force double quotes when dumping
I have a small script to automate some things in YAML files.
I read the original YAML file, convert it into a hash and then dump it to
the file after modifying it.
File.open(output_file, "w") do |out|
YAML.dump(modified_hash, out)
end
That works fine, but it removes double quotes around the string if they
aren't needed. That's valid YAML, but it doesn't look very nice.
As a solution, I could add a space at the end of every string, but I'm not
too happy with that. Is there any way of forcing double quotes around
strings?
I have a small script to automate some things in YAML files.
I read the original YAML file, convert it into a hash and then dump it to
the file after modifying it.
File.open(output_file, "w") do |out|
YAML.dump(modified_hash, out)
end
That works fine, but it removes double quotes around the string if they
aren't needed. That's valid YAML, but it doesn't look very nice.
As a solution, I could add a space at the end of every string, but I'm not
too happy with that. Is there any way of forcing double quotes around
strings?
Sunday, August 18, 2013
Partial derivative of a function with respect to a vector
Partial derivative of a function with respect to a vector
I have the following error term E:
$$E = \frac{1}{c}\sum_{\substack{ i<j}} \frac{[d_{ij}^* -
d_{ij}]^2}{d_{ij}^*}$$
where
$$c = \sum_{\substack{ i<j}}d_{ij}^*$$
and
$$d_{ij} = \sqrt{\sum_{\substack{k=1}}^{d} [ y_{ik} - y_{jk}]^2}$$
$d_{ij}^*$ have the same equation as above but its values are constant but
the measures are in $\mathbb{R}^{N}$ and $N > d$ .
I need step by step explanation on finding the partial derivative
$\frac{\partial E}{\partial y_{pq}}$ which is given below.
$$\frac{\partial E}{\partial y_{pq}} = \frac{-2}{c}\sum_{\substack{
j=1,j\neq p}}^{N} \left[\frac{d_{pj}^* -
d_{pj}}{d_{pj}d_{pj}^*}\right](y_{pq} - y_{jq}) $$
I have the following error term E:
$$E = \frac{1}{c}\sum_{\substack{ i<j}} \frac{[d_{ij}^* -
d_{ij}]^2}{d_{ij}^*}$$
where
$$c = \sum_{\substack{ i<j}}d_{ij}^*$$
and
$$d_{ij} = \sqrt{\sum_{\substack{k=1}}^{d} [ y_{ik} - y_{jk}]^2}$$
$d_{ij}^*$ have the same equation as above but its values are constant but
the measures are in $\mathbb{R}^{N}$ and $N > d$ .
I need step by step explanation on finding the partial derivative
$\frac{\partial E}{\partial y_{pq}}$ which is given below.
$$\frac{\partial E}{\partial y_{pq}} = \frac{-2}{c}\sum_{\substack{
j=1,j\neq p}}^{N} \left[\frac{d_{pj}^* -
d_{pj}}{d_{pj}d_{pj}^*}\right](y_{pq} - y_{jq}) $$
Python Scrapy - save only Item values and not dict lists?
Python Scrapy - save only Item values and not dict lists?
pI have a spider I setup to parse through RSS feeds and save the results
to a database, which works perfectly. However, all the values I save to
the database look like the following:/p
pcode{http://feeds.reuters.com/~r/reuters/businessNews/~3/_mdwUbG4B88/story01.htm}/code/p
pMy question is, where and how do I edit the item (I'm assuming in the
pipeline?) so that only the text is saved and not the {} or ./p pHere's
the pipeline code I'm using:/p precodefrom sqlalchemy.orm import
sessionmaker from models import Feeds, db_connect, create_feeds_table
import MySQLdb import settings class Feeds2Pipeline(object): def
__init__(self): Initialize database connection engine = db_connect()
create_feeds_table(engine) self.Session = sessionmaker(bind=engine) def
process_item(self, item, spider): Save the feeds into the database session
= self.Session() feed = Feeds(**item) try: session.add(feed)
session.commit() except: session.rollback() raise finally: session.close()
return item /code/pre pAnd here's the additional database back-end:/p
precodefrom sqlalchemy import create_engine from
sqlalchemy.ext.declarative import declarative_base from
sqlalchemy.engine.url import URL from sqlalchemy import create_engine,
Column, Integer, String, Date import settings DeclarativeBase =
declarative_base() def db_connect(): return
create_engine(URL(**settings.DATABASE)) def create_feeds_table(engine):
DeclarativeBase.metadata.create_all(engine) class Feeds(DeclarativeBase):
__tablename__ = rawFeeds id = Column(Integer, primary_key=True) link =
Column('link', String) date = Column('date', String) source =
Column('source', String) /code/pre
pI have a spider I setup to parse through RSS feeds and save the results
to a database, which works perfectly. However, all the values I save to
the database look like the following:/p
pcode{http://feeds.reuters.com/~r/reuters/businessNews/~3/_mdwUbG4B88/story01.htm}/code/p
pMy question is, where and how do I edit the item (I'm assuming in the
pipeline?) so that only the text is saved and not the {} or ./p pHere's
the pipeline code I'm using:/p precodefrom sqlalchemy.orm import
sessionmaker from models import Feeds, db_connect, create_feeds_table
import MySQLdb import settings class Feeds2Pipeline(object): def
__init__(self): Initialize database connection engine = db_connect()
create_feeds_table(engine) self.Session = sessionmaker(bind=engine) def
process_item(self, item, spider): Save the feeds into the database session
= self.Session() feed = Feeds(**item) try: session.add(feed)
session.commit() except: session.rollback() raise finally: session.close()
return item /code/pre pAnd here's the additional database back-end:/p
precodefrom sqlalchemy import create_engine from
sqlalchemy.ext.declarative import declarative_base from
sqlalchemy.engine.url import URL from sqlalchemy import create_engine,
Column, Integer, String, Date import settings DeclarativeBase =
declarative_base() def db_connect(): return
create_engine(URL(**settings.DATABASE)) def create_feeds_table(engine):
DeclarativeBase.metadata.create_all(engine) class Feeds(DeclarativeBase):
__tablename__ = rawFeeds id = Column(Integer, primary_key=True) link =
Column('link', String) date = Column('date', String) source =
Column('source', String) /code/pre
User login with PHP and MySQLi not working
User login with PHP and MySQLi not working
I've got a simple form to register users that works perfectly. Now I'm
trying to log in with any registered user but I can't make it work. I've
been reading a while about people with the same problem but I can't find a
solution.
Here's my code:
connection.inc.php
<?php
$name = 'pruser';
$pwd = 'pruser';
$dbname = 'project1db';
$conn = new mysqli("localhost", $name, $pwd, $dbname);
login.php
<?php
include('connection.inc.php');
if (isset($_POST['login'])) {
session_start();
$username = trim($_POST['user']);
$password = trim(sha1($_POST['pass']));
// check user in db
$sql = "SELECT user, pwd FROM users WHERE user = ? AND pwd = ? LIMIT 1";
$stmt = $conn->prepare($sql);
if ($stmt === false) {
echo 'Error';
}
$stmt->bind_param('ss', $username, $password);
$stmt->execute();
$stmt->bind_result($username, $password);
echo $stmt->num_rows;
$stmt->close();
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Log in - Project 1</title>
</head>
<body>
<form id="form1" method="post" action="">
<fieldset>
<legend>Log in</legend>
<p>
<label for="user">Username</label>
<input type="text" name="user" id="user">
<label for="pass">Password</label>
<input type="password" name="pass" id="pass">
</p>
<p>
<input type="submit" name="login" id="login" value="Log in">
</p>
</fieldset>
</form>
<a href="register.php">Register</a/>
</body>
</html>
When I check how many rows are affected the result is -1. After loging in
I want it to redirect to index.php. That's not a problem, but first I need
to log in.
I've got a simple form to register users that works perfectly. Now I'm
trying to log in with any registered user but I can't make it work. I've
been reading a while about people with the same problem but I can't find a
solution.
Here's my code:
connection.inc.php
<?php
$name = 'pruser';
$pwd = 'pruser';
$dbname = 'project1db';
$conn = new mysqli("localhost", $name, $pwd, $dbname);
login.php
<?php
include('connection.inc.php');
if (isset($_POST['login'])) {
session_start();
$username = trim($_POST['user']);
$password = trim(sha1($_POST['pass']));
// check user in db
$sql = "SELECT user, pwd FROM users WHERE user = ? AND pwd = ? LIMIT 1";
$stmt = $conn->prepare($sql);
if ($stmt === false) {
echo 'Error';
}
$stmt->bind_param('ss', $username, $password);
$stmt->execute();
$stmt->bind_result($username, $password);
echo $stmt->num_rows;
$stmt->close();
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Log in - Project 1</title>
</head>
<body>
<form id="form1" method="post" action="">
<fieldset>
<legend>Log in</legend>
<p>
<label for="user">Username</label>
<input type="text" name="user" id="user">
<label for="pass">Password</label>
<input type="password" name="pass" id="pass">
</p>
<p>
<input type="submit" name="login" id="login" value="Log in">
</p>
</fieldset>
</form>
<a href="register.php">Register</a/>
</body>
</html>
When I check how many rows are affected the result is -1. After loging in
I want it to redirect to index.php. That's not a problem, but first I need
to log in.
How do you make instance variable in a controller and use the instance variable in the view?
How do you make instance variable in a controller and use the instance
variable in the view?
I need to know if a directory is empty so as they will not be displayed.
Trying to store: If a directory has files; Then I will call it in the view.
def index
@filter = params[:filter]
@type = params[:type]
@content = []
if @filter
directory_path = "public/files/marketing/voip"
directory = Dir.glob("#{directory_path}/#{@filter}/#{@type}")
directory.each do |data|
if File.exists?(data) && !File.directory?(data)
@content = Array.new("#{@type}")
end
@view = 'types'
end
end
I am not sure how to store the information, here I want to store the @type
of only empty directories.
Then call @content in the view to display the directories that have the
@type I stored.
variable in the view?
I need to know if a directory is empty so as they will not be displayed.
Trying to store: If a directory has files; Then I will call it in the view.
def index
@filter = params[:filter]
@type = params[:type]
@content = []
if @filter
directory_path = "public/files/marketing/voip"
directory = Dir.glob("#{directory_path}/#{@filter}/#{@type}")
directory.each do |data|
if File.exists?(data) && !File.directory?(data)
@content = Array.new("#{@type}")
end
@view = 'types'
end
end
I am not sure how to store the information, here I want to store the @type
of only empty directories.
Then call @content in the view to display the directories that have the
@type I stored.
How to make input+label in a form appear one by one?
How to make input+label in a form appear one by one?
Can someone help me with my example on How to make input+label in a form
appear one by one?
I have a with some inputs and labels and i want to make them appear one by
one. When the ENTER KEY will be pressed there the label #1 and the input
#1 must dissapear and second label + input must appear.
My script + css and jss is up on the jsfiddle http://jsfiddle.net/zApq4/
My js is:
$(document).ready(function() {
// First Show the First Element & Focus it
$("form.fieldContainer:first-child").fadeIn(500).focus();
// Setup a transition handler:
$("form.fieldContainer").keyup(function(ev) {
if $('#nextButton').click(show_next);
{
ev.preventDefault();
ev.stopPropagation();
var _next =
$(this).parents('form.fieldContainer').next('form.fieldContainer');
_next.fadeIn(500);
_next.find("input").focus();
}
});
});
I guess i'm doing something wrong in my js but i can't realise what.
Thanks to everyone
Can someone help me with my example on How to make input+label in a form
appear one by one?
I have a with some inputs and labels and i want to make them appear one by
one. When the ENTER KEY will be pressed there the label #1 and the input
#1 must dissapear and second label + input must appear.
My script + css and jss is up on the jsfiddle http://jsfiddle.net/zApq4/
My js is:
$(document).ready(function() {
// First Show the First Element & Focus it
$("form.fieldContainer:first-child").fadeIn(500).focus();
// Setup a transition handler:
$("form.fieldContainer").keyup(function(ev) {
if $('#nextButton').click(show_next);
{
ev.preventDefault();
ev.stopPropagation();
var _next =
$(this).parents('form.fieldContainer').next('form.fieldContainer');
_next.fadeIn(500);
_next.find("input").focus();
}
});
});
I guess i'm doing something wrong in my js but i can't realise what.
Thanks to everyone
Include file contents in script PHP
Include file contents in script PHP
Real simple one for someone. I've forgotten the terminology, so I'm having
trouble finding a question I'm sure has already been answered.
I'd like to read the contents of a file that's included in the script
itself eg.
<php
// do stuff
// read file at end of script
__FILE_HERE__
zzz 123 5445
aab 494 2983
__END_OF_FILE
?>
What is this technique officially called (eg. 'In script file') - if I
know the term, I'll be off and away coding it I'm sure.
Real simple one for someone. I've forgotten the terminology, so I'm having
trouble finding a question I'm sure has already been answered.
I'd like to read the contents of a file that's included in the script
itself eg.
<php
// do stuff
// read file at end of script
__FILE_HERE__
zzz 123 5445
aab 494 2983
__END_OF_FILE
?>
What is this technique officially called (eg. 'In script file') - if I
know the term, I'll be off and away coding it I'm sure.
Creating a very simple toolbox with jquery. How to insert text from title attr
Creating a very simple toolbox with jquery. How to insert text from title
attr
I'm about to create a very simple tooltip solution for my website based on
jquery. Im using the following script:
jQuery(document).ready(function($){
$("a.tooltip").hover(function () {
$('<div
class="tooltip-box"><p></p></div>').text($this.attr('title')).appendTo(this);
}, function () {
$("div.tooltip-box").remove();
});
$("a.tooltip").on("click", function(event){
event.preventDefault();
});
});
The markup:
<a href="#" title="Tooltip text here" class="tooltip"></a>
Somehow it isn't working at the moment. I tried a lot myself and searched
here but can't figure it out. Sorry if is only simple syntax error. I'm a
jquery beginner. Thanks for your help!
attr
I'm about to create a very simple tooltip solution for my website based on
jquery. Im using the following script:
jQuery(document).ready(function($){
$("a.tooltip").hover(function () {
$('<div
class="tooltip-box"><p></p></div>').text($this.attr('title')).appendTo(this);
}, function () {
$("div.tooltip-box").remove();
});
$("a.tooltip").on("click", function(event){
event.preventDefault();
});
});
The markup:
<a href="#" title="Tooltip text here" class="tooltip"></a>
Somehow it isn't working at the moment. I tried a lot myself and searched
here but can't figure it out. Sorry if is only simple syntax error. I'm a
jquery beginner. Thanks for your help!
Saturday, August 17, 2013
How to communicate a Java server with PHP
How to communicate a Java server with PHP
I succeeded setup a JAVA tcp server. I succeeded setup a PHP tcp client.
(by using stream_get_contents, fwrite) The problem is, when i try to
transfer my PHP tcp client to an hosting company (in my case Godaddy.com),
it doesn't works. Godaddy probably blocks stream_get_contents. What are my
alternatives?
I succeeded setup a JAVA tcp server. I succeeded setup a PHP tcp client.
(by using stream_get_contents, fwrite) The problem is, when i try to
transfer my PHP tcp client to an hosting company (in my case Godaddy.com),
it doesn't works. Godaddy probably blocks stream_get_contents. What are my
alternatives?
random number generator gives same number in array twice for a given game (bingo)
random number generator gives same number in array twice for a given game
(bingo)
I am trying to create a bingo game, and I have a board that gets random
generated numbers on it for each user. However, for every user it
generates the same random board. Effectively @places, gets put in array
@bingo_cards. But instead of being two different hashes of numbers, they
end up the same. There is something wrong with my method below.
The first method sets up the board, and the second method picks numbers
for it
def start_game(user_goes_first)
#bingo slots
@places = {
a1:" ",a2:" ",a3:" ", a4:" ", a5:" ",
b1:" ",b2:" ",b3:" ", b4:" ", b5:" ",
c1:" ",c2:" ",c3:" ", c4:" ", c5:" ",
d1:" ",d2:" ",d3:" ", d4:" ", d5:" ",
e1:" ",e2:" ",e3:" ", e4:" ", e5:" "
}
@places_keys = [
:a1,:a2,:a3,:a4,:a5,
:b1,:b2,:b3,:b4,:b5,
:c1,:c2,:c3,:c4,:c5,
:d1,:d2,:d3,:d4,:d5,
:e1,:e2,:e3,:e4,:e5
]
@bingo_cards = []
@user_name.each do |numbers|
@places_keys.each_with_index do |n,i|
@places[n] = pick_number(i)
end
@bingo_cards << @places
end
user_turn
end
def pick_number(num)
#generates random numbers that make up the bingo board(s)
case num
when 0..5
rand(1..15)
when 6..10
rand(16..30)
when 11..12
rand(16..30)
when 13
"X"
when 14..15
rand(16..30)
when 16..20
rand(31..45)
when 21..25
rand(46..60)
else
0
end
end
(bingo)
I am trying to create a bingo game, and I have a board that gets random
generated numbers on it for each user. However, for every user it
generates the same random board. Effectively @places, gets put in array
@bingo_cards. But instead of being two different hashes of numbers, they
end up the same. There is something wrong with my method below.
The first method sets up the board, and the second method picks numbers
for it
def start_game(user_goes_first)
#bingo slots
@places = {
a1:" ",a2:" ",a3:" ", a4:" ", a5:" ",
b1:" ",b2:" ",b3:" ", b4:" ", b5:" ",
c1:" ",c2:" ",c3:" ", c4:" ", c5:" ",
d1:" ",d2:" ",d3:" ", d4:" ", d5:" ",
e1:" ",e2:" ",e3:" ", e4:" ", e5:" "
}
@places_keys = [
:a1,:a2,:a3,:a4,:a5,
:b1,:b2,:b3,:b4,:b5,
:c1,:c2,:c3,:c4,:c5,
:d1,:d2,:d3,:d4,:d5,
:e1,:e2,:e3,:e4,:e5
]
@bingo_cards = []
@user_name.each do |numbers|
@places_keys.each_with_index do |n,i|
@places[n] = pick_number(i)
end
@bingo_cards << @places
end
user_turn
end
def pick_number(num)
#generates random numbers that make up the bingo board(s)
case num
when 0..5
rand(1..15)
when 6..10
rand(16..30)
when 11..12
rand(16..30)
when 13
"X"
when 14..15
rand(16..30)
when 16..20
rand(31..45)
when 21..25
rand(46..60)
else
0
end
end
ssh -T git@github.com Permission denied (publickey)
ssh -T git@github.com Permission denied (publickey)
I tried to push my blog (Octopress) to github and got this error:
MacBook-Air:octopress bdeely$ git push origin source
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I generated an SSH key, saved it, and even linked it with my GitHub
account in the SSH key settings, but I went ahead and checked the status
and got the same error:
MacBook-Air:.ssh bdeely$ ssh -T git@github.com
Permission denied (publickey).
Does anyone know what is wrong and how I can fix this?
I tried to push my blog (Octopress) to github and got this error:
MacBook-Air:octopress bdeely$ git push origin source
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I generated an SSH key, saved it, and even linked it with my GitHub
account in the SSH key settings, but I went ahead and checked the status
and got the same error:
MacBook-Air:.ssh bdeely$ ssh -T git@github.com
Permission denied (publickey).
Does anyone know what is wrong and how I can fix this?
Kmeans implementation in c++
Kmeans implementation in c++
I have some data information read from a .csv file (coordinates and
dimensions). I need to do kmeans clustering of the data points I have. Can
anyone provide some k-means algorithm implementation in c++?
Thanks in advance.
I have some data information read from a .csv file (coordinates and
dimensions). I need to do kmeans clustering of the data points I have. Can
anyone provide some k-means algorithm implementation in c++?
Thanks in advance.
Add/Remove class without using toggle class
Add/Remove class without using toggle class
I want to use it without toggleClass method
<style type="text/css">
p { background:#FF0000; color:#FFFFFF; font-weight:bold;}
.hover{ background:#000099;}
</style>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('p').on('click', function() {
$(this).addClass("hover")
} $(this).removeClass("hover")
});
});
</script>
<body>
<div id="elm">
<p>prem</p>
<p>Ravi<p>
<p>Sanjay
<p>
<p>Anjali<p>
</div>
</body>
I want to use it without toggleClass method
<style type="text/css">
p { background:#FF0000; color:#FFFFFF; font-weight:bold;}
.hover{ background:#000099;}
</style>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('p').on('click', function() {
$(this).addClass("hover")
} $(this).removeClass("hover")
});
});
</script>
<body>
<div id="elm">
<p>prem</p>
<p>Ravi<p>
<p>Sanjay
<p>
<p>Anjali<p>
</div>
</body>
Combine __in and contains query filter to make a more complex filter in django
Combine __in and contains query filter to make a more complex filter in
django
So here's my question :
Say i have a list of some people's full names and I want to filter my
users to check which one of those people are already of my users.
The problem is that users have first name and last name but what I have is
the list of full names, meaning 'first_name+last_name'.
I was trying to filter in 3 steps, first filter all users whose
first_names where in the list and then filter with their last_name.The
third step would be to check for exact matches between the results, But
the problem is I can't filter my users with their first_name in the list
because __in operator looks for exact matches not partial matches.
So:
Is there anyway to do a filter like this :
users.filter(first_name__in__icontains=list_of_people)
or even better, can i have a filter like :
users.filter((first_name+ ' ' + last_name)__in=list_of_people)
?
Any help would be appreciated :)
Thanks
django
So here's my question :
Say i have a list of some people's full names and I want to filter my
users to check which one of those people are already of my users.
The problem is that users have first name and last name but what I have is
the list of full names, meaning 'first_name+last_name'.
I was trying to filter in 3 steps, first filter all users whose
first_names where in the list and then filter with their last_name.The
third step would be to check for exact matches between the results, But
the problem is I can't filter my users with their first_name in the list
because __in operator looks for exact matches not partial matches.
So:
Is there anyway to do a filter like this :
users.filter(first_name__in__icontains=list_of_people)
or even better, can i have a filter like :
users.filter((first_name+ ' ' + last_name)__in=list_of_people)
?
Any help would be appreciated :)
Thanks
Add email address into web pages which include plus sign
Add email address into web pages which include plus sign
I got some issues while adding a email address into my website . the email
address contain special characters too. therefore when i enter email
address it divided in to two
email Address : abc+de@gmail.com
this is what i have tried ;
<a href="mailto:abc+de@gmail.com">abc+de@gmail.com</a>
on site the link is broken into two parts
pls advice how to add this email address?
I got some issues while adding a email address into my website . the email
address contain special characters too. therefore when i enter email
address it divided in to two
email Address : abc+de@gmail.com
this is what i have tried ;
<a href="mailto:abc+de@gmail.com">abc+de@gmail.com</a>
on site the link is broken into two parts
pls advice how to add this email address?
Friday, August 16, 2013
mac python 2.7 django crash segmentation fault
mac python 2.7 django crash segmentation fault
I installed django and i am able to run import django. However, when I run
print(django.get_version()), it crashes with Segmentation fault: 11
Then I expand the 'report to apple' window prompt. it says the following:
Process: Python [2439]
Path:
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 2.7.2.5 (2.7.2.5.r64662-trunk)
Code Type: X86-64 (Native)
Parent Process: bash [2362]
Responsible: Terminal [2037]
User ID: 501
Date/Time: 2013-08-17 10:42:08.350 +0800
OS Version: Mac OS X 10.9 (13A497d)
Report Version: 11
Anonymous UUID: 73050B1F-EF33-CB1D-23C8-E2F4C44E6C4A
Sleep/Wake UUID: 4D08D546-B66F-4FAF-8715-7FEFB2993315
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Regions Near 0:
-->
__TEXT 0000000100000000-0000000100001000 [ 4K]
r-x/rwx SM=COW
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 readline.so 0x00000001004b1d97 call_readline + 647
1 org.activestate.ActivePython27 0x0000000100008412 PyOS_Readline + 274
2 org.activestate.ActivePython27 0x0000000100009c68 tok_nextc + 104
3 org.activestate.ActivePython27 0x000000010000a49a PyTokenizer_Get + 154
4 org.activestate.ActivePython27 0x00000001000051ba parsetok + 218
5 org.activestate.ActivePython27 0x00000001000ebb62
PyParser_ASTFromFile + 146
6 org.activestate.ActivePython27 0x00000001000ecdc3
PyRun_InteractiveOneFlags + 243
7 org.activestate.ActivePython27 0x00000001000ed0ae
PyRun_InteractiveLoopFlags + 78
8 org.activestate.ActivePython27 0x00000001000ed891
PyRun_AnyFileExFlags + 161
9 org.activestate.ActivePython27 0x00000001001041dc Py_Main + 2940
10 org.activestate.ActivePython27.app 0x0000000100000ed4 0x100000000 + 3796
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x0000000100373df0 rcx:
0x0000000100300000 rdx: 0x0000000000002800
rdi: 0x0000000000000000 rsi: 0x00000001004b2054 rbp:
0x00007fff5fbff420 rsp: 0x00007fff5fbff350
r8: 0x0000000100300000 r9: 0x000000000000021c r10:
0x0000000020080003 r11: 0x0000000000000001
r12: 0x0000000000000001 r13: 0x000000000000000c r14:
0x00007fff5fbff3e0 r15: 0x00007fff5fbff360
rip: 0x00000001004b1d97 rfl: 0x0000000000010206 cr2: 0x0000000000000000
Logical CPU: 4
Error Code: 0x00000004
Trap Number: 14
Binary Images:
0x100000000 - 0x100000fff
+org.activestate.ActivePython27.app (2.7.2.5 -
2.7.2.5.r64662-trunk) <4140045F-2FA3-FAAE-03E9-CBD7351FDD7B>
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
0x100003000 - 0x100171fef +org.activestate.ActivePython27
(2.7.2.5 - 2.7.2.5.r64662-trunk)
<1CA2CB97-0559-3E7E-56DC-00FF6DAE2CE8>
/Library/Frameworks/Python.framework/Versions/2.7/Python
0x1004b0000 - 0x1004b2fff +readline.so (???)
<A64220B5-DE2F-19FB-AB86-74835DACF68F>
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so
0x1004b9000 - 0x1004d7ffb libedit.2.dylib (39)
<24343EDB-E64F-34DC-8632-68C9E44E0FF7> /usr/lib/libedit.2.dylib
0x7fff697bd000 - 0x7fff697f04a7 dyld (237)
<BB7160C2-117E-3369-87F0-866ED454490E> /usr/lib/dyld
0x7fff8b417000 - 0x7fff8b418fff libunc.dylib (28)
<53C7CED6-55F5-3121-B00E-4339C29297C8> /usr/lib/system/libunc.dylib
0x7fff8c8fb000 - 0x7fff8c90cff7 libz.1.dylib (53)
<372E2641-66CA-3B13-8BE6-3A4335F861A6> /usr/lib/libz.1.dylib
0x7fff8d5b5000 - 0x7fff8d5bafff libmacho.dylib (845)
<0038681B-CEC4-348A-A7B8-4236C701F2F8> /usr/lib/system/libmacho.dylib
0x7fff8d5bb000 - 0x7fff8d644fe7 libsystem_c.dylib (997)
<5BAB0B09-A39E-39B9-9552-48B540B3ABD0>
/usr/lib/system/libsystem_c.dylib
0x7fff8d724000 - 0x7fff8d776fff libc++.1.dylib (118)
<5FF54631-AC11-3AD8-B42D-04FAC953CCED> /usr/lib/libc++.1.dylib
0x7fff8d807000 - 0x7fff8d829fff libxpc.dylib (300.1.4)
<4F832032-9709-3E80-91C4-71914C67A32B> /usr/lib/system/libxpc.dylib
0x7fff8ddad000 - 0x7fff8ddb4ff3 libcopyfile.dylib (103)
<54DD5730-3F05-3F18-B55C-24EA9546286F>
/usr/lib/system/libcopyfile.dylib
0x7fff8efcf000 - 0x7fff8f011ff7 libauto.dylib (185.4)
<379FBDA3-DB2A-35A3-A637-3893C0F0E52F> /usr/lib/libauto.dylib
0x7fff8f077000 - 0x7fff8f07effb liblaunch.dylib (842.1.1)
<7055DF9E-52CE-3746-96EB-3718DDBF0BD0> /usr/lib/system/liblaunch.dylib
0x7fff8f0a0000 - 0x7fff8f0c7ff3 libsystem_info.dylib (449)
<B5F10962-3DA2-3557-A0B1-369BB80EA6A5>
/usr/lib/system/libsystem_info.dylib
0x7fff8f19c000 - 0x7fff8f1a6fff libcommonCrypto.dylib (60049)
<FC0D70F5-E485-32E6-BFC2-1E072047282B>
/usr/lib/system/libcommonCrypto.dylib
0x7fff8f1a7000 - 0x7fff8f1c1fff libdispatch.dylib (339.1.2)
<A9C37B4E-B908-3212-BF59-CE336EC30E78>
/usr/lib/system/libdispatch.dylib
0x7fff8f629000 - 0x7fff8f677fff libcorecrypto.dylib (161)
<56048D2C-3668-3E15-AF02-5C5A377320F6>
/usr/lib/system/libcorecrypto.dylib
0x7fff8fade000 - 0x7fff8fb0efff libncurses.5.4.dylib (42)
<DC54026B-27FB-3E1E-8015-0484C92D4970> /usr/lib/libncurses.5.4.dylib
0x7fff90f35000 - 0x7fff90f3cfff libcompiler_rt.dylib (35)
<A0A9D62C-E1A5-39A0-A38E-B0B38762002D>
/usr/lib/system/libcompiler_rt.dylib
0x7fff9132b000 - 0x7fff9132bff7 libkeymgr.dylib (28)
<AB6DE146-DDC4-397B-9182-ECE54FCDF5D7> /usr/lib/system/libkeymgr.dylib
0x7fff91a03000 - 0x7fff91a04ff7 libsystem_blocks.dylib (63)
<7836104E-39B9-31B6-A0C7-C02ACD401ADE>
/usr/lib/system/libsystem_blocks.dylib
0x7fff9289b000 - 0x7fff928a4ff3 libsystem_notify.dylib (121)
<D34E9B17-297F-3C3F-BD16-69D1D9495B79>
/usr/lib/system/libsystem_notify.dylib
0x7fff928a5000 - 0x7fff928a7ff3 libsystem_configuration.dylib
(596.1) <1E0FDEA3-8822-3E80-AA0D-57D0F4E30E2E>
/usr/lib/system/libsystem_configuration.dylib
0x7fff92ced000 - 0x7fff92d16ff7 libc++abi.dylib (43)
<DAF66B4A-AFBE-31AA-9CA3-97A827BC8843> /usr/lib/libc++abi.dylib
0x7fff92fca000 - 0x7fff93177f8f libobjc.A.dylib (551)
<853FA2C9-7BF1-3962-896E-6367F99FD358> /usr/lib/libobjc.A.dylib
0x7fff9322a000 - 0x7fff9322bff7 libDiagnosticMessagesClient.dylib
(100) <B28C426E-E826-3EC3-80AD-E69F2EABE46B>
/usr/lib/libDiagnosticMessagesClient.dylib
0x7fff93376000 - 0x7fff93391ff7 libsystem_kernel.dylib
(2422.1.26.0.1) <5F99677C-C760-3877-AFF7-F60B5ECE365E>
/usr/lib/system/libsystem_kernel.dylib
0x7fff93440000 - 0x7fff93441ffb libremovefile.dylib (33)
<D7EF6E8B-95D8-3D8E-918C-2D3F51D00060>
/usr/lib/system/libremovefile.dylib
0x7fff93825000 - 0x7fff93826ff3 libSystem.B.dylib (1197)
<7589D08E-9338-3E28-AA74-9734F0D51CE0> /usr/lib/libSystem.B.dylib
0x7fff93827000 - 0x7fff9382aff7 libdyld.dylib (237)
<EA2A0414-849F-3976-BA4E-A93D3206ECE5> /usr/lib/system/libdyld.dylib
0x7fff9503d000 - 0x7fff95044ff7 libsystem_pthread.dylib (53)
<2160EC74-26FC-32CE-8161-B1A72D2B09B0>
/usr/lib/system/libsystem_pthread.dylib
0x7fff954f3000 - 0x7fff9550dfff libsystem_malloc.dylib (23.1.1)
<FBCF2C62-AA8D-322E-859E-B5D90C610A3F>
/usr/lib/system/libsystem_malloc.dylib
0x7fff9574b000 - 0x7fff9574cff7 libsystem_sandbox.dylib (278.1)
<F723F1D9-5561-344A-A6F0-B1373D355DBA>
/usr/lib/system/libsystem_sandbox.dylib
0x7fff95f2f000 - 0x7fff96112ff7 com.apple.CoreFoundation (6.9 -
842) <DC8875C4-DC2C-3ADC-B88B-D66722953255>
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x7fff96146000 - 0x7fff96149fff libsystem_stats.dylib
(93.1.8.1.1) <CAC30E07-CE62-3536-8CD4-1A3CE44DD973>
/usr/lib/system/libsystem_stats.dylib
0x7fff962b4000 - 0x7fff962dbff7 libsystem_network.dylib (241.3)
<D518703F-4C71-3CC5-99EF-A15C8F41A834>
/usr/lib/system/libsystem_network.dylib
0x7fff96305000 - 0x7fff96334fd2 libsystem_m.dylib (3047.15)
<8A6B4EC2-BB25-342B-B3FE-9585175225B8>
/usr/lib/system/libsystem_m.dylib
0x7fff96339000 - 0x7fff9633dff7 libcache.dylib (61)
<E9CD6B70-0553-3808-87DA-D16A1A6AC3FB> /usr/lib/system/libcache.dylib
0x7fff96607000 - 0x7fff96618fff libsystem_asl.dylib (217)
<F8795719-7E14-3FB2-8F4D-FF814AFFB7F7>
/usr/lib/system/libsystem_asl.dylib
0x7fff96d3d000 - 0x7fff96d3fff7 libquarantine.dylib (69)
<1776AABC-F1D7-3CB0-B698-B0C70D4E535B>
/usr/lib/system/libquarantine.dylib
0x7fff96dce000 - 0x7fff96dd4fef libsystem_platform.dylib (24)
<5D8FE8C3-2A62-3705-AB7D-FBD7C284AFBD>
/usr/lib/system/libsystem_platform.dylib
0x7fff97bad000 - 0x7fff97d65ffb libicucore.A.dylib (511.16)
<D7EFBDCD-B495-3A4C-990F-AC9AF1E210DB> /usr/lib/libicucore.A.dylib
0x7fff97f87000 - 0x7fff97f8ffff libsystem_dnssd.dylib (522.1.3)
<29695A12-75FC-36EE-97AC-179F6E9DA419>
/usr/lib/system/libsystem_dnssd.dylib
0x7fff986ee000 - 0x7fff986f3ff7 libunwind.dylib (35.3)
<838CE69D-44F1-305C-8FA5-5E439D217F78> /usr/lib/system/libunwind.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 16860
thread_create: 0
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=74.6M resident=34.8M(47%)
swapped_out_or_unallocated=39.9M(53%)
Writable regions: Total=27.7M written=1912K(7%) resident=2496K(9%)
swapped_out=0K(0%) unallocated=25.2M(91%)
REGION TYPE VIRTUAL
=========== =======
Kernel Alloc Once 4K
MALLOC 19.4M
MALLOC (admin) 16K
STACK GUARD 56.0M
Stack 8192K
VM_ALLOCATE 8K
__DATA 1456K
__LINKEDIT 64.2M
__TEXT 10.4M
__UNICODE 544K
shared memory 4K
=========== =======
TOTAL 160.0M
Model: MacBookPro8,2, BootROM MBP81.0047.B27, 4 processors, Intel Core i7,
2.2 GHz, 8 GB, SMC 1.69f4
Graphics: Intel HD Graphics 3000, Intel HD Graphics 3000, Built-In, 512 MB
Graphics: AMD Radeon HD 6750M, AMD Radeon HD 6750M, PCIe, 512 MB
Memory Module: BANK 0/DIMM0, 4 GB, DDR3, 1333 MHz, 0x80CE,
0x4D34373142353237334448302D4348392020
Memory Module: BANK 1/DIMM0, 4 GB, DDR3, 1333 MHz, 0x80CE,
0x4D34373142353237334448302D4348392020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xD6),
Broadcom BCM43xx 1.0 (6.30.223.106.1)
Bluetooth: Version 4.2.0b11 12562, 3 services, 21 devices, 3 incoming
serial ports
Network Service: Ethernet, Ethernet, en0
Network Service: Wi-Fi, AirPort, en1
Serial ATA Device: Hitachi HTS547550A9E384, 500.11 GB
Serial ATA Device: MATSHITADVD-R UJ-8A8
USB Device: Hub
USB Device: iPod
USB Device: BRCM2070 Hub
USB Device: Bluetooth USB Host Controller
USB Device: Apple Internal Keyboard / Trackpad
USB Device: FaceTime HD Camera (Built-in)
USB Device: Hub
USB Device: IR Receiver
Thunderbolt Bus: MacBook Pro, Apple Inc., 22.1, 0x100
I am able to use other tools like scrapy runspider xxx.py with no errors.
I installed django and i am able to run import django. However, when I run
print(django.get_version()), it crashes with Segmentation fault: 11
Then I expand the 'report to apple' window prompt. it says the following:
Process: Python [2439]
Path:
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 2.7.2.5 (2.7.2.5.r64662-trunk)
Code Type: X86-64 (Native)
Parent Process: bash [2362]
Responsible: Terminal [2037]
User ID: 501
Date/Time: 2013-08-17 10:42:08.350 +0800
OS Version: Mac OS X 10.9 (13A497d)
Report Version: 11
Anonymous UUID: 73050B1F-EF33-CB1D-23C8-E2F4C44E6C4A
Sleep/Wake UUID: 4D08D546-B66F-4FAF-8715-7FEFB2993315
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Regions Near 0:
-->
__TEXT 0000000100000000-0000000100001000 [ 4K]
r-x/rwx SM=COW
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 readline.so 0x00000001004b1d97 call_readline + 647
1 org.activestate.ActivePython27 0x0000000100008412 PyOS_Readline + 274
2 org.activestate.ActivePython27 0x0000000100009c68 tok_nextc + 104
3 org.activestate.ActivePython27 0x000000010000a49a PyTokenizer_Get + 154
4 org.activestate.ActivePython27 0x00000001000051ba parsetok + 218
5 org.activestate.ActivePython27 0x00000001000ebb62
PyParser_ASTFromFile + 146
6 org.activestate.ActivePython27 0x00000001000ecdc3
PyRun_InteractiveOneFlags + 243
7 org.activestate.ActivePython27 0x00000001000ed0ae
PyRun_InteractiveLoopFlags + 78
8 org.activestate.ActivePython27 0x00000001000ed891
PyRun_AnyFileExFlags + 161
9 org.activestate.ActivePython27 0x00000001001041dc Py_Main + 2940
10 org.activestate.ActivePython27.app 0x0000000100000ed4 0x100000000 + 3796
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x0000000100373df0 rcx:
0x0000000100300000 rdx: 0x0000000000002800
rdi: 0x0000000000000000 rsi: 0x00000001004b2054 rbp:
0x00007fff5fbff420 rsp: 0x00007fff5fbff350
r8: 0x0000000100300000 r9: 0x000000000000021c r10:
0x0000000020080003 r11: 0x0000000000000001
r12: 0x0000000000000001 r13: 0x000000000000000c r14:
0x00007fff5fbff3e0 r15: 0x00007fff5fbff360
rip: 0x00000001004b1d97 rfl: 0x0000000000010206 cr2: 0x0000000000000000
Logical CPU: 4
Error Code: 0x00000004
Trap Number: 14
Binary Images:
0x100000000 - 0x100000fff
+org.activestate.ActivePython27.app (2.7.2.5 -
2.7.2.5.r64662-trunk) <4140045F-2FA3-FAAE-03E9-CBD7351FDD7B>
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
0x100003000 - 0x100171fef +org.activestate.ActivePython27
(2.7.2.5 - 2.7.2.5.r64662-trunk)
<1CA2CB97-0559-3E7E-56DC-00FF6DAE2CE8>
/Library/Frameworks/Python.framework/Versions/2.7/Python
0x1004b0000 - 0x1004b2fff +readline.so (???)
<A64220B5-DE2F-19FB-AB86-74835DACF68F>
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so
0x1004b9000 - 0x1004d7ffb libedit.2.dylib (39)
<24343EDB-E64F-34DC-8632-68C9E44E0FF7> /usr/lib/libedit.2.dylib
0x7fff697bd000 - 0x7fff697f04a7 dyld (237)
<BB7160C2-117E-3369-87F0-866ED454490E> /usr/lib/dyld
0x7fff8b417000 - 0x7fff8b418fff libunc.dylib (28)
<53C7CED6-55F5-3121-B00E-4339C29297C8> /usr/lib/system/libunc.dylib
0x7fff8c8fb000 - 0x7fff8c90cff7 libz.1.dylib (53)
<372E2641-66CA-3B13-8BE6-3A4335F861A6> /usr/lib/libz.1.dylib
0x7fff8d5b5000 - 0x7fff8d5bafff libmacho.dylib (845)
<0038681B-CEC4-348A-A7B8-4236C701F2F8> /usr/lib/system/libmacho.dylib
0x7fff8d5bb000 - 0x7fff8d644fe7 libsystem_c.dylib (997)
<5BAB0B09-A39E-39B9-9552-48B540B3ABD0>
/usr/lib/system/libsystem_c.dylib
0x7fff8d724000 - 0x7fff8d776fff libc++.1.dylib (118)
<5FF54631-AC11-3AD8-B42D-04FAC953CCED> /usr/lib/libc++.1.dylib
0x7fff8d807000 - 0x7fff8d829fff libxpc.dylib (300.1.4)
<4F832032-9709-3E80-91C4-71914C67A32B> /usr/lib/system/libxpc.dylib
0x7fff8ddad000 - 0x7fff8ddb4ff3 libcopyfile.dylib (103)
<54DD5730-3F05-3F18-B55C-24EA9546286F>
/usr/lib/system/libcopyfile.dylib
0x7fff8efcf000 - 0x7fff8f011ff7 libauto.dylib (185.4)
<379FBDA3-DB2A-35A3-A637-3893C0F0E52F> /usr/lib/libauto.dylib
0x7fff8f077000 - 0x7fff8f07effb liblaunch.dylib (842.1.1)
<7055DF9E-52CE-3746-96EB-3718DDBF0BD0> /usr/lib/system/liblaunch.dylib
0x7fff8f0a0000 - 0x7fff8f0c7ff3 libsystem_info.dylib (449)
<B5F10962-3DA2-3557-A0B1-369BB80EA6A5>
/usr/lib/system/libsystem_info.dylib
0x7fff8f19c000 - 0x7fff8f1a6fff libcommonCrypto.dylib (60049)
<FC0D70F5-E485-32E6-BFC2-1E072047282B>
/usr/lib/system/libcommonCrypto.dylib
0x7fff8f1a7000 - 0x7fff8f1c1fff libdispatch.dylib (339.1.2)
<A9C37B4E-B908-3212-BF59-CE336EC30E78>
/usr/lib/system/libdispatch.dylib
0x7fff8f629000 - 0x7fff8f677fff libcorecrypto.dylib (161)
<56048D2C-3668-3E15-AF02-5C5A377320F6>
/usr/lib/system/libcorecrypto.dylib
0x7fff8fade000 - 0x7fff8fb0efff libncurses.5.4.dylib (42)
<DC54026B-27FB-3E1E-8015-0484C92D4970> /usr/lib/libncurses.5.4.dylib
0x7fff90f35000 - 0x7fff90f3cfff libcompiler_rt.dylib (35)
<A0A9D62C-E1A5-39A0-A38E-B0B38762002D>
/usr/lib/system/libcompiler_rt.dylib
0x7fff9132b000 - 0x7fff9132bff7 libkeymgr.dylib (28)
<AB6DE146-DDC4-397B-9182-ECE54FCDF5D7> /usr/lib/system/libkeymgr.dylib
0x7fff91a03000 - 0x7fff91a04ff7 libsystem_blocks.dylib (63)
<7836104E-39B9-31B6-A0C7-C02ACD401ADE>
/usr/lib/system/libsystem_blocks.dylib
0x7fff9289b000 - 0x7fff928a4ff3 libsystem_notify.dylib (121)
<D34E9B17-297F-3C3F-BD16-69D1D9495B79>
/usr/lib/system/libsystem_notify.dylib
0x7fff928a5000 - 0x7fff928a7ff3 libsystem_configuration.dylib
(596.1) <1E0FDEA3-8822-3E80-AA0D-57D0F4E30E2E>
/usr/lib/system/libsystem_configuration.dylib
0x7fff92ced000 - 0x7fff92d16ff7 libc++abi.dylib (43)
<DAF66B4A-AFBE-31AA-9CA3-97A827BC8843> /usr/lib/libc++abi.dylib
0x7fff92fca000 - 0x7fff93177f8f libobjc.A.dylib (551)
<853FA2C9-7BF1-3962-896E-6367F99FD358> /usr/lib/libobjc.A.dylib
0x7fff9322a000 - 0x7fff9322bff7 libDiagnosticMessagesClient.dylib
(100) <B28C426E-E826-3EC3-80AD-E69F2EABE46B>
/usr/lib/libDiagnosticMessagesClient.dylib
0x7fff93376000 - 0x7fff93391ff7 libsystem_kernel.dylib
(2422.1.26.0.1) <5F99677C-C760-3877-AFF7-F60B5ECE365E>
/usr/lib/system/libsystem_kernel.dylib
0x7fff93440000 - 0x7fff93441ffb libremovefile.dylib (33)
<D7EF6E8B-95D8-3D8E-918C-2D3F51D00060>
/usr/lib/system/libremovefile.dylib
0x7fff93825000 - 0x7fff93826ff3 libSystem.B.dylib (1197)
<7589D08E-9338-3E28-AA74-9734F0D51CE0> /usr/lib/libSystem.B.dylib
0x7fff93827000 - 0x7fff9382aff7 libdyld.dylib (237)
<EA2A0414-849F-3976-BA4E-A93D3206ECE5> /usr/lib/system/libdyld.dylib
0x7fff9503d000 - 0x7fff95044ff7 libsystem_pthread.dylib (53)
<2160EC74-26FC-32CE-8161-B1A72D2B09B0>
/usr/lib/system/libsystem_pthread.dylib
0x7fff954f3000 - 0x7fff9550dfff libsystem_malloc.dylib (23.1.1)
<FBCF2C62-AA8D-322E-859E-B5D90C610A3F>
/usr/lib/system/libsystem_malloc.dylib
0x7fff9574b000 - 0x7fff9574cff7 libsystem_sandbox.dylib (278.1)
<F723F1D9-5561-344A-A6F0-B1373D355DBA>
/usr/lib/system/libsystem_sandbox.dylib
0x7fff95f2f000 - 0x7fff96112ff7 com.apple.CoreFoundation (6.9 -
842) <DC8875C4-DC2C-3ADC-B88B-D66722953255>
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x7fff96146000 - 0x7fff96149fff libsystem_stats.dylib
(93.1.8.1.1) <CAC30E07-CE62-3536-8CD4-1A3CE44DD973>
/usr/lib/system/libsystem_stats.dylib
0x7fff962b4000 - 0x7fff962dbff7 libsystem_network.dylib (241.3)
<D518703F-4C71-3CC5-99EF-A15C8F41A834>
/usr/lib/system/libsystem_network.dylib
0x7fff96305000 - 0x7fff96334fd2 libsystem_m.dylib (3047.15)
<8A6B4EC2-BB25-342B-B3FE-9585175225B8>
/usr/lib/system/libsystem_m.dylib
0x7fff96339000 - 0x7fff9633dff7 libcache.dylib (61)
<E9CD6B70-0553-3808-87DA-D16A1A6AC3FB> /usr/lib/system/libcache.dylib
0x7fff96607000 - 0x7fff96618fff libsystem_asl.dylib (217)
<F8795719-7E14-3FB2-8F4D-FF814AFFB7F7>
/usr/lib/system/libsystem_asl.dylib
0x7fff96d3d000 - 0x7fff96d3fff7 libquarantine.dylib (69)
<1776AABC-F1D7-3CB0-B698-B0C70D4E535B>
/usr/lib/system/libquarantine.dylib
0x7fff96dce000 - 0x7fff96dd4fef libsystem_platform.dylib (24)
<5D8FE8C3-2A62-3705-AB7D-FBD7C284AFBD>
/usr/lib/system/libsystem_platform.dylib
0x7fff97bad000 - 0x7fff97d65ffb libicucore.A.dylib (511.16)
<D7EFBDCD-B495-3A4C-990F-AC9AF1E210DB> /usr/lib/libicucore.A.dylib
0x7fff97f87000 - 0x7fff97f8ffff libsystem_dnssd.dylib (522.1.3)
<29695A12-75FC-36EE-97AC-179F6E9DA419>
/usr/lib/system/libsystem_dnssd.dylib
0x7fff986ee000 - 0x7fff986f3ff7 libunwind.dylib (35.3)
<838CE69D-44F1-305C-8FA5-5E439D217F78> /usr/lib/system/libunwind.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 16860
thread_create: 0
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=74.6M resident=34.8M(47%)
swapped_out_or_unallocated=39.9M(53%)
Writable regions: Total=27.7M written=1912K(7%) resident=2496K(9%)
swapped_out=0K(0%) unallocated=25.2M(91%)
REGION TYPE VIRTUAL
=========== =======
Kernel Alloc Once 4K
MALLOC 19.4M
MALLOC (admin) 16K
STACK GUARD 56.0M
Stack 8192K
VM_ALLOCATE 8K
__DATA 1456K
__LINKEDIT 64.2M
__TEXT 10.4M
__UNICODE 544K
shared memory 4K
=========== =======
TOTAL 160.0M
Model: MacBookPro8,2, BootROM MBP81.0047.B27, 4 processors, Intel Core i7,
2.2 GHz, 8 GB, SMC 1.69f4
Graphics: Intel HD Graphics 3000, Intel HD Graphics 3000, Built-In, 512 MB
Graphics: AMD Radeon HD 6750M, AMD Radeon HD 6750M, PCIe, 512 MB
Memory Module: BANK 0/DIMM0, 4 GB, DDR3, 1333 MHz, 0x80CE,
0x4D34373142353237334448302D4348392020
Memory Module: BANK 1/DIMM0, 4 GB, DDR3, 1333 MHz, 0x80CE,
0x4D34373142353237334448302D4348392020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xD6),
Broadcom BCM43xx 1.0 (6.30.223.106.1)
Bluetooth: Version 4.2.0b11 12562, 3 services, 21 devices, 3 incoming
serial ports
Network Service: Ethernet, Ethernet, en0
Network Service: Wi-Fi, AirPort, en1
Serial ATA Device: Hitachi HTS547550A9E384, 500.11 GB
Serial ATA Device: MATSHITADVD-R UJ-8A8
USB Device: Hub
USB Device: iPod
USB Device: BRCM2070 Hub
USB Device: Bluetooth USB Host Controller
USB Device: Apple Internal Keyboard / Trackpad
USB Device: FaceTime HD Camera (Built-in)
USB Device: Hub
USB Device: IR Receiver
Thunderbolt Bus: MacBook Pro, Apple Inc., 22.1, 0x100
I am able to use other tools like scrapy runspider xxx.py with no errors.
Subscribe to:
Comments (Atom)