PHP Map $_POST data to object
This is more of a best practice question than anything.
Let's say I have a form:
<form action="self.php" method="POST">
<input type="text" name="aA" />
<input type="text" name="aB" />
<input type="text" name="aC" />
</form>
And a corresponding class in PHP:
class A
{
public function getA(){
return $this->a;
}
public function setA($a){
$this->a = $a;
}
public function getB(){
return $this->b;
}
public function setB($b){
$this->b = $b;
}
public function getC(){
return $this->c;
}
public function setC($c){
$this->c = $c;
}
private $a;
private $b;
private $c;
}
And somehow I manage to send the data from the form. Now, I need the form
data transformed into an instance of A.
What I'm currently doing is the following:
abstract class AStrategy {
public function doMapping(){
$a = new A();
if (isset($_POST['aA']) === true) {
$a->setA($_POST['aA']);
}
... (same for b and c)
return $a; //A completely mapped object
}
}
And I'm extremely aware this is pretty much bad practice (violating DRY).
What's the best practice to do this?
What if I have a complex object tree? What if I need to map related
objects at the same time?
Who should do the mapping? Who should create the object and such?
Thank you beforehand.
Saturday, 31 August 2013
How to echo multiple rows with data based on checkbox input?
How to echo multiple rows with data based on checkbox input?
Got stuck trying to echo out multiple rows with data based on checkbox
input. As of current code it processes data from only one checkbox, no
matter how many checkboxes are ticked. Please help!
while($row = mysql_fetch_assoc($r))
{
$pals .= '<input type="checkbox" name="pal_num[]"
value="'.$row['pal_num'].'">'.$row['pal_num'].'<br>';
}
if($pal == '') {
echo '';
} else {
echo '<form name="get_pal" action="post2.php" method="POST">';
echo $pals;
echo '<input type="submit" name="post" value="Go!">';
echo '</form>';
}
post2.php:
$w = $_POST['pal_num'];
$rrr = mysql_query("SELECT * FROM pl_tab WHERE pal_num".$w[0]);
while($row = mysql_fetch_array($rrr))
{
echo '<tr><td>'.' '.'</td>';
echo '<td rowspan="5">'.$row['descr'].'</td>';
echo '<td><b>'.'Total weight'.'<b></td>';
echo '<td>'.' '.'</td><td>'.' '.'</td></tr>';
echo '<td>'.' '.'</td>';
echo '<td colspan="3">'.' '.'</td>';
//this part should multiple based on how many checkboxes are ticked.
echo '<tr><td>'.$row['l_num'].'</td>';
echo '<td>'.$row['pal_num'].'</td>';
echo '<td>'.$row['weight 1'].'</td><td>'.$row['weight 2'].'</td></tr>';
}
echo "</table>";}
Got stuck trying to echo out multiple rows with data based on checkbox
input. As of current code it processes data from only one checkbox, no
matter how many checkboxes are ticked. Please help!
while($row = mysql_fetch_assoc($r))
{
$pals .= '<input type="checkbox" name="pal_num[]"
value="'.$row['pal_num'].'">'.$row['pal_num'].'<br>';
}
if($pal == '') {
echo '';
} else {
echo '<form name="get_pal" action="post2.php" method="POST">';
echo $pals;
echo '<input type="submit" name="post" value="Go!">';
echo '</form>';
}
post2.php:
$w = $_POST['pal_num'];
$rrr = mysql_query("SELECT * FROM pl_tab WHERE pal_num".$w[0]);
while($row = mysql_fetch_array($rrr))
{
echo '<tr><td>'.' '.'</td>';
echo '<td rowspan="5">'.$row['descr'].'</td>';
echo '<td><b>'.'Total weight'.'<b></td>';
echo '<td>'.' '.'</td><td>'.' '.'</td></tr>';
echo '<td>'.' '.'</td>';
echo '<td colspan="3">'.' '.'</td>';
//this part should multiple based on how many checkboxes are ticked.
echo '<tr><td>'.$row['l_num'].'</td>';
echo '<td>'.$row['pal_num'].'</td>';
echo '<td>'.$row['weight 1'].'</td><td>'.$row['weight 2'].'</td></tr>';
}
echo "</table>";}
Ruby script hanging
Ruby script hanging
I've spent a ridiculous amount of time trying to figure out why this is
hanging. I'm assuming it has something to do with the way I've formatted
my || for the "if" statement.
rods = {
:rod1 => [3,2,1],
:rod2 => [],
:rod3 => []
}
init_rod = gets.chomp.to_sym
if ((init_rod != :rod1 || init_rod != :rod2) || init_rod != :rod3)
print "Type in \"rod1\", \"rod2\", or \"rod3\": "
elsif rods[init_rod].empty?
print "Rod has no discs. Select another rod other than #{init_rod}: "
else
disc = rods[init_rod].pop
end
I've spent a ridiculous amount of time trying to figure out why this is
hanging. I'm assuming it has something to do with the way I've formatted
my || for the "if" statement.
rods = {
:rod1 => [3,2,1],
:rod2 => [],
:rod3 => []
}
init_rod = gets.chomp.to_sym
if ((init_rod != :rod1 || init_rod != :rod2) || init_rod != :rod3)
print "Type in \"rod1\", \"rod2\", or \"rod3\": "
elsif rods[init_rod].empty?
print "Rod has no discs. Select another rod other than #{init_rod}: "
else
disc = rods[init_rod].pop
end
Asymptote not working with GSView and Ghostscript
Asymptote not working with GSView and Ghostscript
I downloaded and installed Asymptote 2.24 (the vector graphics language)
according to
http://www.artofproblemsolving.com/Wiki/index.php/Asymptote:_Getting_Started/Windows/Downloads_and_Installation.
I also have GSView 5.0 and Ghostscript 9.07 and I have connected GSView
with Ghostscript. I wanted to see if Asymptote worked so I ran (still
following
http://www.artofproblemsolving.com/Wiki/index.php/Asymptote:_Getting_Started/Windows/Interactive_Mode)
asy
draw((0,0)--(100,100));
with asy.exe and I get "The system cannot find the file out.eps"
All the programs are 32 bit even though I have 64 bit windows 7, and I
can't figure out what's going wrong. Any help would be very much
appreciated.
I downloaded and installed Asymptote 2.24 (the vector graphics language)
according to
http://www.artofproblemsolving.com/Wiki/index.php/Asymptote:_Getting_Started/Windows/Downloads_and_Installation.
I also have GSView 5.0 and Ghostscript 9.07 and I have connected GSView
with Ghostscript. I wanted to see if Asymptote worked so I ran (still
following
http://www.artofproblemsolving.com/Wiki/index.php/Asymptote:_Getting_Started/Windows/Interactive_Mode)
asy
draw((0,0)--(100,100));
with asy.exe and I get "The system cannot find the file out.eps"
All the programs are 32 bit even though I have 64 bit windows 7, and I
can't figure out what's going wrong. Any help would be very much
appreciated.
Moving Linux HDD to another machine with dual Windows boot
Moving Linux HDD to another machine with dual Windows boot
Currently there're Windows 7 and XP in boot menu, and another hdd with
Fedora and CentOS coming off from a different machine. When added to the
windows boot menu, the Grab 2 allows Linux distro selection but neither of
them is able to load forcing computer into the sleep mode.
Would it still be possible to add Linux hdd to the new hardware?
Currently there're Windows 7 and XP in boot menu, and another hdd with
Fedora and CentOS coming off from a different machine. When added to the
windows boot menu, the Grab 2 allows Linux distro selection but neither of
them is able to load forcing computer into the sleep mode.
Would it still be possible to add Linux hdd to the new hardware?
Would a partial index be used on a query?
Would a partial index be used on a query?
Given this partial index:
CREATE INDEX orders_id_created_at_index ON orders(id) WHERE created_at <
'2013-12-31';
Would this query use the index?
SELECT * FROM orders WHERE id = 123 AND created_at = ''2013-10-12';
As per the documentation, "a partial index can be used in a query
only if the system can recognize that the WHERE condition of the query
mathematically implies the predicate of the index". Does that mean that
the index will or will not be used?
Given this partial index:
CREATE INDEX orders_id_created_at_index ON orders(id) WHERE created_at <
'2013-12-31';
Would this query use the index?
SELECT * FROM orders WHERE id = 123 AND created_at = ''2013-10-12';
As per the documentation, "a partial index can be used in a query
only if the system can recognize that the WHERE condition of the query
mathematically implies the predicate of the index". Does that mean that
the index will or will not be used?
android fragment activity How to not save state
android fragment activity How to not save state
I have FragmentActivity where first is A and then can be replaced with B
fragment. If Activity has been destroyed i would like to start app with A
fragment instead of B fragment.
I have FragmentActivity where first is A and then can be replaced with B
fragment. If Activity has been destroyed i would like to start app with A
fragment instead of B fragment.
Kentico CSS List Menu styling
Kentico CSS List Menu styling
I am to implement this structure with kentico
<li class="megamenu_button"><a href="#_">Mega Menu</a></li>
<li><a href="#">Home</a></li>
<li class="aa"><a href="#_" class="megamenu_drop">About Us</a><!--
Begin Item -->
<div class="dropdown_4columns dropdown_container"><!-- Begin
Item Container -->
<div class="col_12">
<img class="img_left" src="images/about_us_img.png"
width="125" height="146">
<ul class="list_unstyled">
<li><a href="#_">FreelanceSwitch</a></li>
<li><a href="#_">Creattica</a></li>
<li><a href="#_">WorkAwesome</a></li>
<li><a href="#_">Mac Apps</a></li>
</ul>
</div>
</div><!-- End Item Container -->
</li><!-- End Item -->
</ul><!-- End Mega Menu -->
The design is meant to have at least 6 menu headers with sub-menu each.
The challenge is I don't even know how to approach the design. I am
currently using aspx master template. All suggestion is welcome.
I am to implement this structure with kentico
<li class="megamenu_button"><a href="#_">Mega Menu</a></li>
<li><a href="#">Home</a></li>
<li class="aa"><a href="#_" class="megamenu_drop">About Us</a><!--
Begin Item -->
<div class="dropdown_4columns dropdown_container"><!-- Begin
Item Container -->
<div class="col_12">
<img class="img_left" src="images/about_us_img.png"
width="125" height="146">
<ul class="list_unstyled">
<li><a href="#_">FreelanceSwitch</a></li>
<li><a href="#_">Creattica</a></li>
<li><a href="#_">WorkAwesome</a></li>
<li><a href="#_">Mac Apps</a></li>
</ul>
</div>
</div><!-- End Item Container -->
</li><!-- End Item -->
</ul><!-- End Mega Menu -->
The design is meant to have at least 6 menu headers with sub-menu each.
The challenge is I don't even know how to approach the design. I am
currently using aspx master template. All suggestion is welcome.
Friday, 30 August 2013
How to create an autocomplete in phonegap with hits the database after and character is entered
How to create an autocomplete in phonegap with hits the database after and
character is entered
I an creating an app in which i want to implement an autocomplete search
field this field will contain the names of the user i saw the example
http://jquerymobile.com/demos/1.3.0/docs/widgets/autocomplete/strong text
but what i want is the list of user will increase every day so every time
to create li of username and then search name from it is not good idea so
what i want to do is every time user will enter character it should hit
the data base and get the name from there in the serach list the name are
saved in the local database. can anyone tell me how to do it and if
example is give then it wouldbe greate help thanks in advance.
character is entered
I an creating an app in which i want to implement an autocomplete search
field this field will contain the names of the user i saw the example
http://jquerymobile.com/demos/1.3.0/docs/widgets/autocomplete/strong text
but what i want is the list of user will increase every day so every time
to create li of username and then search name from it is not good idea so
what i want to do is every time user will enter character it should hit
the data base and get the name from there in the serach list the name are
saved in the local database. can anyone tell me how to do it and if
example is give then it wouldbe greate help thanks in advance.
Thursday, 29 August 2013
Position: Sticky example in JS Fiddle
Position: Sticky example in JS Fiddle
I am testing the new position:sticky feature but it does not appear to work.
CSS
.slide {
width:300px;
height:400px;
border:1px solid #888;
border-radius:8px;
position:relative;
overflow:auto;
}
.slide > ul {
padding:0;
margin:0;
position:relative;
}
.slide > ul > li {
min-height:20px;
display:block;
padding:10px;
background:#F8F8F8;
box-shadow:inset 0 0 3px #CCC;
list-style:none;
}
.slide > ul > li.title {
min-height:12px;
background:#888;
colour:#FFF;
font-weight:bold;
position:-webkit-sticky;
}
HTML
<div class="slide">
<ul>
<li class="title">Settings</li>
<li>General</li>
<li>Social</li>
<li>Search Engine</li>
</ul>
<ul>
<li class="title">Privacy</li>
<li>Personal</li>
<li>Business</li>
<li>Enigma</li>
</ul>
<ul>
<li class="title">Settings</li>
<li>General</li>
<li>Social</li>
<li>Search Engine</li>
</ul>
<ul>
<li class="title">Privacy</li>
<li>Personal</li>
<li>Business</li>
<li>Enigma</li>
</ul>
</div>
The Fiddle http://jsfiddle.net/78kxU/3/
I am testing the new position:sticky feature but it does not appear to work.
CSS
.slide {
width:300px;
height:400px;
border:1px solid #888;
border-radius:8px;
position:relative;
overflow:auto;
}
.slide > ul {
padding:0;
margin:0;
position:relative;
}
.slide > ul > li {
min-height:20px;
display:block;
padding:10px;
background:#F8F8F8;
box-shadow:inset 0 0 3px #CCC;
list-style:none;
}
.slide > ul > li.title {
min-height:12px;
background:#888;
colour:#FFF;
font-weight:bold;
position:-webkit-sticky;
}
HTML
<div class="slide">
<ul>
<li class="title">Settings</li>
<li>General</li>
<li>Social</li>
<li>Search Engine</li>
</ul>
<ul>
<li class="title">Privacy</li>
<li>Personal</li>
<li>Business</li>
<li>Enigma</li>
</ul>
<ul>
<li class="title">Settings</li>
<li>General</li>
<li>Social</li>
<li>Search Engine</li>
</ul>
<ul>
<li class="title">Privacy</li>
<li>Personal</li>
<li>Business</li>
<li>Enigma</li>
</ul>
</div>
The Fiddle http://jsfiddle.net/78kxU/3/
No caching in HTML5
No caching in HTML5
In HTML4 we used stuff like
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="Expires" content="Thu, 01 Jan 1970 00:00:00 GMT" />
to get the browser to not cache the pages.
What should I use in HTML5 to get the browser not to cache my pages. I
don't want any pages at all cached.
I've seen something about
<html manifest="example.appcache">
...
</html>
but it seems like a lot of work to specify all the pages in the whole web
application just to get the browser not to cache anything.
Is there a simpler way?
If I omitt the manifest part from the html tag, will that make the browser
not cache anything? I.e.
<html>
...
</html>
Or will it take that as an ok to cache everything?
Regards, Mattias
In HTML4 we used stuff like
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="Expires" content="Thu, 01 Jan 1970 00:00:00 GMT" />
to get the browser to not cache the pages.
What should I use in HTML5 to get the browser not to cache my pages. I
don't want any pages at all cached.
I've seen something about
<html manifest="example.appcache">
...
</html>
but it seems like a lot of work to specify all the pages in the whole web
application just to get the browser not to cache anything.
Is there a simpler way?
If I omitt the manifest part from the html tag, will that make the browser
not cache anything? I.e.
<html>
...
</html>
Or will it take that as an ok to cache everything?
Regards, Mattias
How to Same methods implements (interfaces) in java
How to Same methods implements (interfaces) in java
/* Class name : Animal.java */
interface Animal {
public void eat();
public void travel();
}
/* Class name : Birds.java */
interface Birds {
public void eat();
public void travel();
}
public class MammalAni implements Animal{
public void eat(){
System.out.println("Mammal eats");
}
public void travel(){
System.out.println("Mammal travels");
}
public static void main(String args[]){
MammalAni m = new MammalAni();
m.eat();
m.travel();
}
}
Here two methods same name but not implements then how to interface
implements in this class.Basically interface inheritances two or more
class but here both different class in same method use then both method
which way implement in one class.
/* Class name : Animal.java */
interface Animal {
public void eat();
public void travel();
}
/* Class name : Birds.java */
interface Birds {
public void eat();
public void travel();
}
public class MammalAni implements Animal{
public void eat(){
System.out.println("Mammal eats");
}
public void travel(){
System.out.println("Mammal travels");
}
public static void main(String args[]){
MammalAni m = new MammalAni();
m.eat();
m.travel();
}
}
Here two methods same name but not implements then how to interface
implements in this class.Basically interface inheritances two or more
class but here both different class in same method use then both method
which way implement in one class.
Samba/winbind/pam AD user incorrect login because of NTLM beeing used?
Samba/winbind/pam AD user incorrect login because of NTLM beeing used?
My problem is, as hinted at by the headline, that if I try to logon to the
SLES machine with an AD account it always denies the login and says
"incorrect login". The AD Domain is at an 2012 function level and NTLM is
disabled via gpo. I have checked that ntp and DNS are setup correctly.
wbinfo -g
wbinfo -u
show the correct users and groups. and the same goes for
getent passwd <user>
getent group <group>
The /var/samba logs show nothing at all unless debug log level is turned
on but than everything seems to be correct. I also can initiate tickets
via
kinit
and
klist -kte
shows the correct SPNs (HOST/server.fqdn and HOST/server) in /etc/smb.conf
I defined for the kerberos method to be system keytab.
My suspission that at somepoint NTLM is required comes from trying
wbinfo --pam-logon <user>
this return the error code
0xC0000418 which according to Microsoft means that "authentication failed
because NTLM is blocked"
So finally ;) my question is:
"how do I configure pam/winbind to only use Kerberos and not NTLM?"
Many thanks in advance :)
My problem is, as hinted at by the headline, that if I try to logon to the
SLES machine with an AD account it always denies the login and says
"incorrect login". The AD Domain is at an 2012 function level and NTLM is
disabled via gpo. I have checked that ntp and DNS are setup correctly.
wbinfo -g
wbinfo -u
show the correct users and groups. and the same goes for
getent passwd <user>
getent group <group>
The /var/samba logs show nothing at all unless debug log level is turned
on but than everything seems to be correct. I also can initiate tickets
via
kinit
and
klist -kte
shows the correct SPNs (HOST/server.fqdn and HOST/server) in /etc/smb.conf
I defined for the kerberos method to be system keytab.
My suspission that at somepoint NTLM is required comes from trying
wbinfo --pam-logon <user>
this return the error code
0xC0000418 which according to Microsoft means that "authentication failed
because NTLM is blocked"
So finally ;) my question is:
"how do I configure pam/winbind to only use Kerberos and not NTLM?"
Many thanks in advance :)
Wednesday, 28 August 2013
Mongoid failing to find document by nested ID
Mongoid failing to find document by nested ID
I have a collection with documents that look something like this:
{
_id: ObjectId("521d11014903728f8d000006"),
association_chain: [
{
name: "Foobar",
id: ObjectId("521d11014903728f8d000005")
}
],
// etc...
}
I can search by the name attribute with this query:
@results = Model.where 'association_chain.name' => 'Foobar'
This returns the results as expected. However, when I try to search using
the id attribute:
@results = Model.where 'association_chain.id' => '521d11014903728f8d000005'
There are no results. What am I doing wrong?
I have a collection with documents that look something like this:
{
_id: ObjectId("521d11014903728f8d000006"),
association_chain: [
{
name: "Foobar",
id: ObjectId("521d11014903728f8d000005")
}
],
// etc...
}
I can search by the name attribute with this query:
@results = Model.where 'association_chain.name' => 'Foobar'
This returns the results as expected. However, when I try to search using
the id attribute:
@results = Model.where 'association_chain.id' => '521d11014903728f8d000005'
There are no results. What am I doing wrong?
adjust different sizes image within a large div
adjust different sizes image within a large div
I have set of images which need to be displayed within in div which has
fixed width but height can be anything. Set of images have different sizes
width hand height. I need to put theses into a div so that div height
should be minimum. i.e occupied div area should be minimum.
It can be done with javascript or server site language like PHP, java or
can be a pseudocode.
Any help will be appreciated.
I have set of images which need to be displayed within in div which has
fixed width but height can be anything. Set of images have different sizes
width hand height. I need to put theses into a div so that div height
should be minimum. i.e occupied div area should be minimum.
It can be done with javascript or server site language like PHP, java or
can be a pseudocode.
Any help will be appreciated.
Google event tracking not working with new style tracking code
Google event tracking not working with new style tracking code
I don't seem to be able to get Google analytics event tracking to work
with the "new" style tracking code.
I cobbled together this code, but it might be wrong:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new
Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-42805759-5', 'my-domain.com');
ga('send', 'pageview');
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-42805759-5']);
_gaq.push(['_trackPageview']);
</script>
And an example link is:
<a href="my-page.aspx" onclick="_gaq.push(['_trackEvent', 'Link click',
'My page clicked', 'Something']);">View this page</a>
Should this work? And also, should tracked events be visible in Real-time
> Events area of the dashboard?
Thanks.
I don't seem to be able to get Google analytics event tracking to work
with the "new" style tracking code.
I cobbled together this code, but it might be wrong:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new
Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-42805759-5', 'my-domain.com');
ga('send', 'pageview');
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-42805759-5']);
_gaq.push(['_trackPageview']);
</script>
And an example link is:
<a href="my-page.aspx" onclick="_gaq.push(['_trackEvent', 'Link click',
'My page clicked', 'Something']);">View this page</a>
Should this work? And also, should tracked events be visible in Real-time
> Events area of the dashboard?
Thanks.
Store values in C# and populate in Javascript
Store values in C# and populate in Javascript
I am working in asp.net 1.1 site.
My requirement is : On post back I have some data, which I want to store
in some variable. And in javascript i want to add those info to a drop
down list.
Ex :
The data coming from post back call is :
Text Value
One 1
two 2
three 3
I want to store them in some variable and assign them to a drop down list
in JAVASCRIPT based on a condidtion.
The code I am using to keep the value in C# is:
StringBuilder sb = new StringBuilder();
sb.Append("<script>");
sb.Append("var test = [];");
for(int i=0; i < Engine.Length; i++)
{
sb.Append("var obj = {text:" + Engine[i][0] + "," + "value:" +
Engine[i][1] +"};");
sb.Append("test.push(obj);");
}
sb.Append("</" + "script>");
this.RegisterStartupScript("ownHtml", sb.ToString());
And adding the value to drop down list in JAVASCRIPT as:
for (var count = 0; count < test.length; count++)
{
dlEngine.options[count] = new Option(test[count].text,
test[count].value);
}
But it is not working.
I am working in asp.net 1.1 site.
My requirement is : On post back I have some data, which I want to store
in some variable. And in javascript i want to add those info to a drop
down list.
Ex :
The data coming from post back call is :
Text Value
One 1
two 2
three 3
I want to store them in some variable and assign them to a drop down list
in JAVASCRIPT based on a condidtion.
The code I am using to keep the value in C# is:
StringBuilder sb = new StringBuilder();
sb.Append("<script>");
sb.Append("var test = [];");
for(int i=0; i < Engine.Length; i++)
{
sb.Append("var obj = {text:" + Engine[i][0] + "," + "value:" +
Engine[i][1] +"};");
sb.Append("test.push(obj);");
}
sb.Append("</" + "script>");
this.RegisterStartupScript("ownHtml", sb.ToString());
And adding the value to drop down list in JAVASCRIPT as:
for (var count = 0; count < test.length; count++)
{
dlEngine.options[count] = new Option(test[count].text,
test[count].value);
}
But it is not working.
Tuesday, 27 August 2013
getting gmail error while sending mail using gmail smtp via php [on hold]
getting gmail error while sending mail using gmail smtp via php [on hold]
Trying to send mails via gmail smtp in PHP, however, facing gmail security
issue. Received mail from gmail - "suspicious sign in prevented".
Should i make any settings change on my gmail account?
Trying to send mails via gmail smtp in PHP, however, facing gmail security
issue. Received mail from gmail - "suspicious sign in prevented".
Should i make any settings change on my gmail account?
Belongs To Association Table Schema Ruby on Rails
Belongs To Association Table Schema Ruby on Rails
I want each student to be able to post multiple messages on my site.
therefore each student has_many :posts and a post belongs_to :student (one
student only)
The thing is I can create a record for a student in rails console but
can't assign a post to the student ? I am a bit confused. The student
model with the has many does not have the attributes from the belongs to
model ?
I have a student.rb model
class Student < ActiveRecord::Base
attr_accessible :first_name, :last_name, :email, :gender, :number,
:college, :password, :budget, :picture
mount_uploader :picture, PictureUploader
has_many :posts
end
I have a post.rb model
class Post < ActiveRecord::Base
attr_accessible :message
belongs_to :student
end
this is my schema
ActiveRecord::Schema.define(version: 20130827191617) do
# These are extensions that must be enabled in order to support this
database
enable_extension "plpgsql"
create_table "posts", force: true do |t|
t.text "message"
end
create_table "students", force: true do |t|
t.string "first_name"
t.string "last_name"
t.string "email"
t.string "number"
t.string "college"
t.string "password"
t.float "budget"
t.string "picture"
t.datetime "created_at"
t.datetime "updated_at"
end
I want each student to be able to post multiple messages on my site.
therefore each student has_many :posts and a post belongs_to :student (one
student only)
The thing is I can create a record for a student in rails console but
can't assign a post to the student ? I am a bit confused. The student
model with the has many does not have the attributes from the belongs to
model ?
I have a student.rb model
class Student < ActiveRecord::Base
attr_accessible :first_name, :last_name, :email, :gender, :number,
:college, :password, :budget, :picture
mount_uploader :picture, PictureUploader
has_many :posts
end
I have a post.rb model
class Post < ActiveRecord::Base
attr_accessible :message
belongs_to :student
end
this is my schema
ActiveRecord::Schema.define(version: 20130827191617) do
# These are extensions that must be enabled in order to support this
database
enable_extension "plpgsql"
create_table "posts", force: true do |t|
t.text "message"
end
create_table "students", force: true do |t|
t.string "first_name"
t.string "last_name"
t.string "email"
t.string "number"
t.string "college"
t.string "password"
t.float "budget"
t.string "picture"
t.datetime "created_at"
t.datetime "updated_at"
end
How can i use a JTABLE to insert data into a database
How can i use a JTABLE to insert data into a database
I am making an application for inserting examination marks into a
database. I have managed to use a JTable to display data from the database
but now i want to use the same JTable to insert data to the database. how
i do that?I will appreciate any assistance given
I am making an application for inserting examination marks into a
database. I have managed to use a JTable to display data from the database
but now i want to use the same JTable to insert data to the database. how
i do that?I will appreciate any assistance given
byteman can not print out the trace message
byteman can not print out the trace message
i am trying to use byteman to add dynamic debug information to JBOSS, but
when i attached the byteman script to JVM, there is no trace message
printed in system.out.
Below is my byteman script (script file name:select-provider.btm):
RULE select provider rule
CLASS com.xxx.tpim.struts.wizard.SelectProviderAction
METHOD execute
AT ENTRY
IF true
#DO traceln("entering createHelloMessage")
#DO traceStack("found the caller!\n", 100)
DO traceln("Hey, I'm random java code!")
ENDRULE
And below is the command i used to install the byteman agent:
bminstall.sh -b -Dorg.jboss.byteman.transform.all 11526
Below is the nohup output after i run above install script:
2013-08-27 17:04:23,554 INFO [stdout] (Attach Listener) Setting
org.jboss.byteman.transform.all=
Below is the command i used to submit the byteman script:
bmsubmit.sh -l select-provider.btm
Below is the result i use bmsubmit.sh to check if the script submit
successfully:
[eniayin@ecnshxenlx0291 target]$ bmsubmit.sh
# File select-provider.btm line 5
RULE select provider rule
CLASS com.xxx.tpim.struts.wizard.SelectProviderAction
METHOD execute
AT ENTRY
IF true
DO traceln("Hey, I'm random java code!")
ENDRULE
Transformed in:
loader: ModuleClassLoader for Module "deployment.tpim.war:main" from
Service Module Loader
trigger method:
com.xxx.tpim.struts.wizard.SelectProviderAction.execute(org.apache.struts.action.ActionMapping,org.apache.struts.action.ActionForm,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
org.apache.struts.action.ActionForward
From the message above, it seems the script is submitted successfully, but
there is no message printed in the nohup file when the
SelectProviderAction.execute method is called.
anyone has ideas about this issue?
thanks for your time ~
i am trying to use byteman to add dynamic debug information to JBOSS, but
when i attached the byteman script to JVM, there is no trace message
printed in system.out.
Below is my byteman script (script file name:select-provider.btm):
RULE select provider rule
CLASS com.xxx.tpim.struts.wizard.SelectProviderAction
METHOD execute
AT ENTRY
IF true
#DO traceln("entering createHelloMessage")
#DO traceStack("found the caller!\n", 100)
DO traceln("Hey, I'm random java code!")
ENDRULE
And below is the command i used to install the byteman agent:
bminstall.sh -b -Dorg.jboss.byteman.transform.all 11526
Below is the nohup output after i run above install script:
2013-08-27 17:04:23,554 INFO [stdout] (Attach Listener) Setting
org.jboss.byteman.transform.all=
Below is the command i used to submit the byteman script:
bmsubmit.sh -l select-provider.btm
Below is the result i use bmsubmit.sh to check if the script submit
successfully:
[eniayin@ecnshxenlx0291 target]$ bmsubmit.sh
# File select-provider.btm line 5
RULE select provider rule
CLASS com.xxx.tpim.struts.wizard.SelectProviderAction
METHOD execute
AT ENTRY
IF true
DO traceln("Hey, I'm random java code!")
ENDRULE
Transformed in:
loader: ModuleClassLoader for Module "deployment.tpim.war:main" from
Service Module Loader
trigger method:
com.xxx.tpim.struts.wizard.SelectProviderAction.execute(org.apache.struts.action.ActionMapping,org.apache.struts.action.ActionForm,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
org.apache.struts.action.ActionForward
From the message above, it seems the script is submitted successfully, but
there is no message printed in the nohup file when the
SelectProviderAction.execute method is called.
anyone has ideas about this issue?
thanks for your time ~
How to know the IndexOfObject in NSArray
How to know the IndexOfObject in NSArray
I am trying to fetch the index position by passing the array objects.I
have an NSArray with name fruits and I gave 4 fruit names in that array as
below In my header file
NSArray *mFruits;
and in my implementation file
mFruits = [[NSArray alloc] initWithObjects: @"Apple", @"Mango",
@"Grape",@"Banana",nil];
now I am getting the array objects means(Apple,Grape,..) in one text field
now I want to know the index of the fruit in that array i.e., If "Apple"
is the text fetched from the text field then I should know the index as
"0" for .
Many Thanks
I am trying to fetch the index position by passing the array objects.I
have an NSArray with name fruits and I gave 4 fruit names in that array as
below In my header file
NSArray *mFruits;
and in my implementation file
mFruits = [[NSArray alloc] initWithObjects: @"Apple", @"Mango",
@"Grape",@"Banana",nil];
now I am getting the array objects means(Apple,Grape,..) in one text field
now I want to know the index of the fruit in that array i.e., If "Apple"
is the text fetched from the text field then I should know the index as
"0" for .
Many Thanks
Monday, 26 August 2013
C++ Segfault when returning an empty vector containing vector
C++ Segfault when returning an empty vector containing vector
I'm having some trouble returning an empty vector which I wasn't
expecting. Can anybody help explain please!
This is the offending section: - I am aware the returns are the same, its
a placeholder for now.
std::vector<std::vector<double> > PerceptronLayer::calculateLayer() {
std::vector<std::vector<double> > result;
if (vPerceptrons.size() == 0) {
return result;
}
return result;
}
If however I make sure that the vector has some values, by setting some
dummy data, the function returns as I would expect.
std::vector<double> val;
val.push_back(1.0);
result.push_back(val);
GDB output:
Program received signal SIGSEGV, Segmentation fault.
0x000000000040ba60 in std::vector<double, std::allocator<double>
>::operator[] (this=0x0, __n=0)
at /usr/include/c++/4.7/bits/stl_vector.h:751
751 { return *(this->_M_impl._M_start + __n); }
I could protect the function by not allowing it to run on empty data, but
I can't help but feel im missing something fundamental here.
Thanks, Joe
I'm having some trouble returning an empty vector which I wasn't
expecting. Can anybody help explain please!
This is the offending section: - I am aware the returns are the same, its
a placeholder for now.
std::vector<std::vector<double> > PerceptronLayer::calculateLayer() {
std::vector<std::vector<double> > result;
if (vPerceptrons.size() == 0) {
return result;
}
return result;
}
If however I make sure that the vector has some values, by setting some
dummy data, the function returns as I would expect.
std::vector<double> val;
val.push_back(1.0);
result.push_back(val);
GDB output:
Program received signal SIGSEGV, Segmentation fault.
0x000000000040ba60 in std::vector<double, std::allocator<double>
>::operator[] (this=0x0, __n=0)
at /usr/include/c++/4.7/bits/stl_vector.h:751
751 { return *(this->_M_impl._M_start + __n); }
I could protect the function by not allowing it to run on empty data, but
I can't help but feel im missing something fundamental here.
Thanks, Joe
Windows 2008 R2 App Locker define times program is opened
Windows 2008 R2 App Locker define times program is opened
I am testing AppLock currently. I have create a GroupPolicyObject and
added a Executable rule. The .exe I am referencing for this test is
Calc.exe . How would I define that I only want want two instances of
calc.exe opened and if a user in the group opens a 3rd one, it denies
them. Is this possible?
I am testing AppLock currently. I have create a GroupPolicyObject and
added a Executable rule. The .exe I am referencing for this test is
Calc.exe . How would I define that I only want want two instances of
calc.exe opened and if a user in the group opens a 3rd one, it denies
them. Is this possible?
How do I transfer Boot disk from External HDD to newly inserted SSD?
How do I transfer Boot disk from External HDD to newly inserted SSD?
I'm trying to upgrade from my MacBook Pro's original HDD to a SSD. Right
now my external HDD, which I installed OSX Mountain Lion on, has to be
plugged in to boot. If I unplug it, I get a white screen with a flashing
folder icon upon boot up.
I open disk utility and it shows my samsung SSD, which I just
repartitioned to use Mac OS Extended (journaled)
EDIT I click finder and it shows under devices: "OSX" which is the name I
gave my external HDD currently running OSX.. and "Samsung SSD." OSX has
the standard folders on a mac.. Samsung SSD is blank.
How can I get OSX to boot from my SSD rather than the external HDD? Thanks!
Would doing this get it to do that?
I'm trying to upgrade from my MacBook Pro's original HDD to a SSD. Right
now my external HDD, which I installed OSX Mountain Lion on, has to be
plugged in to boot. If I unplug it, I get a white screen with a flashing
folder icon upon boot up.
I open disk utility and it shows my samsung SSD, which I just
repartitioned to use Mac OS Extended (journaled)
EDIT I click finder and it shows under devices: "OSX" which is the name I
gave my external HDD currently running OSX.. and "Samsung SSD." OSX has
the standard folders on a mac.. Samsung SSD is blank.
How can I get OSX to boot from my SSD rather than the external HDD? Thanks!
Would doing this get it to do that?
Customize Email Body Content + Mandrill template
Customize Email Body Content + Mandrill template
I have followed this article:
http://blog.mandrill.com/own-your-wordpress-email-with-mandrill.html
But the author is talking about dynamic regions only. I want to use merge
tags. I want to customize the body content using user personal details
which has been extended using Cimy User Extra Fields.
Please help.
Update:
Clearer explanation:
I've followed the article mentioned above and all is well. But the author
suggest to customize the body content using dynamic region.
Note: You can customize Mandrill template using 1) dynamic regions, 2)
merge tags. Below is example for dynamic regions :
$message['template']['content'][] = array(
'name' => 'user_name',
'content' => 'Name'
);
$message['template']['content'][] = array(
'name' => 'password',
'content' => 'Password'
);
$message['template']['content'][] = array(
'name' => 'mobile_site',
'content' => 'http://m.com.com'
);
OK. Let's forget the merge tags. I'm ready to use dynamic region as per
example above. So how do I populate the 'content' key with user data?
(This is a template for new user registration key). Moreover, how do I
populate user data which are extended by the plugin "Cimy User Extra
Fields"?
I have followed this article:
http://blog.mandrill.com/own-your-wordpress-email-with-mandrill.html
But the author is talking about dynamic regions only. I want to use merge
tags. I want to customize the body content using user personal details
which has been extended using Cimy User Extra Fields.
Please help.
Update:
Clearer explanation:
I've followed the article mentioned above and all is well. But the author
suggest to customize the body content using dynamic region.
Note: You can customize Mandrill template using 1) dynamic regions, 2)
merge tags. Below is example for dynamic regions :
$message['template']['content'][] = array(
'name' => 'user_name',
'content' => 'Name'
);
$message['template']['content'][] = array(
'name' => 'password',
'content' => 'Password'
);
$message['template']['content'][] = array(
'name' => 'mobile_site',
'content' => 'http://m.com.com'
);
OK. Let's forget the merge tags. I'm ready to use dynamic region as per
example above. So how do I populate the 'content' key with user data?
(This is a template for new user registration key). Moreover, how do I
populate user data which are extended by the plugin "Cimy User Extra
Fields"?
Evaluating $\sum\limits=?iso-8859-1?Q?=5F{k=3D1}^{\infty}\frac1{?=(3k+1)(3k+2)}$ math.stackexchange.com
Evaluating $\sum\limits_{k=1}^{\infty}\frac1{(3k+1)(3k+2)}$ –
math.stackexchange.com
What is the value of $\displaystyle\sum_{k=1}^{\infty}\frac1{(3k+1)(3k+2)}$?
math.stackexchange.com
What is the value of $\displaystyle\sum_{k=1}^{\infty}\frac1{(3k+1)(3k+2)}$?
Why is iptables rejecting the second and subsequent fragments of an allowed packet=?iso-8859-1?Q?=3F_=96_serverfault.com?=
Why is iptables rejecting the second and subsequent fragments of an
allowed packet? – serverfault.com
I have two hosts which are attempting to set up an IPSec connection with
each other. For this they have to communicate on UDP ports 500 and 4500,
so I opened them in my firewall (shown in relevant ...
allowed packet? – serverfault.com
I have two hosts which are attempting to set up an IPSec connection with
each other. For this they have to communicate on UDP ports 500 and 4500,
so I opened them in my firewall (shown in relevant ...
Sunday, 25 August 2013
Magento folder change
Magento folder change
I tried to rename the Magento installed folder but it not load properly.
Before It store in "demo" folder. At that time it was loaded nicely. I
renamed the folder name from that time it shows only text while browsing
the website. I have already changed the permission of "var" and "media"
folder.
How can I make the website visible with templates.
I tried to rename the Magento installed folder but it not load properly.
Before It store in "demo" folder. At that time it was loaded nicely. I
renamed the folder name from that time it shows only text while browsing
the website. I have already changed the permission of "var" and "media"
folder.
How can I make the website visible with templates.
[ Weddings ] Open Question : If I am pregnant and the father is from South Africa, can he stay here legally without us getting married?
[ Weddings ] Open Question : If I am pregnant and the father is from South
Africa, can he stay here legally without us getting married?
Africa, can he stay here legally without us getting married?
Jquery .when() how to use?
Jquery .when() how to use?
having a bit of trouble with my jquery (as usual). I need one function to
execute only after the first one is complete, but I'm having trouble with
the syntax.. I've been reading about .when and callbacks but I can't seem
to get it to work. I'm not quite sure how to format my functions :-( Any
help?
$('#buttonone').hover(function () {
$('#descriptionone').fadeIn(400);},
function () {
$('#descriptionone').fadeOut(400);
});
$('#buttontwo').hover(function () {
$('#descriptiontwo').fadeIn(400);},
function () {
$('#descriptiontwo').fadeOut(400);
});
I'm just really confused where the .when goes! Any help would be
appreciated :-)
having a bit of trouble with my jquery (as usual). I need one function to
execute only after the first one is complete, but I'm having trouble with
the syntax.. I've been reading about .when and callbacks but I can't seem
to get it to work. I'm not quite sure how to format my functions :-( Any
help?
$('#buttonone').hover(function () {
$('#descriptionone').fadeIn(400);},
function () {
$('#descriptionone').fadeOut(400);
});
$('#buttontwo').hover(function () {
$('#descriptiontwo').fadeIn(400);},
function () {
$('#descriptiontwo').fadeOut(400);
});
I'm just really confused where the .when goes! Any help would be
appreciated :-)
Saturday, 24 August 2013
Heroku and Django random crashes
Heroku and Django random crashes
Sometimes when I push to heroku I get a message saying:
Application Error
An error occurred in the application and your page could not be served.
Please try again in a few moments.
If you are the application owner, check your logs for details.
I then run the command
$ heroku restart
a few times and its suddenly working fine again.
The error message from heroku logs is very long, here is a snippet from
the bottom:
2013-08-25T03:30:26.824149+00:00 app[web.1]: self._setup(name)
2013-08-25T03:30:26.824453+00:00 app[web.1]: File
"/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py",
line 132, in __init__
2013-08-25T03:30:26.824453+00:00 app[web.1]: mod =
importlib.import_module(self.SETTINGS_MODULE)
2013-08-25T03:30:26.824453+00:00 app[web.1]: File
"/app/.heroku/python/lib/python2.7/site-packages/django/utils/importlib.py",
line 35, in import_module
2013-08-25T03:30:26.824453+00:00 app[web.1]: self._wrapped =
Settings(settings_module)
2013-08-25T03:30:26.824453+00:00 app[web.1]: __import__(name)
2013-08-25T03:30:26.824453+00:00 app[web.1]: File
"/app/zinnia/settings.py", line 5, in <module>
2013-08-25T03:30:26.824453+00:00 app[web.1]:
('http://django-blog-zinnia.com/xmlrpc/',))
2013-08-25T03:30:26.824453+00:00 app[web.1]: File
"/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py",
line 53, in __getattr__
2013-08-25T03:30:26.824453+00:00 app[web.1]: self._setup(name)
2013-08-25T03:30:26.824759+00:00 app[web.1]: File
"/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py",
line 152, in __init__
2013-08-25T03:30:26.824759+00:00 app[web.1]: File
"/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py",
line 48, in _setup
2013-08-25T03:30:26.824759+00:00 app[web.1]: self._wrapped =
Settings(settings_module)
2013-08-25T03:30:26.824759+00:00 app[web.1]: raise
ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
2013-08-25T03:30:26.824759+00:00 app[web.1]: ImproperlyConfigured: The
SECRET_KEY setting must not be empty.
2013-08-25T03:30:26.825073+00:00 app[web.1]: 2013-08-25 03:30:26 [7]
[INFO] Worker exiting (pid: 7)
2013-08-25T03:30:26.972807+00:00 app[web.1]: 2013-08-25 03:30:26 [2]
[INFO] Shutting down: Master
2013-08-25T03:30:26.972807+00:00 app[web.1]: 2013-08-25 03:30:26 [2]
[INFO] Reason: Worker failed to boot.
2013-08-25T03:30:27.576714+00:00 heroku[web.1]: Process exited with status 0
2013-08-25T03:30:28.190167+00:00 heroku[web.1]: Process exited with status 3
2013-08-25T03:30:28.205185+00:00 heroku[web.1]: State changed from
starting to crashed
Does anyone have experience of this sort of thing?
Sometimes when I push to heroku I get a message saying:
Application Error
An error occurred in the application and your page could not be served.
Please try again in a few moments.
If you are the application owner, check your logs for details.
I then run the command
$ heroku restart
a few times and its suddenly working fine again.
The error message from heroku logs is very long, here is a snippet from
the bottom:
2013-08-25T03:30:26.824149+00:00 app[web.1]: self._setup(name)
2013-08-25T03:30:26.824453+00:00 app[web.1]: File
"/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py",
line 132, in __init__
2013-08-25T03:30:26.824453+00:00 app[web.1]: mod =
importlib.import_module(self.SETTINGS_MODULE)
2013-08-25T03:30:26.824453+00:00 app[web.1]: File
"/app/.heroku/python/lib/python2.7/site-packages/django/utils/importlib.py",
line 35, in import_module
2013-08-25T03:30:26.824453+00:00 app[web.1]: self._wrapped =
Settings(settings_module)
2013-08-25T03:30:26.824453+00:00 app[web.1]: __import__(name)
2013-08-25T03:30:26.824453+00:00 app[web.1]: File
"/app/zinnia/settings.py", line 5, in <module>
2013-08-25T03:30:26.824453+00:00 app[web.1]:
('http://django-blog-zinnia.com/xmlrpc/',))
2013-08-25T03:30:26.824453+00:00 app[web.1]: File
"/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py",
line 53, in __getattr__
2013-08-25T03:30:26.824453+00:00 app[web.1]: self._setup(name)
2013-08-25T03:30:26.824759+00:00 app[web.1]: File
"/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py",
line 152, in __init__
2013-08-25T03:30:26.824759+00:00 app[web.1]: File
"/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py",
line 48, in _setup
2013-08-25T03:30:26.824759+00:00 app[web.1]: self._wrapped =
Settings(settings_module)
2013-08-25T03:30:26.824759+00:00 app[web.1]: raise
ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
2013-08-25T03:30:26.824759+00:00 app[web.1]: ImproperlyConfigured: The
SECRET_KEY setting must not be empty.
2013-08-25T03:30:26.825073+00:00 app[web.1]: 2013-08-25 03:30:26 [7]
[INFO] Worker exiting (pid: 7)
2013-08-25T03:30:26.972807+00:00 app[web.1]: 2013-08-25 03:30:26 [2]
[INFO] Shutting down: Master
2013-08-25T03:30:26.972807+00:00 app[web.1]: 2013-08-25 03:30:26 [2]
[INFO] Reason: Worker failed to boot.
2013-08-25T03:30:27.576714+00:00 heroku[web.1]: Process exited with status 0
2013-08-25T03:30:28.190167+00:00 heroku[web.1]: Process exited with status 3
2013-08-25T03:30:28.205185+00:00 heroku[web.1]: State changed from
starting to crashed
Does anyone have experience of this sort of thing?
Need help setting up own nameservers for cPanel
Need help setting up own nameservers for cPanel
I am setting up cpanel with own name servers. I think I got the process
right, but still have a feeling that something was missed.
cPanel is installed on a server with two public ip addresses x.x.x.250 and
x.x.x.251. The hostname I set during installation is server.mydomain.com.
Now lastly I am trying to setup name servers and mydomain.com correctly,
so here is what I have done.
Went to domain registar and registered two nameservers ns1.mydomain.com
pointing to x.x.x.250 and ns2.mydomain.com pointing to x.x.x.251
On domain registar's website added A record for domain.com to point to
x.x.x.250 and *.mydomain.com to point to x.x.x.250 as well.
Now I am not sure about last step. Is it correct or do I have to set name
servers for domain.com to the ones I registered
(ns1.domain.com&ns2.domain.com)? If I do so doesn't that make a conflict
or is nameserver registration is not affected by dns records for
domain.com?
I am setting up cpanel with own name servers. I think I got the process
right, but still have a feeling that something was missed.
cPanel is installed on a server with two public ip addresses x.x.x.250 and
x.x.x.251. The hostname I set during installation is server.mydomain.com.
Now lastly I am trying to setup name servers and mydomain.com correctly,
so here is what I have done.
Went to domain registar and registered two nameservers ns1.mydomain.com
pointing to x.x.x.250 and ns2.mydomain.com pointing to x.x.x.251
On domain registar's website added A record for domain.com to point to
x.x.x.250 and *.mydomain.com to point to x.x.x.250 as well.
Now I am not sure about last step. Is it correct or do I have to set name
servers for domain.com to the ones I registered
(ns1.domain.com&ns2.domain.com)? If I do so doesn't that make a conflict
or is nameserver registration is not affected by dns records for
domain.com?
getting a button to sit with drop down menu
getting a button to sit with drop down menu
I'm doing a redesign for my class, and I can't get the button even with
the drop down menu. I've been trying different ways but cant get them to
line up.
http://jgoldd.github.io/wsp/Project/index.html
I'm doing a redesign for my class, and I can't get the button even with
the drop down menu. I've been trying different ways but cant get them to
line up.
http://jgoldd.github.io/wsp/Project/index.html
Thrift and other Rpc frameworks vs ms rpc
Thrift and other Rpc frameworks vs ms rpc
What is difference between rpc frameworks like thrift or gSoap and
build-in MS RPC if we talk about security configurations. MSDN describes
on
http://msdn.microsoft.com/en-us/library/windows/desktop/aa379441(v=vs.85).aspx
some aspects, so I can presume that there is support from Microsoft in
rpc. Does this mean that if i would like to use different frameworks than
MS, I need to take care of security by myself?
What is difference between rpc frameworks like thrift or gSoap and
build-in MS RPC if we talk about security configurations. MSDN describes
on
http://msdn.microsoft.com/en-us/library/windows/desktop/aa379441(v=vs.85).aspx
some aspects, so I can presume that there is support from Microsoft in
rpc. Does this mean that if i would like to use different frameworks than
MS, I need to take care of security by myself?
Detect if element with focus is a textbox
Detect if element with focus is a textbox
How can I detect if the active element in my VB.NET app is a Textbox?
Me.ActiveControl and then?
How can I detect if the active element in my VB.NET app is a Textbox?
Me.ActiveControl and then?
What is a substitute for mascarpone cheese?
What is a substitute for mascarpone cheese?
I've found mascarpone cheese can be pricey. What would be a good (in taste
and price) substitute?
I've found mascarpone cheese can be pricey. What would be a good (in taste
and price) substitute?
Magento- new order notification email add custom field- table sales_flat_order
Magento- new order notification email add custom field- table
sales_flat_order
I would like to add custom variable on new order email notification having
value populated from table sales_flat_order (i.e. heared4us ). How can I
do this ?
I am using magento version 1.7.0.2
Thanks.
sales_flat_order
I would like to add custom variable on new order email notification having
value populated from table sales_flat_order (i.e. heared4us ). How can I
do this ?
I am using magento version 1.7.0.2
Thanks.
Friday, 23 August 2013
Best database to store web pages
Best database to store web pages
What is the best database to store the web pages?
First in place requirements are:
compression - it can be slow, but very effective (should pack not just by
the small amount of blocks);
versioning - better, if it's built-in.
Currently I found that the hBase is more or less what I'm searching, but
may be someone else have the better idea and can suggest me a better
match?
What is the best database to store the web pages?
First in place requirements are:
compression - it can be slow, but very effective (should pack not just by
the small amount of blocks);
versioning - better, if it's built-in.
Currently I found that the hBase is more or less what I'm searching, but
may be someone else have the better idea and can suggest me a better
match?
WPF DataGrid Binding List of Object that contains Dictionary in XAML
WPF DataGrid Binding List of Object that contains Dictionary in XAML
I'm trying to figure out how to display the data from a dictionary
property of a list inside a WPF DataGrid GridViewColumn
All the examples I find only appear to map to list of simple entities that
can be . traversed like {Binding Answers.Title}. Mine however would be
more like {Binding Answers["Title"]} which doesn't work in XAML
I'm missing something obvious here. Any ideas?
Edit: The list contains an entity that contains a Dictionary. Where
Answers is the dictionary in the entity.
I'm trying to figure out how to display the data from a dictionary
property of a list inside a WPF DataGrid GridViewColumn
All the examples I find only appear to map to list of simple entities that
can be . traversed like {Binding Answers.Title}. Mine however would be
more like {Binding Answers["Title"]} which doesn't work in XAML
I'm missing something obvious here. Any ideas?
Edit: The list contains an entity that contains a Dictionary. Where
Answers is the dictionary in the entity.
udhcpc: bind: No such device error
udhcpc: bind: No such device error
How do I fix an error like this?
udhcpc -i wlan0
udhcpc (v1.19.4) started
Sending discover...
Sending discover...
Sending discover...
Read error: Network is down, reopening socket
udhcpc: bind: No such device
How do I fix an error like this?
udhcpc -i wlan0
udhcpc (v1.19.4) started
Sending discover...
Sending discover...
Sending discover...
Read error: Network is down, reopening socket
udhcpc: bind: No such device
iPHONE xcode naviagation
iPHONE xcode naviagation
I am fairly new to iPHONE development. I am using xcode v. 4.6.2. I
started a storybook project without using NavigatorController as the root
in my app., but I placed one in on the 3rd ViewController. As I advance
forward to sub-views I can return back to the 3rd viewcontroller via the
back button on the NavigatorController, now I want to go back to the 2nd
viewcontroller but not sure how to to that.
What the best way to return to the 2nd viewController?
Thanks for your help
I am fairly new to iPHONE development. I am using xcode v. 4.6.2. I
started a storybook project without using NavigatorController as the root
in my app., but I placed one in on the 3rd ViewController. As I advance
forward to sub-views I can return back to the 3rd viewcontroller via the
back button on the NavigatorController, now I want to go back to the 2nd
viewcontroller but not sure how to to that.
What the best way to return to the 2nd viewController?
Thanks for your help
Database poller thread, any alternate approach?
Database poller thread, any alternate approach?
I am running a thread that polls a table every minute and queues to
perform the processes, but I feel this is a single point of failure. I
have another thread to monitor this polling thread, to restart whenever
the poller crashes. But still the problem is not fully addressed, as the
meta monitoring thread can fail anytime! Apart from ejb timers is there
any other api/framework/design approach to address this issue? Can this be
done with Apache Camel or Mule? Is there any api to get events on database
changes, I couldn't find one!
I am running a thread that polls a table every minute and queues to
perform the processes, but I feel this is a single point of failure. I
have another thread to monitor this polling thread, to restart whenever
the poller crashes. But still the problem is not fully addressed, as the
meta monitoring thread can fail anytime! Apart from ejb timers is there
any other api/framework/design approach to address this issue? Can this be
done with Apache Camel or Mule? Is there any api to get events on database
changes, I couldn't find one!
Thursday, 22 August 2013
((((((((((((( __ READ __ BEFORE ___ DELETED ___ BY ___ MODS ___ ))))))))))))))
((((((((((((( __ READ __ BEFORE ___ DELETED ___ BY ___ MODS ___
))))))))))))))
spam removed. spam removed. spam removed. spam removed. spam removed.
))))))))))))))
spam removed. spam removed. spam removed. spam removed. spam removed.
communication between two objects
communication between two objects
I have two objects, I hope to establish the communication between the two
objects. Is there a common way to do this? Of course, I know I can invoke
the method of two objects. Is there any other way?
Your comment welcome
I have two objects, I hope to establish the communication between the two
objects. Is there a common way to do this? Of course, I know I can invoke
the method of two objects. Is there any other way?
Your comment welcome
multiline checkbox using jQueryMobile
multiline checkbox using jQueryMobile
I want to add some more text with a different style and in yellow.
Is there a way to do this inside checkbox?
for example:
<fieldset data-role="controlgroup" data-iconpos="right">
<input type="checkbox" name="checkbox-v-6b"
id="checkbox-v-6b">
<label for="checkbox-v-6b">
some text</label>
</fieldset>
I've tried to add another label but that didn't work...
Any suggestions?
I want to add some more text with a different style and in yellow.
Is there a way to do this inside checkbox?
for example:
<fieldset data-role="controlgroup" data-iconpos="right">
<input type="checkbox" name="checkbox-v-6b"
id="checkbox-v-6b">
<label for="checkbox-v-6b">
some text</label>
</fieldset>
I've tried to add another label but that didn't work...
Any suggestions?
Why is __strong required in ARC
Why is __strong required in ARC
When I do something simialr to the following I get an error saying
for (UIView* att in bottomAttachments) {
if (i <= [cells count]) {
att = [[UIView alloc] extraStuff]
}
}
Fast Enumeration variables cannot be modified in ARC: declare __strong
What does __strong do and why must I add it?
When I do something simialr to the following I get an error saying
for (UIView* att in bottomAttachments) {
if (i <= [cells count]) {
att = [[UIView alloc] extraStuff]
}
}
Fast Enumeration variables cannot be modified in ARC: declare __strong
What does __strong do and why must I add it?
SQL Server 2012 web edition use for desktop applications
SQL Server 2012 web edition use for desktop applications
Can I use normal desktop applications with a SQL server 2012 web edition
or is that prohibited in the license? I found other questions regarding
the web edition (SQL Server 2008 Web Edition) but this is specifically if
it is possible license wise and technical to use it instead of SQL server
standard.
Can I use normal desktop applications with a SQL server 2012 web edition
or is that prohibited in the license? I found other questions regarding
the web edition (SQL Server 2008 Web Edition) but this is specifically if
it is possible license wise and technical to use it instead of SQL server
standard.
counting checkbox and showing the value
counting checkbox and showing the value
I am using the following jquery to show the selected number of checkboxes
selected
$(document).ready(function(){
$('.check:button').toggle(function(){
$('input:checkbox').attr('checked','checked');
var count = $("input[type=checkbox]:checked").size();
$(this).val('uncheck all')
$("#count").text(count+ " item(s) selected");
},function(){
$('input:checkbox').removeAttr('checked');
var count = $("input[type=checkbox]:checked").size();
$(this).val('check all');
$("#count").text(count+ " item(s) selected");
})
})
here is the html
<input type="button" class="check" value="check all" />
<input type="checkbox" class="cb-element" /> Checkbox 1
<input type="checkbox" class="cb-element" /> Checkbox 2
<input type="checkbox" class="cb-element" /> Checkbox 3
<p id="count"></p>
When i check all it shows the right numbers, like 3 items selected and
when i uncheck all, then it shows o items selected.
But when I remove individual selected checkbox then the count does not
show up. like if i remove one, then the count will still be 3 and not the
2.
how can i achieve this?
I am using the following jquery to show the selected number of checkboxes
selected
$(document).ready(function(){
$('.check:button').toggle(function(){
$('input:checkbox').attr('checked','checked');
var count = $("input[type=checkbox]:checked").size();
$(this).val('uncheck all')
$("#count").text(count+ " item(s) selected");
},function(){
$('input:checkbox').removeAttr('checked');
var count = $("input[type=checkbox]:checked").size();
$(this).val('check all');
$("#count").text(count+ " item(s) selected");
})
})
here is the html
<input type="button" class="check" value="check all" />
<input type="checkbox" class="cb-element" /> Checkbox 1
<input type="checkbox" class="cb-element" /> Checkbox 2
<input type="checkbox" class="cb-element" /> Checkbox 3
<p id="count"></p>
When i check all it shows the right numbers, like 3 items selected and
when i uncheck all, then it shows o items selected.
But when I remove individual selected checkbox then the count does not
show up. like if i remove one, then the count will still be 3 and not the
2.
how can i achieve this?
how to retrieve Data from sqlite database
how to retrieve Data from sqlite database
I have created a table in SQLite database with following statement.
i.e.
static final String DATABASE_CREATE =
"create table " + "TEST" +
"( " + "ID" + " integer primary key autoincrement," +
" UID text, FULLNAME text, GENDER integer, MSTATUS integer, MOBILE text,
AGE text );";
with this statement, I can able to insert data but I want to design a
function that will accept the mobile no. and return the UID.
I have created a table in SQLite database with following statement.
i.e.
static final String DATABASE_CREATE =
"create table " + "TEST" +
"( " + "ID" + " integer primary key autoincrement," +
" UID text, FULLNAME text, GENDER integer, MSTATUS integer, MOBILE text,
AGE text );";
with this statement, I can able to insert data but I want to design a
function that will accept the mobile no. and return the UID.
Wednesday, 21 August 2013
Javascript : Why most javascript be used to write a cookie to a browser, why not a plain HTML file?
Javascript : Why most javascript be used to write a cookie to a browser,
why not a plain HTML file?
Whatever the browser wants.. can't HTML do it ?
The browser is suppose to be an
interpreter
it is not suppose to be "racist" or "biased"
towards who to accept the cookie from of.
why is it not possible to set a cookie simply
with a basic html page ?
or even an image file.
the browser is simply 'LOADING' these things.
and whatever is being "LOADED" is simply being
interpreted
in other words "BROWSER" is not suppose to take commands.
it simply should be listening to commands.
if it is simply listening to commands then even a simple
text file should be capable of writing a cookie to the browser.
why not a plain HTML file?
Whatever the browser wants.. can't HTML do it ?
The browser is suppose to be an
interpreter
it is not suppose to be "racist" or "biased"
towards who to accept the cookie from of.
why is it not possible to set a cookie simply
with a basic html page ?
or even an image file.
the browser is simply 'LOADING' these things.
and whatever is being "LOADED" is simply being
interpreted
in other words "BROWSER" is not suppose to take commands.
it simply should be listening to commands.
if it is simply listening to commands then even a simple
text file should be capable of writing a cookie to the browser.
Using Parameter Vectors of Different Lengths in R
Using Parameter Vectors of Different Lengths in R
Assume I have two different parameter vectors used as inputs in a
function. Also, assume the two parameter vectors are of different lengths.
Is there a way to output all the possible values of that function? I know
that if I use two parameter vectors of different lengths, then the shorter
parameter vector is just repeated so that doesn't work. I can solve this
"manually" as you can see below. But, I'd like to find a more efficient
manner of calculating all the possible combinations. An example follows:
Assume I'm using the dbinom() function that has as inputs x (number of
"successes" from the sample), n (number of observations in the sample),
and p (the probability of "success" for each x). n stays constant at 20;
however, my x varies from 7,8,9,...,20 ("x7" below) or 0,1 ("x1" below).
Also, I want to evaluate dbinom() at different values of p, specifically
from 0 to 1 in .1 increments ("p" below). As you can see the three
parameter vectors x7, x1, and p are all of different lengths 14, 2, and
11, respectively.
> p<-seq(from=0,to=1,by=.1)
> x7<-seq.int(7,20)
> x1<-c(0,1)
> n<-20
I can evaluate each combination by using one of the vectors (x7/x2 or p)
in dbinom() and then selecting a value for the remaining parameter. As you
can see below, I used the vector x7 or x2 and then "manually" changed the
p to equal 0,.1,.2,...,1.
> sum(dbinom(x7,n,.1))
[1] 0.002386089
> sum(dbinom(x7,n,.1))+sum(dbinom(x1,n,.1))
[1] 0.3941331
> sum(dbinom(x7,n,.2))+sum(dbinom(x1,n,.2))
[1] 0.1558678
> sum(dbinom(x7,n,.3))+sum(dbinom(x1,n,.3))
[1] 0.3996274
> sum(dbinom(x7,n,.4))+sum(dbinom(x1,n,.4))
[1] 0.7505134
> sum(dbinom(x7,n,.5))+sum(dbinom(x1,n,.5))
[1] 0.9423609
> sum(dbinom(x7,n,.6))+sum(dbinom(x1,n,.6))
[1] 0.9935345
> sum(dbinom(x7,n,.7))+sum(dbinom(x1,n,.7))
[1] 0.999739
> sum(dbinom(x7,n,.8))+sum(dbinom(x1,n,.8))
[1] 0.9999982
> sum(dbinom(x7,n,.9))+sum(dbinom(x1,n,.9))
[1] 1
> sum(dbinom(x7,n,1))+sum(dbinom(x1,n,1))
[1] 1
Basically, I want to know if there is a way to get R to print all the sums
above from 0.3941331,0.1558678,...,1 with a single line of input or some
other more efficient way of varying the parameter p without simply copying
and changing p on each line.
*I'm new to Stackoverflow, so I apologize in advance if I have not
formulated my question conventionally.
Assume I have two different parameter vectors used as inputs in a
function. Also, assume the two parameter vectors are of different lengths.
Is there a way to output all the possible values of that function? I know
that if I use two parameter vectors of different lengths, then the shorter
parameter vector is just repeated so that doesn't work. I can solve this
"manually" as you can see below. But, I'd like to find a more efficient
manner of calculating all the possible combinations. An example follows:
Assume I'm using the dbinom() function that has as inputs x (number of
"successes" from the sample), n (number of observations in the sample),
and p (the probability of "success" for each x). n stays constant at 20;
however, my x varies from 7,8,9,...,20 ("x7" below) or 0,1 ("x1" below).
Also, I want to evaluate dbinom() at different values of p, specifically
from 0 to 1 in .1 increments ("p" below). As you can see the three
parameter vectors x7, x1, and p are all of different lengths 14, 2, and
11, respectively.
> p<-seq(from=0,to=1,by=.1)
> x7<-seq.int(7,20)
> x1<-c(0,1)
> n<-20
I can evaluate each combination by using one of the vectors (x7/x2 or p)
in dbinom() and then selecting a value for the remaining parameter. As you
can see below, I used the vector x7 or x2 and then "manually" changed the
p to equal 0,.1,.2,...,1.
> sum(dbinom(x7,n,.1))
[1] 0.002386089
> sum(dbinom(x7,n,.1))+sum(dbinom(x1,n,.1))
[1] 0.3941331
> sum(dbinom(x7,n,.2))+sum(dbinom(x1,n,.2))
[1] 0.1558678
> sum(dbinom(x7,n,.3))+sum(dbinom(x1,n,.3))
[1] 0.3996274
> sum(dbinom(x7,n,.4))+sum(dbinom(x1,n,.4))
[1] 0.7505134
> sum(dbinom(x7,n,.5))+sum(dbinom(x1,n,.5))
[1] 0.9423609
> sum(dbinom(x7,n,.6))+sum(dbinom(x1,n,.6))
[1] 0.9935345
> sum(dbinom(x7,n,.7))+sum(dbinom(x1,n,.7))
[1] 0.999739
> sum(dbinom(x7,n,.8))+sum(dbinom(x1,n,.8))
[1] 0.9999982
> sum(dbinom(x7,n,.9))+sum(dbinom(x1,n,.9))
[1] 1
> sum(dbinom(x7,n,1))+sum(dbinom(x1,n,1))
[1] 1
Basically, I want to know if there is a way to get R to print all the sums
above from 0.3941331,0.1558678,...,1 with a single line of input or some
other more efficient way of varying the parameter p without simply copying
and changing p on each line.
*I'm new to Stackoverflow, so I apologize in advance if I have not
formulated my question conventionally.
Undefined variable niggles
Undefined variable niggles
Below is my class. Fig A
<?php
class qcon{
public static $conn;
function dbcon()
{
if (!$conn)
{
$host = 'x';
$username = 'x';
$password = 'x';
$dbname = 'x';
$conn = mysqli_connect($host , $username , $password ,$dbname);
}
return $conn;
}
}
?>
Which is called here. Fig B
require_once(class file above);
function openSesame()
{
$boogey = new qcon();
$conn = $boogey->dbcon();
if (!$conn)
{
$this->error_msg = "connection error could not connect to the
database:! ";
return false;
}
$this->conn = $conn;
return true;
}
Is causing
Notice: Undefined variable: conn in C:\...\xxxx\figAclass.php on line 10
I know I can simply turn errors off, but this seems unwise. I took a look
at a generic SO question about the undefined variable notice. Obviously
the advice was general - use isset. Had a go at isset and this does not
seem correct for what I am trying to do.
Based on the code in figure A and B, is there anything obvious causing the
notice to be flagged up. Could you demonstrate a fix that is in line with
the existing code shown.
Below is my class. Fig A
<?php
class qcon{
public static $conn;
function dbcon()
{
if (!$conn)
{
$host = 'x';
$username = 'x';
$password = 'x';
$dbname = 'x';
$conn = mysqli_connect($host , $username , $password ,$dbname);
}
return $conn;
}
}
?>
Which is called here. Fig B
require_once(class file above);
function openSesame()
{
$boogey = new qcon();
$conn = $boogey->dbcon();
if (!$conn)
{
$this->error_msg = "connection error could not connect to the
database:! ";
return false;
}
$this->conn = $conn;
return true;
}
Is causing
Notice: Undefined variable: conn in C:\...\xxxx\figAclass.php on line 10
I know I can simply turn errors off, but this seems unwise. I took a look
at a generic SO question about the undefined variable notice. Obviously
the advice was general - use isset. Had a go at isset and this does not
seem correct for what I am trying to do.
Based on the code in figure A and B, is there anything obvious causing the
notice to be flagged up. Could you demonstrate a fix that is in line with
the existing code shown.
How to unchecked all checkboxes except checkboxes in a table whose id is passed as a variable to a function using jquery?
How to unchecked all checkboxes except checkboxes in a table whose id is
passed as a variable to a function using jquery?
How to unchecked all checkboxes except checkboxes in a table whose id is
passed as a variable to a function using jquery
passed as a variable to a function using jquery?
How to unchecked all checkboxes except checkboxes in a table whose id is
passed as a variable to a function using jquery
how to apply css on specific td on first tr
how to apply css on specific td on first tr
I'm a beginner in AngularJS, and really want not to use JQuery to solve my
problem (maybe I'm wrong).
Here's my problem :
I would like to apply a CSS on the last td element in the first tr in a
table.
My code :
<table>
<tr ng-repeat="person in persons | orderBy:'name'">
<td></td>
</tr>
</table>
So for the first tr, the last td element should be <td
class="myClass">{{person.email}}</td>
Thanks for your answers and explanations.
Edit : I Forgot to say, I know how to resolve my problem by applying css
on the last td, but I want to do it with angularjs, because I can have
differents persons, and depends on the difference, I want to apply another
CSS style.
I'm a beginner in AngularJS, and really want not to use JQuery to solve my
problem (maybe I'm wrong).
Here's my problem :
I would like to apply a CSS on the last td element in the first tr in a
table.
My code :
<table>
<tr ng-repeat="person in persons | orderBy:'name'">
<td></td>
</tr>
</table>
So for the first tr, the last td element should be <td
class="myClass">{{person.email}}</td>
Thanks for your answers and explanations.
Edit : I Forgot to say, I know how to resolve my problem by applying css
on the last td, but I want to do it with angularjs, because I can have
differents persons, and depends on the difference, I want to apply another
CSS style.
Tuesday, 20 August 2013
Jaydata and Odata- HTTP Request Failed
Jaydata and Odata- HTTP Request Failed
I have my own custom server to expose data from an XML file. I can browse
through it in whichever browser of my choosing and I can query the data in
Fiddler, but Jaydata (or one of its building blocks) can't seem to grab
the same data. What's most frustrating is that my code is (or was, I've
tweaked it slightly to try and resolve these errors) pretty much an exact
duplicate of code found here and here. Here's my script:
<script type="text/javascript" src="/Scripts/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="/Scripts/datajs-1.0.3.js"></script>
<script type="text/javascript" src="/Scripts/jaydata.js"></script>
<script type="text/javascript"
src="/Scripts/jaydataproviders/oDataProvider.js"></script>
<script type="text/javascript" src="/Scripts/Block.js"></script>
<script type="text/javascript">
var Context = new foo({
name: 'oData',
oDataServiceHost: 'http://localhost:xxx'
});
function createItemLI(user, id, css) {
var li = "<li></li>".append(name).addClass(css).data('id', id);
return li;
}
$.when($.ready, Context.onReady()).then(function () {
Context.Roots.toArray(function (roots) {
roots.forEach(function (root) {
$('#roots').append(
createItemLI(root.User, root.ID, 'root'));
});
});
});
</script>
Block.js, is the file generated by JaySvcUtil.exe There's only one thing
in the body of the .htm file, a simple <ul id="roots"></ul>
When I try to run the project, there's nothing on the page. When I used
FireBug, I get "HTTP request failed" The requestUri is
http://localhost:xxx/Roots, which works when I manually browse to it, but
the StatusCode is 0, statusText is the empty string, and so on and so
forth. I've looked at Fiddler, at it gets exactly what I expected.
I'm assuming there's some manner of flag that needs to be set, but none of
the tutorials I've found have been of any help. It's assumed that it works
out of the box, and I too had high expectations getting simple read access
would be easy.
I have my own custom server to expose data from an XML file. I can browse
through it in whichever browser of my choosing and I can query the data in
Fiddler, but Jaydata (or one of its building blocks) can't seem to grab
the same data. What's most frustrating is that my code is (or was, I've
tweaked it slightly to try and resolve these errors) pretty much an exact
duplicate of code found here and here. Here's my script:
<script type="text/javascript" src="/Scripts/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="/Scripts/datajs-1.0.3.js"></script>
<script type="text/javascript" src="/Scripts/jaydata.js"></script>
<script type="text/javascript"
src="/Scripts/jaydataproviders/oDataProvider.js"></script>
<script type="text/javascript" src="/Scripts/Block.js"></script>
<script type="text/javascript">
var Context = new foo({
name: 'oData',
oDataServiceHost: 'http://localhost:xxx'
});
function createItemLI(user, id, css) {
var li = "<li></li>".append(name).addClass(css).data('id', id);
return li;
}
$.when($.ready, Context.onReady()).then(function () {
Context.Roots.toArray(function (roots) {
roots.forEach(function (root) {
$('#roots').append(
createItemLI(root.User, root.ID, 'root'));
});
});
});
</script>
Block.js, is the file generated by JaySvcUtil.exe There's only one thing
in the body of the .htm file, a simple <ul id="roots"></ul>
When I try to run the project, there's nothing on the page. When I used
FireBug, I get "HTTP request failed" The requestUri is
http://localhost:xxx/Roots, which works when I manually browse to it, but
the StatusCode is 0, statusText is the empty string, and so on and so
forth. I've looked at Fiddler, at it gets exactly what I expected.
I'm assuming there's some manner of flag that needs to be set, but none of
the tutorials I've found have been of any help. It's assumed that it works
out of the box, and I too had high expectations getting simple read access
would be easy.
f:param does not work with p:commandLink or h:commandLink on query string
f:param does not work with p:commandLink or h:commandLink on query string
f:param works great with h:link, but not with p:commandLink or h:commandLink.
For example, I have two pages test_first.xhtml and test_second.xhtml, and
a backing java bean TestBean.java.
I start running test_first.xhtml.
If I click link1, which is a h:link, the page will redirect to
test_second.xhtml. With the help of f:param, the address bar of the
browser will show .../test_second.xhtml?id=1. On that page,
testBean.userId gets printed.
If I click link2 or link3, the page redirects to test_second.xhtml.
However, the address bar only shows .../test_second.xhtml, there is NO
?id=#! And testBean.userId does not get printed on that page.
How can I make commandLink work with f:param? Sometimes I want the link
not to redirect to another page but to call some methods of bean depending
on the data.
test_first.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head/>
<h:body>
<h:form>
<h:link value="link1" outcome="test_second" >
<f:param name="id" value="1"/>
</h:link>
<br/><br/>
<h:commandLink value="link2" action="test_second?faces-redirect=true" >
<f:param name="id" value="2" />
</h:commandLink>
<br/><br/>
<p:commandLink value="link3" action="test_second?faces-redirect=true">
<f:param name="id" value="3" />
</p:commandLink>
<br/><br/>
</h:form>
</h:body>
</html>
test_second.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<f:metadata>
<f:viewParam name="id" value="#{testBean.userId}" />
</f:metadata>
<h:head/>
<h:body>
<h:form>
This is the second page.
<h:outputText value="Selected id is #{testBean.userId}" />
<h:commandButton value="Print page id" action="#{testBean.print()}" />
</h:form>
</h:body>
</html>
TestBean.java
@ManagedBean
@SessionScoped
public class TestBean implements Serializable{
private Integer userId;
public void print() {
System.out.println(userId);
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
}
f:param works great with h:link, but not with p:commandLink or h:commandLink.
For example, I have two pages test_first.xhtml and test_second.xhtml, and
a backing java bean TestBean.java.
I start running test_first.xhtml.
If I click link1, which is a h:link, the page will redirect to
test_second.xhtml. With the help of f:param, the address bar of the
browser will show .../test_second.xhtml?id=1. On that page,
testBean.userId gets printed.
If I click link2 or link3, the page redirects to test_second.xhtml.
However, the address bar only shows .../test_second.xhtml, there is NO
?id=#! And testBean.userId does not get printed on that page.
How can I make commandLink work with f:param? Sometimes I want the link
not to redirect to another page but to call some methods of bean depending
on the data.
test_first.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head/>
<h:body>
<h:form>
<h:link value="link1" outcome="test_second" >
<f:param name="id" value="1"/>
</h:link>
<br/><br/>
<h:commandLink value="link2" action="test_second?faces-redirect=true" >
<f:param name="id" value="2" />
</h:commandLink>
<br/><br/>
<p:commandLink value="link3" action="test_second?faces-redirect=true">
<f:param name="id" value="3" />
</p:commandLink>
<br/><br/>
</h:form>
</h:body>
</html>
test_second.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<f:metadata>
<f:viewParam name="id" value="#{testBean.userId}" />
</f:metadata>
<h:head/>
<h:body>
<h:form>
This is the second page.
<h:outputText value="Selected id is #{testBean.userId}" />
<h:commandButton value="Print page id" action="#{testBean.print()}" />
</h:form>
</h:body>
</html>
TestBean.java
@ManagedBean
@SessionScoped
public class TestBean implements Serializable{
private Integer userId;
public void print() {
System.out.println(userId);
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
}
Vibration triggered by alarm when device is asleep doesn't stop
Vibration triggered by alarm when device is asleep doesn't stop
I'm rather wondering if this is specific to my device (Nexus 4, Android
4.3, stock ROM), but I have an alarm, registered once via the
AlarmManager. When triggered, the device is set to vibrate for two
seconds. If the alarm is triggered while the device is on, then it
correctly vibrates for the two seconds. However, if the alarm is triggered
when the device is off (and unplugged), the vibration starts, but doesn't
stop until the power button is pressed (to wake up the device). Here is
the code to register the alarm:
public static void registerAlarm(Context context, int uniqueId, long
triggerAlarmAt)
{
Intent intent = new Intent(context, AlarmReceiver.class);
intent.setAction("com.myapp.ALARM_EVENT");
PendingIntent pendingIntent =
PendingIntent.getBroadcast(context.getApplicationContext(), uniqueId,
intent, 0);
AlarmManager alarmManager = (AlarmManager)
context.getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAlarmAt, pendingIntent);
}
And the receiver code:
public class AlarmReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent arg1)
{
Vibrator vibrator = (Vibrator)
context.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(2000);
}
}
Any ideas on why this is happening or how to prevent it?
I'm rather wondering if this is specific to my device (Nexus 4, Android
4.3, stock ROM), but I have an alarm, registered once via the
AlarmManager. When triggered, the device is set to vibrate for two
seconds. If the alarm is triggered while the device is on, then it
correctly vibrates for the two seconds. However, if the alarm is triggered
when the device is off (and unplugged), the vibration starts, but doesn't
stop until the power button is pressed (to wake up the device). Here is
the code to register the alarm:
public static void registerAlarm(Context context, int uniqueId, long
triggerAlarmAt)
{
Intent intent = new Intent(context, AlarmReceiver.class);
intent.setAction("com.myapp.ALARM_EVENT");
PendingIntent pendingIntent =
PendingIntent.getBroadcast(context.getApplicationContext(), uniqueId,
intent, 0);
AlarmManager alarmManager = (AlarmManager)
context.getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAlarmAt, pendingIntent);
}
And the receiver code:
public class AlarmReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent arg1)
{
Vibrator vibrator = (Vibrator)
context.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(2000);
}
}
Any ideas on why this is happening or how to prevent it?
SQL 2008 Select certain columns have specific data
SQL 2008 Select certain columns have specific data
i have a table some of its fields are of a bit datatype. I need to select
only the [BIT] datatype columns and with the value of [TRUE]. i have the
following code to select only the [BIT] columns from a given table.
SELECT OBJECT_NAME(c.OBJECT_ID) TableName, c.name ColumnName
FROM sys.columns AS c
JOIN sys.types AS t ON c.user_type_id=t.user_type_id
join sys.all_objects as o on o.object_id = c.object_id
WHERE t.name = 'bit'
and o.name = 'TABLENAME' --this is the table name
ORDER BY c.OBJECT_ID
GO
Please tell me how to select only those with [TRUE] value
thanks
i have a table some of its fields are of a bit datatype. I need to select
only the [BIT] datatype columns and with the value of [TRUE]. i have the
following code to select only the [BIT] columns from a given table.
SELECT OBJECT_NAME(c.OBJECT_ID) TableName, c.name ColumnName
FROM sys.columns AS c
JOIN sys.types AS t ON c.user_type_id=t.user_type_id
join sys.all_objects as o on o.object_id = c.object_id
WHERE t.name = 'bit'
and o.name = 'TABLENAME' --this is the table name
ORDER BY c.OBJECT_ID
GO
Please tell me how to select only those with [TRUE] value
thanks
Simplifying linq when filtering data
Simplifying linq when filtering data
I wanted to ask for suggestions how I can simplify the foreach block
below. I tried to make it all in one linq statement, but I couldn't figure
out how to manipulate "count" values inside the query.
More details about what I'm trying to achieve: - I have a huge list with
potential duplicates, where Id's are repeated, but property "Count" is
different numbers - I want to get rid of duplicates, but still not to
loose those "Count" values - so for the items with the same Id I summ up
the "Count" properties
Still, the current code doesn't look pretty:
var grouped = bigList.GroupBy(c => c.Id).ToList();
foreach (var items in grouped)
{
var count = 0;
items.Each(c=> count += c.Count);
items.First().Count = count;
}
var filtered = grouped.Select(y => y.First());
I don't expect the whole solution, pieces of ideas will be also highly
appreciated :)
I wanted to ask for suggestions how I can simplify the foreach block
below. I tried to make it all in one linq statement, but I couldn't figure
out how to manipulate "count" values inside the query.
More details about what I'm trying to achieve: - I have a huge list with
potential duplicates, where Id's are repeated, but property "Count" is
different numbers - I want to get rid of duplicates, but still not to
loose those "Count" values - so for the items with the same Id I summ up
the "Count" properties
Still, the current code doesn't look pretty:
var grouped = bigList.GroupBy(c => c.Id).ToList();
foreach (var items in grouped)
{
var count = 0;
items.Each(c=> count += c.Count);
items.First().Count = count;
}
var filtered = grouped.Select(y => y.First());
I don't expect the whole solution, pieces of ideas will be also highly
appreciated :)
Adding a SSD on existing configuration
Adding a SSD on existing configuration
I want to install a SSD to speed up my computer, but I'am still unsure on
how to.
I currently have 2 hard drives of each 500GB partitionned into one volume
of 200GB for the OS and software, the remainder for data storage. These
hard drives use the only 2 SATA3 connections, there are also 4 SATA2 ports
which are currently not used.
So when I install the SSD, do I just plug it in a SATA2 port? Or should I
transfer one hard drive (or both) to the SATA2 port so that the SSD can
use the SATA3?
Thanks!
I want to install a SSD to speed up my computer, but I'am still unsure on
how to.
I currently have 2 hard drives of each 500GB partitionned into one volume
of 200GB for the OS and software, the remainder for data storage. These
hard drives use the only 2 SATA3 connections, there are also 4 SATA2 ports
which are currently not used.
So when I install the SSD, do I just plug it in a SATA2 port? Or should I
transfer one hard drive (or both) to the SATA2 port so that the SSD can
use the SATA3?
Thanks!
Cannot login with non-admin account using AD as identity server's user store
Cannot login with non-admin account using AD as identity server's user store
I configured the IS and I can log in the admin console with the admin
account and it's AD password. In 'Users and Roles', I can see AD accounts
are imported. However, I can't login with any of these account except my
admin account. Anyone knows what the problem is?
I configured the IS and I can log in the admin console with the admin
account and it's AD password. In 'Users and Roles', I can see AD accounts
are imported. However, I can't login with any of these account except my
admin account. Anyone knows what the problem is?
Monday, 19 August 2013
Aptana PHP Code Formatter - Doesn't work?
Aptana PHP Code Formatter - Doesn't work?
Aptana's code formatter is fairly straight-forward. But it does not seem
to work?
In some cases it formats nicely, but in others, it sticks the code flat
against the left.
I could paste examples, but overall its just horrible.
Is this a known fact or does there exist upgrades of any sort needed for
PHP formatting?
Aptana's code formatter is fairly straight-forward. But it does not seem
to work?
In some cases it formats nicely, but in others, it sticks the code flat
against the left.
I could paste examples, but overall its just horrible.
Is this a known fact or does there exist upgrades of any sort needed for
PHP formatting?
Sorting the values in the treemap
Sorting the values in the treemap
I read a text file and stored in a Tree map with each key having multiple
values.Like,
key: A1BG values: G5730 A4527 E3732 B0166
key: BCA3 values: C1478 A4172 D8974 B1432 E2147
key: DB8C values: N0124 K7414 X9851
Since it is tree map I got all the keys sorted.Now,I want to sort all
those values corresponding to the key.And get o/p As,
key: A1BG values: A4527 B0166 E3732 G5730
key: BCA3 values: A4172 B1432 C1478 D8974 E2147
key: DB8C values: K7414 N0124 X9851
Iam new to java.Can anyone help over this. Here is my code
BufferedReader reader = new BufferedReader(new
FileReader("E:\\book\\datasone.txt"));
Map<String, String> map = new TreeMap<String,String>();
String currentLine;
while ((currentLine = reader.readLine()) != null)
{
String[] pair = currentLine.split("\\s+");
key = pair[0];
value = pair[1];
if(map.containsKey(key))
{
value += map.get(key);
}
else
{
map.put(key,value);
}
}
for (String name: map.keySet())
{
String key =name.toString();
String value = map.get(name).toString();
System.out.println(key + " " + value+ " ");
}
I read a text file and stored in a Tree map with each key having multiple
values.Like,
key: A1BG values: G5730 A4527 E3732 B0166
key: BCA3 values: C1478 A4172 D8974 B1432 E2147
key: DB8C values: N0124 K7414 X9851
Since it is tree map I got all the keys sorted.Now,I want to sort all
those values corresponding to the key.And get o/p As,
key: A1BG values: A4527 B0166 E3732 G5730
key: BCA3 values: A4172 B1432 C1478 D8974 E2147
key: DB8C values: K7414 N0124 X9851
Iam new to java.Can anyone help over this. Here is my code
BufferedReader reader = new BufferedReader(new
FileReader("E:\\book\\datasone.txt"));
Map<String, String> map = new TreeMap<String,String>();
String currentLine;
while ((currentLine = reader.readLine()) != null)
{
String[] pair = currentLine.split("\\s+");
key = pair[0];
value = pair[1];
if(map.containsKey(key))
{
value += map.get(key);
}
else
{
map.put(key,value);
}
}
for (String name: map.keySet())
{
String key =name.toString();
String value = map.get(name).toString();
System.out.println(key + " " + value+ " ");
}
How to remove object from List Collection
How to remove object from List Collection
So i have a List of a custom object class so the code looks as follow
var itemList = new List<Item>();
so for my Item its really just a simple class it only inherits defaults,
and only has 3 private fields called
private double Price;
private string @Url;
private string Name;
public double setPrice(string price)
{
this.Price = price;
}
and similar for accessor methods. Now The list of items is for a windows
form project that stores Item info. Now i have 2 questions,
One. How can I remove an Item from the list? Two. How can I access the
itemList variable from a seperate windows form within the same project.
Example when hitting edit a new window pops up creating a seperate windows
form but how can i make the edit window be able to use the itemList
variable?
So i have a List of a custom object class so the code looks as follow
var itemList = new List<Item>();
so for my Item its really just a simple class it only inherits defaults,
and only has 3 private fields called
private double Price;
private string @Url;
private string Name;
public double setPrice(string price)
{
this.Price = price;
}
and similar for accessor methods. Now The list of items is for a windows
form project that stores Item info. Now i have 2 questions,
One. How can I remove an Item from the list? Two. How can I access the
itemList variable from a seperate windows form within the same project.
Example when hitting edit a new window pops up creating a seperate windows
form but how can i make the edit window be able to use the itemList
variable?
(Resolved) Reply-To header not picking the php variable
(Resolved) Reply-To header not picking the php variable
I am creating a page that sends the response from contact form within mail
but reply-to is not working (the variable i am using is having value, but
is not added within headers)
here's my code:
<?php
//$uname=$_REQUEST['uname'];
if(isset($_REQUEST['name']))
{
$name=$_REQUEST['name'];
}
if(isset($_REQUEST['email']))
{
$email=$_REQUEST['email'];
}
if(isset($_REQUEST['phone']))
{
$phone=$_REQUEST['phone'];
}
if(isset($_REQUEST['message']))
{
$message=$_REQUEST['message'];
}
// TESTING IF VARIABLES HAVE VALUES
echo "$name $email $phone $message";
// RESULT: TRUE TILL HERE
if($name=="" || $email=="" || $phone=="" || $message=="")
{
header("location:../?inst=invalid");
}
else
{
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to="mail@example.com";
// Your subject
$subject="$name Contacted you via Contact Form";
// From
$headers = "From: ME <no-reply@example.com>\r\n";
$headers .= 'Reply-To:' . $email . "\r\n";
$headers .= "Return-Path: info@example.com\r\n";
$headers .= "X-Mailer: PHP\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
print $message;
// send email
$sentmail = mail($to,$subject,$message,$headers);
//$sentmail = mail($to1,$subject,$message,$header);
}
// if your email succesfully sent
if($sentmail){
echo "Mail Sent.";
}
else {
header("location:../landing/?status=verification-pending");
}
?>
Now when i checked headers in my gmail, the value for $email doesn't
appear in header information, Also no message is received. All I get is a
blank message or may be $message is not printing anything like the same
case i am facing with reply-to.
please help me a little with this. Thanks in advance.
I am creating a page that sends the response from contact form within mail
but reply-to is not working (the variable i am using is having value, but
is not added within headers)
here's my code:
<?php
//$uname=$_REQUEST['uname'];
if(isset($_REQUEST['name']))
{
$name=$_REQUEST['name'];
}
if(isset($_REQUEST['email']))
{
$email=$_REQUEST['email'];
}
if(isset($_REQUEST['phone']))
{
$phone=$_REQUEST['phone'];
}
if(isset($_REQUEST['message']))
{
$message=$_REQUEST['message'];
}
// TESTING IF VARIABLES HAVE VALUES
echo "$name $email $phone $message";
// RESULT: TRUE TILL HERE
if($name=="" || $email=="" || $phone=="" || $message=="")
{
header("location:../?inst=invalid");
}
else
{
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to="mail@example.com";
// Your subject
$subject="$name Contacted you via Contact Form";
// From
$headers = "From: ME <no-reply@example.com>\r\n";
$headers .= 'Reply-To:' . $email . "\r\n";
$headers .= "Return-Path: info@example.com\r\n";
$headers .= "X-Mailer: PHP\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
print $message;
// send email
$sentmail = mail($to,$subject,$message,$headers);
//$sentmail = mail($to1,$subject,$message,$header);
}
// if your email succesfully sent
if($sentmail){
echo "Mail Sent.";
}
else {
header("location:../landing/?status=verification-pending");
}
?>
Now when i checked headers in my gmail, the value for $email doesn't
appear in header information, Also no message is received. All I get is a
blank message or may be $message is not printing anything like the same
case i am facing with reply-to.
please help me a little with this. Thanks in advance.
Show arrays arranged in a specific format
Show arrays arranged in a specific format
I have the following array in JavaScript:
myArray = ["lu9","lu10","lu11","ma9","ma10","ma11","mi9","mi10","mi11"];
Then, I need to display the values ​​(for example in an alert)
but must be arranged as follows:
"lu9,ma9,mi9,lu10,ma10,mi10,lu11,ma11,mi11"
How I can do this?
I have the following array in JavaScript:
myArray = ["lu9","lu10","lu11","ma9","ma10","ma11","mi9","mi10","mi11"];
Then, I need to display the values ​​(for example in an alert)
but must be arranged as follows:
"lu9,ma9,mi9,lu10,ma10,mi10,lu11,ma11,mi11"
How I can do this?
Sunday, 18 August 2013
How to dump error messages from ffmpeg commnad?
How to dump error messages from ffmpeg commnad?
I need to dump ffmpeg error message.
Already checked ffmpeg documentation, but still do not know how to dump
exactly.
If you can show some specific sample command, I would appreciate very much.
I need to dump ffmpeg error message.
Already checked ffmpeg documentation, but still do not know how to dump
exactly.
If you can show some specific sample command, I would appreciate very much.
sum of each median on the array
sum of each median on the array
I am trying to get the sum of each median... and yes this is homework...
my answer is wrong but I couldn't figure out why it's not giving me the
correct answer. Any suggestion?
package coursera_week6_p2;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;
public class Coursera_week6_p2 {
public static void main(String[] args) throws FileNotFoundException {
Scanner s = new Scanner(new
File("/Users/michellepai/Downloads/Median.txt"));
int[] array = new int[10000];
int i = 0;
while (s.hasNextLine()) {
array[i] = Integer.parseInt(s.nextLine());
i++;
}
Arrays.sort(array);
int m = 0;
long med = 0;
for (int k = 0; k < array.length; k++) {
if (k % 2 == 0) {
m = k/2;
} else {
m =(k-1)/2;
}
System.out.println("arrayIndex [" + k + "]: "+ array[k] +" ,
median index: " + m + " , median: " + array[m]);
med = med + array[m];
System.out.println("total: " + med);
}
System.out.println(med%10000);
}
}
The goal of this problem is to implement the "Median Maintenance"
algorithm (covered in the Week 5 lecture on heap applications). The text
file contains a list of the integers from 1 to 10000 in unsorted order;
you should treat this as a stream of numbers, arriving one by one. Letting
xi denote the ith number of the file, the kth median mk is defined as the
median of the numbers x1,…,xk. (So, if k is odd, then mk is ((k+1)/2)th
smallest number among x1,…,xk; if k is even, then mk is the (k/2)th
smallest number among x1,…,xk.) In the box below you should type the sum
of these 10000 medians, modulo 10000 (i.e., only the last 4 digits). That
is, you should compute (m1+m2+m3+⋯+m10000)mod10000.
I am trying to get the sum of each median... and yes this is homework...
my answer is wrong but I couldn't figure out why it's not giving me the
correct answer. Any suggestion?
package coursera_week6_p2;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;
public class Coursera_week6_p2 {
public static void main(String[] args) throws FileNotFoundException {
Scanner s = new Scanner(new
File("/Users/michellepai/Downloads/Median.txt"));
int[] array = new int[10000];
int i = 0;
while (s.hasNextLine()) {
array[i] = Integer.parseInt(s.nextLine());
i++;
}
Arrays.sort(array);
int m = 0;
long med = 0;
for (int k = 0; k < array.length; k++) {
if (k % 2 == 0) {
m = k/2;
} else {
m =(k-1)/2;
}
System.out.println("arrayIndex [" + k + "]: "+ array[k] +" ,
median index: " + m + " , median: " + array[m]);
med = med + array[m];
System.out.println("total: " + med);
}
System.out.println(med%10000);
}
}
The goal of this problem is to implement the "Median Maintenance"
algorithm (covered in the Week 5 lecture on heap applications). The text
file contains a list of the integers from 1 to 10000 in unsorted order;
you should treat this as a stream of numbers, arriving one by one. Letting
xi denote the ith number of the file, the kth median mk is defined as the
median of the numbers x1,…,xk. (So, if k is odd, then mk is ((k+1)/2)th
smallest number among x1,…,xk; if k is even, then mk is the (k/2)th
smallest number among x1,…,xk.) In the box below you should type the sum
of these 10000 medians, modulo 10000 (i.e., only the last 4 digits). That
is, you should compute (m1+m2+m3+⋯+m10000)mod10000.
Why does a java program closes on termination but not a web browser
Why does a java program closes on termination but not a web browser
If I write a public static void main java program, unless I put a while
(true) loop, the program will run and then exit, closing my applet window.
My question is when a web browser runs through rendering html content,
after it has finished rendering, why doesn't it close itself? Where is the
while (true) implicit in a web browser?
If I write a public static void main java program, unless I put a while
(true) loop, the program will run and then exit, closing my applet window.
My question is when a web browser runs through rendering html content,
after it has finished rendering, why doesn't it close itself? Where is the
while (true) implicit in a web browser?
CKEditor: legend button for styling
CKEditor: legend button for styling
In my ckeditor I would like to have a button like the bold button but then
for the tags. How can I do that?
Could not found anything about it..
In my ckeditor I would like to have a button like the bold button but then
for the tags. How can I do that?
Could not found anything about it..
Why does ajax polling increases CPU usage over time?
Why does ajax polling increases CPU usage over time?
I have a web application polls the server every 1 second for data to
update its display. I see a gradual (over night) increase of CPU usage of
the browser from 6% to 30% with no app interaction or change in behavior.
The problem is easily reproduced with this code running on Chrome, where I
reduced the polling interval to 100ms to get a more noticeable effect:
<html>
<body>
<script>
var i = 0;
var xhr = new XMLHttpRequest();
xhr.onload = function() {
console.log("response", i++);
setTimeout(send, 100);
}
function send() {
xhr.open("GET", "/", true);
xhr.send();
}
send();
</script>
This code can easily be run on any web server like
python -m SimpleHTTPServer 8888
With this example CPU usage increases very fast for no apparent reason. I
do no processing and use setTimeout and not setInterval so I never have
overlapping requests.
I'm testing with Chrome (and Safari) and still see a very fast increase in
CPU usage. Any ideas why?
I have a web application polls the server every 1 second for data to
update its display. I see a gradual (over night) increase of CPU usage of
the browser from 6% to 30% with no app interaction or change in behavior.
The problem is easily reproduced with this code running on Chrome, where I
reduced the polling interval to 100ms to get a more noticeable effect:
<html>
<body>
<script>
var i = 0;
var xhr = new XMLHttpRequest();
xhr.onload = function() {
console.log("response", i++);
setTimeout(send, 100);
}
function send() {
xhr.open("GET", "/", true);
xhr.send();
}
send();
</script>
This code can easily be run on any web server like
python -m SimpleHTTPServer 8888
With this example CPU usage increases very fast for no apparent reason. I
do no processing and use setTimeout and not setInterval so I never have
overlapping requests.
I'm testing with Chrome (and Safari) and still see a very fast increase in
CPU usage. Any ideas why?
Using Intuit-partner-platform for my company
Using Intuit-partner-platform for my company
I'm interested in using the intuit-partner-platform rest API to
automatically generate invoices into our QuickBooks Online account, from
an in house database. Although it would be interesting to eventually
create an application that I could sell to other parties, I'm mainly
trying to get my feet wet with this specific internal need.
Is there any problem with using the Intuit-partner-platform in this way?
Would my company be able to continue to use this application even if it is
not sold to other consumers?
I'm interested in using the intuit-partner-platform rest API to
automatically generate invoices into our QuickBooks Online account, from
an in house database. Although it would be interesting to eventually
create an application that I could sell to other parties, I'm mainly
trying to get my feet wet with this specific internal need.
Is there any problem with using the Intuit-partner-platform in this way?
Would my company be able to continue to use this application even if it is
not sold to other consumers?
Isolate specific HTML elements with jQuery
Isolate specific HTML elements with jQuery
OK, what I need may sounds rather complex, but here it is...
Let's say we have the HTML code below (it's still just an example, but
it's still quite accurate) :
<div data-role="content" comp-id="jqm-content-6207" id="jqm-content-6207"
class="" data-theme="" >
<!-- New Navigation Bar #1 -->
<div data-role="navbar" data-position="fixed"
comp-id="jqm-navbar-4603" id="jqm-navbar-4603" class=""
data-iconpos="top" >
<ul>
<!-- New Navigation Bar Item #1 -->
<li>
<a href="#" comp-id="jqm-navbar-item-6671"
id="jqm-navbar-item-6671" class="" data-icon="home"
data-theme="" >
One
</a>
</li>
<!-- / New Navigation Bar Item #1 -->
<!-- New Navigation Bar Item #2 -->
<li>
<a href="#" comp-id="jqm-navbar-item-4404"
id="jqm-navbar-item-4404" class="" data-icon="gear"
data-theme="" >
Two
</a>
</li>
<!-- / New Navigation Bar Item #2 -->
</ul>
</div>
<!-- / New Navigation Bar #1 -->
<!-- New Navigation Bar #2 -->
<div data-role="navbar" data-position="fixed"
comp-id="jqm-navbar-4658" id="jqm-navbar-4658" class=""
data-iconpos="top" >
<ul>
<!-- New Navigation Bar Item #2.1 -->
<li>
<a href="#" comp-id="jqm-navbar-item-5321"
id="jqm-navbar-item-5321" class="" data-icon="home"
data-theme="" >
One
</a>
</li>
<!-- / New Navigation Bar Item #2.1 -->
<!-- New Navigation Bar Item #2.2 -->
<li>
<a href="#" comp-id="jqm-navbar-item-2843"
id="jqm-navbar-item-2843" class="" data-icon="gear"
data-theme="" >
Two
</a>
</li>
<!-- / New Navigation Bar Item #2.2 -->
</ul>
</div>
</div>
First-off, the core idea is : when the user clicks an item with the
comp-id attribute set, then add class msp-selected just to this specific
element (and remove it from all other elements).
This is how I'm handling this specific part :
function removeAll()
{
$("*").each(function() {
if ($(this)!==undefined) {
$(this).removeClass("msp-selected");
}
});
}
$(document).ready( function() {
$('[comp-id]').bind('click', function(event) {
removeAll();
$(event.target).addClass('msp-selected');
});
});
So, as you may already have guessed it's like a way of "selecting" item
(by clicking on them) from the HTML document.
Now, here's the catch :
How could I make it so that the "selection" is progressive?
What I mean...
When the user first clicks on the Navigation Bar :
Check if the first div with comp-id is selected (has the class
msp-selected). If not, select it.
If the first div is already selected, then go one level deeper looking for
comp-id, and select that one.
So, any ideas?
How would you do it?
OK, what I need may sounds rather complex, but here it is...
Let's say we have the HTML code below (it's still just an example, but
it's still quite accurate) :
<div data-role="content" comp-id="jqm-content-6207" id="jqm-content-6207"
class="" data-theme="" >
<!-- New Navigation Bar #1 -->
<div data-role="navbar" data-position="fixed"
comp-id="jqm-navbar-4603" id="jqm-navbar-4603" class=""
data-iconpos="top" >
<ul>
<!-- New Navigation Bar Item #1 -->
<li>
<a href="#" comp-id="jqm-navbar-item-6671"
id="jqm-navbar-item-6671" class="" data-icon="home"
data-theme="" >
One
</a>
</li>
<!-- / New Navigation Bar Item #1 -->
<!-- New Navigation Bar Item #2 -->
<li>
<a href="#" comp-id="jqm-navbar-item-4404"
id="jqm-navbar-item-4404" class="" data-icon="gear"
data-theme="" >
Two
</a>
</li>
<!-- / New Navigation Bar Item #2 -->
</ul>
</div>
<!-- / New Navigation Bar #1 -->
<!-- New Navigation Bar #2 -->
<div data-role="navbar" data-position="fixed"
comp-id="jqm-navbar-4658" id="jqm-navbar-4658" class=""
data-iconpos="top" >
<ul>
<!-- New Navigation Bar Item #2.1 -->
<li>
<a href="#" comp-id="jqm-navbar-item-5321"
id="jqm-navbar-item-5321" class="" data-icon="home"
data-theme="" >
One
</a>
</li>
<!-- / New Navigation Bar Item #2.1 -->
<!-- New Navigation Bar Item #2.2 -->
<li>
<a href="#" comp-id="jqm-navbar-item-2843"
id="jqm-navbar-item-2843" class="" data-icon="gear"
data-theme="" >
Two
</a>
</li>
<!-- / New Navigation Bar Item #2.2 -->
</ul>
</div>
</div>
First-off, the core idea is : when the user clicks an item with the
comp-id attribute set, then add class msp-selected just to this specific
element (and remove it from all other elements).
This is how I'm handling this specific part :
function removeAll()
{
$("*").each(function() {
if ($(this)!==undefined) {
$(this).removeClass("msp-selected");
}
});
}
$(document).ready( function() {
$('[comp-id]').bind('click', function(event) {
removeAll();
$(event.target).addClass('msp-selected');
});
});
So, as you may already have guessed it's like a way of "selecting" item
(by clicking on them) from the HTML document.
Now, here's the catch :
How could I make it so that the "selection" is progressive?
What I mean...
When the user first clicks on the Navigation Bar :
Check if the first div with comp-id is selected (has the class
msp-selected). If not, select it.
If the first div is already selected, then go one level deeper looking for
comp-id, and select that one.
So, any ideas?
How would you do it?
Saturday, 17 August 2013
How do I play late game Irelia?
How do I play late game Irelia?
How can I be an affective player with Irelia in late-game and teamfights?
When chasing down enemies or 1v1'ing I feel like she excels throughout the
whole game. During teamfights, however I target the squishy champs, and I
usually kill one before I die. Sometimes if I don't get a kill or without
me there after I die, my team loses the teamfights, which often costs us a
few towers or even the game.
I feel like with Irelia I'm doing really well and helping me team win, but
as soon as we hit teamfighting phase I just hit a wall, and I'm either
trading 1:1 or dying more than I kill. I feel that I should be playing
this way since Irelia is an assassin, sorta, but I feel like I'm not
benefiting from it late game. So how can I play her better during
late-game and teamfighting? All help and tips is appreciated!
How can I be an affective player with Irelia in late-game and teamfights?
When chasing down enemies or 1v1'ing I feel like she excels throughout the
whole game. During teamfights, however I target the squishy champs, and I
usually kill one before I die. Sometimes if I don't get a kill or without
me there after I die, my team loses the teamfights, which often costs us a
few towers or even the game.
I feel like with Irelia I'm doing really well and helping me team win, but
as soon as we hit teamfighting phase I just hit a wall, and I'm either
trading 1:1 or dying more than I kill. I feel that I should be playing
this way since Irelia is an assassin, sorta, but I feel like I'm not
benefiting from it late game. So how can I play her better during
late-game and teamfighting? All help and tips is appreciated!
Computer Battery not Charging
Computer Battery not Charging
I recently converted my brand new Acer Aspire M to Ubuntu 13.4 and I have
the same problem (Bran New computer and was working fine with Windows 8).
The battery icon is always in Red saying I have little time left whether
is plugged in or on battery. Any thoughts?
I recently converted my brand new Acer Aspire M to Ubuntu 13.4 and I have
the same problem (Bran New computer and was working fine with Windows 8).
The battery icon is always in Red saying I have little time left whether
is plugged in or on battery. Any thoughts?
How does dropbox its monitoring?
How does dropbox its monitoring?
Which mechanism does Dropbox use to monitor the folders? I am interested
in the mechanism supported by a programming language, by the supported
operating systems or some file system functionalities.
Which mechanism does Dropbox use to monitor the folders? I am interested
in the mechanism supported by a programming language, by the supported
operating systems or some file system functionalities.
Android retrieve data from contact
Android retrieve data from contact
i try to write application to read name, last name , and id of contact and
show in listview, i use following code
Cursor cursor = getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null, null,
null, null);
SmsMultiCasting.selectedRow = new int[cursor.getCount()];
cursor.moveToFirst();
// data = new String[cursor.getCount()][12];
if (cursor.getCount() > 0) {
do {
try {
i++;
Log.d("number", String.valueOf(i));
// numberPhone = 0;
contactId = cursor
.getString(cursor
.getColumnIndex(ContactsContract.Contacts._ID));
Uri contactUri = ContentUris.withAppendedId(
Contacts.CONTENT_URI,
Long.parseLong(contactId));
Uri dataUri = Uri.withAppendedPath(contactUri,
Contacts.Data.CONTENT_DIRECTORY);
Cursor phones = getContentResolver()
.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID
+ " = " + contactId, null,
null);
int phonenumber = 0;
while (phones.moveToNext()) {
phonenumber++;
}
if (phonenumber > 0)
// phones.moveToNext();
{
try {
Cursor nameCursor = getContentResolver()
.query(dataUri,
null,
Data.MIMETYPE + "=?",
new String[] {
StructuredName.CONTENT_ITEM_TYPE
},
null);
nameCursor.moveToFirst();
do {
String firstName = nameCursor
.getString(nameCursor
.getColumnIndex(Data.DATA2));
String lastName = "";
String displayname = cursor
.getString(cursor
.getColumnIndex(Contacts.DISPLAY_NAME_ALTERNATIVE));
if (!firstName.equals(displayname)) {
lastName = nameCursor
.getString(nameCursor
.getColumnIndex(Data.DATA3));
}
if (firstName.equals(null)
&& lastName.equals(null))
SmsMultiCasting.Arrayefullname
.add("unknown name");
else if (firstName.equals(null))
SmsMultiCasting.Arrayefullname
.add(lastName);
else if (lastName.equals(null))
SmsMultiCasting.Arrayefullname
.add(firstName);
else
SmsMultiCasting.Arrayefullname
.add(firstName + " "
+ lastName);
SmsMultiCasting.Arrayeid.add(String
.valueOf(firstName + " "
+ lastName + "//"
+ contactId));
} while (nameCursor.moveToNext());
nameCursor.close();
} catch (Exception e) {
}
}
}
catch (Exception t) {
}
String image_uri = cursor
.getString(cursor
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI));
SmsMultiCasting.ArrayePhoto.add(image_uri);
*/
} while (cursor.moveToNext());
but this code in large date gives error to me, how can i use lighter code
to get data???
i try to write application to read name, last name , and id of contact and
show in listview, i use following code
Cursor cursor = getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null, null,
null, null);
SmsMultiCasting.selectedRow = new int[cursor.getCount()];
cursor.moveToFirst();
// data = new String[cursor.getCount()][12];
if (cursor.getCount() > 0) {
do {
try {
i++;
Log.d("number", String.valueOf(i));
// numberPhone = 0;
contactId = cursor
.getString(cursor
.getColumnIndex(ContactsContract.Contacts._ID));
Uri contactUri = ContentUris.withAppendedId(
Contacts.CONTENT_URI,
Long.parseLong(contactId));
Uri dataUri = Uri.withAppendedPath(contactUri,
Contacts.Data.CONTENT_DIRECTORY);
Cursor phones = getContentResolver()
.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID
+ " = " + contactId, null,
null);
int phonenumber = 0;
while (phones.moveToNext()) {
phonenumber++;
}
if (phonenumber > 0)
// phones.moveToNext();
{
try {
Cursor nameCursor = getContentResolver()
.query(dataUri,
null,
Data.MIMETYPE + "=?",
new String[] {
StructuredName.CONTENT_ITEM_TYPE
},
null);
nameCursor.moveToFirst();
do {
String firstName = nameCursor
.getString(nameCursor
.getColumnIndex(Data.DATA2));
String lastName = "";
String displayname = cursor
.getString(cursor
.getColumnIndex(Contacts.DISPLAY_NAME_ALTERNATIVE));
if (!firstName.equals(displayname)) {
lastName = nameCursor
.getString(nameCursor
.getColumnIndex(Data.DATA3));
}
if (firstName.equals(null)
&& lastName.equals(null))
SmsMultiCasting.Arrayefullname
.add("unknown name");
else if (firstName.equals(null))
SmsMultiCasting.Arrayefullname
.add(lastName);
else if (lastName.equals(null))
SmsMultiCasting.Arrayefullname
.add(firstName);
else
SmsMultiCasting.Arrayefullname
.add(firstName + " "
+ lastName);
SmsMultiCasting.Arrayeid.add(String
.valueOf(firstName + " "
+ lastName + "//"
+ contactId));
} while (nameCursor.moveToNext());
nameCursor.close();
} catch (Exception e) {
}
}
}
catch (Exception t) {
}
String image_uri = cursor
.getString(cursor
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI));
SmsMultiCasting.ArrayePhoto.add(image_uri);
*/
} while (cursor.moveToNext());
but this code in large date gives error to me, how can i use lighter code
to get data???
XSLT User Defined Function
XSLT User Defined Function
I am new to XSLT 2.0. I am intrigued by User Defined functions (
<xsl:function ). In particular, I'd like to use a UDF to make the code
more modular and readable.
I have this xsl:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="stopwords"
select="document('stopwords.xml')//w/string()"/>
<wordcount>
<xsl:for-each-group group-by="." select="
for $w in //text()/tokenize(.,
'\W+')[not(.=$stopwords)] return $w">
<xsl:sort select="count(current-group())"
order="descending"/>
<word word="{current-grouping-key()}"
frequency="{count(current-group())}"/>
</xsl:for-each-group>
</wordcount>
</xsl:template>
</xsl:stylesheet>
Can want to add more condition testing (for example, exclude digits) to
the for $w in //text()/tokenize(., '\W+')[not(.=$stopwords)] but the code
would get messy.
Is a UDF an option to tidy up that section of code if I make it more
complex. Is it good practice to do so?
I am new to XSLT 2.0. I am intrigued by User Defined functions (
<xsl:function ). In particular, I'd like to use a UDF to make the code
more modular and readable.
I have this xsl:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="stopwords"
select="document('stopwords.xml')//w/string()"/>
<wordcount>
<xsl:for-each-group group-by="." select="
for $w in //text()/tokenize(.,
'\W+')[not(.=$stopwords)] return $w">
<xsl:sort select="count(current-group())"
order="descending"/>
<word word="{current-grouping-key()}"
frequency="{count(current-group())}"/>
</xsl:for-each-group>
</wordcount>
</xsl:template>
</xsl:stylesheet>
Can want to add more condition testing (for example, exclude digits) to
the for $w in //text()/tokenize(., '\W+')[not(.=$stopwords)] but the code
would get messy.
Is a UDF an option to tidy up that section of code if I make it more
complex. Is it good practice to do so?
Creating an instance of an object implemented by COM LocalServer freezes
Creating an instance of an object implemented by COM LocalServer freezes
I have created a COM object server exe which implements a COM Object, and
calls to CoRegisterClassObject, and then sleeps for a long time (to
prevent the process from exiting)
After running it, I have another COM client exe which calls to
CoCreateInstance with the CLSID of the object registered previously on
CoRegisterClassObject,
CoCreateInstance freezes the thread, but if I close the COM Server process
- then CoCreateInstance returns immediately with "Class not registered.".
Do any of you know what's going on?
Thank you.
I have created a COM object server exe which implements a COM Object, and
calls to CoRegisterClassObject, and then sleeps for a long time (to
prevent the process from exiting)
After running it, I have another COM client exe which calls to
CoCreateInstance with the CLSID of the object registered previously on
CoRegisterClassObject,
CoCreateInstance freezes the thread, but if I close the COM Server process
- then CoCreateInstance returns immediately with "Class not registered.".
Do any of you know what's going on?
Thank you.
how to change property in for loop vb.net 2010
how to change property in for loop vb.net 2010
Sorry my bad english first.
i have 12 component and i want to change value in for loop.
here my code
Dim serviceNames() As String = {"Security Manager Remote Recorder",
"Security Manager Filter", "Security Manager Prob", "Security Manager
Intelligence", "Security Manager Maintenance", "Security Manager
Action", "Security Manager Agent Check", "Security Manager Control",
"Security Manager Deploy Copy", "Security Manager Monitor", "Security
Manager Reloader", "Security Manager Schedule"}
Dim swButtons() = {sw0.Value, sw1.Value, sw2.Value, sw3.Value,
sw4.Value, sw5.Value, sw6.Value, sw7.Value, sw8.Value, sw9.Value,
sw10.Value, sw11.Value}
For q As Integer = 0 To serviceNames.Count - 1
Dim regService =
My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\"
+ serviceNames(q) + "", "Start", "")
If regService = 2 Then
swButtons(q) = True
End If
If regService = 4 Then
MetroTabItem5.Text = "bu 4"
End If
Next
thanks for all helps.
Sorry my bad english first.
i have 12 component and i want to change value in for loop.
here my code
Dim serviceNames() As String = {"Security Manager Remote Recorder",
"Security Manager Filter", "Security Manager Prob", "Security Manager
Intelligence", "Security Manager Maintenance", "Security Manager
Action", "Security Manager Agent Check", "Security Manager Control",
"Security Manager Deploy Copy", "Security Manager Monitor", "Security
Manager Reloader", "Security Manager Schedule"}
Dim swButtons() = {sw0.Value, sw1.Value, sw2.Value, sw3.Value,
sw4.Value, sw5.Value, sw6.Value, sw7.Value, sw8.Value, sw9.Value,
sw10.Value, sw11.Value}
For q As Integer = 0 To serviceNames.Count - 1
Dim regService =
My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\"
+ serviceNames(q) + "", "Start", "")
If regService = 2 Then
swButtons(q) = True
End If
If regService = 4 Then
MetroTabItem5.Text = "bu 4"
End If
Next
thanks for all helps.
Friday, 16 August 2013
Need to install windows 7 And 8 in same System
Need to install windows 7 And 8 in same System
I need To Install Windows 8 and windows 7 on to the same system.
Currently i am not able to run windows 7 after the installation of windows
8. There is no
option for take windows 7. i installed windows 8 on separate partition.
How solve these problem. Pls help Me
I need To Install Windows 8 and windows 7 on to the same system.
Currently i am not able to run windows 7 after the installation of windows
8. There is no
option for take windows 7. i installed windows 8 on separate partition.
How solve these problem. Pls help Me
Saturday, 10 August 2013
how to tell google that it is not an error page - wordpress seo 404 page
how to tell google that it is not an error page - wordpress seo 404 page
hello seo / wordpress experts, I greatly appreciate your help in advance.
I did a little modification to the 404 page in wordpress in order to
create a customized url.
for example, i modified the 404 page so that instead of showing "page not
found" it actually delivers useful information to the users (i did a parse
in the url to show useful information)
but when I submitted some url to the google index, i think the crawler
sees it as 404 error.
i definitely want to keep it as it is otherwise i would be creating too
many pages.
any comments or suggestions are appreciated. basically my goal is to tell
google that it is not an error page but it is good page.
thank you
hello seo / wordpress experts, I greatly appreciate your help in advance.
I did a little modification to the 404 page in wordpress in order to
create a customized url.
for example, i modified the 404 page so that instead of showing "page not
found" it actually delivers useful information to the users (i did a parse
in the url to show useful information)
but when I submitted some url to the google index, i think the crawler
sees it as 404 error.
i definitely want to keep it as it is otherwise i would be creating too
many pages.
any comments or suggestions are appreciated. basically my goal is to tell
google that it is not an error page but it is good page.
thank you
Inserting/updating data into MySql database using php
Inserting/updating data into MySql database using php
I am trying to insert/update the MySql database depending on whether a
post already exists on the database (I am check this with a unique
user_id). The following works:
$select_query = "SELECT * ";
$select_query .= "FROM test ";
$select_query .= "WHERE user_id = '$user_id'";
$check_user_id = mysqli_query($connection, $select_query);
$query = "INSERT INTO test (";
$query .= " user_id, name, message";
$query .= ") VALUES (";
$query .= " '{$user_id}', '{$name}', '{$message}'";
$query .= ")";
$result = mysqli_query($connection, $query);
if ($result) {
echo "Success!";
} else {
die("Database query failed. " . mysqli_error($connection));
}
However, when I use the following code with an if/else statement, it does
not work anymore, although the console reports "Success!" (meaning $result
has a value). Any help would be greatly appreciated. Thanks.
$select_query = "SELECT * ";
$select_query .= "FROM test ";
$select_query .= "WHERE user_id = '$user_id'";
$check_user_id = mysqli_query($connection, $select_query);
if (!$check_user_id) {
$query = "INSERT INTO test (";
$query .= " user_id, name, message";
$query .= ") VALUES (";
$query .= " '{$user_id}', '{$name}', '{$message}'";
$query .= ")";
} else {
$query = "UPDATE test SET ";
$query .= "name = '{$name}', ";
$query .= "message = '{$message}' ";
$query .= "WHERE user_id = '{$user_id}'";
}
$result = mysqli_query($connection, $query);
if ($result) {
echo "Success!";
} else {
die("Database query failed. " . mysqli_error($connection));
}
I am trying to insert/update the MySql database depending on whether a
post already exists on the database (I am check this with a unique
user_id). The following works:
$select_query = "SELECT * ";
$select_query .= "FROM test ";
$select_query .= "WHERE user_id = '$user_id'";
$check_user_id = mysqli_query($connection, $select_query);
$query = "INSERT INTO test (";
$query .= " user_id, name, message";
$query .= ") VALUES (";
$query .= " '{$user_id}', '{$name}', '{$message}'";
$query .= ")";
$result = mysqli_query($connection, $query);
if ($result) {
echo "Success!";
} else {
die("Database query failed. " . mysqli_error($connection));
}
However, when I use the following code with an if/else statement, it does
not work anymore, although the console reports "Success!" (meaning $result
has a value). Any help would be greatly appreciated. Thanks.
$select_query = "SELECT * ";
$select_query .= "FROM test ";
$select_query .= "WHERE user_id = '$user_id'";
$check_user_id = mysqli_query($connection, $select_query);
if (!$check_user_id) {
$query = "INSERT INTO test (";
$query .= " user_id, name, message";
$query .= ") VALUES (";
$query .= " '{$user_id}', '{$name}', '{$message}'";
$query .= ")";
} else {
$query = "UPDATE test SET ";
$query .= "name = '{$name}', ";
$query .= "message = '{$message}' ";
$query .= "WHERE user_id = '{$user_id}'";
}
$result = mysqli_query($connection, $query);
if ($result) {
echo "Success!";
} else {
die("Database query failed. " . mysqli_error($connection));
}
Friday, 9 August 2013
How to get the order number of same record if the object is data.frame?
How to get the order number of same record if the object is data.frame?
If the object is a vector, i can get the order of the same record with the
following method:
> serial <- c("df12", "cv22", "ca11", "he22", "jj32", "sq11", "cv22")
> which(serial%in%serial[duplicated(serial)])
[1] 2 7
What can i do if the object is a data.frame?
which(iris%in%iris[duplicated(iris)])
Error in `[.data.frame`(iris, duplicated(iris)) :
undefined columns selected
> which(duplicated(iris))
[1] 143
> iris[143,]
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
143 5.8 2.7 5.1 1.9 virginica
> iris[which(iris[,1]==5.8),]
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
15 5.8 4.0 1.2 0.2 setosa
68 5.8 2.7 4.1 1.0 versicolor
83 5.8 2.7 3.9 1.2 versicolor
93 5.8 2.6 4.0 1.2 versicolor
102 5.8 2.7 5.1 1.9 virginica
115 5.8 2.8 5.1 2.4 virginica
143 5.8 2.7 5.1 1.9 virginica
The order of the same record are 102 and 143,how can i get that with a
line of R command?
If the object is a vector, i can get the order of the same record with the
following method:
> serial <- c("df12", "cv22", "ca11", "he22", "jj32", "sq11", "cv22")
> which(serial%in%serial[duplicated(serial)])
[1] 2 7
What can i do if the object is a data.frame?
which(iris%in%iris[duplicated(iris)])
Error in `[.data.frame`(iris, duplicated(iris)) :
undefined columns selected
> which(duplicated(iris))
[1] 143
> iris[143,]
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
143 5.8 2.7 5.1 1.9 virginica
> iris[which(iris[,1]==5.8),]
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
15 5.8 4.0 1.2 0.2 setosa
68 5.8 2.7 4.1 1.0 versicolor
83 5.8 2.7 3.9 1.2 versicolor
93 5.8 2.6 4.0 1.2 versicolor
102 5.8 2.7 5.1 1.9 virginica
115 5.8 2.8 5.1 2.4 virginica
143 5.8 2.7 5.1 1.9 virginica
The order of the same record are 102 and 143,how can i get that with a
line of R command?
Compiling / Decompiling lua byte code
Compiling / Decompiling lua byte code
so I have a script in bytecode which I need to decompile. The script is a
very long one so I've put it [url=http://wklejto.pl/169767]here[/url] so
the post doesnt turn very long. Anyways, I am able to decompile the byte
using online lua executors such as
[url=http://www.compileonline.com/execute_lua_online.php]this one[/url] to
execute [url=http://www.wklejto.pl/169768]this[url] script and I get the
code I want but theres also alot of different stuff in it like EOC DC3
NULL etc, but I am able to edit the part I want so after doing so I try to
compile it using the executor mentioned above and
[url=http://www.wklejto.pl/169769]this[/url] script but I am getting
errors which do not allow the script to be compiled. The error I am stuck
at is [code]unexpected symbol near char(27)[/code]
So now, my question is, could anyone please show me a different, 100%
woring way to decrypt and encrypt the bytecode or help me to encrypt it
with the method I am currently using?
Thanks in advance.
P.S. I know very little about coding etc so please, in your answer give me
tips that a newbie like me will understand.
so I have a script in bytecode which I need to decompile. The script is a
very long one so I've put it [url=http://wklejto.pl/169767]here[/url] so
the post doesnt turn very long. Anyways, I am able to decompile the byte
using online lua executors such as
[url=http://www.compileonline.com/execute_lua_online.php]this one[/url] to
execute [url=http://www.wklejto.pl/169768]this[url] script and I get the
code I want but theres also alot of different stuff in it like EOC DC3
NULL etc, but I am able to edit the part I want so after doing so I try to
compile it using the executor mentioned above and
[url=http://www.wklejto.pl/169769]this[/url] script but I am getting
errors which do not allow the script to be compiled. The error I am stuck
at is [code]unexpected symbol near char(27)[/code]
So now, my question is, could anyone please show me a different, 100%
woring way to decrypt and encrypt the bytecode or help me to encrypt it
with the method I am currently using?
Thanks in advance.
P.S. I know very little about coding etc so please, in your answer give me
tips that a newbie like me will understand.
how to plot an arrow in a matrix structure
how to plot an arrow in a matrix structure
I would like how to do a particular arrow in this scheme. I don´t know if
it´s possible. With this code I need to make an arrow from (rombo1.south)
to the middle arrow from (momentum) -- (pressure). Is it possible? I´m not
sure about it because is inside a matrix structure.
\documentclass[spanish,a4paper,12pt]{book}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{arrows,snakes,backgrounds}
\usetikzlibrary{shapes.geometric}
\begin{document}
\thispagestyle{empty}
\begin{center}
\begin{tikzpicture}
\large
\tikzstyle{block} = [rectangle, draw=blue, thick, fill=blue!20, text
centered,minimum height=2em];
\tikzstyle{line} = [draw, thick, -latex',shorten >=0pt];
\tikzstyle{linwit} = [draw, thick, shorten >=0pt];
\tikzstyle{rombo}=[diamond, aspect=2, draw=blue, thick, fill=blue!20, text
centered, minimum height=3em];
\matrix [column sep=10mm,row sep=10mm]
{
% row 1
& \node [block,text width=3cm] (t) {$t=t+n\:\Delta t$}; \\
% row 2
&
\node [block,text width=4cm,minimum height=3em] (momentum) {Solve U, V,
W\\ equations};
& \node [rombo,text width=2cm] (rombo1) {Converged?};\\
% row 3
& \node [block,text width=4cm] (pressure) {Solve pressure\\ correction}; \\
% row 4
& \node [block,text width=4.5cm] (correct) {Correct velocity,\\ pressure,
fluxes}; \\
% row 5
& \node [block, text width=3.2cm] (scalars) {Solve k and $\varepsilon$};
& \node [rombo,text width=2cm] (rombo2) {Converged?};\\
% row 6
& \node [block,text width=5cm] (converged) {Solve other scalars};\\
% row 7
& \node [block,text width=4cm] (advance) {Advance to\\ next time step};\\
};
\tikzstyle{every path}=[line]
\path (t) -- (momentum);
\path (momentum) -- (pressure);
\path (pressure) -- (correct);
\path (correct) -- (scalars);
\path (scalars) -- (converged);
\path (converged) -- (advance);
\path (advance.west) -- ++(-2,0) |- (t);
\path (rombo1.west) -- node [above,]{No}(momentum);
\path (rombo1.south) -- ++(0,-1) -- (correct);
\path (rombo2.west) -- node [above,]{No}(scalars);
\end{tikzpicture}
\end{center}
\end{document}
I would like how to do a particular arrow in this scheme. I don´t know if
it´s possible. With this code I need to make an arrow from (rombo1.south)
to the middle arrow from (momentum) -- (pressure). Is it possible? I´m not
sure about it because is inside a matrix structure.
\documentclass[spanish,a4paper,12pt]{book}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{arrows,snakes,backgrounds}
\usetikzlibrary{shapes.geometric}
\begin{document}
\thispagestyle{empty}
\begin{center}
\begin{tikzpicture}
\large
\tikzstyle{block} = [rectangle, draw=blue, thick, fill=blue!20, text
centered,minimum height=2em];
\tikzstyle{line} = [draw, thick, -latex',shorten >=0pt];
\tikzstyle{linwit} = [draw, thick, shorten >=0pt];
\tikzstyle{rombo}=[diamond, aspect=2, draw=blue, thick, fill=blue!20, text
centered, minimum height=3em];
\matrix [column sep=10mm,row sep=10mm]
{
% row 1
& \node [block,text width=3cm] (t) {$t=t+n\:\Delta t$}; \\
% row 2
&
\node [block,text width=4cm,minimum height=3em] (momentum) {Solve U, V,
W\\ equations};
& \node [rombo,text width=2cm] (rombo1) {Converged?};\\
% row 3
& \node [block,text width=4cm] (pressure) {Solve pressure\\ correction}; \\
% row 4
& \node [block,text width=4.5cm] (correct) {Correct velocity,\\ pressure,
fluxes}; \\
% row 5
& \node [block, text width=3.2cm] (scalars) {Solve k and $\varepsilon$};
& \node [rombo,text width=2cm] (rombo2) {Converged?};\\
% row 6
& \node [block,text width=5cm] (converged) {Solve other scalars};\\
% row 7
& \node [block,text width=4cm] (advance) {Advance to\\ next time step};\\
};
\tikzstyle{every path}=[line]
\path (t) -- (momentum);
\path (momentum) -- (pressure);
\path (pressure) -- (correct);
\path (correct) -- (scalars);
\path (scalars) -- (converged);
\path (converged) -- (advance);
\path (advance.west) -- ++(-2,0) |- (t);
\path (rombo1.west) -- node [above,]{No}(momentum);
\path (rombo1.south) -- ++(0,-1) -- (correct);
\path (rombo2.west) -- node [above,]{No}(scalars);
\end{tikzpicture}
\end{center}
\end{document}
Query an NTP Server using C# and windows command line
Query an NTP Server using C# and windows command line
I am trying to query an NTP Server using c# to get the time of NTP server
using the following source code from this thread How to Query an NTP
Server using C#? .For some reason the flow stops at
socket.Receive(ntpData).
1) Any idea why it is stopping?
2)How to get the time from a ntp server using windows command line so that
if it works than my program should work .
I am trying to query an NTP Server using c# to get the time of NTP server
using the following source code from this thread How to Query an NTP
Server using C#? .For some reason the flow stops at
socket.Receive(ntpData).
1) Any idea why it is stopping?
2)How to get the time from a ntp server using windows command line so that
if it works than my program should work .
Is every discrete, torsion and divisible group $\sigma-$compact?
Is every discrete, torsion and divisible group $\sigma-$compact?
Let $G$ be a discrete, torsion and divisible group. Is $G$, $\sigma-$compact?
Let $G$ be a discrete, torsion and divisible group. Is $G$, $\sigma-$compact?
set theory -expressing sets-set operations
set theory -expressing sets-set operations
Can anyone please help me in this question:
How do i express (0,1) as the union of infinitely many open intervals none
of them is equal to (0,1).
Can anyone please help me in this question:
How do i express (0,1) as the union of infinitely many open intervals none
of them is equal to (0,1).
Thursday, 8 August 2013
how to convert ANSI to utf8 in java?
how to convert ANSI to utf8 in java?
I have a text file it is ANSI Encoding, i have to convert it into UTF8
encoding.
My text file is like this Stochastic programming is an area of
mathematical programming that studies how to model decision problems under
uncertainty. For example, although a decision might be necessary at a
given point in time, essential information might not be available until a
later time.
I have a text file it is ANSI Encoding, i have to convert it into UTF8
encoding.
My text file is like this Stochastic programming is an area of
mathematical programming that studies how to model decision problems under
uncertainty. For example, although a decision might be necessary at a
given point in time, essential information might not be available until a
later time.
Initialize an array with a class constructor and another array
Initialize an array with a class constructor and another array
I have an array with Type B[]. I have a constructor A(B b).
I want to create an array with Type A[] using them.
I can use the for statement to do that, but I want to know whether there
is a more convinient(shorter) way to do this. (Language syntax, static
method, or whatever)
public class A {
public A(B b) {
A.a = B.a;
A.b = B.b * B.c;
...
}
}
public class B {
...
}
public class C {
public static B[] getBs() {
B[] bs;
...
return bs;
}
}
void process() {
// From here
B[] bs = C.getBs();
A[] as = new A[bs.length];
for (int i=0; i<bs.length; i++) {
as[i] = new A(bs[i]);
}
// To here
}
I have an array with Type B[]. I have a constructor A(B b).
I want to create an array with Type A[] using them.
I can use the for statement to do that, but I want to know whether there
is a more convinient(shorter) way to do this. (Language syntax, static
method, or whatever)
public class A {
public A(B b) {
A.a = B.a;
A.b = B.b * B.c;
...
}
}
public class B {
...
}
public class C {
public static B[] getBs() {
B[] bs;
...
return bs;
}
}
void process() {
// From here
B[] bs = C.getBs();
A[] as = new A[bs.length];
for (int i=0; i<bs.length; i++) {
as[i] = new A(bs[i]);
}
// To here
}
How to show data as bar and circle percentage
How to show data as bar and circle percentage
I am trying to do something like this in my app:
But I don't know where to start, should I use the "ProgressBar" in the
"Form Widgets" or is there something else? How can such thing be done?
what should i bee using? if you have any examples you can link me to i
would appreciate it.
I am trying to do something like this in my app:
But I don't know where to start, should I use the "ProgressBar" in the
"Form Widgets" or is there something else? How can such thing be done?
what should i bee using? if you have any examples you can link me to i
would appreciate it.
Simple Javascript Object and "this"
Simple Javascript Object and "this"
Quick question. Why does the following give a this.testFunction is not a
function error?
Test = {
data: true,
testFunction: function() {
this.data = true;
},
initialize: function() {
this.data = false;
this.testFunction();
console.log(this.data);
}
};
$(document).ready(Test.initialize);
Quick question. Why does the following give a this.testFunction is not a
function error?
Test = {
data: true,
testFunction: function() {
this.data = true;
},
initialize: function() {
this.data = false;
this.testFunction();
console.log(this.data);
}
};
$(document).ready(Test.initialize);
Convert String[] with text to double[]
Convert String[] with text to double[]
I have an Arraylist that I want to convert to a double[] array. I first
convert the Arraylist to a String []. I then try to convert the String[]
to a double[] but fail in the process. Here's the issue: the string
contains some text, as well as some numbers with decimals. I want to
convert only the numbers and decimals to a double[] array and simply
delete the text. However, I only know how to delete the text with a
String, not a String[]. Please take a look:
import java.util.ArrayList;
import java.util.List;
import jsc.independentsamples.SmirnovTest;
public class example{
public static void main(String[] arg) throws Exception {
ArrayList<String> list1 = new ArrayList<String>();
ArrayList<String> list2 = new ArrayList<String>();
list1.add("RSP0001,1.11,1.22");
list1.add("RSP0002,2.11,2.22");
list1.add("RSP0003,3.11,3.22");
list1.add("RSP0004,4.11,4.22");
String[] str1 = new String[list1.size()];
str1 = list1.toArray(str1);
str1.replaceAll("RSP_\\d+","");
double array1 = Double.parseDouble(str1);
System.out.println(array1);
}
}
Any ideas on how to convert my String[] to a double[] ?
Thanks,
kjm
I have an Arraylist that I want to convert to a double[] array. I first
convert the Arraylist to a String []. I then try to convert the String[]
to a double[] but fail in the process. Here's the issue: the string
contains some text, as well as some numbers with decimals. I want to
convert only the numbers and decimals to a double[] array and simply
delete the text. However, I only know how to delete the text with a
String, not a String[]. Please take a look:
import java.util.ArrayList;
import java.util.List;
import jsc.independentsamples.SmirnovTest;
public class example{
public static void main(String[] arg) throws Exception {
ArrayList<String> list1 = new ArrayList<String>();
ArrayList<String> list2 = new ArrayList<String>();
list1.add("RSP0001,1.11,1.22");
list1.add("RSP0002,2.11,2.22");
list1.add("RSP0003,3.11,3.22");
list1.add("RSP0004,4.11,4.22");
String[] str1 = new String[list1.size()];
str1 = list1.toArray(str1);
str1.replaceAll("RSP_\\d+","");
double array1 = Double.parseDouble(str1);
System.out.println(array1);
}
}
Any ideas on how to convert my String[] to a double[] ?
Thanks,
kjm
Design Patterns in VBA Object-Oriented
Design Patterns in VBA Object-Oriented
is there any book about Design Patterns in VBA Object-Oriented available
at internet so I can download for free? if you know any, i'd appreciate.
thanks in advance.
is there any book about Design Patterns in VBA Object-Oriented available
at internet so I can download for free? if you know any, i'd appreciate.
thanks in advance.
Can't load Log4Net configuration
Can't load Log4Net configuration
I have a brand new console application in vb.net. I want to use log4net so
I did the following steps and it works. Great. Yahoo.
But I have to place Log4Net.config in bin/debug together with Log4Net.dll
and Log4Net.xml. I have tried many things but no joy. Or I haven't got to
a right combination. How can i move Log4Net.config to app root?
Installed Log4Net from NuGet.
I added
<Assembly: XmlConfigurator(ConfigFile:="Log4Net.config", Watch:=True)>
in AssemblyInfo.vb.
This is how i am calling it.
Public Class Class1
'Save log4net log into SQL Server
Private Shared ReadOnly DBlog As ILog = LogManager.GetLogger("TestLog4Net")
Public Shared Sub Main(ByVal args() As String)
DBlog.Error("Log4Net testing v1")
End Sub
End Class
My Log4Net.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<connectionString value="xxxxx" />
<commandText value="xxxxx" />
<parameter>
<parameterName value="@log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout" />
</parameter>
<parameter>
<parameterName value="@thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread" />
</layout>
</parameter>
<parameter>
<parameterName value="@log_level" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value="@logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="@message" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
<parameter>
<parameterName value="@exception" />
<dbType value="String" />
<size value="2000" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>
I have tired
to set the following line before I say DBlog.Error("xx")
log4net.Config.XmlConfigurator.Configure()
to set this in app.config.
<log4net configSource="Log4Net.config" />
to move the whole Log4Net.config to app.config. That didn't work.
to set this as someone suggested on one post. That didn't work either.
<appSettings>
<add key="log4net.Config" value="log4net.config"/>
<add key="log4net.Config.Watch" value="True"/>
</appSettings>
to declare this instead of the GetLogger("name") that i am using. No joy
either.
Private Shared ReadOnly log As ILog =
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
I have a brand new console application in vb.net. I want to use log4net so
I did the following steps and it works. Great. Yahoo.
But I have to place Log4Net.config in bin/debug together with Log4Net.dll
and Log4Net.xml. I have tried many things but no joy. Or I haven't got to
a right combination. How can i move Log4Net.config to app root?
Installed Log4Net from NuGet.
I added
<Assembly: XmlConfigurator(ConfigFile:="Log4Net.config", Watch:=True)>
in AssemblyInfo.vb.
This is how i am calling it.
Public Class Class1
'Save log4net log into SQL Server
Private Shared ReadOnly DBlog As ILog = LogManager.GetLogger("TestLog4Net")
Public Shared Sub Main(ByVal args() As String)
DBlog.Error("Log4Net testing v1")
End Sub
End Class
My Log4Net.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<connectionString value="xxxxx" />
<commandText value="xxxxx" />
<parameter>
<parameterName value="@log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout" />
</parameter>
<parameter>
<parameterName value="@thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread" />
</layout>
</parameter>
<parameter>
<parameterName value="@log_level" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value="@logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="@message" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
<parameter>
<parameterName value="@exception" />
<dbType value="String" />
<size value="2000" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>
I have tired
to set the following line before I say DBlog.Error("xx")
log4net.Config.XmlConfigurator.Configure()
to set this in app.config.
<log4net configSource="Log4Net.config" />
to move the whole Log4Net.config to app.config. That didn't work.
to set this as someone suggested on one post. That didn't work either.
<appSettings>
<add key="log4net.Config" value="log4net.config"/>
<add key="log4net.Config.Watch" value="True"/>
</appSettings>
to declare this instead of the GetLogger("name") that i am using. No joy
either.
Private Shared ReadOnly log As ILog =
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
Subscribe to:
Posts (Atom)