How prove this inequality: $\sum_{i,j=1}^{n}|x_{i}+x_{j}|\ge
n\sum_{i=1}^{n}|x_{i}|$?
Let $x_{1},x_{2},\cdots,x_{n}$ be real numbers. Show that
$$\sum_{i,j=1}^{n}|x_{i}+x_{j}|\ge n\sum_{i=1}^{n}|x_{i}|.$$
I think this problem may be solved using nice methods, but I can't find
them yet; I know this may be of use: $$|a|+|b|\ge |a+b|.$$ But I can't
make it work. Thank you everyone.
Monday, 30 September 2013
Extracting URL links from a File
Extracting URL links from a File
Following code is to extract /support/security/bulletins/*.html links from
a file(urlfile contain about 1000 links) to urlsort file using regex,But
i'm weak in regex can anyone show me how to do that...?
#!/usr/bin/env python
import re,sys
fileHandle = open('urlfile', 'r')
f1 = open('urlsort', 'w')
for line in fileHandle.readlines():
links = re.findall(r"(\/support\/security\/bulletins\/*.html.*?)", line)
for link in links:
sys.stdout = f1
print ('%s' % (link[0]))
sys.stdout = sys.__stdout__
f1.close()
fileHandle.close()
Following code is to extract /support/security/bulletins/*.html links from
a file(urlfile contain about 1000 links) to urlsort file using regex,But
i'm weak in regex can anyone show me how to do that...?
#!/usr/bin/env python
import re,sys
fileHandle = open('urlfile', 'r')
f1 = open('urlsort', 'w')
for line in fileHandle.readlines():
links = re.findall(r"(\/support\/security\/bulletins\/*.html.*?)", line)
for link in links:
sys.stdout = f1
print ('%s' % (link[0]))
sys.stdout = sys.__stdout__
f1.close()
fileHandle.close()
Getting error in calling web service using ajax in jquery +jquery mobile?
Getting error in calling web service using ajax in jquery +jquery mobile?
I am calling login web service.But I am not able to check what I will get
from server . I got this
**http://isuite.c-entron.de/CentronService/REST
Username: qus
Password: 1**
I check on browser
http://isuite.c-entron.de/CentronService/REST&&Username=qus?Password= 1
But not getting any thing.
Secondly I used ajax like this 404 will get .Is this way to calling web
service.
$(document).ready(function () {
//event handler for submit button
$("#btnSubmit").click(function () {
//collect userName and password entered by users
var userName = $("#username").val();
var password = $("#password").val();
//call the authenticate function
authenticate(userName, password);
});
});
//authenticate function to make ajax call
function authenticate(userName, password) {
$.ajax
({
type: "POST",
//the url where you want to sent the userName and password to
url: "http://isuite.c-entron.de/CentronService/REST",
dataType: 'json',
async: false,
//json object to sent to the authentication url
data: '{"Username": "' + userName + '", "Password" : "' +
password + '"}',
success: function () {
//do any process for successful authentication here
}
})
}
Here is fiddle http://jsfiddle.net/LsKbJ/1/
I am calling login web service.But I am not able to check what I will get
from server . I got this
**http://isuite.c-entron.de/CentronService/REST
Username: qus
Password: 1**
I check on browser
http://isuite.c-entron.de/CentronService/REST&&Username=qus?Password= 1
But not getting any thing.
Secondly I used ajax like this 404 will get .Is this way to calling web
service.
$(document).ready(function () {
//event handler for submit button
$("#btnSubmit").click(function () {
//collect userName and password entered by users
var userName = $("#username").val();
var password = $("#password").val();
//call the authenticate function
authenticate(userName, password);
});
});
//authenticate function to make ajax call
function authenticate(userName, password) {
$.ajax
({
type: "POST",
//the url where you want to sent the userName and password to
url: "http://isuite.c-entron.de/CentronService/REST",
dataType: 'json',
async: false,
//json object to sent to the authentication url
data: '{"Username": "' + userName + '", "Password" : "' +
password + '"}',
success: function () {
//do any process for successful authentication here
}
})
}
Here is fiddle http://jsfiddle.net/LsKbJ/1/
Eclipse plugin development: Is plugin update or uninstall/install really clean?
Eclipse plugin development: Is plugin update or uninstall/install really
clean?
While developing Nodeclipse, I found that some bugs don't arise
immediately but after some time, when combination of updates, restarts
happens.
Is plugin update or uninstall/install really clean?
I develop and use installing for update, then use newer version until I
got time/idea to improve. However as said above I ran into situation when
Eclipse behaves differently after the new feature have been used for
several days.
Is there some information that must be read about plugin install
life-cycle, that mentions some not so evident behavior.
clean?
While developing Nodeclipse, I found that some bugs don't arise
immediately but after some time, when combination of updates, restarts
happens.
Is plugin update or uninstall/install really clean?
I develop and use installing for update, then use newer version until I
got time/idea to improve. However as said above I ran into situation when
Eclipse behaves differently after the new feature have been used for
several days.
Is there some information that must be read about plugin install
life-cycle, that mentions some not so evident behavior.
Sunday, 29 September 2013
how to take an arraylist of string type from one method to another method
how to take an arraylist of string type from one method to another method
I am a couple of semesters into learning java and I am looking to move an
arraylist from one method to another. I have look everywhere but could not
find exactly what I need. Thank you.
public static void addEmployee(ArrayList<String> list)
{
int i; //declares i as integer
//increments i for the array
for(i = 0; i < list.size(); i++)
list.get(i); //adds employees to an arraylist
for(i = 0; i < list.size(); i++)
addEmployee(list.get(i)); //This does not work
}//end public static void addEmplyoee(Arraylist<String> list)
public static void searchId(ArrayList<String> list)
{
}
I am a couple of semesters into learning java and I am looking to move an
arraylist from one method to another. I have look everywhere but could not
find exactly what I need. Thank you.
public static void addEmployee(ArrayList<String> list)
{
int i; //declares i as integer
//increments i for the array
for(i = 0; i < list.size(); i++)
list.get(i); //adds employees to an arraylist
for(i = 0; i < list.size(); i++)
addEmployee(list.get(i)); //This does not work
}//end public static void addEmplyoee(Arraylist<String> list)
public static void searchId(ArrayList<String> list)
{
}
date_create_from_format does not give back expected result
date_create_from_format does not give back expected result
I just tried,
date_create_from_format('Ym','201302')
And I guess because it's the 29th today, it's actually giving me back
March 1st.
I was hoping to get back 2013-02-01 00:00:00.
Is there a different function that will parse a date "correctly"? If not,
I can extract it myself, not a big deal.
I just tried,
date_create_from_format('Ym','201302')
And I guess because it's the 29th today, it's actually giving me back
March 1st.
I was hoping to get back 2013-02-01 00:00:00.
Is there a different function that will parse a date "correctly"? If not,
I can extract it myself, not a big deal.
Mobile rendering wont stretch 100%
Mobile rendering wont stretch 100%
Hello on my site I have a header/footer wrapper that goes 100% width, this
has a different bg image on it to the rest, however when i go to the site
on a mobile it only stretches 90% of the width, i'm in the process of
converting the site to a responsive grid system I recently developed so
the current version will only be live for a few more weeks however it's
something i would rather fix anyone know hats up?? URL: jp creative vision
CSS for the header
#header{
padding: 0;
height:60px;
width:100%;
background-image:url(../images/general/background_top.jpg);
-webkit-box-shadow: 0px 0px 50px 5px #000000;
-moz-box-shadow: 0px 0px 50px 5px #000000;
box-shadow: 0px 0px 50px 5px #000000;
}
#nav{
margin: 0 auto;
padding-top:0;
width:1000px;
}
#nav ul{
float:right;
}
#nav li {
display: inline-block;
}
#nav li a, #nav li a:visited {
box-sizing: border-box;
color:#FFFFFF;
display: block;
padding: .31em .60em;
transition: border 1s ease-in-out;
-moz-transition: border 1s ease-in-out;
-webkit-transition: border 1s ease-in-out;
}
#nav li a:hover, #nav li a:active, #nav li a:focus {
border-bottom: solid 10px #336699;
}
#nav ul:last-child{
margin-right:0px;
padding-right:0px;
}
Anyone know what my issue is? Thanks for the help :)
Hello on my site I have a header/footer wrapper that goes 100% width, this
has a different bg image on it to the rest, however when i go to the site
on a mobile it only stretches 90% of the width, i'm in the process of
converting the site to a responsive grid system I recently developed so
the current version will only be live for a few more weeks however it's
something i would rather fix anyone know hats up?? URL: jp creative vision
CSS for the header
#header{
padding: 0;
height:60px;
width:100%;
background-image:url(../images/general/background_top.jpg);
-webkit-box-shadow: 0px 0px 50px 5px #000000;
-moz-box-shadow: 0px 0px 50px 5px #000000;
box-shadow: 0px 0px 50px 5px #000000;
}
#nav{
margin: 0 auto;
padding-top:0;
width:1000px;
}
#nav ul{
float:right;
}
#nav li {
display: inline-block;
}
#nav li a, #nav li a:visited {
box-sizing: border-box;
color:#FFFFFF;
display: block;
padding: .31em .60em;
transition: border 1s ease-in-out;
-moz-transition: border 1s ease-in-out;
-webkit-transition: border 1s ease-in-out;
}
#nav li a:hover, #nav li a:active, #nav li a:focus {
border-bottom: solid 10px #336699;
}
#nav ul:last-child{
margin-right:0px;
padding-right:0px;
}
Anyone know what my issue is? Thanks for the help :)
Add ul ID in WordPress submenu
Add ul ID in WordPress submenu
I want to add an ID to the submenu in WordPress that matches the link text
of the sibling like this:
<nav id="main-navigation" role="navigation">
<ul class="nav">
<li>
<a href="#about-us">About Us</a>
<ul id="about-us" class="sub-menu">
...
</ul>
</li>
</ul>
</nav>
I have a custom walker that looks like this:
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "\n" . $indent . '<ul id="' . $pleaseHelp . '"
class="sub-menu">' . "\n";
}
So my problem is; how to get the anchor link text as a variable and how to
make it URL friendly. (e.g. "About Us" -> "about-us")
And also, for the sibling a do something like this:
if ($subMenu){
<a href="$pleaseHelp">
}
Note: This is not for styling purposes but for accessibility and
usability, to be able to add aria-owns="about-us" and
aria-controls="about-us". (Ofc added w/ JavaScript)
I want to add an ID to the submenu in WordPress that matches the link text
of the sibling like this:
<nav id="main-navigation" role="navigation">
<ul class="nav">
<li>
<a href="#about-us">About Us</a>
<ul id="about-us" class="sub-menu">
...
</ul>
</li>
</ul>
</nav>
I have a custom walker that looks like this:
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "\n" . $indent . '<ul id="' . $pleaseHelp . '"
class="sub-menu">' . "\n";
}
So my problem is; how to get the anchor link text as a variable and how to
make it URL friendly. (e.g. "About Us" -> "about-us")
And also, for the sibling a do something like this:
if ($subMenu){
<a href="$pleaseHelp">
}
Note: This is not for styling purposes but for accessibility and
usability, to be able to add aria-owns="about-us" and
aria-controls="about-us". (Ofc added w/ JavaScript)
Saturday, 28 September 2013
What's the significance of the 2 periods here "../bin/python"
What's the significance of the 2 periods here "../bin/python"
I'm trying to do the quick installation described here:
https://github.com/plumi/plumi.app/blob/master/docs/INSTALL.rst
One of the instructions is to run
"~/plumi.app/ffmpeg$../bin/python bootstrap.py && ./bin/buildout -vN"
There are 2 periods before the first /bin and there's one period before
the second /bin
I'm wondering if this is a typo, because a little before that, there's an
instruction as follows:
"~/plumi.app$./bin/python bootstrap.py && ./bin/buildout -v"
And in this case, there's only one period before each /bin
Also, I understand that ./bin/python is the same thing as bin/python but
does Ubuntu Linux Server correctly interpret ./bin/python ??
Thanks.
I'm trying to do the quick installation described here:
https://github.com/plumi/plumi.app/blob/master/docs/INSTALL.rst
One of the instructions is to run
"~/plumi.app/ffmpeg$../bin/python bootstrap.py && ./bin/buildout -vN"
There are 2 periods before the first /bin and there's one period before
the second /bin
I'm wondering if this is a typo, because a little before that, there's an
instruction as follows:
"~/plumi.app$./bin/python bootstrap.py && ./bin/buildout -v"
And in this case, there's only one period before each /bin
Also, I understand that ./bin/python is the same thing as bin/python but
does Ubuntu Linux Server correctly interpret ./bin/python ??
Thanks.
Navigates of page programmatically but address bar URL doesn't changes
Navigates of page programmatically but address bar URL doesn't changes
I am using J-Query Mobile and AngularJS and on the pressing link i want
navigate user to different page it navigates but url address in address
bar doesn't change how to solve this issue. I ma using the single page
structure
HTML Part
<a href="" ng-controller="addFoodToLog" ng-click="go()"
data-role="button">Add To Log</a>
JS Part
var myApp = angular.module('myApp',[]);
myApp.controller('addFoodToLog',function($scope){
$scope.go = function() {
//Here Selected Food Bump In Food Log
alert("Successfully Add In Your Log");
$.mobile.changePage('index.html#foodscreen');
}
});
I am using J-Query Mobile and AngularJS and on the pressing link i want
navigate user to different page it navigates but url address in address
bar doesn't change how to solve this issue. I ma using the single page
structure
HTML Part
<a href="" ng-controller="addFoodToLog" ng-click="go()"
data-role="button">Add To Log</a>
JS Part
var myApp = angular.module('myApp',[]);
myApp.controller('addFoodToLog',function($scope){
$scope.go = function() {
//Here Selected Food Bump In Food Log
alert("Successfully Add In Your Log");
$.mobile.changePage('index.html#foodscreen');
}
});
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
javax.xml.parsers.DocumentBuilderFactory
00:57:38,231 INFO [STDOUT] Caused by: java.lang.ClassCastException:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
javax.xml.parsers.DocumentBuilderFactory
00:57:38,231 INFO [STDOUT] at
javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
~[xml-apis-1.3.02.jar/:1.7.0_21]
00:57:38,231 INFO [STDOUT] at
org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:89)
~[spring-beans-3.0.7.RELEASE.jar/:3.0.7.RELEASE]
00:57:38,231 INFO [STDOUT] at
org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)
~[spring-beans-3.0.7.RELEASE.jar/:3.0.7.RELEASE]
00:57:38,231 INFO [STDOUT] at enter code
hereorg.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
~[spring-beans-3.0.7.RELEASE.jar/:3.0.7.RELEASE]
00:57:38,231 INFO [STDOUT] ... 124 common frames omitted
00:57:38,232 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/test]]
Exception sending context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener:
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected
exception parsing XML document from
"/D:/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1380374774874/deploy/test.war/WEB-INF/classes/spring/application-context.xml";
nested exception is java.lang.ClassCastException:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
javax.xml.parsers.DocumentBuilderFactory
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
[:3.0.7.RELEASE]
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
[:3.0.7.RELEASE]
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
[:3.0.7.RELEASE]
...
...
00:57:38,232 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/test]]
Exception sending context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener:
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected
exception parsing XML document from
"/D:/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1380374774874/deploy/test.war/WEB-INF/classes/spring/application-context.xml";
nested exception is java.lang.ClassCastException:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
javax.xml.parsers.DocumentBuilderFactory
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
[:3.0.7.RELEASE]
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
[:3.0.7.RELEASE]
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
[:3.0.7.RELEASE]
Caused by: java.lang.ClassCastException:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
javax.xml.parsers.DocumentBuilderFactory
at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown
Source) [:1.7.0_21]
at
org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:89)
[:3.0.7.RELEASE]
at
org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)
[:3.0.7.RELEASE]
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
[:3.0.7.RELEASE]
... 124 more
Here's my pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>kt</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>test</name>
<description>Internet Order System</description>
<properties>
<org.springframework.version>3.0.7.RELEASE</org.springframework.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.slf4j.version>1.6.6</org.slf4j.version>
</properties>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.6.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.lazyluke</groupId>
<artifactId>log4jdbc-remix</artifactId>
<version>0.2.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>2.2.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.7.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>mvn2</id>
<url>http://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>mesir-repo</id>
<url>http://mesir.googlecode.com/svn/trunk/mavenrepo</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource
Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle
Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>egovframe</id>
<url>http://www.egovframe.go.kr/maven/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>D:\workspace\test\src\main\java</sourceDirectory>
<scriptSourceDirectory>D:\workspace\test\src\main\scripts</scriptSourceDirectory>
<testSourceDirectory>D:\workspace\test\src\test\java</testSourceDirectory>
<outputDirectory>D:\workspace\test\target\classes</outputDirectory>
<testOutputDirectory>D:\workspace\test\target\test-classes</testOutputDirectory>
<resources>
<resource>
<directory>D:\workspace\test\src\main\resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>D:\workspace\test\src\test\resources</directory>
</testResource>
</testResources>
<directory>D:\workspace\test\target</directory>
<finalName>test-1.0</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>D:\workspace\test\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
<execution>
<id>default-deploy</id>
<phase>site-deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<outputDirectory>D:\workspace\test\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
</executions>
<configuration>
<outputDirectory>D:\workspace\test\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>D:\workspace\test\target\site</outputDirectory>
</reporting>
</project>
javax.xml.parsers.DocumentBuilderFactory
00:57:38,231 INFO [STDOUT] Caused by: java.lang.ClassCastException:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
javax.xml.parsers.DocumentBuilderFactory
00:57:38,231 INFO [STDOUT] at
javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
~[xml-apis-1.3.02.jar/:1.7.0_21]
00:57:38,231 INFO [STDOUT] at
org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:89)
~[spring-beans-3.0.7.RELEASE.jar/:3.0.7.RELEASE]
00:57:38,231 INFO [STDOUT] at
org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)
~[spring-beans-3.0.7.RELEASE.jar/:3.0.7.RELEASE]
00:57:38,231 INFO [STDOUT] at enter code
hereorg.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
~[spring-beans-3.0.7.RELEASE.jar/:3.0.7.RELEASE]
00:57:38,231 INFO [STDOUT] ... 124 common frames omitted
00:57:38,232 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/test]]
Exception sending context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener:
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected
exception parsing XML document from
"/D:/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1380374774874/deploy/test.war/WEB-INF/classes/spring/application-context.xml";
nested exception is java.lang.ClassCastException:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
javax.xml.parsers.DocumentBuilderFactory
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
[:3.0.7.RELEASE]
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
[:3.0.7.RELEASE]
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
[:3.0.7.RELEASE]
...
...
00:57:38,232 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/test]]
Exception sending context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener:
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected
exception parsing XML document from
"/D:/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1380374774874/deploy/test.war/WEB-INF/classes/spring/application-context.xml";
nested exception is java.lang.ClassCastException:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
javax.xml.parsers.DocumentBuilderFactory
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
[:3.0.7.RELEASE]
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
[:3.0.7.RELEASE]
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
[:3.0.7.RELEASE]
Caused by: java.lang.ClassCastException:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
javax.xml.parsers.DocumentBuilderFactory
at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown
Source) [:1.7.0_21]
at
org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:89)
[:3.0.7.RELEASE]
at
org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)
[:3.0.7.RELEASE]
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
[:3.0.7.RELEASE]
... 124 more
Here's my pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>kt</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>test</name>
<description>Internet Order System</description>
<properties>
<org.springframework.version>3.0.7.RELEASE</org.springframework.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.slf4j.version>1.6.6</org.slf4j.version>
</properties>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.6.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.lazyluke</groupId>
<artifactId>log4jdbc-remix</artifactId>
<version>0.2.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>2.2.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.7.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>mvn2</id>
<url>http://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>mesir-repo</id>
<url>http://mesir.googlecode.com/svn/trunk/mavenrepo</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource
Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle
Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>egovframe</id>
<url>http://www.egovframe.go.kr/maven/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>D:\workspace\test\src\main\java</sourceDirectory>
<scriptSourceDirectory>D:\workspace\test\src\main\scripts</scriptSourceDirectory>
<testSourceDirectory>D:\workspace\test\src\test\java</testSourceDirectory>
<outputDirectory>D:\workspace\test\target\classes</outputDirectory>
<testOutputDirectory>D:\workspace\test\target\test-classes</testOutputDirectory>
<resources>
<resource>
<directory>D:\workspace\test\src\main\resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>D:\workspace\test\src\test\resources</directory>
</testResource>
</testResources>
<directory>D:\workspace\test\target</directory>
<finalName>test-1.0</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>D:\workspace\test\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
<execution>
<id>default-deploy</id>
<phase>site-deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<outputDirectory>D:\workspace\test\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
</executions>
<configuration>
<outputDirectory>D:\workspace\test\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>D:\workspace\test\target\site</outputDirectory>
</reporting>
</project>
Export/save specific data from a html file to word or text or excel or csv extension
Export/save specific data from a html file to word or text or excel or csv
extension
I have some huge html files in ".txt" extension. I want to extract
information such as Name, Address, Mobile No, E-mail Address and want to
save it in a text or excel or csv so that it will be easier for me to
access data...Please help as soon as possible.
Thanks - Vikram Kumar
extension
I have some huge html files in ".txt" extension. I want to extract
information such as Name, Address, Mobile No, E-mail Address and want to
save it in a text or excel or csv so that it will be easier for me to
access data...Please help as soon as possible.
Thanks - Vikram Kumar
Friday, 27 September 2013
I get a Java Security Error when I try to run the class
I get a Java Security Error when I try to run the class
I've very new to java and am probably reaching father ahead with it than I
should be trying at this point but I'm trying to learn.
I keep getting this error when trying to run my program
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Here is the code I am trying to run
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;
public class Assingment5 extends JFrame {
public Assingment5() {
//fonts
java.awt.Font titlefont = new java.awt.Font("Dialog",Font.BOLD,20);
java.awt.Font subfont = new java.awt.Font("Dialog",Font.BOLD,14);
java.awt.Font body = new java.awt.Font("Dialog",Font.PLAIN,12);
//window
setSize(1000, 800);
this.setLayout(null);
setTitle("If Statements Assingment");
setLocation(350, 50);
setDefaultCloseOperation(EXIT_ON_CLOSE);
//Welcome Text
JLabel welcomelb = new JLabel("Welcome to my assingment!");
welcomelb.setFont(titlefont);
welcomelb.setBounds(20, 10, 500, 30);
add(welcomelb);
//second set of welcome text
JLabel subwelcome = new JLabel("There are 5 Programs to choose from:");
subwelcome.setFont(subfont);
subwelcome.setBounds(20, 30, 300, 30);
add(subwelcome);
//Question one variables
//Question one title
JLabel q1title = new JLabel("Question 1");
q1title.setFont(subfont);
q1title.setBounds(20, 70, 100, 30);
add(q1title);
//Question one dialog1
JLabel q1d1 = new JLabel("Enter a number and confirm");
q1d1.setFont(body);
q1d1.setBounds(20, 100, 200, 30);
add(q1d1);
//spinner for input
int spinnerstart = 1;
SpinnerModel number = new SpinnerNumberModel(spinnerstart,
spinnerstart - 1, spinnerstart + 50, 1);
final JSpinner q1spin = addSpinner(this,number);
q1spin.setBounds(20, 130, 50, 25);
//Okay button
JButton btconfirm = new JButton("Confirm");
//x, y, width, height
btconfirm.setBounds(80, 130, 80, 25);
btconfirm.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String q1output = null;
Object q1input = q1spin.getValue();
int q1inputINT = Integer.parseInt((String) q1input);
if (q1inputINT <10 && q1inputINT >1) {
q1output = "True";
}
else {
q1output = "False";
}
//Question one output
JLabel q1d2 = new JLabel();
java.awt.Font subfont = new java.awt.Font("Dialog",Font.BOLD,14);
q1d2.setFont(subfont);
q1d2.setBounds(20, 300, 200, 30);
q1d2.setText(q1output);
add(q1d2);
}
});
add(btconfirm);
}
static protected JSpinner addSpinner(Container c, SpinnerModel model) {
JSpinner spinner = new JSpinner(model);
c.add(spinner);
return spinner;
}
public static void main(String[] args) {
Assingment5 window = new Assingment5();
window.setVisible(true);
}
}
I Hope I am doing this right, I just joined. Sorry if I screwed this up.
I've very new to java and am probably reaching father ahead with it than I
should be trying at this point but I'm trying to learn.
I keep getting this error when trying to run my program
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Here is the code I am trying to run
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;
public class Assingment5 extends JFrame {
public Assingment5() {
//fonts
java.awt.Font titlefont = new java.awt.Font("Dialog",Font.BOLD,20);
java.awt.Font subfont = new java.awt.Font("Dialog",Font.BOLD,14);
java.awt.Font body = new java.awt.Font("Dialog",Font.PLAIN,12);
//window
setSize(1000, 800);
this.setLayout(null);
setTitle("If Statements Assingment");
setLocation(350, 50);
setDefaultCloseOperation(EXIT_ON_CLOSE);
//Welcome Text
JLabel welcomelb = new JLabel("Welcome to my assingment!");
welcomelb.setFont(titlefont);
welcomelb.setBounds(20, 10, 500, 30);
add(welcomelb);
//second set of welcome text
JLabel subwelcome = new JLabel("There are 5 Programs to choose from:");
subwelcome.setFont(subfont);
subwelcome.setBounds(20, 30, 300, 30);
add(subwelcome);
//Question one variables
//Question one title
JLabel q1title = new JLabel("Question 1");
q1title.setFont(subfont);
q1title.setBounds(20, 70, 100, 30);
add(q1title);
//Question one dialog1
JLabel q1d1 = new JLabel("Enter a number and confirm");
q1d1.setFont(body);
q1d1.setBounds(20, 100, 200, 30);
add(q1d1);
//spinner for input
int spinnerstart = 1;
SpinnerModel number = new SpinnerNumberModel(spinnerstart,
spinnerstart - 1, spinnerstart + 50, 1);
final JSpinner q1spin = addSpinner(this,number);
q1spin.setBounds(20, 130, 50, 25);
//Okay button
JButton btconfirm = new JButton("Confirm");
//x, y, width, height
btconfirm.setBounds(80, 130, 80, 25);
btconfirm.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String q1output = null;
Object q1input = q1spin.getValue();
int q1inputINT = Integer.parseInt((String) q1input);
if (q1inputINT <10 && q1inputINT >1) {
q1output = "True";
}
else {
q1output = "False";
}
//Question one output
JLabel q1d2 = new JLabel();
java.awt.Font subfont = new java.awt.Font("Dialog",Font.BOLD,14);
q1d2.setFont(subfont);
q1d2.setBounds(20, 300, 200, 30);
q1d2.setText(q1output);
add(q1d2);
}
});
add(btconfirm);
}
static protected JSpinner addSpinner(Container c, SpinnerModel model) {
JSpinner spinner = new JSpinner(model);
c.add(spinner);
return spinner;
}
public static void main(String[] args) {
Assingment5 window = new Assingment5();
window.setVisible(true);
}
}
I Hope I am doing this right, I just joined. Sorry if I screwed this up.
When deploying a web application I get the exception NoClassDefFoundError:LocalizableImpl
When deploying a web application I get the exception
NoClassDefFoundError:LocalizableImpl
I have a standard J2EE web application that includes web services. I'm
using the webservices-rt library to host the services. [See the maven
depdency below]. However, I get the following exception at run time:
SEVERE: Exception sending context initialized event to listener instance
of class com.sun.xml.ws.transport.http.servlet.WSServletContextListener
java.lang.NoClassDefFoundError:
com/sun/xml/ws/util/localization/LocalizableImpl
at
com.sun.xml.ws.util.exception.JAXWSExceptionBase.<init>(JAXWSExceptionBase.java:63)
at
com.sun.xml.ws.transport.http.servlet.WSServletException.<init>(WSServletException.java:47)
at
com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:118)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
[...]
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.ClassNotFoundException:
com.sun.xml.ws.util.localization.LocalizableImpl
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 33 more
Maven WS Dependency
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>webservices-rt</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
Am I missing a library? I've tried adding jaxws-rt. However, that requires
an additional repo [jboss]. I'm a bit weary of that, as that it introduces
a lot of new libraries into the project.
NoClassDefFoundError:LocalizableImpl
I have a standard J2EE web application that includes web services. I'm
using the webservices-rt library to host the services. [See the maven
depdency below]. However, I get the following exception at run time:
SEVERE: Exception sending context initialized event to listener instance
of class com.sun.xml.ws.transport.http.servlet.WSServletContextListener
java.lang.NoClassDefFoundError:
com/sun/xml/ws/util/localization/LocalizableImpl
at
com.sun.xml.ws.util.exception.JAXWSExceptionBase.<init>(JAXWSExceptionBase.java:63)
at
com.sun.xml.ws.transport.http.servlet.WSServletException.<init>(WSServletException.java:47)
at
com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:118)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
[...]
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.ClassNotFoundException:
com.sun.xml.ws.util.localization.LocalizableImpl
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 33 more
Maven WS Dependency
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>webservices-rt</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
Am I missing a library? I've tried adding jaxws-rt. However, that requires
an additional repo [jboss]. I'm a bit weary of that, as that it introduces
a lot of new libraries into the project.
WCF client not mapping and returning null objects
WCF client not mapping and returning null objects
I've setup a Service Reference (WCF Client) to call a Java Web Service
from a Console Application I've setup for testing. It is using HTTPS. I
have Fiddler setup and can see the proper values being sent and returned
from the service (in Fiddler). But no matter what method I call, the
returned values, regardless if it is a String or an object, comes back as
Null.
I'm not sure if the proxy client mapping isn't working or if I need to
change a configure value in app.config.
app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="ResultsSOAP12Binding">
<textMessageEncoding messageVersion="Soap12" />
</binding>
<binding name="ResultsSOAP12Binding1">
<textMessageEncoding messageVersion="Soap12" />
<httpsTransport />
</binding>
<binding name="ResultsSOAP12Binding2">
<textMessageEncoding messageVersion="Soap12" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://services.acme.com/results"
binding="customBinding"
bindingConfiguration="ResultsSOAP12Binding1"
contract="ResultsServiceReference.Result
</client>
</system.serviceModel>
</configuration>
Code:
static void CallResults()
{
var resultsRequest = new
ResultsServiceReference.ResultsRequest();
var client = new
ResultsServiceReference.ResultsPortTypeClient("ResultsSOAP12BindingQSPort");
Console.WriteLine("Call Results Service");
ResultsServiceReference.ResultsBatch result =
client.latestResults(resultsRequest);
Console.WriteLine(result.Status);
Console.ReadLine();
}
In this code the variable result is null, even though when you look in
Fiddler you can see the XML. No error is displayed until you try to use
result.
BTW, I tried setting a breakpoint inside the latestResults method in the
proxy class reference.cs, but the debugger doesn't reach it.
I've setup a Service Reference (WCF Client) to call a Java Web Service
from a Console Application I've setup for testing. It is using HTTPS. I
have Fiddler setup and can see the proper values being sent and returned
from the service (in Fiddler). But no matter what method I call, the
returned values, regardless if it is a String or an object, comes back as
Null.
I'm not sure if the proxy client mapping isn't working or if I need to
change a configure value in app.config.
app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="ResultsSOAP12Binding">
<textMessageEncoding messageVersion="Soap12" />
</binding>
<binding name="ResultsSOAP12Binding1">
<textMessageEncoding messageVersion="Soap12" />
<httpsTransport />
</binding>
<binding name="ResultsSOAP12Binding2">
<textMessageEncoding messageVersion="Soap12" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://services.acme.com/results"
binding="customBinding"
bindingConfiguration="ResultsSOAP12Binding1"
contract="ResultsServiceReference.Result
</client>
</system.serviceModel>
</configuration>
Code:
static void CallResults()
{
var resultsRequest = new
ResultsServiceReference.ResultsRequest();
var client = new
ResultsServiceReference.ResultsPortTypeClient("ResultsSOAP12BindingQSPort");
Console.WriteLine("Call Results Service");
ResultsServiceReference.ResultsBatch result =
client.latestResults(resultsRequest);
Console.WriteLine(result.Status);
Console.ReadLine();
}
In this code the variable result is null, even though when you look in
Fiddler you can see the XML. No error is displayed until you try to use
result.
BTW, I tried setting a breakpoint inside the latestResults method in the
proxy class reference.cs, but the debugger doesn't reach it.
Translate numbers from a range to another range
Translate numbers from a range to another range
Example range 1 (minimum and maximum):
[40 ... 480]
Example numbers from range 1:
[42, 59.4, 78.18, 120.43, 416]
Example range 2:
[10 .. 140]
How can I translate the values of the numbers from range 1 to values
within the second range? 42 should be equivalent to something between 10
and 11 in the new range.
I'm using PHP but this is more like a math problem.
I know how to align them to the second range:
$diff = $range[0] - $numbers[0];
foreach($numbers as $i => $number){
$numbers[$i] = $number + $diff;
}
But that's it :(
Example range 1 (minimum and maximum):
[40 ... 480]
Example numbers from range 1:
[42, 59.4, 78.18, 120.43, 416]
Example range 2:
[10 .. 140]
How can I translate the values of the numbers from range 1 to values
within the second range? 42 should be equivalent to something between 10
and 11 in the new range.
I'm using PHP but this is more like a math problem.
I know how to align them to the second range:
$diff = $range[0] - $numbers[0];
foreach($numbers as $i => $number){
$numbers[$i] = $number + $diff;
}
But that's it :(
Converting Binary To Ascii but Getting Same Result for all bit strings
Converting Binary To Ascii but Getting Same Result for all bit strings
I am doing a little project where I have to write a Genetic Algorithm to
evolve my name and id number. Basically I'm randomly generating bit
strings which have to then be generated into strings of ascii characters
and measure to see how close the generation gets. I will then mutate the
best 10 generations to try and get it as close as possible to my name and
id.
The bit I am having trouble with at the moment is the ascii generation. It
works fine for the first bit string but then just repeats itself for the
rest of them despite the fact that each bit string is different. Can
anyone see the problem? Any help is much appreciated.
Code so far:
import java.util.Random ;
public class GeneticAlgorithm {
public static void main(String[] args) throws Exception
{
int popSize = 0 ;
int gen ;
double repRate ;
double crossRate ;
double mutRate ;
int seed = 9005970 ;
String id = "John Connolly 00000000" ;
int bits = 7 * id.length() ;
String output ;
int pop ;
int bitGen ;
Random rand = new Random(seed) ;
ConvertToAscii convert = new ConvertToAscii() ;
Fitness fit = new Fitness() ;
try {
popSize = Integer.parseInt(args[0]) ;
if(popSize < 0 || popSize > 100000)
{
System.out.print("Invalid number! A positive number
between 0 and 100000 must be used for the population
rate!") ;
System.exit(1) ; // Signifies system exit if error occurs
}
gen = Integer.parseInt(args[1]) ;
if(gen < 0 || gen > 100000)
{
System.out.println("Invalid number! A positive number
between 0 and 100000 must be used for the generation
rate!") ;
System.exit(1) ;
}
repRate = Double.parseDouble(args[2]) ;
if(repRate < 0 || repRate > 1.0)
{
System.out.println("Invalid number! A positive decimal
point number between 0 and 1.0 must be used for the
reproduction rate!") ;
System.exit(1) ;
}
crossRate = Double.parseDouble(args[3]) ;
if(crossRate < 0 || crossRate > 1.0)
{
System.out.println("Invalid number! A positive decimal
point number between 0 and 1.0 must be used for the
crossover rate!") ;
System.exit(1) ;
}
mutRate = Double.parseDouble(args[4]) ;
if(mutRate < 0 || mutRate > 1.0)
{
System.out.println("Invalid number! A positive decimal
point number between 0 and 1.0 must be used for the
mutation rate!") ;
System.exit(1) ;
}
if(repRate + crossRate + mutRate != 1.0)
{
System.out.println("The Reproduction Rate, Crossover Rate
and Mutation Rate when sumed together must equal 1.0!") ;
System.exit(1) ;
}
output = args[5] ;
java.io.File file = new java.io.File(output);
java.io.PrintWriter writeOut = new java.io.PrintWriter(file) ;
StringBuffer bitString = new StringBuffer() ;
int bestFit = 0, fitness = 0, totalFit = 0 ;
String ascii = "" ;
writeOut.println(popSize + " " + gen + " " + repRate + " " +
crossRate + " " + mutRate + " " + output + " " + seed) ;
for(pop = 0 ; pop < popSize ; pop++)
{
ascii = "" ;
writeOut.print(pop + " ") ;
for(int i = 0 ; i < bits ; i++)
{
bitGen = rand.nextInt(2);
writeOut.print(bitGen) ;
bitString.append(bitGen) ;
}
ascii = convert.binaryToASCII(bitString) ;
writeOut.print(" " + ascii) ;
writeOut.println() ;
}
writeOut.close() ;
System.exit(0) ;
} catch(ArrayIndexOutOfBoundsException e) {
System.out.println("You have entered the incorrect number of
arguments!") ;
System.out.println("Please enter the required 6 arguments.") ;
System.exit(1) ;
} catch(NumberFormatException n) {
System.out.println("Invalid argument type") ;
System.exit(1) ;
}
}
}
Here is the conversion code:
public class ConvertToAscii {
public String binaryToASCII(StringBuffer bitString)
{
String ascii = "" ;
String byteString ;
int decimal ;
int i = 0, n = 7 ;
int baseNumber = 2 ;
char asciiChar ;
while(n <= 154)
{
byteString = bitString.substring(i, n) ;
decimal = Integer.parseInt(byteString, baseNumber) ;
System.out.print(" " + decimal) ;
i += 7 ;
n += 7 ;
if(decimal < 33 || decimal > 136)
{
decimal = 32 ;
asciiChar = (char) decimal ;
} else {
asciiChar = (char) decimal ;
}
ascii += asciiChar ;
}
return ascii ;
}
}
I am doing a little project where I have to write a Genetic Algorithm to
evolve my name and id number. Basically I'm randomly generating bit
strings which have to then be generated into strings of ascii characters
and measure to see how close the generation gets. I will then mutate the
best 10 generations to try and get it as close as possible to my name and
id.
The bit I am having trouble with at the moment is the ascii generation. It
works fine for the first bit string but then just repeats itself for the
rest of them despite the fact that each bit string is different. Can
anyone see the problem? Any help is much appreciated.
Code so far:
import java.util.Random ;
public class GeneticAlgorithm {
public static void main(String[] args) throws Exception
{
int popSize = 0 ;
int gen ;
double repRate ;
double crossRate ;
double mutRate ;
int seed = 9005970 ;
String id = "John Connolly 00000000" ;
int bits = 7 * id.length() ;
String output ;
int pop ;
int bitGen ;
Random rand = new Random(seed) ;
ConvertToAscii convert = new ConvertToAscii() ;
Fitness fit = new Fitness() ;
try {
popSize = Integer.parseInt(args[0]) ;
if(popSize < 0 || popSize > 100000)
{
System.out.print("Invalid number! A positive number
between 0 and 100000 must be used for the population
rate!") ;
System.exit(1) ; // Signifies system exit if error occurs
}
gen = Integer.parseInt(args[1]) ;
if(gen < 0 || gen > 100000)
{
System.out.println("Invalid number! A positive number
between 0 and 100000 must be used for the generation
rate!") ;
System.exit(1) ;
}
repRate = Double.parseDouble(args[2]) ;
if(repRate < 0 || repRate > 1.0)
{
System.out.println("Invalid number! A positive decimal
point number between 0 and 1.0 must be used for the
reproduction rate!") ;
System.exit(1) ;
}
crossRate = Double.parseDouble(args[3]) ;
if(crossRate < 0 || crossRate > 1.0)
{
System.out.println("Invalid number! A positive decimal
point number between 0 and 1.0 must be used for the
crossover rate!") ;
System.exit(1) ;
}
mutRate = Double.parseDouble(args[4]) ;
if(mutRate < 0 || mutRate > 1.0)
{
System.out.println("Invalid number! A positive decimal
point number between 0 and 1.0 must be used for the
mutation rate!") ;
System.exit(1) ;
}
if(repRate + crossRate + mutRate != 1.0)
{
System.out.println("The Reproduction Rate, Crossover Rate
and Mutation Rate when sumed together must equal 1.0!") ;
System.exit(1) ;
}
output = args[5] ;
java.io.File file = new java.io.File(output);
java.io.PrintWriter writeOut = new java.io.PrintWriter(file) ;
StringBuffer bitString = new StringBuffer() ;
int bestFit = 0, fitness = 0, totalFit = 0 ;
String ascii = "" ;
writeOut.println(popSize + " " + gen + " " + repRate + " " +
crossRate + " " + mutRate + " " + output + " " + seed) ;
for(pop = 0 ; pop < popSize ; pop++)
{
ascii = "" ;
writeOut.print(pop + " ") ;
for(int i = 0 ; i < bits ; i++)
{
bitGen = rand.nextInt(2);
writeOut.print(bitGen) ;
bitString.append(bitGen) ;
}
ascii = convert.binaryToASCII(bitString) ;
writeOut.print(" " + ascii) ;
writeOut.println() ;
}
writeOut.close() ;
System.exit(0) ;
} catch(ArrayIndexOutOfBoundsException e) {
System.out.println("You have entered the incorrect number of
arguments!") ;
System.out.println("Please enter the required 6 arguments.") ;
System.exit(1) ;
} catch(NumberFormatException n) {
System.out.println("Invalid argument type") ;
System.exit(1) ;
}
}
}
Here is the conversion code:
public class ConvertToAscii {
public String binaryToASCII(StringBuffer bitString)
{
String ascii = "" ;
String byteString ;
int decimal ;
int i = 0, n = 7 ;
int baseNumber = 2 ;
char asciiChar ;
while(n <= 154)
{
byteString = bitString.substring(i, n) ;
decimal = Integer.parseInt(byteString, baseNumber) ;
System.out.print(" " + decimal) ;
i += 7 ;
n += 7 ;
if(decimal < 33 || decimal > 136)
{
decimal = 32 ;
asciiChar = (char) decimal ;
} else {
asciiChar = (char) decimal ;
}
ascii += asciiChar ;
}
return ascii ;
}
}
Javascript Wscript.Shell command not working by clicking button in browser
Javascript Wscript.Shell command not working by clicking button in browser
I am using this code: to create new folder by clicking a button in browser,
function exer()
{
var wsr = WScript.CreateObject("WScript.Shell");
wsr.Exec("cmd /C mkdir C:\\users\\vakav\\Desktop\\VBSCRIPT_2013\\new");
}
<body>
<input type="button" value="test" onclick="exer()" />
</body>
Its not working but if i run the above function in a test.js file and run
the following commnad, its working: cmd> cscript.exe test.js Can anyone
help me please ?
I am using this code: to create new folder by clicking a button in browser,
function exer()
{
var wsr = WScript.CreateObject("WScript.Shell");
wsr.Exec("cmd /C mkdir C:\\users\\vakav\\Desktop\\VBSCRIPT_2013\\new");
}
<body>
<input type="button" value="test" onclick="exer()" />
</body>
Its not working but if i run the above function in a test.js file and run
the following commnad, its working: cmd> cscript.exe test.js Can anyone
help me please ?
cakephp formatting an array
cakephp formatting an array
My goal is to display 1 Projects and many Keywords to it. My DB is simple:
Project has many Keywords
Keyword belongs to Project
So far so good. Now I try to get the Information in my ProjectsController:
public function view($id = null)
{
$this->Project->bindModel(array('hasMany' => array('Keyword' =>
array('className' => 'Keyword',
'foreignKey' =>
'project_id')
)), false);
$this->paginate['Project']['conditions'] = array('Project.id' => $id);
$this->paginate['recursive'] = '2';
$this->set('projects', $this->paginate('Project'));
$Projects = $this->paginate('Project');
$this->set('projects', $this->paginate());
}
by printing out the array it looks a bit strange:
Array
(
[0] => Array
(
[Project] => Array
(
[id] => 3
[title] => Foo
[created] => 0000-00-00 00:00:00
[modified] => 2013-08-05 17:39:07
)
[Keyword] => Array
(
[0] => Array
(
[id] => 1
[project_id] => 3
[title] => Num1
[demand] => 50000000000
[competition] => 37889.56700
[cpc] => 676.50
[created] => 2013-06-26 17:54:48
[modified] => 2013-09-19 13:37:25
)
)
[1] => Array
(
[Project] => Array
(
[id] => 4
[title] => Bar
[created] => 0000-00-00 00:00:00
[modified] =>
)
[Keyword] => Array
(
[0] => Array
(
[id] => 3
[project_id] => 4
[title] => Num1
[demand] => 76534000000
[competition] => 5555.55560
[cpc] => 99.34
[created] => 2013-06-26 17:54:48
[modified] => 2013-09-19 13:37:36
)
)
)
)
Now i have the problem, how do i display it with the right Project.id?
because the new created array contains a different id than Project.id. My
question is how do I filter the right Project.id for display it only in my
/View/[id]
My goal is to display 1 Projects and many Keywords to it. My DB is simple:
Project has many Keywords
Keyword belongs to Project
So far so good. Now I try to get the Information in my ProjectsController:
public function view($id = null)
{
$this->Project->bindModel(array('hasMany' => array('Keyword' =>
array('className' => 'Keyword',
'foreignKey' =>
'project_id')
)), false);
$this->paginate['Project']['conditions'] = array('Project.id' => $id);
$this->paginate['recursive'] = '2';
$this->set('projects', $this->paginate('Project'));
$Projects = $this->paginate('Project');
$this->set('projects', $this->paginate());
}
by printing out the array it looks a bit strange:
Array
(
[0] => Array
(
[Project] => Array
(
[id] => 3
[title] => Foo
[created] => 0000-00-00 00:00:00
[modified] => 2013-08-05 17:39:07
)
[Keyword] => Array
(
[0] => Array
(
[id] => 1
[project_id] => 3
[title] => Num1
[demand] => 50000000000
[competition] => 37889.56700
[cpc] => 676.50
[created] => 2013-06-26 17:54:48
[modified] => 2013-09-19 13:37:25
)
)
[1] => Array
(
[Project] => Array
(
[id] => 4
[title] => Bar
[created] => 0000-00-00 00:00:00
[modified] =>
)
[Keyword] => Array
(
[0] => Array
(
[id] => 3
[project_id] => 4
[title] => Num1
[demand] => 76534000000
[competition] => 5555.55560
[cpc] => 99.34
[created] => 2013-06-26 17:54:48
[modified] => 2013-09-19 13:37:36
)
)
)
)
Now i have the problem, how do i display it with the right Project.id?
because the new created array contains a different id than Project.id. My
question is how do I filter the right Project.id for display it only in my
/View/[id]
Thursday, 26 September 2013
SQL Azure Automated Backups doesn't work
SQL Azure Automated Backups doesn't work
I configured automated export of my SQL azure db, but backups are not
created.
Also, I'am resieved this mail.
Automated SQL Export failed for pgmkixvn6d:aplicensingdb at 25.09.2013
23:06:45. The temporary database copy was made, but this copy could not be
exported to the .bacpac file in storage.
NOTES: We recommend checking that the storage account is available, and
that you can perform a manual export to that account. We will attempt to
export again at the next scheduled time.
I tryed to export db manualy in this storage accaunt — it was created
without problems.
I configured automated export of my SQL azure db, but backups are not
created.
Also, I'am resieved this mail.
Automated SQL Export failed for pgmkixvn6d:aplicensingdb at 25.09.2013
23:06:45. The temporary database copy was made, but this copy could not be
exported to the .bacpac file in storage.
NOTES: We recommend checking that the storage account is available, and
that you can perform a manual export to that account. We will attempt to
export again at the next scheduled time.
I tryed to export db manualy in this storage accaunt — it was created
without problems.
Wednesday, 25 September 2013
Google Maps interfering is interferring with event listeners
Google Maps interfering is interferring with event listeners
I have a google map thats running on a webpage. When I load up the
webpage, I create a modal which expands and goes on top of the google
maps. I want to make is so that I can close the divs I made so that way I
can look at the google Maps. The problem is I believe that google's
listeners are interfering with my clicks. How should I get around this. A
little part of the code which I was working on:
.modalDialog {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacitiy 400ms ease-in;
pointer-events: none;
}
.modalDialog:target {
opacity:0;
pointer-events: auto;
}
.modalDialog > div {
width: 400px;
height: 200px;
position: fixed;
left: 35%;
top: 50px;
margin: 10% auto;
padding: 4px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff,#999);
background: -o-linear-gradient(#fff, #999);
}
.close {
background: #606061;
top: -10px;
right: -10px;
color: #FFFFFF;
line-height: 25px;
right: -12px;
top: -10px;
position: absolute;
text-align: center;
width: 24px;
font-weight: bold;
text-decoration: none;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
box-shadow: 1px 1px 3px #000;
}
.close:hover {
background: #00d9ff;
}
On a separate js file:
window.onload = function createModal(){
var newDiv = document.createElement("div");
newDiv.setAttribute("id", "openModal");
newDiv.setAttribute("class", "modalDialog");
var modalDiv = document.createElement("div");
var close = document.createElement("a");
close.setAttribute("class", "close");
close.setAttribute("onclick", "hideWindows()");
var x = document.createTextNode("x");
modalDiv.appendChild(close);
newDiv.appendChild(modalDiv);//put the modal dialog in this div
var text = document.createTextNode("Testing this variable");
close.appendChild(x);
modalDiv.appendChild(text);
document.body.appendChild(newDiv);
};
I have a google map thats running on a webpage. When I load up the
webpage, I create a modal which expands and goes on top of the google
maps. I want to make is so that I can close the divs I made so that way I
can look at the google Maps. The problem is I believe that google's
listeners are interfering with my clicks. How should I get around this. A
little part of the code which I was working on:
.modalDialog {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacitiy 400ms ease-in;
pointer-events: none;
}
.modalDialog:target {
opacity:0;
pointer-events: auto;
}
.modalDialog > div {
width: 400px;
height: 200px;
position: fixed;
left: 35%;
top: 50px;
margin: 10% auto;
padding: 4px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff,#999);
background: -o-linear-gradient(#fff, #999);
}
.close {
background: #606061;
top: -10px;
right: -10px;
color: #FFFFFF;
line-height: 25px;
right: -12px;
top: -10px;
position: absolute;
text-align: center;
width: 24px;
font-weight: bold;
text-decoration: none;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
box-shadow: 1px 1px 3px #000;
}
.close:hover {
background: #00d9ff;
}
On a separate js file:
window.onload = function createModal(){
var newDiv = document.createElement("div");
newDiv.setAttribute("id", "openModal");
newDiv.setAttribute("class", "modalDialog");
var modalDiv = document.createElement("div");
var close = document.createElement("a");
close.setAttribute("class", "close");
close.setAttribute("onclick", "hideWindows()");
var x = document.createTextNode("x");
modalDiv.appendChild(close);
newDiv.appendChild(modalDiv);//put the modal dialog in this div
var text = document.createTextNode("Testing this variable");
close.appendChild(x);
modalDiv.appendChild(text);
document.body.appendChild(newDiv);
};
Thursday, 19 September 2013
How to prevent NULL from killing my ifelse vectorising?
How to prevent NULL from killing my ifelse vectorising?
I would like to vectorize such function:
if (i > 0)
fun1(a[i])
else
fun2(i)
where fun1, fun2 are already vectorized, and a is a vector.
My attempt:
ifelse(i > 0, fun1(a[i]), fun2(i))
However it is wrong!
> a <- c(1,2,3,4,5)
> i<-c(0,1,2,3)
> ifelse(i > 0, a[i], 0)
[1] 0 2 3 1 # expected 0 1 2 3
Do I have to use sapply? Is there any simple alternative that works?
I would like to vectorize such function:
if (i > 0)
fun1(a[i])
else
fun2(i)
where fun1, fun2 are already vectorized, and a is a vector.
My attempt:
ifelse(i > 0, fun1(a[i]), fun2(i))
However it is wrong!
> a <- c(1,2,3,4,5)
> i<-c(0,1,2,3)
> ifelse(i > 0, a[i], 0)
[1] 0 2 3 1 # expected 0 1 2 3
Do I have to use sapply? Is there any simple alternative that works?
How of track of the since_id parameter in my Processing + Twitter4j application?
How of track of the since_id parameter in my Processing + Twitter4j
application?
I am using the Twitter4j library in Processing to retrieve tweets. I have
added a timer to my application so that it collects tweets at appropriate
intervals without hitting the Twitter API too many times. However, I am
having trouble implementing the Since_Id parameter in order to step
forward (instead of backwards as I am now) through the timeline of tweets.
How do I keep track of the MAX_ID so that value is fed into the next
interval when the timer tells my application to run again.
Timer timer;
import java.util.List;
void setup() {
timer = new Timer(30000);
timer.start();
goTwitter();
}
void draw(){
if (timer.isFinished()){
goTwitter();
timer.start();
}
}
void goTwitter(){
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey("");
cb.setOAuthConsumerSecret("");
cb.setOAuthAccessToken("");
cb.setOAuthAccessTokenSecret("");
Twitter twitter = new TwitterFactory(cb.build()).getInstance();
Query query = new Query("#processing");
int numberOfTweets = 300;
long lastID = Long.MAX_VALUE;
ArrayList<Status> tweets = new ArrayList<Status>();
while (tweets.size () < numberOfTweets) {
if (numberOfTweets - tweets.size() > 100)
query.setCount(100);
else
query.setCount(numberOfTweets - tweets.size());
try {
QueryResult result = twitter.search(query);
tweets.addAll(result.getTweets());
println("Gathered " + tweets.size() + " tweets");
for (Status t: tweets)
if(t.getId() < lastID) lastID = t.getId();
}
catch (TwitterException te) {
println("Couldn't connect: " + te);
};
query.setMaxId(lastID-1);
}
for (int i = 0; i < tweets.size(); i++) {
Status t = (Status) tweets.get(i);
GeoLocation loc = t.getGeoLocation();
String user = t.getUser().getScreenName();
String msg = t.getText();
String time = "";
if (loc!=null) {
Double lat = t.getGeoLocation().getLatitude();
Double lon = t.getGeoLocation().getLongitude();
println(i + " USER: " + user + " wrote: " + msg + " located at " +
lat + ", " + lon);
}
}
println("lastID= " + lastID);
}
class Timer {
int savedTime;
int totalTime;
Timer (int tempTotalTime) {
totalTime = tempTotalTime;
}
void start(){
savedTime = millis();
}
boolean isFinished() {
int passedTime = millis() - savedTime;
if (passedTime > totalTime){
return true;
} else {
return false;
}
}
}
application?
I am using the Twitter4j library in Processing to retrieve tweets. I have
added a timer to my application so that it collects tweets at appropriate
intervals without hitting the Twitter API too many times. However, I am
having trouble implementing the Since_Id parameter in order to step
forward (instead of backwards as I am now) through the timeline of tweets.
How do I keep track of the MAX_ID so that value is fed into the next
interval when the timer tells my application to run again.
Timer timer;
import java.util.List;
void setup() {
timer = new Timer(30000);
timer.start();
goTwitter();
}
void draw(){
if (timer.isFinished()){
goTwitter();
timer.start();
}
}
void goTwitter(){
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey("");
cb.setOAuthConsumerSecret("");
cb.setOAuthAccessToken("");
cb.setOAuthAccessTokenSecret("");
Twitter twitter = new TwitterFactory(cb.build()).getInstance();
Query query = new Query("#processing");
int numberOfTweets = 300;
long lastID = Long.MAX_VALUE;
ArrayList<Status> tweets = new ArrayList<Status>();
while (tweets.size () < numberOfTweets) {
if (numberOfTweets - tweets.size() > 100)
query.setCount(100);
else
query.setCount(numberOfTweets - tweets.size());
try {
QueryResult result = twitter.search(query);
tweets.addAll(result.getTweets());
println("Gathered " + tweets.size() + " tweets");
for (Status t: tweets)
if(t.getId() < lastID) lastID = t.getId();
}
catch (TwitterException te) {
println("Couldn't connect: " + te);
};
query.setMaxId(lastID-1);
}
for (int i = 0; i < tweets.size(); i++) {
Status t = (Status) tweets.get(i);
GeoLocation loc = t.getGeoLocation();
String user = t.getUser().getScreenName();
String msg = t.getText();
String time = "";
if (loc!=null) {
Double lat = t.getGeoLocation().getLatitude();
Double lon = t.getGeoLocation().getLongitude();
println(i + " USER: " + user + " wrote: " + msg + " located at " +
lat + ", " + lon);
}
}
println("lastID= " + lastID);
}
class Timer {
int savedTime;
int totalTime;
Timer (int tempTotalTime) {
totalTime = tempTotalTime;
}
void start(){
savedTime = millis();
}
boolean isFinished() {
int passedTime = millis() - savedTime;
if (passedTime > totalTime){
return true;
} else {
return false;
}
}
}
Program Not Returning Results as Expected. Probably Misuse of "bool"?
Program Not Returning Results as Expected. Probably Misuse of "bool"?
I'm new to programming and I had to work on a program that would simulate
10,000 games of craps. I got it to calculate points for house and player
just fine until I added in the function "diceRoll" where player rolls
again and again until it matches the first roll or 7 (house wins). Now it
gives decidedly not random results (such as the house winning 0 times out
of 10,000). What did I do wrong?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdbool.h>
bool diceRoll (int a)
{
srand( (unsigned)time(NULL));
int n = 0;
int b = 0;
while(n < 1) {
b = rand() % 12;
if(b == a || b == 6) n++;
}
if(b == 6) return false;
else return true;
}
int main (void)
{
srand( (unsigned)time(NULL));
int a, n, house, player, point;
house = 0;
player = 0;
point = 0;
for(n = 0; n < 10000; n++) {
a = rand() % 12;
if(a == 1 || a == 2 || a == 11) {
house++;
}
else if(a == 6 || a == 10) {
player++;
}
else {
if(diceRoll(a) == true) player++;
else house++;
}
}
printf("The house has %i points.\n", house);
printf("The player has %i points.\n", player);
return 0;
}
I'm new to programming and I had to work on a program that would simulate
10,000 games of craps. I got it to calculate points for house and player
just fine until I added in the function "diceRoll" where player rolls
again and again until it matches the first roll or 7 (house wins). Now it
gives decidedly not random results (such as the house winning 0 times out
of 10,000). What did I do wrong?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdbool.h>
bool diceRoll (int a)
{
srand( (unsigned)time(NULL));
int n = 0;
int b = 0;
while(n < 1) {
b = rand() % 12;
if(b == a || b == 6) n++;
}
if(b == 6) return false;
else return true;
}
int main (void)
{
srand( (unsigned)time(NULL));
int a, n, house, player, point;
house = 0;
player = 0;
point = 0;
for(n = 0; n < 10000; n++) {
a = rand() % 12;
if(a == 1 || a == 2 || a == 11) {
house++;
}
else if(a == 6 || a == 10) {
player++;
}
else {
if(diceRoll(a) == true) player++;
else house++;
}
}
printf("The house has %i points.\n", house);
printf("The player has %i points.\n", player);
return 0;
}
Program not giving output
Program not giving output
I need some assistance I am trying to break and IP header down in Python
and I have my code written, but I am not getting anything back on the
screen. I do not know what I am missing. Suggestions are welcome:
import struct
from collections import OrderedDict
def tcpheader (rawTCP):
#Using dict for the dictionary
tcp=OrderedDict.fromkeys({})
tcp['ttl']=struct.unpack('!H',rawTCP[8:12]) [0] # H! is to unpack the
hex file and then search for the portion specified
tcp['totalength']=struct.unpack('!H',rawTCP[0:20]) [0]
tcp['sourceip']=struct.unpack('!H',rawTCP[12:16]) [0]
tcp['destip']=struct.unpack('!H',rawTCP[16:20]) [0]
return tcp #this is the proper way to break the loop and return
def tcpdecode():
infile=open ('C:/users/jwattenbarger/desktop/ip.dd', 'rb') #this is
opening the ip.dd file
rawTCP=infile.read(40)
#IPraw=infile.read (40)
tcp=tcpheader(rawTCP)
#tcp=tcpheader(IPraw)
print ("ttl:", tcp['ttl']) #these are printing the data
print ("totalength:", tcp['totalength'])
print ("sourceip:", tcp['sourceip'])
print ("destip:", tcp['destip'])
Print ("Temp")
for i in tcp: #associating i with tcp
print (i, "\t",tcp[i]) #printing tcp to the screen in a table
I need some assistance I am trying to break and IP header down in Python
and I have my code written, but I am not getting anything back on the
screen. I do not know what I am missing. Suggestions are welcome:
import struct
from collections import OrderedDict
def tcpheader (rawTCP):
#Using dict for the dictionary
tcp=OrderedDict.fromkeys({})
tcp['ttl']=struct.unpack('!H',rawTCP[8:12]) [0] # H! is to unpack the
hex file and then search for the portion specified
tcp['totalength']=struct.unpack('!H',rawTCP[0:20]) [0]
tcp['sourceip']=struct.unpack('!H',rawTCP[12:16]) [0]
tcp['destip']=struct.unpack('!H',rawTCP[16:20]) [0]
return tcp #this is the proper way to break the loop and return
def tcpdecode():
infile=open ('C:/users/jwattenbarger/desktop/ip.dd', 'rb') #this is
opening the ip.dd file
rawTCP=infile.read(40)
#IPraw=infile.read (40)
tcp=tcpheader(rawTCP)
#tcp=tcpheader(IPraw)
print ("ttl:", tcp['ttl']) #these are printing the data
print ("totalength:", tcp['totalength'])
print ("sourceip:", tcp['sourceip'])
print ("destip:", tcp['destip'])
Print ("Temp")
for i in tcp: #associating i with tcp
print (i, "\t",tcp[i]) #printing tcp to the screen in a table
How to get Elements by multiple tag names in Xerces-C?
How to get Elements by multiple tag names in Xerces-C?
I am using Xerces C++ to create a DOMNodeList from a XMLdom like this
(this is working):
DOMNodeList * module_instance_list =
InputDom->getElementsByTagName(X("ABC_INSTANCE"));
while X being a function to convert the string into a XMLString.
I would like to get elements by two or more different tag names and put
them into a DOMNodeList like this
DOMNodeList * module_instance_list =
InputDom->getElementsByTagName(X("ABC_INSTANCE")) +
InputDom->getElementsByTagName(X("ABC"));
or something like that:
DOMNodeList * module_instance_list =
InputDom->getElementsByTagName(X("ABC_INSTANCE") or X("ABC"));
or alternatively search for all beginning with 'ABC'
DOMNodeList * module_instance_list =
InputDom->getElementsByTagName(X("ABC*"));
But this is all not working. Is there any easy way to do this?
I am using Xerces C++ to create a DOMNodeList from a XMLdom like this
(this is working):
DOMNodeList * module_instance_list =
InputDom->getElementsByTagName(X("ABC_INSTANCE"));
while X being a function to convert the string into a XMLString.
I would like to get elements by two or more different tag names and put
them into a DOMNodeList like this
DOMNodeList * module_instance_list =
InputDom->getElementsByTagName(X("ABC_INSTANCE")) +
InputDom->getElementsByTagName(X("ABC"));
or something like that:
DOMNodeList * module_instance_list =
InputDom->getElementsByTagName(X("ABC_INSTANCE") or X("ABC"));
or alternatively search for all beginning with 'ABC'
DOMNodeList * module_instance_list =
InputDom->getElementsByTagName(X("ABC*"));
But this is all not working. Is there any easy way to do this?
Javascript function not returning from within a loop
Javascript function not returning from within a loop
I have a JavaScript function as:
function nodeExists(text, ancestor, tree, generationCount) {
tree.findByText(text).each(function (index, element) {
var gen = generationCount;
var currNode = element;
while (gen !== 1) { // 1: node itself
currNode = tree.parent(currNode);
gen--;
}
if (tree.text(currNode) === ancestor)
return currNode; // Even if condition is met, control continues
looping
})
return null;
//return ($.inArray(ancestor, gArr) !== -1) ? true : false;
}
While debugging function not exiting from a loop even if
tree.text(currNode) === ancestor is truthy. Is Jquery .each causing it.
Please help me.
I have a JavaScript function as:
function nodeExists(text, ancestor, tree, generationCount) {
tree.findByText(text).each(function (index, element) {
var gen = generationCount;
var currNode = element;
while (gen !== 1) { // 1: node itself
currNode = tree.parent(currNode);
gen--;
}
if (tree.text(currNode) === ancestor)
return currNode; // Even if condition is met, control continues
looping
})
return null;
//return ($.inArray(ancestor, gArr) !== -1) ? true : false;
}
While debugging function not exiting from a loop even if
tree.text(currNode) === ancestor is truthy. Is Jquery .each causing it.
Please help me.
Facebook login: getUser() always return 0
Facebook login: getUser() always return 0
I have a problem regarding login with facebook api for website.
Previously I made 1 facebook app (complete with the required
configuration). I made 1 php code (test_login_fb.php for login page). I've
tested it (domain: let's just say domain1.com), and it works smoothly.
Then I tried to do the same thing for another domain. I copied the file
and use it (domain: let's just say domain2.com), but it seems that the
login function does not work. It always show the login button which means
the getUser() always return 0.
I'm sure I've changed the app_id and secret_key from the code perspective,
also the url and other configuration on the facebook side.
Can anyone help me?
Here is my code
test_login_fb.php
<?php
// Remember to copy files from the SDK's src/ directory to a
// directory in your application on the server, such as php-sdk/
require_once('./facebookconnect/facebook.php');
$config = array(
'appId' => 'xxx',
'secret' => 'xxx',
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
?>
<html>
<head></head>
<body>
<?php
if($user_id) {
// We have a user ID, so probably a logged in user.
// If not, we'll get an exception, which we handle below.
try {
$user_profile = $facebook->api('/me','GET');
echo "Name: " . $user_profile['name'];
echo '<br>'.$facebook_user_id = $facebook->getUser();
echo '<br><img
src="https://graph.facebook.com/'.$facebook_user_id.'/picture"
/>';
echo '<br>Email: ' . $user_profile['email'];
$logoutUrl = $facebook->getLogoutUrl(array('next' =>
"http://www.domain2.com/test_logout_fb.php"));
echo '<br/><a href="'.$logoutUrl.'">Logout</a>';
} catch(FacebookApiException $e) {
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
error_log($e->getType());
error_log($e->getMessage());
}
} else {
// No user, print a link for the user to login
$perms = array('scope' => 'email');
$login_url = $facebook->getLoginUrl($perms);
//$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
}
?>
</body>
</html>
Thank you kindly.
I have a problem regarding login with facebook api for website.
Previously I made 1 facebook app (complete with the required
configuration). I made 1 php code (test_login_fb.php for login page). I've
tested it (domain: let's just say domain1.com), and it works smoothly.
Then I tried to do the same thing for another domain. I copied the file
and use it (domain: let's just say domain2.com), but it seems that the
login function does not work. It always show the login button which means
the getUser() always return 0.
I'm sure I've changed the app_id and secret_key from the code perspective,
also the url and other configuration on the facebook side.
Can anyone help me?
Here is my code
test_login_fb.php
<?php
// Remember to copy files from the SDK's src/ directory to a
// directory in your application on the server, such as php-sdk/
require_once('./facebookconnect/facebook.php');
$config = array(
'appId' => 'xxx',
'secret' => 'xxx',
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
?>
<html>
<head></head>
<body>
<?php
if($user_id) {
// We have a user ID, so probably a logged in user.
// If not, we'll get an exception, which we handle below.
try {
$user_profile = $facebook->api('/me','GET');
echo "Name: " . $user_profile['name'];
echo '<br>'.$facebook_user_id = $facebook->getUser();
echo '<br><img
src="https://graph.facebook.com/'.$facebook_user_id.'/picture"
/>';
echo '<br>Email: ' . $user_profile['email'];
$logoutUrl = $facebook->getLogoutUrl(array('next' =>
"http://www.domain2.com/test_logout_fb.php"));
echo '<br/><a href="'.$logoutUrl.'">Logout</a>';
} catch(FacebookApiException $e) {
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
error_log($e->getType());
error_log($e->getMessage());
}
} else {
// No user, print a link for the user to login
$perms = array('scope' => 'email');
$login_url = $facebook->getLoginUrl($perms);
//$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
}
?>
</body>
</html>
Thank you kindly.
function in function in function calls uncaught error: maximum call stack exceeds
function in function in function calls uncaught error: maximum call stack
exceeds
im having a problem with my code in jquery when im calling my function
from function from function it shows a loop alert message and an error
saying "uncaught error: maximum stack calls exceed."
here's my code:
$("#AvailabilityForm").on('submit', function (e)
{
var gvDetDDLs =
$('#availabilityGrid').find("input[name=dllEditAvailableDay]");
$.each(gvDetDDLs, function () {
var duplicateExists = false;
var ddlDay = $("#dllAvailableDay option:selected").text();
var currVal = $(this).val();
gvDetDDLs.not(this).each(function () {
e.stopPropagation();
if (ddlDay == currVal) {
duplicateExists = true;
alert("Duplicate entry is not allowed");
$(this).focus();
return false;
}
}
);
}
);
return true;
}
);
my scenario is i want to put a message when you click submit button and it
will not save to prevent duplicate entry.
kindly help me with this problem???
thanks
exceeds
im having a problem with my code in jquery when im calling my function
from function from function it shows a loop alert message and an error
saying "uncaught error: maximum stack calls exceed."
here's my code:
$("#AvailabilityForm").on('submit', function (e)
{
var gvDetDDLs =
$('#availabilityGrid').find("input[name=dllEditAvailableDay]");
$.each(gvDetDDLs, function () {
var duplicateExists = false;
var ddlDay = $("#dllAvailableDay option:selected").text();
var currVal = $(this).val();
gvDetDDLs.not(this).each(function () {
e.stopPropagation();
if (ddlDay == currVal) {
duplicateExists = true;
alert("Duplicate entry is not allowed");
$(this).focus();
return false;
}
}
);
}
);
return true;
}
);
my scenario is i want to put a message when you click submit button and it
will not save to prevent duplicate entry.
kindly help me with this problem???
thanks
Wednesday, 18 September 2013
Can router nodes in elasticsearch vote?
Can router nodes in elasticsearch vote?
I know that router nodes can't be voted into master but are they involved
in the voting process to elect a new master?
If so is there a way to disable this?
I know that router nodes can't be voted into master but are they involved
in the voting process to elect a new master?
If so is there a way to disable this?
Unable to assign output of FactoryGirl.create(:user) to a :user variable when factory uses 'sequence'
Unable to assign output of FactoryGirl.create(:user) to a :user variable
when factory uses 'sequence'
I'm following Michael Hartl's great book on Ruby on Rails(rails 3.2
version). I'm having some problems in section 9.3.3. Pagination.
After I modified my factory at spec/factories.rb using sequence like
this(note that I have the previous version commented out):
FactoryGirl.define do
#factory :user do
# name "Michael Hartl"
# email "michael@example.com"
# password "foobar"
# password_confirmation "foobar"
when factory uses 'sequence'
I'm following Michael Hartl's great book on Ruby on Rails(rails 3.2
version). I'm having some problems in section 9.3.3. Pagination.
After I modified my factory at spec/factories.rb using sequence like
this(note that I have the previous version commented out):
FactoryGirl.define do
#factory :user do
# name "Michael Hartl"
# email "michael@example.com"
# password "foobar"
# password_confirmation "foobar"
How create a comand line editor in wxwidgets?
How create a comand line editor in wxwidgets?
I need very simple GUI editor. But when I push button or for example
Shift+Enter I would run a command.
This is similar to Mathematica or Octave. I write a instruction, run it
trought button , and get Image or text and image.
Anybody can help me with it?
I need very simple GUI editor. But when I push button or for example
Shift+Enter I would run a command.
This is similar to Mathematica or Octave. I write a instruction, run it
trought button , and get Image or text and image.
Anybody can help me with it?
Replace NULL with string if another cell isn't NULL
Replace NULL with string if another cell isn't NULL
I'm working on a query:
SELECT D.PointPerson AS Person, R.[Name] AS Project, ISNULL(P.[Name]+' -
'+P.[Description], 'KanBan') AS Sprint, COALESCE(S.[Number],
N.IncidentNumber) AS Story, T.[Name] AS Task,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 1 THEN D.[Hours] ELSE 0
END) AS Monday,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 2 THEN D.[Hours] ELSE 0
END) AS Tuesday,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 3 THEN D.[Hours] ELSE 0
END) AS Wednesday,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 4 THEN D.[Hours] ELSE 0
END) AS Thursday,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 5 THEN D.[Hours] ELSE 0
END) AS Friday,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 6 THEN D.[Hours] ELSE 0
END) AS Saturday,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 7 THEN D.[Hours] ELSE 0
END) AS Sunday,
sum(D.[Hours]) AS Total
FROM DailyTaskHours D
LEFT JOIN Task T ON D.TaskId = T.PK_Task
LEFT JOIN Story S ON T.StoryId = S.PK_Story
LEFT JOIN NonScrumStory N ON D.NonScrumStoryId = N.PK_NonScrumStory
LEFT JOIN Sprint P ON S.SprintId = P.PK_Sprint
LEFT JOIN Product R ON S.ProductId = R.PK_Product
GROUP BY D.PointPerson, R.[Name], P.[Name], P.[Description], S.[Number],
N.IncidentNumber, T.[Name]
ORDER BY CASE WHEN ISNULL(P.[Name]+' - '+P.[Description], 'KanBan') =
'KanBan'
THEN 1
ELSE 0 END,
Project ASC,
Sprint ASC,
Story ASC,
Task ASC
If Name and Dexcription are NULL, the cell is populated with 'KanBan '
ISNULL(P.[Name]+' - '+P.[Description], 'KanBan')
This is working how I want it to. But, If a 3rd cell is NULL (T.[Name]) I
would also like this cell is NULL.
So if P.[Name]+' - '+P.[Description] (Sprint) IS NULL then populate with
KanBan, UNLESS T.[Name] IS NULL in which case I would also like (Sprint)
to be NULL
How can I achieve this?
I'm working on a query:
SELECT D.PointPerson AS Person, R.[Name] AS Project, ISNULL(P.[Name]+' -
'+P.[Description], 'KanBan') AS Sprint, COALESCE(S.[Number],
N.IncidentNumber) AS Story, T.[Name] AS Task,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 1 THEN D.[Hours] ELSE 0
END) AS Monday,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 2 THEN D.[Hours] ELSE 0
END) AS Tuesday,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 3 THEN D.[Hours] ELSE 0
END) AS Wednesday,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 4 THEN D.[Hours] ELSE 0
END) AS Thursday,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 5 THEN D.[Hours] ELSE 0
END) AS Friday,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 6 THEN D.[Hours] ELSE 0
END) AS Saturday,
sum(CASE WHEN DatePart(dw, D.ActivityDate) = 7 THEN D.[Hours] ELSE 0
END) AS Sunday,
sum(D.[Hours]) AS Total
FROM DailyTaskHours D
LEFT JOIN Task T ON D.TaskId = T.PK_Task
LEFT JOIN Story S ON T.StoryId = S.PK_Story
LEFT JOIN NonScrumStory N ON D.NonScrumStoryId = N.PK_NonScrumStory
LEFT JOIN Sprint P ON S.SprintId = P.PK_Sprint
LEFT JOIN Product R ON S.ProductId = R.PK_Product
GROUP BY D.PointPerson, R.[Name], P.[Name], P.[Description], S.[Number],
N.IncidentNumber, T.[Name]
ORDER BY CASE WHEN ISNULL(P.[Name]+' - '+P.[Description], 'KanBan') =
'KanBan'
THEN 1
ELSE 0 END,
Project ASC,
Sprint ASC,
Story ASC,
Task ASC
If Name and Dexcription are NULL, the cell is populated with 'KanBan '
ISNULL(P.[Name]+' - '+P.[Description], 'KanBan')
This is working how I want it to. But, If a 3rd cell is NULL (T.[Name]) I
would also like this cell is NULL.
So if P.[Name]+' - '+P.[Description] (Sprint) IS NULL then populate with
KanBan, UNLESS T.[Name] IS NULL in which case I would also like (Sprint)
to be NULL
How can I achieve this?
Can not get Location
Can not get Location
This is the code on the link
https://developer.android.com/training/location/retrieve-current.html
although it is the same code I got error. I got the permission on manifest
file. Thank you...
public class MainActivity extends FragmentActivity implements
GooglePlayServicesClient.ConnectionCallbacks,
GooglePlayServicesClient.OnConnectionFailedListener, OnClickListener{
// Global constants
/*
* Define a request code to send to Google Play services
* This code is returned in Activity.onActivityResult
*/
Location mCurrentLocation;
private final static int
CONNECTION_FAILURE_RESOLUTION_REQUEST = 9000;
LocationClient mLocationClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(this);
/*
* Create a new location client, using the enclosing class to
* handle callbacks.
*/
mLocationClient = new LocationClient(this, this, this);
}
// Define a DialogFragment that displays the error dialog
public static class ErrorDialogFragment extends DialogFragment {
// Global field to contain the error dialog
private Dialog mDialog;
// Default constructor. Sets the dialog field to null
public ErrorDialogFragment() {
super();
mDialog = null;
}
// Set the dialog to display
public void setDialog(Dialog dialog) {
mDialog = dialog;
}
// Return a Dialog to the DialogFragment.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return mDialog;
}
}
/*
* Handle results returned to the FragmentActivity
* by Google Play services
*/
@Override
protected void onActivityResult(
int requestCode, int resultCode, Intent data) {
// Decide what to do based on the original request code
switch (requestCode) {
case CONNECTION_FAILURE_RESOLUTION_REQUEST :
/*
* If the result code is Activity.RESULT_OK, try
* to connect again
*/
switch (resultCode) {
case Activity.RESULT_OK :
/*
* Try the request again
*/
break;
}
}
}
private boolean servicesConnected() {
// Check that Google Play services is available
int resultCode =
GooglePlayServicesUtil.
isGooglePlayServicesAvailable(this);
// If Google Play services is available
if (ConnectionResult.SUCCESS == resultCode) {
// In debug mode, log the status
Log.d("Location Updates",
"Google Play services is available.");
// Continue
return true;
// Google Play services was not available for some reason
} else {
// Get the error code
// Get the error dialog from Google Play services
Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(
resultCode,
this,
CONNECTION_FAILURE_RESOLUTION_REQUEST);
// If Google Play services can provide an error dialog
if (errorDialog != null) {
// Create a new DialogFragment for the error dialog
ErrorDialogFragment errorFragment =
new ErrorDialogFragment();
// Set the dialog in the DialogFragment
errorFragment.setDialog(errorDialog);
// Show the error dialog in the DialogFragment
errorFragment.show(getSupportFragmentManager(),
"Location Updates");
}
}
return false;
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
// TODO Auto-generated method stub
if (connectionResult.hasResolution()) {
try {
// Start an Activity that tries to resolve the error
connectionResult.startResolutionForResult(
this,
CONNECTION_FAILURE_RESOLUTION_REQUEST);
/*
* Thrown if Google Play services canceled the original
* PendingIntent
*/
} catch (IntentSender.SendIntentException e) {
// Log the error
e.printStackTrace();
}
} else {
/*
* If no resolution is available, display a dialog to the
* user with the error.
*/
showDialog(connectionResult.getErrorCode());
}
}
@Override
public void onConnected(Bundle arg0) {
// TODO Auto-generated method stub
}
@Override
public void onDisconnected() {
// TODO Auto-generated method stub
}
/*
* Called when the Activity becomes visible.
*/
@Override
protected void onStart() {
super.onStart();
// Connect the client.
mLocationClient.connect();
}
/*
* Called when the Activity is no longer visible.
*/
@Override
protected void onStop() {
// Disconnecting the client invalidates it.
mLocationClient.disconnect();
super.onStop();
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
TextView tv = (TextView) findViewById(R.id.textView1);
mCurrentLocation = mLocationClient.getLastLocation();
tv.setText(mCurrentLocation.getLatitude()+"");
}
}
And The Error I got is below here
09-18 15:11:43.660: E/AndroidRuntime(6839): FATAL EXCEPTION: main
09-18 15:11:43.660: E/AndroidRuntime(6839): java.lang.RuntimeException:
Unable to instantiate activity
ComponentInfo{com.example.testapplication/com.example.testapplication.MainActivity}:
java.lang.ClassNotFoundException: com.example.testapplication.MainActivity
in loader
dalvik.system.PathClassLoader[/data/app/com.example.testapplication-1.apk]
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.os.Looper.loop(Looper.java:130)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.ActivityThread.main(ActivityThread.java:3693)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
java.lang.reflect.Method.invokeNative(Native Method)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
java.lang.reflect.Method.invoke(Method.java:507)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
dalvik.system.NativeStart.main(Native Method)
09-18 15:11:43.660: E/AndroidRuntime(6839): Caused by:
java.lang.ClassNotFoundException: com.example.testapplication.MainActivity
in loader
dalvik.system.PathClassLoader[/data/app/com.example.testapplication-1.apk]
09-18 15:11:43.660: E/AndroidRuntime(6839): at
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
java.lang.ClassLoader.loadClass(ClassLoader.java:551)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
09-18 15:11:43.660: E/AndroidRuntime(6839): ... 11 more
This is the code on the link
https://developer.android.com/training/location/retrieve-current.html
although it is the same code I got error. I got the permission on manifest
file. Thank you...
public class MainActivity extends FragmentActivity implements
GooglePlayServicesClient.ConnectionCallbacks,
GooglePlayServicesClient.OnConnectionFailedListener, OnClickListener{
// Global constants
/*
* Define a request code to send to Google Play services
* This code is returned in Activity.onActivityResult
*/
Location mCurrentLocation;
private final static int
CONNECTION_FAILURE_RESOLUTION_REQUEST = 9000;
LocationClient mLocationClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(this);
/*
* Create a new location client, using the enclosing class to
* handle callbacks.
*/
mLocationClient = new LocationClient(this, this, this);
}
// Define a DialogFragment that displays the error dialog
public static class ErrorDialogFragment extends DialogFragment {
// Global field to contain the error dialog
private Dialog mDialog;
// Default constructor. Sets the dialog field to null
public ErrorDialogFragment() {
super();
mDialog = null;
}
// Set the dialog to display
public void setDialog(Dialog dialog) {
mDialog = dialog;
}
// Return a Dialog to the DialogFragment.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return mDialog;
}
}
/*
* Handle results returned to the FragmentActivity
* by Google Play services
*/
@Override
protected void onActivityResult(
int requestCode, int resultCode, Intent data) {
// Decide what to do based on the original request code
switch (requestCode) {
case CONNECTION_FAILURE_RESOLUTION_REQUEST :
/*
* If the result code is Activity.RESULT_OK, try
* to connect again
*/
switch (resultCode) {
case Activity.RESULT_OK :
/*
* Try the request again
*/
break;
}
}
}
private boolean servicesConnected() {
// Check that Google Play services is available
int resultCode =
GooglePlayServicesUtil.
isGooglePlayServicesAvailable(this);
// If Google Play services is available
if (ConnectionResult.SUCCESS == resultCode) {
// In debug mode, log the status
Log.d("Location Updates",
"Google Play services is available.");
// Continue
return true;
// Google Play services was not available for some reason
} else {
// Get the error code
// Get the error dialog from Google Play services
Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(
resultCode,
this,
CONNECTION_FAILURE_RESOLUTION_REQUEST);
// If Google Play services can provide an error dialog
if (errorDialog != null) {
// Create a new DialogFragment for the error dialog
ErrorDialogFragment errorFragment =
new ErrorDialogFragment();
// Set the dialog in the DialogFragment
errorFragment.setDialog(errorDialog);
// Show the error dialog in the DialogFragment
errorFragment.show(getSupportFragmentManager(),
"Location Updates");
}
}
return false;
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
// TODO Auto-generated method stub
if (connectionResult.hasResolution()) {
try {
// Start an Activity that tries to resolve the error
connectionResult.startResolutionForResult(
this,
CONNECTION_FAILURE_RESOLUTION_REQUEST);
/*
* Thrown if Google Play services canceled the original
* PendingIntent
*/
} catch (IntentSender.SendIntentException e) {
// Log the error
e.printStackTrace();
}
} else {
/*
* If no resolution is available, display a dialog to the
* user with the error.
*/
showDialog(connectionResult.getErrorCode());
}
}
@Override
public void onConnected(Bundle arg0) {
// TODO Auto-generated method stub
}
@Override
public void onDisconnected() {
// TODO Auto-generated method stub
}
/*
* Called when the Activity becomes visible.
*/
@Override
protected void onStart() {
super.onStart();
// Connect the client.
mLocationClient.connect();
}
/*
* Called when the Activity is no longer visible.
*/
@Override
protected void onStop() {
// Disconnecting the client invalidates it.
mLocationClient.disconnect();
super.onStop();
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
TextView tv = (TextView) findViewById(R.id.textView1);
mCurrentLocation = mLocationClient.getLastLocation();
tv.setText(mCurrentLocation.getLatitude()+"");
}
}
And The Error I got is below here
09-18 15:11:43.660: E/AndroidRuntime(6839): FATAL EXCEPTION: main
09-18 15:11:43.660: E/AndroidRuntime(6839): java.lang.RuntimeException:
Unable to instantiate activity
ComponentInfo{com.example.testapplication/com.example.testapplication.MainActivity}:
java.lang.ClassNotFoundException: com.example.testapplication.MainActivity
in loader
dalvik.system.PathClassLoader[/data/app/com.example.testapplication-1.apk]
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.os.Looper.loop(Looper.java:130)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.ActivityThread.main(ActivityThread.java:3693)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
java.lang.reflect.Method.invokeNative(Native Method)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
java.lang.reflect.Method.invoke(Method.java:507)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
dalvik.system.NativeStart.main(Native Method)
09-18 15:11:43.660: E/AndroidRuntime(6839): Caused by:
java.lang.ClassNotFoundException: com.example.testapplication.MainActivity
in loader
dalvik.system.PathClassLoader[/data/app/com.example.testapplication-1.apk]
09-18 15:11:43.660: E/AndroidRuntime(6839): at
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
java.lang.ClassLoader.loadClass(ClassLoader.java:551)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-18 15:11:43.660: E/AndroidRuntime(6839): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
09-18 15:11:43.660: E/AndroidRuntime(6839): ... 11 more
How to convert large .rdf file to .n3 format
How to convert large .rdf file to .n3 format
I want to convert .rdf file (of 1 TeraByte) to .n3 format. I wrote my own
parser but it is very inefficient (takes 10 days and more). Can someone
please suggest me some good library in python, which I may use to
accomplish this. Also if possible please point me to some good examples
which me help me understand and use the library
I want to convert .rdf file (of 1 TeraByte) to .n3 format. I wrote my own
parser but it is very inefficient (takes 10 days and more). Can someone
please suggest me some good library in python, which I may use to
accomplish this. Also if possible please point me to some good examples
which me help me understand and use the library
How to solve unresolved dependencies exception in Groovy
How to solve unresolved dependencies exception in Groovy
How to solve the unresolved dependencies and java heap space in groovy
project.. Even providing MAVEN_OPTS as -Xmx1024m, heap space issue
occurring.. Hope someone can help to solve this.
Am using Intellij IDEA, maven 2.2.1, Groovy
==== mavenCentral: tried
http://repo1.maven.org/maven2/javax/security/jacc/1.0/jacc-1.0.pom
-- artifact javax.security#jacc;1.0!jacc.jar:
http://repo1.maven.org/maven2/javax/security/jacc/1.0/jacc-1.0.jar
module not found: org.hibernate#hibernate-cglib-repack;2.1_3
==== grailsPlugins: tried
-- artifact
org.hibernate#hibernate-cglib-repack;2.1_3!hibernate-cglib-repack.jar:
C:\Documents and Settings\user\code
base\trunk\war/lib/hibernate-cglib-repack-2.1_3.jar
C:\Documents and Settings\user\code
base\war\plugins\.svn/lib/hibernate-cglib-repack-2.1_3.jar
C:\Documents and Settings\user\code
base\trunk\war\plugins\hibernate-1.3.1/lib/hibernate-cglib-repack-2.1_3.jar
C:\Documents and Settings\user\code
base\trunk\war\plugins\jdbc-pool-0.1/lib/hibernate-cglib-repack-2.1_3.jar
C:\Documents and Settings\user\code
base\trunk\war\plugins\tomcat-1.3.2/lib/hibernate-cglib-repack-2.1_3.jar
==== grailsCentral: tried
-- artifact
org.hibernate#hibernate-cglib-repack;2.1_3!hibernate-cglib-repack.jar:
http://svn.codehaus.org/grails-plugins/grails-hibernate-cglib-repack/tags/RELEASE_2_1_3/grails-hibernate-cglib-repack-2.1_3.jar
==== grailsCore: tried
-- artifact
org.hibernate#hibernate-cglib-repack;2.1_3!hibernate-cglib-repack.jar:
http://svn.codehaus.org/grails/trunk/grails-plugins/grails-hibernate-cglib-repack/tags/RELEASE_2_1_3/grails-hibernate-cglib-repack-2.1_3.jar
==== localMavenResolver: tried
C:\Documents and
Settings\user/.m2/repository/org/hibernate/hibernate-cglib-repack/2.1_3/hibernate-cglib-repack-2.1_3.pom
-- artifact
org.hibernate#hibernate-cglib-repack;2.1_3!hibernate-cglib-repack.jar:
C:\Documents and
Settings\user/.m2/repository/org/hibernate/hibernate-cglib-repack/2.1_3/hibernate-cglib-repack-2.1_3.jar
==== mavenCentral: tried
http://repo1.maven.org/maven2/org/hibernate/hibernate-cglib-repack/2.1_3/hibernate-cglib-repack-2.1_3.pom
-- artifact
org.hibernate#hibernate-cglib-repack;2.1_3!hibernate-cglib-repack.jar:
http://repo1.maven.org/maven2/org/hibernate/hibernate-cglib-repack/2.1_3/hibernate-cglib-repack-2.1_3.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: javax.security#jaas;1.0.01: not found
:: javax.security#jacc;1.0: not found
:: org.hibernate#hibernate-cglib-repack;2.1_3: not found
::::::::::::::::::::::::::::::::::::::::::::::
[copy] Copied 3 empty directories to 2 empty directories under
C:\Documents and Settings\user\code base\trunk\war\target\resources
: java.lang.OutOfMemoryError: Java heap space
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
at
_GrailsCompile$_run_closure4_closure10.doCall(_GrailsCompile.groovy:118)
at _GrailsCompile$_run_closure4_closure10.doCall(_GrailsCompile.groovy)
at _GrailsSettings$_run_closure10.doCall(_GrailsSettings.groovy:282)
at _GrailsSettings$_run_closure10.call(_GrailsSettings.groovy)
at _GrailsCompile$_run_closure4.doCall(_GrailsCompile.groovy:105)
at _GrailsCompile$_run_closure3.doCall(_GrailsCompile.groovy:68)
How to solve the unresolved dependencies and java heap space in groovy
project.. Even providing MAVEN_OPTS as -Xmx1024m, heap space issue
occurring.. Hope someone can help to solve this.
Am using Intellij IDEA, maven 2.2.1, Groovy
==== mavenCentral: tried
http://repo1.maven.org/maven2/javax/security/jacc/1.0/jacc-1.0.pom
-- artifact javax.security#jacc;1.0!jacc.jar:
http://repo1.maven.org/maven2/javax/security/jacc/1.0/jacc-1.0.jar
module not found: org.hibernate#hibernate-cglib-repack;2.1_3
==== grailsPlugins: tried
-- artifact
org.hibernate#hibernate-cglib-repack;2.1_3!hibernate-cglib-repack.jar:
C:\Documents and Settings\user\code
base\trunk\war/lib/hibernate-cglib-repack-2.1_3.jar
C:\Documents and Settings\user\code
base\war\plugins\.svn/lib/hibernate-cglib-repack-2.1_3.jar
C:\Documents and Settings\user\code
base\trunk\war\plugins\hibernate-1.3.1/lib/hibernate-cglib-repack-2.1_3.jar
C:\Documents and Settings\user\code
base\trunk\war\plugins\jdbc-pool-0.1/lib/hibernate-cglib-repack-2.1_3.jar
C:\Documents and Settings\user\code
base\trunk\war\plugins\tomcat-1.3.2/lib/hibernate-cglib-repack-2.1_3.jar
==== grailsCentral: tried
-- artifact
org.hibernate#hibernate-cglib-repack;2.1_3!hibernate-cglib-repack.jar:
http://svn.codehaus.org/grails-plugins/grails-hibernate-cglib-repack/tags/RELEASE_2_1_3/grails-hibernate-cglib-repack-2.1_3.jar
==== grailsCore: tried
-- artifact
org.hibernate#hibernate-cglib-repack;2.1_3!hibernate-cglib-repack.jar:
http://svn.codehaus.org/grails/trunk/grails-plugins/grails-hibernate-cglib-repack/tags/RELEASE_2_1_3/grails-hibernate-cglib-repack-2.1_3.jar
==== localMavenResolver: tried
C:\Documents and
Settings\user/.m2/repository/org/hibernate/hibernate-cglib-repack/2.1_3/hibernate-cglib-repack-2.1_3.pom
-- artifact
org.hibernate#hibernate-cglib-repack;2.1_3!hibernate-cglib-repack.jar:
C:\Documents and
Settings\user/.m2/repository/org/hibernate/hibernate-cglib-repack/2.1_3/hibernate-cglib-repack-2.1_3.jar
==== mavenCentral: tried
http://repo1.maven.org/maven2/org/hibernate/hibernate-cglib-repack/2.1_3/hibernate-cglib-repack-2.1_3.pom
-- artifact
org.hibernate#hibernate-cglib-repack;2.1_3!hibernate-cglib-repack.jar:
http://repo1.maven.org/maven2/org/hibernate/hibernate-cglib-repack/2.1_3/hibernate-cglib-repack-2.1_3.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: javax.security#jaas;1.0.01: not found
:: javax.security#jacc;1.0: not found
:: org.hibernate#hibernate-cglib-repack;2.1_3: not found
::::::::::::::::::::::::::::::::::::::::::::::
[copy] Copied 3 empty directories to 2 empty directories under
C:\Documents and Settings\user\code base\trunk\war\target\resources
: java.lang.OutOfMemoryError: Java heap space
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
at
_GrailsCompile$_run_closure4_closure10.doCall(_GrailsCompile.groovy:118)
at _GrailsCompile$_run_closure4_closure10.doCall(_GrailsCompile.groovy)
at _GrailsSettings$_run_closure10.doCall(_GrailsSettings.groovy:282)
at _GrailsSettings$_run_closure10.call(_GrailsSettings.groovy)
at _GrailsCompile$_run_closure4.doCall(_GrailsCompile.groovy:105)
at _GrailsCompile$_run_closure3.doCall(_GrailsCompile.groovy:68)
Tuesday, 17 September 2013
How to Export data from db2 with Complex SQL query via db2 commandline?
How to Export data from db2 with Complex SQL query via db2 commandline?
I have complex SQL Query and I want to export data with these SQL via db2
commandline and must include these format "xxxxx","aaaaaa","cccccccc"
sql query I save in .sql file
what's command?
I have complex SQL Query and I want to export data with these SQL via db2
commandline and must include these format "xxxxx","aaaaaa","cccccccc"
sql query I save in .sql file
what's command?
Can Bootstrap responsive cancel some style when a site viewed via mobile
Can Bootstrap responsive cancel some style when a site viewed via mobile
--------------------------------CSS---------------------
.image {
height:50px;
}
---------------------------------HTML--------------------
<div class='span6'>
<img class='image' />
</div>
<div class='span6'>
<img class='image' />
</div>
Is it possible to cancel the style when the Bootstrap's responsive works?
I need these image to be displayed without crop by CSS, assuming that the
picture's height is 400px.
Thank you
--------------------------------CSS---------------------
.image {
height:50px;
}
---------------------------------HTML--------------------
<div class='span6'>
<img class='image' />
</div>
<div class='span6'>
<img class='image' />
</div>
Is it possible to cancel the style when the Bootstrap's responsive works?
I need these image to be displayed without crop by CSS, assuming that the
picture's height is 400px.
Thank you
After changing to a float: "Cannot confirm float from string"
After changing to a float: "Cannot confirm float from string"
Hey so here is my code:
if(repeat)
{
Guesses++;
String Input = JOptionPane.showInputDialog("Enter a number between 0
and 10. So far you have had " + Guesses + " guesses.");
Float.parseFloat(Input);
if(**Input > RandomNum**)
{
JOptionPane.showMessageDialog(null, "Too small.");
}
else if(if(repeat)
{
Guesses++;
String Input = JOptionPane.showInputDialog("Enter a number between 0
and 10. So far you have had " + Guesses + " guesses.");
Float.parseFloat(Input);
if(Input > RandomNum)
{
JOptionPane.showMessageDialog(null, "Too small.");
}
else if(Input = RandomNum)
{)
(This is just part of it) The Text with the **'s is where I get the error.
It says
The operator > is undefined for the argument type(s) String, float
Although I (think) I changed the Input, to a float
(Float.parseFloat(Input);) So do you know what the problem is? (If this
has already been answered then can you give me a link?)
Hey so here is my code:
if(repeat)
{
Guesses++;
String Input = JOptionPane.showInputDialog("Enter a number between 0
and 10. So far you have had " + Guesses + " guesses.");
Float.parseFloat(Input);
if(**Input > RandomNum**)
{
JOptionPane.showMessageDialog(null, "Too small.");
}
else if(if(repeat)
{
Guesses++;
String Input = JOptionPane.showInputDialog("Enter a number between 0
and 10. So far you have had " + Guesses + " guesses.");
Float.parseFloat(Input);
if(Input > RandomNum)
{
JOptionPane.showMessageDialog(null, "Too small.");
}
else if(Input = RandomNum)
{)
(This is just part of it) The Text with the **'s is where I get the error.
It says
The operator > is undefined for the argument type(s) String, float
Although I (think) I changed the Input, to a float
(Float.parseFloat(Input);) So do you know what the problem is? (If this
has already been answered then can you give me a link?)
How to check condition in "ref" attribute in Spring
How to check condition in "ref" attribute in Spring
I'm new to Spring. Just wondering, is it possible to check condition
within the "ref" attribute as follows?
<bean id="dbInfo" class="DatabaseProperties"
factory-method="initDatabaseInformation"/>
<bean id="b1" class="someClass" >
<property name="prop1" ref="#{ dbInfo.isValidUser? 'bean2' : 'bean3' }"
</bean>
<bean id="bean2" class="someClass1" >
</bean>
<bean id="bean3" class="someClass2" >
</bean>
I'm getting BeanCreationException by doing above. What would be the best
practice to do so?
I'm new to Spring. Just wondering, is it possible to check condition
within the "ref" attribute as follows?
<bean id="dbInfo" class="DatabaseProperties"
factory-method="initDatabaseInformation"/>
<bean id="b1" class="someClass" >
<property name="prop1" ref="#{ dbInfo.isValidUser? 'bean2' : 'bean3' }"
</bean>
<bean id="bean2" class="someClass1" >
</bean>
<bean id="bean3" class="someClass2" >
</bean>
I'm getting BeanCreationException by doing above. What would be the best
practice to do so?
Making a slider picker in Android
Making a slider picker in Android
I'm trying to make a sliding picker that has circles above it showing you
which one you currently have selected. I know I have seen this before, but
don't know if this is something android can do by default, or if it has to
be built from scratch. If it needs to be built from scratch, dose anyone
know where to begin to make something like that.
here is a picture of what i'm trying to make:
Any help would be appreciated!
I'm trying to make a sliding picker that has circles above it showing you
which one you currently have selected. I know I have seen this before, but
don't know if this is something android can do by default, or if it has to
be built from scratch. If it needs to be built from scratch, dose anyone
know where to begin to make something like that.
here is a picture of what i'm trying to make:
Any help would be appreciated!
Gif file wont show up in chrome but it will in IE
Gif file wont show up in chrome but it will in IE
I dont know why in IE i can see this gif file just fine, but chrome will
return a cancelled status (see network image status below)
My code basically tries to show this gif file inside a hidden panel that
is made visible when a button is clicked
<script type="text/javascript">
function loadingSubmit() {
$("#<%=lblConfirmation.ClientID %>").before("<img
src='Images/478.gif' style='z-index:10;' />");
$("#<%=Table1.ClientID %>").css("z-index", "9");
$("#<%=lblConfirmation.ClientID %>").css("display", "none");
$("#<%=imgBtnNo.ClientID %>").css("display", "none");
$("#<%=imgBtnYes.ClientID %>").css("display", "none");
}
</script>
<asp:ImageButton ID="imgBtnYes" runat="server"
ImageUrl="~/Images/btnyes.jpg" OnClick="imgBtnYes_onClick"
OnClientClick="loadingSubmit()" />
HELP...
I dont know why in IE i can see this gif file just fine, but chrome will
return a cancelled status (see network image status below)
My code basically tries to show this gif file inside a hidden panel that
is made visible when a button is clicked
<script type="text/javascript">
function loadingSubmit() {
$("#<%=lblConfirmation.ClientID %>").before("<img
src='Images/478.gif' style='z-index:10;' />");
$("#<%=Table1.ClientID %>").css("z-index", "9");
$("#<%=lblConfirmation.ClientID %>").css("display", "none");
$("#<%=imgBtnNo.ClientID %>").css("display", "none");
$("#<%=imgBtnYes.ClientID %>").css("display", "none");
}
</script>
<asp:ImageButton ID="imgBtnYes" runat="server"
ImageUrl="~/Images/btnyes.jpg" OnClick="imgBtnYes_onClick"
OnClientClick="loadingSubmit()" />
HELP...
Sunday, 15 September 2013
C++ Birthday paradox equation returning 0 for all but the first one
C++ Birthday paradox equation returning 0 for all but the first one
I'm new to C++ programming and have to make a loop for calculating the
probability that two people in the same room have the same birthday. I
know the equation and just don't seem why it's coming up with zero for 3 -
50 people. :/
double chance, base, power, num(2.0);
const double constant(364.0/365.0);
int people(2);
for (int i = 0; i < 49; i++,num++,people++)
{
base = (1.0 - constant);
power = (num * (num - 1.0) / 2.0);
chance = pow(base, power);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "For " << people << " people, "
<< "the probability of two birthdays is about "
<< chance * 100.0 << "%.\n";
}
Any help would be really appreciated.
I'm new to C++ programming and have to make a loop for calculating the
probability that two people in the same room have the same birthday. I
know the equation and just don't seem why it's coming up with zero for 3 -
50 people. :/
double chance, base, power, num(2.0);
const double constant(364.0/365.0);
int people(2);
for (int i = 0; i < 49; i++,num++,people++)
{
base = (1.0 - constant);
power = (num * (num - 1.0) / 2.0);
chance = pow(base, power);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "For " << people << " people, "
<< "the probability of two birthdays is about "
<< chance * 100.0 << "%.\n";
}
Any help would be really appreciated.
Idealized Plot of two overlapping distributions with different skewness?
Idealized Plot of two overlapping distributions with different skewness?
In order to show the effect of increasing right skewness I want to create
two overlapping plots where one distribution is more right skewed than the
other.
So I do something like the following
tmp1fun <- function(m1=0,m2=1,m3=-0.2,m4=3.7,n=20000) {
parms <- JohnsonFit(c(m1,m2,m3,m4), 'use')
rJohnson(n,parms) }
data1.dens <-
rbind(data.frame(var1=rep('now',50000),y=tmp1fun(m3=-0.2,n=50000))
,data.frame(var1=rep('hist',50000),y=tmp1fun(m3=0.2,n=50000)))
library(ggplot2)
ggplot(data1.dens, aes(y, fill = var1))+
geom_density(alpha = 0.5) + coord_cartesian(xlim=c(-4, 4))
However it doesn't look right, it looks more like the mean of the
distribution is shifted with regards to the other. Also I'd kind of like
the density plot to look a bit smoother.
So my question has two parts 1. What distribution and what parameters
should I use so that one distribution looks similar to the other, but just
more right skewed? 2. What is the best graphics tool for producing this
plot? If possible I'd like a filled chart rather than just a line, and
perhaps a higher bandwidth with the smoother.
Thanks for any hints or suggestions.
In order to show the effect of increasing right skewness I want to create
two overlapping plots where one distribution is more right skewed than the
other.
So I do something like the following
tmp1fun <- function(m1=0,m2=1,m3=-0.2,m4=3.7,n=20000) {
parms <- JohnsonFit(c(m1,m2,m3,m4), 'use')
rJohnson(n,parms) }
data1.dens <-
rbind(data.frame(var1=rep('now',50000),y=tmp1fun(m3=-0.2,n=50000))
,data.frame(var1=rep('hist',50000),y=tmp1fun(m3=0.2,n=50000)))
library(ggplot2)
ggplot(data1.dens, aes(y, fill = var1))+
geom_density(alpha = 0.5) + coord_cartesian(xlim=c(-4, 4))
However it doesn't look right, it looks more like the mean of the
distribution is shifted with regards to the other. Also I'd kind of like
the density plot to look a bit smoother.
So my question has two parts 1. What distribution and what parameters
should I use so that one distribution looks similar to the other, but just
more right skewed? 2. What is the best graphics tool for producing this
plot? If possible I'd like a filled chart rather than just a line, and
perhaps a higher bandwidth with the smoother.
Thanks for any hints or suggestions.
How should I structure the logic of an object oriented Role-playing game?
How should I structure the logic of an object oriented Role-playing game?
Please look at this method in my player class of my game:
public void eatSomethingt(Items eatable)
{
foreach (Items i in items )
{
if (i is Ieatable && i.name == eatable.name) //Give items an
ID in the future
{
Ieatable k = i as Ieatable;
k.eat(this);
items.Remove(i);
break;
}
}
}
Basically this will go through the list of items a player has and compare
them to check if the parameter being passed in is eatable, if it is, check
if the player have one. If it gets into the IF statement then the item
will be removed from the players back-pack(items)
The problem is with the line: k.eat(this) It is sent to this method:
public void eat(Player p)
{
Console.WriteLine(p.Name + " Ate the " + name);
p.life = p.life + amountHealed;
}
This feels slightly 'ping-pong'ish as it's the Fruit class that feeds the
item to the player. As my Fruitclass implements the interface iEatable
(which surely makes sense to do) I have to place an eat method in the
classes that implement it.
Please look at this method in my player class of my game:
public void eatSomethingt(Items eatable)
{
foreach (Items i in items )
{
if (i is Ieatable && i.name == eatable.name) //Give items an
ID in the future
{
Ieatable k = i as Ieatable;
k.eat(this);
items.Remove(i);
break;
}
}
}
Basically this will go through the list of items a player has and compare
them to check if the parameter being passed in is eatable, if it is, check
if the player have one. If it gets into the IF statement then the item
will be removed from the players back-pack(items)
The problem is with the line: k.eat(this) It is sent to this method:
public void eat(Player p)
{
Console.WriteLine(p.Name + " Ate the " + name);
p.life = p.life + amountHealed;
}
This feels slightly 'ping-pong'ish as it's the Fruit class that feeds the
item to the player. As my Fruitclass implements the interface iEatable
(which surely makes sense to do) I have to place an eat method in the
classes that implement it.
Qt Unresolved external symbol LNK2019
Qt Unresolved external symbol LNK2019
I know that this topic has been discussed, but i really can't find a
solution for my problem. I want to read data from an XML file with
QDomDocument and i get errors of this type:
main.obj:-1: error: LNK2019: unresolved external symbol
"__declspec(dllimport) public: class QDomElement __cdecl
QDomNode::toElement(void)const "
(__imp_?toElement@QDomNode@@QEBA?AVQDomElement@@XZ) referenced in function
"void __cdecl ListElements(class QDomElement,class QString,class QString)"
(?ListElements@@YAXVQDomElement@@VQString@@1@Z)
I included
#include <QCoreApplication>
#include <QtXml/QtXml>
#include <QDebug>
and i also added Qt += xml to .pro file
I know that this topic has been discussed, but i really can't find a
solution for my problem. I want to read data from an XML file with
QDomDocument and i get errors of this type:
main.obj:-1: error: LNK2019: unresolved external symbol
"__declspec(dllimport) public: class QDomElement __cdecl
QDomNode::toElement(void)const "
(__imp_?toElement@QDomNode@@QEBA?AVQDomElement@@XZ) referenced in function
"void __cdecl ListElements(class QDomElement,class QString,class QString)"
(?ListElements@@YAXVQDomElement@@VQString@@1@Z)
I included
#include <QCoreApplication>
#include <QtXml/QtXml>
#include <QDebug>
and i also added Qt += xml to .pro file
How to decide which JavaScript chunk should be executed in Rails asset pipelining
How to decide which JavaScript chunk should be executed in Rails asset
pipelining
With Rails Asset Pipeline all JavaScript/CoffeeScript gets loaded into one
JavaScript file, that's fine. I need, however, to distinguish when to
execute which JavaScript in order to avoid error messages for instance
when applying jQuery code to manipulate elements, add events, etc.
One common solution is to namespace every element.
<div class="magazines ads panel">...</div>
Where the CoffeeScript file is in
app/assets/javascript/magazines/ads.js.coffee
$(".magazines.ads.panel")
What if I don't want to use namespaces like this? Currently, I just add a
conditional statement to look if the current window location path equals
the one I want:
if window.location.path == 'magazines/ads'
This can get tricky if the path gets a bit more complicated, contains REST
identifiers for the resources, etc. Is there a more formal approach to
encapsulate these requests or even automate them in a nice way?
pipelining
With Rails Asset Pipeline all JavaScript/CoffeeScript gets loaded into one
JavaScript file, that's fine. I need, however, to distinguish when to
execute which JavaScript in order to avoid error messages for instance
when applying jQuery code to manipulate elements, add events, etc.
One common solution is to namespace every element.
<div class="magazines ads panel">...</div>
Where the CoffeeScript file is in
app/assets/javascript/magazines/ads.js.coffee
$(".magazines.ads.panel")
What if I don't want to use namespaces like this? Currently, I just add a
conditional statement to look if the current window location path equals
the one I want:
if window.location.path == 'magazines/ads'
This can get tricky if the path gets a bit more complicated, contains REST
identifiers for the resources, etc. Is there a more formal approach to
encapsulate these requests or even automate them in a nice way?
Semantic issue sending keyboard away?
Semantic issue sending keyboard away?
Unable to send keyboard away while following apples my first ios app
guide. PLEASE HELP
Unable to send keyboard away while following apples my first ios app
guide. PLEASE HELP
Subscribe to:
Comments (Atom)