Configuring Dialout with the Cisco 2500 router
I'm working on configuring dialout with a Cisco 2511 router and external
modems. The end point is a dial-in server, which will create a ppp
connection. I use this guide as a reference but it only work with async1
port, when I switch to async2 and ping the server, the router doesn't dial
the server.
Config: client computer==(ethernet)router==(async
port)modems----pstn----modem==dial-in server(s)
Can someone help me out of this? A detail answer or document will help me
much since I'm new with this things.
Update: the result of sho run
!
version 11.2
no service password-encryption
no service udp-small-servers
no service tcp-small-servers
!
hostname Cisco
!
!
chat-script dialnum ABORT ERROR ABORT BUSY "" "ATD\T" TIMEOUT 180 CONNECT
chat-script DialOut ABORT ERROR ABORT BUSY "" "ATD\T" TIMEOUT 120 CONNECT
modemcap entry Zyxelsetup:MSC=&FS0=1&K4&N70
modemcap entry hayes:MSC=&FS0=1&K4&N70
modemcap entry Mosetup MSC=&FS0=1+MS=11,1,19200,19200
!
interface Ethernet0
description !!----- LAN interface -----!!
ip address 192.185.10.254 255.255.255.0
ip access-group 100 in
ip access-group 100 out
no ip mroute-cache
!
interface Serial0
no ip address
shutdown
no fair-queue
!
interface Serial1
no ip address
shutdown
!
interface Async1
no ip address
encapsulation ppp
async mode dedicated
dialer in-band
dialer rotary-group 0
!
interface Async2
no ip address
encapsulation ppp
async mode dedicated
dialer in-band
dialer rotary-group 1
!
interface Dialer0
ip address 192.184.10.254 255.255.255.0
encapsulation ppp
dialer in-band
dialer idle-timeout 180
dialer string xxxxxxx
dialer-group 1
ppp chap hostname CISCO1
ppp chap password 7 0010161510
!
interface Dialer1
ip address 192.184.9.254 255.255.255.0
encapsulation ppp
dialer in-band
dialer idle-timeout 60
dialer string xxxxxxxx
dialer-group 1
ppp chap hostname CISCO2
ppp chap password 7 110A11001419
!
ip classless
ip route 192.184.9.0 255.255.255.0 Dialer1
ip route 192.184.10.0 255.255.255.255 Dialer0
access-list 100 permit tcp any any
access-list 100 permit icmp any any
access-list 100 permit ip any any
!
dialer-list 1 protocol ip list 100
!
line con 0
line 1 16
script dialer DialOut
modem InOut
modem autoconfigure discovery
speed 115200
flowcontrol hardware
line aux 0
line vty 0 4
login
!
end
Thank you!
Monday, September 30, 2013
Derivative of a parametric function [on hold]
Derivative of a parametric function [on hold]
pI have the following parametric function: \begin{align} x amp;= A_1
\sin(deg(t) F_1 + P_1) \exp(-D_1 t) + A_2 \sin(deg(t) F_2 + P_2) \exp(-D_2
t)\\ y amp;= A_3 \sin(deg(t) F_3 + P_3) \exp(-D_3 t) + A_4 \sin(deg(t) F_4
+ P_4) \exp(-D_4 t)\\ z amp;= A_1 \sin(deg(t) F_5 + P_5) \exp(-D_5 t) +
A_6 \sin(deg(t) F_6 + P_6) \exp(-D_6 t) \end{align}/p pWhat is the
derivative? Thanks!/p pI'm trying to plot something called a Harmonograph,
and would like to enclose the curve within a tube. For that I need the
derivative and tangents./p pI tried using the a
href=http://www.derivative-calculator.net/ rel=nofollowOnline Derivative
Calculator/a but became confused./p pThanks!/p
pI have the following parametric function: \begin{align} x amp;= A_1
\sin(deg(t) F_1 + P_1) \exp(-D_1 t) + A_2 \sin(deg(t) F_2 + P_2) \exp(-D_2
t)\\ y amp;= A_3 \sin(deg(t) F_3 + P_3) \exp(-D_3 t) + A_4 \sin(deg(t) F_4
+ P_4) \exp(-D_4 t)\\ z amp;= A_1 \sin(deg(t) F_5 + P_5) \exp(-D_5 t) +
A_6 \sin(deg(t) F_6 + P_6) \exp(-D_6 t) \end{align}/p pWhat is the
derivative? Thanks!/p pI'm trying to plot something called a Harmonograph,
and would like to enclose the curve within a tube. For that I need the
derivative and tangents./p pI tried using the a
href=http://www.derivative-calculator.net/ rel=nofollowOnline Derivative
Calculator/a but became confused./p pThanks!/p
What does "L", "[" and ";" mean in smali code?
What does "L", "[" and ";" mean in smali code?
I'm trying to get a deep understanding of smali language. I found a page
talking about opcodes online, but it never talks about these special
symbols, which is L, ; and [, e.g
invoke-static {v2, v3},
Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
So, what does these symbols mean here? e.g [Ljava/lang/Object; and
Ljava/lang/String;
I'm trying to get a deep understanding of smali language. I found a page
talking about opcodes online, but it never talks about these special
symbols, which is L, ; and [, e.g
invoke-static {v2, v3},
Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
So, what does these symbols mean here? e.g [Ljava/lang/Object; and
Ljava/lang/String;
Creating a dynamic text field that changes content depending on select list choice?
Creating a dynamic text field that changes content depending on select
list choice?
Me and my colleague are in the process of starting up our own company that
handles exam results and school data. I am currently in the process of
setting up the webpage (I am completely new with PHP and Dreamweaver CC)
where the end-user can access and edit the database in the extent that
they need to.
But I shall get to the point of my problem. At the moment I am trying to
build a data edit page where all relevant data is shown once the user has
logged in (In this case it's an admin-kind of person, so he/she needs to
see which teacher teaches which classes). On this page I want to build a
drop-down list of all the possible Classes (done this with the recordset,
sorted alphabetically and working) and linking to that, a dynamic text
field that changes value depending on the option picked in the select
list.
Example:
There are four classes, and four corresponding teachers as followed:
Class - Teacher
English - Bob
Spanish - Juan
Math - Jenny
Geography - William
What I'm basically after is that if you choose the Class 'English' in the
drop-down select list, the text field should display 'Bob' (and similarly
for all the other classes). So far I've not managed to work out how to do
that in Dreamweaver CC.
Help is much appreciated!
list choice?
Me and my colleague are in the process of starting up our own company that
handles exam results and school data. I am currently in the process of
setting up the webpage (I am completely new with PHP and Dreamweaver CC)
where the end-user can access and edit the database in the extent that
they need to.
But I shall get to the point of my problem. At the moment I am trying to
build a data edit page where all relevant data is shown once the user has
logged in (In this case it's an admin-kind of person, so he/she needs to
see which teacher teaches which classes). On this page I want to build a
drop-down list of all the possible Classes (done this with the recordset,
sorted alphabetically and working) and linking to that, a dynamic text
field that changes value depending on the option picked in the select
list.
Example:
There are four classes, and four corresponding teachers as followed:
Class - Teacher
English - Bob
Spanish - Juan
Math - Jenny
Geography - William
What I'm basically after is that if you choose the Class 'English' in the
drop-down select list, the text field should display 'Bob' (and similarly
for all the other classes). So far I've not managed to work out how to do
that in Dreamweaver CC.
Help is much appreciated!
Sunday, September 29, 2013
Display jQuery Datepicker calculated date elsewhere on page
Display jQuery Datepicker calculated date elsewhere on page
Currently I'm using jQuery ui Datepicker. I'm using the calendar to allow
customers to choose delivery dates in one area of the page and it's set up
with a minDate of 4 days, excluding weekends and holidays. I wondered if
it's possible to display the final calculated minDate elsewhere on my
page? I want to display the "Earliest possible Delivery Date" in the
product description. Very, very new at jQuery and javascript.
Thanks in advance for your answers!
Currently I'm using jQuery ui Datepicker. I'm using the calendar to allow
customers to choose delivery dates in one area of the page and it's set up
with a minDate of 4 days, excluding weekends and holidays. I wondered if
it's possible to display the final calculated minDate elsewhere on my
page? I want to display the "Earliest possible Delivery Date" in the
product description. Very, very new at jQuery and javascript.
Thanks in advance for your answers!
Connect to database from another file class
Connect to database from another file class
I am trying to connect to a database PDO, but am having problems doing so.
I have tried to putt the connection inside the class.acl.php
The error is Fatal error: Call to a member function prepare() on a
non-object in.... class.acl.php
Connect.php:
$config = array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'lar'
);
$db = new PDO('mysql:host=' . $config['host'] . ';dbname=' .
$config['dbname'], $config['username'], $config['password']);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
class.acl.php:
class ACL{
private $db;
function __constructor($userID=''){
if ($userID != ''){
$this->userID = floatval($userID);
}else{
$this->userID = floatval($_SESSION['userID']);
}
$this->userRoles = $this->getUserRoles('ids');
$this->buildACL();
}
function ACL($userID=''){
$this->__constructor($userID);
}
function database($database){
$this->db = $database;
}
function getPermKeyFromID($permID){
Code....
return $permID
}
}
index.php:
require 'class.acl.php';
$userID=$_SESSION['ID'];
$ACL = new ACL($userID);
$ACL->database($db);
echo $ACL->getPermKeyFromID('1');
I am trying to connect to a database PDO, but am having problems doing so.
I have tried to putt the connection inside the class.acl.php
The error is Fatal error: Call to a member function prepare() on a
non-object in.... class.acl.php
Connect.php:
$config = array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'lar'
);
$db = new PDO('mysql:host=' . $config['host'] . ';dbname=' .
$config['dbname'], $config['username'], $config['password']);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
class.acl.php:
class ACL{
private $db;
function __constructor($userID=''){
if ($userID != ''){
$this->userID = floatval($userID);
}else{
$this->userID = floatval($_SESSION['userID']);
}
$this->userRoles = $this->getUserRoles('ids');
$this->buildACL();
}
function ACL($userID=''){
$this->__constructor($userID);
}
function database($database){
$this->db = $database;
}
function getPermKeyFromID($permID){
Code....
return $permID
}
}
index.php:
require 'class.acl.php';
$userID=$_SESSION['ID'];
$ACL = new ACL($userID);
$ACL->database($db);
echo $ACL->getPermKeyFromID('1');
Andengine: Version not supported by gl2
Andengine: Version not supported by gl2
I am new to gaming and when I tried to use Andengine GL ES 2.0 on the
emulator or bluestacks it errors out, saying that version not supported on
the gl2.
I'm using API Level 15, and the latest revision of the SDK (18), on
Windows XP professional, 32 bit I have GPU Emulation set to "yes".
My CPU is: Intel Core TM2 Duo Processor T7300, and I have a Intel 965/963
Graphics Media Accelerator
Also i have updated by OpenGl verion to 2.0 in my system
Any ideas? Should it be working? If so, how do I make it work?
Pls help me regarding this issue
I am new to gaming and when I tried to use Andengine GL ES 2.0 on the
emulator or bluestacks it errors out, saying that version not supported on
the gl2.
I'm using API Level 15, and the latest revision of the SDK (18), on
Windows XP professional, 32 bit I have GPU Emulation set to "yes".
My CPU is: Intel Core TM2 Duo Processor T7300, and I have a Intel 965/963
Graphics Media Accelerator
Also i have updated by OpenGl verion to 2.0 in my system
Any ideas? Should it be working? If so, how do I make it work?
Pls help me regarding this issue
Preventing Sql Injection in php (codeigniter)
Preventing Sql Injection in php (codeigniter)
How do I prevent sql injection in codeigniter for additional security?
Does Codeigniter do that itself or do I have to make my own? I want my
pages to be heavily secure.
How do I prevent sql injection in codeigniter for additional security?
Does Codeigniter do that itself or do I have to make my own? I want my
pages to be heavily secure.
Saturday, September 28, 2013
Canvas toDataURL() giving blank image
Canvas toDataURL() giving blank image
I'm a complete beginner to JS and I'm just playing around with HTML5.
While experimenting, I came across this issue. I have something like this:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
function graph() {
// ...stuff that draws to canvas, verified "working"...
var downloadLink =
document.getElementById("myCanvas").toDataURL();
$("#dlLink").attr("href", downloadLink);
}
$(window).load(function() {
graph();
});
</script>
</head>
<body>
<div class="container">
<h1 style = ";padding-bottom:30px;"><a href="#">Tool</a></h1>
<canvas id="myCanvas" width="400" height="400"></canvas>
<a href="#" id="dlLink">Download</a>
</div>
</body>
</html>
When I click the download link with the base64 encoding, I get a blank
image. Can anyone bring to light why this is happening? It seems like the
link is generated before the canvas has anything on it, but I can't be
sure.
I'm a complete beginner to JS and I'm just playing around with HTML5.
While experimenting, I came across this issue. I have something like this:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
function graph() {
// ...stuff that draws to canvas, verified "working"...
var downloadLink =
document.getElementById("myCanvas").toDataURL();
$("#dlLink").attr("href", downloadLink);
}
$(window).load(function() {
graph();
});
</script>
</head>
<body>
<div class="container">
<h1 style = ";padding-bottom:30px;"><a href="#">Tool</a></h1>
<canvas id="myCanvas" width="400" height="400"></canvas>
<a href="#" id="dlLink">Download</a>
</div>
</body>
</html>
When I click the download link with the base64 encoding, I get a blank
image. Can anyone bring to light why this is happening? It seems like the
link is generated before the canvas has anything on it, but I can't be
sure.
Why do I keep getting NoSuchMethodError on LocationAwareLogger?
Why do I keep getting NoSuchMethodError on LocationAwareLogger?
I'm trying to embed Jetty server into my automated tests so I've added the
following dependency in my project:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>7.6.13.v20130916</version>
<scope>test</scope>
</dependency>
I'm using Jetty 7 because the Web app uses Java 6, Servlet 2.5.
However when I try to start embedded Jetty server, I get:
java.lang.NoSuchMethodError:
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at
org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:607)
at
org.eclipse.jetty.util.log.JettyAwareLogger.warn(JettyAwareLogger.java:431)
at org.eclipse.jetty.util.log.Slf4jLog.warn(Slf4jLog.java:69)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.setFailed(AbstractLifeCycle.java:204)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:74)
I've been trying to figure out what's wrong but none of the steps I've
taken so far addresses the issue. Here's a list of what I've done so far:
Trace transitive dependencies to search for incompatible versions of
slf4j-api
Try out different versions of slf4j-api (1.5.11, 1.6.1, 1.6.4, 1.7.5)
Looked into the some sources of Jetty 7 particularly the pom.xml and found
that there's a dependency to slf4j 1.6.1
Looked into this similar question and got null when trying to print
org.slf4j.spi.LocationAwareLogger, and org.slf4j.Marker
I hope someone can offer a fresh insight into this issue. Thanks.
I'm trying to embed Jetty server into my automated tests so I've added the
following dependency in my project:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>7.6.13.v20130916</version>
<scope>test</scope>
</dependency>
I'm using Jetty 7 because the Web app uses Java 6, Servlet 2.5.
However when I try to start embedded Jetty server, I get:
java.lang.NoSuchMethodError:
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at
org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:607)
at
org.eclipse.jetty.util.log.JettyAwareLogger.warn(JettyAwareLogger.java:431)
at org.eclipse.jetty.util.log.Slf4jLog.warn(Slf4jLog.java:69)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.setFailed(AbstractLifeCycle.java:204)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:74)
I've been trying to figure out what's wrong but none of the steps I've
taken so far addresses the issue. Here's a list of what I've done so far:
Trace transitive dependencies to search for incompatible versions of
slf4j-api
Try out different versions of slf4j-api (1.5.11, 1.6.1, 1.6.4, 1.7.5)
Looked into the some sources of Jetty 7 particularly the pom.xml and found
that there's a dependency to slf4j 1.6.1
Looked into this similar question and got null when trying to print
org.slf4j.spi.LocationAwareLogger, and org.slf4j.Marker
I hope someone can offer a fresh insight into this issue. Thanks.
Alert hello world not working
Alert hello world not working
I have created a webservice to alert hello world using javacript. But no
results come. Even no error. I couldnot figure out where I do the mistake.
I just host the wsdl in locally. What have I missed?
Here is my code
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="Site.master.cs" Inherits="SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<link href="~/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/NetWebsite/js/jquery-1.10.2.js"
></script>
<script type="text/javascript" src="/NetWebsite/js/script.js" ></script>
<script language="JavaScript">
var iCallID;
function InitializeService(){
service.useService(http://localhost:5431/WebSite1/WebService.asmx?WSDL,"HelloWorldService");
service.HelloWorldService.callService("HellowWorld");
}
function ShowResult(){
alert(event.result.value);
}
</script>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body onload="InitializeService()" id="service"
style="behavior:url(webservice.htc)" onresult="ShowResult()">
<form runat="server">
<div class="page">
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
</body>
</html>
I have created a webservice to alert hello world using javacript. But no
results come. Even no error. I couldnot figure out where I do the mistake.
I just host the wsdl in locally. What have I missed?
Here is my code
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="Site.master.cs" Inherits="SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<link href="~/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/NetWebsite/js/jquery-1.10.2.js"
></script>
<script type="text/javascript" src="/NetWebsite/js/script.js" ></script>
<script language="JavaScript">
var iCallID;
function InitializeService(){
service.useService(http://localhost:5431/WebSite1/WebService.asmx?WSDL,"HelloWorldService");
service.HelloWorldService.callService("HellowWorld");
}
function ShowResult(){
alert(event.result.value);
}
</script>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body onload="InitializeService()" id="service"
style="behavior:url(webservice.htc)" onresult="ShowResult()">
<form runat="server">
<div class="page">
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
</body>
</html>
Bash doesn't quit on syntax error
Bash doesn't quit on syntax error
I have a bash code in which I have made a function which is called in the
program. I forgot to put a quotation mark in one of the statement because
of which the script threw a syntax error.Following is the code :
#function
write_errors()
{
#writes RIGHT TRUNCATION errors in bcp import
temp_file=$1
error_file=$2
stepName=$3
error_count=`fgrep -c "right truncation" ${error_file} "` #here is the
extra quotation mark
...
}
#start of script
date
...
write_errors #syntax error happens here
...
date #these lines are executed
rm -f ${temp}
rm -f ${error_file}
...
I have a bash code in which I have made a function which is called in the
program. I forgot to put a quotation mark in one of the statement because
of which the script threw a syntax error.Following is the code :
#function
write_errors()
{
#writes RIGHT TRUNCATION errors in bcp import
temp_file=$1
error_file=$2
stepName=$3
error_count=`fgrep -c "right truncation" ${error_file} "` #here is the
extra quotation mark
...
}
#start of script
date
...
write_errors #syntax error happens here
...
date #these lines are executed
rm -f ${temp}
rm -f ${error_file}
...
Friday, September 27, 2013
How to convert specific time format to timestamp in R?
How to convert specific time format to timestamp in R?
I am working on "Localization Data for Person Activity Data Set" dataset
from UCI and in this data set there is a column of date and time(both in
one column) with following format:
27.05.2009 14:03:25:777
27.05.2009 14:03:25:183
27.05.2009 14:03:25:210
27.05.2009 14:03:25:237
...
I am wondering if there is anyway to convert this column to timestamp
using R.
I am working on "Localization Data for Person Activity Data Set" dataset
from UCI and in this data set there is a column of date and time(both in
one column) with following format:
27.05.2009 14:03:25:777
27.05.2009 14:03:25:183
27.05.2009 14:03:25:210
27.05.2009 14:03:25:237
...
I am wondering if there is anyway to convert this column to timestamp
using R.
The persistence-context-ref-name [org.springframework.data.jpa.repository.support.QueryDslRepositorySupport/entityManager]
The persistence-context-ref-name
[org.springframework.data.jpa.repository.support.QueryDslRepositorySupport/entityManager]
I want to create an 'EJB web service'(ejb) that interacts with 'Spring
DATA JPA' and deployed it on glassfish
When i deploy the application on glassfish it throws this exception.
Could not resolve a persistence unit corresponding to the
persistence-context-ref-name
[org.springframework.data.jpa.repository.support.QueryDslRepositorySupport/entityManager]
in the scope of the module called
[dbaas-1.0-SNAPSHOT-jar-with-dependencies]. Please verify your
application.
My code
@WebService
@Stateless
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class JobServiceImpl implements JobService{
@Inject
JobDaoJpa jobDaoJpa;
}
Someone could tell me, what is the workaroud to fix this problem?
[org.springframework.data.jpa.repository.support.QueryDslRepositorySupport/entityManager]
I want to create an 'EJB web service'(ejb) that interacts with 'Spring
DATA JPA' and deployed it on glassfish
When i deploy the application on glassfish it throws this exception.
Could not resolve a persistence unit corresponding to the
persistence-context-ref-name
[org.springframework.data.jpa.repository.support.QueryDslRepositorySupport/entityManager]
in the scope of the module called
[dbaas-1.0-SNAPSHOT-jar-with-dependencies]. Please verify your
application.
My code
@WebService
@Stateless
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class JobServiceImpl implements JobService{
@Inject
JobDaoJpa jobDaoJpa;
}
Someone could tell me, what is the workaroud to fix this problem?
R code: Extracting highly correlated variables and Running multivariate regression model with selected variables
R code: Extracting highly correlated variables and Running multivariate
regression model with selected variables
I have a huge data which has about 2,000 variables and about 10,000
observations. Initially, I wanted to run a regression model for each one
with 1999 independent variables and then do stepwise model selection.
Therefore, I would have 2,000 models.
However, unfortunately R presented errors because of lack of memory.. So,
alternatively, I have tried to remove some independent variables which are
low correlation value- maybe lower than .5-
With variables which are highly correlated with each dependent variable, I
would like to run regression model..
I tried to do follow codes, even "melt"function doesn't work because of
memory issue.. oh god..
test<-data.frame(X1=rnorm(50,mean=50,sd=10), X2=rnorm(50,mean=5,sd=1.5),
X3=rnorm(50,mean=200,sd=25))
test$X1[10]<-5
test$X2[10]<-5
test$X3[10]<-530
corr<-cor(test)
diag(corr)<-NA
corr[upper.tri(corr)]<-NA
melt(corr)
#it doesn't work with my own data..because of lack of memory.
Please help me.. and thank you so much in advance..!
regression model with selected variables
I have a huge data which has about 2,000 variables and about 10,000
observations. Initially, I wanted to run a regression model for each one
with 1999 independent variables and then do stepwise model selection.
Therefore, I would have 2,000 models.
However, unfortunately R presented errors because of lack of memory.. So,
alternatively, I have tried to remove some independent variables which are
low correlation value- maybe lower than .5-
With variables which are highly correlated with each dependent variable, I
would like to run regression model..
I tried to do follow codes, even "melt"function doesn't work because of
memory issue.. oh god..
test<-data.frame(X1=rnorm(50,mean=50,sd=10), X2=rnorm(50,mean=5,sd=1.5),
X3=rnorm(50,mean=200,sd=25))
test$X1[10]<-5
test$X2[10]<-5
test$X3[10]<-530
corr<-cor(test)
diag(corr)<-NA
corr[upper.tri(corr)]<-NA
melt(corr)
#it doesn't work with my own data..because of lack of memory.
Please help me.. and thank you so much in advance..!
MATLAB Cell Array - Average two values if another column matches
MATLAB Cell Array - Average two values if another column matches
I have a cell array in which some of the entries have two data points. I
want to average the two data points if the data were collected on the same
day.
The first column of cell array 'site' is the date. The fourth column is
the data concentration. I want to average the fourth column if the data
comes from the same day.
For example, if my cell array looks like this:
01/01/2011 36-061-0069 1 10.4
01/01/2011 36-061-0069 2 10.1
01/04/2011 36-061-0069 1 7.9
01/05/2011 36-061-0069 1 13
I want to average the fourth column (10.4 and 10.1) into one row and leave
everything else the same.
Help? Would an if elseif loop work? I'm not sure how to approach this
issue, especially since cell arrays work a little differently than
matrices.
I have a cell array in which some of the entries have two data points. I
want to average the two data points if the data were collected on the same
day.
The first column of cell array 'site' is the date. The fourth column is
the data concentration. I want to average the fourth column if the data
comes from the same day.
For example, if my cell array looks like this:
01/01/2011 36-061-0069 1 10.4
01/01/2011 36-061-0069 2 10.1
01/04/2011 36-061-0069 1 7.9
01/05/2011 36-061-0069 1 13
I want to average the fourth column (10.4 and 10.1) into one row and leave
everything else the same.
Help? Would an if elseif loop work? I'm not sure how to approach this
issue, especially since cell arrays work a little differently than
matrices.
How can I drop a pin on the apple map and get the location?
How can I drop a pin on the apple map and get the location?
In my application i want to show for the user map in current location and
i want the user can move (change) the pin for new location or drop a new
pin on the map and get the location.
somebody know good toturial for this ? i develop Cocoa developer but never
work with MapKit.
Thanks for help.
In my application i want to show for the user map in current location and
i want the user can move (change) the pin for new location or drop a new
pin on the map and get the location.
somebody know good toturial for this ? i develop Cocoa developer but never
work with MapKit.
Thanks for help.
How to run an php application without installing xampp on client system?
How to run an php application without installing xampp on client system?
In my application i have to deploy my application on client system. So is
there any way to run my php application without installing xampp...
Because the client should access it as a readymade app without installing
anything...
In my application i have to deploy my application on client system. So is
there any way to run my php application without installing xampp...
Because the client should access it as a readymade app without installing
anything...
) Expected using t4 text templates in c#
) Expected using t4 text templates in c#
Trying to make a conversion .exe between a .gbxml filetype and a .idf
filetype by using a t4 text template, i ran into an error.
Somehow, this code snippet keeps telling me: Error CS1026: ) expected.
This occurs after the 'relative north{deg}");' part I tried putting in
more brackets, just to see what happens, but the error keeps occurring.
Here's the part of the text template:
<# foreach(XElement zone in
doc.Element(ns+"Campus").Element(ns+"Building").Elements(ns+"Space")
{
WriteLine("Zone,");
WriteLine(" "+ zone.Element(ns+"Name").Value + ", !- Name");
WriteLine(" 0.00000,"+ "!- Direction of Relative North {deg}");
WriteLine(" 0.0, !- X Origin {m}");
WriteLine(" 0.0, !- Y Origin {m}");
WriteLine(" 0.0, !- Z Origin {m}");
WriteLine(" 1, !- Type");
WriteLine(" 1.0, !- Multiplier");
WriteLine(" autocalculate, !- Ceiling Height {m}");
WriteLine(" "+zone.Element(ns+"Volume").Value + ", !-
Volume {m3}");
WriteLine(" "+zone.Element(ns+"Area").Value + "; !-
Floor Area {m2}");
}#>
Has anyone had experience with this problem? Thanks in advance.
EDIT: Resolved. I forgot the ) at the end of the foreach loop. Thank you
for your help.
Trying to make a conversion .exe between a .gbxml filetype and a .idf
filetype by using a t4 text template, i ran into an error.
Somehow, this code snippet keeps telling me: Error CS1026: ) expected.
This occurs after the 'relative north{deg}");' part I tried putting in
more brackets, just to see what happens, but the error keeps occurring.
Here's the part of the text template:
<# foreach(XElement zone in
doc.Element(ns+"Campus").Element(ns+"Building").Elements(ns+"Space")
{
WriteLine("Zone,");
WriteLine(" "+ zone.Element(ns+"Name").Value + ", !- Name");
WriteLine(" 0.00000,"+ "!- Direction of Relative North {deg}");
WriteLine(" 0.0, !- X Origin {m}");
WriteLine(" 0.0, !- Y Origin {m}");
WriteLine(" 0.0, !- Z Origin {m}");
WriteLine(" 1, !- Type");
WriteLine(" 1.0, !- Multiplier");
WriteLine(" autocalculate, !- Ceiling Height {m}");
WriteLine(" "+zone.Element(ns+"Volume").Value + ", !-
Volume {m3}");
WriteLine(" "+zone.Element(ns+"Area").Value + "; !-
Floor Area {m2}");
}#>
Has anyone had experience with this problem? Thanks in advance.
EDIT: Resolved. I forgot the ) at the end of the foreach loop. Thank you
for your help.
Thursday, September 26, 2013
How to identify a column with name exist in all tables?
How to identify a column with name exist in all tables?
i want to query a database which has huge tables for the columns with
specific name
ex: fetch all the tables which has column name like 'name'
Thanks.
i want to query a database which has huge tables for the columns with
specific name
ex: fetch all the tables which has column name like 'name'
Thanks.
Wednesday, September 25, 2013
ajax call in worker Thread throws Error "Origin file:// is not allowed by Access-Control-Allow-Origin."
ajax call in worker Thread throws Error "Origin file:// is not allowed by
Access-Control-Allow-Origin."
I am a new bie to webwoker and was trying my first sample on webworker. my
first webworker.html is the main thread doWork2.js is the worker thread.
If a post a message like 'HI ' form main thread to worker, the worker
receives it and returns back the same message to main thread using its own
post message in doWork2.js.
I am trying to use a worker thread to make ajax request. I am trying to
make a synchronous ajax request to retrieve the RSS feeds for itunes.
On the click of the button hi, the main thread posts a message to worker
like"worker.postMessage({'cmd': 'start', 'msg': "Hi"});"
In the worker thread the httpGet() makes an Ajax request and returns the
which is stored in
self.postMessage('WORKER STARTED: ' + data.msg+ myresult);
Access-Control-Allow-Origin."
I am a new bie to webwoker and was trying my first sample on webworker. my
first webworker.html is the main thread doWork2.js is the worker thread.
If a post a message like 'HI ' form main thread to worker, the worker
receives it and returns back the same message to main thread using its own
post message in doWork2.js.
I am trying to use a worker thread to make ajax request. I am trying to
make a synchronous ajax request to retrieve the RSS feeds for itunes.
On the click of the button hi, the main thread posts a message to worker
like"worker.postMessage({'cmd': 'start', 'msg': "Hi"});"
In the worker thread the httpGet() makes an Ajax request and returns the
which is stored in
self.postMessage('WORKER STARTED: ' + data.msg+ myresult);
Thursday, September 19, 2013
Npm is definitely not working
Npm is definitely not working
Every time I try to do something with NPM it doesn't work. I have node
installed with the version 0.10.7 and npm with version 1.2.21. I need to
install coffee-script and it gives me this error:
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm ERR! network tunneling socket could not be established,
cause=getaddrinfo ENOTFOUND
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network
settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! System Linux 3.5.0-39-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g"
"coffee-script"
npm ERR! cwd /home/sasuke/Videos/Node.js/Ex_Files_Node.js_FL/Exercise
Files/3 Modules
npm ERR! node -v v0.10.18
npm ERR! npm -v 1.3.8
npm ERR! code ECONNRESET
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/sasuke/Videos/Node.js/Ex_Files_Node.js_FL/Exercise
Files/3 Modules/npm-debug.log
npm ERR! not ok code 0
I've saw this link: https://github.com/isaacs/npm/issues/2677 But after I
tried to check the proxies I got this:
~ > npm config get proxy
proxy-url:port
~ > npm config get https-proxy
proxy-url:port
Later on that post someone said to change the token at
/usr/local/etc/npmrc But I don't have that file. After that I've update
node to v0.10.18 but I still have the same error. I am working on Ubuntu
12.04 and I still have no idea how to fix this. Please help.
Every time I try to do something with NPM it doesn't work. I have node
installed with the version 0.10.7 and npm with version 1.2.21. I need to
install coffee-script and it gives me this error:
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm ERR! network tunneling socket could not be established,
cause=getaddrinfo ENOTFOUND
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network
settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! System Linux 3.5.0-39-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g"
"coffee-script"
npm ERR! cwd /home/sasuke/Videos/Node.js/Ex_Files_Node.js_FL/Exercise
Files/3 Modules
npm ERR! node -v v0.10.18
npm ERR! npm -v 1.3.8
npm ERR! code ECONNRESET
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/sasuke/Videos/Node.js/Ex_Files_Node.js_FL/Exercise
Files/3 Modules/npm-debug.log
npm ERR! not ok code 0
I've saw this link: https://github.com/isaacs/npm/issues/2677 But after I
tried to check the proxies I got this:
~ > npm config get proxy
proxy-url:port
~ > npm config get https-proxy
proxy-url:port
Later on that post someone said to change the token at
/usr/local/etc/npmrc But I don't have that file. After that I've update
node to v0.10.18 but I still have the same error. I am working on Ubuntu
12.04 and I still have no idea how to fix this. Please help.
How would I add enumerated type values in an array
How would I add enumerated type values in an array
Heres the method where I try to add everything. What im trying to do is
add up a series of coins, which are named penny,dime...etc. And i gave all
of them a value within the enum. But how do I access each of the coins
within the array, then add up their values?
public double totalValue(Coin[] coins)
{
double sum = 0;
//computes and returns the monetary value of all the coins in the jar
for(int i = 0; i < coins.length; i++)
{
double coinValue = coins[i].CoinName.getCoinValue();
sum = sum + coins[i];
System.out.println(sum);
}
return sum; //change this!
}
and here is where the values for the enum are defined.
public enum CoinName
{
PENNY(.01), NICKEL(.05), DIME(.10), QUARTER(.25), FIFTY_CENT(.50),
DOLLAR(1.0);
private double value;
private double coinValue;
private CoinName(double value)
{
this.coinValue = value;
}
public double getCoinValue()
{
return coinValue;
}
}
Heres the method where I try to add everything. What im trying to do is
add up a series of coins, which are named penny,dime...etc. And i gave all
of them a value within the enum. But how do I access each of the coins
within the array, then add up their values?
public double totalValue(Coin[] coins)
{
double sum = 0;
//computes and returns the monetary value of all the coins in the jar
for(int i = 0; i < coins.length; i++)
{
double coinValue = coins[i].CoinName.getCoinValue();
sum = sum + coins[i];
System.out.println(sum);
}
return sum; //change this!
}
and here is where the values for the enum are defined.
public enum CoinName
{
PENNY(.01), NICKEL(.05), DIME(.10), QUARTER(.25), FIFTY_CENT(.50),
DOLLAR(1.0);
private double value;
private double coinValue;
private CoinName(double value)
{
this.coinValue = value;
}
public double getCoinValue()
{
return coinValue;
}
}
Regex for 7-10 integers
Regex for 7-10 integers
I have another question today. I have an email appliance that I am setting
up to filter certain data, but it can only do this via regular expression.
I have this partially accomplished thanks to this fine gentleman. What I
need to accomplish now is something a bit more complex. I should add that
I am a complete novice at regex. Right now i'm using this:
(?<!\d)(?!1000000)([1-7]\d{6}|8000000)(?!\d)
To find 7 digit integers within a range from 1000001 to 8000000, what i'm
looking to do now is find integers between 1000000 and 12000000000, I can
re purpose this code by simply changing up the section here
([1-7]\d{6}
But from my understanding this would require I format 5 separate
expressions to find the data I need (I may be completely off base about
this, but I don't know enough about regex to change this line to what I
need). I would prefer one expression to look for data between 7-12 digits
and stop at certain explicit 12 digit value. How can I accomplish this?
I have another question today. I have an email appliance that I am setting
up to filter certain data, but it can only do this via regular expression.
I have this partially accomplished thanks to this fine gentleman. What I
need to accomplish now is something a bit more complex. I should add that
I am a complete novice at regex. Right now i'm using this:
(?<!\d)(?!1000000)([1-7]\d{6}|8000000)(?!\d)
To find 7 digit integers within a range from 1000001 to 8000000, what i'm
looking to do now is find integers between 1000000 and 12000000000, I can
re purpose this code by simply changing up the section here
([1-7]\d{6}
But from my understanding this would require I format 5 separate
expressions to find the data I need (I may be completely off base about
this, but I don't know enough about regex to change this line to what I
need). I would prefer one expression to look for data between 7-12 digits
and stop at certain explicit 12 digit value. How can I accomplish this?
Using keypress event in knockout JS
Using keypress event in knockout JS
I'm trying to read the contents of an html textbox and fetch data from my
DB to accomplish a google type auto complete. I'm using twitter bootstrap
typeahead for the auto complete functionality. For that I need to record
keys as they are pressed and make a call to my DB with the query text to
the DB.
The html for the text box is this
<input id="query" data-bind="value: query, valueUpdate: 'keypress', event:
{ keypress: check }"/>
My assumption was that this will update the value in the viewmodel as soon
as the key is pressed, and the check function will meanwhile call the DB.
But the call is made to check( ) and the text box never gets populated
when the user types. if the JS looks like this -
function check() {
alert("Hello");
}
For every key I press, hello pops up but the text box in the HTML UI does
not show the key that was pressed/does not record which key was pressed.
How do I record the key press and send the request simultaneously?
I'm trying to read the contents of an html textbox and fetch data from my
DB to accomplish a google type auto complete. I'm using twitter bootstrap
typeahead for the auto complete functionality. For that I need to record
keys as they are pressed and make a call to my DB with the query text to
the DB.
The html for the text box is this
<input id="query" data-bind="value: query, valueUpdate: 'keypress', event:
{ keypress: check }"/>
My assumption was that this will update the value in the viewmodel as soon
as the key is pressed, and the check function will meanwhile call the DB.
But the call is made to check( ) and the text box never gets populated
when the user types. if the JS looks like this -
function check() {
alert("Hello");
}
For every key I press, hello pops up but the text box in the HTML UI does
not show the key that was pressed/does not record which key was pressed.
How do I record the key press and send the request simultaneously?
jquery fullcalendar how to serialize events
jquery fullcalendar how to serialize events
I use fullcalendar jquery plugin from http://arshaw.com/fullcalendar/ and
I use knockout js on my website.
I added the event array what is the source of the calendar. The user can
modify the events (array).
Then I want to serialize the event array, send by ajax, but I can not,
because the calendar modifies my array, and puts an cycle into the source
array. How can I remove the changes. Why is there a cycle in my array? I
read, may be there is an DOM object in this.
Chrome sendrequest error: TypeError: Converting circular structure to JSON
var a = [];
a.push({
title : 'Event2',
start : '2013-09-05'
});
a.push({
title : 'Event2',
start : '2013-09-15'
});
$("#calendar").fullCalendar({
events : a,
header : {
left : 'title',
center : '',
right : 'today prev,next'
},
editable : false,
});
console.log(JSON.stringify(a));
TypeError: Converting circular structure to JSON
How can I fix it? What is the cause of the cycle?
I use fullcalendar jquery plugin from http://arshaw.com/fullcalendar/ and
I use knockout js on my website.
I added the event array what is the source of the calendar. The user can
modify the events (array).
Then I want to serialize the event array, send by ajax, but I can not,
because the calendar modifies my array, and puts an cycle into the source
array. How can I remove the changes. Why is there a cycle in my array? I
read, may be there is an DOM object in this.
Chrome sendrequest error: TypeError: Converting circular structure to JSON
var a = [];
a.push({
title : 'Event2',
start : '2013-09-05'
});
a.push({
title : 'Event2',
start : '2013-09-15'
});
$("#calendar").fullCalendar({
events : a,
header : {
left : 'title',
center : '',
right : 'today prev,next'
},
editable : false,
});
console.log(JSON.stringify(a));
TypeError: Converting circular structure to JSON
How can I fix it? What is the cause of the cycle?
C# Enum.ToString() with complete name
C# Enum.ToString() with complete name
I am searching a solution to get the complete String of an enum.
Example:
Public Enum Color
{
Red = 1,
Blue = 2
}
Color color = Color.Red;
// This will always get "Red" but I need "Color.Red"
string colorString = color.ToString();
// I know that this is what I need:
colorString = Color.Red.ToString();
So is there a solution?
I am searching a solution to get the complete String of an enum.
Example:
Public Enum Color
{
Red = 1,
Blue = 2
}
Color color = Color.Red;
// This will always get "Red" but I need "Color.Red"
string colorString = color.ToString();
// I know that this is what I need:
colorString = Color.Red.ToString();
So is there a solution?
Wednesday, September 18, 2013
segmentation fault with printf on linux
segmentation fault with printf on linux
@Team,
While trying to print an integer value through printf i accidentally wrote
the statement as
int x =10;
printf(x);
In linux i am getting a segmentation fault when tried to execute it.
Although its wrong but can some one please help me to know the reason for
it.
Strace says:
mprotect(0x7f872fb26000, 4096, PROT_READ) = 0
munmap(0x7f872fb0b000, 99154) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV (core dumped) +++
Tried searching in SO but to no success.
@Team,
While trying to print an integer value through printf i accidentally wrote
the statement as
int x =10;
printf(x);
In linux i am getting a segmentation fault when tried to execute it.
Although its wrong but can some one please help me to know the reason for
it.
Strace says:
mprotect(0x7f872fb26000, 4096, PROT_READ) = 0
munmap(0x7f872fb0b000, 99154) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV (core dumped) +++
Tried searching in SO but to no success.
Can I use "not equal" in MS Access Find Function
Can I use "not equal" in MS Access Find Function
Can i use the qualifier "not equal" in the ms access find function? I have
a column of numbers that are the same for most records but an occasional
different number gets in the list and i want to find these different
number every time they occur.
Can i use the qualifier "not equal" in the ms access find function? I have
a column of numbers that are the same for most records but an occasional
different number gets in the list and i want to find these different
number every time they occur.
Adding item into a linked list, pass by reference or value?
Adding item into a linked list, pass by reference or value?
Part of my homework assignment is to implement a generic linked list. So
far I wrote this function:
template<class T>
void List<T>::insert(const T& data)
{
List<T>::Node* newNode = new List<T>::Node(data);
newNode->next = nullptr;
if (head == nullptr)
{
head = newNode;
tail = newNode;
}
else
{
tail->next = newNode;
tail = newNode;
}
size++;
}
As you can see I'm getting the data by reference but I could get it by
value as well. My question is what approach is better and why?
Part of my homework assignment is to implement a generic linked list. So
far I wrote this function:
template<class T>
void List<T>::insert(const T& data)
{
List<T>::Node* newNode = new List<T>::Node(data);
newNode->next = nullptr;
if (head == nullptr)
{
head = newNode;
tail = newNode;
}
else
{
tail->next = newNode;
tail = newNode;
}
size++;
}
As you can see I'm getting the data by reference but I could get it by
value as well. My question is what approach is better and why?
How do I pass a multistring variable into php through a parameter
How do I pass a multistring variable into php through a parameter
How do I send in a "multi"-string variable(looking like this: 1,2.3,4)
into a php through a parameter which goes through an url.
Lets say some of the php that is connected to the mysql server looks
something like this
`$id_ = $_GET['id'];`
`$q=mysql_query("SELECT * FROM brain WHERE braincell_id in ('$id_');`
And the variable that goes into it is: id = 1,2,3,4
How can I make this work?
What I am using currently and that does work:
$q=mysql_query("SELECT * FROM brain WHERE braincell_id in ("$_GET['id']");
How do I send in a "multi"-string variable(looking like this: 1,2.3,4)
into a php through a parameter which goes through an url.
Lets say some of the php that is connected to the mysql server looks
something like this
`$id_ = $_GET['id'];`
`$q=mysql_query("SELECT * FROM brain WHERE braincell_id in ('$id_');`
And the variable that goes into it is: id = 1,2,3,4
How can I make this work?
What I am using currently and that does work:
$q=mysql_query("SELECT * FROM brain WHERE braincell_id in ("$_GET['id']");
Database that supports efficient query with ranges
Database that supports efficient query with ranges
Is there a database technology that supports efficient queries / indexing
within a continuous range of values? For example consider the following
data set
Name Age
Alice 25
Bob 35
Charlie 26
Diane 39
Edward 19
... ...
Now imagine I want to do a query for the names of all people in their
twenties. I can express this query in a number of database systems. Is
there any system which supports efficient queries of this sort? I'm
looking for something like an index but over ordered and continuous data.
Note that I'm not looking for a query to solve this problem. I'm looking
for an example database system that supports efficient (sublinear)
filtering over ordered continuous data.
Is there a database technology that supports efficient queries / indexing
within a continuous range of values? For example consider the following
data set
Name Age
Alice 25
Bob 35
Charlie 26
Diane 39
Edward 19
... ...
Now imagine I want to do a query for the names of all people in their
twenties. I can express this query in a number of database systems. Is
there any system which supports efficient queries of this sort? I'm
looking for something like an index but over ordered and continuous data.
Note that I'm not looking for a query to solve this problem. I'm looking
for an example database system that supports efficient (sublinear)
filtering over ordered continuous data.
Get a Map[enum, String] from a Java enum with a String field in Scala (Play Framework)?
Get a Map[enum, String] from a Java enum with a String field in Scala
(Play Framework)?
I have the following Java enum:
public enum CertificateType {
@EnumValue( "e" )
EMAIL("Email"),
@EnumValue( "n" )
NATURAL_QUALIFIED("Qualified"),
@EnumValue( "p" )
PSEUDONYMOUS_QUALIFIED("Qualified");
public final String NAME;
private CertificateType( final String name ) {
this.NAME = name;
}
}
What I would like to do is turn that enum into a Map[enum value,
enum.NAME] to use in a Play Framework @select function.
For a list of objects, I'd use the .map function, like so:
Organization.all.map(org => (org.id.toString, org.name))(collection.breakOut)
But I don't think I can modify that to work with an enum.
How can I accomplish this?
(Play Framework)?
I have the following Java enum:
public enum CertificateType {
@EnumValue( "e" )
EMAIL("Email"),
@EnumValue( "n" )
NATURAL_QUALIFIED("Qualified"),
@EnumValue( "p" )
PSEUDONYMOUS_QUALIFIED("Qualified");
public final String NAME;
private CertificateType( final String name ) {
this.NAME = name;
}
}
What I would like to do is turn that enum into a Map[enum value,
enum.NAME] to use in a Play Framework @select function.
For a list of objects, I'd use the .map function, like so:
Organization.all.map(org => (org.id.toString, org.name))(collection.breakOut)
But I don't think I can modify that to work with an enum.
How can I accomplish this?
passing cmd line input parameters to GNU scripts run in Win7 batch files
passing cmd line input parameters to GNU scripts run in Win7 batch files
A batch file has to first process and print out some data from the
datafile to let me select proper parameters %2 and %3 for later use. Next,
I have to enter manually those two select parameters.
What syntax should I use to request and input several parameters, possibly
using the SET /p command on a Win7 Pro box, when a batch file is being
run, so that these parameters are then passed on to various GNU utilities
which expect the %1 parameter format? Here's an example of a run.bat file
and its use:
C:\run <datafile>
@set /p pattern1=Enter pattern1:
@set /p pattern2=Enter pattern2:
@awk '/%1/,/%2/' datafile
This example should print all the lines between, and inclusive of, two
strings pattern1 and pattern2 from , but whatever parameter format I try
for pattern1 with the set /p command (%1, %%1, %1%,...), it doesn't work.
A batch file has to first process and print out some data from the
datafile to let me select proper parameters %2 and %3 for later use. Next,
I have to enter manually those two select parameters.
What syntax should I use to request and input several parameters, possibly
using the SET /p command on a Win7 Pro box, when a batch file is being
run, so that these parameters are then passed on to various GNU utilities
which expect the %1 parameter format? Here's an example of a run.bat file
and its use:
C:\run <datafile>
@set /p pattern1=Enter pattern1:
@set /p pattern2=Enter pattern2:
@awk '/%1/,/%2/' datafile
This example should print all the lines between, and inclusive of, two
strings pattern1 and pattern2 from , but whatever parameter format I try
for pattern1 with the set /p command (%1, %%1, %1%,...), it doesn't work.
Show a portion of image based on scroll
Show a portion of image based on scroll
Been searching for this but haven't found any good answer. I wan't to show
a portion of an image based on scroll positioning, so when the user scroll
downs the image shows the portion of the image based on scroll
positioning, and when scrolling back up it hides the portion...
Wondering on what is the best way to do so, or if any of you done this
before and wan't to share your knowledge ?.
Thanks guys!...
Been searching for this but haven't found any good answer. I wan't to show
a portion of an image based on scroll positioning, so when the user scroll
downs the image shows the portion of the image based on scroll
positioning, and when scrolling back up it hides the portion...
Wondering on what is the best way to do so, or if any of you done this
before and wan't to share your knowledge ?.
Thanks guys!...
Add array items to array in one line
Add array items to array in one line
I am building a CSV object and I have a dynamic set of header items. I
build this 'header' row as follows:
headers = ["name", "email"]
questions.each do |q|
headers << q
end
csv << headers
Although this works just fine, what I would like to do is have the call in
one line without having to add the headers variable first.
So something like:
csv << ["name", "email", questions.each { |q| q }]
Obviously the above doesn't work because the each returns the 'questions'
array.
Any suggestions?
I am building a CSV object and I have a dynamic set of header items. I
build this 'header' row as follows:
headers = ["name", "email"]
questions.each do |q|
headers << q
end
csv << headers
Although this works just fine, what I would like to do is have the call in
one line without having to add the headers variable first.
So something like:
csv << ["name", "email", questions.each { |q| q }]
Obviously the above doesn't work because the each returns the 'questions'
array.
Any suggestions?
Tuesday, September 17, 2013
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException in Netbeans
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException in
Netbeans
there is a program for gui
/* * To change this template, choose Tools | Templates * and open the
templaenter code herete in the editor. */ package loginpage;
import javax.swing.JOptionPane;
/** * * @author Parth */ public class NewJFrame extends javax.swing.JFrame {
/**
* Creates new form NewJFrame
*/
regidatabase1 db;
public NewJFrame() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
button1 = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
uname1 = new javax.swing.JTextField();
ppass1 = new javax.swing.JPasswordField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
fname = new javax.swing.JTextField();
lname = new javax.swing.JTextField();
uname = new javax.swing.JTextField();
ppass = new javax.swing.JPasswordField();
button = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel2.setText("UserName");
button1.setText("Login");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button1ActionPerformed(evt);
}
});
jLabel3.setText("PassWord");
jLabel4.setText("FirstName");
jLabel5.setText("LastName");
jLabel6.setText("PassWord");
jLabel7.setText("Username");
button.setText("Registration");
button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(85, 85, 85)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jLabel3,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel2,
javax.swing.GroupLayout.DEFAULT_SIZE, 58,
Short.MAX_VALUE)
.addComponent(jLabel4,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 58,
Short.MAX_VALUE)
.addComponent(jLabel5,
javax.swing.GroupLayout.DEFAULT_SIZE, 58,
Short.MAX_VALUE)
.addComponent(jLabel7,
javax.swing.GroupLayout.DEFAULT_SIZE, 58,
Short.MAX_VALUE)
.addComponent(jLabel6,
javax.swing.GroupLayout.DEFAULT_SIZE, 58,
Short.MAX_VALUE))
.addGap(74, 74, 74)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(uname1,
javax.swing.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE)
.addComponent(ppass1)
.addComponent(fname,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE)
.addComponent(lname,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE)
.addComponent(uname,
javax.swing.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE)
.addComponent(ppass,
javax.swing.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addGap(186, 186, 186)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(button)
.addComponent(button1))))
.addContainerGap(682, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(89, 89, 89)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(uname1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(ppass1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(button1)
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(fname,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lname,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(uname,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(38, 38, 38)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(ppass,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33)
.addComponent(button)
.addContainerGap(330, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(evt.getSource()==button1)
{
char[] temp_pwd1=ppass1.getPassword();
String pwd1;
pwd1=String.copyValueOf(temp_pwd1);
System.out.println("Username,Pwd:"+uname1.getText()+","+pwd1);
if(db.checkLogin(uname1.getText(),pwd1))
{
JOptionPane.showMessageDialog(null, "You have logged in
successfully","Success",
JOptionPane.INFORMATION_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(null, "Login failed!","Failed!!",
JOptionPane.ERROR_MESSAGE);
}
}
}
private void buttonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
/* if(evt.getSource()==button)
{
char[] temp_pwd=ppass.getPassword();
String pwd=null;
pwd=String.copyValueOf(temp_pwd);
System.out.println("fname,lname,uname,ppass:"+fname.getText()+","+lname.getText()+","+uname.getText()+","+pwd);
if(db.Registration(fname.getText(),
lname.getText(),uname.getText(),pwd))
{
JOptionPane.showMessageDialog(null, "Registratione
Successfully ","Success",
JOptionPane.INFORMATION_MESSAGE);
}
else
{
// int result = JOptionPane.showMessageDialog(null,
"Username exists","Failed!!",
// + JOptionPane.ERROR_MESSAGE);
int result = JOptionPane.showConfirmDialog(null, "Username
exists","Error", JOptionPane.OK_CANCEL_OPTION);
if (result == JOptionPane.OK_OPTION)
{
uname.setText("");
uname.requestFocus();
}
else if(result == JOptionPane.CANCEL_OPTION)
{
System.exit(0);
}
// JOptionPane.showMessageDialog(null, "Registration
Fail","Failed!!",
// + JOptionPane.ERROR_MESSAGE);
}
}*/
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting
code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the
default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton button;
private javax.swing.JButton button1;
private javax.swing.JTextField fname;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JTextField lname;
private javax.swing.JPasswordField ppass;
private javax.swing.JPasswordField ppass1;
private javax.swing.JTextField uname;
private javax.swing.JTextField uname1;
// End of variables declaration
}
and this is database program
/*
To change this template, choose Tools | Templates
and open the template in the editor.
*/
package loginpage;
import java.sql.; /* * * @author Parth */ public class regidatabase1 {
/**
* @param args the command line arguments
*/
Connection con;
PreparedStatement pst,pst1,pst2;
ResultSet rs;
regidatabase1()
{
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/ajax","root","parth");
pst=con.prepareStatement("select * from registrtion where uname=?
and pwd=password(?)");
pst1=con.prepareStatement("INSERT INTO registrtion"+
"(firstname,lastname,uname,pwd) VALUES"+ "(?,?,?,password(?))");
// pst1=con.prepareStatement("INSERT INTO registrtion"+
"(firstname,lastname,uname,pwd) VALUES"+ "(?,?,?,?)");
}
catch (Exception e)
{
System.out.println(e);
}
}
public Boolean checkLogin(String uname,String pwd)
{
try {
pst.setString(1, uname);
pst.setString(2, pwd);
rs=pst.executeQuery();
if(rs.next())
{
return true;
}
else
{
return false;
}
} catch (Exception e) {
System.out.println("error while validating"+e);
return false;
}
}
/*public Boolean Registration(String firstname,String lastname,String
uname,String pwd) { try {
pst1.setString(1, firstname);
pst1.setString(2, lastname);
pst1.setString(3, uname);
pst1.setString(4, pwd);
pst1.executeUpdate();
return true;
}
catch (Exception e) {
System.out.println("error while validating"+e);
return false;
}
}*/ }
plz help me this is gives me Runtime NullPointer exception.
Netbeans
there is a program for gui
/* * To change this template, choose Tools | Templates * and open the
templaenter code herete in the editor. */ package loginpage;
import javax.swing.JOptionPane;
/** * * @author Parth */ public class NewJFrame extends javax.swing.JFrame {
/**
* Creates new form NewJFrame
*/
regidatabase1 db;
public NewJFrame() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
button1 = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
uname1 = new javax.swing.JTextField();
ppass1 = new javax.swing.JPasswordField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
fname = new javax.swing.JTextField();
lname = new javax.swing.JTextField();
uname = new javax.swing.JTextField();
ppass = new javax.swing.JPasswordField();
button = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel2.setText("UserName");
button1.setText("Login");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button1ActionPerformed(evt);
}
});
jLabel3.setText("PassWord");
jLabel4.setText("FirstName");
jLabel5.setText("LastName");
jLabel6.setText("PassWord");
jLabel7.setText("Username");
button.setText("Registration");
button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(85, 85, 85)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jLabel3,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel2,
javax.swing.GroupLayout.DEFAULT_SIZE, 58,
Short.MAX_VALUE)
.addComponent(jLabel4,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 58,
Short.MAX_VALUE)
.addComponent(jLabel5,
javax.swing.GroupLayout.DEFAULT_SIZE, 58,
Short.MAX_VALUE)
.addComponent(jLabel7,
javax.swing.GroupLayout.DEFAULT_SIZE, 58,
Short.MAX_VALUE)
.addComponent(jLabel6,
javax.swing.GroupLayout.DEFAULT_SIZE, 58,
Short.MAX_VALUE))
.addGap(74, 74, 74)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(uname1,
javax.swing.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE)
.addComponent(ppass1)
.addComponent(fname,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE)
.addComponent(lname,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE)
.addComponent(uname,
javax.swing.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE)
.addComponent(ppass,
javax.swing.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addGap(186, 186, 186)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(button)
.addComponent(button1))))
.addContainerGap(682, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(89, 89, 89)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(uname1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(ppass1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(button1)
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(fname,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lname,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(uname,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(38, 38, 38)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(ppass,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33)
.addComponent(button)
.addContainerGap(330, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(evt.getSource()==button1)
{
char[] temp_pwd1=ppass1.getPassword();
String pwd1;
pwd1=String.copyValueOf(temp_pwd1);
System.out.println("Username,Pwd:"+uname1.getText()+","+pwd1);
if(db.checkLogin(uname1.getText(),pwd1))
{
JOptionPane.showMessageDialog(null, "You have logged in
successfully","Success",
JOptionPane.INFORMATION_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(null, "Login failed!","Failed!!",
JOptionPane.ERROR_MESSAGE);
}
}
}
private void buttonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
/* if(evt.getSource()==button)
{
char[] temp_pwd=ppass.getPassword();
String pwd=null;
pwd=String.copyValueOf(temp_pwd);
System.out.println("fname,lname,uname,ppass:"+fname.getText()+","+lname.getText()+","+uname.getText()+","+pwd);
if(db.Registration(fname.getText(),
lname.getText(),uname.getText(),pwd))
{
JOptionPane.showMessageDialog(null, "Registratione
Successfully ","Success",
JOptionPane.INFORMATION_MESSAGE);
}
else
{
// int result = JOptionPane.showMessageDialog(null,
"Username exists","Failed!!",
// + JOptionPane.ERROR_MESSAGE);
int result = JOptionPane.showConfirmDialog(null, "Username
exists","Error", JOptionPane.OK_CANCEL_OPTION);
if (result == JOptionPane.OK_OPTION)
{
uname.setText("");
uname.requestFocus();
}
else if(result == JOptionPane.CANCEL_OPTION)
{
System.exit(0);
}
// JOptionPane.showMessageDialog(null, "Registration
Fail","Failed!!",
// + JOptionPane.ERROR_MESSAGE);
}
}*/
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting
code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the
default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton button;
private javax.swing.JButton button1;
private javax.swing.JTextField fname;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JTextField lname;
private javax.swing.JPasswordField ppass;
private javax.swing.JPasswordField ppass1;
private javax.swing.JTextField uname;
private javax.swing.JTextField uname1;
// End of variables declaration
}
and this is database program
/*
To change this template, choose Tools | Templates
and open the template in the editor.
*/
package loginpage;
import java.sql.; /* * * @author Parth */ public class regidatabase1 {
/**
* @param args the command line arguments
*/
Connection con;
PreparedStatement pst,pst1,pst2;
ResultSet rs;
regidatabase1()
{
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/ajax","root","parth");
pst=con.prepareStatement("select * from registrtion where uname=?
and pwd=password(?)");
pst1=con.prepareStatement("INSERT INTO registrtion"+
"(firstname,lastname,uname,pwd) VALUES"+ "(?,?,?,password(?))");
// pst1=con.prepareStatement("INSERT INTO registrtion"+
"(firstname,lastname,uname,pwd) VALUES"+ "(?,?,?,?)");
}
catch (Exception e)
{
System.out.println(e);
}
}
public Boolean checkLogin(String uname,String pwd)
{
try {
pst.setString(1, uname);
pst.setString(2, pwd);
rs=pst.executeQuery();
if(rs.next())
{
return true;
}
else
{
return false;
}
} catch (Exception e) {
System.out.println("error while validating"+e);
return false;
}
}
/*public Boolean Registration(String firstname,String lastname,String
uname,String pwd) { try {
pst1.setString(1, firstname);
pst1.setString(2, lastname);
pst1.setString(3, uname);
pst1.setString(4, pwd);
pst1.executeUpdate();
return true;
}
catch (Exception e) {
System.out.println("error while validating"+e);
return false;
}
}*/ }
plz help me this is gives me Runtime NullPointer exception.
Extend onclick function to javascript class
Extend onclick function to javascript class
I'd like to include an onclick event in a JavaScript class, but since
onclick is a function inside of the class the this variable won't work
properly.
How can I modify/output the this variable from the onclick function?
img = new image();
function image() {
this.width = 400;
this.height = 600;
document.getElementById('button').onclick = function()
{
alert(this.width); // alerts undefined
};
}
See JSfiddle here: http://jsfiddle.net/ZghRv/
I'd like to include an onclick event in a JavaScript class, but since
onclick is a function inside of the class the this variable won't work
properly.
How can I modify/output the this variable from the onclick function?
img = new image();
function image() {
this.width = 400;
this.height = 600;
document.getElementById('button').onclick = function()
{
alert(this.width); // alerts undefined
};
}
See JSfiddle here: http://jsfiddle.net/ZghRv/
Change list-style onclick with JavaScript
Change list-style onclick with JavaScript
I'm trying to change the style of a list element on click to have a black
background with white text. When I click another one, I want it to return
to its base state of a white background and black text. The problem I'm
having is when I click the second list element, the first one retains the
style generated in the JS. This is not what I want.
Here's the HTML:
<ul class="menu">
<li>
<a href="#">Item One</a>
</li>
<li>
<a href="#">Item Two</a>
</li>
</ul>
And here's the JS
$('.menu > li > a').click(function(){
$(this).css({
'background-color': 'black',
'color': 'white'
});
$(this).siblings('.menu > li > a').css({
'background-color': 'white',
'color':'black'
});
});
I know I'm probably just targeting the wrong thing and I've tried multiple
ways, but I can't seem to figure it out. I think I have the parent,
children, and sibling tree mixed up too. Any help is greatly appreciated!
Here it is on JSFiddle
I'm trying to change the style of a list element on click to have a black
background with white text. When I click another one, I want it to return
to its base state of a white background and black text. The problem I'm
having is when I click the second list element, the first one retains the
style generated in the JS. This is not what I want.
Here's the HTML:
<ul class="menu">
<li>
<a href="#">Item One</a>
</li>
<li>
<a href="#">Item Two</a>
</li>
</ul>
And here's the JS
$('.menu > li > a').click(function(){
$(this).css({
'background-color': 'black',
'color': 'white'
});
$(this).siblings('.menu > li > a').css({
'background-color': 'white',
'color':'black'
});
});
I know I'm probably just targeting the wrong thing and I've tried multiple
ways, but I can't seem to figure it out. I think I have the parent,
children, and sibling tree mixed up too. Any help is greatly appreciated!
Here it is on JSFiddle
How do I interchange function doMouseDown() in HTML5 canvas
How do I interchange function doMouseDown() in HTML5 canvas
I am trying to create a painting game with HTML5 canvas.
I want the first button to call a function that draws a line when I click
on the canvas. I want the second button to call a function that draws a
circle when I click on the canvas.
I can build the game from there if I can figure out how to interchange
"function doMouseDown()".
It won't work for me.
Here is some of my code:
<head>
<meta charset="UTF-8">
<title>Home</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<style>
canvas
{
border: 2px solid black;
}
</style>
<script>
// the setup canvas function runs when the document is loaded.
var context;
function setupCanvas()
{
function initialise() {
var canvas =document.getElementById("myCanvas");
context = canvas.getContext("2d");
canvas.addEventListener("mousedown", doMouseDown, true);
var coordinateX;
var coordinateY;
}
function doMouseDown(event)
{
coordinateX= event.pageX;
coordinateY= event.pageY;
context.fillRect(coordinateX, coordinateY, 100, 100);
context.strokeRect(coordinateX, coordinateY, 100, 100);
}
function doMouseDown(event2)
{
coordinateX= event.pageX;
coordinateY= event.pageY;
context.beginPath();
context.arc(coordinateX, coordinateY, 150, 0, Math.PI, false);
context.stroke();
}
</script>
</head>
<body onload = "setupCanvas(); initialise()">
<canvas id="myCanvas" height='400' width='400'>
</canvas>
<p>
<input type="button" onclick="doMouseDown(event);" value="Line">
<input type="button" onclick="doMouseDown(event2);" value="Circle">
</p>
I am trying to create a painting game with HTML5 canvas.
I want the first button to call a function that draws a line when I click
on the canvas. I want the second button to call a function that draws a
circle when I click on the canvas.
I can build the game from there if I can figure out how to interchange
"function doMouseDown()".
It won't work for me.
Here is some of my code:
<head>
<meta charset="UTF-8">
<title>Home</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<style>
canvas
{
border: 2px solid black;
}
</style>
<script>
// the setup canvas function runs when the document is loaded.
var context;
function setupCanvas()
{
function initialise() {
var canvas =document.getElementById("myCanvas");
context = canvas.getContext("2d");
canvas.addEventListener("mousedown", doMouseDown, true);
var coordinateX;
var coordinateY;
}
function doMouseDown(event)
{
coordinateX= event.pageX;
coordinateY= event.pageY;
context.fillRect(coordinateX, coordinateY, 100, 100);
context.strokeRect(coordinateX, coordinateY, 100, 100);
}
function doMouseDown(event2)
{
coordinateX= event.pageX;
coordinateY= event.pageY;
context.beginPath();
context.arc(coordinateX, coordinateY, 150, 0, Math.PI, false);
context.stroke();
}
</script>
</head>
<body onload = "setupCanvas(); initialise()">
<canvas id="myCanvas" height='400' width='400'>
</canvas>
<p>
<input type="button" onclick="doMouseDown(event);" value="Line">
<input type="button" onclick="doMouseDown(event2);" value="Circle">
</p>
Remove iframe before load page
Remove iframe before load page
How do I remove an iframe before a page loads?
On my website I have users fill out a surveymonkey survey in an iframe.
Upon completion of the survey, surveymonkey redirects to a page in my
website domain. This new page is still trapped within the iframe; I want
the iframe removed before this new page is loaded. I tried the following
code, but this removes both the iframe AND the content of this new page I
want loaded, producing a blank screen:
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$('iframe', parent.document).remove();
});
</script>
</head>
</html>
<?php
//the content for the page I want loaded
?>
Any suggestions?
How do I remove an iframe before a page loads?
On my website I have users fill out a surveymonkey survey in an iframe.
Upon completion of the survey, surveymonkey redirects to a page in my
website domain. This new page is still trapped within the iframe; I want
the iframe removed before this new page is loaded. I tried the following
code, but this removes both the iframe AND the content of this new page I
want loaded, producing a blank screen:
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$('iframe', parent.document).remove();
});
</script>
</head>
</html>
<?php
//the content for the page I want loaded
?>
Any suggestions?
How to make menu, navbar nav-pills nav-stacked collapse Twitter-bootstrap 3.0
How to make menu, navbar nav-pills nav-stacked collapse Twitter-bootstrap 3.0
I have this code, I want to make this menu collapse for mobile-devices
<nav class="navigation">
<ul class="nav nav-pills nav-stacked" id="nav-menu">
<li class="active" ><a href="index.php">Domov</a></li>
<li><a href="#">Koncerty</a></li>
<li><a href="#">Shop</a></li>
<li><a href="#">Download</a></li>
<li><a href="#">Kontakty</a></li>
<li><a href="#">Troll</a></li>
</ul>
</nav>
check site here http://share.hardsun.eu/konflikt/
And I want to do this http://www.2i.sk/ff6a6b4192 Click to full resolution
image
I have this code, I want to make this menu collapse for mobile-devices
<nav class="navigation">
<ul class="nav nav-pills nav-stacked" id="nav-menu">
<li class="active" ><a href="index.php">Domov</a></li>
<li><a href="#">Koncerty</a></li>
<li><a href="#">Shop</a></li>
<li><a href="#">Download</a></li>
<li><a href="#">Kontakty</a></li>
<li><a href="#">Troll</a></li>
</ul>
</nav>
check site here http://share.hardsun.eu/konflikt/
And I want to do this http://www.2i.sk/ff6a6b4192 Click to full resolution
image
Sunday, September 15, 2013
Best way to store a value to query latest without de-nomalizing?
Best way to store a value to query latest without de-nomalizing?
This is the structure of my Table which stores meter readings for
machines. I need to save all readings so I can retrieve readings for any
date and validate any new readings.
I have an index on AssetID, ForDate Descending so the latest readings are
at the top.
It's taking too long to find the latest meter reading for a machine with
this table. I don't want to de-normalize the meter reading against the
Machine as it would cause concurrency issues when two or more people try
to enter readings at once.
Any suggestions to make this faster?
This is the structure of my Table which stores meter readings for
machines. I need to save all readings so I can retrieve readings for any
date and validate any new readings.
I have an index on AssetID, ForDate Descending so the latest readings are
at the top.
It's taking too long to find the latest meter reading for a machine with
this table. I don't want to de-normalize the meter reading against the
Machine as it would cause concurrency issues when two or more people try
to enter readings at once.
Any suggestions to make this faster?
Reason: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib
Reason: Incompatible library version: nokogiri.bundle requires version
11.0.0 or later, but libxml2.2.dylib
I'm getting this error when trying to run rspec in Hartl's tutorial. I've
googled the error, but its never for the specific version and the fixes
don't actually fix my problem. Any help would be appreciated.
Thanks
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in
`require': dlopen(/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-
1.6.0/lib/nokogiri/nokogiri.bundle, 9): Library not loaded:
/Users/Jimbo/.bundler/tmp/22862/gems/nokogiri-1.6.0/ports/i686-apple-
darwin11/libxml2/2.8.0/lib/libxml2.2.dylib (LoadError)
Referenced from: /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-
1.6.0/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version
11.0.0 or later, but libxml2.2.dylib provides version 10.0.0 -
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in
`<top (required)>'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.1.0/lib/capybara.rb:2:in
`require'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.1.0/lib/capybara.rb:2:in
`<top (required)>'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in
`require'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in
`block (2 levels) in require'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in
`each'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in
`block in require'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in
`each'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in
`require'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb:132:in
`require'
11.0.0 or later, but libxml2.2.dylib
I'm getting this error when trying to run rspec in Hartl's tutorial. I've
googled the error, but its never for the specific version and the fixes
don't actually fix my problem. Any help would be appreciated.
Thanks
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in
`require': dlopen(/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-
1.6.0/lib/nokogiri/nokogiri.bundle, 9): Library not loaded:
/Users/Jimbo/.bundler/tmp/22862/gems/nokogiri-1.6.0/ports/i686-apple-
darwin11/libxml2/2.8.0/lib/libxml2.2.dylib (LoadError)
Referenced from: /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-
1.6.0/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version
11.0.0 or later, but libxml2.2.dylib provides version 10.0.0 -
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in
`<top (required)>'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.1.0/lib/capybara.rb:2:in
`require'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.1.0/lib/capybara.rb:2:in
`<top (required)>'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in
`require'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in
`block (2 levels) in require'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in
`each'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in
`block in require'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in
`each'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in
`require'
from
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb:132:in
`require'
What are the basic differences and similarities between Angular js and Express js?
What are the basic differences and similarities between Angular js and
Express js?
So I am a bit confused in regards to the aim of Angular js vs Express js.
From my understanding we use Node.js to serve Angular js but we are not
entirely limited/forced to use Node.js for serving it. Express js on the
other hand seems like it accomplishes something similar to the more
traditional MVC framework.
So is Angular Js a type of non-server-specific MVC framework? and does
this limits Angular js backend server capabilities or ease of use?
Express js?
So I am a bit confused in regards to the aim of Angular js vs Express js.
From my understanding we use Node.js to serve Angular js but we are not
entirely limited/forced to use Node.js for serving it. Express js on the
other hand seems like it accomplishes something similar to the more
traditional MVC framework.
So is Angular Js a type of non-server-specific MVC framework? and does
this limits Angular js backend server capabilities or ease of use?
Facebook - cannot suscribe API key
Facebook - cannot suscribe API key
I didn't receive the confirmation number in SMS using the developper
account creation page. I've tried two different phone numbers and the SMS
is never received. Is there is any bug with SMS subscription system ?
Regards,
I didn't receive the confirmation number in SMS using the developper
account creation page. I've tried two different phone numbers and the SMS
is never received. Is there is any bug with SMS subscription system ?
Regards,
Symfony 2.3.4 NotFoundHttpException status 200 istead of 404 on prod
Symfony 2.3.4 NotFoundHttpException status 200 istead of 404 on prod
According to symfony2 documentation NotFoundHttpException should be
catched by framework and ultimately triggers a 404 response, but I'm just
getting fatal error (Uncaught exception) with status 200 on prod
environment. On dev environment i got 404. I'm using this:
throw $this->createNotFoundException();
I just want to display my customized 404 page. Am I doing something wrong?
According to symfony2 documentation NotFoundHttpException should be
catched by framework and ultimately triggers a 404 response, but I'm just
getting fatal error (Uncaught exception) with status 200 on prod
environment. On dev environment i got 404. I'm using this:
throw $this->createNotFoundException();
I just want to display my customized 404 page. Am I doing something wrong?
yii post a audio file and show CSRF token
yii post a audio file and show CSRF token
i want to post a form included a name text field and file as a sound file
(MP3 and etc.) but when i want to post it , i see an error about CSRF
token ... and when i remove encrypt in my form , i can save it ... i
exactly don't know , Why?
this is my code?
my MODLE:
<?php
class Radio extends CActiveRecord
{
public $id;
public $file;
public $name;
public $date;
public $addby;
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function tableName()
{
return '{{radio}}';
}
public function rules()
{
return array(
array('name', 'required' ),
array('name,date,addby,file', 'safe'),
array('file', 'file', 'types'=>'mp3,mp4','allowEmpty'=>true),
);
}
public function attributeLabels()
{
return array(
'name'=>'title',
'file'=>'sound file',
);
} }?>
This is my view :
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'Form_addvoice',
'htmlOptions' =>
array('class'=>'Margindownfrm','enctype'=>'multipart/form-data'),
'type'=>'horizontal',
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
));
echo $form->errorSummary($model);?>
<BR>enter code here
<?php echo $form->textFieldRow($model, 'name'); ?>
<?php echo $form->fileFieldRow($model, 'file'); ?>
<BR>
<div class="footer">
<?php $this->widget('bootstrap.widgets.TbButton',
array('buttonType'=>'submit', 'type'=>'primary', 'label'=>'save')); ?>
</div>
<?php $this->endWidget(); ?>
This is my controller:
public function actionChecklistAdd(){
$editid = (int) Yii::app()->getRequest()->getParam('eid',0);
if($editid == 0){
$checklist= new CheckList();
$params['type'] = 'new';
}else{
$checklist = CheckList::model()->findByPk($editid);
$params['type'] = 'update';
}
if(isset($_POST['CheckList'])){
$checklist->name = $_POST['CheckList']['name'];
$checklist->catid= $_POST['CheckList']['catid'];
if(isset($_POST['checklist'])){
$checklist->params = json_encode($_POST['checklist']);
}
if($checklist->validate() && $checklist->save()){
Yii::app()->user->setFlash('success','successed');
$this->redirect(Yii::app()->createUrl("main/checklistList"));
}else{
Yii::app()->user->setFlash('error',' show some error');
}
}
$params['checklist'] = $checklist;
$this->render('ChecklistAdd',$params);
}
thank you dudes ...
i want to post a form included a name text field and file as a sound file
(MP3 and etc.) but when i want to post it , i see an error about CSRF
token ... and when i remove encrypt in my form , i can save it ... i
exactly don't know , Why?
this is my code?
my MODLE:
<?php
class Radio extends CActiveRecord
{
public $id;
public $file;
public $name;
public $date;
public $addby;
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function tableName()
{
return '{{radio}}';
}
public function rules()
{
return array(
array('name', 'required' ),
array('name,date,addby,file', 'safe'),
array('file', 'file', 'types'=>'mp3,mp4','allowEmpty'=>true),
);
}
public function attributeLabels()
{
return array(
'name'=>'title',
'file'=>'sound file',
);
} }?>
This is my view :
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'Form_addvoice',
'htmlOptions' =>
array('class'=>'Margindownfrm','enctype'=>'multipart/form-data'),
'type'=>'horizontal',
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
));
echo $form->errorSummary($model);?>
<BR>enter code here
<?php echo $form->textFieldRow($model, 'name'); ?>
<?php echo $form->fileFieldRow($model, 'file'); ?>
<BR>
<div class="footer">
<?php $this->widget('bootstrap.widgets.TbButton',
array('buttonType'=>'submit', 'type'=>'primary', 'label'=>'save')); ?>
</div>
<?php $this->endWidget(); ?>
This is my controller:
public function actionChecklistAdd(){
$editid = (int) Yii::app()->getRequest()->getParam('eid',0);
if($editid == 0){
$checklist= new CheckList();
$params['type'] = 'new';
}else{
$checklist = CheckList::model()->findByPk($editid);
$params['type'] = 'update';
}
if(isset($_POST['CheckList'])){
$checklist->name = $_POST['CheckList']['name'];
$checklist->catid= $_POST['CheckList']['catid'];
if(isset($_POST['checklist'])){
$checklist->params = json_encode($_POST['checklist']);
}
if($checklist->validate() && $checklist->save()){
Yii::app()->user->setFlash('success','successed');
$this->redirect(Yii::app()->createUrl("main/checklistList"));
}else{
Yii::app()->user->setFlash('error',' show some error');
}
}
$params['checklist'] = $checklist;
$this->render('ChecklistAdd',$params);
}
thank you dudes ...
Can I use Hichart with https url?
Can I use Hichart with https url?
Please need to make sure that Highchart can be integrated with https url.
Application runs on https. I can integrate with http but can not with
https.
Please need to make sure that Highchart can be integrated with https url.
Application runs on https. I can integrate with http but can not with
https.
Saturday, September 14, 2013
Data Transfer from NFC app to PN532 reader
Data Transfer from NFC app to PN532 reader
i m working on final year project of nfc based payment , i m stucked here
coz i read on net that you cant transfer data (say credit card details)
from NFC phone to PN532 reader ..i read about P2P mode to transfer data
but i m not getting an exact idea how to do that..is any method to
transfer card details from Phone Application to NFC reader?? i m just at
the starting of the project , currently i m gathering all infos regarding
my project! but i cant transfer data from phone to reader then my project
would fail!
Hope someone can help!
i m working on final year project of nfc based payment , i m stucked here
coz i read on net that you cant transfer data (say credit card details)
from NFC phone to PN532 reader ..i read about P2P mode to transfer data
but i m not getting an exact idea how to do that..is any method to
transfer card details from Phone Application to NFC reader?? i m just at
the starting of the project , currently i m gathering all infos regarding
my project! but i cant transfer data from phone to reader then my project
would fail!
Hope someone can help!
refinery cms integration devise helper
refinery cms integration devise helper
refinerycms integration into an app which has contains a devise as user
authentication system is done, but I encounter a problem.
I mount the refinery engine in my routes.rb: mount Refinery::Core::Engine,
:at => '/blogs'
My application has header with new_user_session_path and
new_user_registration_path or destroy_user_session_path for all the pages,
also for the refinery pages. I got an undefined local variable or method
"new_user_session_path" for #<#<Class:0x007f9a686c8388>:0x007f9a686d29f0>
error when open refinery pageshttp://localhost:3000/blogs.
After find some discussion in google groups, I follow the suggestion add
main_app prefix in devise path, it works! I can open the refinery
homepage. but a new issue comes out when I open
http://localhost:3000/blogs/refinery: ``` NoMethodError in
Refinery::Admin::DashboardController#index
undefined method `signup_path' for #
```
I have no idea how to handle this, any suggestion will be appreciated!
PS: I had followed the instruction in with-an-existing-rails-31-devise-app
and added refinery_patch .rb restrict_refinery_to_refinery_users.rb into
lib/refinery and then loaded it in application.rb. it says "it will just
consist in telling refinery to use your devise helpers" but not working!
refinerycms integration into an app which has contains a devise as user
authentication system is done, but I encounter a problem.
I mount the refinery engine in my routes.rb: mount Refinery::Core::Engine,
:at => '/blogs'
My application has header with new_user_session_path and
new_user_registration_path or destroy_user_session_path for all the pages,
also for the refinery pages. I got an undefined local variable or method
"new_user_session_path" for #<#<Class:0x007f9a686c8388>:0x007f9a686d29f0>
error when open refinery pageshttp://localhost:3000/blogs.
After find some discussion in google groups, I follow the suggestion add
main_app prefix in devise path, it works! I can open the refinery
homepage. but a new issue comes out when I open
http://localhost:3000/blogs/refinery: ``` NoMethodError in
Refinery::Admin::DashboardController#index
undefined method `signup_path' for #
```
I have no idea how to handle this, any suggestion will be appreciated!
PS: I had followed the instruction in with-an-existing-rails-31-devise-app
and added refinery_patch .rb restrict_refinery_to_refinery_users.rb into
lib/refinery and then loaded it in application.rb. it says "it will just
consist in telling refinery to use your devise helpers" but not working!
Quotes won't work while updating MySQL table from HTML form using PHP
Quotes won't work while updating MySQL table from HTML form using PHP
Normally I insert a value (first name and last name in this case) to the
database using this form:
<form action="" method="post">
First name<br><input type="text" name="fname">
Last name: <br><input type="text" name="lname">
<input type="submit">
</form>
Now I want to edit the table. Retrieving the values (first name and last
name) and puts it to the next form like this:
<form action="" method="post">
First name<br><input type="text" name="fname"
value="'.$user['username'].'">
Last name: <br><input type="text" name="lname"
value="'.$user['password'].'">
<input type="submit">
</form>
But when I do it this way I can't use double quotes in the text fields. I
can use it when I insert the value to the database, but not when I want to
update the value from a form. It just cuts/end the string at the first
double quote sign..
How do you build a user friendly interface to edit their data in the table?
Btw, I use PDO to select, insert and update the table.
Thanks in advance.
Normally I insert a value (first name and last name in this case) to the
database using this form:
<form action="" method="post">
First name<br><input type="text" name="fname">
Last name: <br><input type="text" name="lname">
<input type="submit">
</form>
Now I want to edit the table. Retrieving the values (first name and last
name) and puts it to the next form like this:
<form action="" method="post">
First name<br><input type="text" name="fname"
value="'.$user['username'].'">
Last name: <br><input type="text" name="lname"
value="'.$user['password'].'">
<input type="submit">
</form>
But when I do it this way I can't use double quotes in the text fields. I
can use it when I insert the value to the database, but not when I want to
update the value from a form. It just cuts/end the string at the first
double quote sign..
How do you build a user friendly interface to edit their data in the table?
Btw, I use PDO to select, insert and update the table.
Thanks in advance.
Unable to uninstall Vagrant entirely
Unable to uninstall Vagrant entirely
Even after deleting C:/users/.vagrant.d and uninstalling Vagrant... then
rebooting and installing again throws these errors at me:
I don't want to run a registry cleaner over my computer, since it makes my
computer unstable.
Where are more leftover vagrant installation files? How can I install
Vagrant from scratch?
Even after deleting C:/users/.vagrant.d and uninstalling Vagrant... then
rebooting and installing again throws these errors at me:
I don't want to run a registry cleaner over my computer, since it makes my
computer unstable.
Where are more leftover vagrant installation files? How can I install
Vagrant from scratch?
Deleted _percolator index and need to recover
Deleted _percolator index and need to recover
We need to clear all of queries from our _percolator index and then
re-index new queries. I deleted the index thinking that when I indexed the
new queries it would just auto-create the index and everything would be
fine.
But now when I try to index into _percolate, I get an exception
org.elasticsearch.indices.IndexMissingException: [_percolator] missing
How can I recover from this? Can I recover from this?
We need to clear all of queries from our _percolator index and then
re-index new queries. I deleted the index thinking that when I indexed the
new queries it would just auto-create the index and everything would be
fine.
But now when I try to index into _percolate, I get an exception
org.elasticsearch.indices.IndexMissingException: [_percolator] missing
How can I recover from this? Can I recover from this?
How to create canvas shapes
How to create canvas shapes
This is my code.I have to create canvas in a circle shape.
i am applying css in line code using canvas get context. i have tried but
nothing shows right.
if(shap=="circle")
{
var elementID = 'canvas' + $('canvas').length;
$('<canvas>').attr({
id: elementID
}).css({
width:1200,
height:600
}).appendTo('#work_area');
var canvas = document.getElementById(elementID);
var ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.arc(100,75,50,0,2*Math.PI);
ctx.stroke();
}
This is my code.I have to create canvas in a circle shape.
i am applying css in line code using canvas get context. i have tried but
nothing shows right.
if(shap=="circle")
{
var elementID = 'canvas' + $('canvas').length;
$('<canvas>').attr({
id: elementID
}).css({
width:1200,
height:600
}).appendTo('#work_area');
var canvas = document.getElementById(elementID);
var ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.arc(100,75,50,0,2*Math.PI);
ctx.stroke();
}
I need JTextField to be editable after calling requestFocus() on it's parent container
I need JTextField to be editable after calling requestFocus() on it's
parent container
I have the following window. I need to be able to edit the text when I
click on the JTextField.
Explanation: JTextField is inside a JComponent called PriorityPanel. When
I click on JTextField, it calls this.requestFocus(); meaning that the
PriorityPanel will gain focus. This way I am still able to modify the
value of JSLider, but not the text.
The described problem is in this part:
//constructor
public PriorityPanel(Priority p, int row) {
this.Slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 100);
this.model = p;
this.rowName = row;
this.TextField = new JTextField(model.getTitle());
setLayout(new GridLayout(1, 2));
add(TextField);
add(Slider);
addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
TextField.setBackground(new Color(220, 220, 255));
Slider.setBackground(new Color(220, 220, 255));
JPriorityEditor.this.selectedRow = rowName;
}
@Override
public void focusLost(FocusEvent e) {
TextField.setBackground(Color.WHITE);
Slider.setBackground(Color.WHITE);
}
});
Slider.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
requestFocus();
}
});
TextField.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
requestFocus();
}
});
//atc
}
Here is the SSCCE:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import static test.Priority.staticPriorities;
class Main{
public static void main(String[] args) {
staticPriorities.add(new Priority("AutoGen1"));
staticPriorities.add(new Priority("AutoGen2"));
GridBagConstraints gbc = new GridBagConstraints();
JPanel panelAll = new JPanel(new GridBagLayout());
JPanel panelBottom = new JPanel(new GridLayout(1,2));
JButton buttonNew = new JButton("buttonNew");
JButton buttonRemove = new JButton("buttonErase");
final JPriorityEditor priorityEditor = new JPriorityEditor();
//Add to panelBottom
panelBottom.add(buttonNew);
panelBottom.add(buttonRemove);
//Add to panelAll
gbc.weightx = 1;
gbc.weighty = 1;
gbc.fill = GridBagConstraints.BOTH;
panelAll.add(priorityEditor, gbc);
gbc.weighty = 0;
gbc.gridy = 1;
panelAll.add(panelBottom, gbc);
buttonNew.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
priorityEditor.AddNewPriority();
}
});
buttonRemove.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
priorityEditor.RemovePriority();
}
});
JFrame d = new JFrame("windowPrioritiesTitle");
d.add(panelAll, BorderLayout.CENTER);
d.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
d.pack();
d.setMinimumSize(d.getSize());
d.setLocationRelativeTo(null);
d.setVisible(true);
}
}
/**
* This is only an object
* @author Daniel
*/
class Priority {
public static ArrayList<Priority> staticPriorities = new ArrayList<>();
private String Title;
private int Percent;
public Priority(String title) {
this.Title = title;
int sum = 0;
for (Priority p : staticPriorities) {
sum += p.Percent;
}
this.Percent = 100 - sum;
}
public String getTitle() {
return Title;
}
public void setTitle(String title) {
this.Title = title;
}
public int getPercent() {
return Percent;
}
public void setPercent(int newValue) {
this.Percent = newValue;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Priority) {
return ((Priority) obj).getTitle().equals(this.getTitle());
} else {
return false;
}
}
}
/**
* My own component
*/
public final class JPriorityEditor extends JScrollPane {
private PriorityPanel[] priorityPanels;
private int selectedRow;
private JPanel con;
public JPriorityEditor() {
super(new JPanel());
this.selectedRow = -1;
ArrayList<Priority> Priorities = Priority.staticPriorities;
priorityPanels = new PriorityPanel[Priorities.size()];
this.con = (JPanel) getViewport().getView();
con.setLayout(new GridBagLayout());
con.setBackground(Color.WHITE);
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
int i = 0;
for (; i < Priorities.size(); i++) {
gbc.gridy = i;
priorityPanels[i] = new PriorityPanel(Priorities.get(i), i);
con.add(priorityPanels[i], gbc);
}
gbc.weighty = 1;
gbc.gridy = i;
con.add(new JComponent(){},gbc);
}
public void AddNewPriority(){
con.removeAll();
Priority p = new Priority("NewTitle");
Priority.staticPriorities.add(p);
ArrayList<Priority> Priorities = Priority.staticPriorities;
priorityPanels = new PriorityPanel[Priorities.size()];
con.setLayout(new GridBagLayout());
con.setBackground(Color.WHITE);
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
int i = 0;
for (; i < Priorities.size(); i++) {
gbc.gridy = i;
priorityPanels[i] = new PriorityPanel(Priorities.get(i), i);
con.add(priorityPanels[i], gbc);
}
gbc.weighty = 1;
gbc.gridy = i;
con.add(new JComponent() {
}, gbc);
con.updateUI();
}
public void RemovePriority() {
if (selectedRow != -1) {
Priority.staticPriorities.remove(Priority.staticPriorities.get(selectedRow));
con.removeAll();
ArrayList<Priority> Priorities = Priority.staticPriorities;
priorityPanels = new PriorityPanel[Priorities.size()];
con.setLayout(new GridBagLayout());
con.setBackground(Color.WHITE);
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
int i = 0;
for (; i < Priorities.size(); i++) {
gbc.gridy = i;
priorityPanels[i] = new PriorityPanel(Priorities.get(i), i);
con.add(priorityPanels[i], gbc);
}
gbc.weighty = 1;
gbc.gridy = i;
con.add(new JComponent() {
}, gbc);
con.updateUI();
}
}
/**
* Another custom component
*/
private class PriorityPanel extends JComponent {
int rowName;
JSlider Slider;
JTextField TextField;
Priority model;
public PriorityPanel(Priority p, int row) {
this.Slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 100);
this.model = p;
this.rowName = row;
this.TextField = new JTextField(model.getTitle());
setLayout(new GridLayout(1, 2));
add(TextField);
add(Slider);
addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
TextField.setBackground(new Color(220, 220, 255));
Slider.setBackground(new Color(220, 220, 255));
JPriorityEditor.this.selectedRow = rowName;
}
@Override
public void focusLost(FocusEvent e) {
TextField.setBackground(Color.WHITE);
Slider.setBackground(Color.WHITE);
}
});
Slider.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
requestFocus();
}
});
TextField.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
requestFocus();
}
});
Slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int value = Slider.getValue();
model.setPercent(value);
}
});
TextField.getDocument().addDocumentListener(new
DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
SetText();
}
@Override
public void removeUpdate(DocumentEvent e) {
SetText();
}
@Override
public void changedUpdate(DocumentEvent e) {
SetText();
}
private void SetText() {
model.setTitle(TextField.getText());
}
});
}
}
}
parent container
I have the following window. I need to be able to edit the text when I
click on the JTextField.
Explanation: JTextField is inside a JComponent called PriorityPanel. When
I click on JTextField, it calls this.requestFocus(); meaning that the
PriorityPanel will gain focus. This way I am still able to modify the
value of JSLider, but not the text.
The described problem is in this part:
//constructor
public PriorityPanel(Priority p, int row) {
this.Slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 100);
this.model = p;
this.rowName = row;
this.TextField = new JTextField(model.getTitle());
setLayout(new GridLayout(1, 2));
add(TextField);
add(Slider);
addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
TextField.setBackground(new Color(220, 220, 255));
Slider.setBackground(new Color(220, 220, 255));
JPriorityEditor.this.selectedRow = rowName;
}
@Override
public void focusLost(FocusEvent e) {
TextField.setBackground(Color.WHITE);
Slider.setBackground(Color.WHITE);
}
});
Slider.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
requestFocus();
}
});
TextField.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
requestFocus();
}
});
//atc
}
Here is the SSCCE:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import static test.Priority.staticPriorities;
class Main{
public static void main(String[] args) {
staticPriorities.add(new Priority("AutoGen1"));
staticPriorities.add(new Priority("AutoGen2"));
GridBagConstraints gbc = new GridBagConstraints();
JPanel panelAll = new JPanel(new GridBagLayout());
JPanel panelBottom = new JPanel(new GridLayout(1,2));
JButton buttonNew = new JButton("buttonNew");
JButton buttonRemove = new JButton("buttonErase");
final JPriorityEditor priorityEditor = new JPriorityEditor();
//Add to panelBottom
panelBottom.add(buttonNew);
panelBottom.add(buttonRemove);
//Add to panelAll
gbc.weightx = 1;
gbc.weighty = 1;
gbc.fill = GridBagConstraints.BOTH;
panelAll.add(priorityEditor, gbc);
gbc.weighty = 0;
gbc.gridy = 1;
panelAll.add(panelBottom, gbc);
buttonNew.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
priorityEditor.AddNewPriority();
}
});
buttonRemove.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
priorityEditor.RemovePriority();
}
});
JFrame d = new JFrame("windowPrioritiesTitle");
d.add(panelAll, BorderLayout.CENTER);
d.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
d.pack();
d.setMinimumSize(d.getSize());
d.setLocationRelativeTo(null);
d.setVisible(true);
}
}
/**
* This is only an object
* @author Daniel
*/
class Priority {
public static ArrayList<Priority> staticPriorities = new ArrayList<>();
private String Title;
private int Percent;
public Priority(String title) {
this.Title = title;
int sum = 0;
for (Priority p : staticPriorities) {
sum += p.Percent;
}
this.Percent = 100 - sum;
}
public String getTitle() {
return Title;
}
public void setTitle(String title) {
this.Title = title;
}
public int getPercent() {
return Percent;
}
public void setPercent(int newValue) {
this.Percent = newValue;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Priority) {
return ((Priority) obj).getTitle().equals(this.getTitle());
} else {
return false;
}
}
}
/**
* My own component
*/
public final class JPriorityEditor extends JScrollPane {
private PriorityPanel[] priorityPanels;
private int selectedRow;
private JPanel con;
public JPriorityEditor() {
super(new JPanel());
this.selectedRow = -1;
ArrayList<Priority> Priorities = Priority.staticPriorities;
priorityPanels = new PriorityPanel[Priorities.size()];
this.con = (JPanel) getViewport().getView();
con.setLayout(new GridBagLayout());
con.setBackground(Color.WHITE);
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
int i = 0;
for (; i < Priorities.size(); i++) {
gbc.gridy = i;
priorityPanels[i] = new PriorityPanel(Priorities.get(i), i);
con.add(priorityPanels[i], gbc);
}
gbc.weighty = 1;
gbc.gridy = i;
con.add(new JComponent(){},gbc);
}
public void AddNewPriority(){
con.removeAll();
Priority p = new Priority("NewTitle");
Priority.staticPriorities.add(p);
ArrayList<Priority> Priorities = Priority.staticPriorities;
priorityPanels = new PriorityPanel[Priorities.size()];
con.setLayout(new GridBagLayout());
con.setBackground(Color.WHITE);
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
int i = 0;
for (; i < Priorities.size(); i++) {
gbc.gridy = i;
priorityPanels[i] = new PriorityPanel(Priorities.get(i), i);
con.add(priorityPanels[i], gbc);
}
gbc.weighty = 1;
gbc.gridy = i;
con.add(new JComponent() {
}, gbc);
con.updateUI();
}
public void RemovePriority() {
if (selectedRow != -1) {
Priority.staticPriorities.remove(Priority.staticPriorities.get(selectedRow));
con.removeAll();
ArrayList<Priority> Priorities = Priority.staticPriorities;
priorityPanels = new PriorityPanel[Priorities.size()];
con.setLayout(new GridBagLayout());
con.setBackground(Color.WHITE);
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
int i = 0;
for (; i < Priorities.size(); i++) {
gbc.gridy = i;
priorityPanels[i] = new PriorityPanel(Priorities.get(i), i);
con.add(priorityPanels[i], gbc);
}
gbc.weighty = 1;
gbc.gridy = i;
con.add(new JComponent() {
}, gbc);
con.updateUI();
}
}
/**
* Another custom component
*/
private class PriorityPanel extends JComponent {
int rowName;
JSlider Slider;
JTextField TextField;
Priority model;
public PriorityPanel(Priority p, int row) {
this.Slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 100);
this.model = p;
this.rowName = row;
this.TextField = new JTextField(model.getTitle());
setLayout(new GridLayout(1, 2));
add(TextField);
add(Slider);
addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
TextField.setBackground(new Color(220, 220, 255));
Slider.setBackground(new Color(220, 220, 255));
JPriorityEditor.this.selectedRow = rowName;
}
@Override
public void focusLost(FocusEvent e) {
TextField.setBackground(Color.WHITE);
Slider.setBackground(Color.WHITE);
}
});
Slider.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
requestFocus();
}
});
TextField.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
requestFocus();
}
});
Slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int value = Slider.getValue();
model.setPercent(value);
}
});
TextField.getDocument().addDocumentListener(new
DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
SetText();
}
@Override
public void removeUpdate(DocumentEvent e) {
SetText();
}
@Override
public void changedUpdate(DocumentEvent e) {
SetText();
}
private void SetText() {
model.setTitle(TextField.getText());
}
});
}
}
}
playing sound on andriod with looping and pasue it when user rised an event like touch-pressed
playing sound on andriod with looping and pasue it when user rised an
event like touch-pressed
i want to play a sound (defult-ringtone or sample sound on the Raw folder)
with looping. Actually I want to play a sound in every phone mode(silent,
... ) and with a key pressed or other events the ringtone stop working. I
searched and found some methods like Media Player or Ringtone but I
couldn't satisfy my need. any comment will be appreciated.
Thanks in advance
event like touch-pressed
i want to play a sound (defult-ringtone or sample sound on the Raw folder)
with looping. Actually I want to play a sound in every phone mode(silent,
... ) and with a key pressed or other events the ringtone stop working. I
searched and found some methods like Media Player or Ringtone but I
couldn't satisfy my need. any comment will be appreciated.
Thanks in advance
Friday, September 13, 2013
Understanding C++ String Concatenation
Understanding C++ String Concatenation
In C++, I'm trying to understand why you don't get an error when you
construct a string like this:
const string hello = "Hello";
const string message = hello + ", world" + "!";
But you do get a compile time error with this:
const string exclam = "!";
const string msg = "Hello" + ", world" + exclam
Compile time error is:
main.cpp:10:33: error: invalid operands of types 'const char [6]' and
'const char [8]' to binary 'operator+'
Why is the first run fine but the second produce a compile time Error?
In C++, I'm trying to understand why you don't get an error when you
construct a string like this:
const string hello = "Hello";
const string message = hello + ", world" + "!";
But you do get a compile time error with this:
const string exclam = "!";
const string msg = "Hello" + ", world" + exclam
Compile time error is:
main.cpp:10:33: error: invalid operands of types 'const char [6]' and
'const char [8]' to binary 'operator+'
Why is the first run fine but the second produce a compile time Error?
What syntax is for (var i = 0, item; item = a[i++];)
What syntax is for (var i = 0, item; item = a[i++];)
In the Re-Introduction to Javascript, the syntax
for (var i = 0, item; item = a[i++];)
is explained as the middle "item" being a conditional test for
truthtiness/falsiness. However, I had assumed the syntax to be (start;
condition test; control factor) with semi-colons between each segment.
Here, the syntax is unfamiliar to me in the form (start, condition test;
control factor;) with a comma in the middle and semicolon at the very end.
Is it equivalent to
for (var i = 0; item; item = a[i++])
?
If so, why write it using comma and semicolon at the end?
In the Re-Introduction to Javascript, the syntax
for (var i = 0, item; item = a[i++];)
is explained as the middle "item" being a conditional test for
truthtiness/falsiness. However, I had assumed the syntax to be (start;
condition test; control factor) with semi-colons between each segment.
Here, the syntax is unfamiliar to me in the form (start, condition test;
control factor;) with a comma in the middle and semicolon at the very end.
Is it equivalent to
for (var i = 0; item; item = a[i++])
?
If so, why write it using comma and semicolon at the end?
Why am I getting a "the name does not exist in the current context" error on this C# program?
Why am I getting a "the name does not exist in the current context" error
on this C# program?
//Author:
//Date Created: Monday, September 9, 2013
//This is the tester class for the project for Exercise 8 in Chapter 4.
//Statement of Authenticity:
//I certify that all work in this assignment has been completed by me...
//Signed by:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Exercise8
{
class Park
{
Park aPark = new Park();
private string name;
public string Name
{
get
{
name = Console.ReadLine();
return name;
}
set
{
}
}
private string location;
public string Location
{
get
{
location = Console.ReadLine();
return location;
}
set
{
}
}
private string facilityType;
public string FacilityType
{
get
{
facilityType = Console.ReadLine();
return facilityType;
}
set
{
}
}
private string facilitiesAvailable;
public string FacilitiesAvailable
{
get
{
facilitiesAvailable = Console.ReadLine();
return facilitiesAvailable;
}
set
{
}
}
private double fee;
public string sFee;
public double Fee
{
get
{
fee = double.Parse(sFee);
sFee = Console.ReadLine();
return fee;
}
set
{
}
}
private int noOfEmployees;
public string sNoOfEmployees;
public int NoOfEmployees
{
get
{
noOfEmployees = int.Parse(sNoOfEmployees);
sNoOfEmployees = Console.ReadLine();
return noOfEmployees;
}
set
{
}
}
//variables for Cost Per Visitor.
//noVisitors will be used in Calculate Revenue
public double costPerVisitor;
public double annualBudget = 200000;
public double noVisitors = 10000;
public double CalculateCostPerVisitor(double annualBudget, double
noOfVisitors)
{
//divide annual budget by number of visitors
return costPerVisitor = annualBudget / noVisitors;
}
//Calculate Revenue
public double revenue;
public double CalculateRevenue(double noOfVisitors,double fee)
{
//No of Visitors times Fee
revenue = noVisitors * fee;
return revenue;
}
public override string ToString()
{
return "Name of park: " + this.Name + "\nLocation: " +
this.Location + "\nFacility Type: " + this.FacilityType +
"\nFacility Fee: " + this.Fee + "\nNumber of employees: " +
this.NoOfEmployees +
"\nNumber of visitors recorded in the past 12 months: " +
this.noVisitors + "Annual Budget: " + this.annualBudget;
}
}
}
Error 1 The name 'CalculateCostPerVisitor' does not exist in the current
context line 36 column 61 Exercise8
Error 2 The name 'CalculateRevenue' does not exist in the current context
line 38 column 45 Exercise8
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Exercise8
{
class Program
{
public static void main (String [] args)
{
//Instantiate Objects
Park aPark = new Park();
//Call Methods
Console.WriteLine("Name of park: " + aPark.Name + "; Location
of park: " + aPark.Location + "; Type of park: " +
aPark.FacilityType);
Console.WriteLine("Name of park: " + aPark.Name + "; Location
of park: " + aPark.Location + "; Facilities available: " +
aPark.FacilitiesAvailable);
Console.WriteLine("Annual cost per visitor: " +
CalculateCostPerVisitor());
Console.WriteLine("Revenue: " + CalculateRevenue());
//Below should hopefully return To String
Console.WriteLine(aPark.ToString());
}
}
}
on this C# program?
//Author:
//Date Created: Monday, September 9, 2013
//This is the tester class for the project for Exercise 8 in Chapter 4.
//Statement of Authenticity:
//I certify that all work in this assignment has been completed by me...
//Signed by:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Exercise8
{
class Park
{
Park aPark = new Park();
private string name;
public string Name
{
get
{
name = Console.ReadLine();
return name;
}
set
{
}
}
private string location;
public string Location
{
get
{
location = Console.ReadLine();
return location;
}
set
{
}
}
private string facilityType;
public string FacilityType
{
get
{
facilityType = Console.ReadLine();
return facilityType;
}
set
{
}
}
private string facilitiesAvailable;
public string FacilitiesAvailable
{
get
{
facilitiesAvailable = Console.ReadLine();
return facilitiesAvailable;
}
set
{
}
}
private double fee;
public string sFee;
public double Fee
{
get
{
fee = double.Parse(sFee);
sFee = Console.ReadLine();
return fee;
}
set
{
}
}
private int noOfEmployees;
public string sNoOfEmployees;
public int NoOfEmployees
{
get
{
noOfEmployees = int.Parse(sNoOfEmployees);
sNoOfEmployees = Console.ReadLine();
return noOfEmployees;
}
set
{
}
}
//variables for Cost Per Visitor.
//noVisitors will be used in Calculate Revenue
public double costPerVisitor;
public double annualBudget = 200000;
public double noVisitors = 10000;
public double CalculateCostPerVisitor(double annualBudget, double
noOfVisitors)
{
//divide annual budget by number of visitors
return costPerVisitor = annualBudget / noVisitors;
}
//Calculate Revenue
public double revenue;
public double CalculateRevenue(double noOfVisitors,double fee)
{
//No of Visitors times Fee
revenue = noVisitors * fee;
return revenue;
}
public override string ToString()
{
return "Name of park: " + this.Name + "\nLocation: " +
this.Location + "\nFacility Type: " + this.FacilityType +
"\nFacility Fee: " + this.Fee + "\nNumber of employees: " +
this.NoOfEmployees +
"\nNumber of visitors recorded in the past 12 months: " +
this.noVisitors + "Annual Budget: " + this.annualBudget;
}
}
}
Error 1 The name 'CalculateCostPerVisitor' does not exist in the current
context line 36 column 61 Exercise8
Error 2 The name 'CalculateRevenue' does not exist in the current context
line 38 column 45 Exercise8
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Exercise8
{
class Program
{
public static void main (String [] args)
{
//Instantiate Objects
Park aPark = new Park();
//Call Methods
Console.WriteLine("Name of park: " + aPark.Name + "; Location
of park: " + aPark.Location + "; Type of park: " +
aPark.FacilityType);
Console.WriteLine("Name of park: " + aPark.Name + "; Location
of park: " + aPark.Location + "; Facilities available: " +
aPark.FacilitiesAvailable);
Console.WriteLine("Annual cost per visitor: " +
CalculateCostPerVisitor());
Console.WriteLine("Revenue: " + CalculateRevenue());
//Below should hopefully return To String
Console.WriteLine(aPark.ToString());
}
}
}
jquery triggerhandler not being called
jquery triggerhandler not being called
the trigger below never call. The alert on call never pop up. It was
triggered by these statements. See second block.
$('#sCart').trigger('add', { stock_id: stock_id
$('#sCart').on('add', function(event, data) {
alert('on add');
$.ajax({
url: '$subCartUpdate'.replace('$tokenHolder', Math.random()),
type: 'GET',
dataType: 'json',
beforeSend: function(jqXHR) {
jqXHR.setRequestHeader('if-Modified-Since', '0');
},
success: function(success, statusText, jqXHR) {
alert(statusText);
$('#sCart').trigger('clear');
$('#sCart').html(success.subCart);
if(timerId === null) {
$('#sCart').queue('add', function() {
$(this).fadeIn(function() {
$(this).dequeue('add');
});
});
} else {
clearTimeout(timerId);
}
timerId = setTimeout(function() {
$('#sCart').fadeOut();
timerId = null;
}, 7000);
$('#sCart').queue('add', function() {
var updatedItemSelector = '#stock_'+data.stock_id;
var updatedItem = $(updatedItemSelector).fadeOut(500);
updatedItem.fadeIn(2000, function() {
$(this).dequeue('add');
});
});
if(success.reservedTimeStamp) {
$('#sCartTimer').trigger('start', {timer:
success.reservedTimeStamp});
}
$('#sCart').dequeue('add');
},
error: function(jqXHR, statusText, errors) {
var i = 0;
}
});
});
It was triggered from code below.
$.ajax({
url: '$addUrl',
type: 'POST',
data: {
id: stock_id,
amount: amount
},
success: function(success, statusText, jqXHR) {
alert(statusText);
if(success.reload) {
location.reload(true);
} else if(success.redirect) {
location.href = success.redirect;
} else {
$('#sCart').trigger('add', {
stock_id: stock_id
});
$('.product-amount').val(1);
//$('.type .selected').first().trigger('click');
$('.stock_left').trigger('update');
$('.purchase').trigger('unblock');
}
},
error: function(jqXHR, statusText, error) {
var i = 0;
}
});
the trigger below never call. The alert on call never pop up. It was
triggered by these statements. See second block.
$('#sCart').trigger('add', { stock_id: stock_id
$('#sCart').on('add', function(event, data) {
alert('on add');
$.ajax({
url: '$subCartUpdate'.replace('$tokenHolder', Math.random()),
type: 'GET',
dataType: 'json',
beforeSend: function(jqXHR) {
jqXHR.setRequestHeader('if-Modified-Since', '0');
},
success: function(success, statusText, jqXHR) {
alert(statusText);
$('#sCart').trigger('clear');
$('#sCart').html(success.subCart);
if(timerId === null) {
$('#sCart').queue('add', function() {
$(this).fadeIn(function() {
$(this).dequeue('add');
});
});
} else {
clearTimeout(timerId);
}
timerId = setTimeout(function() {
$('#sCart').fadeOut();
timerId = null;
}, 7000);
$('#sCart').queue('add', function() {
var updatedItemSelector = '#stock_'+data.stock_id;
var updatedItem = $(updatedItemSelector).fadeOut(500);
updatedItem.fadeIn(2000, function() {
$(this).dequeue('add');
});
});
if(success.reservedTimeStamp) {
$('#sCartTimer').trigger('start', {timer:
success.reservedTimeStamp});
}
$('#sCart').dequeue('add');
},
error: function(jqXHR, statusText, errors) {
var i = 0;
}
});
});
It was triggered from code below.
$.ajax({
url: '$addUrl',
type: 'POST',
data: {
id: stock_id,
amount: amount
},
success: function(success, statusText, jqXHR) {
alert(statusText);
if(success.reload) {
location.reload(true);
} else if(success.redirect) {
location.href = success.redirect;
} else {
$('#sCart').trigger('add', {
stock_id: stock_id
});
$('.product-amount').val(1);
//$('.type .selected').first().trigger('click');
$('.stock_left').trigger('update');
$('.purchase').trigger('unblock');
}
},
error: function(jqXHR, statusText, error) {
var i = 0;
}
});
Objective c How to scale image view size (height) as per image size
Objective c How to scale image view size (height) as per image size
In my application i have used and image view to display images getting
from database
in data base images are having different sizes,
for now i added image view with frame (10, 10, 300, 220).
I need to resize the frames of image view as per image size, just like
Aspect Fit.
I know Aspect fit can able to resize but it do in changing width as per
height ratio,
But i need to increase the height as per width ratio
i need to have width always 300, fixed but need to changes in height
For ex :
if image size is 500x1000 i need to resize imageview as 300x600
if image size is 400x600 i need to resize imageview as 300x450
In my application i have used and image view to display images getting
from database
in data base images are having different sizes,
for now i added image view with frame (10, 10, 300, 220).
I need to resize the frames of image view as per image size, just like
Aspect Fit.
I know Aspect fit can able to resize but it do in changing width as per
height ratio,
But i need to increase the height as per width ratio
i need to have width always 300, fixed but need to changes in height
For ex :
if image size is 500x1000 i need to resize imageview as 300x600
if image size is 400x600 i need to resize imageview as 300x450
Thursday, September 12, 2013
PHP failed to download uploaded file from database since uploaded with chinese filename
PHP failed to download uploaded file from database since uploaded with
chinese filename
Excuse me, I am building a web site that can let user upload their
document(pdf) to the mysql database.
Since I have wrote the upload and download php page, I could upload
files(pdf) and download english named files successfully, but fail to
download the files whose name contain chinese words.
More specifically, I can download the chinese named file, but couldn't
open it. It shows that the file is damaged.
Here is a part of code of my upload php page:
$connect = mysqli_connect("localhost", "root", "password", "table");
if(mysqli_connect_errno($connect))//check connection
{
/*show error message and die*/
}
//set client character set to 'utf8'
mysqli_set_charset($connect, "utf8");
$fileName = mysqli_real_escape_string($connect, $name);
$filePath = mysqli_real_escape_string($connect, $tmp_name);
$fileSize = mysqli_real_escape_string($connect, $size);
$fileType = mysqli_real_escape_string($connect, $type);
$content = mysqli_real_escape_string($connect,
file_get_contents($tmp_name));
$filePath = addslashes($filePath);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$teamName = $_COOKIE['teamName'];
$reportQuery = "UPDATE uploadedreport SET name='$fileName',
type='$fileType', size='$fileSize', content='$content' WHERE
team='$teamName'";
uploadFileQuery($connect, $reportQuery, $fileName);
mysqli_close($connect);
Besides, another part of code of download php page is:
$teamName = $_COOKIE['teamName'];
$downloadReportQuery = "SELECT name, type, size, content FROM
uploadedreport WHERE team='$teamName'";
$result = mysqli_query($connect, $downloadReportQuery);
if($result == false)
{
/*alert error message and die*/
}
$row = mysqli_fetch_array($result);
header("Content-length:$row[size]");
header("Content-type:$row[type];charset:UTF-8");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=$row[name]");//Tells
the browser to save this downloaded file under the specified name
echo $row["content"];
mysqli_free_result($result);
mysqli_close($connect);
It's there anything wrong? I am disturbed by this problem for several days.
Thanks for your help!
Using Notepad++ to open the damaged downloaded pdf file: little part of
downloaded pdf
chinese filename
Excuse me, I am building a web site that can let user upload their
document(pdf) to the mysql database.
Since I have wrote the upload and download php page, I could upload
files(pdf) and download english named files successfully, but fail to
download the files whose name contain chinese words.
More specifically, I can download the chinese named file, but couldn't
open it. It shows that the file is damaged.
Here is a part of code of my upload php page:
$connect = mysqli_connect("localhost", "root", "password", "table");
if(mysqli_connect_errno($connect))//check connection
{
/*show error message and die*/
}
//set client character set to 'utf8'
mysqli_set_charset($connect, "utf8");
$fileName = mysqli_real_escape_string($connect, $name);
$filePath = mysqli_real_escape_string($connect, $tmp_name);
$fileSize = mysqli_real_escape_string($connect, $size);
$fileType = mysqli_real_escape_string($connect, $type);
$content = mysqli_real_escape_string($connect,
file_get_contents($tmp_name));
$filePath = addslashes($filePath);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$teamName = $_COOKIE['teamName'];
$reportQuery = "UPDATE uploadedreport SET name='$fileName',
type='$fileType', size='$fileSize', content='$content' WHERE
team='$teamName'";
uploadFileQuery($connect, $reportQuery, $fileName);
mysqli_close($connect);
Besides, another part of code of download php page is:
$teamName = $_COOKIE['teamName'];
$downloadReportQuery = "SELECT name, type, size, content FROM
uploadedreport WHERE team='$teamName'";
$result = mysqli_query($connect, $downloadReportQuery);
if($result == false)
{
/*alert error message and die*/
}
$row = mysqli_fetch_array($result);
header("Content-length:$row[size]");
header("Content-type:$row[type];charset:UTF-8");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=$row[name]");//Tells
the browser to save this downloaded file under the specified name
echo $row["content"];
mysqli_free_result($result);
mysqli_close($connect);
It's there anything wrong? I am disturbed by this problem for several days.
Thanks for your help!
Using Notepad++ to open the damaged downloaded pdf file: little part of
downloaded pdf
Processing: How to wrap text in 3D
Processing: How to wrap text in 3D
I'm struggling to wrap text in 3D by processing. Does anyone know
appropriate library or sample code?
I'm struggling to wrap text in 3D by processing. Does anyone know
appropriate library or sample code?
Convert Varchar column to datetime
Convert Varchar column to datetime
I have two columns as below. ColumnA is a varchar. 9bd is an assigned
number, 10 is fiscal year, 07 is month, and the rest is unique id. ColumnB
is datetime.
ColumnA ColumnB
9db1007000001 8/7/2011
I would like to seperate from ColumnA into a Month column (datetime) and a
Year column (datetime).
Desired result from ColumnA:
Column Month Column Year
7 2010
OR
7 10
I can seperate ColumnB into Month column and Year column. Here is my
attempted SQL script.
SELECT
ColumnA,
DATEPART(mm, (ColumnB)) as Month,
DATEPART(yy, (ColumnB)) as YEAR
FROM MY TABLE
Can someone please help? I did search within this website and found
similar question but my attempted script produces error
--Conversion failed when converting datetime from character string.
SELECT
CAST(SUBSTRING(ColumnB, 5, 2) + SUBSTRING(ColumnB, 3, 2) AS DATETIME)
Month_Year
FROM MY TABLE
BTW, this DATEPART(yy, (ColumnB)) function returns 2011. How can it return
11 instead? Or should I submit another question?
I have two columns as below. ColumnA is a varchar. 9bd is an assigned
number, 10 is fiscal year, 07 is month, and the rest is unique id. ColumnB
is datetime.
ColumnA ColumnB
9db1007000001 8/7/2011
I would like to seperate from ColumnA into a Month column (datetime) and a
Year column (datetime).
Desired result from ColumnA:
Column Month Column Year
7 2010
OR
7 10
I can seperate ColumnB into Month column and Year column. Here is my
attempted SQL script.
SELECT
ColumnA,
DATEPART(mm, (ColumnB)) as Month,
DATEPART(yy, (ColumnB)) as YEAR
FROM MY TABLE
Can someone please help? I did search within this website and found
similar question but my attempted script produces error
--Conversion failed when converting datetime from character string.
SELECT
CAST(SUBSTRING(ColumnB, 5, 2) + SUBSTRING(ColumnB, 3, 2) AS DATETIME)
Month_Year
FROM MY TABLE
BTW, this DATEPART(yy, (ColumnB)) function returns 2011. How can it return
11 instead? Or should I submit another question?
How to change the text after extract it in PHP?
How to change the text after extract it in PHP?
I'm working on my website to extract the data and I want to change text I
actually want. I'm stored the website link in MYSQL database where I can
output the link in PHP and I'm using PHP DOM to extract the data. I have
extracted the text which I got "College Football "Texas Christian at Texas
Tech" LIVE " using with this code:
<?php
define('DB_HOST', 'localhost');
define('DB_USER', 'myusername');
define('DB_PASSWORD', 'mypassword');
define('DB_DATABASE', 'mydbname');
$errmsg_arr = array();
$errflag = false;
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link)
{
die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db)
{
die("Unable to select database");
}
function clean($var)
{
return mysql_real_escape_string(strip_tags($var));
}
$channels = clean($_GET['channels']);
$id = clean($_GET['id']);
if($errflag)
{
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
echo implode('<br />',$errmsg_arr);
}
else
{
$insert = array();
if(isset($_GET['channels']))
{
$insert[] = 'channels = \'' . clean($_GET['channels']) .'\'';
}
if(isset($_GET['id']))
{
$insert[] = 'id = \'' . clean($_GET['id']) . '\'';
}
if($channels && $id)
{
$qrytable1="SELECT id, channels, links FROM tvguide WHERE
channels='$channels' && id='$id'";
$result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br
/>' . mysql_error());
while ($row = mysql_fetch_array($result1))
{
$links = $row['links'];
include ('simple_html_dom.php');
$html = file_get_html($links);
$title1 = $html->find('a[id=rowTitle1]', 0); // with this
echo $html->find('li[id=row1-3]', 0)->plaintext;
echo "<BR></BR>";
}
mysql_close($link);
}
}
?>
Here's the HTML source after I extract it:
7:30 PM College
Football
"Texas Christian at Texas Tech"
LIVE
<BR></BR>
I can see in the HTML source that there are long space which I want to get
rid it and I also want to ignore the time including AM and PM.
I want to change in the HTML source from this:
7:30 PM College
Football
"Texas Christian at Texas Tech"
LIVE
<BR></BR>
to this:
<span id='title1'>College Football: Texas Christian at Texas Tech -
LIVE</span><br></br>
Could you please tell me how I can change the text I want using my current
code?
I'm working on my website to extract the data and I want to change text I
actually want. I'm stored the website link in MYSQL database where I can
output the link in PHP and I'm using PHP DOM to extract the data. I have
extracted the text which I got "College Football "Texas Christian at Texas
Tech" LIVE " using with this code:
<?php
define('DB_HOST', 'localhost');
define('DB_USER', 'myusername');
define('DB_PASSWORD', 'mypassword');
define('DB_DATABASE', 'mydbname');
$errmsg_arr = array();
$errflag = false;
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link)
{
die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db)
{
die("Unable to select database");
}
function clean($var)
{
return mysql_real_escape_string(strip_tags($var));
}
$channels = clean($_GET['channels']);
$id = clean($_GET['id']);
if($errflag)
{
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
echo implode('<br />',$errmsg_arr);
}
else
{
$insert = array();
if(isset($_GET['channels']))
{
$insert[] = 'channels = \'' . clean($_GET['channels']) .'\'';
}
if(isset($_GET['id']))
{
$insert[] = 'id = \'' . clean($_GET['id']) . '\'';
}
if($channels && $id)
{
$qrytable1="SELECT id, channels, links FROM tvguide WHERE
channels='$channels' && id='$id'";
$result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br
/>' . mysql_error());
while ($row = mysql_fetch_array($result1))
{
$links = $row['links'];
include ('simple_html_dom.php');
$html = file_get_html($links);
$title1 = $html->find('a[id=rowTitle1]', 0); // with this
echo $html->find('li[id=row1-3]', 0)->plaintext;
echo "<BR></BR>";
}
mysql_close($link);
}
}
?>
Here's the HTML source after I extract it:
7:30 PM College
Football
"Texas Christian at Texas Tech"
LIVE
<BR></BR>
I can see in the HTML source that there are long space which I want to get
rid it and I also want to ignore the time including AM and PM.
I want to change in the HTML source from this:
7:30 PM College
Football
"Texas Christian at Texas Tech"
LIVE
<BR></BR>
to this:
<span id='title1'>College Football: Texas Christian at Texas Tech -
LIVE</span><br></br>
Could you please tell me how I can change the text I want using my current
code?
Subscribe to:
Comments (Atom)