Firebase AngularFire nested collections
I have data of the form
{
"events" : {
"-J2MoqWZnkcRCSugBfj3" : {
"title" : "Some other event",
"ratings" : {
"-J2N4QYSk4y2BYznkGvk" : {
"value" : 0
},
"-J2N3rfUPlPNP45RUZYx" : {
"value" : 0
}
}
},
"-J2MpSSN8oldDqd-0jrr" : {
"title" : "New event"
}
}
}
The events collection has a nested collection called ratings. I wish to
manage both the collections through angularFireCollection, but I am not
sure how do I get around to do it.
My Angular controller and template are defined as:
APP.controller('EventsCtrl', function ($scope, angularFireCollection) {
$scope.events = angularFireCollection(<reference to events collection>);
});
<ul class="list-group">
<li class="list-group-item" ng-controller="IndividualEventCtrl"
ng-repeat="event in events">
<div><strong class="lead">{{event.title}}</strong></div>
<div ng-include="event.template"></div>
<rating value="rate" max="max" readonly="isReadonly"></rating>
</li>
</ul>
Controller for each event:
APP.controller('IndividualEventCtrl', function ($scope, FirebaseService,
angularFireCollection) {
$scope.max = 5;
$scope.rate = 0;
$scope.isReadonly = false;
var ratingsRef =
FirebaseService.events().child($scope.event.$id).child("ratings");
$scope.rating = ratingsRef.push({value:0});
});
The last two lines where I create the ratingsRef and add a new rating to
the collection cause my controller to go in some sort of an infinite loop.
I'd really like to know what is the best way to manage nested collections
so that I can add/update the elements in those collections.
Thanks.
Saturday, 31 August 2013
rails - can I 'rake spec' a directory, e.g. models
rails - can I 'rake spec' a directory, e.g. models
I can rake spec and all specs run.
However trying to run specs for one directory, as in
rake spec/models/ or rake spec/models/*.rb
does not provide any output or errors.
One option is that I can do
rspec spec/models/*.rb
or
rspec spec/models/
but I was wondering if I could stay within Rake.
I can rake spec and all specs run.
However trying to run specs for one directory, as in
rake spec/models/ or rake spec/models/*.rb
does not provide any output or errors.
One option is that I can do
rspec spec/models/*.rb
or
rspec spec/models/
but I was wondering if I could stay within Rake.
imagestring align to the right
imagestring align to the right
I want to align the watermark of an image to the right side.
This is what i have so far but its aligned to the left...
// Add Watermark featuring Website Name
$home_url = home_url();
$search = array('http://','https://');
$site_name = str_ireplace($search, '', $home_url);
$watermark = imagecreatetruecolor($width, $height+15);
// Determine color of watermark's background
if (is_array($Meme_Generator_Data) &&
array_key_exists('watermark_background',$Meme_Generator_Data)
&& strlen($Meme_Generator_Data['watermark_background']) ==
7) {
$wm_bg =
$this->convert_color(substr($Meme_Generator_Data['watermark_background'],
1));
$bg_color = imagecolorallocate($watermark, $wm_bg[0],
$wm_bg[1], $wm_bg[2]);
imagefill($watermark, 0, 0, $bg_color);
}
// Determine color of watermark's text
if (is_array($Meme_Generator_Data) &&
array_key_exists('watermark_text',$Meme_Generator_Data) &&
strlen($Meme_Generator_Data['watermark_text']) == 7) {
$wm_text =
$this->convert_color(substr($Meme_Generator_Data['watermark_text'],
1));
$text_color = imagecolorallocate($watermark,
$wm_text[0], $wm_text[1], $wm_text[2]);
} else {
$text_color = imagecolorallocate($watermark, 255, 255,
255);
}
imagestring($watermark, 5, 5, $height, $site_name,
$text_color);
imagecopy($watermark, $img, 0, 0, 0, 0, $width, $height);
$img = $watermark;
I want to align the watermark of an image to the right side.
This is what i have so far but its aligned to the left...
// Add Watermark featuring Website Name
$home_url = home_url();
$search = array('http://','https://');
$site_name = str_ireplace($search, '', $home_url);
$watermark = imagecreatetruecolor($width, $height+15);
// Determine color of watermark's background
if (is_array($Meme_Generator_Data) &&
array_key_exists('watermark_background',$Meme_Generator_Data)
&& strlen($Meme_Generator_Data['watermark_background']) ==
7) {
$wm_bg =
$this->convert_color(substr($Meme_Generator_Data['watermark_background'],
1));
$bg_color = imagecolorallocate($watermark, $wm_bg[0],
$wm_bg[1], $wm_bg[2]);
imagefill($watermark, 0, 0, $bg_color);
}
// Determine color of watermark's text
if (is_array($Meme_Generator_Data) &&
array_key_exists('watermark_text',$Meme_Generator_Data) &&
strlen($Meme_Generator_Data['watermark_text']) == 7) {
$wm_text =
$this->convert_color(substr($Meme_Generator_Data['watermark_text'],
1));
$text_color = imagecolorallocate($watermark,
$wm_text[0], $wm_text[1], $wm_text[2]);
} else {
$text_color = imagecolorallocate($watermark, 255, 255,
255);
}
imagestring($watermark, 5, 5, $height, $site_name,
$text_color);
imagecopy($watermark, $img, 0, 0, 0, 0, $width, $height);
$img = $watermark;
Multiple headless browsers in Windows environment?
Multiple headless browsers in Windows environment?
Is there a way to use multiple headless browsers (simultaneously) in
Windows to do web automation testing?
Preferably I need to automate a browser with full javascript support so a
modern Qt backend, with webkit implemented, would be ideal.
Spynner and Ghost.py looked promising but only support an X11 environment
for "more than 1 browser" setups.
Any ideas?
Is there a way to use multiple headless browsers (simultaneously) in
Windows to do web automation testing?
Preferably I need to automate a browser with full javascript support so a
modern Qt backend, with webkit implemented, would be ideal.
Spynner and Ghost.py looked promising but only support an X11 environment
for "more than 1 browser" setups.
Any ideas?
Hibernate Inheritance SingleTable Subclass Joins
Hibernate Inheritance SingleTable Subclass Joins
Ive been working with Hibernate since a couple of weeks. Well its a very
helpful tool but i cannot resolve following task:
Table:
Create Table `Product`
(
`product_id` INT(10) PRIMARY KEY,
`package_id` INT(10) NULL,
`product_type` VARCHAR(50) NOT NULL,
`title` VARCHAR(255) NOT NULL,
`desc` VARCHAR(255) NULL,
`price` REAL(10) NOT NULL,
...
);
in Java i have 3 Classes
@Entity
@Table(name = "Product")
@DiscriminatorColumn(name = "product_type")
public abstract class Product {
...
}
there are two types of instances, where an "Item" could but may not always
deserve to a "Bundle". "Bundles" have at least one "Item"
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue(value = "Item")
public class Item extends Product {
Bundle bundle;
....
@ManyToOne (fetch=FetchType.LAZY, targetEntity=Bundle.class)
@JoinColumn (name="album_id")
public Bundle getBundle() {...}
public void setBundle(Bundle bundle) {...}
....
}
and:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue(value = "Bundle")
public class Bundle extends Product {
Set<Item> items;
....
@OneToMany (mappedBy="album", targetEntity=MusicSong.class)
@OrderBy ("track")
public Set<Item> getItems() {...}
public void setItems(Set<Item> items) {...}
....
}
At Runtime its not possible to call any data, error: Expected type:
org.blah.Bundle, actual value: org.blah.Item
does anyone have an idea or hint. isearching google up&down but i cannot
find this specific issue.
Ive been working with Hibernate since a couple of weeks. Well its a very
helpful tool but i cannot resolve following task:
Table:
Create Table `Product`
(
`product_id` INT(10) PRIMARY KEY,
`package_id` INT(10) NULL,
`product_type` VARCHAR(50) NOT NULL,
`title` VARCHAR(255) NOT NULL,
`desc` VARCHAR(255) NULL,
`price` REAL(10) NOT NULL,
...
);
in Java i have 3 Classes
@Entity
@Table(name = "Product")
@DiscriminatorColumn(name = "product_type")
public abstract class Product {
...
}
there are two types of instances, where an "Item" could but may not always
deserve to a "Bundle". "Bundles" have at least one "Item"
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue(value = "Item")
public class Item extends Product {
Bundle bundle;
....
@ManyToOne (fetch=FetchType.LAZY, targetEntity=Bundle.class)
@JoinColumn (name="album_id")
public Bundle getBundle() {...}
public void setBundle(Bundle bundle) {...}
....
}
and:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue(value = "Bundle")
public class Bundle extends Product {
Set<Item> items;
....
@OneToMany (mappedBy="album", targetEntity=MusicSong.class)
@OrderBy ("track")
public Set<Item> getItems() {...}
public void setItems(Set<Item> items) {...}
....
}
At Runtime its not possible to call any data, error: Expected type:
org.blah.Bundle, actual value: org.blah.Item
does anyone have an idea or hint. isearching google up&down but i cannot
find this specific issue.
How can one set elements on top of the Applicationbar (or have the layout be aware of it)?
How can one set elements on top of the Applicationbar (or have the layout
be aware of it)?
To clarify, I want to have my ApplicationBar resting on top of my
LayoutRoot grid. The desired effect would be like this:
<StackPanel>
<Grid x:Name="LayoutRoot" Background="Transparent">
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
<StackPanel />
Of course, the above code doesn't work because the must be in the root tag
of the page, but I do wish it did.
Does anyone know a way that I can create this effect? It doesn't have to
be a perfect solution, just something that replicates it and will work on
any resolution.
Thank you for reading and for your help
be aware of it)?
To clarify, I want to have my ApplicationBar resting on top of my
LayoutRoot grid. The desired effect would be like this:
<StackPanel>
<Grid x:Name="LayoutRoot" Background="Transparent">
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
<StackPanel />
Of course, the above code doesn't work because the must be in the root tag
of the page, but I do wish it did.
Does anyone know a way that I can create this effect? It doesn't have to
be a perfect solution, just something that replicates it and will work on
any resolution.
Thank you for reading and for your help
Dynamically switch content in website based on user language selection
Dynamically switch content in website based on user language selection
I am designing a small, simple website that will need two languages. I
want to keep things simple. I would like to use placeholders/variables in
the code that will have user-visible text. Then, allow the user to the
select the language of his choice (using a simple link), and make the
entire site's text switch over to that language. I would prefer something
similar to a language file, in which the values in the code are simply
switched when the user selects his language. Below is a small example to
illustrate what I am referring to.
<div class='title'>
[$siteTitleGoesHere]
</div>
I hope that makes sense. I am familiar enough with php and javascript that
I might be able to use them to do this, if given direction. Thanks for any
help.
I am designing a small, simple website that will need two languages. I
want to keep things simple. I would like to use placeholders/variables in
the code that will have user-visible text. Then, allow the user to the
select the language of his choice (using a simple link), and make the
entire site's text switch over to that language. I would prefer something
similar to a language file, in which the values in the code are simply
switched when the user selects his language. Below is a small example to
illustrate what I am referring to.
<div class='title'>
[$siteTitleGoesHere]
</div>
I hope that makes sense. I am familiar enough with php and javascript that
I might be able to use them to do this, if given direction. Thanks for any
help.
How deal with 3rd party login information on a static website hosted with nginx?
How deal with 3rd party login information on a static website hosted with
nginx?
I do have a static website which has public access but I do want to
implement a smart page that can take advantage of getting the logged
username from another application from the same domain.
Users can login to /auth/ and when logged in the resulted page returns the
username as part of the HTTP response-headers.
I want to be able to detect if the user is logged in and to change the
current page a little bit with jQuery.
I guess that this would require me to have a json request each time so I
can check if the user is logged-in or not and to to my logic after.
Is there any other better option? … preferably one that would not make two
requests to the server for each login-enabled page.
nginx?
I do have a static website which has public access but I do want to
implement a smart page that can take advantage of getting the logged
username from another application from the same domain.
Users can login to /auth/ and when logged in the resulted page returns the
username as part of the HTTP response-headers.
I want to be able to detect if the user is logged in and to change the
current page a little bit with jQuery.
I guess that this would require me to have a json request each time so I
can check if the user is logged-in or not and to to my logic after.
Is there any other better option? … preferably one that would not make two
requests to the server for each login-enabled page.
Friday, 30 August 2013
C++/CLI marshalingl/aliasing of memory and struct intropbability
C++/CLI marshalingl/aliasing of memory and struct intropbability
I've wrapped Christophe Devine's FIPS-197 compliant AES implementation in
a managed C++/CLI class. I'm running into trouble after
encrypting/decrypting anywhere from 20 to 52 blocks of 4096 bytes each.
I've been able to narrow the issue down to this:
If I declare a native pointer to the aes_context struct and just new up
the aes_context in the constructor, like so
Aes::Aes()
: m_Context(new aes_context)
{
}
Then the code will run fine.
But when I attempt to declare the aes_context as array<System::Byte>^ and
then in the constructor do this
Aes::Aes()
: m_Context(gcnew array<System::Byte>(sizeof(aes_context)))
{
}
While it does compile and in theory should work, this now doesn't
pin_ptr<System::Byte> pinned_context = &m_Context[0];
auto context = (aes_context*)pinned_context;
aes_crypt_cbc(context, ...);
Effectively and in my limited experience, this should work just fine. The
only difference is that the memory was allocated by the GC and that I have
to pin the memory before I pass it to the AES library.
I was unable to reproduce this issue any other way and all tests that I
have run against other reference implementation doesn't reveal any issues
with implementation. I've even set up two exactly identical test cases,
one in C and one in C++/CLI (that uses the managed wrapper to call into
the AES library), the managed wrapper doesn't work when backed by a
managed byte array!?
Since the problem doesn't reveal itself after you've run through a fair
deal of data, I've been thinking it's a truncation or alignment issue, but
regardless of how much I overallocate I get the same result.
I'm using the Visual Studio 2012 C++ compiler.
Anyone know anything that might suggest why this is the case?
I've wrapped Christophe Devine's FIPS-197 compliant AES implementation in
a managed C++/CLI class. I'm running into trouble after
encrypting/decrypting anywhere from 20 to 52 blocks of 4096 bytes each.
I've been able to narrow the issue down to this:
If I declare a native pointer to the aes_context struct and just new up
the aes_context in the constructor, like so
Aes::Aes()
: m_Context(new aes_context)
{
}
Then the code will run fine.
But when I attempt to declare the aes_context as array<System::Byte>^ and
then in the constructor do this
Aes::Aes()
: m_Context(gcnew array<System::Byte>(sizeof(aes_context)))
{
}
While it does compile and in theory should work, this now doesn't
pin_ptr<System::Byte> pinned_context = &m_Context[0];
auto context = (aes_context*)pinned_context;
aes_crypt_cbc(context, ...);
Effectively and in my limited experience, this should work just fine. The
only difference is that the memory was allocated by the GC and that I have
to pin the memory before I pass it to the AES library.
I was unable to reproduce this issue any other way and all tests that I
have run against other reference implementation doesn't reveal any issues
with implementation. I've even set up two exactly identical test cases,
one in C and one in C++/CLI (that uses the managed wrapper to call into
the AES library), the managed wrapper doesn't work when backed by a
managed byte array!?
Since the problem doesn't reveal itself after you've run through a fair
deal of data, I've been thinking it's a truncation or alignment issue, but
regardless of how much I overallocate I get the same result.
I'm using the Visual Studio 2012 C++ compiler.
Anyone know anything that might suggest why this is the case?
Thursday, 29 August 2013
run button's click on page load
run button's click on page load
i have a input like this "
<input type='button' name='osx' value='Demo' class='osx demo'
runat="server" />
that when i click on this , it runs a jQuery plugin. now i want to call
this input's click event on my page load, in fact i want to run it's
plugin at page load, so i use this code :
<script>
$("document").ready(function () {
window.getElementById("osx").click();
});
</script>
but when i run my page , i get this error :
Line: 16 Error: Object doesn't support property or method 'getElementById'
can enyone help me ,please?
i have a input like this "
<input type='button' name='osx' value='Demo' class='osx demo'
runat="server" />
that when i click on this , it runs a jQuery plugin. now i want to call
this input's click event on my page load, in fact i want to run it's
plugin at page load, so i use this code :
<script>
$("document").ready(function () {
window.getElementById("osx").click();
});
</script>
but when i run my page , i get this error :
Line: 16 Error: Object doesn't support property or method 'getElementById'
can enyone help me ,please?
Wednesday, 28 August 2013
Difference between with-local-vars and with-bindings in Clojure
Difference between with-local-vars and with-bindings in Clojure
The documentation for Clojure with-local-vars and with-bindings doesn't
suffice for me to distinguish the two. Any hints?
The documentation for Clojure with-local-vars and with-bindings doesn't
suffice for me to distinguish the two. Any hints?
Getting LINQ query result into a list?
Getting LINQ query result into a list?
I'm converting old code to use LINQ. The old code looked like this:
// Get Courses
sqlQuery = @"SELECT Comment.Comment, Status.StatusId,
Comment.DiscussionBoardId, DiscussionBoard.CourseId, Comment.CommentID
FROM Status INNER JOIN Comment ON Status.StatusId =
Comment.StatusId INNER JOIN
DiscussionBoard ON Comment.DiscussionBoardId =
DiscussionBoard.DiscussionBoardId
WHERE (DiscussionBoard.CourseID = 'CourseID')";
var comments = new
List<Comment>(dataContext.ExecuteQuery<Comment>(sqlQuery));
I've converted the above SQL to LINQ:
var db = new CMSDataContext();
var query = from c in db.Comments
join s in db.Status on c.StatusId equals s.StatusId join d in
db.DiscussionBoards on c.DiscussionBoardId equals d.DiscussionBoardId
where d.CourseId == "CourseID" select new
{ d.ItemType, c.Comment1, s.Status1, c.DiscussionBoardId, d.CourseId,
c.CommentID };
The problem I've having, though, is with trying to get the results of the
query into the List. Can someone offer me some pointers?
Thanks!
I'm converting old code to use LINQ. The old code looked like this:
// Get Courses
sqlQuery = @"SELECT Comment.Comment, Status.StatusId,
Comment.DiscussionBoardId, DiscussionBoard.CourseId, Comment.CommentID
FROM Status INNER JOIN Comment ON Status.StatusId =
Comment.StatusId INNER JOIN
DiscussionBoard ON Comment.DiscussionBoardId =
DiscussionBoard.DiscussionBoardId
WHERE (DiscussionBoard.CourseID = 'CourseID')";
var comments = new
List<Comment>(dataContext.ExecuteQuery<Comment>(sqlQuery));
I've converted the above SQL to LINQ:
var db = new CMSDataContext();
var query = from c in db.Comments
join s in db.Status on c.StatusId equals s.StatusId join d in
db.DiscussionBoards on c.DiscussionBoardId equals d.DiscussionBoardId
where d.CourseId == "CourseID" select new
{ d.ItemType, c.Comment1, s.Status1, c.DiscussionBoardId, d.CourseId,
c.CommentID };
The problem I've having, though, is with trying to get the results of the
query into the List. Can someone offer me some pointers?
Thanks!
PHP get string value from Assoc array and convert it to string for comparison
PHP get string value from Assoc array and convert it to string for comparison
I am trying to create a piece of code which will dynamically set the
maximum values of a slider on my page by finding the max values returned
from my database using a PDO statement.
The problem I am having is that I cannot convert the value returned in my
assoc array to an integer value, what am I doing wrong?
Example of PDO statement
$maxHGPM = $connection->prepare("SELECT MAX(high_gpm) FROM pumps
WHERE pump_type = :pType AND pump_category = :cVal");
$maxHGPM->bindParam(':pType', $pType, PDO::PARAM_STR);
$maxHGPM->bindParam(':cVal', $cVal, PDO::PARAM_STR);
$maxHGPM->execute();
$res3 = $maxHGPM->fetch(PDO::FETCH_ASSOC);
$maxFGPM = $connection->prepare("SELECT MAX(flow_gpm) FROM pumps
WHERE pump_type = :pType AND pump_category = :cVal");
$maxFGPM->bindParam(':pType', $pType, PDO::PARAM_STR);
$maxFGPM->bindParam(':cVal', $cVal, PDO::PARAM_STR);
$maxFGPM->execute();
$res4 = $maxFGPM->fetch(PDO::FETCH_ASSOC);
Test code and integer conversion
// TEST CURRENT SET VALUES
var_dump($res1);
var_dump($res2);
var_dump($res3);
var_dump($res4);
// INTEGER CONVERSION
$psiA = (integer) array_keys($res1)[0];
var_dump($psiA);
// PERFORM LOGICAL COMPARISONS
if(array_keys($res1)[0] >= array_keys($res2)[0]){
$psiOut = $res1;
} else {
$psiOut = $res2;
}
if(array_keys($res3)[0] >= array_keys($res4)[0]){
$gpmOut = $res3;
} else {
$gpmOut = $res4;
}
var_dump($psiOut);
var_dump($gpmOut);
When the code runs the value dumped by $psiA is 0, am I missing a step for
variable conversion ( I am fairly new to PHP )
I am trying to create a piece of code which will dynamically set the
maximum values of a slider on my page by finding the max values returned
from my database using a PDO statement.
The problem I am having is that I cannot convert the value returned in my
assoc array to an integer value, what am I doing wrong?
Example of PDO statement
$maxHGPM = $connection->prepare("SELECT MAX(high_gpm) FROM pumps
WHERE pump_type = :pType AND pump_category = :cVal");
$maxHGPM->bindParam(':pType', $pType, PDO::PARAM_STR);
$maxHGPM->bindParam(':cVal', $cVal, PDO::PARAM_STR);
$maxHGPM->execute();
$res3 = $maxHGPM->fetch(PDO::FETCH_ASSOC);
$maxFGPM = $connection->prepare("SELECT MAX(flow_gpm) FROM pumps
WHERE pump_type = :pType AND pump_category = :cVal");
$maxFGPM->bindParam(':pType', $pType, PDO::PARAM_STR);
$maxFGPM->bindParam(':cVal', $cVal, PDO::PARAM_STR);
$maxFGPM->execute();
$res4 = $maxFGPM->fetch(PDO::FETCH_ASSOC);
Test code and integer conversion
// TEST CURRENT SET VALUES
var_dump($res1);
var_dump($res2);
var_dump($res3);
var_dump($res4);
// INTEGER CONVERSION
$psiA = (integer) array_keys($res1)[0];
var_dump($psiA);
// PERFORM LOGICAL COMPARISONS
if(array_keys($res1)[0] >= array_keys($res2)[0]){
$psiOut = $res1;
} else {
$psiOut = $res2;
}
if(array_keys($res3)[0] >= array_keys($res4)[0]){
$gpmOut = $res3;
} else {
$gpmOut = $res4;
}
var_dump($psiOut);
var_dump($gpmOut);
When the code runs the value dumped by $psiA is 0, am I missing a step for
variable conversion ( I am fairly new to PHP )
C# Selenium WebDriver: Get HTTP Status Code
C# Selenium WebDriver: Get HTTP Status Code
I'm using Selenium, C#, NUnit to write automated tests.
Is it possible to get the http status code with WebDriver so that tests
that fail due to http requests can be alerted to the user?
I'm using Selenium, C#, NUnit to write automated tests.
Is it possible to get the http status code with WebDriver so that tests
that fail due to http requests can be alerted to the user?
Tuesday, 27 August 2013
working with foreach in mysql and php.
working with foreach in mysql and php.
I have two arrays the selected and questiondesc, I want to update it to
the database but My code doesnt seem to work. Is it possible to do nested
for each?
<?php do { ?><tr><th width="170" scope="col"><input type="checkbox"
name="selected[]" value="<?php echo $row_Recordset1['question_id']; ?>"
/>
Description:</th>
<td colspan="2" scope="col">old:
<?php echo $row_Recordset1['question_description']; ?>
new:<input name="questiondesc[]" type="text" size="50" />/td>
<td width="549" colspan="2" scope="col"><div align="left"></td>
</tr><?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>
if(isset($_POST['selected'])){
$selected = $_POST['selected'];
$question = $_POST['questiondesc'];
foreach($selected as $enable) {
mysql_query("UPDATE exam_questions SET question_description = '$question'
WHERE question_id = '$selected' ")or die(mysql_error());
}
}
Thanks :)
I have two arrays the selected and questiondesc, I want to update it to
the database but My code doesnt seem to work. Is it possible to do nested
for each?
<?php do { ?><tr><th width="170" scope="col"><input type="checkbox"
name="selected[]" value="<?php echo $row_Recordset1['question_id']; ?>"
/>
Description:</th>
<td colspan="2" scope="col">old:
<?php echo $row_Recordset1['question_description']; ?>
new:<input name="questiondesc[]" type="text" size="50" />/td>
<td width="549" colspan="2" scope="col"><div align="left"></td>
</tr><?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>
if(isset($_POST['selected'])){
$selected = $_POST['selected'];
$question = $_POST['questiondesc'];
foreach($selected as $enable) {
mysql_query("UPDATE exam_questions SET question_description = '$question'
WHERE question_id = '$selected' ")or die(mysql_error());
}
}
Thanks :)
How to center an image in jquery mobile?
How to center an image in jquery mobile?
I am using jquery mobile for my mobile app but have been having issues
getting my image to be centered properly. As you can see from the image,
there is more white space to the left of the image compared to the right
side. This is happening consistently for all images on the page.
Any advice on how to fix this?
$("#allpictures").append('<div class = "img_center"><div><img
src = "'+item.url+'"></div></div><p style = "margin-left:10px;
margin-right:10px; font-size:15px;">'+item.title+'</p><br/>');
<style>
.img_center {
text-align:center;
}
.img_center * {
margin: 0 auto;
}
</style>
I am using jquery mobile for my mobile app but have been having issues
getting my image to be centered properly. As you can see from the image,
there is more white space to the left of the image compared to the right
side. This is happening consistently for all images on the page.
Any advice on how to fix this?
$("#allpictures").append('<div class = "img_center"><div><img
src = "'+item.url+'"></div></div><p style = "margin-left:10px;
margin-right:10px; font-size:15px;">'+item.title+'</p><br/>');
<style>
.img_center {
text-align:center;
}
.img_center * {
margin: 0 auto;
}
</style>
Disable or remove the Run Enhanced Content menu item from CDs and DVDs
Disable or remove the "Run Enhanced Content" menu item from CDs and DVDs
I tried to watch a DVD on my computer. I put it in and VLC started, but
later on, it crashed when I tried to rewind as it often does.
Naturally, I opened My Computer to play the DVD with VLC. Unfortunately,
when I sleected the DVD drive and pressed Enter, instead of running VLC as
I expected, it ran some kind of program that was on the disc.
I have absolutely no interest in letting Sony run a program on my system.
Granted it is (supposedly) only a Shockwave projector program, but I don't
exactly trust them. Besides, I don't even like or care for deleted scenes,
let alone whatever useless "bonus materials" the program provides (usually
just wallpapers, ringtones, and other equally meaningless junk).
Anyway, I was surprised by the program because I had already specifically
set the default programs and actions for various media. I right-clicked
the DVD drive and found that the default action is Run Enhanced Content.
First, I checked the AutoPlay settings and the action default action for
when a disc is inserted is indeed set to VLC. The problem is that this has
no effect on the context-menu you see when right-clicking the DVD drive in
My Computer (or worse, pressing Enter).
Of course my next reaction was to check the registry to delete the Run
Enhanced Content entry. Unfortunately there isn't one. I checked
HKCR\DVD\shell but the default action is PlayWithVLC and there is nothing
that could correspond to running the program of "enhanced" discs. (In
fact, I put a different DVD in that definitely has no such content and yet
Explorer is still showing me the menu entry, and not surprisingly, using
it gives an error about being unable to run the non-existent program.)
Does anyone know how to disable or remove the menu-entry?
I tried to watch a DVD on my computer. I put it in and VLC started, but
later on, it crashed when I tried to rewind as it often does.
Naturally, I opened My Computer to play the DVD with VLC. Unfortunately,
when I sleected the DVD drive and pressed Enter, instead of running VLC as
I expected, it ran some kind of program that was on the disc.
I have absolutely no interest in letting Sony run a program on my system.
Granted it is (supposedly) only a Shockwave projector program, but I don't
exactly trust them. Besides, I don't even like or care for deleted scenes,
let alone whatever useless "bonus materials" the program provides (usually
just wallpapers, ringtones, and other equally meaningless junk).
Anyway, I was surprised by the program because I had already specifically
set the default programs and actions for various media. I right-clicked
the DVD drive and found that the default action is Run Enhanced Content.
First, I checked the AutoPlay settings and the action default action for
when a disc is inserted is indeed set to VLC. The problem is that this has
no effect on the context-menu you see when right-clicking the DVD drive in
My Computer (or worse, pressing Enter).
Of course my next reaction was to check the registry to delete the Run
Enhanced Content entry. Unfortunately there isn't one. I checked
HKCR\DVD\shell but the default action is PlayWithVLC and there is nothing
that could correspond to running the program of "enhanced" discs. (In
fact, I put a different DVD in that definitely has no such content and yet
Explorer is still showing me the menu entry, and not surprisingly, using
it gives an error about being unable to run the non-existent program.)
Does anyone know how to disable or remove the menu-entry?
Is there a way to group by a case statement in a SQL Query?
Is there a way to group by a case statement in a SQL Query?
i have a code, will post the last part.
group by
case when @pa_id is NULL then
( pct.patient_assignment_id, pat.patient_id,pat.lname,pat.fname,
pct.clinician_id,pat.patient_id,sta.lname,sta.fname )
else 0
end
is that possible? or what is the way to get the needed results? i want it
to group by the given values if the parameter @pa_id is NUll and if it is
not Null, i want it to be grouped by the values from a CTE, which has a
name CTE
i have a code, will post the last part.
group by
case when @pa_id is NULL then
( pct.patient_assignment_id, pat.patient_id,pat.lname,pat.fname,
pct.clinician_id,pat.patient_id,sta.lname,sta.fname )
else 0
end
is that possible? or what is the way to get the needed results? i want it
to group by the given values if the parameter @pa_id is NUll and if it is
not Null, i want it to be grouped by the values from a CTE, which has a
name CTE
Columns from two models in one webgrid
Columns from two models in one webgrid
first, please note that I am a little new in that. I would like to know,
how can I make Webgrid with columns from two models (two tables).
I have two models, like that: Model1:
public int Id { get; set; }
public string Name { get; set; }
Model2:
public int Id { get; set; }
public int Model1_Id { get; set; }
public string Level { get; set; }
public string AdditionalInfo { get; set; }
public string Note { get; set; }
In controller handle data and send to view.
...
List<Model2> data = new List<Model2>();
...
return View(data)
Now starts the problem. In the view I am creating Webgrid from the model.
Once problem is, that names of columns have to be identical with property
names or it falls.
@model IEnumerable<Model2>
<div class="class-name">
@grid.GetHtml(columns: new [] {
grid.Column("Level"),
grid.Column("AdditionalInfo", header: "Additional info"),
grid.Column("Note")
}, tableStyle: "some-name")
</div>
That's all ok, but I want in that grid also name from Model1 and the
values will be depends on Model1_Id.
If I try add new column by grid.Column it falls.
If I add second model (after the first line) it writes 'Only one 'model'
statement is allowed in file'.
Everything what I tried it fell.
I tried work with google but after several hours, I would like ask you
guys. Thank you
first, please note that I am a little new in that. I would like to know,
how can I make Webgrid with columns from two models (two tables).
I have two models, like that: Model1:
public int Id { get; set; }
public string Name { get; set; }
Model2:
public int Id { get; set; }
public int Model1_Id { get; set; }
public string Level { get; set; }
public string AdditionalInfo { get; set; }
public string Note { get; set; }
In controller handle data and send to view.
...
List<Model2> data = new List<Model2>();
...
return View(data)
Now starts the problem. In the view I am creating Webgrid from the model.
Once problem is, that names of columns have to be identical with property
names or it falls.
@model IEnumerable<Model2>
<div class="class-name">
@grid.GetHtml(columns: new [] {
grid.Column("Level"),
grid.Column("AdditionalInfo", header: "Additional info"),
grid.Column("Note")
}, tableStyle: "some-name")
</div>
That's all ok, but I want in that grid also name from Model1 and the
values will be depends on Model1_Id.
If I try add new column by grid.Column it falls.
If I add second model (after the first line) it writes 'Only one 'model'
statement is allowed in file'.
Everything what I tried it fell.
I tried work with google but after several hours, I would like ask you
guys. Thank you
How can I find if some commit is included in branch?
How can I find if some commit is included in branch?
During development we commit into trunk, when time comes we create branch
to be tested separately and further turned into tag.
My question is: is there a simple way to find out whether some commit is
inside trunk? Different flavour of this question: how can I find out when
the branch was created?
During development we commit into trunk, when time comes we create branch
to be tested separately and further turned into tag.
My question is: is there a simple way to find out whether some commit is
inside trunk? Different flavour of this question: how can I find out when
the branch was created?
Monday, 26 August 2013
GAE force overwrite of download_data dump file
GAE force overwrite of download_data dump file
I am running the following command to take a dump of my GAE app's datastore:
python ~/google_appengine/appcfg.py download_data
--application=s~myappsname
--url=http://myappsname.appspot.com/_ah/remote_api --filename=gaedump
--db_filename=skip
This works fine unless the gaedump file already exists, in which case it
fails with error:
google.appengine.tools.bulkloader.FileExistsError: gaedump: output file
exists
I would like to automate this command but cannot find a comprehensive
reference for the download_data function.
Preceding the command with rm gaedump; is a workable solution, but would
prefer to use just the one command if possible.
I am running the following command to take a dump of my GAE app's datastore:
python ~/google_appengine/appcfg.py download_data
--application=s~myappsname
--url=http://myappsname.appspot.com/_ah/remote_api --filename=gaedump
--db_filename=skip
This works fine unless the gaedump file already exists, in which case it
fails with error:
google.appengine.tools.bulkloader.FileExistsError: gaedump: output file
exists
I would like to automate this command but cannot find a comprehensive
reference for the download_data function.
Preceding the command with rm gaedump; is a workable solution, but would
prefer to use just the one command if possible.
What's the best way to create models for this situation in django?
What's the best way to create models for this situation in django?
I'm creating a website about services provided by certain professionals.
Each professional creates his own personal page and lists services which
he provides, with prices.
However, he has a certain limited choice of service types to choose from.
The professional can't create new service types — it's admin's
prerogative. Each service that the professional lists has to be of a
certain pre-determined type, and he can't have to services of the same
type.
So far, that's what I have in models.py:
# Created and edited only by site administration
class Service(models.Model):
url_name = models.CharField(max_length=100, primary_key=True) # to use
in URLs
name = models.CharField(max_length=200)
description = models.TextField()
def __unicode__(self):
return self.name
class Master(models.Model):
name = models.CharField(max_length=200)
description = models.TextField()
def __unicode__(self):
return self.name
class MasterService(models.Model):
master = models.ForeignKey(Master)
service = models.ForeignKey(Service)
price = models.PositiveIntegerField(blank=True)
How can I edit that model in such a way that the django will "know" that
each master can only have 1 service of a certain Service type?
I'm creating a website about services provided by certain professionals.
Each professional creates his own personal page and lists services which
he provides, with prices.
However, he has a certain limited choice of service types to choose from.
The professional can't create new service types — it's admin's
prerogative. Each service that the professional lists has to be of a
certain pre-determined type, and he can't have to services of the same
type.
So far, that's what I have in models.py:
# Created and edited only by site administration
class Service(models.Model):
url_name = models.CharField(max_length=100, primary_key=True) # to use
in URLs
name = models.CharField(max_length=200)
description = models.TextField()
def __unicode__(self):
return self.name
class Master(models.Model):
name = models.CharField(max_length=200)
description = models.TextField()
def __unicode__(self):
return self.name
class MasterService(models.Model):
master = models.ForeignKey(Master)
service = models.ForeignKey(Service)
price = models.PositiveIntegerField(blank=True)
How can I edit that model in such a way that the django will "know" that
each master can only have 1 service of a certain Service type?
Asp,Net strange behaviour of ViewState
Asp,Net strange behaviour of ViewState
I have an Asp.Net page (named 'PostAD') which allows user to upload upto 4
pictures. The file upload button function is as follows;
protected void btnUpload_Click(object sender, EventArgs e)
{
if ((ViewState["Img1"] != null) && (ViewState["Img2"] != null) &&
(ViewState["Img3"] != null) && (ViewState["Img4"] != null))
{
lblUploadMsg.Text = "You cannot upload more than 4 pictures";
return;
}
if (FileUpload1.HasFile)
{
//FileUpload1.Attributes.Clear();
string fileExtension =
System.IO.Path.GetExtension(FileUpload1.FileName);
if (fileExtension.ToLower() == ".jpg")
{
int fileSize = FileUpload1.PostedFile.ContentLength;
if (FileUpload1.PostedFile.ContentLength < 2097152)
{
//FileUpload1.SaveAs(Server.MapPath("~/Temp/" +
FileUpload1.FileName));
//Response.Write("Successfully Done");
string sp = Server.MapPath("~/ItemPictures/");
String fn = Guid.NewGuid().ToString() +
FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf("."));
if (sp.EndsWith("\\") == false)
sp += "\\";
sp += fn;
FileUpload1.PostedFile.SaveAs(sp);
lblUploadMsg.ForeColor = System.Drawing.Color.Green;
lblUploadMsg.Text = "Picture Uploaded successfully. You
can upload upto 4 pictures";
if (ViewState["Img1"] == null)
{
ViewState["Img1"] = "~/ItemPictures/" + fn;
}
else if (ViewState["Img2"] == null)
{
ViewState["Img2"] = "~/ItemPictures/" + fn;
}
else if (ViewState["Img3"] == null)
{
ViewState["Img3"] = "~/ItemPictures/" + fn;
}
else if (ViewState["Img4"] == null)
{
ViewState["Img4"] = "~/ItemPictures/" + fn;
}
}
else
{
lblUploadMsg.Text = "Maximum 2MB files are allowed";
}
}
else
{
lblUploadMsg.Text = "Only JPG files are allowed";
}
}
else
{
lblUploadMsg.Text = "No File was Selected";
}
ShowAvailblImgs();
}
I have four Asp.Net images that are invisible at page load time. To show
them i have the following code.
private void ShowAvailblImgs()
{
if (ViewState["Img1"] != null)
{
//The string URL variable is used just to show what value
ViewState["image1"] currently has.
string URL = (string)ViewState["img1"];
Response.Write(URL);
Image1.ImageUrl = (string)ViewState["img1"];
Image1.Width = 130;
Image1.Height = 130;
Image1.Visible = true;
}
else
Image1.Visible = false;
if (ViewState["Img2"] != null)
{
Image2.ImageUrl = (string)ViewState["img2"];
Image2.Width = 130;
Image2.Height = 130;
Image2.Visible = true;
}
else
Image2.Visible = false;
if (ViewState["Img3"] != null)
{
Image3.ImageUrl = (string)ViewState["img3"];
Image3.Width = 130;
Image3.Height = 130;
Image3.Visible = true;
}
else
Image3.Visible = false;
if (ViewState["Img4"] != null)
{
Image4.ImageUrl = (string)ViewState["img4"];
Image4.Width = 130;
Image4.Height = 130;
Image4.Visible = true;
}
else
Image4.Visible = false;
}
I am having very strange behaviour of ViewState variable. Upon loading
images, they are not shown in Asp.Net image control. Instead empty image
areas are shown. Though the URL variable i used print exact path to the
image. Upon saving the image (which are really blank image areas), it get
saved my .aspx page. I was using Session variable which worked fine but
due to some reasons, i want to use ViewState variable. I shall be very
thankful if somebody can help.
I have an Asp.Net page (named 'PostAD') which allows user to upload upto 4
pictures. The file upload button function is as follows;
protected void btnUpload_Click(object sender, EventArgs e)
{
if ((ViewState["Img1"] != null) && (ViewState["Img2"] != null) &&
(ViewState["Img3"] != null) && (ViewState["Img4"] != null))
{
lblUploadMsg.Text = "You cannot upload more than 4 pictures";
return;
}
if (FileUpload1.HasFile)
{
//FileUpload1.Attributes.Clear();
string fileExtension =
System.IO.Path.GetExtension(FileUpload1.FileName);
if (fileExtension.ToLower() == ".jpg")
{
int fileSize = FileUpload1.PostedFile.ContentLength;
if (FileUpload1.PostedFile.ContentLength < 2097152)
{
//FileUpload1.SaveAs(Server.MapPath("~/Temp/" +
FileUpload1.FileName));
//Response.Write("Successfully Done");
string sp = Server.MapPath("~/ItemPictures/");
String fn = Guid.NewGuid().ToString() +
FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf("."));
if (sp.EndsWith("\\") == false)
sp += "\\";
sp += fn;
FileUpload1.PostedFile.SaveAs(sp);
lblUploadMsg.ForeColor = System.Drawing.Color.Green;
lblUploadMsg.Text = "Picture Uploaded successfully. You
can upload upto 4 pictures";
if (ViewState["Img1"] == null)
{
ViewState["Img1"] = "~/ItemPictures/" + fn;
}
else if (ViewState["Img2"] == null)
{
ViewState["Img2"] = "~/ItemPictures/" + fn;
}
else if (ViewState["Img3"] == null)
{
ViewState["Img3"] = "~/ItemPictures/" + fn;
}
else if (ViewState["Img4"] == null)
{
ViewState["Img4"] = "~/ItemPictures/" + fn;
}
}
else
{
lblUploadMsg.Text = "Maximum 2MB files are allowed";
}
}
else
{
lblUploadMsg.Text = "Only JPG files are allowed";
}
}
else
{
lblUploadMsg.Text = "No File was Selected";
}
ShowAvailblImgs();
}
I have four Asp.Net images that are invisible at page load time. To show
them i have the following code.
private void ShowAvailblImgs()
{
if (ViewState["Img1"] != null)
{
//The string URL variable is used just to show what value
ViewState["image1"] currently has.
string URL = (string)ViewState["img1"];
Response.Write(URL);
Image1.ImageUrl = (string)ViewState["img1"];
Image1.Width = 130;
Image1.Height = 130;
Image1.Visible = true;
}
else
Image1.Visible = false;
if (ViewState["Img2"] != null)
{
Image2.ImageUrl = (string)ViewState["img2"];
Image2.Width = 130;
Image2.Height = 130;
Image2.Visible = true;
}
else
Image2.Visible = false;
if (ViewState["Img3"] != null)
{
Image3.ImageUrl = (string)ViewState["img3"];
Image3.Width = 130;
Image3.Height = 130;
Image3.Visible = true;
}
else
Image3.Visible = false;
if (ViewState["Img4"] != null)
{
Image4.ImageUrl = (string)ViewState["img4"];
Image4.Width = 130;
Image4.Height = 130;
Image4.Visible = true;
}
else
Image4.Visible = false;
}
I am having very strange behaviour of ViewState variable. Upon loading
images, they are not shown in Asp.Net image control. Instead empty image
areas are shown. Though the URL variable i used print exact path to the
image. Upon saving the image (which are really blank image areas), it get
saved my .aspx page. I was using Session variable which worked fine but
due to some reasons, i want to use ViewState variable. I shall be very
thankful if somebody can help.
Bind Xaml Radio button to boolean
Bind Xaml Radio button to boolean
I saw many posts on how to bind a boolean value to a radio button. But my
scenario is that I need to bind it to a radio button and read the
selection from the user.
That is no option should be selected intially.
If I bind it to a boolean, since boolean cant be null it shows the default
value selected in radio button.
If I use nullable boolean, I still defaults to false when trying to use
the converter.
I cant use oneway mode in xaml as I need to check if the radio button
selection was made which I do using the bounded variable.
Ant pointers on how to achieve this?
I saw many posts on how to bind a boolean value to a radio button. But my
scenario is that I need to bind it to a radio button and read the
selection from the user.
That is no option should be selected intially.
If I bind it to a boolean, since boolean cant be null it shows the default
value selected in radio button.
If I use nullable boolean, I still defaults to false when trying to use
the converter.
I cant use oneway mode in xaml as I need to check if the radio button
selection was made which I do using the bounded variable.
Ant pointers on how to achieve this?
cannot find weblogic shared libraries
cannot find weblogic shared libraries
I just checked out code from an old repository. I'm using eclipse that
comes with the oracle middleware for weblogic 12.1.
There seems to be problems with many shared libraries which are being used
by the project.
I was wondering how to resolve these issues. Should I install these
libraries seperately since they are not part of weblogic? or its just a
matter of finding these libraries in my system.
Here is the screenshots from my project facets page.
I just checked out code from an old repository. I'm using eclipse that
comes with the oracle middleware for weblogic 12.1.
There seems to be problems with many shared libraries which are being used
by the project.
I was wondering how to resolve these issues. Should I install these
libraries seperately since they are not part of weblogic? or its just a
matter of finding these libraries in my system.
Here is the screenshots from my project facets page.
PHP: a way to check user login other than sessions
PHP: a way to check user login other than sessions
I am building a website and I am using sessions to check user login. I am
wondering if there is any better and safer way to check user login.
Because sessions are stored in the clients computer I think they are not
very safe and easy to hack. Am I correct?How do big websites like facebook
and twitter check if their user is logged in or not. I am new to PHP so
dont say my question is too basic.
I am building a website and I am using sessions to check user login. I am
wondering if there is any better and safer way to check user login.
Because sessions are stored in the clients computer I think they are not
very safe and easy to hack. Am I correct?How do big websites like facebook
and twitter check if their user is logged in or not. I am new to PHP so
dont say my question is too basic.
iPhone 4s Broken LCD is worthy?
iPhone 4s Broken LCD is worthy?
Is there anyways I can fix my iPhone broken LCD glass, LCD is working from
inside but i think the digitizer is broken. I have visited so many blog
and website and most of them told me to replace all the screen with LCD
and digitizer. But I want to know can I replace all that or I can still
fix Digitzer?
Is there anyways I can fix my iPhone broken LCD glass, LCD is working from
inside but i think the digitizer is broken. I have visited so many blog
and website and most of them told me to replace all the screen with LCD
and digitizer. But I want to know can I replace all that or I can still
fix Digitzer?
12.04.2 and 13.04 recursive fault
12.04.2 and 13.04 recursive fault
26/08/13 system: HP Pavillion DV6700 hdd upgraded to 1.0Tb WD10JPVT OS Win
7 64 bit (wiped vista) Aim : to dual boot win 7 with ubuntu 12.04.2 64bit
downloaded amd 64 bit 12.04.2 then burned to disk.no error messages at any
stage.NB used desktop system Ubuntu 8.04 to do download and burn
(brassero).Triple boot XP, Win7, Ubuntu 8.04 loaded system onto laptop,
and again no error messages during os loading. Removed disk and restarted.
Appeared to be a normal start, selected ubuntu, made all normal noises,
then fan sped up to full. Laptop quickly got warmer, the screen had
stopped at recursive fault reboot needed 14.524009 _ _ _ [end trace
30e853624bd8f9] Boot up would not procede past this point. The cooling fan
ran at maximum and the laptop was running quite warm.Also could hear hdd
running
In 5 attempts using both normal and recovery mode I had 5 boot failures.
Fail point was variable, between 9.xxxxxx and 16.xxxxxx Error message was
always "recursive error reboot needed" I also tried to load ubuntu 13.04
as per above. After multiple failures I gave up. The only difference was
the fail points varied from 7.xxxxxxxx to 14.xxxxxx with the same error
message. Hard shutdown was needed each time. Win7 worked perfectly
reguardless of ubuntu status. Test loaded mint 14 64 bit, Worked
perfectly. I have installed ubuntu 12.04 32 bit on 2 other computers
successfully. What is wrong with ubuntu 64 bit???
26/08/13 system: HP Pavillion DV6700 hdd upgraded to 1.0Tb WD10JPVT OS Win
7 64 bit (wiped vista) Aim : to dual boot win 7 with ubuntu 12.04.2 64bit
downloaded amd 64 bit 12.04.2 then burned to disk.no error messages at any
stage.NB used desktop system Ubuntu 8.04 to do download and burn
(brassero).Triple boot XP, Win7, Ubuntu 8.04 loaded system onto laptop,
and again no error messages during os loading. Removed disk and restarted.
Appeared to be a normal start, selected ubuntu, made all normal noises,
then fan sped up to full. Laptop quickly got warmer, the screen had
stopped at recursive fault reboot needed 14.524009 _ _ _ [end trace
30e853624bd8f9] Boot up would not procede past this point. The cooling fan
ran at maximum and the laptop was running quite warm.Also could hear hdd
running
In 5 attempts using both normal and recovery mode I had 5 boot failures.
Fail point was variable, between 9.xxxxxx and 16.xxxxxx Error message was
always "recursive error reboot needed" I also tried to load ubuntu 13.04
as per above. After multiple failures I gave up. The only difference was
the fail points varied from 7.xxxxxxxx to 14.xxxxxx with the same error
message. Hard shutdown was needed each time. Win7 worked perfectly
reguardless of ubuntu status. Test loaded mint 14 64 bit, Worked
perfectly. I have installed ubuntu 12.04 32 bit on 2 other computers
successfully. What is wrong with ubuntu 64 bit???
Sunday, 25 August 2013
Get background color of text from webpage
Get background color of text from webpage
My web application primary and secondary search.
Based on the search term the web application highlights the first search
term in blue color and the second search term (or search within as they
call) is highlighted in purple color. This is mostly done using java
script in the back end for which we do not have access.
I need to automate this scenario, since the color of the element is not
seen in page source i am unable to identify the color of the element using
selenium.
Please suggest me a suitable solution.
My web application primary and secondary search.
Based on the search term the web application highlights the first search
term in blue color and the second search term (or search within as they
call) is highlighted in purple color. This is mostly done using java
script in the back end for which we do not have access.
I need to automate this scenario, since the color of the element is not
seen in page source i am unable to identify the color of the element using
selenium.
Please suggest me a suitable solution.
Remote Access Service
Remote Access Service
I just want to know that can any class of ip(both public and private) can
be used for establishing a remote access service like ssh, or is their
their any limitation that public cannot access private and so on.
I just want to know that can any class of ip(both public and private) can
be used for establishing a remote access service like ssh, or is their
their any limitation that public cannot access private and so on.
Making a Linked List in C++
Making a Linked List in C++
This is a code to make a linked list with 2 values- one user input and
another 7.
#include<iostream>
#include<cstdlib>
using namespace std;
class node{
public:
node();
~node();
void printList();
void insert_front(int);
void delete_front();
private:
int data;
node *head;
node *next;
};
node::node()
{
head=NULL;
}
node::~node( ){//destructor
cout <<"destructor called";
while( head!= NULL) delete_front() ;
}
void node::delete_front(){
node *h=head;
if(head==NULL)
{
cout<< "Empty List.\n";
return;
}
head = head->next;
delete(h);
}
void node::printList()
{
node *h=head;
cout<< "Printing the list";
while(h!=NULL)
{
cout<< h->data;
cout<< '\n';
h->next= h->next->next;
}
}
void node::insert_front(int value){
node *temp = new node;
temp->data=value;
temp -> next = NULL;
if (head != NULL){
temp->next =head;
}
head= temp;
}
int main()
{
node ListX;
cout<< "enter integer";
int as;
cin>> as;
ListX.insert_front(as);
ListX.insert_front(7);
ListX.printList();
ListX.~node( );//call destructor to free objects
return 0;
}
Please tell the error in this as it shows an error while compiling it
online on http://www.compileonline.com/compile_cpp_online.php and even on
my laptop.
This is a code to make a linked list with 2 values- one user input and
another 7.
#include<iostream>
#include<cstdlib>
using namespace std;
class node{
public:
node();
~node();
void printList();
void insert_front(int);
void delete_front();
private:
int data;
node *head;
node *next;
};
node::node()
{
head=NULL;
}
node::~node( ){//destructor
cout <<"destructor called";
while( head!= NULL) delete_front() ;
}
void node::delete_front(){
node *h=head;
if(head==NULL)
{
cout<< "Empty List.\n";
return;
}
head = head->next;
delete(h);
}
void node::printList()
{
node *h=head;
cout<< "Printing the list";
while(h!=NULL)
{
cout<< h->data;
cout<< '\n';
h->next= h->next->next;
}
}
void node::insert_front(int value){
node *temp = new node;
temp->data=value;
temp -> next = NULL;
if (head != NULL){
temp->next =head;
}
head= temp;
}
int main()
{
node ListX;
cout<< "enter integer";
int as;
cin>> as;
ListX.insert_front(as);
ListX.insert_front(7);
ListX.printList();
ListX.~node( );//call destructor to free objects
return 0;
}
Please tell the error in this as it shows an error while compiling it
online on http://www.compileonline.com/compile_cpp_online.php and even on
my laptop.
Display webpage with highlighted content on another site
Display webpage with highlighted content on another site
I am using curl to download the content of a webpage. When it's downloaded
I use a regex to find phonenumbers and adresses on the page. I wonder if
there is a way to create a iFrame-like box that highlight the phonenumbers
and adresses I've found. The highlighting should be no problem. The issue
here is how to download the page including the css and other scripts.
Example page: http://www.citygross.se/Om-City-Gross/Kundservice-och-kontakt/
Here is how I would like it to look:
I am using curl to download the content of a webpage. When it's downloaded
I use a regex to find phonenumbers and adresses on the page. I wonder if
there is a way to create a iFrame-like box that highlight the phonenumbers
and adresses I've found. The highlighting should be no problem. The issue
here is how to download the page including the css and other scripts.
Example page: http://www.citygross.se/Om-City-Gross/Kundservice-och-kontakt/
Here is how I would like it to look:
c# absolute position of control on screen
c# absolute position of control on screen
I'm trying to get the absolute position of a control on the screen. I'm
using two monitors and the results aren't really that great...
What I'm doing is opening another form to capture an image, then passing
this image to the main form and closing the capture form. I then want the
main form to appear in the same place the picture was captured. To get a
gist of what I'm trying to do as an example, open Snipping Tool on Windows
and capture a snip. The window will then appear in the place that the
image was taken.
This is the current code I am using to do this:
Location = new Point(Cursor.Position.X - CaptureBox.Width -
CapturePanel.Location.X - CaptureBox.Location.X - 8, Cursor.Position.Y -
CaptureBox.Height - CapturePanel.Location.Y - CaptureBox.Location.Y - 30);
CapturePanel contains the CaptureBox control which stores the picture. I'm
also taking 8 from the X location and 30 from te Y location to compensate
for the form's border and title bar, but the only problem with this is
that some computers will be using a different window style, and these
numbers will change.
If there is a method that can be used to grab the border and title
width/height of windows, that would be great.
I'm trying to get the absolute position of a control on the screen. I'm
using two monitors and the results aren't really that great...
What I'm doing is opening another form to capture an image, then passing
this image to the main form and closing the capture form. I then want the
main form to appear in the same place the picture was captured. To get a
gist of what I'm trying to do as an example, open Snipping Tool on Windows
and capture a snip. The window will then appear in the place that the
image was taken.
This is the current code I am using to do this:
Location = new Point(Cursor.Position.X - CaptureBox.Width -
CapturePanel.Location.X - CaptureBox.Location.X - 8, Cursor.Position.Y -
CaptureBox.Height - CapturePanel.Location.Y - CaptureBox.Location.Y - 30);
CapturePanel contains the CaptureBox control which stores the picture. I'm
also taking 8 from the X location and 30 from te Y location to compensate
for the form's border and title bar, but the only problem with this is
that some computers will be using a different window style, and these
numbers will change.
If there is a method that can be used to grab the border and title
width/height of windows, that would be great.
Saturday, 24 August 2013
alternatives for "mailing lists" now that google apps is no longer free
alternatives for "mailing lists" now that google apps is no longer free
Does anyone know of an easy way to set up an administrate mailing lists
now that google apps is no longer free and I am not willing to pay for it
just so I can set up a mailing list under my custom domain?
Does anyone know of an easy way to set up an administrate mailing lists
now that google apps is no longer free and I am not willing to pay for it
just so I can set up a mailing list under my custom domain?
Can I program a Raspberry Pi with Node.js?
Can I program a Raspberry Pi with Node.js?
I want to learn to program Raspberry Pi's and I'm pretty good with
Node.js. I haven't touched c++ in almost half a decade. I understand that
I can load Linux on the Pi, but how do can I do my programming in Node?
If so, how do I handle things like input / output? If I wanted to make a
simple device that detected motion and emitted a beep, for example, is
this doable via Node.js on the Pi?
I want to learn to program Raspberry Pi's and I'm pretty good with
Node.js. I haven't touched c++ in almost half a decade. I understand that
I can load Linux on the Pi, but how do can I do my programming in Node?
If so, how do I handle things like input / output? If I wanted to make a
simple device that detected motion and emitted a beep, for example, is
this doable via Node.js on the Pi?
jQuery slideshow image delay
jQuery slideshow image delay
I have a slideshow which rotates three images from right to left.
Everything works fine, except the images slide in after the previous image
has already slid all the way out (leaving a white space between images). I
have tried different timings with the setInterval and hide and show
functions but with no avail.
JavaScript:
function Slider() {
$(".slider .1").show("fade", 500);
$(".slider .1").delay(5500).hide("slide", {direction:"left"}, 500);
var sc = $(".slider img").size();
var count = 2;
setInterval(function() {
$(".slider ."+count).show("slide", {direction:"right"}, 500);
$(".slider ."+count).delay(5500).hide("slide", {direction:'left'},
500);
if(count == sc) {
count = 1;
} else {
count = count + 1;
}
}, 6000);
}
CSS:
.slider {
width: 200px;
height: 200px;
overflow: hidden;
margin: 30px auto;
background-image:
url('http://www.thatssotrue.com/images/ajax_loader.gif');
background-size: 50px 50px;
background-position: center center;
background-repeat: no-repeat;
}
.slider img {
width: 200px;
height: 200px;
display: none;
}
HTML:
<body onload="Slider();">
<div class="slider">
<img class="1"
src="http://thebarking.com/wp-content/uploads/2012/09/biscuit.jpg"
height="200" width="200">
<img class="2"
src="http://31.media.tumblr.com/tumblr_m33f16g9Li1r21nejo1_400.jpg"
height="200" width="200">
<img class="3"
src="https://www.creameryschoolofmusic.com/template/upload_images/Guitar-guitar-10566054-1920-1200.jpg"
height="200" width="200">
</div>
</body>
Any ideas on how I could make the images hug each other (no space in
between) as they slide in/out?
Note: I don't own any of the images, nor do I associate myself with the
websites they are hosted at. I just used these as an example since the
images I'm actually using are merely in a directory, not a url.
Any help would be much appreciated!
I have a slideshow which rotates three images from right to left.
Everything works fine, except the images slide in after the previous image
has already slid all the way out (leaving a white space between images). I
have tried different timings with the setInterval and hide and show
functions but with no avail.
JavaScript:
function Slider() {
$(".slider .1").show("fade", 500);
$(".slider .1").delay(5500).hide("slide", {direction:"left"}, 500);
var sc = $(".slider img").size();
var count = 2;
setInterval(function() {
$(".slider ."+count).show("slide", {direction:"right"}, 500);
$(".slider ."+count).delay(5500).hide("slide", {direction:'left'},
500);
if(count == sc) {
count = 1;
} else {
count = count + 1;
}
}, 6000);
}
CSS:
.slider {
width: 200px;
height: 200px;
overflow: hidden;
margin: 30px auto;
background-image:
url('http://www.thatssotrue.com/images/ajax_loader.gif');
background-size: 50px 50px;
background-position: center center;
background-repeat: no-repeat;
}
.slider img {
width: 200px;
height: 200px;
display: none;
}
HTML:
<body onload="Slider();">
<div class="slider">
<img class="1"
src="http://thebarking.com/wp-content/uploads/2012/09/biscuit.jpg"
height="200" width="200">
<img class="2"
src="http://31.media.tumblr.com/tumblr_m33f16g9Li1r21nejo1_400.jpg"
height="200" width="200">
<img class="3"
src="https://www.creameryschoolofmusic.com/template/upload_images/Guitar-guitar-10566054-1920-1200.jpg"
height="200" width="200">
</div>
</body>
Any ideas on how I could make the images hug each other (no space in
between) as they slide in/out?
Note: I don't own any of the images, nor do I associate myself with the
websites they are hosted at. I just used these as an example since the
images I'm actually using are merely in a directory, not a url.
Any help would be much appreciated!
Monthly Network Maintenance/Support Charges
Monthly Network Maintenance/Support Charges
I just moved to Greece and may be taking on a small business network. They
currently have:
2 physical servers both running Windows 2008 on ESXi (1 files server, 1
server running a CRM package and separate accounting package both of which
utilise SQL)
15 email accounts (hosted on google apps)
15 work stations running Windows XP, Vista and 7
4 network printers
2 ipads
10 mobile devices (android, iphone and blackberry)
They basically want someone to take on the network
maintenance/backup/troubleshooting and upkeep of their html website. The
website is hosted by a hosting company and is up an running. They just
want someone to make changes from time to time (3-4 times a month).
I already have 4 years hands on experience doing this as an employee in
the UK but never as a contractor. I have checked out everything onsite and
am more than capable of doing it.
My question is, as a freelancer what would be a fair monthly charge for
all this?
Ideally anyone having worked in the Greek market would be very helpful but
answers from UK, US and anywhere would be helpful too! Just to put things
into perspective, if I was to be an employee the minimum gross salary I
would be entitled to would be 645 EUR = 555 GBP = 865 USD(!) Not very
enticing...
Thanks in advance! ;)
I just moved to Greece and may be taking on a small business network. They
currently have:
2 physical servers both running Windows 2008 on ESXi (1 files server, 1
server running a CRM package and separate accounting package both of which
utilise SQL)
15 email accounts (hosted on google apps)
15 work stations running Windows XP, Vista and 7
4 network printers
2 ipads
10 mobile devices (android, iphone and blackberry)
They basically want someone to take on the network
maintenance/backup/troubleshooting and upkeep of their html website. The
website is hosted by a hosting company and is up an running. They just
want someone to make changes from time to time (3-4 times a month).
I already have 4 years hands on experience doing this as an employee in
the UK but never as a contractor. I have checked out everything onsite and
am more than capable of doing it.
My question is, as a freelancer what would be a fair monthly charge for
all this?
Ideally anyone having worked in the Greek market would be very helpful but
answers from UK, US and anywhere would be helpful too! Just to put things
into perspective, if I was to be an employee the minimum gross salary I
would be entitled to would be 645 EUR = 555 GBP = 865 USD(!) Not very
enticing...
Thanks in advance! ;)
Allowing custom CSS
Allowing custom CSS
I want to allow my users to insert their custom CSS into their websites.
The custom CSS file will be served to the customers website only. I will
host the CSS myself and I'm thinking of serving it through a PHP script
and doing the filtering there.
What should I pay attention to while doing this?
I should filter things, what exactly should not be included in the CSS file?
Thank you
I want to allow my users to insert their custom CSS into their websites.
The custom CSS file will be served to the customers website only. I will
host the CSS myself and I'm thinking of serving it through a PHP script
and doing the filtering there.
What should I pay attention to while doing this?
I should filter things, what exactly should not be included in the CSS file?
Thank you
How to manage with less technical knowledge?
How to manage with less technical knowledge?
I've become a project manager in my company and here is what I've
experienced till now:
At first, I was trying to keep in shape technically with other developers
of the team (about 15 developers) and read as much as I could so that I
would know almost everything going on in the project, from architecture,
up to syntax consistency.
However, soon I realized that it's almost impossible for you to know
everything. Therefore it's natural that you fall back in the technical
race. Imagine how much work it requires for you to learn Angular JS, BRE,
WCF, Enterprise Library for logging, Asterisk, etc. etc. all at the same
time. Thus it seems to me that this is not the correct path.
I think the formula is: The more people you have to manage, the less
technical knowledge you can possess.
However, there are problems in not knowing what's going on inside your
team technically:
You might not understand and detect bottlenecks just the way you would do
when you were developing
You might not decide which technology is better at performance and
productivity
In case of a technical dispute in team, you might not be able to help
The more distance you get from code, the less you might understand
developer's stress, pressures, and feelings (this is a big concern for me)
You might not be able to forecast and predict the time necessary to get a
task done
You loose your passion when a developer talks with enthusiasm about a
problem that has been solved, because you don't understand like 40 percent
of what he talks about, and the less you know about something, the more
boring it might become for you
Developers would find it harder to explain something to you and they need
to speak less technically
Bad developers (rare but existing) might misuse your lesser technical
knowledge and cause all sort of problems
...
This phenomenon probably occurs in any career and profession. However,
since the world of development and computer in general is moving forward
with more speed (comparing to say, car industry), thus in a short period
of time like 6 months you feel that you've fallen back. Version after
version, feature after feature, library after library, you got the idea.
I saw these questions, and they contain good suggestions.
How can I maintain my technical skills after becoming a project manager?
How much should my project manager know?
How much should my project manager know?
Should a manager (or CEO) in an IT company have an IT background to
perform in the organization?
How can I convince management to deal with technical debt?
However, they're based more on personal experience and advises, which is
of course good, but might not help that much.
Do we have a book, or a well-thought and researched essay on this subject,
on how to manage a team of software developers, with lesser technical
knowledge than team members? What points should I take into account to
lead effectively and make the whole team achieve success?
I've become a project manager in my company and here is what I've
experienced till now:
At first, I was trying to keep in shape technically with other developers
of the team (about 15 developers) and read as much as I could so that I
would know almost everything going on in the project, from architecture,
up to syntax consistency.
However, soon I realized that it's almost impossible for you to know
everything. Therefore it's natural that you fall back in the technical
race. Imagine how much work it requires for you to learn Angular JS, BRE,
WCF, Enterprise Library for logging, Asterisk, etc. etc. all at the same
time. Thus it seems to me that this is not the correct path.
I think the formula is: The more people you have to manage, the less
technical knowledge you can possess.
However, there are problems in not knowing what's going on inside your
team technically:
You might not understand and detect bottlenecks just the way you would do
when you were developing
You might not decide which technology is better at performance and
productivity
In case of a technical dispute in team, you might not be able to help
The more distance you get from code, the less you might understand
developer's stress, pressures, and feelings (this is a big concern for me)
You might not be able to forecast and predict the time necessary to get a
task done
You loose your passion when a developer talks with enthusiasm about a
problem that has been solved, because you don't understand like 40 percent
of what he talks about, and the less you know about something, the more
boring it might become for you
Developers would find it harder to explain something to you and they need
to speak less technically
Bad developers (rare but existing) might misuse your lesser technical
knowledge and cause all sort of problems
...
This phenomenon probably occurs in any career and profession. However,
since the world of development and computer in general is moving forward
with more speed (comparing to say, car industry), thus in a short period
of time like 6 months you feel that you've fallen back. Version after
version, feature after feature, library after library, you got the idea.
I saw these questions, and they contain good suggestions.
How can I maintain my technical skills after becoming a project manager?
How much should my project manager know?
How much should my project manager know?
Should a manager (or CEO) in an IT company have an IT background to
perform in the organization?
How can I convince management to deal with technical debt?
However, they're based more on personal experience and advises, which is
of course good, but might not help that much.
Do we have a book, or a well-thought and researched essay on this subject,
on how to manage a team of software developers, with lesser technical
knowledge than team members? What points should I take into account to
lead effectively and make the whole team achieve success?
Abnormal disk read usage
Abnormal disk read usage
My Hard Drive is giving me abnormal reading usage. It is displaying 15
MB/s read usage while 101.4 MB/s write usage. (My hard drive was not busy
before I performed the test) When I was testing the write, the process
took a while but when I tested the read, it just finished straight away.
My Hard Drive is giving me abnormal reading usage. It is displaying 15
MB/s read usage while 101.4 MB/s write usage. (My hard drive was not busy
before I performed the test) When I was testing the write, the process
took a while but when I tested the read, it just finished straight away.
Dispalying newly created users from last login
Dispalying newly created users from last login
I have installed the Members for Elgg 1.8 plugin in my Elgg application,
now I'm editing this plugin to display all the user that are created from
last admin login to current login.
but I'm not getting the expected results from the query that I have written.
Here is my index.php code
case 'lasttonow':
$db_prefix = elgg_get_config('dbprefix');
$joins = array("JOIN {$db_prefix}users_entity u on e.guid = u.guid");
$time = time();
$options['joins'] = $joins;
options['wheres'] = "e.time_created >= u.prev_last_login";
$options['order_by'] = "e.time_created DESC";
$content = elgg_list_entities_from_metadata($options);
break;
I'm not understanding where I'm doing mistake.
Thank You
I have installed the Members for Elgg 1.8 plugin in my Elgg application,
now I'm editing this plugin to display all the user that are created from
last admin login to current login.
but I'm not getting the expected results from the query that I have written.
Here is my index.php code
case 'lasttonow':
$db_prefix = elgg_get_config('dbprefix');
$joins = array("JOIN {$db_prefix}users_entity u on e.guid = u.guid");
$time = time();
$options['joins'] = $joins;
options['wheres'] = "e.time_created >= u.prev_last_login";
$options['order_by'] = "e.time_created DESC";
$content = elgg_list_entities_from_metadata($options);
break;
I'm not understanding where I'm doing mistake.
Thank You
how to serve website with apache over the internet?
how to serve website with apache over the internet?
I have somehow managed to serve both my project app and its static files
on the apache. But only I can see my webpage, by typing localhost and by
my IPv4 address. And I can't see my webpage from the other's computer. In
my http.conf, it is Listen 80. I don't know much about this. I even
registered on a free dynamic DNS provider, but even from that url I can
only see It works message. I really suck at these things. Please guide me
here. Thank you.
I have somehow managed to serve both my project app and its static files
on the apache. But only I can see my webpage, by typing localhost and by
my IPv4 address. And I can't see my webpage from the other's computer. In
my http.conf, it is Listen 80. I don't know much about this. I even
registered on a free dynamic DNS provider, but even from that url I can
only see It works message. I really suck at these things. Please guide me
here. Thank you.
Friday, 23 August 2013
autoindent is subset of smartindent in vim?
autoindent is subset of smartindent in vim?
:help autoindent : Copy indent from current line when starting a new line
(typing in Insert mode or when using the "o" or "O" command). ...
:help smartindent : Do smart autoindenting when starting a new line. Works
for C-like programs, but can also be used for other languages. ...
Normally 'autoindent' should also be on when using 'smartindent'. An
indent is automatically inserted:
After a line ending in '{'.
After a line starting with a keyword from 'cinwords'.
Before a line starting with '}' (only with the "O" command).
When typing '}' as the first character in a new line, that line is given
the same indent as the matching '{'. ...
smartindent also coping indent from current line when starting a new line.
That means autoindent feature is subset of smartindent feature and no need
of autoindent if smartindent is on, right? Why autoindent should be turn
on?
:help autoindent : Copy indent from current line when starting a new line
(typing in Insert mode or when using the "o" or "O" command). ...
:help smartindent : Do smart autoindenting when starting a new line. Works
for C-like programs, but can also be used for other languages. ...
Normally 'autoindent' should also be on when using 'smartindent'. An
indent is automatically inserted:
After a line ending in '{'.
After a line starting with a keyword from 'cinwords'.
Before a line starting with '}' (only with the "O" command).
When typing '}' as the first character in a new line, that line is given
the same indent as the matching '{'. ...
smartindent also coping indent from current line when starting a new line.
That means autoindent feature is subset of smartindent feature and no need
of autoindent if smartindent is on, right? Why autoindent should be turn
on?
c# text box "between" validation
c# text box "between" validation
I would like to have a text box validate if the entry is a number between
1 and 100.
Example: if (textBox.Text is equal to numbers between 1 and 100) { do
this; } else { do this; }
This is form validation for a trackbar used for jpeg compression and can
only have numeric values between 1 and 100.
I would like to have a text box validate if the entry is a number between
1 and 100.
Example: if (textBox.Text is equal to numbers between 1 and 100) { do
this; } else { do this; }
This is form validation for a trackbar used for jpeg compression and can
only have numeric values between 1 and 100.
USB keyboard only works intermittently in GRUB 2 on reboots - how to make it work consistently?
USB keyboard only works intermittently in GRUB 2 on reboots - how to make
it work consistently?
Something weird is going on with my keyboard. The keyboard is a
USB-connected Unicomp, which works absolutely flawlessly once the computer
is up and running. However, GRUB 2 (specifically, 1.99-27+deb7u1 as
shipped in Debian Wheezy) isn't quite so happy. The failure modes make
this a little difficult to test, but here's what I've been able to deduce
thus far:
The keyboard status LEDs flash during the POST, so the keyboard is
detected (I also get a report "Detected: ... 1 Keyboard"); I've got maybe
one "no keyboard detected" error from the POST, nowhere near enough to
deduce any pattern to that, and I've been rebooting the system quite a few
times in different ways lately
On a power on from a full power off with the front panel power button,
everything seems to work great
On a reboot (either using reboot or Control+Alt+Delete in a booted system
or in GRUB), the keyboard works in GRUB maybe every other time I try
If I hit the Reset button on the computer to reboot, the keyboard
consistently does not work in GRUB when the boot loader comes back, and
many times does not react to key presses during the POST either
What's even more weird is that I don't recall the computer acting like
this before. I'm hoping it's unrelated, but it seems to have started
acting up right around when I hooked up the UPS to some more things around
my desk, instead of only having hooked it up to the computer and monitor.
(No, the UPS is nowhere near overloaded; the load is reported as being in
the range 7-20% depending on usage; around 15-16% of maximum load when the
computer is up and running normally.)
I've Googled and found the suggestion to load the GRUB 2 modules uhci and
usb_keyboard. I added a GRUB_PRELOAD_MODULES declaration specifying the
two of them to /etc/default/grub and re-ran update-grub (there is now
insmod uhci and insmod usb_keyboard in my /boot/grub/grub.cfg), but that
does not seem to have changed anything.
I've moved the keyboard to another USB port, which does not appear to have
helped. I would try an offboard USB controller if I had one handy.
BIOS/UEFI setup reports legacy USB support and legacy USB 3.0 support as
enabled, and even if it didn't, I don't see why it would sometimes work
and sometimes not, especially when many times the only difference between
the two is which side of a warm reboot it's on.
The motherboard is an ASUS M5A97 Pro with UEFI version 1007 02/10/2012.
I can't think of any other configuration changes I've done that coincide
with when the computer started acting up. The logs do mention an upgrade
of linux-image on Aug 1, and that I reinstalled (it's noted as upgrade,
but the from-version and to-version are identical) grub-pc on Aug 2, but
both of those was a week before I even bought the UPS, and two weeks
before I hooked it up to more than just the computer and monitor (I take
care to not change too many things at once). uname -r reports
3.2.0-4-amd64.
I'm running out of ideas to try. How can I get my USB keyboard to work
consistently in GRUB 2? What else can I check?
it work consistently?
Something weird is going on with my keyboard. The keyboard is a
USB-connected Unicomp, which works absolutely flawlessly once the computer
is up and running. However, GRUB 2 (specifically, 1.99-27+deb7u1 as
shipped in Debian Wheezy) isn't quite so happy. The failure modes make
this a little difficult to test, but here's what I've been able to deduce
thus far:
The keyboard status LEDs flash during the POST, so the keyboard is
detected (I also get a report "Detected: ... 1 Keyboard"); I've got maybe
one "no keyboard detected" error from the POST, nowhere near enough to
deduce any pattern to that, and I've been rebooting the system quite a few
times in different ways lately
On a power on from a full power off with the front panel power button,
everything seems to work great
On a reboot (either using reboot or Control+Alt+Delete in a booted system
or in GRUB), the keyboard works in GRUB maybe every other time I try
If I hit the Reset button on the computer to reboot, the keyboard
consistently does not work in GRUB when the boot loader comes back, and
many times does not react to key presses during the POST either
What's even more weird is that I don't recall the computer acting like
this before. I'm hoping it's unrelated, but it seems to have started
acting up right around when I hooked up the UPS to some more things around
my desk, instead of only having hooked it up to the computer and monitor.
(No, the UPS is nowhere near overloaded; the load is reported as being in
the range 7-20% depending on usage; around 15-16% of maximum load when the
computer is up and running normally.)
I've Googled and found the suggestion to load the GRUB 2 modules uhci and
usb_keyboard. I added a GRUB_PRELOAD_MODULES declaration specifying the
two of them to /etc/default/grub and re-ran update-grub (there is now
insmod uhci and insmod usb_keyboard in my /boot/grub/grub.cfg), but that
does not seem to have changed anything.
I've moved the keyboard to another USB port, which does not appear to have
helped. I would try an offboard USB controller if I had one handy.
BIOS/UEFI setup reports legacy USB support and legacy USB 3.0 support as
enabled, and even if it didn't, I don't see why it would sometimes work
and sometimes not, especially when many times the only difference between
the two is which side of a warm reboot it's on.
The motherboard is an ASUS M5A97 Pro with UEFI version 1007 02/10/2012.
I can't think of any other configuration changes I've done that coincide
with when the computer started acting up. The logs do mention an upgrade
of linux-image on Aug 1, and that I reinstalled (it's noted as upgrade,
but the from-version and to-version are identical) grub-pc on Aug 2, but
both of those was a week before I even bought the UPS, and two weeks
before I hooked it up to more than just the computer and monitor (I take
care to not change too many things at once). uname -r reports
3.2.0-4-amd64.
I'm running out of ideas to try. How can I get my USB keyboard to work
consistently in GRUB 2? What else can I check?
How setup Varnish, Nginx and Apache and APC?
How setup Varnish, Nginx and Apache and APC?
On Ubuntu 13.04 I've installed Varnish, Nginx, Apache and APC. It's one
server with one IP address using php-fpm.
I was able to successfully set it up to do CloudFlare > Varnish > Nginx >
Wordpress/APC for domains on the server.
However some domains on the same server I want to be able to serve using
CloudFlare > Varnish > Nginx Reverse Proxy > Apache > WordPress/APC.
While I know how to do one or the other, I'm unsure concept wise how I
would be able to do both at the same time.
Presumably, Varnish would listen on port 80 for all domains. But then some
domains such as example1.com and example2.com would need to use just
nginx. While other domains such as example3.com and example4.com would
need to use nginx reverse proxy and pushed to Apache.
On StackOverflow people noted this should be possible, but now posting
here to get help with how to actually do it on Ubuntu. Most importantly
the theory aka which ports each server should be listening for and such.
If there is actually no way to do this easily with one IP but would be
possible with two IP's on one server I'd be open to hearing how that would
work instead?
On Ubuntu 13.04 I've installed Varnish, Nginx, Apache and APC. It's one
server with one IP address using php-fpm.
I was able to successfully set it up to do CloudFlare > Varnish > Nginx >
Wordpress/APC for domains on the server.
However some domains on the same server I want to be able to serve using
CloudFlare > Varnish > Nginx Reverse Proxy > Apache > WordPress/APC.
While I know how to do one or the other, I'm unsure concept wise how I
would be able to do both at the same time.
Presumably, Varnish would listen on port 80 for all domains. But then some
domains such as example1.com and example2.com would need to use just
nginx. While other domains such as example3.com and example4.com would
need to use nginx reverse proxy and pushed to Apache.
On StackOverflow people noted this should be possible, but now posting
here to get help with how to actually do it on Ubuntu. Most importantly
the theory aka which ports each server should be listening for and such.
If there is actually no way to do this easily with one IP but would be
possible with two IP's on one server I'd be open to hearing how that would
work instead?
Vertical Smooth Div Scrolling
Vertical Smooth Div Scrolling
I would like to use the Smooth Div Scrolling
(http://www.smoothdivscroll.com/index.html#toc) just like in the example
but I need it to smoothly scroll vertically not horizontally.
I would like to use the Smooth Div Scrolling
(http://www.smoothdivscroll.com/index.html#toc) just like in the example
but I need it to smoothly scroll vertically not horizontally.
Stretch a ViewGroup to its contents in Android
Stretch a ViewGroup to its contents in Android
I have a customized ViewGroup with some items inside. I would like to
height of the ViewGroup to be stretched as long as possible to fit the
contents. How can I achieve this?
NOTE: I have already tried with android:layout_height="wrap_content"
without success.
I have a customized ViewGroup with some items inside. I would like to
height of the ViewGroup to be stretched as long as possible to fit the
contents. How can I achieve this?
NOTE: I have already tried with android:layout_height="wrap_content"
without success.
Thursday, 22 August 2013
RDLC Visual Studio 2010: how to add "terms and conditions" subreport to be displayed/printed on even pages
RDLC Visual Studio 2010: how to add "terms and conditions" subreport to be
displayed/printed on even pages
I have to add "Terms and Conditions" subreport to be printed or displayed
on even pages to the rdlc report. I can add subreport to tablix only on
Body section using grouping, but have no luck to set a hidden condition as
do not have access to PageNumber. Any help would be appreciated!
displayed/printed on even pages
I have to add "Terms and Conditions" subreport to be printed or displayed
on even pages to the rdlc report. I can add subreport to tablix only on
Body section using grouping, but have no luck to set a hidden condition as
do not have access to PageNumber. Any help would be appreciated!
Having error in deletion of data in my database via php
Having error in deletion of data in my database via php
Hello so i just found out this program to delete information from the
database so i am getting some error some help would be appreciated This
code is for deleting data in database via php script this should work like
this when we enter employee id then the id should be deleted but i doesn't
delete and shows some error
<html>
<head>
<title>Delete a Record from MySQL Database</title>
</head>
<body>
<?php
if(isset($_POST['delete']))
{
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$emp_id = $_POST['emp_id'];
$sql = "DELETE employee ".
"WHERE emp_id = $emp_id" ;
mysql_select_db('test');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not delete data: ' . mysql_error());
}
echo "Deleted data successfully\n";
mysql_close($conn);
}
else
{
?>
<form method="post" action="<?php $_PHP_SELF ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Employee ID</td>
<td><input name="emp_id" type="text" id="emp_id"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<input name="delete" type="submit" id="delete" value="Delete">
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
Could not delete data: You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax
to use near 'WHERE emp_id = 1' at line 1
So i get this error can someone tell me
Hello so i just found out this program to delete information from the
database so i am getting some error some help would be appreciated This
code is for deleting data in database via php script this should work like
this when we enter employee id then the id should be deleted but i doesn't
delete and shows some error
<html>
<head>
<title>Delete a Record from MySQL Database</title>
</head>
<body>
<?php
if(isset($_POST['delete']))
{
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$emp_id = $_POST['emp_id'];
$sql = "DELETE employee ".
"WHERE emp_id = $emp_id" ;
mysql_select_db('test');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not delete data: ' . mysql_error());
}
echo "Deleted data successfully\n";
mysql_close($conn);
}
else
{
?>
<form method="post" action="<?php $_PHP_SELF ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Employee ID</td>
<td><input name="emp_id" type="text" id="emp_id"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<input name="delete" type="submit" id="delete" value="Delete">
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
Could not delete data: You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax
to use near 'WHERE emp_id = 1' at line 1
So i get this error can someone tell me
indent/pretty-printing utility for System Verilog
indent/pretty-printing utility for System Verilog
Not properly a programming question, but is anybody aware of a open source
indent (similar to gnu indent or astyle) capable of indenting System
Verilog?
More sophisticated pretty-printing (such as aligning assignments or
reformatting source to fit 80 character lines) would be very nice to have,
but basic indentation would already be useful.
Not properly a programming question, but is anybody aware of a open source
indent (similar to gnu indent or astyle) capable of indenting System
Verilog?
More sophisticated pretty-printing (such as aligning assignments or
reformatting source to fit 80 character lines) would be very nice to have,
but basic indentation would already be useful.
Does Yum have an equivalent to apt / aptitude's DEBIAN_FRONTEND=noninteractive?
Does Yum have an equivalent to apt / aptitude's
DEBIAN_FRONTEND=noninteractive?
On Ubuntu you can use something like this:
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get update
Which will prevent things that require input (choosing grub versions or
conflicts between configuration files, or even prompting for a mysql root
password during install)
I checked the man page for yum but didn't see anything related to
non-interactive usage other than check-update which "Returns exit value of
100 if there are packages available for an update"
Does Yum have an equivalent to apt / aptitude's
DEBIAN_FRONTEND=noninteractive ?
DEBIAN_FRONTEND=noninteractive?
On Ubuntu you can use something like this:
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get update
Which will prevent things that require input (choosing grub versions or
conflicts between configuration files, or even prompting for a mysql root
password during install)
I checked the man page for yum but didn't see anything related to
non-interactive usage other than check-update which "Returns exit value of
100 if there are packages available for an update"
Does Yum have an equivalent to apt / aptitude's
DEBIAN_FRONTEND=noninteractive ?
VS2003 Build on Command Line Throws Errors
VS2003 Build on Command Line Throws Errors
I am trying to do an automated build using the command line for Visual
Studio 2003. I have the following codes:
call "C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Tools\vsvars32.bat"
Devenv /rebuild debug /project Project1 "C:\Builds\MyApp\Sample.sln"
Devenv /rebuild debug /project Project2 "C:\Builds\MyApp\Sample.sln"
Devenv /rebuild debug /project Project3 "C:\Builds\MyApp\Sample.sln"
In my script above, I build each project individually (like I saw in a
tutorial on the internet). But each time I try to build, it throws me a
lot of errors about the Microsoft Namespaces not being found. Below are
sample error messages I get on the build:
Namespace or type 'Data' for the Imports
'Microsoft.Practices.EnterpriseLibrary.Data' cannot be found.
Namespace or type 'Sql' for the Imports
'Microsoft.Practices.EnterpriseLibrary.Data.Sql' cannot be found.
Namespace or type 'Logging' for the Imports
'Microsoft.Practices.EnterpriseLibrary.Logging' cannot be found.
Satellite assemblies could not be built because the main project
output is missing.
I have tried another method to build but this time it's the entire
solution but still it gives me the same errors.
call "C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Tools\vsvars32.bat"
Devenv C:\Builds\MyApp\Sample.sln /rebuild "Debug"
Can somebody please tell me what i'm missing? I have over 50 projects in a
single solution and it would really help me big time to create an
automated build for this.
Thanks a lot! Cheers!
I am trying to do an automated build using the command line for Visual
Studio 2003. I have the following codes:
call "C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Tools\vsvars32.bat"
Devenv /rebuild debug /project Project1 "C:\Builds\MyApp\Sample.sln"
Devenv /rebuild debug /project Project2 "C:\Builds\MyApp\Sample.sln"
Devenv /rebuild debug /project Project3 "C:\Builds\MyApp\Sample.sln"
In my script above, I build each project individually (like I saw in a
tutorial on the internet). But each time I try to build, it throws me a
lot of errors about the Microsoft Namespaces not being found. Below are
sample error messages I get on the build:
Namespace or type 'Data' for the Imports
'Microsoft.Practices.EnterpriseLibrary.Data' cannot be found.
Namespace or type 'Sql' for the Imports
'Microsoft.Practices.EnterpriseLibrary.Data.Sql' cannot be found.
Namespace or type 'Logging' for the Imports
'Microsoft.Practices.EnterpriseLibrary.Logging' cannot be found.
Satellite assemblies could not be built because the main project
output is missing.
I have tried another method to build but this time it's the entire
solution but still it gives me the same errors.
call "C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Tools\vsvars32.bat"
Devenv C:\Builds\MyApp\Sample.sln /rebuild "Debug"
Can somebody please tell me what i'm missing? I have over 50 projects in a
single solution and it would really help me big time to create an
automated build for this.
Thanks a lot! Cheers!
java.lang.IllegalStateException: GameHelper: operation attempted at incorrect state
java.lang.IllegalStateException: GameHelper: operation attempted at
incorrect state
I'm getting the following exception using GameHelper class from Google
Play Games Services.
java.lang.IllegalStateException: GameHelper: operation attempted at
incorrect state.
Operation: succeedSignIn. State: DISCONNECTED. Expected states: CONNECTING
CONNECTED.
at ru.funapps.games.frutcoctail.GameHelper.assertState(GameHelper.java:185)
at ru.funapps.games.frutcoctail.GameHelper.succeedSignIn(GameHelper.java:781)
at
ru.funapps.games.frutcoctail.GameHelper.connectNextClient(GameHelper.java:678)
at ru.funapps.games.frutcoctail.GameHelper.onConnected(GameHelper.java:777)
at com.google.android.gms.internal.u.v(Unknown Source)
at com.google.android.gms.internal.bp.v(Unknown Source)
at com.google.android.gms.internal.u$f.a(Unknown Source)
at com.google.android.gms.internal.u$f.a(Unknown Source)
at com.google.android.gms.internal.u$b.A(Unknown Source)
at com.google.android.gms.internal.u$a.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4511)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:976)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:743)
at dalvik.system.NativeStart.main(Native Method)
incorrect state
I'm getting the following exception using GameHelper class from Google
Play Games Services.
java.lang.IllegalStateException: GameHelper: operation attempted at
incorrect state.
Operation: succeedSignIn. State: DISCONNECTED. Expected states: CONNECTING
CONNECTED.
at ru.funapps.games.frutcoctail.GameHelper.assertState(GameHelper.java:185)
at ru.funapps.games.frutcoctail.GameHelper.succeedSignIn(GameHelper.java:781)
at
ru.funapps.games.frutcoctail.GameHelper.connectNextClient(GameHelper.java:678)
at ru.funapps.games.frutcoctail.GameHelper.onConnected(GameHelper.java:777)
at com.google.android.gms.internal.u.v(Unknown Source)
at com.google.android.gms.internal.bp.v(Unknown Source)
at com.google.android.gms.internal.u$f.a(Unknown Source)
at com.google.android.gms.internal.u$f.a(Unknown Source)
at com.google.android.gms.internal.u$b.A(Unknown Source)
at com.google.android.gms.internal.u$a.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4511)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:976)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:743)
at dalvik.system.NativeStart.main(Native Method)
Visual Studio 2010 Package Hide Button in context menu
Visual Studio 2010 Package Hide Button in context menu
I created Package in Visual Studio to extend TFS functionality by my own
workitem printing (TFS printing is very bad). I placed it using following
guid/id: 2DC8D6BB-916C-4B80-9C52-FD8FC371ACC2/517, so my functionality
appears when you right-click on workitem(s) in query results list. But in
the same place there is this bad TFS print button. Is there any way to
hide that button, so that user could choose only my printing??
Regards
I created Package in Visual Studio to extend TFS functionality by my own
workitem printing (TFS printing is very bad). I placed it using following
guid/id: 2DC8D6BB-916C-4B80-9C52-FD8FC371ACC2/517, so my functionality
appears when you right-click on workitem(s) in query results list. But in
the same place there is this bad TFS print button. Is there any way to
hide that button, so that user could choose only my printing??
Regards
Wednesday, 21 August 2013
How to Implement Command Line CURL into PHP CURL Request
How to Implement Command Line CURL into PHP CURL Request
I want to Implement following Command Line CURL into PHP CURL Request.
curl --data username=ekansh&domain=siteURL&password=mypass
http://siteURL:8090/add-user -k -v -u apiuser:yru3472825fhj
I have tried below code for the same:
$fields = array('domain'=> 'siteURL','password'=> 'mypass','apiuser'=>
'yru3472825fhj','username'=> 'ekansh');
$data=>array(CURLOPT_POST => 1,CURLOPT_HEADER => 0,CURLOPT_URL =>
$url,CURLOPT_FRESH_CONNECT => 1,CURLOPT_RETURNTRANSFER =>
1,CURLOPT_FORBID_REUSE =>
1,CURLOPT_TIMEOUT => 4,CURLOPT_POSTFIELDS => http_build_query($_POST));
$ch = curl_init();
$options=$fields+$defaults;
curl_setopt_array($ch,$options);
$result=curl_exec($ch)
curl_close($ch);
But this is not working .. i am not getting any response in $result. How
could i will implement above code?
I want to Implement following Command Line CURL into PHP CURL Request.
curl --data username=ekansh&domain=siteURL&password=mypass
http://siteURL:8090/add-user -k -v -u apiuser:yru3472825fhj
I have tried below code for the same:
$fields = array('domain'=> 'siteURL','password'=> 'mypass','apiuser'=>
'yru3472825fhj','username'=> 'ekansh');
$data=>array(CURLOPT_POST => 1,CURLOPT_HEADER => 0,CURLOPT_URL =>
$url,CURLOPT_FRESH_CONNECT => 1,CURLOPT_RETURNTRANSFER =>
1,CURLOPT_FORBID_REUSE =>
1,CURLOPT_TIMEOUT => 4,CURLOPT_POSTFIELDS => http_build_query($_POST));
$ch = curl_init();
$options=$fields+$defaults;
curl_setopt_array($ch,$options);
$result=curl_exec($ch)
curl_close($ch);
But this is not working .. i am not getting any response in $result. How
could i will implement above code?
How to stub an object's __call__ method?
How to stub an object's __call__ method?
I'm using Nose and Fudge for unit testing. Consider the following class:
class Foo():
def __init__(self, some_commandline):
self._some_commandline = commandline
def process(self):
stdout, stderr = self._commandline()
...
And a test:
def test_process_commandline(self):
import StringIO
# Setup
fake_stdout = StringIO.StringIO()
fake_stderr = StringIO.StringIO()
fake_stdio = fake_stdout, fake_stderr
fake_cline = (fudge
.Fake('SomeCommandline')
.is_a_stub()
.provides('__call__')
.returns(fake_stdio))
sut = Foo(fake_cline)
# Exercise
sut.process()
# Verify
...
The error I get is:
...
stdout, stderr = self._commandline()
TypeError: 'Fake' object is not iterable
The code I'm stubbing has a return line that looks like this (the real
version of "SomeCommandline")
return stdout_str, stderr_str
Why am I getting the TypeError saying Fake is not iterable, and how do i
stub this method with fudge?
I'm using Nose and Fudge for unit testing. Consider the following class:
class Foo():
def __init__(self, some_commandline):
self._some_commandline = commandline
def process(self):
stdout, stderr = self._commandline()
...
And a test:
def test_process_commandline(self):
import StringIO
# Setup
fake_stdout = StringIO.StringIO()
fake_stderr = StringIO.StringIO()
fake_stdio = fake_stdout, fake_stderr
fake_cline = (fudge
.Fake('SomeCommandline')
.is_a_stub()
.provides('__call__')
.returns(fake_stdio))
sut = Foo(fake_cline)
# Exercise
sut.process()
# Verify
...
The error I get is:
...
stdout, stderr = self._commandline()
TypeError: 'Fake' object is not iterable
The code I'm stubbing has a return line that looks like this (the real
version of "SomeCommandline")
return stdout_str, stderr_str
Why am I getting the TypeError saying Fake is not iterable, and how do i
stub this method with fudge?
add html in jquery and use jquery on new html
add html in jquery and use jquery on new html
i am trying to add html using jquery and than i want to do actions
according to the new added html. Here is the example what i am trying to
do..
This is my html
<div id='area'></div>
i use this jquery command to add html in this section
$("#area").html('<p id="mynewid">my text</p>');
now i want to add text in p tag and i used this command
$("#mynewid").click(function() {
$(this).html("my 2nd new text");
});
But it's not working...
i am trying to add html using jquery and than i want to do actions
according to the new added html. Here is the example what i am trying to
do..
This is my html
<div id='area'></div>
i use this jquery command to add html in this section
$("#area").html('<p id="mynewid">my text</p>');
now i want to add text in p tag and i used this command
$("#mynewid").click(function() {
$(this).html("my 2nd new text");
});
But it's not working...
Object controll with mouse position relative to circle
Object controll with mouse position relative to circle
Need some inspiration. I've got a picture (blue) and want it to move
proportional to the mouse position inside an invisible area (orange). So,
if the mouse moves in top-left direction, the image should follow the
movement.
I don't want to simply copy the mouse position, rather create an Joystick
like behaviour, so if the mouse moves, the image should move stepwise in
the desired direction.
But how? I've no idea how to set the right x+y coordinates for the image
or how to establish a formula to calculate them.
Need some inspiration. I've got a picture (blue) and want it to move
proportional to the mouse position inside an invisible area (orange). So,
if the mouse moves in top-left direction, the image should follow the
movement.
I don't want to simply copy the mouse position, rather create an Joystick
like behaviour, so if the mouse moves, the image should move stepwise in
the desired direction.
But how? I've no idea how to set the right x+y coordinates for the image
or how to establish a formula to calculate them.
How can I get my graphic to move without lag or without slowing down?
How can I get my graphic to move without lag or without slowing down?
I have a game where a ball(circle graphic moves around the form. It moves
based on a timer that ticks every 8 milliseconds. The problem is that
after a few seconds the ball slows down a lot. How can i stop the ball
from slowing down and keep it going at the same pace.
move.Stop();//Prevents a queue of events
//Moves the ball
ballGraphic.Location = new Point(ballGraphic.Location.X +
ball.xVelocity(), ballGraphic.Location.Y + ball.yVelocity())
I have a game where a ball(circle graphic moves around the form. It moves
based on a timer that ticks every 8 milliseconds. The problem is that
after a few seconds the ball slows down a lot. How can i stop the ball
from slowing down and keep it going at the same pace.
move.Stop();//Prevents a queue of events
//Moves the ball
ballGraphic.Location = new Point(ballGraphic.Location.X +
ball.xVelocity(), ballGraphic.Location.Y + ball.yVelocity())
mysql avg on multiple inner join
mysql avg on multiple inner join
I have the following query:
SELECT ROUND(AVG( p.price ),2) as Avg_value
FROM quotes
inner join `system_users`
ON quotes.created_by = system_users.id
inner join quote_items s
ON s.quote_id = quotes.id
inner join new_products p
ON p.id = new_product_id
how do you determine what the average is being based on seeing that: a
system user can have many quotes and a quote can have many quote items
each quote item has one product.
I'd like the average to be based on the number of quotes. how would the
query have to be changed for it to be based on the number of quote_items
Thanks
I have the following query:
SELECT ROUND(AVG( p.price ),2) as Avg_value
FROM quotes
inner join `system_users`
ON quotes.created_by = system_users.id
inner join quote_items s
ON s.quote_id = quotes.id
inner join new_products p
ON p.id = new_product_id
how do you determine what the average is being based on seeing that: a
system user can have many quotes and a quote can have many quote items
each quote item has one product.
I'd like the average to be based on the number of quotes. how would the
query have to be changed for it to be based on the number of quote_items
Thanks
Should we treat "information" as a plural term in the following context?
Should we treat "information" as a plural term in the following context?
I'm writing a thesis on web information extraction. I use the term
information a lot in my thesis, but I'm not sure I should treat it as a
plural term or singular term. The following are some cases where I have
doubt.
How are faculty member information presented in web pages?
Information extracted from multiple sources are integrated based on some
rules.
As you can see from the examples, I use it as a plural term in the
context. However, I don't feel right when I actually read it. Anyone
please shed some light on this?
I'm writing a thesis on web information extraction. I use the term
information a lot in my thesis, but I'm not sure I should treat it as a
plural term or singular term. The following are some cases where I have
doubt.
How are faculty member information presented in web pages?
Information extracted from multiple sources are integrated based on some
rules.
As you can see from the examples, I use it as a plural term in the
context. However, I don't feel right when I actually read it. Anyone
please shed some light on this?
Tuesday, 20 August 2013
Difference between 2 lbs(pound) values
Difference between 2 lbs(pound) values
I need a suggestion in finding difference between two lbs(pound) values. I
tried in 2 ways,
First way,
var pound1 = 151.10;
var pound2 = 142.19;
var finalPoundValue = (151.10 - 142.19);
// result 8.91 -> 8 Pounds 91 Ounce
Second way,
var value1 = 151.10;
var value2 = 142.19;
var poundDiff = (151 - 142);
var ounceDiff = (10 - 19);
// result 9 Pounds -9 Ounce
but, don't know which one is the right way to find difference between
pound values. Or any other best method available to solve this problem..?
I need a suggestion in finding difference between two lbs(pound) values. I
tried in 2 ways,
First way,
var pound1 = 151.10;
var pound2 = 142.19;
var finalPoundValue = (151.10 - 142.19);
// result 8.91 -> 8 Pounds 91 Ounce
Second way,
var value1 = 151.10;
var value2 = 142.19;
var poundDiff = (151 - 142);
var ounceDiff = (10 - 19);
// result 9 Pounds -9 Ounce
but, don't know which one is the right way to find difference between
pound values. Or any other best method available to solve this problem..?
I am creating a simple database that controls my company's stock
I am creating a simple database that controls my company's stock
We have already have a CRM software but it doesn't have stock control
ability. I am thinking to create another database from central MSSQL
server which has a table of list of product, price, quantity and other
information. In addition, we want to generate a monthly, quarterly and
annual report of our stock.
So I am thinking to create a table monthly named as e.g. 201308, 201309..
201312.. 201405.... Every time when I need to do reporting, I can
consolidate multiple tables into a pivot table in excel to do some
analysis.
Basically, this is my idea. I don't know the best practice is in this
scenario.
Can anyone give me some advices?
We have already have a CRM software but it doesn't have stock control
ability. I am thinking to create another database from central MSSQL
server which has a table of list of product, price, quantity and other
information. In addition, we want to generate a monthly, quarterly and
annual report of our stock.
So I am thinking to create a table monthly named as e.g. 201308, 201309..
201312.. 201405.... Every time when I need to do reporting, I can
consolidate multiple tables into a pivot table in excel to do some
analysis.
Basically, this is my idea. I don't know the best practice is in this
scenario.
Can anyone give me some advices?
Symfony 2.3 how do you group the buttons together in one form group?
Symfony 2.3 how do you group the buttons together in one form group?
Right now i have a FormType that contains the following:
$builder->add('name','text')
->add('save','submit',array('label'=>'Save',
'attr'=>array('class'=>'btn btn-primary')))
->add('reset','reset',array('label'=>'Reset Form',
'attr'=>array('class'=>'btn btn-warning')));
Right now i have a little bit of form themeing going on that renders the
above as:
<form method="post" action="">
<input type="hidden" name="_csrf_token" value="*********" />
<div class="form-group">
<label class="col-4">Name</label>
<input type="text" name="form[name]" value="" placeholder="Name" />
</div>
<div class="form-group">
<input type="submit" name="form[save]" value="Save" class="btn
btn-primary" />
</div>
<div class="form-group">
<input type="reset" name="form[reset]" value="Reset" class="btn
btn-warning" />
</div>
</form>
However what I would like the output to be is:
<form method="post" action="">
<input type="hidden" name="_csrf_token" value="*********" />
<div class="form-group">
<label class="col-4">Name</label>
<input type="text" name="form[name]" value="" placeholder="Name" />
</div>
<div class="form-group">
<input type="submit" name="form[save]" value="Save" class="btn
btn-primary" />
<input type="reset" name="form[reset]" value="Reset" class="btn
btn-warning" />
</div>
</form>
Notice the buttons are in the same form group wrapper div. I want to know
if there is a way to do this using only the FormType or editing the Form
Theme. I dont want to change the views from using:
{{ form(form,{'method':'POST','attr':{'class':'form-horizontal'} }) }}
I am aware this can be accomplished if I render the buttons from the form
in a custom manner.
Right now i have a FormType that contains the following:
$builder->add('name','text')
->add('save','submit',array('label'=>'Save',
'attr'=>array('class'=>'btn btn-primary')))
->add('reset','reset',array('label'=>'Reset Form',
'attr'=>array('class'=>'btn btn-warning')));
Right now i have a little bit of form themeing going on that renders the
above as:
<form method="post" action="">
<input type="hidden" name="_csrf_token" value="*********" />
<div class="form-group">
<label class="col-4">Name</label>
<input type="text" name="form[name]" value="" placeholder="Name" />
</div>
<div class="form-group">
<input type="submit" name="form[save]" value="Save" class="btn
btn-primary" />
</div>
<div class="form-group">
<input type="reset" name="form[reset]" value="Reset" class="btn
btn-warning" />
</div>
</form>
However what I would like the output to be is:
<form method="post" action="">
<input type="hidden" name="_csrf_token" value="*********" />
<div class="form-group">
<label class="col-4">Name</label>
<input type="text" name="form[name]" value="" placeholder="Name" />
</div>
<div class="form-group">
<input type="submit" name="form[save]" value="Save" class="btn
btn-primary" />
<input type="reset" name="form[reset]" value="Reset" class="btn
btn-warning" />
</div>
</form>
Notice the buttons are in the same form group wrapper div. I want to know
if there is a way to do this using only the FormType or editing the Form
Theme. I dont want to change the views from using:
{{ form(form,{'method':'POST','attr':{'class':'form-horizontal'} }) }}
I am aware this can be accomplished if I render the buttons from the form
in a custom manner.
ListView in Child Fragment with backStack is not refreshing but appending
ListView in Child Fragment with backStack is not refreshing but appending
In my application, there are some fragments and I maintain a backstack for
them. I resume those fragment whenever possible. fragments are resuming
successfully and other operations are also performed properly. But problem
is- one of them is a nested-fragment and it has a child-fragment inside it
which is extending a listFragment.
Everytime when I resume this fragment, the listview inside the
child-fragmnet is not recreating. Rather than it appending the same
elements below. I mean if there are 5 list-items in real, everytime after
resuming there will be 5 more same items at the end.
I have notifyDataSetChanged() but it is not working. This is my
child-fragment code:
public class ChaptersListFragment extends SherlockListFragment {
OnChapterSelectListener mCallback;
ArrayAdapter<String> mAdapter = null;
public interface OnChapterSelectListener {
public void onChapterSelected(int position);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (mAdapter != null)
mAdapter.clear(); // I try this but not working
List<String> items = new ArrayList<String>();
for (int i = 0; i < CompetitiveProgramming.chapterList.size(); i++) {
items.add(CompetitiveProgramming.chapterList.get(i).chapterTitle);
}
mAdapter = new ArrayAdapter<String>(getSherlockActivity(),
R.layout.list_layout, items);
mAdapter.notifyDataSetChanged(); // I try this but not working
setListAdapter(mAdapter);
}
@Override
public void onStart() {
super.onStart();
if
(getFragmentManager().findFragmentById(R.id.sub_category_fragment)
!= null) {
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
}
}
@Override
public void onResume() {
super.onResume();
mAdapter.notifyDataSetChanged();
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mCallback = (OnChapterSelectListener) getParentFragment();
} catch (ClassCastException e) {
throw new ClassCastException(getParentFragment().toString()
+ " must implement OnChapterSelectListener");
}
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
mCallback.onChapterSelected(position);
getListView().setItemChecked(position, true);
}
}
Moreover when I am changing the orientation, the listview is recreating
and there is only 5 items then. However, after resuming several times. the
application is crashed with the following logcat:
08-21 01:16:09.114: E/AndroidRuntime(664): FATAL EXCEPTION: main
08-21 01:16:09.114: E/AndroidRuntime(664):
java.lang.IllegalStateException: No activity
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1075)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1070)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1861)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1474)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:931)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.os.Handler.handleCallback(Handler.java:587)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.os.Looper.loop(Looper.java:123)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.app.ActivityThread.main(ActivityThread.java:4627)
08-21 01:16:09.114: E/AndroidRuntime(664): at
java.lang.reflect.Method.invokeNative(Native Method)
08-21 01:16:09.114: E/AndroidRuntime(664): at
java.lang.reflect.Method.invoke(Method.java:521)
08-21 01:16:09.114: E/AndroidRuntime(664): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-21 01:16:09.114: E/AndroidRuntime(664): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-21 01:16:09.114: E/AndroidRuntime(664): at
dalvik.system.NativeStart.main(Native Method)
And this the parent fragment which is holding the above child fragment:
public class CompetitiveProgramming extends SherlockProgressFragment
implements
OnChapterSelectListener, OnSubChapterSelectListener {
View mContentView;
static public List<Chapter> chapterList = new ArrayList<Chapter>();
private ProcessTask processTask = null;
Fragment chapterFragment = null;
Fragment subChapterFragment = null;
Fragment subSubChapterFragment = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setRetainInstance(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mContentView = inflater.inflate(
R.layout.competitive_programming_exercise, container, false);
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setContentShown(false);
setContentView(mContentView);
processTask = new ProcessTask();
processTask.execute();
}
protected class ProcessTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
InputStream inputStream = null;
try {
inputStream = getSherlockActivity().getAssets().open(
CommonUtils.FILE_COMPETITIVE_PROGRAMMING_3);
JsonReader reader = new JsonReader(new InputStreamReader(
inputStream));
reader.beginArray(); // array #1
while (reader.hasNext()) {
String chapterTitle = null;
List<SubChapter> subList = new ArrayList<SubChapter>();
reader.beginObject(); // object #2
while (reader.hasNext()) {
reader.skipValue();
chapterTitle = reader.nextString();
reader.skipValue();
reader.beginArray(); // array #3
while (reader.hasNext()) {
String subChapterTitle = null;
List<SubSubChapter> subSubList = new
ArrayList<SubSubChapter>();
reader.beginObject(); // object #4
while (reader.hasNext()) {
reader.skipValue();
subChapterTitle = reader.nextString();
reader.skipValue();
reader.beginArray(); // array #5
while (reader.hasNext()) {
reader.beginArray(); // array #6
String subSubChapterTitle = reader
.nextString(); //
sub-sub-category
// title
List<ProblemList> problemsList = new
ArrayList<ProblemList>();
while (reader.hasNext()) {
int signedProblemID =
reader.nextInt(); // problemNo
String title = reader.nextString();
if (signedProblemID < 0)
problemsList.add(new ProblemList(
Math.abs(signedProblemID),
title,
true));
else
problemsList.add(new ProblemList(
signedProblemID,
title, false));
}
reader.endArray(); // array #6
subSubList.add(new SubSubChapter(
subSubChapterTitle,
problemsList));
}
reader.endArray(); // array #5
}
reader.endObject(); // object #4
subList.add(new SubChapter(subChapterTitle,
subSubList));
}
reader.endArray(); // array #3
}
reader.endObject(); // object #2
chapterList.add(new Chapter(chapterTitle, subList));
}
reader.endArray(); // array #1
reader.close();
} catch (IOException e) {
// nothing
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// nothing
}
}
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
FragmentTransaction transaction = getChildFragmentManager()
.beginTransaction();
chapterFragment = new ChaptersListFragment();
if (mContentView.findViewById(R.id.fragment_container) != null) {
transaction.replace(R.id.fragment_container,
chapterFragment);
} else {
subChapterFragment = new SubChaptersListFragment();
subSubChapterFragment = new SubSubChaptersListFragment();
transaction.replace(R.id.category_fragment, chapterFragment);
transaction.replace(R.id.sub_category_fragment,
subChapterFragment);
transaction.replace(R.id.sub_sub_category_fragment,
subSubChapterFragment);
}
transaction.commit();
setContentShown(true);
}
}
static protected class Chapter {
String chapterTitle;
List<SubChapter> subchapterList;
public Chapter(String chapterTitle, List<SubChapter>
subchapterList) {
this.chapterTitle = chapterTitle;
this.subchapterList = subchapterList;
}
}
static protected class SubChapter {
String subChapterTitle;
List<SubSubChapter> subsubchapterList;
public SubChapter(String subChapterTitle,
List<SubSubChapter> subsubchapterList) {
this.subChapterTitle = subChapterTitle;
this.subsubchapterList = subsubchapterList;
}
}
static protected class SubSubChapter {
String subSubChapterTitle;
List<ProblemList> problemList;
public SubSubChapter(String subSubChapterTitle,
List<ProblemList> problemList) {
this.subSubChapterTitle = subSubChapterTitle;
this.problemList = problemList;
}
}
static public class ProblemList {
Integer problemNo;
String problemTitle;
boolean isStarred;
public ProblemList(Integer problemNo, String problemTitle, boolean
isStarred) {
this.problemNo = problemNo;
this.isStarred = isStarred;
this.problemTitle = problemTitle;
}
}
@Override
public void onChapterSelected(int position) {
SubChaptersListFragment subChaptersListFrag =
(SubChaptersListFragment) getChildFragmentManager()
.findFragmentById(R.id.sub_category_fragment);
if (subChaptersListFrag != null) {
subChaptersListFrag.updateList(position);
} else {
subChapterFragment = new SubChaptersListFragment();
Bundle args = new Bundle();
args.putInt(SubChaptersListFragment.CHAPTER_POSITION, position);
subChapterFragment.setArguments(args);
FragmentTransaction transaction = getChildFragmentManager()
.beginTransaction();
transaction.replace(R.id.fragment_container, subChapterFragment);
transaction.commit();
}
}
@Override
public void onSubChapterSelected(int prev, int position) {
SubSubChaptersListFragment subSubChaptersListFrag =
(SubSubChaptersListFragment) getChildFragmentManager()
.findFragmentById(R.id.sub_sub_category_fragment);
if (subSubChaptersListFrag != null) {
subSubChaptersListFrag.updateList(prev, position);
} else {
subSubChapterFragment = new SubSubChaptersListFragment();
Bundle args = new Bundle();
args.putIntArray(SubSubChaptersListFragment.POSITIONS, new
int[]{prev, position});
subSubChapterFragment.setArguments(args);
FragmentTransaction transaction = getChildFragmentManager()
.beginTransaction();
transaction.replace(R.id.fragment_container,
subSubChapterFragment);
transaction.commit();
}
}
@Override
public void onStop() {
super.onStop();
if (processTask != null && processTask.getStatus() !=
AsyncTask.Status.FINISHED) {
processTask.cancel(true);
}
}
}
How can I solve it? If any more code snippet is required, let me know in
comment :)
In my application, there are some fragments and I maintain a backstack for
them. I resume those fragment whenever possible. fragments are resuming
successfully and other operations are also performed properly. But problem
is- one of them is a nested-fragment and it has a child-fragment inside it
which is extending a listFragment.
Everytime when I resume this fragment, the listview inside the
child-fragmnet is not recreating. Rather than it appending the same
elements below. I mean if there are 5 list-items in real, everytime after
resuming there will be 5 more same items at the end.
I have notifyDataSetChanged() but it is not working. This is my
child-fragment code:
public class ChaptersListFragment extends SherlockListFragment {
OnChapterSelectListener mCallback;
ArrayAdapter<String> mAdapter = null;
public interface OnChapterSelectListener {
public void onChapterSelected(int position);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (mAdapter != null)
mAdapter.clear(); // I try this but not working
List<String> items = new ArrayList<String>();
for (int i = 0; i < CompetitiveProgramming.chapterList.size(); i++) {
items.add(CompetitiveProgramming.chapterList.get(i).chapterTitle);
}
mAdapter = new ArrayAdapter<String>(getSherlockActivity(),
R.layout.list_layout, items);
mAdapter.notifyDataSetChanged(); // I try this but not working
setListAdapter(mAdapter);
}
@Override
public void onStart() {
super.onStart();
if
(getFragmentManager().findFragmentById(R.id.sub_category_fragment)
!= null) {
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
}
}
@Override
public void onResume() {
super.onResume();
mAdapter.notifyDataSetChanged();
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mCallback = (OnChapterSelectListener) getParentFragment();
} catch (ClassCastException e) {
throw new ClassCastException(getParentFragment().toString()
+ " must implement OnChapterSelectListener");
}
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
mCallback.onChapterSelected(position);
getListView().setItemChecked(position, true);
}
}
Moreover when I am changing the orientation, the listview is recreating
and there is only 5 items then. However, after resuming several times. the
application is crashed with the following logcat:
08-21 01:16:09.114: E/AndroidRuntime(664): FATAL EXCEPTION: main
08-21 01:16:09.114: E/AndroidRuntime(664):
java.lang.IllegalStateException: No activity
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1075)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1070)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1861)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1474)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:931)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.os.Handler.handleCallback(Handler.java:587)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.os.Looper.loop(Looper.java:123)
08-21 01:16:09.114: E/AndroidRuntime(664): at
android.app.ActivityThread.main(ActivityThread.java:4627)
08-21 01:16:09.114: E/AndroidRuntime(664): at
java.lang.reflect.Method.invokeNative(Native Method)
08-21 01:16:09.114: E/AndroidRuntime(664): at
java.lang.reflect.Method.invoke(Method.java:521)
08-21 01:16:09.114: E/AndroidRuntime(664): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-21 01:16:09.114: E/AndroidRuntime(664): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-21 01:16:09.114: E/AndroidRuntime(664): at
dalvik.system.NativeStart.main(Native Method)
And this the parent fragment which is holding the above child fragment:
public class CompetitiveProgramming extends SherlockProgressFragment
implements
OnChapterSelectListener, OnSubChapterSelectListener {
View mContentView;
static public List<Chapter> chapterList = new ArrayList<Chapter>();
private ProcessTask processTask = null;
Fragment chapterFragment = null;
Fragment subChapterFragment = null;
Fragment subSubChapterFragment = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setRetainInstance(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mContentView = inflater.inflate(
R.layout.competitive_programming_exercise, container, false);
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setContentShown(false);
setContentView(mContentView);
processTask = new ProcessTask();
processTask.execute();
}
protected class ProcessTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
InputStream inputStream = null;
try {
inputStream = getSherlockActivity().getAssets().open(
CommonUtils.FILE_COMPETITIVE_PROGRAMMING_3);
JsonReader reader = new JsonReader(new InputStreamReader(
inputStream));
reader.beginArray(); // array #1
while (reader.hasNext()) {
String chapterTitle = null;
List<SubChapter> subList = new ArrayList<SubChapter>();
reader.beginObject(); // object #2
while (reader.hasNext()) {
reader.skipValue();
chapterTitle = reader.nextString();
reader.skipValue();
reader.beginArray(); // array #3
while (reader.hasNext()) {
String subChapterTitle = null;
List<SubSubChapter> subSubList = new
ArrayList<SubSubChapter>();
reader.beginObject(); // object #4
while (reader.hasNext()) {
reader.skipValue();
subChapterTitle = reader.nextString();
reader.skipValue();
reader.beginArray(); // array #5
while (reader.hasNext()) {
reader.beginArray(); // array #6
String subSubChapterTitle = reader
.nextString(); //
sub-sub-category
// title
List<ProblemList> problemsList = new
ArrayList<ProblemList>();
while (reader.hasNext()) {
int signedProblemID =
reader.nextInt(); // problemNo
String title = reader.nextString();
if (signedProblemID < 0)
problemsList.add(new ProblemList(
Math.abs(signedProblemID),
title,
true));
else
problemsList.add(new ProblemList(
signedProblemID,
title, false));
}
reader.endArray(); // array #6
subSubList.add(new SubSubChapter(
subSubChapterTitle,
problemsList));
}
reader.endArray(); // array #5
}
reader.endObject(); // object #4
subList.add(new SubChapter(subChapterTitle,
subSubList));
}
reader.endArray(); // array #3
}
reader.endObject(); // object #2
chapterList.add(new Chapter(chapterTitle, subList));
}
reader.endArray(); // array #1
reader.close();
} catch (IOException e) {
// nothing
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// nothing
}
}
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
FragmentTransaction transaction = getChildFragmentManager()
.beginTransaction();
chapterFragment = new ChaptersListFragment();
if (mContentView.findViewById(R.id.fragment_container) != null) {
transaction.replace(R.id.fragment_container,
chapterFragment);
} else {
subChapterFragment = new SubChaptersListFragment();
subSubChapterFragment = new SubSubChaptersListFragment();
transaction.replace(R.id.category_fragment, chapterFragment);
transaction.replace(R.id.sub_category_fragment,
subChapterFragment);
transaction.replace(R.id.sub_sub_category_fragment,
subSubChapterFragment);
}
transaction.commit();
setContentShown(true);
}
}
static protected class Chapter {
String chapterTitle;
List<SubChapter> subchapterList;
public Chapter(String chapterTitle, List<SubChapter>
subchapterList) {
this.chapterTitle = chapterTitle;
this.subchapterList = subchapterList;
}
}
static protected class SubChapter {
String subChapterTitle;
List<SubSubChapter> subsubchapterList;
public SubChapter(String subChapterTitle,
List<SubSubChapter> subsubchapterList) {
this.subChapterTitle = subChapterTitle;
this.subsubchapterList = subsubchapterList;
}
}
static protected class SubSubChapter {
String subSubChapterTitle;
List<ProblemList> problemList;
public SubSubChapter(String subSubChapterTitle,
List<ProblemList> problemList) {
this.subSubChapterTitle = subSubChapterTitle;
this.problemList = problemList;
}
}
static public class ProblemList {
Integer problemNo;
String problemTitle;
boolean isStarred;
public ProblemList(Integer problemNo, String problemTitle, boolean
isStarred) {
this.problemNo = problemNo;
this.isStarred = isStarred;
this.problemTitle = problemTitle;
}
}
@Override
public void onChapterSelected(int position) {
SubChaptersListFragment subChaptersListFrag =
(SubChaptersListFragment) getChildFragmentManager()
.findFragmentById(R.id.sub_category_fragment);
if (subChaptersListFrag != null) {
subChaptersListFrag.updateList(position);
} else {
subChapterFragment = new SubChaptersListFragment();
Bundle args = new Bundle();
args.putInt(SubChaptersListFragment.CHAPTER_POSITION, position);
subChapterFragment.setArguments(args);
FragmentTransaction transaction = getChildFragmentManager()
.beginTransaction();
transaction.replace(R.id.fragment_container, subChapterFragment);
transaction.commit();
}
}
@Override
public void onSubChapterSelected(int prev, int position) {
SubSubChaptersListFragment subSubChaptersListFrag =
(SubSubChaptersListFragment) getChildFragmentManager()
.findFragmentById(R.id.sub_sub_category_fragment);
if (subSubChaptersListFrag != null) {
subSubChaptersListFrag.updateList(prev, position);
} else {
subSubChapterFragment = new SubSubChaptersListFragment();
Bundle args = new Bundle();
args.putIntArray(SubSubChaptersListFragment.POSITIONS, new
int[]{prev, position});
subSubChapterFragment.setArguments(args);
FragmentTransaction transaction = getChildFragmentManager()
.beginTransaction();
transaction.replace(R.id.fragment_container,
subSubChapterFragment);
transaction.commit();
}
}
@Override
public void onStop() {
super.onStop();
if (processTask != null && processTask.getStatus() !=
AsyncTask.Status.FINISHED) {
processTask.cancel(true);
}
}
}
How can I solve it? If any more code snippet is required, let me know in
comment :)
Get all unique numbers in MySQL table using php
Get all unique numbers in MySQL table using php
I am trying to build an archive list for a blog using php and mysql. The
problem is I am not sure of the best way to do this.
I was hoping there was a way to get a list of years and than display them
so lets say my table has id | year | content and has the current rows
1 | 2013 | content
2 | 2013 | content
3 | 2013 | content
4 | 2012 | content
5 | 2012 | content
6 | 2011 | content
is it possible to make a mysql statement that well only return IDs 1,4,6,
if so how?
I am trying to build an archive list for a blog using php and mysql. The
problem is I am not sure of the best way to do this.
I was hoping there was a way to get a list of years and than display them
so lets say my table has id | year | content and has the current rows
1 | 2013 | content
2 | 2013 | content
3 | 2013 | content
4 | 2012 | content
5 | 2012 | content
6 | 2011 | content
is it possible to make a mysql statement that well only return IDs 1,4,6,
if so how?
upload image in a new post save file path to db confusion codeigniter
upload image in a new post save file path to db confusion codeigniter
ive made the news post were you can upload just text with a title and some
text.. now i want to expand it and add in an image upload if the user
wants to add it in... ive made an image upload were it stores in a folder
images
now i want to interpret so its all together so you can add in a text and
title and can add in an image....
now i know all i need to figue out is how to combined them in a form and
then upload the source file of the image were it uploaded so it displays
the image in the news post
News - Controller
public function create(){
$this->load->helper('form');
$this->load->library('form_validation');
$data['title'] = 'Create a news item';
$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('text', 'text', 'required');
if ($this->form_validation->run() === FALSE)
{
$this->load->view('templates/header', $data);
$this->load->view('news/create');
$this->load->view('templates/footer');
}
else
{
$this->news_model->set_news();
$this->load->view('news/success');
}
}
News model
public function set_news()
{
$this->load->helper('url');
$slug = url_title($this->input->post('title'), 'dash', TRUE);
$data = array(
'title' => $this->input->post('title'),
'slug' => $slug,
'text' => $this->input->post('text')
);
return $this->db->insert('news', $data);
}
Create form
<?php echo validation_errors(); ?>
<?php echo form_open('news/create') ?>
<label for="title">Title</label>
<input type="input" name="title" /><br />
<label for="text">Text</label>
<textarea name="text"></textarea><br />
<input type="file" name="userfile" />
<input type="submit" name="submit" value="Create news item" />
</form>
Now for the image upload i have done controller
public function upload(){
$config['upload_path'] = "./images/";
$config['allowed_types'] = 'jpg|jpeg|png|gif';
$this->load->library('upload',$config);
if(!$this->upload->do_upload()){
$error = array('error'=>$this->upload->display_errors());
$this->load->view('main_view', $error);
} else {
$file_data = $this->upload->data();
$data['img'] = base_url(). '/images/' .$file_data['file_name'];
$this->load->view('success_msg',$data);
}
}
I just need to interpret this so the file upload source save to the db and
you create the post with the image
ive made the news post were you can upload just text with a title and some
text.. now i want to expand it and add in an image upload if the user
wants to add it in... ive made an image upload were it stores in a folder
images
now i want to interpret so its all together so you can add in a text and
title and can add in an image....
now i know all i need to figue out is how to combined them in a form and
then upload the source file of the image were it uploaded so it displays
the image in the news post
News - Controller
public function create(){
$this->load->helper('form');
$this->load->library('form_validation');
$data['title'] = 'Create a news item';
$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('text', 'text', 'required');
if ($this->form_validation->run() === FALSE)
{
$this->load->view('templates/header', $data);
$this->load->view('news/create');
$this->load->view('templates/footer');
}
else
{
$this->news_model->set_news();
$this->load->view('news/success');
}
}
News model
public function set_news()
{
$this->load->helper('url');
$slug = url_title($this->input->post('title'), 'dash', TRUE);
$data = array(
'title' => $this->input->post('title'),
'slug' => $slug,
'text' => $this->input->post('text')
);
return $this->db->insert('news', $data);
}
Create form
<?php echo validation_errors(); ?>
<?php echo form_open('news/create') ?>
<label for="title">Title</label>
<input type="input" name="title" /><br />
<label for="text">Text</label>
<textarea name="text"></textarea><br />
<input type="file" name="userfile" />
<input type="submit" name="submit" value="Create news item" />
</form>
Now for the image upload i have done controller
public function upload(){
$config['upload_path'] = "./images/";
$config['allowed_types'] = 'jpg|jpeg|png|gif';
$this->load->library('upload',$config);
if(!$this->upload->do_upload()){
$error = array('error'=>$this->upload->display_errors());
$this->load->view('main_view', $error);
} else {
$file_data = $this->upload->data();
$data['img'] = base_url(). '/images/' .$file_data['file_name'];
$this->load->view('success_msg',$data);
}
}
I just need to interpret this so the file upload source save to the db and
you create the post with the image
How can i use event time for querying events in public google calendar
How can i use event time for querying events in public google calendar
I have the public google calendar like this
http://www.google.com/calendar/feeds/xxx2cb4fl1qm8ig8qijxxxcabso%40group.calendar.google.com/public/basic
If i go to that address then it shows all the events.
But how can i only see events which fall between two dates. I mean those
events who startdate > today
I have the public google calendar like this
http://www.google.com/calendar/feeds/xxx2cb4fl1qm8ig8qijxxxcabso%40group.calendar.google.com/public/basic
If i go to that address then it shows all the events.
But how can i only see events which fall between two dates. I mean those
events who startdate > today
Monday, 19 August 2013
Excel VBA copy cells on key press
Excel VBA copy cells on key press
I'm using VBA to dynamically change the worksheet while typing into
another cell. To do so, I've been using the API code that is found here:
Excel track keypresses
so the Sub Sheet_Keypress describes the desired action upon pressing a
key. However, I've been running into problems with the following:
Private Sub Sheet_KeyPress(ByVal KeyAscii As Integer, _
ByVal KeyCode As Integer, _
ByVal Target As Range, _
Cancel As Boolean)
Dim Col As String
Col = Chr(KeyAscii)
Worksheets(1).Range("G" & 4 & ":G" & 6).Value = _
Worksheets(1).Range(Col & 1 & ":" & Col & 3).Value
End Sub
When I go back to the sheet and type somewhere not in rows 1-3, the first
keypress does fine. However, the second keypress is not recorded, and a
further key gives Error 1004. What exactly is causing this error and is it
possible to avoid it?
I'm using VBA to dynamically change the worksheet while typing into
another cell. To do so, I've been using the API code that is found here:
Excel track keypresses
so the Sub Sheet_Keypress describes the desired action upon pressing a
key. However, I've been running into problems with the following:
Private Sub Sheet_KeyPress(ByVal KeyAscii As Integer, _
ByVal KeyCode As Integer, _
ByVal Target As Range, _
Cancel As Boolean)
Dim Col As String
Col = Chr(KeyAscii)
Worksheets(1).Range("G" & 4 & ":G" & 6).Value = _
Worksheets(1).Range(Col & 1 & ":" & Col & 3).Value
End Sub
When I go back to the sheet and type somewhere not in rows 1-3, the first
keypress does fine. However, the second keypress is not recorded, and a
further key gives Error 1004. What exactly is causing this error and is it
possible to avoid it?
Why am I seeing such low SMB transfer throughput?
Why am I seeing such low SMB transfer throughput?
Ok, there's a bit more to the story than the title implies.
Background and Environment: I'm copying several TB from an older Ubuntu
server to a newer Windows 2012 server over SMB. (Technically, it's
commodity hardware, but they're servers around here.) Everybody is on a
gigabit LAN, and the older Ubuntu box has a bonded interface. I believe
the Ubuntu server has two Rosewill PCI-e 1x ethernet cards and the Windows
server has one reasonably nice PCI Intel ethernet card.
The destination computer (the Windows server) is running a Storage Pool
with parity over 4x 2TB drives. It is running Microsoft's new ReFS. The
source computer (the Ubuntu server) is running a software RAID mirror. It
is running good ol' EXT4.
The two servers are running through a single gigabit switch. I have
experimented with breaking the bonding on the source (Ubuntu) computer
without any improvement.
Problem: I have no trouble transferring at reasonable speeds from other
computers to the Windows server. Other computers can hold 50-80MB/s
without much difficulty, but transferring from that Ubuntu server tops out
at no more than 20MB/s. 4+TB at 20MB/s takes a long time (something like
2.3 days), and I'm wondering what I can do to figure out where the
bottleneck is.
Symptoms: CPU on both computers is pretty minimal, and certainly not
prohibitively busy. Hard drives on both computers are active but not
swamped, and CPU IOwait is almost 0% on at least the Ubuntu server.
I did a Wireshark trace for 35 seconds (presumably long enough to make
sure all ACKs were for new packets) and noticed that there were quite a
few things I didn't expect. (1) There weren't any checksums for the ACKs
(and SOME SMB packets) from Windows to Ubuntu. However, Wireshark claims
that this may be due to "IP checksum offload." Ok, I have a pretty nice
card in there. I suppose it is possible that the network card could do
checksum calculations. Fine. Moving on... (2) "TCP ACKed unseen segment."
This one I have a problem with. The ACK number is within an acceptable
range from what I can tell, and there are often huge blocks of these
messages. Perhaps Wireshark is just too slow?
Summary: Transfer speed sucks (20MB/s over gigabit ethernet) and I don't
know why. Wireshark claims Windows is ACKing things that were never sent
by Ubuntu.
Guesses: My initial guess is that the cheaper Rosewill cards are getting
swamped. My second guess is that the software RAID-like things on one end
or the other is getting inundated with stuff to do.
Ok, there's a bit more to the story than the title implies.
Background and Environment: I'm copying several TB from an older Ubuntu
server to a newer Windows 2012 server over SMB. (Technically, it's
commodity hardware, but they're servers around here.) Everybody is on a
gigabit LAN, and the older Ubuntu box has a bonded interface. I believe
the Ubuntu server has two Rosewill PCI-e 1x ethernet cards and the Windows
server has one reasonably nice PCI Intel ethernet card.
The destination computer (the Windows server) is running a Storage Pool
with parity over 4x 2TB drives. It is running Microsoft's new ReFS. The
source computer (the Ubuntu server) is running a software RAID mirror. It
is running good ol' EXT4.
The two servers are running through a single gigabit switch. I have
experimented with breaking the bonding on the source (Ubuntu) computer
without any improvement.
Problem: I have no trouble transferring at reasonable speeds from other
computers to the Windows server. Other computers can hold 50-80MB/s
without much difficulty, but transferring from that Ubuntu server tops out
at no more than 20MB/s. 4+TB at 20MB/s takes a long time (something like
2.3 days), and I'm wondering what I can do to figure out where the
bottleneck is.
Symptoms: CPU on both computers is pretty minimal, and certainly not
prohibitively busy. Hard drives on both computers are active but not
swamped, and CPU IOwait is almost 0% on at least the Ubuntu server.
I did a Wireshark trace for 35 seconds (presumably long enough to make
sure all ACKs were for new packets) and noticed that there were quite a
few things I didn't expect. (1) There weren't any checksums for the ACKs
(and SOME SMB packets) from Windows to Ubuntu. However, Wireshark claims
that this may be due to "IP checksum offload." Ok, I have a pretty nice
card in there. I suppose it is possible that the network card could do
checksum calculations. Fine. Moving on... (2) "TCP ACKed unseen segment."
This one I have a problem with. The ACK number is within an acceptable
range from what I can tell, and there are often huge blocks of these
messages. Perhaps Wireshark is just too slow?
Summary: Transfer speed sucks (20MB/s over gigabit ethernet) and I don't
know why. Wireshark claims Windows is ACKing things that were never sent
by Ubuntu.
Guesses: My initial guess is that the cheaper Rosewill cards are getting
swamped. My second guess is that the software RAID-like things on one end
or the other is getting inundated with stuff to do.
how to get ldap certificate bypass the mutual certification using Java
how to get ldap certificate bypass the mutual certification using Java
I'm writing a project that could get Ldap certificate from a remote
server. It works fine for the general mode when the server does not
require mutual certification. But when I try a server that requires mutual
certification, it fails. Here is the code:
String serverSpec = null;
boolean enableAnonSuites = false;
boolean isTracing = false;
// Try and parse command line arguments.
try {
serverSpec = "ldap://10.47.16.60:389";
}
catch (Exception e) {
trace(true,e.toString());
usage();
return;
}
try {
// Create a SocketFactory that will be given to LDAP for
// building SSL sockets
MySocketFactory msf = new MySocketFactory(isTracing,
enableAnonSuites);
// Set up environment for creating initial context
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
// Must use the name of the server that is found in its certificate
env.put(Context.PROVIDER_URL,
serverSpec
);
// Create initial context
trace(isTracing,"Creating new Ldapcontext");
LdapContext ctx = new InitialLdapContext(env, null);
// Start
trace(isTracing,"Performing StartTlsRequest");
StartTlsResponse tls = null;
try {
tls = (StartTlsResponse)ctx.extendedOperation(new
StartTlsRequest());
}
catch (NamingException e) {
trace(true,"Unable to establish SSL connection:\n"
+e);
return;
}
// The default JSSE implementation will compare the hostname of
// the server with the hostname in the server's certificate, and
// will not proceed unless they match. To override this behaviour,
// you have to provide your own HostNameVerifier object. The
// example below simply bypasses the check
tls.setHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session)
{
return true;
}
});
// Negotiate SSL on the connection using our own SocketFactory
trace(isTracing,"Negotiating SSL");
SSLSession sess = null;
sess = tls.negotiate(msf);
X509Certificate[] cert = sess.getPeerCertificateChain();
The exception information is as follows: "javax.net.ssl.SSLException:
Received fatal alert: internal error", and it happens at the "negotiate"
method. And I analyzed the wireshark trace information and am sure this is
because the server requires mutual certification. Right now, I'm wondering
if there are certain class that is in the com.sun.jndi.ldap package that
could be useful for this problem. Could anyone help?
I'm writing a project that could get Ldap certificate from a remote
server. It works fine for the general mode when the server does not
require mutual certification. But when I try a server that requires mutual
certification, it fails. Here is the code:
String serverSpec = null;
boolean enableAnonSuites = false;
boolean isTracing = false;
// Try and parse command line arguments.
try {
serverSpec = "ldap://10.47.16.60:389";
}
catch (Exception e) {
trace(true,e.toString());
usage();
return;
}
try {
// Create a SocketFactory that will be given to LDAP for
// building SSL sockets
MySocketFactory msf = new MySocketFactory(isTracing,
enableAnonSuites);
// Set up environment for creating initial context
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
// Must use the name of the server that is found in its certificate
env.put(Context.PROVIDER_URL,
serverSpec
);
// Create initial context
trace(isTracing,"Creating new Ldapcontext");
LdapContext ctx = new InitialLdapContext(env, null);
// Start
trace(isTracing,"Performing StartTlsRequest");
StartTlsResponse tls = null;
try {
tls = (StartTlsResponse)ctx.extendedOperation(new
StartTlsRequest());
}
catch (NamingException e) {
trace(true,"Unable to establish SSL connection:\n"
+e);
return;
}
// The default JSSE implementation will compare the hostname of
// the server with the hostname in the server's certificate, and
// will not proceed unless they match. To override this behaviour,
// you have to provide your own HostNameVerifier object. The
// example below simply bypasses the check
tls.setHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session)
{
return true;
}
});
// Negotiate SSL on the connection using our own SocketFactory
trace(isTracing,"Negotiating SSL");
SSLSession sess = null;
sess = tls.negotiate(msf);
X509Certificate[] cert = sess.getPeerCertificateChain();
The exception information is as follows: "javax.net.ssl.SSLException:
Received fatal alert: internal error", and it happens at the "negotiate"
method. And I analyzed the wireshark trace information and am sure this is
because the server requires mutual certification. Right now, I'm wondering
if there are certain class that is in the com.sun.jndi.ldap package that
could be useful for this problem. Could anyone help?
Subscribe to:
Comments (Atom)