Update not working-NodeJs and MongoDB using MongoClient
I was going through the mongodb and nodejs course on MongoDBUniversity and
one of the task involves finding the documents which has the highest
recorded temperature for any state and then add a field "month_high" to
it.I am able to find the documents for the state with the highest
temperature but am unable to update it. The code is as below.
Can someone tell me what might I be doing wrong?
var MongoClient=require('mongodb').MongoClient;
MongoClient.connect('mongodb://localhost:27017/course',function(err,db){
var cursor=db.collection("weather").find();
cursor.sort({"State":1,"Temperature":-1});
var oldState,newState;
cursor.each(function(err,doc){
if(err)throw err;
if(doc==null){
return db.close();
}
newState=doc.State;
if(newState!=oldState){
var operator={'$set':{"month_high":true}};
var query={"_id":doc._id};
console.log(doc._id+" has temp "+doc.Temperature+" "+doc.State);
db.collection("weather").update(doc,operator,function(err,updated){
console.log("hi");//---->Never Logs
if(err)throw err;
console.log(JSON.stringify(updated));
})
}
oldState=newState;
});
});
Saturday, 31 August 2013
Servlets beginner
Servlets beginner
I am studying a JEE course at the moment and I am on the module with
servlets.
Included in the course are simple sample servlets.
This may sound dumb but I cant get any of them to work either by
themselves or in netbeans on the glassfish server. I have tried dropiing
them in the web pages folder in the project and also I replaced the
content of the index.jsp file with WelcomeServlet.html content. The
example I will use her is the first one and the most simple called
WelcomeServlet.
The function of the servlet is that when the user pressed the "get html
document" button the program should retrieve the document from the .java
file. However when I press the button I get this error
HTTP Status 404 - Not Found type Status report
messageNot Found
descriptionThe requested resource is not available.
GlassFish Server Open Source Edition 4.0
Here is the code in question. WelcomeServlet.html
<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Fig. 17.6: WelcomeServlet.html -->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Handling an HTTP Get Request</title>
</head>
<body>
<form action = "/advjhtp1/welcome1" method = "get">
<p><label>Click the button to invoke the servlet
<input type = "submit" value = "Get HTML Document" />
</label></p>
</form>
</body>
</html>
WelcomeServlet.java
// Fig. 16.5: WelcomeServlet.java
// A simple servlet to process get requests.
package com.deitel.advjhtp1.servlets;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class WelcomeServlet extends HttpServlet {
// process "get" requests from clients
protected void doGet( HttpServletRequest request,
HttpServletResponse response )
throws ServletException, IOException
{
response.setContentType( "text/html" );
PrintWriter out = response.getWriter();
// send XHTML page to client
// start XHTML document
out.println( "<?xml version = \"1.0\"?>" );
out.println( "<!DOCTYPE html PUBLIC \"-//W3C//DTD " +
"XHTML 1.0 Strict//EN\" \"http://www.w3.org" +
"/TR/xhtml1/DTD/xhtml1-strict.dtd\">" );
out.println(
"<html xmlns = \"http://www.w3.org/1999/xhtml\">" );
// head section of document
out.println( "<head>" );
out.println( "<title>A Simple Servlet Example</title>" );
out.println( "</head>" );
// body section of document
out.println( "<body>" );
out.println( "<h1>Welcome to Servlets!</h1>" );
out.println( "</body>" );
// end XHTML document
out.println( "</html>" );
out.close(); // close stream to complete the page
}
}
If anyone out there can get this code running please help me to do the same.
I am studying a JEE course at the moment and I am on the module with
servlets.
Included in the course are simple sample servlets.
This may sound dumb but I cant get any of them to work either by
themselves or in netbeans on the glassfish server. I have tried dropiing
them in the web pages folder in the project and also I replaced the
content of the index.jsp file with WelcomeServlet.html content. The
example I will use her is the first one and the most simple called
WelcomeServlet.
The function of the servlet is that when the user pressed the "get html
document" button the program should retrieve the document from the .java
file. However when I press the button I get this error
HTTP Status 404 - Not Found type Status report
messageNot Found
descriptionThe requested resource is not available.
GlassFish Server Open Source Edition 4.0
Here is the code in question. WelcomeServlet.html
<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Fig. 17.6: WelcomeServlet.html -->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Handling an HTTP Get Request</title>
</head>
<body>
<form action = "/advjhtp1/welcome1" method = "get">
<p><label>Click the button to invoke the servlet
<input type = "submit" value = "Get HTML Document" />
</label></p>
</form>
</body>
</html>
WelcomeServlet.java
// Fig. 16.5: WelcomeServlet.java
// A simple servlet to process get requests.
package com.deitel.advjhtp1.servlets;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class WelcomeServlet extends HttpServlet {
// process "get" requests from clients
protected void doGet( HttpServletRequest request,
HttpServletResponse response )
throws ServletException, IOException
{
response.setContentType( "text/html" );
PrintWriter out = response.getWriter();
// send XHTML page to client
// start XHTML document
out.println( "<?xml version = \"1.0\"?>" );
out.println( "<!DOCTYPE html PUBLIC \"-//W3C//DTD " +
"XHTML 1.0 Strict//EN\" \"http://www.w3.org" +
"/TR/xhtml1/DTD/xhtml1-strict.dtd\">" );
out.println(
"<html xmlns = \"http://www.w3.org/1999/xhtml\">" );
// head section of document
out.println( "<head>" );
out.println( "<title>A Simple Servlet Example</title>" );
out.println( "</head>" );
// body section of document
out.println( "<body>" );
out.println( "<h1>Welcome to Servlets!</h1>" );
out.println( "</body>" );
// end XHTML document
out.println( "</html>" );
out.close(); // close stream to complete the page
}
}
If anyone out there can get this code running please help me to do the same.
Adding row_array to result_array foreach loop with codeigniter?
Adding row_array to result_array foreach loop with codeigniter?
I currently have a function on a web app which I'm building where a
jobseeker can view the jobs they have applied for, very simple.
When they "apply" this application is stored in the database table
'applications' with a 'job_id' column which stores the 'id' of the job
from the 'jobs' database table.
At the moment I am able to pull each application the said jobseeker has made.
Though, I am unable to loop through each application and find the job
which corresponds to that application and then add the row_array() array
which I will then output the jobs with a foreach loop.
Essentially I am asking how do I add an array to an array and then output
the full array?
appliedfor.php (CONTROLLER)
$applications_query = $this->db->get_where('applications',
array('jobseeker_profile_id' => $user['id']) );
$applications = $applications_query->result_array();
$data[] = array();
foreach($applications as $application){
$job_id = $application['job_id'];
$data['job'] = $this->db->get_where('jobs', array('id' =>
$job_id ))->row_array();
$data['jobs'] .= $data['job'];
}
$data['jobs'];
$this->load->view('header');
$this->load->view('appliedfor', $data);
appliedfor.php (VIEW)
foreach($jobs as $job){
$single_job_id = $job['id'];
echo "<br>";
echo form_open('job/view'.'" id="eachJob');
echo "<div id=\"leftContain\" class=\"floatLeft\">";
echo "<h4 class=\"green\">".$job['role']."</h4>";
echo "<div class=\"italic\"><div class=\"blue
floatLeft\">".$job['company']." </div><div
class=\"floatLeft\">in</div><div class=\"blue floatLeft\">
".$job['location']."</div></div><br><br>";
echo "</div>";
echo "<div id=\"rightContain\" class=\"floatLeft\">";
echo "<input type=\"hidden\" name=\"job_id\"
value=\"".$single_job_id."\">";
echo form_submit('submit'.'" class="jobButton floatRight"', 'View Job');
echo "</div>";
echo form_close();
}
I am currently getting 2 errors: Undefined index: jobs and the error is on
this line apparently $data['jobs'] in the controller within the foreach.
The other error is the foreach within the view file but that is basically
triggered by the first error.
Thanks for your help.
I currently have a function on a web app which I'm building where a
jobseeker can view the jobs they have applied for, very simple.
When they "apply" this application is stored in the database table
'applications' with a 'job_id' column which stores the 'id' of the job
from the 'jobs' database table.
At the moment I am able to pull each application the said jobseeker has made.
Though, I am unable to loop through each application and find the job
which corresponds to that application and then add the row_array() array
which I will then output the jobs with a foreach loop.
Essentially I am asking how do I add an array to an array and then output
the full array?
appliedfor.php (CONTROLLER)
$applications_query = $this->db->get_where('applications',
array('jobseeker_profile_id' => $user['id']) );
$applications = $applications_query->result_array();
$data[] = array();
foreach($applications as $application){
$job_id = $application['job_id'];
$data['job'] = $this->db->get_where('jobs', array('id' =>
$job_id ))->row_array();
$data['jobs'] .= $data['job'];
}
$data['jobs'];
$this->load->view('header');
$this->load->view('appliedfor', $data);
appliedfor.php (VIEW)
foreach($jobs as $job){
$single_job_id = $job['id'];
echo "<br>";
echo form_open('job/view'.'" id="eachJob');
echo "<div id=\"leftContain\" class=\"floatLeft\">";
echo "<h4 class=\"green\">".$job['role']."</h4>";
echo "<div class=\"italic\"><div class=\"blue
floatLeft\">".$job['company']." </div><div
class=\"floatLeft\">in</div><div class=\"blue floatLeft\">
".$job['location']."</div></div><br><br>";
echo "</div>";
echo "<div id=\"rightContain\" class=\"floatLeft\">";
echo "<input type=\"hidden\" name=\"job_id\"
value=\"".$single_job_id."\">";
echo form_submit('submit'.'" class="jobButton floatRight"', 'View Job');
echo "</div>";
echo form_close();
}
I am currently getting 2 errors: Undefined index: jobs and the error is on
this line apparently $data['jobs'] in the controller within the foreach.
The other error is the foreach within the view file but that is basically
triggered by the first error.
Thanks for your help.
CKEditor 4 and nonstandard HTML element
CKEditor 4 and nonstandard HTML element
Here is a nonstandard HTML element that I defined (AngularJS makes this
easy):
<exercise id="Sample Exercise" language="Scala" lectureId="5437"> This is
the text of the lecture </exercise>
If I use this element in an HTML document, each time I switch from
CKEditor's rendered mode to source mode a new empty paragraph is added
between each of the block elements in the document:
<p> </p>
The 2nd time I switch, I get two insertions:
<p> </p>
<p> </p>
The 3rd time I switch, I get three insertions between each block-level
element, etc:
<p> </p>
<p> </p>
<p> </p>
Can anyone suggest a workaround?
Here is a nonstandard HTML element that I defined (AngularJS makes this
easy):
<exercise id="Sample Exercise" language="Scala" lectureId="5437"> This is
the text of the lecture </exercise>
If I use this element in an HTML document, each time I switch from
CKEditor's rendered mode to source mode a new empty paragraph is added
between each of the block elements in the document:
<p> </p>
The 2nd time I switch, I get two insertions:
<p> </p>
<p> </p>
The 3rd time I switch, I get three insertions between each block-level
element, etc:
<p> </p>
<p> </p>
<p> </p>
Can anyone suggest a workaround?
JS will not loop, stops after first loop
JS will not loop, stops after first loop
I've written the code below to act as a simple slideshow in the header of
a clients website. Now, the only problem is when I put it into a for or a
while loop it gets to the end of the first loop and then stops.
I've tried using calling togglinga() in the last callback, I've tried,
wrapping the whole thing in a for and while loop, I've tried creating a
different function that calls this one and then using that same function
name in the final call back but get the same result everytime. I'd really
appreciate someone casting their eye over this to see if they can see
anything I can't....
Thanks
function togglinga(){ triggerAnimation };
function triggerAnimation(){
$("#logoareacontainer").delay(15000).fadeOut(3000, function() {
$("#title-1").fadeIn(0).delay(0, function() {
$("#cdsl-1-1").fadeIn(1000).delay(2000).fadeOut(0,
function(){
$("#cdsl-1-2").fadeIn(0).delay(2000).fadeOut(0,
function(){
$("#cdsl-1-3").fadeIn(0).delay(2000).fadeOut(0,
function(){
$("#cdsl-1-4").fadeIn(0).delay(2000).fadeOut(0,
function(){
$("#title-1").fadeOut(0).css({display:'none'})
$("#title-2").fadeIn(0).delay(0, function() {
$("#cdsl-2-1").fadeIn(0).delay(2000).fadeOut(0,
function(){
$("#cdsl-2-2").fadeIn(0).delay(2000).fadeOut(1000,
function(){
$("#title-2").fadeOut(1000).css({display:'none'})
$("#title-3").fadeIn(0).delay(2000,
function() {
$("#cdsl-3-1").fadeIn(1000).delay(2000).fadeOut(1000,
function(){
$("#cdsl-3-2").fadeIn(1000).delay(2000).fadeOut(1000,
function(){
$("#title-3").fadeOut(1000).css({display:'none'})
$("#title-4").fadeIn(0).delay(0,
function() {
$("#title-4-1").fadeIn(1);
$("#cdsl-4-1").fadeIn(1000).delay(2000).fadeOut(1000,
function(){
$("#cdsl-4-2").fadeIn(1000).delay(2000).fadeOut(1000,
function(){
$("#title-4").fadeOut(1000).css({display:'none'})
$("#title-4-1").fadeOut(1000).css({display:'none'})
$("#title-5").fadeIn(0).delay(0,
function()
{
$("#title-5-1").fadeIn(1);
$("#cdsl-5-1").fadeIn(1000).delay(2000).fadeOut(1000,
function(){
$("#title-5").fadeOut(1000).css({display:'none'})
$("#title-5-1").fadeOut(100).css({display:'none'})
$("#title-6").fadeIn(0).delay(0,
function()
{
$("#cdsl-6-1").fadeIn(1000).delay(2000).fadeOut(1000,
function(){
$("#title-6").fadeOut(1000).css({display:'none'})
$("#logoareacontainer").fadeIn(1000).css({display:'block'})
})
})
})
})
})
})
})
})
})
})
})
})
})
})
})
})
})
})
})
}
I've written the code below to act as a simple slideshow in the header of
a clients website. Now, the only problem is when I put it into a for or a
while loop it gets to the end of the first loop and then stops.
I've tried using calling togglinga() in the last callback, I've tried,
wrapping the whole thing in a for and while loop, I've tried creating a
different function that calls this one and then using that same function
name in the final call back but get the same result everytime. I'd really
appreciate someone casting their eye over this to see if they can see
anything I can't....
Thanks
function togglinga(){ triggerAnimation };
function triggerAnimation(){
$("#logoareacontainer").delay(15000).fadeOut(3000, function() {
$("#title-1").fadeIn(0).delay(0, function() {
$("#cdsl-1-1").fadeIn(1000).delay(2000).fadeOut(0,
function(){
$("#cdsl-1-2").fadeIn(0).delay(2000).fadeOut(0,
function(){
$("#cdsl-1-3").fadeIn(0).delay(2000).fadeOut(0,
function(){
$("#cdsl-1-4").fadeIn(0).delay(2000).fadeOut(0,
function(){
$("#title-1").fadeOut(0).css({display:'none'})
$("#title-2").fadeIn(0).delay(0, function() {
$("#cdsl-2-1").fadeIn(0).delay(2000).fadeOut(0,
function(){
$("#cdsl-2-2").fadeIn(0).delay(2000).fadeOut(1000,
function(){
$("#title-2").fadeOut(1000).css({display:'none'})
$("#title-3").fadeIn(0).delay(2000,
function() {
$("#cdsl-3-1").fadeIn(1000).delay(2000).fadeOut(1000,
function(){
$("#cdsl-3-2").fadeIn(1000).delay(2000).fadeOut(1000,
function(){
$("#title-3").fadeOut(1000).css({display:'none'})
$("#title-4").fadeIn(0).delay(0,
function() {
$("#title-4-1").fadeIn(1);
$("#cdsl-4-1").fadeIn(1000).delay(2000).fadeOut(1000,
function(){
$("#cdsl-4-2").fadeIn(1000).delay(2000).fadeOut(1000,
function(){
$("#title-4").fadeOut(1000).css({display:'none'})
$("#title-4-1").fadeOut(1000).css({display:'none'})
$("#title-5").fadeIn(0).delay(0,
function()
{
$("#title-5-1").fadeIn(1);
$("#cdsl-5-1").fadeIn(1000).delay(2000).fadeOut(1000,
function(){
$("#title-5").fadeOut(1000).css({display:'none'})
$("#title-5-1").fadeOut(100).css({display:'none'})
$("#title-6").fadeIn(0).delay(0,
function()
{
$("#cdsl-6-1").fadeIn(1000).delay(2000).fadeOut(1000,
function(){
$("#title-6").fadeOut(1000).css({display:'none'})
$("#logoareacontainer").fadeIn(1000).css({display:'block'})
})
})
})
})
})
})
})
})
})
})
})
})
})
})
})
})
})
})
})
}
jcurses with scala ClassLoader.getSystemClassLoader().getResource() returns NULL
jcurses with scala ClassLoader.getSystemClassLoader().getResource()
returns NULL
I'm learning trying to learn scala this weekend and so decided to try to
write a simple text based game using java curses.
The scala code (simplified for the question submission) looks like:
import jcurses.widgets.Window
object testScala {
def main (args: Array[String]) {
val w = new Window(80, 24, true, "snake")
}
}
The program is compiled thus:
scalac -cp jcurses.jar:. n.scala
and run like so:
scala -cp jcurses.jar:. testScala
Which produces the following exception:
java.lang.NullPointerException
at jcurses.system.Toolkit.getLibraryPath(Toolkit.java:97)
at jcurses.system.Toolkit.<clinit>(Toolkit.java:37)
at jcurses.system.InputChar.<clinit>(InputChar.java:13)
at jcurses.widgets.Window.<clinit>(Window.java:209)
at testScala$.main(n.scala:5)
at testScala.main(n.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:71)
at
scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
at
scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:139)
at
scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:71)
at
scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:139)
at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:28)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:45)
at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:35)
at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:45)
at
scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:74)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
The offending code is:
String url =
ClassLoader.getSystemClassLoader().getResource("jcurses/system/Toolkit.class").toString();
Now, I've read a few posts about how getResource() here is relative to the
package root, so the above line looks fine to me since when I untar the
.jar file the same structure is revealed:
$ mkdir tmp && cp jcurses.jar tmp && cd tmp
$ jar xvf jcurses.jar
$ file jcurses/system/Toolkit.class
jcurses/system/Toolkit.class: compiled Java class data, version 50.0 (Java
1.6)
Next thing I did was hack up the same thing in Java, which works fine:
$ cat m.java import jcurses.widgets.Window;
public class m {
public static void main (String args[]) {
Window w = new Window(80, 24, true, "snake");
}
}
Then compile and run:
javac -cp jcurses.jar:. m.java
java -cp jcurses.jar:. m
Why does this work and the scala program does not? Has anyone got jcurses
to work with scala?
I've tried this on both linux (debian) and os x and neither works with scala.
Help!
returns NULL
I'm learning trying to learn scala this weekend and so decided to try to
write a simple text based game using java curses.
The scala code (simplified for the question submission) looks like:
import jcurses.widgets.Window
object testScala {
def main (args: Array[String]) {
val w = new Window(80, 24, true, "snake")
}
}
The program is compiled thus:
scalac -cp jcurses.jar:. n.scala
and run like so:
scala -cp jcurses.jar:. testScala
Which produces the following exception:
java.lang.NullPointerException
at jcurses.system.Toolkit.getLibraryPath(Toolkit.java:97)
at jcurses.system.Toolkit.<clinit>(Toolkit.java:37)
at jcurses.system.InputChar.<clinit>(InputChar.java:13)
at jcurses.widgets.Window.<clinit>(Window.java:209)
at testScala$.main(n.scala:5)
at testScala.main(n.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:71)
at
scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
at
scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:139)
at
scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:71)
at
scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:139)
at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:28)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:45)
at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:35)
at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:45)
at
scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:74)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
The offending code is:
String url =
ClassLoader.getSystemClassLoader().getResource("jcurses/system/Toolkit.class").toString();
Now, I've read a few posts about how getResource() here is relative to the
package root, so the above line looks fine to me since when I untar the
.jar file the same structure is revealed:
$ mkdir tmp && cp jcurses.jar tmp && cd tmp
$ jar xvf jcurses.jar
$ file jcurses/system/Toolkit.class
jcurses/system/Toolkit.class: compiled Java class data, version 50.0 (Java
1.6)
Next thing I did was hack up the same thing in Java, which works fine:
$ cat m.java import jcurses.widgets.Window;
public class m {
public static void main (String args[]) {
Window w = new Window(80, 24, true, "snake");
}
}
Then compile and run:
javac -cp jcurses.jar:. m.java
java -cp jcurses.jar:. m
Why does this work and the scala program does not? Has anyone got jcurses
to work with scala?
I've tried this on both linux (debian) and os x and neither works with scala.
Help!
Git local repository management
Git local repository management
I am quite new to git but the advantages to use it are quite clear! I have
been developing for iOS and I have created some custom class of mine that
I share among several projects, I would like to keep them centralized so I
can pull and push only from/in a single place, and only that specific
folder will be always up to date with the latest changes, that can come
from different projects.
How can I setup practically a scenario like this? I really thank you in
advance!
I am quite new to git but the advantages to use it are quite clear! I have
been developing for iOS and I have created some custom class of mine that
I share among several projects, I would like to keep them centralized so I
can pull and push only from/in a single place, and only that specific
folder will be always up to date with the latest changes, that can come
from different projects.
How can I setup practically a scenario like this? I really thank you in
advance!
Friday, 30 August 2013
Checkstyle equivalent for Objective-C
Checkstyle equivalent for Objective-C
Is there a checkstyle equivalent for Objective-C?
This question has been attempted before, but either the wasn't clear in
what was being asked, or the answers were not satisfactory.
I do not want a code formatting tool. (There's lots of options here. I use
AppCode).
I do want a tool that can identify code smells, and fail the build for me.
Here's some checks that would be useful:
Class too long.
Method too long.
Method has too many parameters.
Cyclomatic complexity - class has too many dependencies.
I've found that doing these continuous, automated code audits really helps
in a team environment.
Is there a checkstyle equivalent for Objective-C?
This question has been attempted before, but either the wasn't clear in
what was being asked, or the answers were not satisfactory.
I do not want a code formatting tool. (There's lots of options here. I use
AppCode).
I do want a tool that can identify code smells, and fail the build for me.
Here's some checks that would be useful:
Class too long.
Method too long.
Method has too many parameters.
Cyclomatic complexity - class has too many dependencies.
I've found that doing these continuous, automated code audits really helps
in a team environment.
Thursday, 29 August 2013
AS3 depth sorting with extras
AS3 depth sorting with extras
I got an issue recently with depth sorting in my program. Basically, I
sort on every frame. The sort should watch the "depth" which is actually
the scaleX and scaleY (they're always the same so I'm just watching the
scaleX), so those elements which has bigger scaleX should be above of
those which has lower but also check the y value and then sort. In one
word: sort on scaleX then sort on Y. Any suggestions how could I write
such sorting function?
I got an issue recently with depth sorting in my program. Basically, I
sort on every frame. The sort should watch the "depth" which is actually
the scaleX and scaleY (they're always the same so I'm just watching the
scaleX), so those elements which has bigger scaleX should be above of
those which has lower but also check the y value and then sort. In one
word: sort on scaleX then sort on Y. Any suggestions how could I write
such sorting function?
How do you add a jquery library?
How do you add a jquery library?
Got a piece of code that is working on fiddle but i don't think my library
is correct. or i haven't done the below right
im really lost as what to do can someone link me a jquery library
<head>
<meta charset="UTF-8">
<title>Main Form</title>
<link rel= "stylesheet" href="CSS/Stylesheet.css">
<script src="Jquery.js"></script>
<script src="jquery-1.10.2.min.js"></script>
</head>
Got a piece of code that is working on fiddle but i don't think my library
is correct. or i haven't done the below right
im really lost as what to do can someone link me a jquery library
<head>
<meta charset="UTF-8">
<title>Main Form</title>
<link rel= "stylesheet" href="CSS/Stylesheet.css">
<script src="Jquery.js"></script>
<script src="jquery-1.10.2.min.js"></script>
</head>
Wednesday, 28 August 2013
Child Node's attribute value using DOM
Child Node's attribute value using DOM
I want to get the attribute value of a childnode in a xml file using DOM
parser without XPath..Is there any way that I can do that
I want to get the attribute value of a childnode in a xml file using DOM
parser without XPath..Is there any way that I can do that
Removing/Showing Elements
Removing/Showing Elements
I'm trying to create a site where 3 images, which are to be clicked on,
toggle 3 different divs/elements. What I want is each click-able image to
show a certain element, whilst removing the elements previously shown.
So image1 will show div1, image2 will show div2, image3 will show div3.
The elements before have to be literally removed, not just hidden from
sight.
If possible, is there a way to save the option for when someone lasts
visits the site with cookies?
I'm trying to create a site where 3 images, which are to be clicked on,
toggle 3 different divs/elements. What I want is each click-able image to
show a certain element, whilst removing the elements previously shown.
So image1 will show div1, image2 will show div2, image3 will show div3.
The elements before have to be literally removed, not just hidden from
sight.
If possible, is there a way to save the option for when someone lasts
visits the site with cookies?
How to remap Caps_Lock to left Alt + left Ctrl and Ctrl to Caps_Lock?
How to remap Caps_Lock to left Alt + left Ctrl and Ctrl to Caps_Lock?
How to remap Caps_Lock to left Alt + left Ctrl and Ctrl to Caps_Lock?
My xmodmap config:
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Mode_switch
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
How to remap Caps_Lock to left Alt + left Ctrl and Ctrl to Caps_Lock?
My xmodmap config:
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Mode_switch
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
Tuesday, 27 August 2013
How to make Download in android?
How to make Download in android?
I wanna create download app from url using android code like download
manager but really I don't know how to start
thanks for any help or any video tuts
I wanna create download app from url using android code like download
manager but really I don't know how to start
thanks for any help or any video tuts
stop emacs server being killed on logout
stop emacs server being killed on logout
I'd like to run an emacs server in the background and have it persist
after logout. I do not want to start it a system service since it's not a
system service. A more practical reason is that I'm not the only one using
this computer.
I've tried running emacs --daemon from a graphical terminal, and running
emacs-client -c --alternate-editor "" from a graphical terminal and from
the unity launcher, but in all cases the emacs server process is killed on
logout.
This seems to be a bug to me. For instance, my screen session is not
killed on logout. I thought I might ask about this here before filing a
bug report. There is this bug
https://bugs.launchpad.net/ubuntu/+source/emacs-defaults/+bug/1079820
which seems to suggest it is desirable to kill the emacs server on logout.
I disagree: it's a daemon and should be launchable from within unity and
not killed on logout. The bug report also suggests that the problem does
not exist in emacs24 so is not an issue. I'm running Ubuntu 12.04 with
emacs23 and can't upgrade right now and so it is an issue for me.
The workaround I have found is to ctrl-alt-F1 and run the daemon from the
terminal there. Then Unity has no knowledge of the process and doesn't
kill it on logout. I'd prefer not to have to do this however.
Does anyone know how to prevent the emacs --daemon process being killed
when I logout?
I'd like to run an emacs server in the background and have it persist
after logout. I do not want to start it a system service since it's not a
system service. A more practical reason is that I'm not the only one using
this computer.
I've tried running emacs --daemon from a graphical terminal, and running
emacs-client -c --alternate-editor "" from a graphical terminal and from
the unity launcher, but in all cases the emacs server process is killed on
logout.
This seems to be a bug to me. For instance, my screen session is not
killed on logout. I thought I might ask about this here before filing a
bug report. There is this bug
https://bugs.launchpad.net/ubuntu/+source/emacs-defaults/+bug/1079820
which seems to suggest it is desirable to kill the emacs server on logout.
I disagree: it's a daemon and should be launchable from within unity and
not killed on logout. The bug report also suggests that the problem does
not exist in emacs24 so is not an issue. I'm running Ubuntu 12.04 with
emacs23 and can't upgrade right now and so it is an issue for me.
The workaround I have found is to ctrl-alt-F1 and run the daemon from the
terminal there. Then Unity has no knowledge of the process and doesn't
kill it on logout. I'd prefer not to have to do this however.
Does anyone know how to prevent the emacs --daemon process being killed
when I logout?
PHP - Converting Seconds to Minutes discrepancy
PHP - Converting Seconds to Minutes discrepancy
I'm running into a discrepancy with either my conversion of an integer
into defined Minutes.
<?php
$seconds = 269;
echo date("G:i:s", $seconds);
// result: 0:04:29
?>
I figured I'd double check on some sites to see if the conversion is correct:
Here's one I found: http://www.thecalculatorsite.com/conversions/time.php
The result returned is: 4.4833333333333
Example 1 returns: 0:04:29 Example 2 returns: 4.4833333333333
I'm confused about this. What am I missing here. Am I using the date()
function incorrectly?
I'm running into a discrepancy with either my conversion of an integer
into defined Minutes.
<?php
$seconds = 269;
echo date("G:i:s", $seconds);
// result: 0:04:29
?>
I figured I'd double check on some sites to see if the conversion is correct:
Here's one I found: http://www.thecalculatorsite.com/conversions/time.php
The result returned is: 4.4833333333333
Example 1 returns: 0:04:29 Example 2 returns: 4.4833333333333
I'm confused about this. What am I missing here. Am I using the date()
function incorrectly?
Create a persistent qemu+ssh connection
Create a persistent qemu+ssh connection
I am trying to make a script that will list the VMs on my four host
servers, and dump the xml for guest domains that are running. I am running
the script on one host server, and using qemu+ssh to connect to the
others.
This is an example command:virsh -c qemu+ssh://${HOSTS[$index]}/system
dumpxml $vm > xmldump/$DATE/$vm.xml
This command runs for each VM running on that host and a new connection is
made each time and I am prompted for my password each time. This works but
is not ideal.
How could I do this so that I only make one connection per host, and run
all my commands within that connection?
These are KVMs running on Ubuntu servers using libvirt.
I am trying to make a script that will list the VMs on my four host
servers, and dump the xml for guest domains that are running. I am running
the script on one host server, and using qemu+ssh to connect to the
others.
This is an example command:virsh -c qemu+ssh://${HOSTS[$index]}/system
dumpxml $vm > xmldump/$DATE/$vm.xml
This command runs for each VM running on that host and a new connection is
made each time and I am prompted for my password each time. This works but
is not ideal.
How could I do this so that I only make one connection per host, and run
all my commands within that connection?
These are KVMs running on Ubuntu servers using libvirt.
Django Cannot update a query once a slice has been taken
Django Cannot update a query once a slice has been taken
I have a query...
message_batch = Message.objects.all()[500]
I don't want to have to make another database call to retrieve the
objects, besides I already have them in memory so whats the point.
So I tried to update like this:
message_batch.update(send_date=datetime.datetime.now(), status="Sent")
But I get the following error message:
Cannot update a query once a slice has been taken.
Why? Is there a around around this? I want to update the objects I already
have in memory but make another call to retrieve them.
This is my full code, has to be way around this....
total = Message.objects.filter(status="Unsent", sender=user,
batch=batch).exclude(recipient_number__exact='').count()
for i in xrange(0,total,500):
message_batch =
Message.objects.filter(status="Unsent").exclude(recipient_number__exact='')[i:i+500]
# do some stuff here
#once all done update the objects
message_batch.update(send_date=datetime.datetime.now(),
billed=True)
I have a query...
message_batch = Message.objects.all()[500]
I don't want to have to make another database call to retrieve the
objects, besides I already have them in memory so whats the point.
So I tried to update like this:
message_batch.update(send_date=datetime.datetime.now(), status="Sent")
But I get the following error message:
Cannot update a query once a slice has been taken.
Why? Is there a around around this? I want to update the objects I already
have in memory but make another call to retrieve them.
This is my full code, has to be way around this....
total = Message.objects.filter(status="Unsent", sender=user,
batch=batch).exclude(recipient_number__exact='').count()
for i in xrange(0,total,500):
message_batch =
Message.objects.filter(status="Unsent").exclude(recipient_number__exact='')[i:i+500]
# do some stuff here
#once all done update the objects
message_batch.update(send_date=datetime.datetime.now(),
billed=True)
simple SQL query to display values from a table based on condition
simple SQL query to display values from a table based on condition
Assume there is client and a server
Client:: Android mobile
Server:: AWS server
Server has mysql database installed in it
Database name:: Person
Tables in person Database:: "sam" and "carl"
Now mobile sends a request...
How to write an SQL query so that if mobile sends request i/p as "sam"
display all the values of sam table
But if the mobile sends an i/p as carl then dipslay all the values of carl
table
[Note] I have used statement SELECT * FROM TABLE_NAME
What i am trying to achieve is a condition response when a client request
comes in
I/p means :: say i get carl as ip .... i want to perform one query else
sam as input ... i want to perform another query
what query statement should i need to write ?
hope i am stating my problem correctly
Thanks
Assume there is client and a server
Client:: Android mobile
Server:: AWS server
Server has mysql database installed in it
Database name:: Person
Tables in person Database:: "sam" and "carl"
Now mobile sends a request...
How to write an SQL query so that if mobile sends request i/p as "sam"
display all the values of sam table
But if the mobile sends an i/p as carl then dipslay all the values of carl
table
[Note] I have used statement SELECT * FROM TABLE_NAME
What i am trying to achieve is a condition response when a client request
comes in
I/p means :: say i get carl as ip .... i want to perform one query else
sam as input ... i want to perform another query
what query statement should i need to write ?
hope i am stating my problem correctly
Thanks
WC Cart Edit Public Function
WC Cart Edit Public Function
How would you go about making an edit to the following public function in
your child theme? For instance, I would like to comment out the 'if
statement' in the WooCommerce WC_Cart class function that performs the
check against email and coupon code.
Line 400: /classes/class-wc-cart.php
public function check_customer_coupons( $posted ) {
global $woocommerce;
if ( ! empty( $this->applied_coupons ) ) {
foreach ( $this->applied_coupons as $key => $code ) {
$coupon = new WC_Coupon( $code );
if ( ! is_wp_error( $coupon->is_valid() ) && is_array(
$coupon->customer_email ) && sizeof(
$coupon->customer_email ) > 0 ) {
$coupon->customer_email = array_map( 'sanitize_email',
$coupon->customer_email );
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
$check_emails[] = $current_user->user_email;
}
$check_emails[] = $posted['billing_email'];
$check_emails = array_map( 'sanitize_email',
array_map( 'strtolower', $check_emails ) );
/*if ( 0 == sizeof( array_intersect( $check_emails,
$coupon->customer_email ) ) ) {
$coupon->add_coupon_message(
WC_Coupon::E_WC_COUPON_NOT_YOURS_REMOVED );
// Remove the coupon
unset( $this->applied_coupons[ $key ] );
$woocommerce->session->coupon_codes =
$this->applied_coupons;
$woocommerce->session->refresh_totals = true;
} */
}
}
}
}
This function is executed Line 104: /classes/class-wc-cart.php
public function init() {
$this->get_cart_from_session();
add_action('woocommerce_check_cart_items', array( $this,
'check_cart_items' ), 1 );
add_action('woocommerce_check_cart_items', array( $this,
'check_cart_coupons' ), 1 );
add_action('woocommerce_after_checkout_validation', array( $this,
'check_customer_coupons' ), 1 );
}
I think the answer would be useful for anyone else wanting to know how to
edit other functions.
Thank you.
How would you go about making an edit to the following public function in
your child theme? For instance, I would like to comment out the 'if
statement' in the WooCommerce WC_Cart class function that performs the
check against email and coupon code.
Line 400: /classes/class-wc-cart.php
public function check_customer_coupons( $posted ) {
global $woocommerce;
if ( ! empty( $this->applied_coupons ) ) {
foreach ( $this->applied_coupons as $key => $code ) {
$coupon = new WC_Coupon( $code );
if ( ! is_wp_error( $coupon->is_valid() ) && is_array(
$coupon->customer_email ) && sizeof(
$coupon->customer_email ) > 0 ) {
$coupon->customer_email = array_map( 'sanitize_email',
$coupon->customer_email );
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
$check_emails[] = $current_user->user_email;
}
$check_emails[] = $posted['billing_email'];
$check_emails = array_map( 'sanitize_email',
array_map( 'strtolower', $check_emails ) );
/*if ( 0 == sizeof( array_intersect( $check_emails,
$coupon->customer_email ) ) ) {
$coupon->add_coupon_message(
WC_Coupon::E_WC_COUPON_NOT_YOURS_REMOVED );
// Remove the coupon
unset( $this->applied_coupons[ $key ] );
$woocommerce->session->coupon_codes =
$this->applied_coupons;
$woocommerce->session->refresh_totals = true;
} */
}
}
}
}
This function is executed Line 104: /classes/class-wc-cart.php
public function init() {
$this->get_cart_from_session();
add_action('woocommerce_check_cart_items', array( $this,
'check_cart_items' ), 1 );
add_action('woocommerce_check_cart_items', array( $this,
'check_cart_coupons' ), 1 );
add_action('woocommerce_after_checkout_validation', array( $this,
'check_customer_coupons' ), 1 );
}
I think the answer would be useful for anyone else wanting to know how to
edit other functions.
Thank you.
Monday, 26 August 2013
Display pop up ( alert ) when submit
Display pop up ( alert ) when submit
I have a situation where I need to submit the form and display an alert
message after the action completes. I am sending request from xyz.jsp and
after submit, xyz.jsp will be displayed back in the browser with modified
data.
My code in servlet looks as below.
public void doPost(......)
{
//process input value.
PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println("<script type=\"text/javascript\">");
out.println("alert('"+message+"');");
out.println("</script>");
RequestDispatcher rd = sc.getRequestDispatcher(/xyz.jsp);
rd.forward(request, response);
}
But when I submit, the pop up will not appear, but xyz.jsp will be loaded
in the browser.
Could anyone please help me to resolve the issue.
I have a situation where I need to submit the form and display an alert
message after the action completes. I am sending request from xyz.jsp and
after submit, xyz.jsp will be displayed back in the browser with modified
data.
My code in servlet looks as below.
public void doPost(......)
{
//process input value.
PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println("<script type=\"text/javascript\">");
out.println("alert('"+message+"');");
out.println("</script>");
RequestDispatcher rd = sc.getRequestDispatcher(/xyz.jsp);
rd.forward(request, response);
}
But when I submit, the pop up will not appear, but xyz.jsp will be loaded
in the browser.
Could anyone please help me to resolve the issue.
When using popToRootViewController I lose my navigation bar
When using popToRootViewController I lose my navigation bar
I have an iOS app where the main screen is a UICollectionViewController.
When selecting an Item from the collection view the view is pushed to a
detail view of the item. In the detail view I built a drawer/slider that
moves out from the side. In order to get the view to look the way I wanted
I hid the default navigation bar and inserted one via storyboards.
I ran into an issue that when hiding the default navigation bar you lose
the back button functionality that comes with using a navigation
controller. I worked around this by adding a button where the back button
would have been (the image above is shown without the button). Now I use
the line of code below to move back to the collection view.
[self.navigationController popToRootViewControllerAnimated:YES];
It works the way I want it except that I lose my Navigation Bar when I
return to the collection view. Does anyone have any thoughts on how to fix
this? Thanks in advance!
I have an iOS app where the main screen is a UICollectionViewController.
When selecting an Item from the collection view the view is pushed to a
detail view of the item. In the detail view I built a drawer/slider that
moves out from the side. In order to get the view to look the way I wanted
I hid the default navigation bar and inserted one via storyboards.
I ran into an issue that when hiding the default navigation bar you lose
the back button functionality that comes with using a navigation
controller. I worked around this by adding a button where the back button
would have been (the image above is shown without the button). Now I use
the line of code below to move back to the collection view.
[self.navigationController popToRootViewControllerAnimated:YES];
It works the way I want it except that I lose my Navigation Bar when I
return to the collection view. Does anyone have any thoughts on how to fix
this? Thanks in advance!
How do I reset a USB device using a script?
How do I reset a USB device using a script?
I have a USB GSM modem that does not alwasys work property (Huawei
E367u-2) Sometimes it gets reset (USB device disconnect/reconnect in logs)
and when it comes back up, it's has different ttyUSB numbers. Sometimes on
boot, usb_modswitch seems to just not get fired. The computer is a
Raspberry Pi running Raspbian.
I have a simple solution to this, every minute CROM runs the following
script:
If WVDIAL is not running:
Run WVDIAL
I want to change the script to be this:
If /dev/ttyUSB0 is not present:
If DevicePresent(12d1:1446):
ResetDevice(12d1:1446)
ElseIs DevicePresemt(12d1:1506)
ResetUSB(12d1:1506)
If WVDIAL is not running:
Run WVDIAL
Obvisouly this is psuedo code, but I havethe follwoing lines that I need
to string together but I can't firgure out how:
This loads wvdial if it is not running:
#! /bin/sh
# /etc/init.d/wvdial
### BEGIN INIT INFO
# Provides: TheInternet
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Simple script to start a program at boot
# Description: A simple script from www.stuffaboutcode.com which
will start / stop a program a boot / shutdown.
### END INIT INFO
# If you want a command to always run, put it here
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting GPRS Internet"
# run application you want to start
/sbin/start-stop-daemon --start --background --quiet --exec
/usr/bin/wvdial internet
;;
stop)
echo "Stopping GPRS Internet"
# kill application you want to stop
/sbin/start-stop-daemon --stop --exec /usr/bin/wvdial
;;
*)
echo "Usage: /etc/init.d/noip {start|stop}"
exit 1
;;
esac
exit 0
This lets me find the /sys path to a certain device:
for X in /sys/bus/usb/devices/*; do
echo "$X"
cat "$X/idVendor" 2>/dev/null
cat "$X/idProduct" 2>/dev/null
echo
done
And this resets a USB device if you know the correct /sys path:
echo 0 > /sys/bus/usb/devices/1-1.2.1.1/authorized
echo 1 > /sys/bus/usb/devices/1-1.2.1.1/authorized
So, I need to string the last 2 sections and a test to /dev/ttyUSB0 into a
section that goes under the "If you want a command to always run. put it
here" section
How can I do that? Or Is there a better way to do this?
I have a USB GSM modem that does not alwasys work property (Huawei
E367u-2) Sometimes it gets reset (USB device disconnect/reconnect in logs)
and when it comes back up, it's has different ttyUSB numbers. Sometimes on
boot, usb_modswitch seems to just not get fired. The computer is a
Raspberry Pi running Raspbian.
I have a simple solution to this, every minute CROM runs the following
script:
If WVDIAL is not running:
Run WVDIAL
I want to change the script to be this:
If /dev/ttyUSB0 is not present:
If DevicePresent(12d1:1446):
ResetDevice(12d1:1446)
ElseIs DevicePresemt(12d1:1506)
ResetUSB(12d1:1506)
If WVDIAL is not running:
Run WVDIAL
Obvisouly this is psuedo code, but I havethe follwoing lines that I need
to string together but I can't firgure out how:
This loads wvdial if it is not running:
#! /bin/sh
# /etc/init.d/wvdial
### BEGIN INIT INFO
# Provides: TheInternet
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Simple script to start a program at boot
# Description: A simple script from www.stuffaboutcode.com which
will start / stop a program a boot / shutdown.
### END INIT INFO
# If you want a command to always run, put it here
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting GPRS Internet"
# run application you want to start
/sbin/start-stop-daemon --start --background --quiet --exec
/usr/bin/wvdial internet
;;
stop)
echo "Stopping GPRS Internet"
# kill application you want to stop
/sbin/start-stop-daemon --stop --exec /usr/bin/wvdial
;;
*)
echo "Usage: /etc/init.d/noip {start|stop}"
exit 1
;;
esac
exit 0
This lets me find the /sys path to a certain device:
for X in /sys/bus/usb/devices/*; do
echo "$X"
cat "$X/idVendor" 2>/dev/null
cat "$X/idProduct" 2>/dev/null
echo
done
And this resets a USB device if you know the correct /sys path:
echo 0 > /sys/bus/usb/devices/1-1.2.1.1/authorized
echo 1 > /sys/bus/usb/devices/1-1.2.1.1/authorized
So, I need to string the last 2 sections and a test to /dev/ttyUSB0 into a
section that goes under the "If you want a command to always run. put it
here" section
How can I do that? Or Is there a better way to do this?
400 Bad Request error when using .net Paymill Wrapper
400 Bad Request error when using .net Paymill Wrapper
I'm trying to use the .net Paymill Wrapper
When trying to add a subscription, I'm getting back a 400 Bad Request.
To illustrate the problem, I created a branch and changed the Sandbox
console app to call the method to test addSubscription
The problem is happening here where the request is actually posted.
The content posted is: (as an example)
client=client_bbe895116de80b6141fd&
offer=offer_32008ddd39954e71ed48&
payment=pay_81ec02206e9b9c587513
It appears this hasn't been updated for sometime, and the original author
is unresponsive via email or twitter, so I've forked the repo and am
trying to fix the error.
I'm trying to use the .net Paymill Wrapper
When trying to add a subscription, I'm getting back a 400 Bad Request.
To illustrate the problem, I created a branch and changed the Sandbox
console app to call the method to test addSubscription
The problem is happening here where the request is actually posted.
The content posted is: (as an example)
client=client_bbe895116de80b6141fd&
offer=offer_32008ddd39954e71ed48&
payment=pay_81ec02206e9b9c587513
It appears this hasn't been updated for sometime, and the original author
is unresponsive via email or twitter, so I've forked the repo and am
trying to fix the error.
getting error when installing new-doc plugin in grails
getting error when installing new-doc plugin in grails
I am getting failed download error when trying to install new-doc plugin.
The error message I get looks like:
==== http://repo.grails.org/grails/libs-releases-local: tried
http://repo.grails.org/grails/libs-releases-local/net/sf/json-lib/json
-lib/2.4/json-lib-2.4.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: FAILED DOWNLOADS ::
:: ^ see resolution messages for details ^ ::
::::::::::::::::::::::::::::::::::::::::::::::
:: net.sf.json-lib#json-lib;2.4!json-lib.jar
::::::::::::::::::::::::::::::::::::::::::::::
| Error Failed to resolve dependencies (Set log level to 'warn' in
BuildConfig.groovy for more information):
- net.sf.json-lib:json-lib:2.4
My BuildConfig.groovy looks like:
grails.servlet.version = "3.0" // Change depending on target container
compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.plugins.dir = "plugins"
grails.project.war.file = "target/${appName}.war"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info',
'debug' or 'verbose'
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
//mavenLocal()
mavenCentral()
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile',
'runtime', 'test' or 'provided' scopes eg.
compile 'org.apache.poi:poi:3.9'
compile 'org.apache.poi:poi-ooxml:3.9'
compile 'com.google.guava:guava:12.0'
}
plugins {
compile ":new-doc:0.3.2"
}
}
I am fairly new to groovy/grails so I am not sure what should I do next to
resolve this issue. Or can anyone suggest me any other code documentation
plugin for grails?
Thanks, Dee
I am getting failed download error when trying to install new-doc plugin.
The error message I get looks like:
==== http://repo.grails.org/grails/libs-releases-local: tried
http://repo.grails.org/grails/libs-releases-local/net/sf/json-lib/json
-lib/2.4/json-lib-2.4.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: FAILED DOWNLOADS ::
:: ^ see resolution messages for details ^ ::
::::::::::::::::::::::::::::::::::::::::::::::
:: net.sf.json-lib#json-lib;2.4!json-lib.jar
::::::::::::::::::::::::::::::::::::::::::::::
| Error Failed to resolve dependencies (Set log level to 'warn' in
BuildConfig.groovy for more information):
- net.sf.json-lib:json-lib:2.4
My BuildConfig.groovy looks like:
grails.servlet.version = "3.0" // Change depending on target container
compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.plugins.dir = "plugins"
grails.project.war.file = "target/${appName}.war"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info',
'debug' or 'verbose'
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
//mavenLocal()
mavenCentral()
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile',
'runtime', 'test' or 'provided' scopes eg.
compile 'org.apache.poi:poi:3.9'
compile 'org.apache.poi:poi-ooxml:3.9'
compile 'com.google.guava:guava:12.0'
}
plugins {
compile ":new-doc:0.3.2"
}
}
I am fairly new to groovy/grails so I am not sure what should I do next to
resolve this issue. Or can anyone suggest me any other code documentation
plugin for grails?
Thanks, Dee
EF - Getting metadata about related entities by eager loading to avoid extra DB calls
EF - Getting metadata about related entities by eager loading to avoid
extra DB calls
Scenario:
I have Users. Each user can be an "author" to an Article. (An article can
have several collaborating "authors".)
I want to present a GUI interface to search for an User by name. You will
be presented a list where the authors who have any articles have a link to
their articles, while the ones with zero still will be presented but
without the link.
Implementation:
I present a search interface for the client. They send the search string
to my UserSearchForArticlesList-controller where I ask EF for all the
Users that have a name that match the search query and sent this list to
my View.
The view iterates through the list of Users. For each it checks if it has
any documents that is public (Connection table for User<->Article, I know
that EF can solve this without making this visible, but that's how it is
now.) If the User has connections to public Articles, it creates an
ActionLink, counts the public articles and presents this count by the
link.
Controller (without eager loading):
[HttpGet]
public ActionResult UserSearchForArticlesList(string searchTerm)
{
var model = myEF.Users.Where(x =>
x.Name.Contains(searchTerm)).OrderBy(x => x.Name)};
return View("Index", model);
}
View:
@foreach (var item in Model)
{
if (item.UserArticles.Any(o => o.Article.IsPublic))
{
<li>@Html.RouteLink(item.Name, "UserArticles", new { item.Id
}) (@item.UserArticles.Count(o => o.Article.IsPublic))</li>
}else
{
<li title="No public articles for this User">@item.Name</li>
}
}
Problem:
With lazy loading the relations for the User, I get approx 7 DB calls for
EACH User I present in the list. When I eager load (.Inlude(user =>
user.UserArticles.Articles)) I get only one call, but with way to much
data then I actually need.
Is it possible that you somehow can get EF to get the matching Users and
the count of the connected public Articles for that user, using only a
reasonable amount of DB calls?
"Just after writing a big article about my problem"-insight:
It actually just hit me when debugging and looking at the EF profiler that
both the if-clause and the count in the View is resulting in a lot of
single row querys to the DB. Why is this? Shouldn't EF figure out some
minified SQL queries for this?
extra DB calls
Scenario:
I have Users. Each user can be an "author" to an Article. (An article can
have several collaborating "authors".)
I want to present a GUI interface to search for an User by name. You will
be presented a list where the authors who have any articles have a link to
their articles, while the ones with zero still will be presented but
without the link.
Implementation:
I present a search interface for the client. They send the search string
to my UserSearchForArticlesList-controller where I ask EF for all the
Users that have a name that match the search query and sent this list to
my View.
The view iterates through the list of Users. For each it checks if it has
any documents that is public (Connection table for User<->Article, I know
that EF can solve this without making this visible, but that's how it is
now.) If the User has connections to public Articles, it creates an
ActionLink, counts the public articles and presents this count by the
link.
Controller (without eager loading):
[HttpGet]
public ActionResult UserSearchForArticlesList(string searchTerm)
{
var model = myEF.Users.Where(x =>
x.Name.Contains(searchTerm)).OrderBy(x => x.Name)};
return View("Index", model);
}
View:
@foreach (var item in Model)
{
if (item.UserArticles.Any(o => o.Article.IsPublic))
{
<li>@Html.RouteLink(item.Name, "UserArticles", new { item.Id
}) (@item.UserArticles.Count(o => o.Article.IsPublic))</li>
}else
{
<li title="No public articles for this User">@item.Name</li>
}
}
Problem:
With lazy loading the relations for the User, I get approx 7 DB calls for
EACH User I present in the list. When I eager load (.Inlude(user =>
user.UserArticles.Articles)) I get only one call, but with way to much
data then I actually need.
Is it possible that you somehow can get EF to get the matching Users and
the count of the connected public Articles for that user, using only a
reasonable amount of DB calls?
"Just after writing a big article about my problem"-insight:
It actually just hit me when debugging and looking at the EF profiler that
both the if-clause and the count in the View is resulting in a lot of
single row querys to the DB. Why is this? Shouldn't EF figure out some
minified SQL queries for this?
Tell gradle to bypass dependency checks
Tell gradle to bypass dependency checks
I am at a clients site, behind a firewall. Im trying to compile but gradle
keeps trying to check my dependencies. The corporate firewall explicitly
blocks maven downloads so my build is failing. Now I have compiled before,
so the dependencies do already exist in my [user]/.gradle folder, but its
been more than 24 hours so gradle is trying to do its daily "lets check
the repo and make sure nothing changed stuff."
Is there a command switch or anything that im just simply not seeing here
to tell gradle to bypass this version check and simply compile the code? I
would even be happy with a command switch that says I don't care if
dependency resolution failed, compile anyways.
I am at a clients site, behind a firewall. Im trying to compile but gradle
keeps trying to check my dependencies. The corporate firewall explicitly
blocks maven downloads so my build is failing. Now I have compiled before,
so the dependencies do already exist in my [user]/.gradle folder, but its
been more than 24 hours so gradle is trying to do its daily "lets check
the repo and make sure nothing changed stuff."
Is there a command switch or anything that im just simply not seeing here
to tell gradle to bypass this version check and simply compile the code? I
would even be happy with a command switch that says I don't care if
dependency resolution failed, compile anyways.
php line change including space for string
php line change including space for string
I need to put hyperlinks for the strings, but the line break is wrong. I
need to change line per string, so underlined links don't mix up each
other.
$aaa = 'aaaaaaaaaaaaaaaa'
$aaa = 'bbbbbbb';
$aaa = 'ccccccc cccccc';
for($i = 1; $i <= 3; $i++)
{
echo $aaa;
echo ' '; ----->space between string
}
Currently, I'm getting wrong outputs below:
wrong output1:
aaaaaaaaaaaaaaaa bbb
bbbb
wrong output2:
aaaaaaaaaaaaaaaa bbbbbbb ccccccc
cccccc
I need to print out like this:
aaaaaaaaaaaaaaaa bbbbbbb
ccccccc cccccc
I tried and , but it still change line per at space.
I need to put hyperlinks for the strings, but the line break is wrong. I
need to change line per string, so underlined links don't mix up each
other.
$aaa = 'aaaaaaaaaaaaaaaa'
$aaa = 'bbbbbbb';
$aaa = 'ccccccc cccccc';
for($i = 1; $i <= 3; $i++)
{
echo $aaa;
echo ' '; ----->space between string
}
Currently, I'm getting wrong outputs below:
wrong output1:
aaaaaaaaaaaaaaaa bbb
bbbb
wrong output2:
aaaaaaaaaaaaaaaa bbbbbbb ccccccc
cccccc
I need to print out like this:
aaaaaaaaaaaaaaaa bbbbbbb
ccccccc cccccc
I tried and , but it still change line per at space.
multiple dynamically created jquery slider galleries on one page
multiple dynamically created jquery slider galleries on one page
I am trying to create a page where the user can add jquery slider
galleries to a page on the click of a button.
I have nearly got it working but am having problems with the rotation of
the images on the additional sliders when there are more than one.
I have created a jsfiddle to demonstrate http://jsfiddle.net/UUKP4/26/
the additional sliders only loop round once and then stop
any help greatly appreciated.
code for fiddle
css:
#slideshow {
position:relative;
height:350px;
}
#slideshow IMG {
position:absolute;
top:0;
left:0;
z-index:8;
opacity:0.0;
}
#slideshow IMG.active {
z-index:10;
opacity:1.0;
}
#slideshow IMG.last-active {
z-index:9;
}
jscript
var i;
var topplus=50;
function buildslider(i, id, content) {
id = id + i;
var newdiv = document.createElement('div');
newdiv.setAttribute('id', id);
newdiv.style.position = "absolute";
newdiv.style.top = +topplus + "px";
newdiv.style.left = +topplus + "px";
newdiv.style.display = 'inline-block';
newdiv.style.width = '320px';
newdiv.style.height = '270px';
newdiv.innerHTML = content;
document.getElementById("content").appendChild(newdiv);
topplus=topplus+150;
function slideSwitch() {
var $active = $('#' + id + ' #slide_image.active');
if ($active.length === 0) $active = $('#' + id + '
#slide_image:last');
var $next = $active.next().length ? $active.next() : $('#' +
id + ' #slide_image:first');
$active.addClass('last-active');
$next.css({
opacity: 0.0
})
.addClass('active')
.animate({
opacity: 1.0
}, 1000, function () {
$active.removeClass('active last-active');
});
}
$(function () {
setInterval(slideSwitch, 3000);
});
i++;
}
function addSlider() {
buildslider('i', 'draggable', '<div id="slideshow"><img
id="slide_image"
src="http://jonraasch.com/img/slideshow/mini-golf-ball.jpg"
class="active" /><img id="slide_image"
src="http://jonraasch.com/img/slideshow/jon-raasch.jpg" /><img
id="slide_image"
src="http://jonraasch.com/img/slideshow/ear-cleaning.jpg"
/></div>');
}
HTML
<input type='button' value='add slider' id='addSlider'
onclick='addSlider();'>
I am trying to create a page where the user can add jquery slider
galleries to a page on the click of a button.
I have nearly got it working but am having problems with the rotation of
the images on the additional sliders when there are more than one.
I have created a jsfiddle to demonstrate http://jsfiddle.net/UUKP4/26/
the additional sliders only loop round once and then stop
any help greatly appreciated.
code for fiddle
css:
#slideshow {
position:relative;
height:350px;
}
#slideshow IMG {
position:absolute;
top:0;
left:0;
z-index:8;
opacity:0.0;
}
#slideshow IMG.active {
z-index:10;
opacity:1.0;
}
#slideshow IMG.last-active {
z-index:9;
}
jscript
var i;
var topplus=50;
function buildslider(i, id, content) {
id = id + i;
var newdiv = document.createElement('div');
newdiv.setAttribute('id', id);
newdiv.style.position = "absolute";
newdiv.style.top = +topplus + "px";
newdiv.style.left = +topplus + "px";
newdiv.style.display = 'inline-block';
newdiv.style.width = '320px';
newdiv.style.height = '270px';
newdiv.innerHTML = content;
document.getElementById("content").appendChild(newdiv);
topplus=topplus+150;
function slideSwitch() {
var $active = $('#' + id + ' #slide_image.active');
if ($active.length === 0) $active = $('#' + id + '
#slide_image:last');
var $next = $active.next().length ? $active.next() : $('#' +
id + ' #slide_image:first');
$active.addClass('last-active');
$next.css({
opacity: 0.0
})
.addClass('active')
.animate({
opacity: 1.0
}, 1000, function () {
$active.removeClass('active last-active');
});
}
$(function () {
setInterval(slideSwitch, 3000);
});
i++;
}
function addSlider() {
buildslider('i', 'draggable', '<div id="slideshow"><img
id="slide_image"
src="http://jonraasch.com/img/slideshow/mini-golf-ball.jpg"
class="active" /><img id="slide_image"
src="http://jonraasch.com/img/slideshow/jon-raasch.jpg" /><img
id="slide_image"
src="http://jonraasch.com/img/slideshow/ear-cleaning.jpg"
/></div>');
}
HTML
<input type='button' value='add slider' id='addSlider'
onclick='addSlider();'>
Rails 3.2. Routing helper generates unvalid links
Rails 3.2. Routing helper generates unvalid links
In routes.rb:
scope "(:locale)", locale: /en|de/ do
get 'service' => 'service#index'
get 'service/:id' => 'service#show'
end
Then in view I use helper service_path(params[:locale], id) and get this
link /en/service.1. But i need link like this /en/service/1.
Check the routing via rake routes:
service GET (/:locale)/service(.:format) service#index (locale=>/en|ru/}
GET (/:locale)/service/:id(.:format) service#show
{:locale=>/en|ru/}
How to get normal links like /en/service/1, what I'm doing wrong?
In routes.rb:
scope "(:locale)", locale: /en|de/ do
get 'service' => 'service#index'
get 'service/:id' => 'service#show'
end
Then in view I use helper service_path(params[:locale], id) and get this
link /en/service.1. But i need link like this /en/service/1.
Check the routing via rake routes:
service GET (/:locale)/service(.:format) service#index (locale=>/en|ru/}
GET (/:locale)/service/:id(.:format) service#show
{:locale=>/en|ru/}
How to get normal links like /en/service/1, what I'm doing wrong?
Sunday, 25 August 2013
Working on a Sony Vaio PCG-2J3L won't boot, and no display, any ideas?
Working on a Sony Vaio PCG-2J3L won't boot, and no display, any ideas?
my friend asked me to look at a Vaio PCG-2J3L VISTA HOME PREMIUM, WHICH
WON'T BOOT, AND THE DISPLAY SHUTS OFF AFTER TWO SECONDS, I HAVE DETERMINED
THAT THE MOUSE, AND KEYBOARD WORK, BUT AS SOON AS THE BIOS PAGE, OR BOOT
ORDER PAGE IS DISPLAYED, (AFTER HITTING THE APPROPRIATE KEYS) THE SCREEN
GOES BLANK (BLACK) THE HDD LIGHT BLINKS, AND THE WIRELESS LIGHT LIGHTS UP,
THEN THE WHOLE PROCESS STARTS OVER AGAIN, I HAVE RESEATED THE RAM TWICE,
DETERMINED THE DATE AND TIME ARE CORRECT, (SO IT'S NOT THE MB BATTERY) AND
TRIED LOADING A BOOTABLE "VISTA HOME PREMIUM " OPERATING SYSTEM DISK. ALL
TO NO AVAIL. I'M ALMOST CERTAIN THE MACHINE IS INCAPABLE OF BOOTING FROM
THE "D:" DRIVE, AND I CAN'T SEE THE BIOS LONG ENOUGH TO MAKE THE NECESSARY
CHANGES. DOES ANYBODY HAVE ANY IDEAS ON WHAT I CAN TRY NEXT? THANKS,
RICHARD.
my friend asked me to look at a Vaio PCG-2J3L VISTA HOME PREMIUM, WHICH
WON'T BOOT, AND THE DISPLAY SHUTS OFF AFTER TWO SECONDS, I HAVE DETERMINED
THAT THE MOUSE, AND KEYBOARD WORK, BUT AS SOON AS THE BIOS PAGE, OR BOOT
ORDER PAGE IS DISPLAYED, (AFTER HITTING THE APPROPRIATE KEYS) THE SCREEN
GOES BLANK (BLACK) THE HDD LIGHT BLINKS, AND THE WIRELESS LIGHT LIGHTS UP,
THEN THE WHOLE PROCESS STARTS OVER AGAIN, I HAVE RESEATED THE RAM TWICE,
DETERMINED THE DATE AND TIME ARE CORRECT, (SO IT'S NOT THE MB BATTERY) AND
TRIED LOADING A BOOTABLE "VISTA HOME PREMIUM " OPERATING SYSTEM DISK. ALL
TO NO AVAIL. I'M ALMOST CERTAIN THE MACHINE IS INCAPABLE OF BOOTING FROM
THE "D:" DRIVE, AND I CAN'T SEE THE BIOS LONG ENOUGH TO MAKE THE NECESSARY
CHANGES. DOES ANYBODY HAVE ANY IDEAS ON WHAT I CAN TRY NEXT? THANKS,
RICHARD.
Unable to right-align view using contraints
Unable to right-align view using contraints
I have a tableview that uses a custom UITableViewCell. The cell contains a
UILabel that needs to be right-aligned in the cell.
This is an iPad app. I've designed the custom cell to fit in portrait
orientation by default (768 width). The issue is when the app rotates to
landscape orientation that the UILabel does not stay on the right side.
I've even tested to ensure that the cell itself is stretching correctly to
the width of the landscape orientation.
No matter what I do it seems that it wants to align relative to the left
side only. In the constraints in IB I select "Trailing Space to Superview"
but it doesn't seem to do anything. IB automatically sets Horizontal Space
(651) as offset from the left side. I am unable to delete this constraint.
Is this really that difficult to do or I am just missing something really
obvious?
I have a tableview that uses a custom UITableViewCell. The cell contains a
UILabel that needs to be right-aligned in the cell.
This is an iPad app. I've designed the custom cell to fit in portrait
orientation by default (768 width). The issue is when the app rotates to
landscape orientation that the UILabel does not stay on the right side.
I've even tested to ensure that the cell itself is stretching correctly to
the width of the landscape orientation.
No matter what I do it seems that it wants to align relative to the left
side only. In the constraints in IB I select "Trailing Space to Superview"
but it doesn't seem to do anything. IB automatically sets Horizontal Space
(651) as offset from the left side. I am unable to delete this constraint.
Is this really that difficult to do or I am just missing something really
obvious?
Disassembly in Visual Studio 2012 Ultimate
Disassembly in Visual Studio 2012 Ultimate
I'd like to check the generated assembly code of the compiler optimized
parts (release) of my C++ code in Visual Studio 2012 Ultimate. There are
articles on the web about a Disassembly window, but I can't access it.
Any advice would be appreciated.
I'd like to check the generated assembly code of the compiler optimized
parts (release) of my C++ code in Visual Studio 2012 Ultimate. There are
articles on the web about a Disassembly window, but I can't access it.
Any advice would be appreciated.
httpd unpacking error on installing subversion and mod_dav_svn
httpd unpacking error on installing subversion and mod_dav_svn
I am unable to make subversion working on centOS 6.4. I am getting httpd
unpacking error on installing mod_dav_svn. I am getting the following
error.
Running Transaction
Installing : subversion-1.6.11-9.el6_4.x86_64
1/3
Installing : httpd-2.2.15-29.el6.centos.x86_64
2/3
Error unpacking rpm package httpd-2.2.15-29.el6.centos.x86_64
warning: /etc/httpd/conf/httpd.conf created as
/etc/httpd/conf/httpd.conf.rpmnew
warning: /etc/httpd/conf/magic created as /etc/httpd/conf/magic.rpmnew
error: unpacking of archive failed on file /etc/httpd/logs: cpio: rename
Installing : mod_dav_svn-1.6.11-9.el6_4.x86_64
3/3
Verifying : mod_dav_svn-1.6.11-9.el6_4.x86_64
1/3
Verifying : subversion-1.6.11-9.el6_4.x86_64
2/3
Verifying : httpd-2.2.15-29.el6.centos.x86_64
3/3
Installed:
mod_dav_svn.x86_64 0:1.6.11-9.el6_4 subversion.x86_64 0:1.6.11-9.el6_4
Failed:
httpd.x86_64 0:2.2.15-29.el6.centos
Any help or suggestions will be appreciable. Thanks
I am unable to make subversion working on centOS 6.4. I am getting httpd
unpacking error on installing mod_dav_svn. I am getting the following
error.
Running Transaction
Installing : subversion-1.6.11-9.el6_4.x86_64
1/3
Installing : httpd-2.2.15-29.el6.centos.x86_64
2/3
Error unpacking rpm package httpd-2.2.15-29.el6.centos.x86_64
warning: /etc/httpd/conf/httpd.conf created as
/etc/httpd/conf/httpd.conf.rpmnew
warning: /etc/httpd/conf/magic created as /etc/httpd/conf/magic.rpmnew
error: unpacking of archive failed on file /etc/httpd/logs: cpio: rename
Installing : mod_dav_svn-1.6.11-9.el6_4.x86_64
3/3
Verifying : mod_dav_svn-1.6.11-9.el6_4.x86_64
1/3
Verifying : subversion-1.6.11-9.el6_4.x86_64
2/3
Verifying : httpd-2.2.15-29.el6.centos.x86_64
3/3
Installed:
mod_dav_svn.x86_64 0:1.6.11-9.el6_4 subversion.x86_64 0:1.6.11-9.el6_4
Failed:
httpd.x86_64 0:2.2.15-29.el6.centos
Any help or suggestions will be appreciable. Thanks
Saturday, 24 August 2013
Check neighbour pixels Matlab
Check neighbour pixels Matlab
I have a vector A of size 640x1. where the value of each cell A(i,1)
varies from row to row, for example A(1,1) =[], while A(2,1)=[1] and
A(3,1)=[1,2,3]. There is another matrix B of size 480x640, where the
row_index (i) of vector A corresponds to the col_index of matrix B. While
the cell value of each row in vector A corresponds to the row_index in
matrix B. For example, A(2,1)=[1] this means col_2 row_1 in matrix B,
while A(3,1)=[1,2,3] means col_3 rows 1,2&3 in matrix B. What I'm trying
to do is to for each non-zero value in matrix B that are referenced from
vector A, I want to check whether there are at least 4 other neighbours
that are also referenced from vector A. The number neighbours of each
value are determined by a value N. For example, this is a part of matrix B
where all the zeros"just to clarify, as in fact they may be non-zeros" are
the neighbours of pixel X when N=3:
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 X 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
As shown, because N=3, all these zeros are pixel X's neighbors. So if more
than 4 neighbor pixels are found in vector A then do something e.g G=1 if
not then G=0; So if anyone could please advise. And please let me know if
any more clarification is needed.
I have a vector A of size 640x1. where the value of each cell A(i,1)
varies from row to row, for example A(1,1) =[], while A(2,1)=[1] and
A(3,1)=[1,2,3]. There is another matrix B of size 480x640, where the
row_index (i) of vector A corresponds to the col_index of matrix B. While
the cell value of each row in vector A corresponds to the row_index in
matrix B. For example, A(2,1)=[1] this means col_2 row_1 in matrix B,
while A(3,1)=[1,2,3] means col_3 rows 1,2&3 in matrix B. What I'm trying
to do is to for each non-zero value in matrix B that are referenced from
vector A, I want to check whether there are at least 4 other neighbours
that are also referenced from vector A. The number neighbours of each
value are determined by a value N. For example, this is a part of matrix B
where all the zeros"just to clarify, as in fact they may be non-zeros" are
the neighbours of pixel X when N=3:
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 X 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
As shown, because N=3, all these zeros are pixel X's neighbors. So if more
than 4 neighbor pixels are found in vector A then do something e.g G=1 if
not then G=0; So if anyone could please advise. And please let me know if
any more clarification is needed.
Get JSON data from a file using (JavaScript)
Get JSON data from a file using (JavaScript)
I need to know how can I get json data using JavaScript without using
Jquery. I just want to know how to get data only using JavaScript.
My Json file.
{"JsonProjectIDResult":[{"_capacity":15,"_description":"Meeting
Room","_dev_default_view":3,"_deviceID":1,"_deviceName":"MobiTech","_deviceTypeID":1,"_projectID":1,"_roomID":2,"_roomName":"Room2","_room_admin_mail":null}]}
My home.html file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Get JSON Using JavaScript</title>
</head>
<body>
<h1>My Home Page</h1>
<div id="results">
<!-- Display Jason Data -->
</div>
<script>
var resultDiv = document.getElementById("results");
var newsURL = "http://localhost:81/testjs/data.json";
</script>
</body>
</html>
I need to know how can I get json data using JavaScript without using
Jquery. I just want to know how to get data only using JavaScript.
My Json file.
{"JsonProjectIDResult":[{"_capacity":15,"_description":"Meeting
Room","_dev_default_view":3,"_deviceID":1,"_deviceName":"MobiTech","_deviceTypeID":1,"_projectID":1,"_roomID":2,"_roomName":"Room2","_room_admin_mail":null}]}
My home.html file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Get JSON Using JavaScript</title>
</head>
<body>
<h1>My Home Page</h1>
<div id="results">
<!-- Display Jason Data -->
</div>
<script>
var resultDiv = document.getElementById("results");
var newsURL = "http://localhost:81/testjs/data.json";
</script>
</body>
</html>
how to define tokenizing rules
how to define tokenizing rules
I want to tokenize strings like:
'my name.is(johnny ,knoxville):'
into:
['my', 'name', '.', 'is', '(johnny ,knoxville)', ':']
As you can notice, whitespace separates tokens, non-alphanumeric chars are
not grouped with alphanumeric chars, and there's another exception:
Everything enclosed in parenthesis is taken as a whole token.
I'm not sure if I should use python RE, some python module I don't know
about or an external lib like pyparsing
Any ideas?
I want to tokenize strings like:
'my name.is(johnny ,knoxville):'
into:
['my', 'name', '.', 'is', '(johnny ,knoxville)', ':']
As you can notice, whitespace separates tokens, non-alphanumeric chars are
not grouped with alphanumeric chars, and there's another exception:
Everything enclosed in parenthesis is taken as a whole token.
I'm not sure if I should use python RE, some python module I don't know
about or an external lib like pyparsing
Any ideas?
I can't retrieve data from a JSON file
I can't retrieve data from a JSON file
I've created a website in wordpress and I'm using wordpress json API to
retrieve data for a web-app I'm developing. The json API is working fine:
http://danielvivancos.com/edu/wordpress/?json=1 I get my Json file. But
now I'm trying to print it in my html page with getjson jquery method.
First I'm just just trying to display in a div some information from the
json file to check that it is working but i don't know why it's not. Here
you can check my script:
$(document).ready(function (){
$("#btn382").click(function(){
$.ajaxSetup({ cache: false });
$.getJSON("http://danielvivancos.com/edu/wordpress/?json=1&count=1",
function(data){
var html = [];
$.each(data.posts.author, function(index, author){
html.push("id : ", author.id, ", ",
"slug : ", author.slug, ", ",
"name : ", author.name, "<br>");
});
$("#div381").html(html.join('')).css("background-color", "orange");
}).error(function(jqXHR, textStatus, errorThrown){ /* assign handler */
/* alert(jqXHR.responseText) */
alert("error occurred!");
});
});
});
And of course I have the #div381 created. I don't know what I'm doing
wrong but I'm really stuck. Any help would be appreciated!!
Edit: The console error is: Cannot read property 'length' of undefined.
I've created a website in wordpress and I'm using wordpress json API to
retrieve data for a web-app I'm developing. The json API is working fine:
http://danielvivancos.com/edu/wordpress/?json=1 I get my Json file. But
now I'm trying to print it in my html page with getjson jquery method.
First I'm just just trying to display in a div some information from the
json file to check that it is working but i don't know why it's not. Here
you can check my script:
$(document).ready(function (){
$("#btn382").click(function(){
$.ajaxSetup({ cache: false });
$.getJSON("http://danielvivancos.com/edu/wordpress/?json=1&count=1",
function(data){
var html = [];
$.each(data.posts.author, function(index, author){
html.push("id : ", author.id, ", ",
"slug : ", author.slug, ", ",
"name : ", author.name, "<br>");
});
$("#div381").html(html.join('')).css("background-color", "orange");
}).error(function(jqXHR, textStatus, errorThrown){ /* assign handler */
/* alert(jqXHR.responseText) */
alert("error occurred!");
});
});
});
And of course I have the #div381 created. I don't know what I'm doing
wrong but I'm really stuck. Any help would be appreciated!!
Edit: The console error is: Cannot read property 'length' of undefined.
Checking JavaScript object for null subtelty
Checking JavaScript object for null subtelty
Unless you are really sure, please don't come and tell me this question
has already been asked and answered.
OK, so I believe I have found cases where I need to check for both
undefined and null for a javascript object as follows:
if (x !== undefined && x != null && x.length > 0) {...}
However, in a recent upgrade of JetBrains tools, it tells me that this is
sufficient
if (x != undefined && x.length > 0) {...}
My question is, I'm just wanting to insure that a string "x" has a length
of non-zero and is not undefined or null (with the least amount tests).
Thoughts?
Unless you are really sure, please don't come and tell me this question
has already been asked and answered.
OK, so I believe I have found cases where I need to check for both
undefined and null for a javascript object as follows:
if (x !== undefined && x != null && x.length > 0) {...}
However, in a recent upgrade of JetBrains tools, it tells me that this is
sufficient
if (x != undefined && x.length > 0) {...}
My question is, I'm just wanting to insure that a string "x" has a length
of non-zero and is not undefined or null (with the least amount tests).
Thoughts?
Scrollviewer with expander not working
Scrollviewer with expander not working
The scroll viewer was working well until I added an expander control with
it and now for the life o me cannot get it working. Have removed
stackpanel and as from what I have read this assigns an infinate height.
Am still getting to grips with WPF, so any assiatance would be greatly
appreciated.
Nested Child Control:
<UserControl x:Class="BloodHound.Controls.ucDocumentEmail"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Name="grdSearchEmail" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Height="Auto" Width="Auto" Margin="15,15,15,15" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" ></ColumnDefinition>
<ColumnDefinition Width="*" ></ColumnDefinition>
<ColumnDefinition Width="Auto" ></ColumnDefinition>
<ColumnDefinition Width="*" ></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="0" >
<Image Source="/Images/email.png" />
<Label FontWeight="Bold" >EMail</Label>
</StackPanel>
<Label Grid.Column="1" Grid.Row="0" >Created Date</Label>
<TextBox Name="txtDateCreated" Grid.Column="2" Grid.Row="0"
Grid.ColumnSpan="2" ></TextBox>
<Label Grid.Column="0" Grid.Row="1" >From</Label>
<TextBox Name="txtFrom" Grid.Column="1" Grid.Row="1" ></TextBox>
<Label Grid.Column="2" Grid.Row="1" >To</Label>
<TextBox Name="txtTo" Grid.Column="3" Grid.Row="1" ></TextBox>
<Label Grid.Column="0" Grid.Row="2" >Subject</Label>
<TextBox Name="txtSubject" Grid.Column="1" Grid.Row="2"
Grid.ColumnSpan="3" ></TextBox>
<Expander Header="Email Details"
Width="Auto" Height="Auto" ExpandDirection="Down"
HorizontalAlignment="Stretch" Grid.Row="3"
Grid.Column="0" Grid.ColumnSpan="10"
VerticalAlignment="Top" MaxHeight="300" >
<Border Background="LightGray" Grid.Column="0" Grid.Row="0"
BorderBrush="Black"
BorderThickness="1" Height="Auto" HorizontalAlignment="Stretch"
CornerRadius="15"
Padding="5" VerticalAlignment="Top" >
<Grid Name="grdTrans" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="10"
Height="Auto" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" ></ColumnDefinition>
<ColumnDefinition Width="*" ></ColumnDefinition>
<ColumnDefinition Width="*" ></ColumnDefinition>
<ColumnDefinition Width="*" ></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Grid.Row="0" >CC</Label>
<TextBox Name="txtCC" Grid.Column="1" Grid.Row="0"
Grid.ColumnSpan="3" ></TextBox>
<Label Grid.Column="0" Grid.Row="1"
>Importance</Label>
<TextBox Name="txtImportance" Grid.Column="1"
Grid.Row="1" ></TextBox>
<Label Grid.Column="2" Grid.Row="1" >Folder</Label>
<TextBox Name="txtFolder" Grid.Column="3"
Grid.Row="1" ></TextBox>
<Label Grid.Column="0" Grid.Row="2" >Received
By</Label>
<TextBox Name="txtReceivedBy" Grid.Column="1"
Grid.Row="2" Grid.ColumnSpan="3" ></TextBox>
<Label Grid.Column="0" Grid.Row="4" >Body</Label>
<TextBox Grid.Column="1" Grid.ColumnSpan="3"
MaxHeight="150"
ScrollViewer.VerticalScrollBarVisibility="Auto"
TextWrapping="Wrap" AcceptsReturn="True" Grid.Row="4"
Name="txtBody" Height="Auto" Width="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" ></TextBox>
<Label Grid.Column="0" Grid.Row="5"
>Attachments</Label>
<ListView Name="lvwAttach" Grid.Column="1"
Grid.Row="5" Grid.ColumnSpan="4" ></ListView>
</Grid>
</Border>
</Expander>
</Grid>
</UserControl>
Then the Parent Control:
<UserControl x:Class="BloodHound.Controls.ucDocumentListing"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Name="grdDocList" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="21"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" ></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0">
<Label>Search for keyword</Label>
<TextBox Name="txtSearch" Width="65" Margin="15,5,5,5"
></TextBox>
<Button x:Name="btnSearch" Margin="5,5,5,5"
Click="btnSearch_Click" ToolTip="Search
for Keyword" >
<StackPanel Orientation="Horizontal">
<Image Source="/Images/magnifier_zoom_in.png" />
<Label>Search</Label>
</StackPanel>
</Button>
<Button x:Name="btnAddNew" Margin="25,5,5,5"
Click="btnAddNew_Click" ToolTip="Add New
File/s" >
<StackPanel Orientation="Horizontal">
<Image Source="/Images/add.png" />
<Label>Add File/s</Label>
</StackPanel>
</Button>
</StackPanel>
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1"
Grid.Column="0" >
<Grid Name="grdDocs" Grid.Column="0" Grid.Row="1"
Margin="15,15,15,15" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" ></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
</ScrollViewer>
</Grid>
</UserControl>
Then am loading it into a window:
<Window x:Class="BloodHound.TestDocumentList"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="TestDocumentList" Height="300" Width="300"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<Grid Name="grdTest" Loaded="grdTest_Loaded"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" ></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
</Window>
with the Code behind:
private void grdTest_Loaded(object sender, RoutedEventArgs e)
{
Controls.ucDocumentListing ctl = new Controls.ucDocumentListing();
ctl.EntityID = 1;
ctl.EntityTypeID = 1;
ctl.LoadControl();
RowDefinition newRow = new RowDefinition();
newRow.Height = new GridLength(0, GridUnitType.Auto);
grdTest.RowDefinitions.Insert(grdTest.RowDefinitions.Count - 1, newRow);
Controls.ucSearchEmail em = new Controls.ucSearchEmail();
int rowIndex = grdTest.RowDefinitions.Count - 2;
Grid.SetRow(ctl, rowIndex);
Grid.SetColumn(ctl, 1);
Grid.SetRowSpan(ctl, 1);
Grid.SetColumnSpan(ctl, 1); // Change this if you want.
grdTest.Children.Add(ctl);
}
The scroll viewer was working well until I added an expander control with
it and now for the life o me cannot get it working. Have removed
stackpanel and as from what I have read this assigns an infinate height.
Am still getting to grips with WPF, so any assiatance would be greatly
appreciated.
Nested Child Control:
<UserControl x:Class="BloodHound.Controls.ucDocumentEmail"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Name="grdSearchEmail" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Height="Auto" Width="Auto" Margin="15,15,15,15" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" ></ColumnDefinition>
<ColumnDefinition Width="*" ></ColumnDefinition>
<ColumnDefinition Width="Auto" ></ColumnDefinition>
<ColumnDefinition Width="*" ></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="0" >
<Image Source="/Images/email.png" />
<Label FontWeight="Bold" >EMail</Label>
</StackPanel>
<Label Grid.Column="1" Grid.Row="0" >Created Date</Label>
<TextBox Name="txtDateCreated" Grid.Column="2" Grid.Row="0"
Grid.ColumnSpan="2" ></TextBox>
<Label Grid.Column="0" Grid.Row="1" >From</Label>
<TextBox Name="txtFrom" Grid.Column="1" Grid.Row="1" ></TextBox>
<Label Grid.Column="2" Grid.Row="1" >To</Label>
<TextBox Name="txtTo" Grid.Column="3" Grid.Row="1" ></TextBox>
<Label Grid.Column="0" Grid.Row="2" >Subject</Label>
<TextBox Name="txtSubject" Grid.Column="1" Grid.Row="2"
Grid.ColumnSpan="3" ></TextBox>
<Expander Header="Email Details"
Width="Auto" Height="Auto" ExpandDirection="Down"
HorizontalAlignment="Stretch" Grid.Row="3"
Grid.Column="0" Grid.ColumnSpan="10"
VerticalAlignment="Top" MaxHeight="300" >
<Border Background="LightGray" Grid.Column="0" Grid.Row="0"
BorderBrush="Black"
BorderThickness="1" Height="Auto" HorizontalAlignment="Stretch"
CornerRadius="15"
Padding="5" VerticalAlignment="Top" >
<Grid Name="grdTrans" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="10"
Height="Auto" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" ></ColumnDefinition>
<ColumnDefinition Width="*" ></ColumnDefinition>
<ColumnDefinition Width="*" ></ColumnDefinition>
<ColumnDefinition Width="*" ></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Grid.Row="0" >CC</Label>
<TextBox Name="txtCC" Grid.Column="1" Grid.Row="0"
Grid.ColumnSpan="3" ></TextBox>
<Label Grid.Column="0" Grid.Row="1"
>Importance</Label>
<TextBox Name="txtImportance" Grid.Column="1"
Grid.Row="1" ></TextBox>
<Label Grid.Column="2" Grid.Row="1" >Folder</Label>
<TextBox Name="txtFolder" Grid.Column="3"
Grid.Row="1" ></TextBox>
<Label Grid.Column="0" Grid.Row="2" >Received
By</Label>
<TextBox Name="txtReceivedBy" Grid.Column="1"
Grid.Row="2" Grid.ColumnSpan="3" ></TextBox>
<Label Grid.Column="0" Grid.Row="4" >Body</Label>
<TextBox Grid.Column="1" Grid.ColumnSpan="3"
MaxHeight="150"
ScrollViewer.VerticalScrollBarVisibility="Auto"
TextWrapping="Wrap" AcceptsReturn="True" Grid.Row="4"
Name="txtBody" Height="Auto" Width="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" ></TextBox>
<Label Grid.Column="0" Grid.Row="5"
>Attachments</Label>
<ListView Name="lvwAttach" Grid.Column="1"
Grid.Row="5" Grid.ColumnSpan="4" ></ListView>
</Grid>
</Border>
</Expander>
</Grid>
</UserControl>
Then the Parent Control:
<UserControl x:Class="BloodHound.Controls.ucDocumentListing"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Name="grdDocList" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="21"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" ></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0">
<Label>Search for keyword</Label>
<TextBox Name="txtSearch" Width="65" Margin="15,5,5,5"
></TextBox>
<Button x:Name="btnSearch" Margin="5,5,5,5"
Click="btnSearch_Click" ToolTip="Search
for Keyword" >
<StackPanel Orientation="Horizontal">
<Image Source="/Images/magnifier_zoom_in.png" />
<Label>Search</Label>
</StackPanel>
</Button>
<Button x:Name="btnAddNew" Margin="25,5,5,5"
Click="btnAddNew_Click" ToolTip="Add New
File/s" >
<StackPanel Orientation="Horizontal">
<Image Source="/Images/add.png" />
<Label>Add File/s</Label>
</StackPanel>
</Button>
</StackPanel>
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1"
Grid.Column="0" >
<Grid Name="grdDocs" Grid.Column="0" Grid.Row="1"
Margin="15,15,15,15" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" ></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
</ScrollViewer>
</Grid>
</UserControl>
Then am loading it into a window:
<Window x:Class="BloodHound.TestDocumentList"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="TestDocumentList" Height="300" Width="300"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<Grid Name="grdTest" Loaded="grdTest_Loaded"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" ></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
</Window>
with the Code behind:
private void grdTest_Loaded(object sender, RoutedEventArgs e)
{
Controls.ucDocumentListing ctl = new Controls.ucDocumentListing();
ctl.EntityID = 1;
ctl.EntityTypeID = 1;
ctl.LoadControl();
RowDefinition newRow = new RowDefinition();
newRow.Height = new GridLength(0, GridUnitType.Auto);
grdTest.RowDefinitions.Insert(grdTest.RowDefinitions.Count - 1, newRow);
Controls.ucSearchEmail em = new Controls.ucSearchEmail();
int rowIndex = grdTest.RowDefinitions.Count - 2;
Grid.SetRow(ctl, rowIndex);
Grid.SetColumn(ctl, 1);
Grid.SetRowSpan(ctl, 1);
Grid.SetColumnSpan(ctl, 1); // Change this if you want.
grdTest.Children.Add(ctl);
}
Changing color of first letter of a text through javascript
Changing color of first letter of a text through javascript
one short question , is there a way, a function or something, i can change
color of only somepart of the text like if there is a text
"(asterick)Username" i want "Asterik" to stay in red color and "Username"
in white?
one short question , is there a way, a function or something, i can change
color of only somepart of the text like if there is a text
"(asterick)Username" i want "Asterik" to stay in red color and "Username"
in white?
Windows Phone 8 app randomly crashes with error code -2147220717 (0x80040313)
Windows Phone 8 app randomly crashes with error code -2147220717 (0x80040313)
I am currently developing a stopwatch and timer app in C#/XAML for Windows
Phone 8. While using my app on my phone, I found that it randomly closed
out/crashed and that too at different points of use (i.e. I wasn't doing
the same thing each time it closed out). While debugging, I found that my
app closed out with the following error code in my output window:
"The program '[1100] TaskHost.exe' has exited with code -2147220717
(0x80040313)."
I am very confused as to why this is happening. I tried creating an
entirely new solution and moving my code over and I've still been getting
the same issue. I have tried using the app on multiple different devices,
and the same thing happens (even in the Emulator). Sometimes the app
crashes after 5 minutes of use, sometimes it crashes after 30 minutes of
use, it's very unpredictable which makes it very hard to find the root of
the problem. My app uses the XNA Framework to play an audio sound and the
Coding4Fun Toolkit for a TimeSpanPicker control, and besides that there
isn't much else that's particularly notable about my app. I have tried
removing the playing of the audio file and removing references to the XNA
Framework, and the problem persists.
Any ideas on what the problem could be?
Thanks in advance!
I am currently developing a stopwatch and timer app in C#/XAML for Windows
Phone 8. While using my app on my phone, I found that it randomly closed
out/crashed and that too at different points of use (i.e. I wasn't doing
the same thing each time it closed out). While debugging, I found that my
app closed out with the following error code in my output window:
"The program '[1100] TaskHost.exe' has exited with code -2147220717
(0x80040313)."
I am very confused as to why this is happening. I tried creating an
entirely new solution and moving my code over and I've still been getting
the same issue. I have tried using the app on multiple different devices,
and the same thing happens (even in the Emulator). Sometimes the app
crashes after 5 minutes of use, sometimes it crashes after 30 minutes of
use, it's very unpredictable which makes it very hard to find the root of
the problem. My app uses the XNA Framework to play an audio sound and the
Coding4Fun Toolkit for a TimeSpanPicker control, and besides that there
isn't much else that's particularly notable about my app. I have tried
removing the playing of the audio file and removing references to the XNA
Framework, and the problem persists.
Any ideas on what the problem could be?
Thanks in advance!
Friday, 23 August 2013
Find the equation which has 4 distinct roots
Find the equation which has 4 distinct roots
For which value of $k$ does the equation $x^4 - 4x^2 + x + k = 0 $ have
four distinct real roots?
I found this question on a standardized test, and the answer presumably
relies on a graphing calculator. Is there some method to solve this
problem without the aid of a calculator?
For which value of $k$ does the equation $x^4 - 4x^2 + x + k = 0 $ have
four distinct real roots?
I found this question on a standardized test, and the answer presumably
relies on a graphing calculator. Is there some method to solve this
problem without the aid of a calculator?
Convergence of a sequence implies the convergence of another sequence
Convergence of a sequence implies the convergence of another sequence
Let $a_n>0$, $n¡Ý 0$. Call $k$ ¡°good¡± if $k¡Ý1$ and $a_k>\frac12
a_{k-1}$. Also call 0 good. Show $\sum^{\infty}_{k=0}a_k$ converges if
$\sum_{k \ \ is\ \ good} a_k$ converges. I can only see that the sum of
the good k terms is greater than half of their previous terms' sum, how to
relate the good k terms with every term of this sequence? This is my first
semester in college and first post here, please don't downvote me like
redditors and be gentle! ;-)
-Belen
Let $a_n>0$, $n¡Ý 0$. Call $k$ ¡°good¡± if $k¡Ý1$ and $a_k>\frac12
a_{k-1}$. Also call 0 good. Show $\sum^{\infty}_{k=0}a_k$ converges if
$\sum_{k \ \ is\ \ good} a_k$ converges. I can only see that the sum of
the good k terms is greater than half of their previous terms' sum, how to
relate the good k terms with every term of this sequence? This is my first
semester in college and first post here, please don't downvote me like
redditors and be gentle! ;-)
-Belen
Simple integration of Bing Maps into WPF application page
Simple integration of Bing Maps into WPF application page
How would I go about integrating Bing Maps into a page or frame in my WPF
application? I have found a lot of resources for Bing Maps development,
but I don't need to develop with Bing Maps, just add the actual thing into
my application without hyper-linking out to the website.
Windows 8 applications do this with "contracts" with other metro apps but
I do not see a similar functionality with WPF applications.
Thank you!
How would I go about integrating Bing Maps into a page or frame in my WPF
application? I have found a lot of resources for Bing Maps development,
but I don't need to develop with Bing Maps, just add the actual thing into
my application without hyper-linking out to the website.
Windows 8 applications do this with "contracts" with other metro apps but
I do not see a similar functionality with WPF applications.
Thank you!
Can I assign the TAB key to Zen coding's Expend Abbreviation command in Microsoft Visual Studio 2010?
Can I assign the TAB key to Zen coding's Expend Abbreviation command in
Microsoft Visual Studio 2010?
I installed Zen Coding for the Microsoft Virtual Studio 2010.
Zen Coding v0.7 by Sergey Chikuyonok
Visual Studio Plugin v0.7 by Danny Su
http://visualstudiogallery.msdn.microsoft.com/924090a6-1177-4e81-96a3-e929d7193130
I would like to be able to use the TAB key in order to use Zen Coding's
Expend Abbreviation command (instead of ALT-Z) when editing HTML documents
like in Sublime Text 2.
I go to Tools/Options/Environment/Keyboard and choose
ZenCoding.ExpandAbbreviation but when I type the TAB key in the box to
Assign the key it doesn't work.
Any idea? Is it possible?
Many thanks for your time and help.
Microsoft Visual Studio 2010?
I installed Zen Coding for the Microsoft Virtual Studio 2010.
Zen Coding v0.7 by Sergey Chikuyonok
Visual Studio Plugin v0.7 by Danny Su
http://visualstudiogallery.msdn.microsoft.com/924090a6-1177-4e81-96a3-e929d7193130
I would like to be able to use the TAB key in order to use Zen Coding's
Expend Abbreviation command (instead of ALT-Z) when editing HTML documents
like in Sublime Text 2.
I go to Tools/Options/Environment/Keyboard and choose
ZenCoding.ExpandAbbreviation but when I type the TAB key in the box to
Assign the key it doesn't work.
Any idea? Is it possible?
Many thanks for your time and help.
select price having max year in another column
select price having max year in another column
I have following select result
Code Price Year
1 200 2013
1 100 2012
2 250 2011
2 275 2012
2 300 2010
But I want following something like this with one extra column which hold
price based on maximum year,
Code Price Year ExPrice
1 200 2013 200
1 100 2012 200
2 250 2011 275
2 275 2012 275
2 300 2010 275
Sorry for bad English and wrong way for asking this question.
I have following select result
Code Price Year
1 200 2013
1 100 2012
2 250 2011
2 275 2012
2 300 2010
But I want following something like this with one extra column which hold
price based on maximum year,
Code Price Year ExPrice
1 200 2013 200
1 100 2012 200
2 250 2011 275
2 275 2012 275
2 300 2010 275
Sorry for bad English and wrong way for asking this question.
How to add Event Listener for Event after Youtube video is finished playing
How to add Event Listener for Event after Youtube video is finished playing
I am trying to get an event fired once the youtube video reached its end.
The video embedding works, but nothing happens once the video ends. I
think I am missing something for the EventListener...
this is my code:
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
var video =
swfobject.embedSWF("http://www.youtube.com/v/elvOZm0d4H0?enablejsapi=1&playerapiid=ytplayer&version=3&rel=0&autoplay=1&controls=1","ytapiplayer",
"450", "250", "8", null, null, params, atts);
XXXXX.addEventListener("onStateChange", function(state){
if(state === 0){
alert("Stack Overflow rocks!");
}
});
What I do not get is, what I should listen to? Marked with "XXXXX" in the
code, what do i need to put there? I tried myytplayer, video, ytplayer,
ytapiplayer... most of them give me an error, e.g. "ytplayer can not be
found". "ytapiplayer" did not throw an error, but also nothing happens
once the video is finished playing.
I searched stack Overflow, but all the "answers" I found so far are just
naming this event listener, but do not explain what I have to put at
"XXXXX".
I am pretty new to this and any help is very welcome, thanks!
JSFIDDLE: http://jsfiddle.net/T5HBZ/
edit: edited code for controls, added jsfiddle
I am trying to get an event fired once the youtube video reached its end.
The video embedding works, but nothing happens once the video ends. I
think I am missing something for the EventListener...
this is my code:
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
var video =
swfobject.embedSWF("http://www.youtube.com/v/elvOZm0d4H0?enablejsapi=1&playerapiid=ytplayer&version=3&rel=0&autoplay=1&controls=1","ytapiplayer",
"450", "250", "8", null, null, params, atts);
XXXXX.addEventListener("onStateChange", function(state){
if(state === 0){
alert("Stack Overflow rocks!");
}
});
What I do not get is, what I should listen to? Marked with "XXXXX" in the
code, what do i need to put there? I tried myytplayer, video, ytplayer,
ytapiplayer... most of them give me an error, e.g. "ytplayer can not be
found". "ytapiplayer" did not throw an error, but also nothing happens
once the video is finished playing.
I searched stack Overflow, but all the "answers" I found so far are just
naming this event listener, but do not explain what I have to put at
"XXXXX".
I am pretty new to this and any help is very welcome, thanks!
JSFIDDLE: http://jsfiddle.net/T5HBZ/
edit: edited code for controls, added jsfiddle
Thursday, 22 August 2013
Print alphabetical navigation list from an array
Print alphabetical navigation list from an array
I have an array of items and I am trying to generate an alphabetical
navigation for them.
A|B|C|D|E|F|G|H etc...
Apple
Apricot
Carrot
Camel
Dog
So I want to list every letter of the alphabet but only link the ones that
have matching items in the array.
So far I have:
$productArr = array('Apple','Apricot','Carrot','Camel','Dog');
$previous = null;
foreach(range('A','Z') as $alpha) {
$arrayCount = count($productArr);
for ($i=0; $i < $arrayCount; $i++) {
$firstLetter = $productArr[$i];
if ($firstLetter[0] == $alpha && $firstLetter[0] != $previous){
echo '<li><a href="#'.$alpha.'">'.$alpha.'</a></li>';
$previous = $alpha;
}elseif ($firstLetter[0] != $alpha && $alpha != $previous){
echo '<li>'.$alpha.'</li>';
$previous = $alpha;
}
}
}
It works fine up until the elseif, if you comment out the elseif it prints
the list of links as expected. Just need to work out how to print the rest
of the alphabet.
Any help as to where I'm going wrong would be appreciated.
Cheers
I have an array of items and I am trying to generate an alphabetical
navigation for them.
A|B|C|D|E|F|G|H etc...
Apple
Apricot
Carrot
Camel
Dog
So I want to list every letter of the alphabet but only link the ones that
have matching items in the array.
So far I have:
$productArr = array('Apple','Apricot','Carrot','Camel','Dog');
$previous = null;
foreach(range('A','Z') as $alpha) {
$arrayCount = count($productArr);
for ($i=0; $i < $arrayCount; $i++) {
$firstLetter = $productArr[$i];
if ($firstLetter[0] == $alpha && $firstLetter[0] != $previous){
echo '<li><a href="#'.$alpha.'">'.$alpha.'</a></li>';
$previous = $alpha;
}elseif ($firstLetter[0] != $alpha && $alpha != $previous){
echo '<li>'.$alpha.'</li>';
$previous = $alpha;
}
}
}
It works fine up until the elseif, if you comment out the elseif it prints
the list of links as expected. Just need to work out how to print the rest
of the alphabet.
Any help as to where I'm going wrong would be appreciated.
Cheers
MYSQL MULTIPLE COUNT AND SUM
MYSQL MULTIPLE COUNT AND SUM
I hope this is possible in MYSQL, I am scripting with PHP.
I am trying to create multiple column on SUM of values and COUNT on table1
based on each month based with individual conditions and groupings. The
tables are already joined through the accountid. I have two tables
monthlyreport(table1) & planters(table2).
Desired Results is in table 1
MONTHLY REPORT (Table 1)
REPORTID|ACCOUNTID|COMPMONTH|SUMtoDATE|COUNTtoDATE|SUMcompDATE|COUNTcompDATE|
1 | 190 | JAN | 150 | 2 | 150 |
2 |
2 | 190 | FEB | 0 | 0 | 100 |
1 |
Planters (Table 2)
PlanterID | ACCOUNTID |PLANTER | SALARY | compDATE | toDATE |
1 | 190 | aaa | 100 | Jan-1-2013 | Jan-05-2013 |
2 | 190 | bbb | 50 | Jan-9-2013 | Jan-12-2013 |
3 | 190 | aaa | 100 | Feb-1-2013 | Mar-12-2013 |
4 | 190 | bbb | 0 | Mar-5-2013 | Mar-12-2013 |
A single query with inner join already works but if I run both I get
nothing because I can't seem to get the logic if it is possible.
This is what I have so far from stackoverflow but getting error. Wish
someone can refactor it or make it work.
SELECT *,
(
SELECT COUNT(planters.todate), SUM(planters.todate)
FROM monthlyreport
INNER JOIN planters ON monthlyreport.accountid = planters.accountid
WHERE monthlyreport.accountid = 190 AND MONTH(monthlyreport.compmonth) =
MONTH(planters.todate)
GROUP BY monthlyreport.mthreportid, month(planters.todate)
) AS count_1,
(
SELECT COUNT(planters.compdate), SUM(planters.compdate)
FROM monthlyreport
INNER JOIN planters ON monthlyreport.accountid = planters.accountid
WHERE monthlyreport.accountid = 190 AND MONTH(monthlyreport.compmonth) =
MONTH(planters.compdate)
GROUP BY monthlyreport.mthreportid, month(planters.compdate)
) AS count_2
I hope this is possible in MYSQL, I am scripting with PHP.
I am trying to create multiple column on SUM of values and COUNT on table1
based on each month based with individual conditions and groupings. The
tables are already joined through the accountid. I have two tables
monthlyreport(table1) & planters(table2).
Desired Results is in table 1
MONTHLY REPORT (Table 1)
REPORTID|ACCOUNTID|COMPMONTH|SUMtoDATE|COUNTtoDATE|SUMcompDATE|COUNTcompDATE|
1 | 190 | JAN | 150 | 2 | 150 |
2 |
2 | 190 | FEB | 0 | 0 | 100 |
1 |
Planters (Table 2)
PlanterID | ACCOUNTID |PLANTER | SALARY | compDATE | toDATE |
1 | 190 | aaa | 100 | Jan-1-2013 | Jan-05-2013 |
2 | 190 | bbb | 50 | Jan-9-2013 | Jan-12-2013 |
3 | 190 | aaa | 100 | Feb-1-2013 | Mar-12-2013 |
4 | 190 | bbb | 0 | Mar-5-2013 | Mar-12-2013 |
A single query with inner join already works but if I run both I get
nothing because I can't seem to get the logic if it is possible.
This is what I have so far from stackoverflow but getting error. Wish
someone can refactor it or make it work.
SELECT *,
(
SELECT COUNT(planters.todate), SUM(planters.todate)
FROM monthlyreport
INNER JOIN planters ON monthlyreport.accountid = planters.accountid
WHERE monthlyreport.accountid = 190 AND MONTH(monthlyreport.compmonth) =
MONTH(planters.todate)
GROUP BY monthlyreport.mthreportid, month(planters.todate)
) AS count_1,
(
SELECT COUNT(planters.compdate), SUM(planters.compdate)
FROM monthlyreport
INNER JOIN planters ON monthlyreport.accountid = planters.accountid
WHERE monthlyreport.accountid = 190 AND MONTH(monthlyreport.compmonth) =
MONTH(planters.compdate)
GROUP BY monthlyreport.mthreportid, month(planters.compdate)
) AS count_2
Script to periodically check if a class has opened
Script to periodically check if a class has opened
Would anyone be able to help me generate a script which can either
periodically generate a search using the class search function
(website:SBCC Class - Lookup Search CRN: 36444) or look-up the correct
value from the Java/SQL (Not sure what they are using, sorry) table which
data is populated from?
Then based on the results of the search, I would to know whether or not
the class is CLOSED, OPEN, or WAITLISTED based on the result, and be
notified if the class is OPEN. Or if this is not possible I would be
interested in knowing why?
Again, any response is appreciated! Thanks.
Would anyone be able to help me generate a script which can either
periodically generate a search using the class search function
(website:SBCC Class - Lookup Search CRN: 36444) or look-up the correct
value from the Java/SQL (Not sure what they are using, sorry) table which
data is populated from?
Then based on the results of the search, I would to know whether or not
the class is CLOSED, OPEN, or WAITLISTED based on the result, and be
notified if the class is OPEN. Or if this is not possible I would be
interested in knowing why?
Again, any response is appreciated! Thanks.
Phonegap (3.0.0) debugging
Phonegap (3.0.0) debugging
I have small issues with debugging Phonegap application.
What I know:
I can upload application data to build.phonegap.com, build it, download
application to phone and then use debug.build.phonegap.com to debug
application, that's fine. That works for me.
What I want:
I would like to build phonegap application locally using Phonegap 3.0.0
CLI and Android SDK ("phonegap local run android") and then use weinre
debug server at debug.build.phonegap.com. Everything works fine except I
can't see it in debug.build.phonegap.com.
Why I want it:
It takes too much time to upload data, build it, download back and run.
Even when I can use phonegap CLI ("phonegap remote build android"). I
still have to use QR code, download it and install. Much better would be
using "phonegap local run android" (which installs app to phone
automatically) and then be able to use weinre debugger on
debug.build.phonegap.com
Why it is not working?
I think this is not working because build scripts in build.phonegap.com
are adding attribute into config.xml before building app. But I do not
know how to fill it with data.
I hope this is understandable. Thanks in advance, Martin
I have small issues with debugging Phonegap application.
What I know:
I can upload application data to build.phonegap.com, build it, download
application to phone and then use debug.build.phonegap.com to debug
application, that's fine. That works for me.
What I want:
I would like to build phonegap application locally using Phonegap 3.0.0
CLI and Android SDK ("phonegap local run android") and then use weinre
debug server at debug.build.phonegap.com. Everything works fine except I
can't see it in debug.build.phonegap.com.
Why I want it:
It takes too much time to upload data, build it, download back and run.
Even when I can use phonegap CLI ("phonegap remote build android"). I
still have to use QR code, download it and install. Much better would be
using "phonegap local run android" (which installs app to phone
automatically) and then be able to use weinre debugger on
debug.build.phonegap.com
Why it is not working?
I think this is not working because build scripts in build.phonegap.com
are adding attribute into config.xml before building app. But I do not
know how to fill it with data.
I hope this is understandable. Thanks in advance, Martin
Hundreds of JBoss 5.1 System Threads WAITING forever
Hundreds of JBoss 5.1 System Threads WAITING forever
About 3 months ago we migrated to JBoss 5.1.0.GA and a few days after
testing we found several Out Of Memory Errors (OOME) in the logs of our
app.
Then I found an issue that described the cause as a bug in the JVM up to
version 7. We updated to version 7u25 and we haven't seen more OOME but
now I see an abnormally huge thread count: about 2k threads and of them
1.9k are daemon threads.
After checking in our monitoring tools I discovered that they are all
threads generated by the JBoss system thread pool (they are all named
JBoss System Threads(1)-XXXX). And here is the Stack Trace Details:
"JBoss System Threads(1)-1649" Id=130217 in WAITING on
lock=java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@a4d1d3
at sun.misc.Unsafe.park(Native Method)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at
java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
I have also checked in the tool for collection leaks and found the next
data that I think is somewhat related:
I have checked JBoss JIRA but haven't found something related.
Can someone point me what is going on?
UPDATE:
Here is the thread pool configuration in the jboss-service.xml
<!-- A Thread pool service -->
<mbean code="org.jboss.util.threadpool.BasicThreadPool"
name="jboss.system:service=ThreadPool">
<attribute name="Name">JBoss System Threads</attribute>
<attribute name="ThreadGroupName">System Threads</attribute>
<!-- How long a thread will live without any tasks in MS -->
<attribute name="KeepAliveTime">60000</attribute>
<!-- The max number of threads in the pool -->
<attribute name="MaximumPoolSize">3200</attribute>
<!-- The max number of tasks before the queue is full -->
<attribute name="MaximumQueueSize">3200</attribute>
<!-- The behavior of the pool when a task is added and the queue is
full.
abort - a RuntimeException is thrown
run - the calling thread executes the task
wait - the calling thread blocks until the queue has room
discard - the task is silently discarded without being run
discardOldest - check to see if a task is about to complete and enque
the new task if possible, else run the task in the calling thread
-->
<attribute name="BlockingMode">run</attribute>
</mbean>
About 3 months ago we migrated to JBoss 5.1.0.GA and a few days after
testing we found several Out Of Memory Errors (OOME) in the logs of our
app.
Then I found an issue that described the cause as a bug in the JVM up to
version 7. We updated to version 7u25 and we haven't seen more OOME but
now I see an abnormally huge thread count: about 2k threads and of them
1.9k are daemon threads.
After checking in our monitoring tools I discovered that they are all
threads generated by the JBoss system thread pool (they are all named
JBoss System Threads(1)-XXXX). And here is the Stack Trace Details:
"JBoss System Threads(1)-1649" Id=130217 in WAITING on
lock=java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@a4d1d3
at sun.misc.Unsafe.park(Native Method)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at
java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
I have also checked in the tool for collection leaks and found the next
data that I think is somewhat related:
I have checked JBoss JIRA but haven't found something related.
Can someone point me what is going on?
UPDATE:
Here is the thread pool configuration in the jboss-service.xml
<!-- A Thread pool service -->
<mbean code="org.jboss.util.threadpool.BasicThreadPool"
name="jboss.system:service=ThreadPool">
<attribute name="Name">JBoss System Threads</attribute>
<attribute name="ThreadGroupName">System Threads</attribute>
<!-- How long a thread will live without any tasks in MS -->
<attribute name="KeepAliveTime">60000</attribute>
<!-- The max number of threads in the pool -->
<attribute name="MaximumPoolSize">3200</attribute>
<!-- The max number of tasks before the queue is full -->
<attribute name="MaximumQueueSize">3200</attribute>
<!-- The behavior of the pool when a task is added and the queue is
full.
abort - a RuntimeException is thrown
run - the calling thread executes the task
wait - the calling thread blocks until the queue has room
discard - the task is silently discarded without being run
discardOldest - check to see if a task is about to complete and enque
the new task if possible, else run the task in the calling thread
-->
<attribute name="BlockingMode">run</attribute>
</mbean>
Some E-mails are being rejected, do I need a DNS record for my default gateway?
Some E-mails are being rejected, do I need a DNS record for my default
gateway?
I have been seeing more of these types of bounceback messages (IP address
changed for example):
mail.test.com #550-Your message was rejected by this user and was not
delivered. 550-Reason: Your IP address [1.1.1.1] appears not to be an
email server. 550-Protection provided by: MagicMail version 1.3.5
(http://magicmail.linuxmagic.com) 550-For more information, please visit
the URL:
550-http://www.linuxmagic.com/best_practices/check_dynamic_reverse_dns.html
550-or contact your ISP or mail server operator. 550
ae9e5e74-0ad7-11e3-b831-0050569008a5 ##
We have all of the DNS records set up for our e-mail servers and smtp
outbound relay. Our MX record actually points back to our Barracuda
Spam/Virus Filter in front of our Exchange server. The IP address that the
message is referring to is our gateway address from our ISP.
What do I have to set up so that these messages are delivered? Do I set up
a fake MX record pointing to the default gateway? Add another A & PTR
record pointing to the default gateway? Is there something in our internal
configuration that could be incorrect? No records are set up for the
gateway address now, just the assigned IP addresses for each of the
outbound services. All servers are Windows based. Primary e-mail server is
Exchange 2007.
gateway?
I have been seeing more of these types of bounceback messages (IP address
changed for example):
mail.test.com #550-Your message was rejected by this user and was not
delivered. 550-Reason: Your IP address [1.1.1.1] appears not to be an
email server. 550-Protection provided by: MagicMail version 1.3.5
(http://magicmail.linuxmagic.com) 550-For more information, please visit
the URL:
550-http://www.linuxmagic.com/best_practices/check_dynamic_reverse_dns.html
550-or contact your ISP or mail server operator. 550
ae9e5e74-0ad7-11e3-b831-0050569008a5 ##
We have all of the DNS records set up for our e-mail servers and smtp
outbound relay. Our MX record actually points back to our Barracuda
Spam/Virus Filter in front of our Exchange server. The IP address that the
message is referring to is our gateway address from our ISP.
What do I have to set up so that these messages are delivered? Do I set up
a fake MX record pointing to the default gateway? Add another A & PTR
record pointing to the default gateway? Is there something in our internal
configuration that could be incorrect? No records are set up for the
gateway address now, just the assigned IP addresses for each of the
outbound services. All servers are Windows based. Primary e-mail server is
Exchange 2007.
Storage Database Analysing, Input & Output table
Storage Database Analysing, Input & Output table
Storage System Database Analysing, about the Input & Output tables, what
is better, Keep the records of "IN" and "OUT" in the same table with type
"IN" or "OUT", or I have to separate it in tow tables one for "IN" and
another for "OUT" ?
Please any one have experience in this field to send me any suggestions or
references.
Storage System Database Analysing, about the Input & Output tables, what
is better, Keep the records of "IN" and "OUT" in the same table with type
"IN" or "OUT", or I have to separate it in tow tables one for "IN" and
another for "OUT" ?
Please any one have experience in this field to send me any suggestions or
references.
Wednesday, 21 August 2013
WebResource.axd not loaded when using latest Google Chrome Browser
WebResource.axd not loaded when using latest Google Chrome Browser
I'm having a strange issue:
I can't login at http://maskatel.info/login, when I try to click the login
button (the blue button that says Connexion), nothing happens at all.
So I opened up the developer tools in Chrome (f12) and saw the following
javascript error everyime I click the button: Uncaught ReferenceError:
WebForm_PostBackOptions
I then found out that this fuction should be in WebResource.axd, I then
went to the Resources tab in the developers tool and found out that this
'file' is not there and it is not loaded in the HTML source.
I tried a lot of different things without any succes and finally tried
another browser and it works fine in any other browsers. That same page
was working perfectly previously in Chrome on the same computer in the
past.
So then I tried to click the small gear in the Chrome developer tools and
went to the overrides section and changed the UserAgent to something else
and refreshed the page and it works perfectly with any other UserAgent
string. The correct UserAgent when not overriden for my browser is
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/29.0.1547.57 Safari/537.36
So right now I really don't know what to do next:
Is this issue related to the latest version of Chrome? I have not found
any information on release dates for chrome.
It could also be a DotNetNuke problem but I doubt it since nothing there
changed before and after the problem
It could aslo be asp.net related (I renamed App_Browsers to App_Browsers2
and still no luck.
Any help would be appreciated.
I'm having a strange issue:
I can't login at http://maskatel.info/login, when I try to click the login
button (the blue button that says Connexion), nothing happens at all.
So I opened up the developer tools in Chrome (f12) and saw the following
javascript error everyime I click the button: Uncaught ReferenceError:
WebForm_PostBackOptions
I then found out that this fuction should be in WebResource.axd, I then
went to the Resources tab in the developers tool and found out that this
'file' is not there and it is not loaded in the HTML source.
I tried a lot of different things without any succes and finally tried
another browser and it works fine in any other browsers. That same page
was working perfectly previously in Chrome on the same computer in the
past.
So then I tried to click the small gear in the Chrome developer tools and
went to the overrides section and changed the UserAgent to something else
and refreshed the page and it works perfectly with any other UserAgent
string. The correct UserAgent when not overriden for my browser is
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/29.0.1547.57 Safari/537.36
So right now I really don't know what to do next:
Is this issue related to the latest version of Chrome? I have not found
any information on release dates for chrome.
It could also be a DotNetNuke problem but I doubt it since nothing there
changed before and after the problem
It could aslo be asp.net related (I renamed App_Browsers to App_Browsers2
and still no luck.
Any help would be appreciated.
XEN Hypervisor migration
XEN Hypervisor migration
I know that there is no Type 2 hypervisor solution to run on an existing
OS, what I'm wondering is, is there a server or a way to spin up and image
localy on some sort of work station for devalopement then Migrate it over
to an Xen server?
Any information on this would be gratly appriciated.
Regards Tea
I know that there is no Type 2 hypervisor solution to run on an existing
OS, what I'm wondering is, is there a server or a way to spin up and image
localy on some sort of work station for devalopement then Migrate it over
to an Xen server?
Any information on this would be gratly appriciated.
Regards Tea
glDrawArrays() not working on Mac OS X
glDrawArrays() not working on Mac OS X
I am practicing the usage of VBOs in OpenGL with Java and LWJGL (using
this tutorial, and basically copying it's code:
http://www.arcsynthesis.org/gltut/index.html) and right now something
really weird is happening.
I have a window set up and this is my render() function, called inside the
main loop:
public void render() {
FloatBuffer buffer = BufferUtils.createFloatBuffer(3 * 3);
buffer.put(-1);
buffer.put(-1);
buffer.put(0);
buffer.put(0);
buffer.put(1);
buffer.put(0);
buffer.put(1);
buffer.put(-1);
buffer.put(0);
buffer.flip();
int vbo = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, false, Vertex.SIZE * 4, 0);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(0);
}
As you can see, it's very simple code which should draw a triangle. But
what I get on a Mac OS X Mountain Lion laptop, running Intel HD 4000
graphics is this:
And what I get on Windows 7, running AMD HD 6850 graphics is this:
Why is that? I really see no reason for this to happen, both of the video
cards support OpenGL 2.0, which is what I'm using, right?
I am practicing the usage of VBOs in OpenGL with Java and LWJGL (using
this tutorial, and basically copying it's code:
http://www.arcsynthesis.org/gltut/index.html) and right now something
really weird is happening.
I have a window set up and this is my render() function, called inside the
main loop:
public void render() {
FloatBuffer buffer = BufferUtils.createFloatBuffer(3 * 3);
buffer.put(-1);
buffer.put(-1);
buffer.put(0);
buffer.put(0);
buffer.put(1);
buffer.put(0);
buffer.put(1);
buffer.put(-1);
buffer.put(0);
buffer.flip();
int vbo = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, false, Vertex.SIZE * 4, 0);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(0);
}
As you can see, it's very simple code which should draw a triangle. But
what I get on a Mac OS X Mountain Lion laptop, running Intel HD 4000
graphics is this:
And what I get on Windows 7, running AMD HD 6850 graphics is this:
Why is that? I really see no reason for this to happen, both of the video
cards support OpenGL 2.0, which is what I'm using, right?
Setting up CredSSP properly for powershell multi-hop issue
Setting up CredSSP properly for powershell multi-hop issue
I've encountering the double-hop issue with a script I'm writing. Issue
right now is that when I get to New-PSSession on the computer remoting in.
I get the following error:
Image Link if its too hard to read
Here's the code that runs on the original server:
$password = ConvertTo-SecureString "password" -AsPlainText -Force
$cred= New-Object System.Management.Automation.PSCredential
("domain\admin", $CApassword)
$sesh = new-pssession -computername "MSSCA" -credential $CAcred
-Authentication CredSSP
This $sesh variable comes back null and throws the error above.
Server executing powershell script/remoting is set to delegate fresh
credentials to mssca, and likewise mssca is set to receive.
Any ideas how I can fix this?
I've encountering the double-hop issue with a script I'm writing. Issue
right now is that when I get to New-PSSession on the computer remoting in.
I get the following error:
Image Link if its too hard to read
Here's the code that runs on the original server:
$password = ConvertTo-SecureString "password" -AsPlainText -Force
$cred= New-Object System.Management.Automation.PSCredential
("domain\admin", $CApassword)
$sesh = new-pssession -computername "MSSCA" -credential $CAcred
-Authentication CredSSP
This $sesh variable comes back null and throws the error above.
Server executing powershell script/remoting is set to delegate fresh
credentials to mssca, and likewise mssca is set to receive.
Any ideas how I can fix this?
Node.js returning result from MySQL query
Node.js returning result from MySQL query
I have the following function that gets a hexcode from the database
function getColour(username, roomCount)
{
connection.query('SELECT hexcode FROM colours WHERE precedence = ?',
[roomCount], function(err, result)
{
if (err) throw err;
return result[0].hexcode;
});
}
My problem is that I am returning the result in the callback function but
the getColour function doesn't return anything. I want the getColour
function to return the value of result[0].hexcode.
At the moment when I called getColour it doesn't return anything
I have the following function that gets a hexcode from the database
function getColour(username, roomCount)
{
connection.query('SELECT hexcode FROM colours WHERE precedence = ?',
[roomCount], function(err, result)
{
if (err) throw err;
return result[0].hexcode;
});
}
My problem is that I am returning the result in the callback function but
the getColour function doesn't return anything. I want the getColour
function to return the value of result[0].hexcode.
At the moment when I called getColour it doesn't return anything
Winforms TreeView Serialization which includes Node Tag-attribute objects
Winforms TreeView Serialization which includes Node Tag-attribute objects
How can I (binary) serialize a "WinForm Treeview" into a file, so that
also objects, which are assigned to the "Node-Tag-Attribute" are also
saved. I need serialization and deserialization (into the treeview again).
I have tried the following solution: Saving content of a treeview to a
file and load it later, but after deserialization all tag attributes,
which consists of objects original treeview, are now = null.
How can I (binary) serialize a "WinForm Treeview" into a file, so that
also objects, which are assigned to the "Node-Tag-Attribute" are also
saved. I need serialization and deserialization (into the treeview again).
I have tried the following solution: Saving content of a treeview to a
file and load it later, but after deserialization all tag attributes,
which consists of objects original treeview, are now = null.
rails ,paginate, sort and more than one table
rails ,paginate, sort and more than one table
I'm new to rails,i want to know how to paginate and sort by a particular
column. I can do this within one table,but when there are more than one
,like query between three or more tables,and the sorted column not in the
main table,i tried many times but failed ,and i also searched the web ,but
also in vain. now I need your help...help please!
while paginate i'm using this `# encoding: utf-8 module Pagination class
Paginator attr_reader :item_count, :per_page, :page, :page_param
def initialize(*args)
if args.first.is_a?(ActionController::Base)
args.shift
ActiveSupport::Deprecation.warn "Paginator no longer takes a
controller instance as the first argument. Remove it from #new
arguments."
end
item_count, per_page, page, page_param = *args
@item_count = item_count
@per_page = per_page
page = (page || 1).to_i
if page < 1
page = 1
end
@page = page
@page_param = page_param || :page
end
def offset
(page - 1) * per_page
end
def first_page
if item_count > 0
1
end
end
def previous_page
if page > 1
page - 1
end
end
def next_page
if last_item < item_count
page + 1
end
end
def last_page
if item_count > 0
(item_count - 1) / per_page + 1
end
end
def first_item
item_count == 0 ? 0 : (offset + 1)
end
def last_item
l = first_item + per_page - 1
l > item_count ? item_count : l
end
def linked_pages
pages = []
if item_count > 0
pages += [first_page, page, last_page]
pages += ((page-2)..(page+2)).to_a.select {|p| p > first_page && p <
last_page}
end
pages = pages.compact.uniq.sort
if pages.size > 1
pages
else
[]
end
end
def items_per_page
ActiveSupport::Deprecation.warn "Paginator#items_per_page will be
removed. Use #per_page instead."
per_page
end
def current
ActiveSupport::Deprecation.warn "Paginator#current will be removed.
Use .offset instead of .current.offset."
self
end
end
# Paginates the given scope or model. Returns a Paginator instance and
# the collection of objects for the current page.
#
# Options:
# :parameter name of the page parameter
#
# Examples:
# @user_pages, @users = paginate User.where(:status => 1)
#
def paginate(scope, options={})
options = options.dup
finder_options = options.extract!(
:conditions,
:order,
:joins,
:include,
:select
)
if scope.is_a?(Symbol) || finder_options.values.compact.any?
return deprecated_paginate(scope, finder_options, options)
end
paginator = paginator(scope.count, options)
collection = scope.limit(paginator.per_page).offset(paginator.offset).to_a
return paginator, collection
end
def deprecated_paginate(arg, finder_options, options={})
ActiveSupport::Deprecation.warn "#paginate with a Symbol and/or find
options is depreceted and will be removed. Use a scope instead."
klass = arg.is_a?(Symbol) ? arg.to_s.classify.constantize : arg
scope = klass.scoped(finder_options)
paginate(scope, options)
end
def paginator(item_count, options={})
options.assert_valid_keys :parameter, :per_page
page_param = options[:parameter] || :page
page = (params[page_param] || 1).to_i
per_page = options[:per_page] || per_page_option
Paginator.new(item_count, per_page, page, page_param)
end
module Helper
include Redmine::I18n
# Renders the pagination links for the given paginator.
#
# Options:
# :per_page_links if set to false, the "Per page" links are not
rendered
#
def pagination_links_full(*args)
pagination_links_each(*args) do |text, parameters, options|
if block_given?
yield text, parameters, options
else
link_to text, params.merge(parameters), options
end
end
end
# Yields the given block with the text and parameters
# for each pagination link and returns a string that represents the links
def pagination_links_each(paginator, count=nil, options={}, &block)
options.assert_valid_keys :per_page_links
per_page_links = options.delete(:per_page_links)
per_page_links = false if count.nil?
page_param = paginator.page_param
html = ''
if paginator.previous_page
# \xc2\xab(utf-8) = «
text = "\xc2\xab " + l(:label_previous)
html << yield(text, {page_param => paginator.previous_page}, :class
=> 'previous') + ' '
end
previous = nil
paginator.linked_pages.each do |page|
if previous && previous != page - 1
html << content_tag('span', '...', :class => 'spacer') + ' '
end
if page == paginator.page
html << content_tag('span', page.to_s, :class => 'current page')
else
html << yield(page.to_s, {page_param => page}, :class => 'page')
end
html << ' '
previous = page
end
if paginator.next_page
# \xc2\xbb(utf-8) = »
text = l(:label_next) + " \xc2\xbb"
html << yield(text, {page_param => paginator.next_page}, :class =>
'next') + ' '
end
html << content_tag('span',
"(#{paginator.first_item}-#{paginator.last_item}/#{paginator.item_count})",
:class => 'items') + ' '
if per_page_links != false && links = per_page_links(paginator, &block)
html << content_tag('span', links.to_s, :class => 'per-page')
end
html.html_safe
end
# Renders the "Per page" links.
def per_page_links(paginator, &block)
values = per_page_options(paginator.per_page, paginator.item_count)
if values.any?
links = values.collect do |n|
if n == paginator.per_page
content_tag('span', n.to_s)
else
yield(n, :per_page => n, paginator.page_param => nil)
end
end
l(:label_display_per_page, links.join(', ')).html_safe
end
end
def per_page_options(selected=nil, item_count=nil)
options = Setting.per_page_options_array
if item_count && options.any?
if item_count > options.first
max = options.detect {|value| value >= item_count} || item_count
else
max = item_count
end
options = options.select {|value| value <= max || value == selected}
end
if options.empty? || (options.size == 1 && options.first == selected)
[]
else
options
end
end
end
end end `
I'm new to rails,i want to know how to paginate and sort by a particular
column. I can do this within one table,but when there are more than one
,like query between three or more tables,and the sorted column not in the
main table,i tried many times but failed ,and i also searched the web ,but
also in vain. now I need your help...help please!
while paginate i'm using this `# encoding: utf-8 module Pagination class
Paginator attr_reader :item_count, :per_page, :page, :page_param
def initialize(*args)
if args.first.is_a?(ActionController::Base)
args.shift
ActiveSupport::Deprecation.warn "Paginator no longer takes a
controller instance as the first argument. Remove it from #new
arguments."
end
item_count, per_page, page, page_param = *args
@item_count = item_count
@per_page = per_page
page = (page || 1).to_i
if page < 1
page = 1
end
@page = page
@page_param = page_param || :page
end
def offset
(page - 1) * per_page
end
def first_page
if item_count > 0
1
end
end
def previous_page
if page > 1
page - 1
end
end
def next_page
if last_item < item_count
page + 1
end
end
def last_page
if item_count > 0
(item_count - 1) / per_page + 1
end
end
def first_item
item_count == 0 ? 0 : (offset + 1)
end
def last_item
l = first_item + per_page - 1
l > item_count ? item_count : l
end
def linked_pages
pages = []
if item_count > 0
pages += [first_page, page, last_page]
pages += ((page-2)..(page+2)).to_a.select {|p| p > first_page && p <
last_page}
end
pages = pages.compact.uniq.sort
if pages.size > 1
pages
else
[]
end
end
def items_per_page
ActiveSupport::Deprecation.warn "Paginator#items_per_page will be
removed. Use #per_page instead."
per_page
end
def current
ActiveSupport::Deprecation.warn "Paginator#current will be removed.
Use .offset instead of .current.offset."
self
end
end
# Paginates the given scope or model. Returns a Paginator instance and
# the collection of objects for the current page.
#
# Options:
# :parameter name of the page parameter
#
# Examples:
# @user_pages, @users = paginate User.where(:status => 1)
#
def paginate(scope, options={})
options = options.dup
finder_options = options.extract!(
:conditions,
:order,
:joins,
:include,
:select
)
if scope.is_a?(Symbol) || finder_options.values.compact.any?
return deprecated_paginate(scope, finder_options, options)
end
paginator = paginator(scope.count, options)
collection = scope.limit(paginator.per_page).offset(paginator.offset).to_a
return paginator, collection
end
def deprecated_paginate(arg, finder_options, options={})
ActiveSupport::Deprecation.warn "#paginate with a Symbol and/or find
options is depreceted and will be removed. Use a scope instead."
klass = arg.is_a?(Symbol) ? arg.to_s.classify.constantize : arg
scope = klass.scoped(finder_options)
paginate(scope, options)
end
def paginator(item_count, options={})
options.assert_valid_keys :parameter, :per_page
page_param = options[:parameter] || :page
page = (params[page_param] || 1).to_i
per_page = options[:per_page] || per_page_option
Paginator.new(item_count, per_page, page, page_param)
end
module Helper
include Redmine::I18n
# Renders the pagination links for the given paginator.
#
# Options:
# :per_page_links if set to false, the "Per page" links are not
rendered
#
def pagination_links_full(*args)
pagination_links_each(*args) do |text, parameters, options|
if block_given?
yield text, parameters, options
else
link_to text, params.merge(parameters), options
end
end
end
# Yields the given block with the text and parameters
# for each pagination link and returns a string that represents the links
def pagination_links_each(paginator, count=nil, options={}, &block)
options.assert_valid_keys :per_page_links
per_page_links = options.delete(:per_page_links)
per_page_links = false if count.nil?
page_param = paginator.page_param
html = ''
if paginator.previous_page
# \xc2\xab(utf-8) = «
text = "\xc2\xab " + l(:label_previous)
html << yield(text, {page_param => paginator.previous_page}, :class
=> 'previous') + ' '
end
previous = nil
paginator.linked_pages.each do |page|
if previous && previous != page - 1
html << content_tag('span', '...', :class => 'spacer') + ' '
end
if page == paginator.page
html << content_tag('span', page.to_s, :class => 'current page')
else
html << yield(page.to_s, {page_param => page}, :class => 'page')
end
html << ' '
previous = page
end
if paginator.next_page
# \xc2\xbb(utf-8) = »
text = l(:label_next) + " \xc2\xbb"
html << yield(text, {page_param => paginator.next_page}, :class =>
'next') + ' '
end
html << content_tag('span',
"(#{paginator.first_item}-#{paginator.last_item}/#{paginator.item_count})",
:class => 'items') + ' '
if per_page_links != false && links = per_page_links(paginator, &block)
html << content_tag('span', links.to_s, :class => 'per-page')
end
html.html_safe
end
# Renders the "Per page" links.
def per_page_links(paginator, &block)
values = per_page_options(paginator.per_page, paginator.item_count)
if values.any?
links = values.collect do |n|
if n == paginator.per_page
content_tag('span', n.to_s)
else
yield(n, :per_page => n, paginator.page_param => nil)
end
end
l(:label_display_per_page, links.join(', ')).html_safe
end
end
def per_page_options(selected=nil, item_count=nil)
options = Setting.per_page_options_array
if item_count && options.any?
if item_count > options.first
max = options.detect {|value| value >= item_count} || item_count
else
max = item_count
end
options = options.select {|value| value <= max || value == selected}
end
if options.empty? || (options.size == 1 && options.first == selected)
[]
else
options
end
end
end
end end `
Subscribe to:
Comments (Atom)