Node projects with Underscore template delimeters conflicting in EJS views
Have backbone project using underscore templates. Using nodejs on the
server and rendering views with EJS. Underscore templates use the same
delimiters as EJS and because the underscore templates are in my .ejs
views as inline script tags I am getting errors. I tried the below
solution:
app.set('view options', {
open: '{{',
close: '}}'
});
It still appears to be trying to render the underscore template and
throwing an error:
<h2><%= title %></h2>
title is not defined
It seems using a custom delimiter in EJS just adds to the type of tags
that are accepted instead of changing them. I also couldn't find a way to
spit out raw html like you can in haml.
page btwn gough and franklin
Wednesday, 4 September 2013
How do I minimize or inform users of connection lag?
How do I minimize or inform users of connection lag?
I'm maintaining a ASP/C# program that uses an MS SQL Server 2008 R2 for
its database requirements.
On normal and perfect days, everything works fine as it is. But we don't
live in a perfect world, do we?
An Application (Leave, Sick Leave, Overtime, Undertime, etc.) Approval
process requires up to ten separate connections to the database. The
program uses stored procedures to do the work.
Now, due to the structure of the entire thing, which I can not change, a
dip in the connection, or heck, if I put a debug point in VS2005 and let
it hand there long enough, the Application Approval Process goes
incomplete. The tables are often just joined together, so a data mismatch
- a missing data here, a primary key that failed to update there - would
mean an entire row would be useless.
Now, I know that there is nothing I can do to prevent this. But are there
ways to minimize it? Or at the very least, a way to inform the users that
something went wrong with the process?
Thanks.
I'm maintaining a ASP/C# program that uses an MS SQL Server 2008 R2 for
its database requirements.
On normal and perfect days, everything works fine as it is. But we don't
live in a perfect world, do we?
An Application (Leave, Sick Leave, Overtime, Undertime, etc.) Approval
process requires up to ten separate connections to the database. The
program uses stored procedures to do the work.
Now, due to the structure of the entire thing, which I can not change, a
dip in the connection, or heck, if I put a debug point in VS2005 and let
it hand there long enough, the Application Approval Process goes
incomplete. The tables are often just joined together, so a data mismatch
- a missing data here, a primary key that failed to update there - would
mean an entire row would be useless.
Now, I know that there is nothing I can do to prevent this. But are there
ways to minimize it? Or at the very least, a way to inform the users that
something went wrong with the process?
Thanks.
Determining Prime Numbers Java
Determining Prime Numbers Java
I am writing a program that takes as input an integer, and outputs a
message whether the integer entered is prime or not. The algorithm I am
using is as follows... Require: n>0, Require: isPrime <- true, for i=2 to
sqrt(n) do, if n%i=0 then isPrime <- false end if and end for Then Print
whether the number is Prime or not. Here is my code so far, the code is
not working and I am not able to find the problem.
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
int n;
System.out.println("Input a positive integer");
n = kb.nextInt();
while (n>0){
boolean isPrime = true;
for (int i =2; i <= n/2;i++){
if(n % i == 0){
isPrime = false;
break;
}
}
if (isPrime = true){
System.out.println("The integer, " + n + ", is a prime");
break;
}
else{
System.out.println("The integer, " + n + ", is not a prime");
break;
}
}
}
}
I would be grateful if someone could help, Thanks!
I am writing a program that takes as input an integer, and outputs a
message whether the integer entered is prime or not. The algorithm I am
using is as follows... Require: n>0, Require: isPrime <- true, for i=2 to
sqrt(n) do, if n%i=0 then isPrime <- false end if and end for Then Print
whether the number is Prime or not. Here is my code so far, the code is
not working and I am not able to find the problem.
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
int n;
System.out.println("Input a positive integer");
n = kb.nextInt();
while (n>0){
boolean isPrime = true;
for (int i =2; i <= n/2;i++){
if(n % i == 0){
isPrime = false;
break;
}
}
if (isPrime = true){
System.out.println("The integer, " + n + ", is a prime");
break;
}
else{
System.out.println("The integer, " + n + ", is not a prime");
break;
}
}
}
}
I would be grateful if someone could help, Thanks!
How to Proxy, Remoting, HttpTunnel, through IIS
How to Proxy, Remoting, HttpTunnel, through IIS
I'm not sure of the best solution to this problem. The current network is
setup as:
Web server => Cms server => DB server
This is an existing setup for security reasons and cannot change. The Web
server is connected to the internet, and can connect to the Cms server but
not the DB server. The Cms server can access the DB server. (The idea was
if the Web server got hacked, they would have to get past the Cms Server
before getting to the DB server)
My current implementation to the problem as to create a simple proxy on
the Web server, with the website on the Cms server (as the website need to
access the DB). This works ok but i have timeout issues randomly. I've
written the proxy in MVC and its very simple and works. Is this the best
solution or is there a better way to solve this.
I'm not sure of the best solution to this problem. The current network is
setup as:
Web server => Cms server => DB server
This is an existing setup for security reasons and cannot change. The Web
server is connected to the internet, and can connect to the Cms server but
not the DB server. The Cms server can access the DB server. (The idea was
if the Web server got hacked, they would have to get past the Cms Server
before getting to the DB server)
My current implementation to the problem as to create a simple proxy on
the Web server, with the website on the Cms server (as the website need to
access the DB). This works ok but i have timeout issues randomly. I've
written the proxy in MVC and its very simple and works. Is this the best
solution or is there a better way to solve this.
what is the condition to check value from input text with javascript
what is the condition to check value from input text with javascript
I make a quiz app with codeigniter. When i publishing question i need to
check the option value with answer value. so how i make this check with a
suitable condition.or what is the condition for checking all this option
value with answer value? Below i show my view
<?php include_once('header.php'); ?>
<?php include_once('tnavbar.php'); ?>
<script src="<?php echo base_url();?>/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
function validateForm1(){
var j=3;
//alert(j);
for(var i=1; i<= j ; i++){
var qus1=document.forms["myForm1"]["ques[" + i + "]"].value;
var opt1=document.forms["myForm1"]["opt1[" + i + "]"].value;
var opt2=document.forms["myForm1"]["opt2[" + i + "]"].value;
var opt3=document.forms["myForm1"]["opt3[" + i + "]"].value;
var ans1=document.forms["myForm1"]["ans[" + i + "]"].value;
if ((qus1==null || qus1=="")||(opt1==null || opt1=="")||(opt2==null ||
opt2=="")||(opt3==null || opt3=="")||(ans1==null || ans1==""))
{
alert("All field must be fill");
return false;
}
}
for(var z=1; z<= j ; z++){
//var qus2=document.forms["myForm1"]["ques[" + z + "]"].value;
var opt4=document.forms["myForm1"]["opt1[" + z + "]"].value;
var opt5=document.forms["myForm1"]["opt2[" + z + "]"].value;
var opt6=document.forms["myForm1"]["opt3[" + z + "]"].value;
var ans2=document.forms["myForm1"]["ans[" + z + "]"].value;
if ((opt4||opt5||opt6)==ans2)
{
//alert("answer not match");
return true;
}
else{
alert("answer not match");
return false;
}
//return true;
}
}
</script>
<div class="maincontent_area">
<div class="container">
<div class="row">
<div class="span12">
<form id="myForm1" action="<? echo
base_url()."/index.php/Tmcq_test/insertmcq";?>" onsubmit="return
validateForm1();" method="post">
<?php for($i=1; $i<= 3; $i++){
?>
Question : <input type="text" name="ques[<?php echo $i;?>]"><br/>
Option 1 : <input type="text" name="opt1[<?php echo $i;?>]" ><br/>
Option 2 : <input type="text" name="opt2[<?php echo $i;?>]" ><br/>
Option 3 : <input type="text" name="opt3[<?php echo $i;?>]" ><br/>
Answer : <input type="text" name="ans[<?php echo $i;?>]"
><br/>
<br/>
<?php //echo $value->answer;
} ?>
<input type="hidden" name="quiz_name" value="<?php
echo $name;?>">
<input type="hidden" name="sub_id" value="<?php echo
$sub_id;?>">
<input type="hidden" name="quiz_number" value="<?php
echo $number;?>">
<input type="hidden" name="time_number" value="<?php
echo $time_number;?>">
<input type="submit" name="submit" id="submit" value="Create"
class="btn btn-info">
</form>
<a href="<? echo base_url()."/index.php/Tmcq_test";?>"> <button
class="btn btn-info"> Exit </button> </a>
</div>
</div>
</div>
<?php include_once('footer.php'); ?>
Here i am possible to check all the filed must fill up. But in second
condition in
for(var z=1;z<=j;z++)
//var qus2=document.forms["myForm1"]["ques[" + z + "]"].value;
var opt4=document.forms["myForm1"]["opt1[" + z + "]"].value;
var opt5=document.forms["myForm1"]["opt2[" + z + "]"].value;
var opt6=document.forms["myForm1"]["opt3[" + z + "]"].value;
var ans2=document.forms["myForm1"]["ans[" + z + "]"].value;
if ((opt4||opt5||opt6)==ans2)
{
//alert("answer not match");
return true;
}
else{
alert("answer not match");
return false;
}
//return true;
}
}
how i check that at least one option value must match with answer ? what
is the condition i need to use ?
I make a quiz app with codeigniter. When i publishing question i need to
check the option value with answer value. so how i make this check with a
suitable condition.or what is the condition for checking all this option
value with answer value? Below i show my view
<?php include_once('header.php'); ?>
<?php include_once('tnavbar.php'); ?>
<script src="<?php echo base_url();?>/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
function validateForm1(){
var j=3;
//alert(j);
for(var i=1; i<= j ; i++){
var qus1=document.forms["myForm1"]["ques[" + i + "]"].value;
var opt1=document.forms["myForm1"]["opt1[" + i + "]"].value;
var opt2=document.forms["myForm1"]["opt2[" + i + "]"].value;
var opt3=document.forms["myForm1"]["opt3[" + i + "]"].value;
var ans1=document.forms["myForm1"]["ans[" + i + "]"].value;
if ((qus1==null || qus1=="")||(opt1==null || opt1=="")||(opt2==null ||
opt2=="")||(opt3==null || opt3=="")||(ans1==null || ans1==""))
{
alert("All field must be fill");
return false;
}
}
for(var z=1; z<= j ; z++){
//var qus2=document.forms["myForm1"]["ques[" + z + "]"].value;
var opt4=document.forms["myForm1"]["opt1[" + z + "]"].value;
var opt5=document.forms["myForm1"]["opt2[" + z + "]"].value;
var opt6=document.forms["myForm1"]["opt3[" + z + "]"].value;
var ans2=document.forms["myForm1"]["ans[" + z + "]"].value;
if ((opt4||opt5||opt6)==ans2)
{
//alert("answer not match");
return true;
}
else{
alert("answer not match");
return false;
}
//return true;
}
}
</script>
<div class="maincontent_area">
<div class="container">
<div class="row">
<div class="span12">
<form id="myForm1" action="<? echo
base_url()."/index.php/Tmcq_test/insertmcq";?>" onsubmit="return
validateForm1();" method="post">
<?php for($i=1; $i<= 3; $i++){
?>
Question : <input type="text" name="ques[<?php echo $i;?>]"><br/>
Option 1 : <input type="text" name="opt1[<?php echo $i;?>]" ><br/>
Option 2 : <input type="text" name="opt2[<?php echo $i;?>]" ><br/>
Option 3 : <input type="text" name="opt3[<?php echo $i;?>]" ><br/>
Answer : <input type="text" name="ans[<?php echo $i;?>]"
><br/>
<br/>
<?php //echo $value->answer;
} ?>
<input type="hidden" name="quiz_name" value="<?php
echo $name;?>">
<input type="hidden" name="sub_id" value="<?php echo
$sub_id;?>">
<input type="hidden" name="quiz_number" value="<?php
echo $number;?>">
<input type="hidden" name="time_number" value="<?php
echo $time_number;?>">
<input type="submit" name="submit" id="submit" value="Create"
class="btn btn-info">
</form>
<a href="<? echo base_url()."/index.php/Tmcq_test";?>"> <button
class="btn btn-info"> Exit </button> </a>
</div>
</div>
</div>
<?php include_once('footer.php'); ?>
Here i am possible to check all the filed must fill up. But in second
condition in
for(var z=1;z<=j;z++)
//var qus2=document.forms["myForm1"]["ques[" + z + "]"].value;
var opt4=document.forms["myForm1"]["opt1[" + z + "]"].value;
var opt5=document.forms["myForm1"]["opt2[" + z + "]"].value;
var opt6=document.forms["myForm1"]["opt3[" + z + "]"].value;
var ans2=document.forms["myForm1"]["ans[" + z + "]"].value;
if ((opt4||opt5||opt6)==ans2)
{
//alert("answer not match");
return true;
}
else{
alert("answer not match");
return false;
}
//return true;
}
}
how i check that at least one option value must match with answer ? what
is the condition i need to use ?
AngularJS $http DELETE request Content-Type header
AngularJS $http DELETE request Content-Type header
When I make a DELETE request with AngularJS $resource module, angular adds
a Content-Type: application/xml header to request headers. In AngularJS
source code, there is a section that removes content-type request header
when no parameters sent. But, I don't understand why this is happen, this
doesn't works.
Here is how I make delete request:
$resource('/my/topics/:topicId').remove({ topicId: 1}, successFn, errorFn
And here is which headers browser
Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:0
Content-Type:application/xml
Cookie:session=0a627145415440740d6cc8cd35d19ba3; __ngDebug=true
Host:localhost:9001
Origin:http://localhost:9001
Referer:http://localhost:9001/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36
Where that Content-Type header come from?
When I make a DELETE request with AngularJS $resource module, angular adds
a Content-Type: application/xml header to request headers. In AngularJS
source code, there is a section that removes content-type request header
when no parameters sent. But, I don't understand why this is happen, this
doesn't works.
Here is how I make delete request:
$resource('/my/topics/:topicId').remove({ topicId: 1}, successFn, errorFn
And here is which headers browser
Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:0
Content-Type:application/xml
Cookie:session=0a627145415440740d6cc8cd35d19ba3; __ngDebug=true
Host:localhost:9001
Origin:http://localhost:9001
Referer:http://localhost:9001/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36
Where that Content-Type header come from?
Click image to call php function
Click image to call php function
I need to click an image and it to run some php script that sets a php
variable and reloads the same page.
I know it sounds simple but i've tried every different way I can think of
and i'm guessing it's just something basic i've missed.
I've tried onclick of the image, a href and a onclick, making the image
the 'submit button' of a form etc..
Any response would be appreciated.
Thanks in advance.
Regards, Kumar
I need to click an image and it to run some php script that sets a php
variable and reloads the same page.
I know it sounds simple but i've tried every different way I can think of
and i'm guessing it's just something basic i've missed.
I've tried onclick of the image, a href and a onclick, making the image
the 'submit button' of a form etc..
Any response would be appreciated.
Thanks in advance.
Regards, Kumar
Subscribe to:
Posts (Atom)