Monday, 30 September 2013

jemalloc error making redis on centos 6.4 [on hold]

jemalloc error making redis on centos 6.4 [on hold]

I am setting up a new, dedicated, centos 6.4 system with redis. I have
installed redis many times, but have never hit this issue (and have never
been on centos 6.4 before).
cd redis-2.6.16
sudo make install
error:
sh: ./mkreleasehdr.sh: Permission denied
and later:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
When I try to build jemalloc directly (from the /src area of the redis
tarball), other errors include:
cd src && make jemalloc
sh: ./mkreleasehdr.sh: Permission denied
make[1]: Entering directory `/tmp/rediswork/redis-2.6.16/src'
make[1]: *** No rule to make target `jemalloc'. Stop.
make[1]: Leaving directory `/tmp/rediswork/redis-2.6.16/src'
make: *** [jemalloc] Error 2
I also tried redis 2.6.7 and have the same issue.
I have dug all over and can find no path forward.

Questions about tangent spaces of $A^n$.

Questions about tangent spaces of $A^n$.

Let $A^n=k\times \cdots \times k$ be the affine $n$-space, $k$ is a field.
Define $d_xf = \sum_{i=1}^n \frac{\partial f}{\partial T_i}(x)(T_i-x_i)$,
where $x=(x_1, \ldots, x_n) \in A^n$.
Suppose that $X \subset A^n$ is defined by polynomials $f(T)=f(T_1,
\ldots, T_n)$. Define $$ \operatorname{Tan}(X)_x = \{x \in A^n \mid
d_xf(x) = 0, \forall f(T) \in I(X) \}. $$
Suppose that $I(X)$ is generated by $f_1(T), \ldots, f_m(T)$. Then each
element in $I(X)$ is of the form $a_1f_1+\cdots +a_nf_n$ for some $a_i \in
I(X)$. How to show that $d_xf_1, \ldots, d_xf_m$ generated by ideal of
$\operatorname{Tan}(X)_x$? Thank you very much.
I think that the ideal of $\operatorname{Tan}(X)_x$ is $$ \{f \mid f(x) =
0, \forall x \in \operatorname{Tan}(X)_x \}. $$ If $x \in
\operatorname{Tan}(X)_x$, then $d_xf(x)=0$ for all $f\in I(X)$. That is,
$d_xf(x)=0$ for all $f$ which are of the form $a_1f_1+\cdots a_mf_m$.
Therefore the ideal of $\operatorname{Tan}(X)_x$ is contained in the ideal
generated by $d_xf_1, \ldots, d_xf_m$. If $f$ is generated by $d_xf_1,
\ldots, d_xf_m$, we also have $f(x)=0$ for all $x \in
\operatorname{Tan}(X)_x$. Hence $x$ is in the ideal of
$\operatorname{Tan}(X)_x$. Is this correct? Thank you very much.

Comparing php array key value

Comparing php array key value

I am trying to compare two array value. My array1 is like
$a1= array('123' => 'test1, '456' => 'test2', '789' => 'test3')
array2 is like
a2=array('456' => 'match2', '99' => 'match3')
a3 = array();
I want to compare the key value. If array1 key matches array2 key, push
array1 element to a new array
I have
for($i=0; $i < count($a1); $i++){
//i am not sure how to write my codes heree......
if($a1[$i]==a2[$i]{
$a3[]=a1$[$i];
}
}
Can someone help me out on this? Thanks a lot!

SIMULINK - Effects of Tunable/Changable Parameters in a masked subsystem when using Embedded Coder

SIMULINK - Effects of Tunable/Changable Parameters in a masked subsystem
when using Embedded Coder

I have a masked subsystem (in SIMULINK) containing several tunable
parameters. There is a stage where my model will have to be code-generated
(using Embedded Coder) and used for real-time testing and investigation.
What I am not sure about is the effect of using tunable parameters for a
model that requires code generation. I know that people will now
scream,"Why don't you just do it and see what happens?". I have been
waiting for my Embedded Coder license and trying to derisk my models
meanwhile. Without any expert suggestion, I have no way to determine this.
Could anyone please advise?
KR,

Sunday, 29 September 2013

php foreach shows only results for an x result in one of my rows

php foreach shows only results for an x result in one of my rows

There is a forech search, I want to get the results only where $postType<2
. How can I amend my code?
<?php
if ($resultSearch){
foreach ( $resultSearch as $row ){
$idPost=$row['idPost'];
$postType=$row['type'];
$postTypeName=getTypeName($postType);
$postTitle=$row['title'];
$category=$row['category'];//real category name
$fcategory=$row['fcategory'];//frienfly name category
$idCategoryParent=$row['idCategoryParent'];
$fCategoryParent=$row['parent'];
$postImage=$row['image'];
$insertDate=setDate($row['insertDate']);
if ($row["hasImages"]==1){
$postImage=getPostImages($idPost,$insertDate,true,true);
}
else $postImage=getPostImages(true,true,true,true);//there's no image
$postUrl=itemURL($idPost,$fcategory,$postTypeName,$postTitle,$fCategoryParent);?>

How to remove the spacing between the line and the content?

How to remove the spacing between the line and the content?

Working on the latest Wordpress Project - couldn't find a way to remove
the spacing between the line and the post.
H1 was removed already, leaving the page with nothing but the content.
I've tried to dig in the code and altering a few commands but didn't find
the solution so I'm addressing this site.
Theme: Decode, version 2.7.6
Visual thing: http://i.stack.imgur.com/Y1cqA.jpg
Will provide the actual code if needed.
Thanks in advance and have a nice day onwards.
Schiva

jQuery: absolute pathname before hash

jQuery: absolute pathname before hash

I'm currently experiencing some conflict between a hashchange function I
have set up and jQuery mobile (used for sliding page transitions).
To demonstrate here's an isolated demo on my server:
http://nealfletcher.co.uk/transition/
Click on transition click which slides the relevant page in, as it should
and appends the url accordingly: /transition/news.

This is where the problem lies, click on news hash click and this will
fire my hashchange function and load in the relevant div, BUT instead of
the url being like so: /transition/news/#news-01 the url is being rendered
like so /transition/#news-01 which causes problems when navigating to the
url.
Is there anyway to force the /news/ to be added before the hash, so I get
/transition/news/#news-01 instead of /transition/#news-01?

Any suggestions would be greatly appreciated!
jQuery:
$(document).ready(function () { $(window).hashchange(function () { var
hash = location.hash; if (hash) { var element =
$('.click-block[data-hook="' + hash.substring(1) + '"]'); if (element)
showDetail(element); } });
$(document).ready(function () {
$(document).hashchange();
var $container = $('#main-grid, #news-grid');
$(function () {
$container.imagesLoaded(function () {
$container.isotope({
itemSelector: '.grid-block, .grid-break, .hidden',
animationEngine: 'best-available',
filter: '*:not(.hidden), .grid-block',
masonry: {
columnWidth: 8,
gutterWidth: 25
}
});
});
});
$(".click-block").click(function () {
document.location.hash = $(this).attr('data-hook');
});
});
function showDetail(element) {
var newHeight = $('#post-' + element.attr('data-hook')).height();
$('#post-' +
element.attr('data-hook')).removeClass('hidden').addClass('grid-break').delay(300).fadeIn('slow');
newHeight = (Math.floor((newHeight + 10) / 230) + 1) * 230 - 10;
$('#post-' + element.attr('data-hook')).css('height', newHeight);
element.children('.up-arrow').fadeIn('slow');
setTimeout(function () {
$('html, body').animate({
scrollTop: $('#post-' +
element.attr('data-hook')).offset().top - 90
}, "slow");
}, 1500);
$('#main-grid').isotope();
$('#news-grid').isotope();
}

i want to filter my datagrid view

i want to filter my datagrid view

I want to filter my DataGridView based on two textboxes (first name(fname)
and second name(sname), but it gets filtered just based on fname
Here is my code:
Try
Dim conn As New OleDbConnection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + IO.Directory.GetCurrentDirectory + "\Kyc.mdb"
Dim cmdfilter As String = " select ID as ÇáÑÞã_ÇáæØäí,fname as
ÇáÇÓã_ÇáÇæá,sname as ÇáÇÓã_ÇáËÇäí,thname as ÇáÇÓã_ÇáËÇáË,finame as
ÇáÇÓã_ÇáÑÇÈÚ from O_name where fname like '%" & fname.Text & "' OR
sname like '%" & sname.Text & " ' "
Dim cmdcommand As New OleDbCommand
Dim dataadabtar As New OleDbDataAdapter
Dim table As New DataTable
With cmdcommand
.CommandText = cmdfilter
.Connection = conn
End With
With dataadabtar
.SelectCommand = cmdcommand
.Fill(table)
End With
DataGridView1.DataSource = table
DataGridView1.DataSource = Nothing
For i = 0 To table.Rows.Count - 1
With DataGridView1
.Rows.Add(table.Rows(i)("ÇáÑÞã_ÇáæØäí"),
table.Rows(i)("ÇáÇÓã_ÇáÇæá"), table.Rows(i)("ÇáÇÓã_ÇáËÇäí"),
table.Rows(i)("ÇáÇÓã_ÇáËÇáË"), table.Rows(i)("ÇáÇÓã_ÇáÑÇÈÚ"))
End With
Next
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub

Saturday, 28 September 2013

Can I know my mac have a ethernet connection?

Can I know my mac have a ethernet connection?

How can I know my mac is connect to network by ethernet. Is there any
framework in cocoa can help me?
I just find some wifi connection check framework ,but no ethernet
connection check .

connect Wifly(RN-171) module's SPI to Arduino's SPI pins?

connect Wifly(RN-171) module's SPI to Arduino's SPI pins?

I've searched a lot about the Wifly(RN-171 Wifi Bee) module on how to
connect the SPI pins to Arduino's SPI but it seems that the SPI pins are
not even connected to the module's Pins!
These are the links for the module's datasheets:
http://www.dfrobot.com/image/data/TEL0067/rn-171-ds-v3.21.pdf
http://www.dfrobot.com/image/data/TEL0067/rn-171-xv-ds-v1.04r.pdf
I was thinking if there's a way to configure some GPIO pins to connect to
the spi pins, but also I couldn't find anything about it.
I need some help here!

BBcode parser, size not changing

BBcode parser, size not changing

I am using a simple BBCode parser, which I have had to manipulate and add
things to as it has a limited number of commands, which then I have had to
extend. Everything else works perfectly, but the size is just not
changing. It does not show the BBCode tags, so it is converting it to
something but it is not recognising the change in the font-size I guess.
Any ideas?
/* Size */
$match["size"] = "/\[size=([0-7]+(%|px|em)?)\](.*?)\[\/size\]/is";
$replace["size"] = "<span style=\"font-size: $1;\">$3</span>";
$bbcode = preg_replace($match, $replace, $bbcode); ....etc.
I put the size from 0-7 here as the size possibilities only go up to 7 in
my editor...

Friday, 27 September 2013

CSS menu: dropdowns not showing all

CSS menu: dropdowns not showing all

I'm having trouble getting this menu to work properly. The articles and
shows menu should show a dropdown when I hover over the image-text. It
does, but only shows the very last li item instead of the entire list.
Here is the html:
<ul id="mainmenu">
<li id="nav_hom"><a href="index.html">Home</a></li>
<li id="nav_art"><a href="articles.html">Articles</a>
<ul>
<li><a href="cg.html">Cardboard Gamer</a></li>
</ul>
</li>
<li id="nav_show"><a href="shows.html">Shows</a>
<ul>
<li><a href="rez.html">ReZonance</a></li>
<li><a href="dd.html">Dumpster Diving</a></li>
<li><a href="letsplay.html">Let's Play!</a></li>
</ul>
</li>
<li id="nav_abt"><a href="about.html">About</a></li>
<li id="nav_con"><a href="contact.html">Contact</a></li>
</ul>
And here is the relevant CSS:
#mainmenu{position:relative; list-style-type:none; width:800px;
height:50px; margin:0; padding:0; background: url(menu.png) no-repeat;}
#mainmenu li a{position:absolute; margin:0; padding:0; display:block;
height:50px; background: url(menu.png) no-repeat; text-indent:-9999px;
overflow:hidden; font-size:1%;}
#mainmenu li:hover ul {display:block; position:relative; top:50px;}
#mainmenu ul {list-style-type:none; /*display:none;*/ z-index:999;}
#mainmenu ul li a {z-index:999; overflow:visible; height:25px;
width:160px; background:#C78120; border-top-style:solid;
border-bottom-style:solid; border-width:1px; border-color:#000000;
display: block; padding:2px; font-size:14px; text-indent:1em;
text-decoration:none; color:black;}
#mainmenu ul li:hover a{background:#9e0b0f;}
li#nav_hom a{left:0; width:160px; background-position:0 0;}
li#nav_art a{left:160px; width:160px; background-position:-160px 0;}
li#nav_show a{left:320px; width:160px; background-position:-320px 0; }
li#nav_abt a{left:480px; width:160px; background-position:-480px 0; }
li#nav_con a{left:640px; width:160px; background-position:-640px 0; }
li#nav_hom a:hover{background-position:0 -50px;}
li#nav_art a:hover{background-position:-160px -50px;}
li#nav_show a:hover{background-position:-320px -50px;}
li#nav_abt a:hover{background-position:-480px -50px;}
li#nav_con a:hover{background-position:-640px -50px;}
The second block of CSS is just there to adjust the positioning of the
menu image and shouldn't be affecting the dropdown parts of it, but I
included it in case. The closest I've gotten to making it work is:
#mainmenu ul li {height:25px;}
Which shows all the li items, but then screws up the positioning of the
other links in the menu.
#mainmenu ul li {position:absolute;}
This makes the dropdown show up in the right spot and doesn't break the
main menu, but doesn't show all the li items. This is so frustrating. Any
help? Thanks.

parse response time minute wise python

parse response time minute wise python

I have an input file which looks like this and I want to calculate the
response times by minutes.
datapoint,time,transaction,PT,Responsetime,errorcode
a06i0000003uNQOAA2,2013-09-26T19:15:55.873+0000,EditMode,57,109.877193,0
a06i0000003uNQOAA2,2013-09-26T19:15:55.875+0000,Update,58,733.741379,0
a06i0000003uNQOAA2,2013-09-26T19:15:55.875+0000,ViewObject,94,386.893617,0
a06i0000003uNQOAA2,2013-09-26T19:16:25.889+0000,EditMode,110,109.209091,0
a06i0000003uNQOAA2,2013-09-26T19:16:25.889+0000,Update,109,743.660550,0
a06i0000003uNQOAA2,2013-09-26T19:16:25.890+0000,ViewObject,181,376.198895,0
a06i0000003uNQOAA2,2013-09-26T19:16:55.904+0000,EditMode,162,109.080247,0
a06i0000003uNQOAA2,2013-09-26T19:16:55.904+0000,Update,161,738.683230,0
a06i0000003uNQOAA2,2013-09-26T19:16:55.904+0000,ViewObject,266,372.627820,0
a06i0000003uNQOAA2,2013-09-26T19:17:25.918+0000,EditMode,212,108.580189,0
a06i0000003uNQOAA2,2013-09-26T19:17:25.919+0000,Update,213,735.244131,0
a06i0000003uNQOAA2,2013-09-26T19:17:25.919+0000,ViewObject,350,362.394286,0
a06i0000003uNQOAA2,2013-09-26T19:17:55.933+0000,EditMode,263,107.954373,0
a06i0000003uNQOAA2,2013-09-26T19:17:55.933+0000,Update,264,732.598485,0
a06i0000003uNQOAA2,2013-09-26T19:17:55.934+0000,ViewObject,431,359.965197,0
a06i0000003uNQOAA2,2013-09-26T19:18:25.947+0000,EditMode,314,107.815287,0
a06i0000003uNQOAA2,2013-09-26T19:18:25.948+0000,Update,315,733.292063,0
a06i0000003uNQOAA2,2013-09-26T19:18:25.948+0000,ViewObject,516,360.098837,0
a06i0000003uNQOAA2,2013-09-26T19:18:55.961+0000,EditMode,368,107.559783,0
a06i0000003uNQOAA2,2013-09-26T19:18:55.961+0000,Update,366,731.808743,0
a06i0000003uNQOAA2,2013-09-26T19:18:55.962+0000,ViewObject,600,359.780000,0
a06i0000003uNQOAA2,2013-09-26T19:19:25.975+0000,EditMode,418,107.406699,0
a06i0000003uNQOAA2,2013-09-26T19:19:25.976+0000,Update,419,731.613365,0
a06i0000003uNQOAA2,2013-09-26T19:19:25.976+0000,ViewObject,686,358.169096,0
a06i0000003uNQOAA2,2013-09-26T19:19:55.989+0000,EditMode,470,107.265957,0
a06i0000003uNQOAA2,2013-09-26T19:19:55.990+0000,Update,467,732.107066,0
a06i0000003uNQOAA2,2013-09-26T19:19:55.990+0000,ViewObject,768,360.317708,0
a06i0000003uNQOAA2,2013-09-26T19:20:26.003+0000,EditMode,521,107.149712,0
a06i0000003uNQOAA2,2013-09-26T19:20:26.004+0000,Update,521,733.990403,0
a06i0000003uNQOAA2,2013-09-26T19:20:26.004+0000,ViewObject,853,361.735053,0
a06i0000003uNQOAA2,2013-09-26T19:20:56.018+0000,EditMode,572,107.117133,0
a06i0000003uNQOAA2,2013-09-26T19:20:56.018+0000,Update,572,733.139860,0
a06i0000003uNQOAA2,2013-09-26T19:20:56.018+0000,ViewObject,937,361.497332,0
a06i0000003uNQOAA2,2013-09-26T19:21:26.032+0000,EditMode,623,106.855538,0
a06i0000003uNQOAA2,2013-09-26T19:21:26.032+0000,Update,623,732.057785,0
a06i0000003uNQOAA2,2013-09-26T19:21:26.032+0000,ViewObject,1020,361.191176,0
a06i0000003uNQOAA2,2013-09-26T19:21:56.046+0000,EditMode,674,107.112760,0
a06i0000003uNQOAA2,2013-09-26T19:21:56.046+0000,Update,674,731.721068,0
a06i0000003uNQOAA2,2013-09-26T19:21:56.046+0000,ViewObject,1106,360.622966,0
a06i0000003uNQOAA2,2013-09-26T19:22:26.059+0000,EditMode,724,107.041436,0
This is the program I came up with however, this is giving me the entire
response time and not for every minute in specific. Not sure where I am
going wrong. Any pointers would be greatly appreciated.
import numpy as np
from scipy import stats
rtlist = []
reqpslist = []
newFile = open('100ulog.csv','r')
FILE = newFile.readlines()
newFile.close()
for line in FILE:
newline1 = line.split(":")
newline2 = line.split(",")
min = newline1[1]
if newline1[1] == min:
rtlist.append(newline2[4])
reqpslist.append(newline2[3])
print rtlist
else:
rtlist[:] = []
min = min+1

Struts2; keeping a session open for StrutsSpringTestCase JUnit tests

Struts2; keeping a session open for StrutsSpringTestCase JUnit tests

My project architecture is Struts2 with Spring integration and
JPA/Hibernate. StrutsSpringTestCase base class is utilized for JUnit
integration tests.
Under normal circumstances, the following configuration in web.xml keeps a
single session open from start to finish of each request:
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
As a result, all lazy loading works fine in all services. For example:
@Override
public Person find(int id) {
Person person = personDao.find(id);
// Take care of lazy loading before detaching the object for
// the view layer...
person.getGender().getCode();
// Detach the object so that it can be used for data transfer
// (as a DTO) without causing JPA issues and errors...
getEntityManager().detach(person);
return person;
}
Now... issues arise when I try to run the integration tests, which are
independent of the OpenEntityManagerInViewFilter configuration in web.xml.
What happens is that since there is no session being kept open from start
to finish of each request, lazy loading statements like
"person.getGender().getCode()" don't work any longer, and I get the "could
not initialize proxy - no Session" errors.
One solution I'm aware of is to force the @Transactional annotation upon
the service methods that are having the lazy-loading issues, which will
result in a session being open from start to finish of the method call. I
tested it and it fixed the problem:
@Transactional
@Override
public Person find(int id) {
Person person = personDao.find(id);
// Take care of lazy loading before detaching the object for
// the view layer...
person.getGender().getCode();
// Detach the object so that it can be used for data transfer
// (as a DTO) without causing JPA issues and errors...
getEntityManager().detach(person);
return person;
}
However, this could be overkill as the method doesn't need a transaction
under normal circumstances. I'm wondering if there is another solution
that doesn't require to compromise on the service side.
Is there something I can add to my test classes (which extend
StrutsSpringTestCase) to keep the session open? Or is there perhaps an
elegant configuration solution on the Spring or JUnit side?
Here is my Spring configuration file - applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"
default-dependency-check="all"
default-lazy-init="false"
default-autowire="byName">
<!-- *************** MAIN CONFIGURATION SECTION *************** -->
<!-- Bean post-processor for JPA annotations. -->
<!-- Make the Spring container act as a JPA container and inject an
EnitityManager from
the EntityManagerFactory. -->
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"
autowire="no"
dependency-check="none" />
<!-- ** Data Source Configuration ** -->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close"
autowire="no"
dependency-check="none">
<!-- Database configuration: -->
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost/**********" />
<property name="user" value="**********" />
<property name="password" value="**********" />
<!-- C3P0 pooling properties configuration: -->
<property name="acquireIncrement" value="4" />
<property name="initialPoolSize" value="4" />
<property name="minPoolSize" value="4" />
<property name="maxPoolSize" value="20" />
<property name="maxIdleTime" value="600" />
<property name="maxConnectionAge" value="1800" />
</bean>
<!-- ** JPA Vendor Selection ** -->
<bean id="jpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
autowire="no"
dependency-check="none" />
<!-- ** JPA Vendor and Entity Manager Configuration ** -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
autowire="no"
dependency-check="none">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
<property name="jpaProperties">
<props>
<prop
key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<!-- Have the JPA vendor manage the database schema: -->
<prop key="hibernate.hbm2ddl.auto">create</prop>
<prop
key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop
key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
<prop key="hibernate.max_fetch_depth">4</prop>
<prop key="hibernate.jdbc.batch_size">1000</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">false</prop>
</props>
</property>
</bean>
<!-- ** Transaction Manager Configuration ** -->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
autowire="no"
dependency-check="none">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<!-- ** Transaction Annotation Configuration; classes/functions with
@Transactional will
get a framework transaction. ** -->
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- **** DETAILED SERVICE BEAN CONFIGURATION WAS TAKEN OUT TO SHORTEN
THE FILE **** -->
</beans>
I would appreciate any pointers.

Empty value of a search form

Empty value of a search form

I want to search in a adress book from a page which I am developing. The
adress book is a content of another page and the url of the adress book on
this page is http://example.com/start.php. This adress book has its own
search field, which I will use for my page. I have written the following
search form:
<form action="http://example.com/start.php" method="post" target="_blank">
<div>
<input type="hidden" value="adress" name="cmd" />
<input id = "adressinput" name="search" type="text" title="Search in the
adress book [ctrl-f]" accesskey="f" value="adress book" />
<input id="refresh" title="refreshnow" name="refresh" type="image"
src="icons/Downloads/arrow-circle-single.png" class="iconbutton"/>
</div>
</form>
The problem is that, when I write somethung in the text box of my form and
after that click on the icon refreshnow, the page
http://example.com/start.php (the adress book) is displayed, but the
search field of the this page has still an empty value and I don't get any
result, of course.
This wasn't my first search form. I have written similar forms and they
work, so, I have no idea why it doesn't work.

How to update wordpress content

How to update wordpress content

add_filter('the_content','filter_trendland_content');
//create a the function to get the content of the page by using the hook
the_content
function filter_trendland_content($content) {
$getdata = $content;
if ( preg_match_all(
'#(?:<a.+?href=["|\'](?P<link_url>.+?)["|\'].*?>\s*)?(?P<img_tag><img.+?src=["|\'](?P<img_url>.+?)["|\'].*?>){1}(?:\s*</a>)?#is',
$getdata, $images ) ) {
foreach ( $images[img_url] as $key => $value) {
$subdomain = rand( 1, 3 );
$newurl="yaseen.media$subdomain.com";
$content = preg_replace('/\bmedia.trendland.com\b/', $newurl,
$value);
print $content;
}
print $getdata;
}
//return $getdata;
}
I am using the above method to replace the url's with the new one and
update the content of the page but the page content is still the same so
please help me with this..

Thursday, 26 September 2013

why do we have use Model.new for def new and def create?

why do we have use Model.new for def new and def create?

following the RailsTutorial book
(http://ruby.railstutorial.org/chapters/sign-up#sec-signup_form)
we have the following snippet:
def new
@user = User.new
end
def create
@user = User.new(user_params)
....
end
why do we need to recreate the model, if the user goes to /users/new def
new is called and @user variable is initialzed, but on post request (def
create), User.new is recalled, why is this? if we are going to create a
new user model on create then why create it in def new?

Wednesday, 25 September 2013

python breaking if statement inside for loop

python breaking if statement inside for loop

I want the if-statement to break if the condition is met, because
currently if it isn't broken early then I get some mishaps in my code.
The problem is, I am not sure where to put the break. When I put it where
it is shown here I get "Unexpected indent", but when I put it back a level
I get an error with the else-statement saying "Invalid Syntax".
So I am not sure what to do. Any help would be appreciated.
def pTurn(CampLoc, AICampLoc, score, yourHits, cHits):
if yourHits < 5:
hGuess = int(raw_input("Enter a co-ordinate to air-strike: "))
print "Air-striking co-ordinate: %d" % hGuess
for cSpot in AICampLoc:
if hGuess == cSpot:
yConfirMsg = "Kill confirmed!!"
yourHits += 1
score += 100
AICampLoc.remove(hGuess)
break
else:
yConfirMsg= "No casualties"
score = score
yourHits = yourHits

Thursday, 19 September 2013

Create a 'BufferedReader' out of a JTextField

Create a 'BufferedReader' out of a JTextField

I'm fairly new to Java, and I need to create a 'BufferedReader' for a
JTextField. What needs to happen is, when the program calls my getText()
method, It needs to wait until it recieves input from the Enter key event
handler. If i do something like:
String input = null;
while(true) {
if(!input.equals(null)) {
break;
}
}
I get nullpointerexception errors. I've thought about it, and determined
that since getText() has to return data to the method that called it, I
would have to run like a nested method inside the getText() method, that
would be able to run the code to run the data. Any ideas?

How can I make my rails time input fields respect server timezone?

How can I make my rails time input fields respect server timezone?

I have a date_select and time_select for a date/time field in my Rails
app, which I am running locally in development mode. My problem is that
the date/time I enter does not align with the timezone of the server
instance.
As an example, my computer's clock currently says it's 5:34pm on Sept. 19,
2013. (I am in Central time zone in case it has any bearing.) If I fill
out my form with values equating to "September 19, 2013 5:34 PM", I am
seeing this parsed as "2013-09-19 17:34:00 UTC". However, Time.now returns
"2013-09-19 17:38:00 -0600", and Time.current returns "2013-09-19 23:38:58
UTC". Basically, the form is assuming the time in UTC, but is not aligning
it with my server's UTC time (6 hour difference).
How can I ensure the form's inputs get converted to the proper zone offset?

How do I add these php tags to the tag?

How do I add these php tags to the tag?

I am modifying a wordpress function. I have the following code:
$output .= $r['link_before'] . '<ul><li class="bbp-forum-info"><a href="'
. esc_url( $permalink ) . '" class="bbp-forum-link">' . $title .
'</a></li>' . $counts . '<li class="bbp-forum-freshness">' . $subfresh .
'</li></ul>' . $r['link_after'];
And I need the ul tag to look like this:
<ul id="bbp-forum-<?php bbp_forum_id(); ?>" <?php bbp_forum_class(); ?>>
However, I don't know how to add those php tags inside of that code. I
have tried it in a number of different ways, but haven't been able to get
it to work. Any advice?

List of interfaces from List of implementation class

List of interfaces from List of implementation class

I have the following code:
List<MassEditionObject> objects = getProjects();
where MassEditionObject is an interface that is implemented by the Project
class.
getProjects() returns List<Project>, which seems like it should be fine
because Project is a MassEditionObject.
However, Eclipse is giving me this error: Type mismatch: cannot convert
from List<Project> to List<MassEditionObject>
I understand the general idea of interfaces and how to use them, I'm just
not sure why this is invalid.
Thanks, and sorry if this question has been posted. I searched and found
similar situations but none that answered this problem.

Export to Excell stoped working when i added a AJAX panel

Export to Excell stoped working when i added a AJAX panel

I am just starting to learn how to use Ajax and i am stuck on this.
I have buttons in my ASP.net web site that work perfectly but the export
to Excel and Export to CVS stopped working after I added a Ajax panel.
they worked before I added the panel and when I debug the function
To_Excel_Click is called is processed but it just does not create the
excel file. Something in Ajax I think is preventing the file to be created
Thank you for any help
HTML Ajax
</asp:Content>
<asp:Content ID="BodyContent" runat="server"
ContentPlaceHolderID="MainContent">
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<contenttemplate>
<asp:Button ID="BT1" runat="server" Text="Submit" Visible="false"
onclick="BT1"/>
<asp:Button ID="BT2" runat="server" Text="Submit" Visible="false"
onclick="BT2" />
<asp:Button ID="BTMakeCVS" runat="server" Text="Submit to CVS"
Visible="false" onclick="BTMakeCVS_Click" />
<asp:Button ID="To_Excel" runat="server" Text="To Excel"
onclick="To_Excel_Click" Visible="false" AutoPostBack="True"/>
</fieldset><fieldset class="Matainancefieldset3">
<asp:GridView ID="GVData" runat="server" Visible="false">
<RowStyle CssClass="Row" />
<AlternatingRowStyle CssClass="AltRow" />
<PagerTemplate><table><tr><td>
<asp:PlaceHolder ID="ph" runat="server">
</asp:PlaceHolder></td></tr></table>
</PagerTemplate>
</asp:GridView>
<asp:Label ID="LBExcell" runat="server" Text="Model:"
Visible="false"></asp:Label>
</contenttemplate>
</asp:UpdatePanel>
</asp:Content>
C#
protected void To_Excel_Click(object sender, EventArgs e)
{
ExcelExport.Export("Summary.xls", GVData);
}
public class ExcelExport
{
public static void Export(string fileName, GridView gv)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader(
"content-disposition",
string.Format("attachment;filename={0}", fileName));
HttpContext.Current.Response.ContentType = "application/ms-excel";
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
Table table = new Table();
table.GridLines = gv.GridLines;
if (gv.HeaderRow != null)
{
ExcelExport.PrepareControlForExport(gv.HeaderRow);
table.Rows.Add(gv.HeaderRow);
}
foreach (GridViewRow row in gv.Rows)
{
ExcelExport.PrepareControlForExport(row);
table.Rows.Add(row);
}
if (gv.FooterRow != null)
{
ExcelExport.PrepareControlForExport(gv.FooterRow);
table.Rows.Add(gv.FooterRow);
}
table.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
}
}
private static void PrepareControlForExport(Control control)
{
for (int i = 0; i < control.Controls.Count; i++)
{
Control current = control.Controls[i];
if (current is LinkButton)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current
as LinkButton).Text));
}
else if (current is ImageButton)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current
as ImageButton).AlternateText));
}
else if (current is HyperLink)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current
as HyperLink).Text));
}
else if (current is DropDownList)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current
as DropDownList).SelectedItem.Text));
}
else if (current is CheckBox)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current
as CheckBox).Checked ? "True" : "False"));
}
if (current.HasControls())
{
ExcelExport.PrepareControlForExport(current);
}
}
}
}

I am getting AFHTTPClient Failed to call designated initializer

I am getting AFHTTPClient Failed to call designated initializer

My code was ok until I downloaded the latest AFNetworking library from
CocoaPods.
Now I am getting:
*** Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'AFHTTPClient Failed to call
designated initializer. Invoke `initWithBaseURL:` instead.'
I didn't understand what is wrong.

C# App Make a log of changes in a directory/subdirectories

C# App Make a log of changes in a directory/subdirectories

I'm creating an app that checks for changes in ALL the files in a
directory/subdirectories in the previous 24 hours. (or any other time
given).
I've seen lots of other codes but not all of them contain what I'm looking
for.
This is my code so far:
string myDirectory = Path.Combine(@"path");
var directory = new DirectoryInfo(myDirectory);
DateTime from_date = DateTime.Now.AddDays(-1);
DateTime to_date = DateTime.Now;
var files = directory.GetFiles().Where(file => file.LastWriteTime >=
from_date && file.LastWriteTime <= to_date).ToArray();
Console.WriteLine(files);
In the end it has to create a .txt file containing the changes: (name of
the files that were changed). I already got this code working.
FileStream filestream = new FileStream(@"path", FileMode.Create);
var streamwriter = new StreamWriter(filestream);
streamwriter.AutoFlush = true;
Console.SetOut(streamwriter);
Console.SetError(streamwriter);
The problem is that the code above only writes the most previous change in
the given directory. What I want is ALL the changes in 24 hours in the
given directory.
I am kind of new to this, and my goal is to keep the code nice and compact.
I am NOT, I repeat NOT, looking for FileSystemWatcher, I don't want my
server to stay on for 24 hours. I want to boot this program once a day,
make a log, close it.
If anyone can help me out with this, or at least give me something to
start with, I would very much appreciate it!

how to detect screen mirroring

how to detect screen mirroring

I have been wondering if there is any way in the android API (or any other
lib/framework) that can help me to detect if my device screen is mirrored
using WiDi,Miracast or MHL or basically any other technique for mirroring
your screen.
Br, Inx

Wednesday, 18 September 2013

How to Implemen client code for the getting jar which is generated by wsdl2Java by CXF

How to Implemen client code for the getting jar which is generated by
wsdl2Java by CXF

I am new to Webservice. I got xxxService.wsdl file from my client. I have
generated jar using the following command with apache CXF. wsdl2java.bat
-V -d com\xxxx\service\sso -clientjar xxxwsservice.jar
xxxTokenWebService.wsdl.
Now i got the jar. I am using apache-cxf-2.7.6 ,jdk1.6.0_37 and
jboss-eap-5.1.2 softwares.My doubt is how to write the client code. Means
which class is starting point to invoke the service. Is there any
configuration for credentials, timeout,content type and content length.
Please advise me to implement the client.
Thanks in advance, Apar.

Wordpress: unable to get the user logged in

Wordpress: unable to get the user logged in

The header.php in my project includes at the very beginning a php file
with content like this:
global $profile;
global $user;
if(is_user_logged_in()){
global $current_user;
get_currentuserinfo();
$user = array();
$user['username'] = $current_user->user_login;
$user['email'] = $current_user->user_email;
..
..
}
On my page template file I am trying to get info from this user object,
through the following code
$.ajax({ url: path + '/gmail/user.php',
type: 'post',
success: function(status) {alert(status);} }
});
which is calling
<?php
print_r($user);
?>
and I get an empty alert. I get this whether I log in or not. Why could
this happen? Is there another solution to picking up the logged in user?
maybe with sql?

Infinite Loop when parse XML File to Flat Flie. Bug SpringBatch or Not

Infinite Loop when parse XML File to Flat Flie. Bug SpringBatch or Not

I tried to parse an xml file to flatefile. All worked fine except at the
end. In debug Mode the cause of the infinite loop is due to the method
moveCursorToNextFragment( reader) in
org.springframework.batch.item.xml.StaxEventItemRe ader.class.
More precisily in this part of method
while (reader.peek() != null && !reader.peek().isStartElement()) {
reader.nextEvent();
}
it seems that these conditions are not sufficient to recognize the end of
the document. I replace this part of code by this code to be sure the end
of the document test
while (reader.peek() != null && !reader.peek().isStartElement() &&
!reader.peek().isEndDocument()) {
reader.nextEvent();
}
if (reader.peek() == null || reader.peek().isEndDocument()) {
return false;
}
below my context file and the link for an INSEE xmlfile :
http://lei-france.insee.fr/Telechargement.do I always taked the full file.
Here is my context file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.2.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
p:dataSource-ref="dataSource"/>
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher"
p:jobRepository-ref="jobRepository"
p:taskExecutor-ref="taskExecutor" />
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"
p:dataSource-ref="dataSource"
p:transactionManager-ref="transactionManager" />
<bean id="taskExecutor"
class="org.springframework.core.task.SimpleAsyncTaskExecutor"/>
<!-- DATASOURCE -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver" />
<property name="url"
value="jdbc:oracle:thin:@gulli:1521:OPE" />
<property name="username" value="xxxxxx" />
<property name="password" value="xxx" />
</bean>
<!-- ITEM READER -->
<bean id="itemReader" scope="step"
class="org.springframework.batch.item.xml.StaxEventItemReader"
p:resource="insee/lei.xml"
p:fragmentRootElementName="LEIRecord"
p:unmarshaller-ref="inseeMarshaller" />
<bean id="inseeMarshaller"
class="org.springframework.oxm.xstream.XStreamMarshaller"
p:autodetectAnnotations="true" p:encoding="UTF-8">
<property name="aliases">
<props>
<prop key="LEIDirectory">fr.cdn.dtc.etudes.emir.insee.LEIDirectory</prop>
<prop key="LEIRecord">fr.cdn.dtc.etudes.emir.insee.LEIRecord</prop>
<prop key="LegalEntity">fr.cdn.dtc.etudes.emir.insee.LegalEntity</prop>
<prop
key="OtherIdentifiers">fr.cdn.dtc.etudes.emir.insee.OtherIdentifiers</prop>
<prop key="OtherNames">fr.cdn.dtc.etudes.emir.insee.OtherNames</prop>
<prop key="RelatedLEI">fr.cdn.dtc.etudes.emir.insee.RelatedLEI</prop>
<prop key="Event">fr.cdn.dtc.etudes.emir.insee.Event</prop>
<prop
key="OtherAddresses">fr.cdn.dtc.etudes.emir.insee.OtherAddresses</prop>
</props>
</property>
</bean>
<!-- ITEM WRITER DELIMETED LENGTH-->
<bean id="itemWriterFile"
class="org.springframework.batch.item.file.FlatFileItemWriter"
p:resource-ref="outputDelimitedResource"
p:lineAggregator-ref="lineAggregator"
p:shouldDeleteIfExists="true"
/>
<bean id="outputDelimitedResource"
class="org.springframework.core.io.FileSystemResource">
<constructor-arg value="target/outputs/inseeOutput.txt" />
</bean>
<bean id="lineAggregator"
class="org.springframework.batch.item.file.transform.DelimitedLineAggregator"
p:delimiter=";"
p:fieldExtractor-ref="fieldExtractor" />
<bean id="fieldExtractor"
class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor"
p:names="le" />
<batch:job id="inseeJob" job-repository="jobRepository" >
<batch:step id="inseeStep">
<batch:tasklet>
<batch:chunk reader="itemReader" writer="itemWriterFile"
commit-interval="10" />
<batch:transaction-attributes isolation="DEFAULT"
propagation="REQUIRED" timeout="30"/>
</batch:tasklet>
</batch:step>
</batch:job>
</beans>
Best Regards Clément

Robust solution to dynamically transform SVG

Robust solution to dynamically transform SVG

Apparently, IE10 does not support CSS transformations for SVGs, only
attribute transformations like so (JSFIDDLE):
<svg><rect id="myrect" width="200" height="200"></rect></svg>

setTimeout(function()
{
var r = document.getElementById("myrect")
//works in IE
//r.setAttribute("transform","scale(1.5)")
//does not work in IE
r.style.transform = r.style.WebkitTransform = "scale(1.5)"
},1000);
Where supported, I want to include a smooth transition:
#myrect { transition: all 1s; }
The way I see it, a smooth transitions requires a CSS transformation,
whereas IE requires an attribute transformation.
So what's the best strategy? Test for IE, then if IE use an attribute
transformation, else use a CSS transformation?
Any thoughts much appreciated!

Awk split file give incomplete lines

Awk split file give incomplete lines

my file is a csv file with comma delimited fields.
I tried to split the file into multiple files by first field. I did the
following.
cat myfile.csv | awk -F',' '{print $0 > "Mydata"$1".csv"}'
It does split the file, but the file is corrupted, the last line of each
file is not complete. The breaking position seems random. Anyone has the
same problem?

Cannot call method of on of undefined

Cannot call method of on of undefined

I was wondering if someone could tell me why the below code is not
working. The first 2 on functions are working and then the last on
function is not working and I am getting the error message "cannot call
method of on of undefined."
It seems to not like this line, textF.getEl().on('click', function() {
bUpdateSwitch.on({'click': function (){ var textF =
Ext.getCmp('switchStatus');
textF.enable();
textF.setReadOnly(false);
var textValue = textF.getValue();
if(textValue && Ext.isString(textValue) &&
(textValue.toUpperCase().indexOf("O") != -1 ||
textValue.toUpperCase().indexOf("R") != -1 ||
textValue.toUpperCase().indexOf("P") != -1))
{
textF = Ext.getCmp('cbServCarrier');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('rateAuthorityType');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('rateAuthorityId');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('rateAuthorityNumber');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('rateAuthorityItem');
textF.enable();
textF.setReadOnly(false);
}
}});
bUpdateSwitch.on({'click': function (){
var textF = Ext.getCmp('cbServCarrier');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('cbSwitchFSAC');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('industryComment');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('physicallyServed');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('cbPrivateCarrier');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('cbStation');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('cbStationFSAC');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('scrsEDate');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('accountingEDate');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('scrsExDate');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('accountingExDate');
textF.enable();
textF.setReadOnly(false);
textF = Ext.getCmp('changeDescription');
textF.enable();
textF.setReadOnly(false);
}});
bUpdateSwitch.on({'click': function (){
var textF = Ext.getCmp('rateSummary');
textF.enable();
textF.getEl().on('click', function() {
Ext.getCmp('rtCurrency').enable();
Ext.getCmp('rtCurrency').setReadOnly(false);
Ext.getCmp('rtAccEffDate').enable();
Ext.getCmp('rtAccEffDate').setReadOnly(false);
Ext.getCmp('rtAccExDate').enable();
Ext.getCmp('rtAccExDate').setReadOnly(false);
Ext.getCmp('rtJctR260').enable();
Ext.getCmp('rtJctR260').setReadOnly(false);
Ext.getCmp('switchRate').enable();
Ext.getCmp('switchRate').setReadOnly(false);
Ext.getCmp('minRateCharge').enable();
Ext.getCmp('minRateCharge').setReadOnly(false);
Ext.getCmp('maxRateCharge').enable();
Ext.getCmp('maxRateCharge').setReadOnly(false);
Ext.getCmp('rtZone').enable();
Ext.getCmp('rtZone').setReadOnly(false);
Ext.getCmp('rtAddMile').enable();
Ext.getCmp('rtAddMile').setReadOnly(false);
Ext.getCmp('rtTarAppCd').enable();
Ext.getCmp('rtTarAppCd').setReadOnly(false);
Ext.getCmp('rtDetailSPLC').enable();
Ext.getCmp('rtDetailSPLC').setReadOnly(false);
Ext.getCmp('locationId1').enable();
Ext.getCmp('locationId1').setReadOnly(false);
Ext.getCmp('locationId2').enable();
Ext.getCmp('locationId2').setReadOnly(false);
Ext.getCmp('rtSettleCd').enable();
Ext.getCmp('rtSettleCd').setReadOnly(false);
Ext.getCmp('rtDetailNumber').enable();
Ext.getCmp('rtDetailNumber').setReadOnly(false);
Ext.getCmp('rtDetailId').enable();
Ext.getCmp('rtDetailId').setReadOnly(false);
Ext.getCmp('rtDetailType').enable();
Ext.getCmp('rtDetailType').setReadOnly(false);
Ext.getCmp('rtDetailItem').enable();
Ext.getCmp('rtDetailItem').setReadOnly(false);
Ext.getCmp('rtZTS1').enable();
Ext.getCmp('rtZTS1').setReadOnly(false);
Ext.getCmp('rtZTS2').enable();
Ext.getCmp('rtZTS2').setReadOnly(false);
});
}})

How to change accept header at google chrome?

How to change accept header at google chrome?

I want to see an error which will happen if I send not valid(according to
XHTML standard) markup to browser. I'm using google chrome as browser,
apache as server and php as script language. I've created a script with
such lines:
header('Content-type: application/xhtml+xml');
$content = <<< XHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml;
charset=utf-8" />
<title>XHTML</title>
</head>
<BODY>
<P>Lorem ipsum dolor sit amet...</P>
</BODY>
</html>
XHTML;
echo $content;
It should be incorrect because of BODY from capital letters. But I'm
getting correct results, because I see that google chrome accept such
mime-types:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
So it interprets result as text/html and everything is fine.
I want to make this document invalid. How I can remove text/html from
accepted headers at google chrome? Or I am wrong at something?

iOS 7 UIWebView rotation to landscape orientation add some bar

iOS 7 UIWebView rotation to landscape orientation add some bar

I have such situation, all screens in my application is in portrait mode,
but I have one screen that could be in both orientations. On iOs 6
everything works fine but on iOS 7 when I rotate to landscape I am receive
such situation as shown at the bottom:
I have try to make self.edgesForExtendedLayout = UIRectEdgeNone; but it
doesn't work for me.

Tuesday, 17 September 2013

My ogg file is not read on the server by Symfony

My ogg file is not read on the server by Symfony

In my Symfony(1.4) project, I have an ogg file that is supposed to load on
one of the pages (on Firefox, or Chrome) using HTML5 audio tag. Whenever I
load the page Symfony gives this error: "Empty module and/or action after
parsing the URL..."
As far as I understand, the problem has to do with Symfony. Either my
Symfony code has a problem with ogg files or the way it should parse their
paths. Can anyone guess what can be the source of such a problem?
Notes:
The problem is not with the file because it loads perfectly when I store
it on another server and load it from there.
The problem is not with the server (MIME types, etc) because the file
loads perfectly when I enter the full URL for the file in my browser.
Additionally when I try to load the file in a page on the server outside
of my Symfony project, it works.
The problem is not with the way I've typed the address of the file or its
permissions. There's also an mp3 file in the same directory with the same
permissions that loads perfectly on Chrome.
The problem, if it has to do with Symfony, is not very general because
again the mp3 file which is in the same directory works fine.

Mongoose select on sub document

Mongoose select on sub document

I have this Mongoose Schema:
UserSchema = new db.Schema({
fullname : String,
sale : [{ _id: [db.Schema.Types.ObjectId] }],
friends : [db.Schema.Types.ObjectId]
}
how can I fix this code to make it select the _id field of Sale? TIA
user.Model
.find({
_id : {
$in: friends
}
})
.select('sale._id') // invalid syntax
.exec(function(err, results) {
console.log(results);
});

Provide schema for xsd:any element while importing WSDL using wsimport

Provide schema for xsd:any element while importing WSDL using wsimport

I have a WSDL that uses an xsd:any element in a return type for one of the
methods, like this:
<xs:element name="Method_XMLResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="Method_XMLResult">
<xs:complexType mixed="true">
<xs:sequence>
<xs:any/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
When I run the WSDL through the wsimport tool, I get a generated class
that has this xs:any field mapped as a list of objects:
public static class MethodXMLResult {
@XmlMixed
@XmlAnyElement(lax = true)
protected List<Object> content;
}
When invoking the service using the generated code, I get instances of
org.w3c.dom.Node in the content list
(com.sun.org.apache.xerces.internal.dom.ElementNSImpl to be precise) that
I would need to parse myself. I was, however, provided with a separate,
external schema document for the objects actually returned - and I'm
trying to somehow feed it to wsimport so it generates the classes for them
as well.
I'm trying to accomplish that through JAX-WS / JAXB customization file
like this:
<jaxws:bindings xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:a="http://www.w3.org/2001/XMLSchema"
wsdlLocation="wsdlLocation.wsdl">
<jaxws:bindings node="wsdl:definitions">
<jaxws:bindings node="wsdl:types"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
<jaxws:bindings
node="//s:schema[@targetNamespace='wsNamespace']">
<jaxb:bindings
node="//s:element[@name='Method_XMLResponse']//s:any">
...
</jaxb:bindings>
</jaxws:bindings>
</jaxws:bindings>
</jaxws:bindings>
</jaxws:bindings>
Looks like wsimport picks the right location to customize (gave me
numerous error meesages with properly designated line number in the WSDL),
but I can't figure out how to fill the <jaxb:bindings> element to make
wsimport generate classes from the external schema. Is it even possible?
Any help would be much appreciated.

Spinner layout refresh in expanded list

Spinner layout refresh in expanded list

I have spinner in my extended list. What I would like to refresh layout of
spinner after button is clicked. I am successful at refreshing its state
to "0" position, but user still sees old value.
What I would like to know:
It is possible to recreate layout in expanded list?
How to refresh spinner layout, so user would see change and would not need
to scroll down and up for that
Maybe a little bit of topic. It is possible to have one spinner in
expanded list with different values on each child of expanded list? In
example:
Test1
sub1 SpinnerValue1
sub2 SpinnerValue2

Cant pause audio during applicationDidEnterBackground

Cant pause audio during applicationDidEnterBackground

I cant change the values or alter any variables or objects declared. Can
anyone see whats wrong?
In my app delegate method..
- (void)applicationDidEnterBackground:(UIApplication *)application
{
MainPage *mp = [[MainPage alloc]init];
mp.newTime = [[NSDate date] timeIntervalSinceDate:mp.date];
[mp.timer invalidate];
mp.switchT = 1;
mp.playBarButton.enabled = YES;
mp.pauseBarButton.enabled = NO;
mp.stopBarButton.enabled = YES;
[mp.avPlayer pause];
}
None of these actions above are executed..In my mainpage.h file I have the
followed declared like this
@property (nonatomic, retain) AVAudioPlayer *avPlayer;
@property (strong, retain) NSTimer *timer;
@property (strong, retain) NSDate *date;
@property (nonatomic) NSTimeInterval newTime;
@property (nonatomic) NSInteger switchT;
@property (strong, nonatomic) IBOutlet UIBarButtonItem *playBarButton;
@property (strong, nonatomic) IBOutlet UIBarButtonItem *pauseBarButton;
@property (strong, nonatomic) IBOutlet UIBarButtonItem *stopBarButton;
Of coarse in my implementation file these are synthesized and all works
well with my code within mainpage.m just not in my appDelegate file can
anyone see the problem? Note this is a fully functioning app everything
works well just can't execute the following code in my
applicationDidEnterBackground method and im assuming its the way my
properties are made? Also no errors with my code written in the app
delegate.

ASP.NET MVC 4 Entity Framework pointing to an embedded SQL Server database

ASP.NET MVC 4 Entity Framework pointing to an embedded SQL Server database

I have a web application that is being build from ASP.NET MVC 4 internet
application pattern. This web application is using a SQL Server database,
obviously I need to have SQL Server installed.
I would like to know if it is possible and not difficult to modify the
logic that comes with ASP.NET MVC 4 internet application pattern to point
to an embedded SQL Server database instead of using the typical SQL Server
database to which is attached to. I need this because I need to publish
this application in a machine that has not installed SQL Server and I
wonder if it is possible to use an embedded SQL Server database and avoid
having installed SQL Server on the machine.
Is it possible? If so, how to do that?

Sunday, 15 September 2013

How can I limit the amount of characters between a newline?

How can I limit the amount of characters between a newline?

I have a textarea that should only have 50 characters per line. I found a
way to automatically add a newline after a user has typed 50 characters
$('#textarea').keyup(function (e) {
if ($(this).val().length % 50 == 0 && $(this).val().length > 0) {
$(this).val($(this).val() + '\n');
}
})
but this doesn't cover text that is pasted into the textarea. How can I
simply prevent there from ever being more than 50 characters between every
'\n' in the textarea? In other words, I want to have a fixed limit of 50
characters per line.

How to use Javascript in Visual Studio 2012 Ultimate and General Visual Studio

How to use Javascript in Visual Studio 2012 Ultimate and General Visual
Studio

I am very new to Visual Studio and I can code a few things in javascript
my problem is I do not know how to get the javascript to run so I can make
sure it works also I have no idea what debugging does. I have hit start
debugging with google chrome and I kept getting error 403 with iis 8.0 I
then switched the server to the visual studio default server and all it
did was show the text with headers and nothing ran. I would like it to run
kinda in console the way codeaccademy does it. I know these are some
simple questions but I have spent two days trying to get it to work. Also
any help with visual studio 2012 ultimate would be good because I could
not find any tutorials.

Using Boost.python in Visual Studio 2008

Using Boost.python in Visual Studio 2008

I am in a HUGE depression now! I spend 2 days trying to use boost.python .
PLEASE guide me! I will explain what I did.
I have Winows 7 64 bit. The Python is 64 bit 2.7.3 installed at
C:\Python27_amd64.
Now, I take boost_1_54_0.zip and unzip in F: directory. The I use cmd.
bootstrap
this creates project-config.jam. I edit it and insert
using msvc : 9.0 ; using python : 2.7 : C:\Python27_amd64\python :
C:\Python27_amd64\include : C:\Python27_amd64\libs ;
Now i do
.\b2
This process runs for 20 something minutes and I am told that boost has
successfully been build.
After that I install boost binaries from
http://sourceforge.net/projects/boost/files/boost-binaries/ The binaries
get installed in C:\local\boost_1_54_0.
Now I want to create a General project.
Now, I use the code given for embedding python in C++ here
#include <boost/python.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <iostream>
namespace py = boost::python;
using namespace std;
int main()
{
// Initialize the interpreter
Py_Initialize();
py::object main_module = py::import("__main__");
py::object main_namespace = main_module.attr("__dict__");
py::exec("print 'Hello, world'", main_namespace);
py::exec("print 'Hello, world'[3:5]", main_namespace);
py::exec("print '.'.join(['1','2','3'])", main_namespace);
}
I setup the header files and library in VC++ directories to
F:\boost_1_54_0\boost_1_54_0 and F:\boost_1_54_0\boost_1_54_0\stage\lib
respectively.
I also setup project-->properties-->configuration
properties-->C/C++-->General-->Additional Include directories to
C:\Python27_amd64\include
Likewise, I also setup project-->properties-->configuration properties-->
Linker--> General to
C:\Python27_amd64\libs;"C:\local\boost_1_54_0\lib64-msvc-9.0" .
Now when I compile using x64 debugger. It gives me an error
Unhandled exception at 0x00000000 in test8.exe: 0xC0000005: Access
violation at location 0x0000000000000000.
I am struck since last 2 days...but thats the closest I have been since
then. please help me!

How to custom a datepiker in my language

How to custom a datepiker in my language

I have a webpage which contains a date field and need to have a datepicker
so that user can easyly choose a date. I wonder if there is an easy way to
make my own custom datepicker (changing text, styles). Thanks for suggest
your idea.

Qt Application Icon doesn't work

Qt Application Icon doesn't work

I created a small .ico for my program. Now I want Qt to set it as the
applications icon.
I found this documentation but it doesn't seem to work :
http://qt-project.org/doc/qt-4.8/appicon.html
I did exactly what they want me to do.
Create an myapp.rc file and write IDI_ICON102 ICON DISCARDABLE
"Movie-World.ico" into it. -> Did that.
Write RC_FILE += myapp.rc into your .pro file.
-> Did that.
When I compile and run, it doesn't work. I deleted the realese folder but
still no changes. I restarted Qt but still no changes.
I even added win32: before RC_FILE += myapp.rc but it did not work...
I don't understand why. My files are all in the same directory.

submit button arrays in PHP

submit button arrays in PHP

<div id='Descp'><?php echo $rows['productName'];?></div><!--decpx-->
<div id='buynow'><input type='submit' name='buyNow[]' id='buyNow'
class='buynow' value='Buy' /></div>
My question is, is it possible to create arrays of submit buttons like
above? Simply the need is to assign a submit button to capture the product
type user picks and then redirect to another page to buy.
Second point is using foreach will be a good method to capture the clicked
button response?
Thanks

Saturday, 14 September 2013

Android Virual Device manager can't run application

Android Virual Device manager can't run application

I just followed this tutorial here
http://mobile.tutsplus.com/tutorials/android/android-sdk-create-a-drawing-app-interface-creation/
and i created just the graphic view of the app as u can see here
http://gyazo.com/9d168d5c4c2cdc9a5853daa9e55d1a63
but when i try to run it as app and test in avd it shows error ?

Can jQuery promises be chained with Ember.RSVP.Promise's?

Can jQuery promises be chained with Ember.RSVP.Promise's?

I need help to understand some promises logic. Here is what I want to
achieve - with jQuery I make get request, then I chain it with my promise
which makes some checks, my code:
http://jsbin.com/UVEpurU/1/edit
function checkInfoPromise(r) {
var ok = true,
promise = Ember.RSVP.Promise(function(resolve, reject) {
if(ok) {
return resolve(r);
}
else {
return reject(r);
}
});
return promise;
}
var requestPromise = $.get('/')
.then(function(r){
return checkInfoPromise(r);
});
requestPromise.then(function(r) {
console.log(r);
}).fail(function(r) {
console.log('fail');
});
and it doesn't work as I expect. Documentation says they should work fine
with each other, but they don't or my code is incorrect.
Same logic with jQuery+jQuery works fine:
http://jsbin.com/AYeyaxO/1/edit
And Ember+Ember works:
http://jsbin.com/iMUgiDo/1/edit

PHP multi curl works on one machine, fails on another

PHP multi curl works on one machine, fails on another

I am trying to run a parallel image downloading with multi curl. I have a
short script that works fine for me on my laptop (php 5.3.10-1) but fails
on my server (PHP 5.5.3-1).
When I run this script on my server the target files are being created (I
guess that curl opens the handle successfully) but the files are empty,
there is no warning or error that I could see on my server to indicate any
issue.
Following is a sample of the original POC code I wrote/found online and
runs perfectly on my laptop but fails as is on my server. I would
appreciate your thoughts. Thank you.
<?php
$urls = array(
'http://static.php.net/www.php.net/images/php.gif',
'http://p.ebaystatic.com/aw/pics/globalheader/spr9.png'
);
$save_to = '/tmp/';
function add_file_to_curl($save_to, $mh, $url, $i){
global $conn, $fp;
$g=$save_to.basename($url);
if(is_file($g)){
unlink($g);
}
$conn[$i]=curl_init($url);
$fp[$i]=fopen ($g, "w");
curl_setopt ($conn[$i], CURLOPT_FILE, $fp[$i]);
curl_setopt ($conn[$i], CURLOPT_HEADER ,0);
curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,60);
curl_multi_add_handle ($mh,$conn[$i]);
}
$conn="";
$fp="";
$mh = curl_multi_init();
foreach ($urls as $i => $url) {
add_file_to_curl($save_to, $mh, $url, $i);
echo "URL IS $url, I is $i\n";
}
do {
$n = curl_multi_exec($mh,$running);
$ready = curl_multi_select($mh); // Waiting for one of the
files to finish
if(0 < $ready){
while($info = curl_multi_info_read($mh)){
$status =
curl_getinfo($info['handle'],CURLINFO_HTTP_CODE);
echo "STATUS $status\n";
if(200 == $status){
$successUrl =
curl_getinfo($info['handle'],CURLINFO_EFFECTIVE_URL);
echo "$successUrl\n";
}
break 1;
}
}
}
while (0 < $running && -1 != $ready);
$info = curl_multi_info_read($mh);
$status = curl_getinfo($info['handle'],CURLINFO_HTTP_CODE);
echo "STATUS $status\n";
if(200 == $status){
$successUrl =
curl_getinfo($info['handle'],CURLINFO_EFFECTIVE_URL);
echo "$successUrl\n";
}
foreach ($urls as $i => $url) {
echo "Running on $url and $i\n";
curl_multi_remove_handle($mh,$conn[$i]);
curl_close($conn[$i]);
fclose ($fp[$i]);
}
curl_multi_close($mh);
?>

php email sent successfully but not received by gmail

php email sent successfully but not received by gmail

I have some code that has worked for me in the past, but isn't anymore,
for some reason I don't understand. I'm pretty sure the problem isn't in
the code itself, since 1) I haven't changed anything, and 2) it's worked
for me in the past. I am using XAMPP and PHP. My webpage allows a user to
fill out a contact form and send an email through PHP. It seems to execute
successfully, since it takes the user to thankyou.html as a result. To
troubleshoot the issue, I have 1) cleared my browser's cache and 2)
checked my spam folder in Gmail. But I still can't find my email, and
don't know why. I'm not familiar with how SNMP works, so if that may be
the issue, I could use an explanation. Here is the code:
<?php
$field_first_name = $_POST['cf_first_name'];
$field_last_name = $_POST['cf_last_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
$field_reference = $_POST['cf_reference'];
$mail_to = 'myself@gmail.com';
$subject = 'Message from a website visitor '.$field_first_name.'
'.$field_last_name;
$body_message = 'From: '.$field_first_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message."\n";
$body_message .= 'Reference: '.$field_reference;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
//alert('Thank you for the message. We will contact you
shortly.');
window.location = 'thankyou.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to
someemail@gmail.com');
window.location = 'home.php';
</script>
<?php
}
?>
Any input is much appreciated!

Using Gradle execute for wix

Using Gradle execute for wix

I have a build.gradle that compiles my project, runs test creates a jar
then packages that with launch4j. I want to be able to use wix to create a
installer as well, however I seem to be having a lot of trouble launching
it from .execute().
The files necessary for candle and light are held in \build\installer.
However trying to access those files by calling execute in the build file
is always met with failure.
I have made a second build.gradle in /build/installer that does work. It is:
task buildInstaller {
def command = "\"LSML Setup.wxs\""
def candleCommand = ['candle', command]
def candleProc = candleCommand.execute()
candleProc.waitFor()
def lightCommand = ['light' , '-ext', 'WixUIExtension', "LSML Setup.wixobj"]
def lightProc = lightCommand.execute()
}
Is there some way I can run the second build file from the main one and
have it work or is there a way to call execute directly and have it work?
Thanks.

completion handler is not called on ios7 GM

completion handler is not called on ios7 GM

Thanks in advance.
I'm using AVAssetWriter, and it is perfectly working on iOS6.
The problem is, when I called finishWritingWithCompletionHandler, the
completion handler is not called on iOS7 GM.
I called markAsFinished, and even endSessionAtSourceTime before I call
finishWritingWithCompletionHandler.
It works fine on iOS6.
And even more, on iOS7, it works at some time. An then it doesn't work again.
I need your help.
Thanks.

How to add extra html attribute in struts 1 html taglib?

How to add extra html attribute in struts 1 html taglib?

how can I add autocomplete="off" standard html attribute to my input tag
in struts 1?
my input:
<html:text property="appUser.username" size="21" maxlength="50"/>
none javascript solution required. CSS or struts 1 solution.

Friday, 13 September 2013

When i set these images position to fixed, they pile on top of each other

When i set these images position to fixed, they pile on top of each other

The css below is what I've applied to the Facebook, twitter, and Google
plus links, I've added to a website I'm making, I want to make it so that
when i scroll down on the website the Facebook, twitter, and Google plus
icons stay in the top, right hand corner of the screen. I added position:
fixed; to it and they stay in that corner when i scroll; however, they
pile on top of each other, this should come easy to me, but my brains
blank:
.facebook {
width: 40px;
height: 40px;
display: inline-block;
background: transparent url('Styling-Images/fb.png') center top no-repeat;
background-size: contain;
margin-right:5px;
position: fixed;
}
.facebook:hover {
background-image: url('Styling-Images/bgcolor.png');
}
.twitter {
width: 40px;
height: 40px;
display: inline-block;
background: transparent url('Styling-Images/tw.png') center top no-repeat;
background-size: contain;
margin-right:5px;
position: fixed;
}
.twitter:hover {
background-image: url('Styling-Images/bgcolor.png');
}
.gp {
width: 40px;
height: 40px;
display: inline-block;
background: transparent url('Styling-Images/gp.png') center top no-repeat;
background-size: contain;
margin-right:5px;
position: fixed;
}
.gp:hover {
background-image: url('Styling-Images/bgcolor.png');
}

“Class type redefinition” error between header and source files (Different Case)

"Class type redefinition" error between header and source files (Different
Case)

I have seen this question: "Class type redefinition" error between header
and source files
If you'll just say a duplicate of the above question, please check first
the code below.
The problem is that the "Class type redefinition" should not happened
because I think I have done it properly.
Here is the code.
TTSpeech.h
#include <wtypes.h>
#include <string>
#include <vector>
class TTSpeech
{
public:
enum State
{
State_Loaded,
State_Unloaded,
};
TTSpeech();
virtual ~TTSpeech();
virtual bool isAvailable() = 0;
virtual bool load() = 0;
virtual bool unload() = 0;
virtual bool isLoaded() const = 0;
virtual bool say(const std::string &sentence) = 0;
virtual bool setVolume(int volume) = 0;
virtual bool setPitch(int pitch) = 0;
virtual bool setRate(int rate) = 0;
virtual bool setVoice(const std::string &voice) = 0;
virtual std::vector<std::string> getVoices() const = 0;
};
TTSpeech.cpp
#include "TTSpeech.h"
TTSpeech::TTSpeech()
{
//code
}
TTSpeech::~TTSpeech()
{
//code
}
The only unusual thing that I have done is to remove the files from the
solution, relocate the above file to a folder because of this issue:
cannot open include no such file or directory. Then re-add the files to
the solution. I'm using Visual Studio 2012 running of Windows 8

How to return a bool using execute scalar

How to return a bool using execute scalar

I have a stored procedure returning a boolean varialbe :
Here is my C# code that works when I try to return an int variable.But it
doesnt work when I try it for bool.
DbCommand dbCommand = db.GetStoredProcCommand("spGetConfigureAlerts");
object o = db.ExecuteScalar(dbCommand);
bool item = o == null ? 0 : (bool)o;
return item;
I have it as shown above , but on line three it says that :
Type of conditional expression cannot be determined because there is no
implicit conversion between 'int' and 'bool'
How can I solve it ?

Paypal error “This payment attempt is already processed”

Paypal error "This payment attempt is already processed"

I am using both paypal and e-junkie's "add to cart" buttons on my various
websites:
please view the screen shot linked below displaying error codes that
customers are receiving when checking out on the above listed sites. The
screen shot is from using a paypal account to check out of the shopping
cart. When customers use their paypal account, they are able to login,
select payment method, but then when they click "Pay Now", the page
refreshes with the error message "This payment attempt is already
processed" which you can see on the screenshot. At this point, the "Pay
Now" buttons are grey and not active. However, it seems payments are able
to go through when people use their paypal login despite the error
message.
After doing some research online I made sure that my selling settings were
set to allow transactions changed my primary email on the paypal account
and even created a new paypal merchant account. Still the issue persisted.
Further researching the problem online, I found another question posted
today here on SO with a similar issue: Paypal sandbox accounts gives "This
payment attempt is already processed" error and found the suggestion to
refresh the browser cache and cookies. After completing this I was
delighted to find that the issue was resolved. I then tried other browsers
and found the same fix worked.
My question is now this: is there anything I can do on my end to make sure
my customers do not have to refresh their cache and cookies in order to
use my shopping cart? I spoke with someone last night at paypal and they
gave me an email address to send this information and screenshot to. They
also explained that other merchants were having similar problems due to a
recent system upgrade that paypal has been performing. Whatever the
problem I am VERY anxious to fix it asap.

Is it possible to change default page of facebook?

Is it possible to change default page of facebook?

I want to add an additional option to default pages of facebook.
e.g. I want to add a combobox in friends list page of Facebook to further
categorize friends.
But, I am not sure, whether it's possible using SDK or not?
Can it be done using Facebook SDK?

Thursday, 12 September 2013

Android Difficulty in upgrading SQlite table without loosing old data

Android Difficulty in upgrading SQlite table without loosing old data

I my code for creating data base is this...
public class DatabaseHandler extends SQLiteOpenHelper {
// ====================== String Variables ======================
// The Android's default system path of your application database.
private static String DB_PATH = "/data/data/com.example/databases/";
private static final String DATABASE_NAME = "test.sqlite"; // Database Name
// ++++++++++++++++++++++ int Variables ++++++++++++++++++++++
private static final int DATABASE_VERSION = 1; // Database Version
// = = = = = = = = = = = Other Variables = = = = = = = = = = ==
private SQLiteDatabase myDataBase;
private final Context myContext;
SQLiteDatabase db;
@SuppressWarnings("unused")
private String privateDirectoryPath;
public DatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
this.myContext = context;
// db = this.getWritableDatabase();
//this.privateDirectoryPath = privateDirectory;
}
public void db_open()
{
db = this.getWritableDatabase();
}
/**
* Creates a empty database on the system and rewrites it with your own
* database.
* */
public void createDataBase() throws IOException {
boolean dbExist = databaseExist();
if (dbExist) {
// do nothing - database already exist
} else {
// By calling this method and empty database will be created into
// the default system path
// of your application so we are gone a be able to overwrite that
// database with our database.
this.getReadableDatabase();
try {
copyDataBase(); // call method to copy database
db = this.getWritableDatabase();
} catch (IOException e) {
throw new Error("Error copying database");
}
}
}
/**
* Mrthod to check database is exist or not
* @return
*/
public boolean databaseExist()
{
File dbFile = new File(DB_PATH + DATABASE_NAME);
return dbFile.exists();
}
/**
* Copies your database from your local assets-folder to the just created
* empty database in the system folder, from where it can be accessed and
* handled. This is done by transfering bytestream.
* */
private void copyDataBase() throws IOException {
// Open your local db as the input stream
InputStream myInput = myContext.getAssets().open(DATABASE_NAME);
// Path to the just created empty db
String outFileName = DB_PATH + DATABASE_NAME;
// Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);
// transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0) {
myOutput.write(buffer, 0, length);
}
// Close the streams
myOutput.flush();
myOutput.close();
myInput.close();
}
/**
* Close Database
*/
@Override
public synchronized void close() {
if (myDataBase != null)
myDataBase.close();
super.close();
}
public void DB_close()
{
if(db!=null)
db.close();
}
@Override
public void onCreate(SQLiteDatabase db) {
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
Now when i change new structure of data base from assets ... how it will
update in app.. without loosing old data.....
Please gave me proper giudence... Thanks in advance....

Web hosting for Java support

Web hosting for Java support

I am looking for a cheap web hosting service which support java. I am a
student and i want to start my small commercial project. Please give me
some suggestions. I live in North America.
Thank You

jquery ajax fails to parse valid json

jquery ajax fails to parse valid json

So I'm made a php script to output tweets in json and now I am trying to
parse with data with javascript. I've tested the data and it's valid json.
When I do the request in Example 2 it works fine. When I try to parse
using example 1 it fails saying Uncaught SyntaxError: Unexpected token N.
What is my problem?
Example 1
var request = $.ajax({
url: "http://website.com/twitter.php",
type: "GET",
data: {
twitter: 'google'
},
dataType: "json"
});
request.done(function(data) {
var resp = JSON.parse(data);
console.log(resp);
});
request.fail(function(jqXHR, textStatus) {
alert("Request failed: " + textStatus);
});
Example 2
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://website.com/twitter.php?twitter=google", true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
var resp = JSON.parse(xhr.responseText);
console.log(resp);
}
};
xhr.send();
JSON Data
["New Google Trends features\u2014including Trending Top Charts\u2014make
it easier to explore hot topics in #GoogleSearch g.co\/jmv6","Stating now,
join our Hangout w\/ President Barroso on the #SOTEU goo.gl\/FZCXaJ
#askbarroso","Explore the Galapagos Islands + see sea lions, blue-footed
boobies & other animals w\/ Street View in @googlemaps g.co\/ufjq","Slow
connections may keep Google Instant (results as you type) from working
smoothly. Our troubleshooting tip: g.co\/bve7","From @BBCNews: search VP
Ben Gomes on how search has become more intuitive & the next frontier
(includes video) goo.gl\/Z0ESkJ","\"Audio Ammunition\" - an exclusive
5-part documentary about the Clash from @GooglePlay g.co\/zrxn & on
youtube.com\/googleplay","justareflektor.com\u2013\u2013an interactive
@ChromeExp HTML5 film with @arcadefire, featuring their new single,
\u201cReflektor\u201d","#askbarroso about the State of the European Union
in a live conversation Thurs, Sept 12 g.co\/n3tj","Don\u2019t get locked
out: set up recovery options for your Google Account now g.co\/sm4k","It's
time for more transparency: our amended petition to the the U.S. Foreign
Surveillance Court g.co\/gkww"]