Thursday, 3 October 2013

syntax error unexpected T_ENCAPSED... php

syntax error unexpected T_ENCAPSED... php

Probably a really simple one to do with quotes but php is not my thing!
"INSERT INTO feedback_test (FirstName, LastName, Age) VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')"
getting the error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING
or T_VARIABLE or T_NUM_STRING

Wednesday, 2 October 2013

Relative lyaout in Android

Relative lyaout in Android

I am making an android app for diabetic patients. In that app I want to
show the food item with their quantity for every meal for diet control. It
should look somewhat like below:
RICE 100gm
POTATO 50gm
FISH 60gm
Those info will be obtained from my database dynamically. However I am
facing problem arranging them. I want the food items to be aligned left
and quantity aligned right of the screen. As below (dots denote the screen
)
|-------------------------------------------------------|
|RICE 100gm |
|POTATO 50gm |
|FISH 60gm |
|-------------------------------------------------------|
To do that I have declared a relative Layout in xml file. The code looks
as below :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</RelativeLayout>
</LinearLayout>
All I need to do now is to create textview and add them to this relative
layout dynamically. But I am confused how to do that. Any hint please...
The final output should look something like below :

Prove if $a|b$ and $b|a$, then $|a|=|b|$ , $a, b$ are integers.

Prove if $a|b$ and $b|a$, then $|a|=|b|$ , $a, b$ are integers.

Form the assumption, we can say $b=ak$ ,$k$ integer, $a=bm$, $m$ integer.
Intuitively, this conjecture makes sense.But I can't make further step.

ListView does not resize when hiding element(s) dynamically

ListView does not resize when hiding element(s) dynamically

I have a menu ListView that has a dynamic SignOut button that should only
show when the user is logged in. The ListView has a drop shadow after it
(not set as a Footer, but rather as a View following the ListView). When I
remove the SignOut button it disappears, but the size of the ListView does
not change, so there is a transparent gap and then the dropshadow. I am
hiding the SignOut row using signOutBtn.setVisibility(View.GONE); (I have
a reference to the signOutBtn view). Also, I have verified I am not using
View.INVISIBLE anywhere since I would expect this behavior using that.
The ListView is using wrap_content for the height, and I believe this is
where the problem lies - the height is being calculated including the
SignOut button.
So, the question is, how can I make the ListView dynamically resize when a
row is shown or hidden? I would prefer not to destroy and recreate the
View, although that is what I will probably try next, since it is a
relatively simple view.
PS. I can add code samples if needed, but I do not believe this is a code
issue.

Dynamic creation of SVG links in JavaScript

Dynamic creation of SVG links in JavaScript

I am dynamically creating SVG elements from JavaScript. It's working fine
for visual objects like a rectangle, but I'm having trouble producing
functioning xlinks. In the example below the first rectangle (which is
statically defined) works correctly when clicked on, but the other two
(created in JavaScript) ignore clicks... even though inspecting the
elements in Chrome seems to show the same structure.
I've seen multiple similar questions come up, but none that exactly
address this. The closest I found was [ adding image namespace in svg
through JS still doesn't show me the picture ] but that's not working (as
noted below). My goal is to do this purely in JavaScript, without
depending on JQuery or other libraries.



<!-- Static - this rectangle draws and responds to click -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" id="svgTag">
<a xlink:href="page2.html" id="buttonTemplate">
<rect x="20" y="20" width="200" height="50" fill="red"
class="linkRect"/>
</a>
</svg>
<script>
var svgElement = document.getElementById ("svgTag");
// Dynamic attempt #1 - draws but doesn't respond to clicks
var link = document.createElementNS("http://www.w3.org/2000/svg",
"a"); // using http://www.w3.org/1999/xlink for NS prevents drawing
link.setAttribute ("xlink:href", "page2.html"); // no improvement
with setAttributeNS
svgElement.appendChild(link);
var box = document.createElementNS("http://www.w3.org/2000/svg", "rect");
box.setAttribute("x", 30);
box.setAttribute("y", 30);
box.setAttribute("width", 200);
box.setAttribute("height", 50);
box.setAttribute("fill", "blue");
link.appendChild(box);
// Dynamic attempt #2 (also draws & doesn't respond) - per
http://stackoverflow.com/questions/6893391
box = document.createElementNS("http://www.w3.org/2000/svg", "rect");
box.setAttribute("x", 40);
box.setAttribute("y", 40);
box.setAttribute("width", 200);
box.setAttribute("height", 50);
box.setAttribute("fill", "green");
box.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href',
"page2.html");
svgElement.appendChild(box);

Tuesday, 1 October 2013

HQL between two time interval

HQL between two time interval

How is the correct format to use a HQL between 2 intervals of date times.
I have this SQL in oracle:
select * from vw_diariorecauda where ts_crea between TO_DATE
('01/10/2013 00:00:00','dd/MM/yyyy hh24:mi:ss')
and TO_DATE ('01/10/2013 23:59:59', 'dd/MM/yyyy hh24:mi:ss')
My HQl:
**the field:**
private Date tsCrea;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "TS_CREA")
public Date getTsCrea() {
return this.tsCrea;
}
**DAO:**
public List<VwDiariorecauda> buscarFecha(Date fecha) {
log.trace(fecha);
Calendar c = Calendar.getInstance();
c.setTime(fecha);
c.add(Calendar.HOUR, 0);
c.add(Calendar.MINUTE, 0);
c.add(Calendar.SECOND, 0);
Date fInicio = c.getTime();
c.add(Calendar.HOUR, 23);
c.add(Calendar.MINUTE, 59);
c.add(Calendar.SECOND, 59);
Date fFin = c.getTime();
Session session = sessionFactory.getCurrentSession();
Query query=session.createQuery("FROM VwDiariorecauda WHERE
tsCrea BETWEEN :hora1 AND
:hora2").setTimestamp("hora1",fInicio).
setTimestamp("hora2",fFin);
return query.list();
the hql works good but the results is different with the simple sql. How
can I improve this hql.
Thanks in advance.

How do I asynchronously map values onto a function with threading?

How do I asynchronously map values onto a function with threading?

I'm trying to learn how to execute "embarrassingly" parallel tasks in
C++11. A common pattern I come across is get the result of a function when
evaluated over a range of values, similar to calling python's
multiprocessing.Pool.map. I've written a minimal example that shows what I
know how to do, namely call a single process and wait for the result. How
can I "map" this call asynchronously and wait until all values are done?
Ideally, I'd like the results in a vector of the same length and order as
the original.
#include <iostream>
#include <thread>
#include <future>
#include <vector>
using namespace std;
double square_add(double x, double y) { return x*x+y; }
int main() {
vector<double> A = {1,2,3,4,5};
// Single evaluation
auto single_result = std::async(square_add,A[2],3);
cout << "Evaluating a single index " << single_result.get() << endl;
// Blocking map
for(auto &x:A) {
auto blocking_result = std::async(square_add,x,3);
cout << "Evaluating a single index " << blocking_result.get() << endl;
}
// Non-blocking map?
return 0;
}
Note: to get this code to compile with gcc I need the -pthreads flag.

What are the Java semantics of an escaped number in a character literal=?iso-8859-1?Q?=2C_e.g._'\15'_=3F_=96_stackoverflow.com?=

What are the Java semantics of an escaped number in a character literal,
e.g. '\15' ? – stackoverflow.com

Please explain what, exactly, happens when the following sections of code
are executed: int a='\15'; System.out.println(a); this prints out 13; int
a='\25'; System.out.println(a); this prints …

Why was my upvoted answer deleted=?iso-8859-1?Q?=3F_=96_meta.stackoverflow.com?=

Why was my upvoted answer deleted? – meta.stackoverflow.com

My answer on Using C# to check if string contains a string in string array
was deleted by a moderator despite having 1 up vote. I would like to
understand why?

Monday, 30 September 2013

Is it true that simple projective modules are injective=?iso-8859-1?Q?=3F_=96_mathoverflow.net?=

Is it true that simple projective modules are injective? – mathoverflow.net

It is known that simple modules are either projective or singular. Is it
true that simple projective modules over (commutative) rings are injective
?

DNS Records not found for a website

DNS Records not found for a website

I am running a dedicated server.
The server is running two sites. This morning one website is not working
and I found that there is a problem with the dns settings. I don't know
how it happened very suddenly.
The other website is working properly.
nslookup @domainname.com
Server: 8.8.8.8
Address: 8.8.8.8#53
** server can't find @domainname.com: NXDOMAIN
I checked online dns tools and they are reporting errors.
nslookup for another site is also not working
But dig for another site is working properly.
dig @domainname.com
dig: couldn't get address for 'domainname.com': not found
and ping is reporting
ping: unknown host domainname.com
dig SOA sitename.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> SOA sitename.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 25377
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;sitename.com. IN SOA
;; AUTHORITY SECTION:
co.in. 879 IN SOA a0.cctld.afilias-nst.info.
noc.afilias-nst.info. 2008728028 600 900 2592000 86400
;; Query time: 53 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Mon Sep 30 17:36:06 2013
;; MSG SIZE rcvd: 99
cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
I tried one online website for nslookup.
DNS server handling your query: localhost
DNS server's address: 127.0.0.1#53
** server can't find domain.co.in: NXDOMAIN
domain name : justforfun.co.in

How to focus on the textbox again after enter key is pressed?

How to focus on the textbox again after enter key is pressed?

This might be a trivial question but I have a simple textbox and a button
that will add the item entered in the textbox into a list, as follows:
<input type="text" placeholder="Add New Tag" data-bind="value: tagToAdd,
valueUpdate: 'afterkeydown', executeOnEnter: addTag" />
<button data-bind="click: addTag">+ ADD</button>
The program works as intended, but every time after I hit enter and the
item is added into the list, the "+ ADD" button is focused and I am unable
to type in the textbox unless I use my mouse to click on the textbox
again. Is there a way to focus the textbox so I can simply enter my data,
press enter, then directly enter a new value without having to pick up the
mouse?
Thank you!

Building dynamic where condition in SQL statement

Building dynamic where condition in SQL statement

I want to build custom Where condition based on stored procedure inputs,
if not null then I will use them in the statement, else I will not use
them.
if @Vendor_Name is not null
begin
set @where += 'Upper(vendors.VENDOR_NAME) LIKE "%"+
UPPER(@Vendor_Name) +"%"'
end
else if @Entity is not null
begin
set @where += 'AND headers.ORG_ID = @Entity'
end
select * from table_name where @where
But I get this error
An expression of non-boolean type specified in a context where a condition
is expected, near 'set'.

Sunday, 29 September 2013

How to measure the length of a class with the property display:none

How to measure the length of a class with the property display:none

Is there a way to measure the elements with a certain class that have
display:none in javaScript jQuery?
For example:
<div class="x" style="display: none;"></div>
<div class="x" style="display: none;"></div>
<div class="x"></div>
If I do this code below I'll get an alert "3" as there is 3 elements with
class="x".
var n = document.getElementsByClassName('x').length;
alert(n);
What would be the proper selector so that my alert show the only 2 classes
"x" with display:none?
Thanks for your help!

php purging, echo, html5 sorting

php purging, echo, html5 sorting

I am having some weird troubles here.. I have this script that will catch
the .mp4 location of a vine video for example..
https://vine.co/v/bv5ZeQjY35 if you check the source of that url you will
see twitter:player:stream set as meta tag.
I already have some code setup to grab and output that result..
function vine_video( $id )
{
$vine = file_get_contents("http://vine.co/v/{$id}");
preg_match('/property="twitter:player:stream" content="(.*?)"/',
$vine, $matches);
return ($matches[1]) ? $matches[1] : false;
}
Right now, the only way to output the content of twitter:player:stream is
to do this,
<?php echo vine_video('bv5ZeQjY35'); ?>
So, The best way I figure this could be setup instead of me just putting
in bv5ZeQjY35 I want it to be outputted from the end of my url by using
this.
$url = $_SERVER['REQUEST_URI'];
$check = end(explode('/v/?',$url));
echo $check;
However, I tried doing this <?php echo vine_video(echo $check); ?> and it
didn't work when I added it into my src=" "
So, I looked up the apache logs and it was saying $check is undefined. But
I was able to output $check on a regular <p></p> tag just fine.
If someone could please help me I would very much appreciate it.

Blur content behind div tag when background centred

Blur content behind div tag when background centred

I know this has been asked before and I have been able to blur content
behind a div tag, but when the background is centred, Blur.js doesn't pick
up that the background has been centred and continues to blur it as if the
background was the full sized image.
The problem can be seen here: http://home.josephftaylor.com/cadets/

How do I remove a line from a txt file in jQuery/javaScript

How do I remove a line from a txt file in jQuery/javaScript

I've been trying to get my head around this for a while, how do you remove
a certain line from a TXT file using jQuery or JavaScript.
I understand you could use an AJAX method to process this server side, but
is there a possibility of doing this in jQuery/JavaScript.
For example, say my text file "players.txt" has four lines:
Bob
Dave
Ethan
Sarah
When Ethan unloads the window, it should remove "Ethan" from the TXT file.
Thanks!

Saturday, 28 September 2013

Legitimate uses of "javascript:" code execution in the browser's location bar

Legitimate uses of "javascript:" code execution in the browser's location bar

The one usage I can think of are bookmarklets which rely on this method.

Why would a page load take 350-500ms or 1500-1600ms?

Why would a page load take 350-500ms or 1500-1600ms?

I am not certain this is a server issue, but I cannot discover why it
would be a code issue. I have a site running on an ec2 instance with low
cpu usage and lots of free memory. When you hit pages on the site there is
a long wait (15-16 seconds) before first byte time. This is inconsistent
though as it will also frequently have short wait times (350-500ms).
My dns is hosted by route53, and the server is WAY overkill for what it
is. I can't figure out what the issue might be. Any ideas?
Ubuntu, Apache, Mysql (RDS), and PHP...using yii framework.

What is meant by early initialization of a Singleton class in Java

What is meant by early initialization of a Singleton class in Java

I am not quite clear on what is meant by the term Early initialization of
a Singleton class. Also it would be helpful to understand the life cycle
of a Singleton class.

Python windows path slash

Python windows path slash

pI am facing a very basic problem using directory path in python script.
When I do copy path from the windows explorer, it uses backward slash as
path seperator which is causing problem./p precodegt;gt;gt; x
'D:\testfolder' gt;gt;gt; print x D: estfolder gt;gt;gt; print
os.path.normpath(x) D: estfolder gt;gt;gt; print os.path.abspath(x) D:\
estfolder gt;gt;gt; print x.replace('\\','/') D: estfolder /code/pre pCan
some one please help me to fix this./p

Friday, 27 September 2013

Parse fails to obtain images from android

Parse fails to obtain images from android

Im trying to make a simple signup page which gets images from the Android
gallery and saves them to the Parse.com cloud for further reference.
Here's the code:
This is the method that executes on tapping the Browse button...
public void choosePic(View v)
{
Intent i = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);
}
This method executes on picking an image:
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK &&
null != data) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Bitmap bitmap = null;
try {
bitmap =
MediaStore.Images.Media.getBitmap(this.getContentResolver(),
selectedImage);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
byte[] image = bos.toByteArray();
profilePic = new ParseFile("image2.jpg", image);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
}
}
This is the method that executes on tapping the sign up button
public void signupClicked(View arg0)
{
// Retrieve the text entered from the EditText
usernametxt = username.getText().toString();
passwordtxt = password.getText().toString();
addresstxt = address.getText().toString();
emailtxt = email.getText().toString();
// Force user to fill up the form
if (usernametxt.equals("") && passwordtxt.equals("")) {
Toast.makeText(getApplicationContext(),
"Please complete the sign up form",
Toast.LENGTH_LONG).show();
} else {
// Save new user data into Parse.com Data Storage
ParseUser user = new ParseUser();
user.setUsername(usernametxt);
user.setPassword(passwordtxt);
user.setEmail(emailtxt);
// other fields can be set just like with ParseObject
user.put("address", addresstxt);
user.put("photo", profilePic);
user.signUpInBackground(new SignUpCallback() {
@Override
public void done(com.parse.ParseException e) {
// TODO Auto-generated method stub
if (e == null) {
// Show a simple Toast message upon successful
registration
Toast.makeText(getApplicationContext(),
"Successfully Signed up, please log in.",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(),
"Sign up Error", Toast.LENGTH_LONG)
.show();
}
}
});
}
Intent intent = new Intent(this,MainActivity.class);
startActivity(intent);
}
This is the error I get when I click on the photo data object in the
Parse.com cloud
This XML file does not appear to have any style information associated
with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>534755F82D0FFA4C</RequestId>
<HostId>
tPHdYj7iVHL67mYKoyXwf6GtbzQr6TO5r5Xfmj3usbA5HQcGd/vEpnr3DGDaAhac
</HostId>
</Error>

Repainting a JPanel with data from another object (thread)

Repainting a JPanel with data from another object (thread)

I'm facing a problem where a JPanel takes data from an object which has a
cycle updating its state variables.
The scenario is as follows: a JFrame calls a method of the object, the
method creates the second JFrame has a cycle then updating a state
variable. The second JFrame access that variable and should be displayed
in a JPanel, but no, the GUI hangs.
I reduced the problem to an example with the same behavior so it can be
easily tested.
I appreciate any help, thanks!
Starter.java
public class Starter extends JFrame {
JButton button = new JButton("Fight!");
public Starter() {
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
OneClass.getInstance().start();
}
});
add(button);
}
public static void main(String[] args) {
Starter frame = new Starter();
frame.setTitle("Test");
frame.setSize(400, 300);
frame.setVisible(true);
}
}
OneClass.java
public class OneClass {
private OneFrame frame;
private int count;
private static OneClass instance;
private OneClass() {
}
public static OneClass getInstance() {
if (instance == null)
instance = new OneClass();
return instance;
}
public void start() {
frame = new OneFrame();
frame.setSize(400, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
while (true)
{
count++;
System.out.println(count);
frame.repaint();
}
}
public int getCount() {
return count;
}
}
OneFrame.java
public class OneFrame extends JFrame {
private OnePanel panel = new OnePanel();
public OneFrame() {
setTitle("Test frame");
setContentPane(panel);
setResizable(false);
}
}
OnePanel.java
public class OnePanel extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
Font ft = new Font("Times New Roman", Font.PLAIN, 20);
g.setFont(ft);
g.drawString("Count = " + OneClass.getInstance().getCount(), 20, 20);
}
}

XML not well formed - android

XML not well formed - android

I have error on the seconde relative layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip"
**android:xmlns:android="http://schemas.android.com/apk/res/android">**
<LinearLayout
android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:background="@drawable/image_bg"
android:padding="3dip" >
<ImageView
android:id="@+id/place_thumbnail"
android:layout_width="70dip"
android:layout_height="70dip"
android:src="@drawable/progressbar" />
</LinearLayout>
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/thumbnail"
android:layout_alignParentRight="true"
android:gravity="right"
android:textColor="#10bcc9"
android:textSize="14dip"
android:textStyle="bold" />
<TextView
android:id="@+id/adress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/thumbnail"
android:textColor="#343434"
android:textSize="14sp" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/thumbnail"
android:layout_toRightOf="@+id/thumbnail"
android:textColor="#040404"
android:textSize="15sp"
android:textStyle="bold"
android:typeface="sans" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="phone :"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#040404"
android:textSize="20sp" />
<TextView
android:id="@+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#040404"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="website :"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#040404"
android:textSize="20sp" />
<TextView
android:id="@+id/website"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#040404"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="rating :"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#040404"
android:textSize="20sp" />
<RatingBar
android:id="@+id/ratingBar1"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rating="0" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dip" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@android:drawable/ic_menu_call" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@android:drawable/ic_menu_directions" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@android:drawable/ic_menu_compass" />
</RelativeLayout>
<Gallery
android:id="@+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
i have checked old posts in the same problem , but i didn't find a
similare case i will need to find the correct format and also the
possibilitys of having this problem

Checking CSS Linear gradient support

Checking CSS Linear gradient support

Support for CSS properties(border-radius here) can be checked by this code:
if(document.createElement('test').style.borderRadius===''){
//some code
}
but what do I do in case of linear gradients? The declaration being like:
background:linear-gradient(top,bottom,#123,#456);
P.S. I don't want to use Modernizr. I want to learn how-to do this.

Security of Docker as it runs as root user

Security of Docker as it runs as root user

A Docker blog post indicates:
Docker containers are, by default, quite secure; especially if you take
care of running your processes inside the containers as non-privileged
users (i.e. non root)."
So, what is the security issue if I'm running as a root under the docker?
I mean, it is quite secure if I take care of my processes as
non-privileged users, so, how can I be harmful to host in a container as a
root user? I'm just asking it to understand it, how can it be isolated if
it is not secure when running as root? Which system calls can expose the
host system then?

how to get textarea value on modal (BOOTSTRAP)

how to get textarea value on modal (BOOTSTRAP)

function getMsgList(){
var table = "<tr class='vps_list_head'><th
width='20%'>Date</th><th width='70%'>Title List</th> <th
width='10%'></th></tr>";
for (i=0; i<msgdetail.length; i++){
table += "<tr id='list"+i+"' class='vps_list' >"
+"<td class='vps_col' href='#myModal"+i+"'
role='button'
data-toggle='modal'>"+(msgdetail[i][1]).substring(0,10)+"</td>"
+"<td href='#myModal"+i+"' role='button'
data-toggle='modal'>"+msgdetail[i][4]+"</td>"
+"<td><i class='icon-remove'
onclick='delMessage("+msgdetail[i][0]+")'></i></td></tr>"
+"<div id='myModal"+i+"' class='modal hide fade'
tabindex='-1' role='dialog'
aria-labelledby='myModalLabel'
aria-hidden='true'>"
+"<div class='modal-header'>"
+" <button type='button' class='close'
data-dismiss='modal'
aria-hidden='true'>×</button>"
+" <h4 id='myModalLabel'>Title:
"+msgdetail[i][4]+"</h4>"
+"From : "+msgdetail[i][2]
+"<br>Date : "+(msgdetail[i][1]).substring(0,10)
+"</div>"
+"<div class='modal-body'>"
+""+msgdetail[i][5]+""
+"</div>"
+"<div class='modal-footer'>"
+"<div align='center'><textarea name='detail'
id='detail' style='margin: 0px 0px 30px 0px;
width: 500px; height:
81px;'></textarea></div>"//This is ploblem.
+" <button class='btn btn-primary'
onclick='replyMessage("+msgdetail[i][0]+")'>Reply</button>"
+" <button class='btn' data-dismiss='modal'
aria-hidden='true'>Close</button>"
+"</div>"
+"</div>"
}
document.getElementById('data_msg_order').innerHTML = table;
}
function replyMessage(i){
var rep = document.getElementById("detail").value;
alert(rep);
}
How to get value from modal Help me pls.
i try to fix it by use
document.getElementById("modal").getElementById("detail")
but still error.

Insert element between elements via using date (by date)

Insert element between elements via using date (by date)

I wonder how to insert a element via using date ?
Example :
<time datetime="2013-07-29">2013-07-29</time>
<time datetime="2013-06-14">2013-06-14</time>
<time datetime="2013-06-10">2013-06-10</time>
<time datetime="2013-05-01">2013-05-01</time>
so new element look like... :
<time datetime="2013-06-12">2013-06-12</time>
How to insert this new element between 2013-06-14 and 2013-06-10elements
functionally ?
This is my code :
HTML :
<input value ="2013-06-12"><button>Add</button>
<time datetime="2013-07-29">2013-07-29</time>
<time datetime="2013-06-14">2013-06-14</time>
<time datetime="2013-06-10">2013-06-10</time>
<time datetime="2013-05-01">2013-05-01</time>
jQuery :
$('button').on('click',function(){
var date = $('input').val();
var html = $('<time datetime="'+date+'">'+date+'</time>');
//html.addClass('new').insertAfter('time[datetime="2013-06-14"]');
});
Demo : http://jsfiddle.net/pmREJ/
If it's ok I want to insert this new element , not sort elements agian.

Thursday, 26 September 2013

AngularJS: use sub-object attribute as ng-model

AngularJS: use sub-object attribute as ng-model

I have a dropdown which is bound to an object user with the following
structure:
{
userId:1,
userLogin:"test",
locale: { localeCode:"en-US" }
}
This structure comes directly from a C# model class where User and Locale
are two classes linked as an association (User has one Locale).
So I would like to define the following dropdown without doing any custom
logic like serializing the objects in a special way, or adding $watch to a
"UI" attribute so I can update locale.localeCode in the background.
<select id="dropLocale" required="required" addempty="true"
ng-model="user.locale.localeCode"
ng-options="i.localeCode as i.localeCode for i in
localeList"></select>
Any help will be appreciated! Thanks

Wednesday, 25 September 2013

MYSQL:SQL query to return a row only if all the rows satisfy a condition

MYSQL:SQL query to return a row only if all the rows satisfy a condition

Consider three tables -
users
<id, type>
1, a
2, b
3, c
types
<type, training>
a, X
a, Y
b, X
c, X
c, Y
c, Z
training_status
<id, training, status>
1, X, F
2, X, S
2, Y, S
3, X, F
3, Y, S
Each user has a type, and types defines the trainings that each user of a
particular type have to complete.
training_status contains status of all the trainings that a user has taken
and its result (S,F). It a user is yet to take a training, there won't be
any row for that training.
I would like to find out all users that have successfully completed all
the trainings that they have to take.
Here's the direction that I am thinking in:
select id from users join types using (type) left join training_status
using (id,type)
where status NOT IN (None, F);
Obviously this is not the right query because even if the user has
completed one of the trainings, we get that row. In the aforementioned
example, I'd like to get id = 2 because he has completed both trainings of
its type.

Thursday, 19 September 2013

Jquery waypoint stops working after certain action

Jquery waypoint stops working after certain action

I have a list of folders on the page which has waypoint attached to load
folders infinitely.
infinite scrolls works perfectly until we expand anyone of the folder
which has 30-40 items. Expanded folder items occupy whole page height &
after that infinite scroll stops working. Folder expand is an ajax call
which loads folder data below it.
Does the long folder data is causing issue with my waypoint functioning?

How to delete dynamically added item from sortable list?

How to delete dynamically added item from sortable list?

I've created a jquery sortable list where each item has a "delete" button
to the right. When you click the delete button, that item is deleted. I
found this from another question on here ( Delete Jquery-ui sortable list
item ). I need to allow the user to add items to the list, so I've created
an Add button. The adding works fine, however, the newly added items
cannot be deleted using the delete button. Here's the jfiddle:
http://jsfiddle.net/g33ky/fadAn/1/
Code is below:
<script>
$("#fruitList").sortable();
$("#fruitList .delete").click(function () {
$(this).parent().remove();
});
$("#addFruit").click(function () {
$('#fruitList').append("<li class='fruit'>New fruit<button
class='delete'>Delete</button></li>");
});
</script>
<html>
<button id='addFruit'>Add fruit</button>
<ul id="fruitList">
<li class="fruit">Apple
<button class="delete">Delete</button>
</li>
<li class="fruit">Banana
<button class="delete">Delete</button>
</li>
<li class="fruit">Orange
<button class="delete">Delete</button>
</li>
</ul>
</html>
Click on "Add Fruit", then try deleting the new fruit, and you'll see that
the delete on "New Fruit" doesn't work. I've googled and searched on here,
but so far no luck. Any help would be greatly appreciated.

Grouping Regular Expression in Python

Grouping Regular Expression in Python

I'm having a problem. I'm trying to figure out what is the regular
expression for the following situation, where I want to match one of the
follwoing if returned back.
ABC 1 or
ABC 1 0 or
ABC 1 0 1 or
ABC 1 0 1 0 or etc
I'm trying the following to acheive this but its only matching the first
string (ABC 1).
regular expression: ABC (1|0)+
I have been trying to figure this out for a long time and I can't seem to
figure it out. Could someone please help?
Thanks

adding project dependency in Eclipse

adding project dependency in Eclipse

How can I add one project as a dependency to another? I can't use
Build-path stuff because the projects are Enterprise projects and not
regular Java projects. Thanks in advance!

C++ convert string characters lower to upper and upper to lower

C++ convert string characters lower to upper and upper to lower

Can someone help me to write a few c++ lines of code to convert an input
string letters as follow:
Lowercase letters to Uppercase letters.
Uppercase letters to lowercase letters.
libraries functions are not allowed.
if statement, no comparisons, | operation and & not allowed.
Thanks.

doubled values ​​of IEnumerable on cshtml

doubled values &#8203;&#8203;of IEnumerable on cshtml

I want to fill an IEnumerable to I build a loop to run through me per
array length. The value will be added to the result list that happens in
the function 2 times ie for users and passwords. Each array has a length
of two values. If I now spend in. Cshtml I get everything twice when one
of the two values &#8203;&#8203;is higher
List<Template> result = new List<Template>();
// Password
string[] Password_Array = TemplateModel.Password.Split(',');
for (int i = 0; i < Password_Array.Length; i++)
{
string[] Password = Password_Array[i].Split(';');
result.Add(new Template { Password = Password[0] });
}
// User
string[] User_Array = TemplateModel.User.Split(',');
for (int i = 0; i < User.Length; i++)
{
string[] User = User[i].Split(';');
result.Add(new Template { User = User[0] });
}
the cshtml
@foreach (var item in Model)
{
<tr>
<td width="250px">@item.User</td>
<td width="250px">@item.Password</td>
</tr>
}
only if there are 3 users are only 1 password are still useable 3 "tr" for
nothing loaded
thank you

Google Maps API v3 - Tiles turn gray when selecting area (but map is still visible underneath the gray)

Google Maps API v3 - Tiles turn gray when selecting area (but map is still
visible underneath the gray)

When selecting an area in my google maps application, some tiles turn
gray. The map underneath stays visible. I am not using any functions or
methods that handle tiles, so I have no idea where to look for the cause.
The internet was not a big help so far. Can somebody please help me to
squash this annoying bug :p?
Ps: I have never coded javascript before, just been doing that for about 4
days, so that might explain my low level of expertise on the subject;
hopefully it's just a small thing...
/// <reference path="google-maps-3-vs-1-0.js" />
google.maps.visualRefresh = true;
var global = this;
var map;
var center;
var geocoder;
var country = 'Belgium';
var fMapBounds = new google.maps.LatLngBounds();
var curZoomLevel, prvZoomLevel;
var markers = [];
var icons = [];
var recSelectActive = true;
// Initialize
//#region
function initialize() {
// Create map + center (this center must be done before adding markers)
curZoomLevel = 8;
var mapOptions =
{
center: new google.maps.LatLng(50.0, 5.0),
zoom: curZoomLevel,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,
panControl: true,
panControlOptions: { position:
google.maps.ControlPosition.TOP_RIGHT },
zoomControl: true,
zoomControlOptions: { style: google.maps.ZoomControlStyle.LARGE,
position: google.maps.ControlPosition.LEFT_CENTER },
scaleControl: false,
streetViewControl: false
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
map.setCenter(center);
// Create all pins for performance reasons
//#region
createPins();
//

Wednesday, 18 September 2013

allowing users to download files from azure blob storage as single zip file

allowing users to download files from azure blob storage as single zip file

I have multipl files in my blob storage. Also I have a azure database
table which stores url which points to actual individual files in blob
storage . On my webform user can specify search criteria.Then it will
search for files that match the search condition and show a single link to
download matching files all as a single zip file. I have my search results
returned as a list. for example
List searchresults
This search result will contain multiple urls eg.,searchresults.url
="https://myblobstorage.blob.windows.net\xyz\mymusic.mp3"
if there are matching records ,it will show a single download link on the
page,so that the user can click on the link and download the the matching
files together as as single zip file.
I am able generate the searchresultsList with the required file urls
pointing to the files in my azure blob container.
Now my Question Is there a way I can generate a zip file by looping
through the searchresultsList and grabbing files from blob and generate a
single zip file for the user to download them? Give me your suggestions or
some sample code to achieve this functionality.
When the user clicks on the link, it should go and fetch all the files
from corresponding urls from the search results list and generate a single
zip file and download to the users machine

jquery - run effects one after another to get smooth animation

jquery - run effects one after another to get smooth animation

I have the following piece of code:
$('#content').fadeOut().html('').queue(function() {});
$('#content').append(jQuery(data).find("#content").clone()).html();
$('#content').fadeIn();
I want these effects to run after the previous one is done however they
all happen together!!
I tried using queue but was not successful.

c# Export Object Into New A Type Of Files

c# Export Object Into New A Type Of Files

i will explain by an example, a PSD file is a file where photoshop save a
project, a DOC file is a file where Office Save a Document...
I am making an application where i work with object and i want to export
my object into a new type of files (for exemple TQA : Test Question
Answer), and i want my application to be the only program that can open
that file.
static class TestQuestionAnswer
{
public string Question;
public string Answer;
//...initiating of the Question and Answer
//...Exporting the object to a TQA file..??
}
any ideas ?

ColdFusion 10 Update 11 404 handler not firing

ColdFusion 10 Update 11 404 handler not firing

I know CF 10 has a number of issues surrounding 404 handling. This seems
to be different from the other reports. Details:
Win2k8 R2/64 and IIS7.5
Upgrading from identical config on separate server. Only difference is CF9
-> CF 10. All works fine on CF9. Adobe CF9 Lockdown implemented on
original server, CF10 Lockdown implemented on this server.
missing template handler set in CF Admin as /404.cfm, which should
translate to the Cfusion root (c:\ColdFusion10\cfusion\wwwroot).
IIS has been config'd to trace failed 404 requests
IIS 404 handling is default (originally executed a CF URL but removed to
simplify debug).
Coldfusion webroot where missing template handler resides is default
install location
IIS site root is entirely different: c:\Other\Place\SiteRoot\
A sitewide error handler is also set in CF Admin in the same ColdFusion
webroot and works as expected.
404.cfm is very simple:
<cfheader
statuscode="404"
statustext="Not Found">
<h1>404</h1><p>Page not found</p>
<cfoutput>#now()#</cfoutput>
Inputting the bad url [domain]/foo.cfm should display the above template.
Instead I get an IIS error screen. The CF missing template handler is
ignored. The IIS failed request trace says the url is
http://[mydomain]:80/jakarta/isapi_redirect.dll
and a detail view shows at Step 1
RequestURL="http://[mydomain]:80/foo.cfm
I've seen plenty of issues surrounding CF10 and 404's, but never that the
missing template handler assignment is completely ignored. In CF9 this
will generate output as expected. Anyone seen anything like this?
EDIT: I have also tried config'ing this to match a different CF9 server I
have running: Added a CF mapping to the web root of the site. Then placed
the missing template handler in the web site's root rather than the CF
default web root, lastly in cfadmin pointed to the missing template
handler in the web site's root using the mapped folder. Same problem.
Works fine in CF9 and not at all using CF10.

using promise pattern in a loop

using promise pattern in a loop

I need to loop thru div's and load them using the promise pattern but
apparently only the data from the last call gets displayed.
Here is my code
$('div[class=ceTable]').each(function () {
var position = $(this).position();
gridID = $(this).attr('id')
tableID = $(this).attr("data-tableid")
docId = $(this).attr("data-docid")
headerFound = $(this).data("headerFound")
headerArray = $(this).data("headerArray")
columnCount = $(this).data("columnCount")
$.ajax({
type: "GET",
dataType: "json",
url: "ajaxGetTableData",
data: {'docID': docId, 'tableID': tableID},
beforeSend: function () {
$('#' + gridID).block({ css: {
border: 'none',
padding: '15px',
backgroundColor: '#36a9e1',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: 5,
color: '#fff'
}, message: 'Loading Grid'
});
}
}).done(function (data) {
console.log(data, "ajaxGetTableData")
ceFeature.generateGridFromJSONObject({tabledata:
data, columnCount: columnCount, gridID:
gridID, headerArray: headerArray, headerFound:
headerFound})
$('#' + gridID).unblock();
})

c++ - converting a base class pointer to a derived class pointer

c++ - converting a base class pointer to a derived class pointer

#include <iostream>
using namespace std;
class Base {
public:
Base() {};
~Base() {};
};
template<class T>
class Derived: public Base {
T _val;
public:
Derived() {}
Derived(T val): _val(val) {}
T raw() {return _val;}
};
int main()
{
Base * b = new Derived<int>(1);
Derived<int> * d = b;
cout << d->raw() << endl;
return 0;
}
I have some polymorphism problem right now and the code above summarizes
everything. I created a Base class pointer and I put the pointer of a new
derived template class in it. Then I created a new pointer for the derived
template class and I want it to have the reference the base class pointer
points to. Even though Base pointer (b) points to a Derived, the reference
cannot be passed to Derived class pointer (d) because there's no known
conversion from Base * to Derived<int> * (as what the compiler says).
So is there a trick or an alternative way to be able to do it? Thanks in
advance.

Detection of disks as /dev/sd* [on hold]

Detection of disks as /dev/sd* [on hold]

If a disk is detected as /dev/sd*, does that mean it is a scsi disk?
because even USB stick is detected as /dev/sd* on Linux system.
It it doesn't mean it scsi disk, how to know whether the disk is scsi disk
or not?

Database Cell with multiple values?

Database Cell with multiple values?

I am designing an app where I want to search for diseases based on
symptoms. I am trying to design the database using MySql, but as a
beginner I run into some trouble with the design philosophy.
Basically a disease is going to have multiple symptoms, so on the
"disease" table I wanted to have these columns:
disease_id, disease_name, disease_description, disease_symptoms
The thing is, one disease is not going to have only a single symptom, and
putting multiple values in a single cell goes against DB design philosophy
from what I found out online.
So the best solution I found so far was to make a table with multiple
columns, 1 for disease id and then like 10 columns called: symptom_0,
symptom_1, symptom_2 ect. ect., so when I do an sql query it can return
all the diseases that have a specific symptom.
I was just wondering if there is a more efficient way to do this. Thank
you for your help.

Tuesday, 17 September 2013

Guvnor5.5 REST API Authorization not Working

Guvnor5.5 REST API Authorization not Working

I have a centralized Guvnor5.5 environment where multiple applications
access the Guvnor through rest api for their respective assets and BAs
access Guvnor's WEB UI to create/modify process definitions. From Guvnor's
WEB UI I can define "User and Permissions" and users accessing the web UI
are accessing based on the permissions defined for them. E.g user A is
permitted to modify Package A only so Guvnor's WEB interface is properly
restricting the USER A and User A can only see Package A when he logs into
Guvnor WEB UI.
My PROBLEM is that when USER A accesses guvnor through Guvnor's REST
Interface then USER A can upload/modify any asset in any package (Package
A, Package B, Package....). How can I apply the User Permission setup on
access through REST API.
Using REST Interface I can access Package C with the user and password of
User A. While USER A is only permitted to access Package A.
I have 5 applications accessing single Guvnor for their assets. Each
application is getting assets from its own Package (E.g application 1 -->
Package A, application 2 --> Package B ...).
I am using Guvnor's REST API for getting Task-Forms and also doing Import
and Export of a package using REST API. (Doing Import/Export through REST
interface as Guvnor imports or Exports only the complete repository. It is
not importing exporting a single package.)
Security Breach Case: If the application developer knows the names of
other packages he can point the application to get assets of other
applications. This causes security issue for us. Applications should
access assets assigned to them in their package only. I need to setup user
and permissions for access through REST interface on the basis of
packages. Applications accessing Guvnor should be allowed only to access
their respective package/assets/categories only.
Thanks and Best Regards, Zahid Ahmed

javascript store values that are similar together

javascript store values that are similar together

I have a list that is setup like this from a sql database
Team Name Date Joined
TeamA David June 3
TeamB Mike July 2
TeamC Mark June 7
TeamA Lisa July 2
TeamA Stacy June 7
TeamB Tracy July 2
TeamC Joe June 3
I want to be able to store the list and print all the people and dates
joined in TeamA or TeamB or TeamC using javascript. I am not sure how to
approach this, was thinking about arrays but don't think that won't reach
my goal because not sure how to combine all the items together...does
anyone have ideas

want to write a small web server in JAVA

want to write a small web server in JAVA

I want to write a small web server that listens on for connections to
127.0.0.1 on a
TCP port provided on the command line using a sub-set of the HTTP 1.0
protocol.
This web server shall present a small page of arbitrary (possibly empty)
content in response to
an HTTP/1.0 request for /. Such a request will look like:
GET / HTTP/1.0\r\n\r\n
Where \r is carriage return (character 0x0d) and \n is line feed (character
0x0a). An appropriate response to this request might be:
HTTP/1.0 200 OK\r\nContent-length: 5\r\n\r\nHello
Requests for non-existent pages shall return HTTP response code 404,
returning something like:
HTTP/1.0 404 PAGE NOT FOUND\r\nContent-length: 14\r\n\r\nPage not
found
When presented with a request for /port/, the web server should make an
outbound
HTTP connection to the specified port number on 127.0.0.1, and request the
URL /gettoken
to obtain a token, parse the response, and use the obtained token as the
output to the HTTP
request.
For example, if an HTTP request is received for /port/12345, the web
server should make an
HTTP connection to TCP port 12345 on 127.0.0.1, and issue an HTTP request
for /gettoken,
and return the HTTP body of the response to that request as the body of
the original HTTP
request.
If the HTTP request for /gettoken fails, your web server should respond
with an appropriate
HTTP error response code (a result code in the range 500 – 599).

remove x ticks but keep grid lines

remove x ticks but keep grid lines

I have a Pyplot plot, which I want to add gridlines to. I did this using:
plt.grid(True)
I then removed my x ticks using:
ax1.xaxis.set_visible(False)
My x ticks were removed, but so were the x grid lines. I would like them
to stay.
Is there a way I can do this please?

Java: Code Understanding

Java: Code Understanding

I'm new to JAVA, but I know Objective-C. I have to write a server side
Custom Code and I'm having trouble with the code below:
/**
* This example will show a user how to write a custom code method
* with two parameters that updates the specified object in their schema
* when given a unique ID and a `year` field on which to update.
*/
public class UpdateObject implements CustomCodeMethod {
@Override
public String getMethodName() {
return "CRUD_Update";
}
@Override
public List<String> getParams() {
return Arrays.asList("car_ID","year");
}
@Override
public ResponseToProcess execute(ProcessedAPIRequest request,
SDKServiceProvider serviceProvider) {
String carID = "";
String year = "";
LoggerService logger =
serviceProvider.getLoggerService(UpdateObject.class);
logger.debug(request.getBody());
Map<String, String> errMap = new HashMap<String, String>();
/* The following try/catch block shows how to properly fetch
parameters for PUT/POST operations
* from the JSON request body
*/
JSONParser parser = new JSONParser();
try {
Object obj = parser.parse(request.getBody());
JSONObject jsonObject = (JSONObject) obj;
// Fetch the values passed in by the user from the body of JSON
carID = (String) jsonObject.get("car_ID");
year = (String) jsonObject.get("year");
//Q1: This is assigning the values to fields in the fetched Object?
} catch (ParseException pe) {
logger.error(pe.getMessage(), pe);
return Util.badRequestResponse(errMap, pe.getMessage());
}
if (Util.hasNulls(year, carID)){
return Util.badRequestResponse(errMap);
}
//Q2: Is this creating a new HashMap? If so, why is there a need?
Map<String, SMValue> feedback = new HashMap<String, SMValue>();
//Q3: This is taking the key "updated year" and assigning a value
(year)? Why?
feedback.put("updated year", new SMInt(Long.parseLong(year)));
DataService ds = serviceProvider.getDataService();
List<SMUpdate> update = new ArrayList<SMUpdate>();
/* Create the changes in the form of an Update that you'd like to
apply to the object
* In this case I want to make changes to year by overriding existing
values with user input
*/
update.add(new SMSet("year", new SMInt(Long.parseLong(year))));
SMObject result;
try {
// Remember that the primary key in this car schema is `car_id`
//Q4: If the Object is updated earlier with update.add... What is
the code below doing?
result = ds.updateObject("car", new SMString(carID), update);
//Q5: What's the need for the code below?
feedback.put("updated object", result);
} catch (InvalidSchemaException ise) {
return Util.internalErrorResponse("invalid_schema", ise, errMap);
// http 500 - internal server error
} catch (DatastoreException dse) {
return Util.internalErrorResponse("datastore_exception", dse,
errMap); // http 500 - internal server error
}
return new ResponseToProcess(HttpURLConnection.HTTP_OK, feedback);
}
}
Q1: Code below is assigning the values to fields in the fetched Object?
carID = (String) jsonObject.get("car_ID");
year = (String) jsonObject.get("year");
Q2: Is this creating a new HashMap? If so, why is there a need?
Map<String, SMValue> feedback = new HashMap<String, SMValue>();
Q3: This is taking the key "updated year" and assigning a value (year)? Why?
feedback.put("updated year", new SMInt(Long.parseLong(year)));
Q4: If the Object is updated earlier with update.add... What is the code
below doing?
result = ds.updateObject("car", new SMString(carID), update);
Q5: What's the code below doing?
feedback.put("updated object", result);
Original Code
SMSet
SMInt

How to define dbhandler constructor variables in mainactivity?

How to define dbhandler constructor variables in mainactivity?

dbhandler class
public class DBHandler extends SQLiteOpenHelper{
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "feedbackDB.db";
private static final String TABLE_FEEDBACK = "feedback";
private static final String DB_PATH =
"/data/data/com.example.vbfeed/databases/";
public DBHandler(Context context, String name,CursorFactory factory, int
version) {
super(context,context.getExternalFilesDir(null).getAbsolutePath()
+ DB_PATH + DATABASE_NAME, factory, DATABASE_VERSION);
}
Main activity code under onCreate and button on Click
DBHandler dbHandler = new DBHandler(getBaseContext(),name,null, 1);
//having error in this line--just constructor defining error,
//i dono the variables to declare

Sunday, 15 September 2013

unknown database file with .dat extension?

unknown database file with .dat extension?

I have a .dat database that could not open with ms.access. I don't know
how to open it. There is a Dos software that use this database and I want
to modify it's contents.
When open that file with notepad I see: 1

Eclipse's equivalent of IntelliJ's Ctrl+P

Eclipse's equivalent of IntelliJ's Ctrl+P

In IntelliJ, when your cursor is inside a method, you can press Ctrl+P to
view the parameters of the method.
What's the equivalent shortcut in Eclipse?

Kendo UI grid popup edit custom template - Add a multi-select control

Kendo UI grid popup edit custom template - Add a multi-select control

I'm using custom popup editor template for the edit popup option of the grid:
editable: { mode: "popup",
template: $("#popup_editor").html()
},
<!-- popup editor template -->
<script id="popup_editor" type="text/x-kendo-template">
template
</script>
There requirements for the template have a few multi-select controls that
are not in the grid, the summary of what the user selects in these
multi-select controls is what determines a "summary" field in the grid.
Ex:
(multi-select1) color: red, blue, purple --- not a field in grid
(multi-select2) size: xs, s --- not a field in grid
Summary: color="red, blue, purple" ; size="xs, s" --- field shown in grid
Question is: how can i add the multi-select in the edit popup custom
template?

Dynamic Image Slideshow

Dynamic Image Slideshow

I have a php script that returns url links to images that I want to
display one at a time in a slideshow-like form. The string can return up
to 10 new image links at a time so I wanted to only call the php script
again once they have reached the end of the current image list.
The lightbox2 library was the closest to the look and feel that I wanted
with the functionality that I mentioned above. Can anyone point me to a
similar project with the html, css, and jquery required?

How to pass the contents of a CGI file to a custom interpreter?

How to pass the contents of a CGI file to a custom interpreter?

I'm trying to write a custom cgi scripting language so I can pass simple
commands to a program through cgi rather than piping or passing.
#! ./CustomInterpreter
Test line 1
Test Line 2
Test Line 3
I'm trying to read the lines out of this cgi file from CustomInterpreter
and then execute commands in response. But I'm running into trouble.
I tried reading the lines from the standard input stream, like with piping
files.
In java:
Scanner s = new Scanner(System.in);
in c++:
char c;
while (c = getchar() != EOF)
putchar(c);
I can just read the file-name of the cgi script from the argument list and
open an input stream from that file, ignore the invocation line and then
proceed to the content. But I don't know if invoking a cgi script locally
already creates a data stream. If so, wont I have an extra stream? If not
then I know I just open the cgi file explicitly, but that seems so
slap-dash.
Any help on this would be great.

i wont to make the device vibrate when press down and stop if i move my finger

i wont to make the device vibrate when press down and stop if i move my
finger

how can i make the device vibrate if i press down and stop vibrate if i
move my finger of ?? now this work with the sound but it not working with
the vibrate and this is the code `
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
if(MotionEvent.ACTION_DOWN == arg1.getAction())
{
mp.start();
df= (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
}
else
if(MotionEvent.ACTION_UP == arg1.getAction())
{
mp.stop();
try {
mp.prepare();
try {
df.wait(arg1.getDownTime());
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//df.cancel();
}
return false;
}
});
}
`

Mouse events in C#

Mouse events in C#

I use Mouse events MouseEnter and MouseLeave with a pictureBox. The Back
Color changes with Mouse Enter but do not change in normal with mouse
Leave Event.
public void pictureBox1_MouseEnter(object sender, EventArgs e)
{
pictureBox1.BackColor = Color.Blue;
}
public void pictureBox1_MouseLeave(object sender, EventArgs e)
{
pictureBox1.BackColor = SystemColors.Control;
}

Saturday, 14 September 2013

How to convert html menu to WordPress menu (WordPress)

How to convert html menu to WordPress menu (WordPress)

Guys, I have following codes in my html. I'm using 320 bootstrap wp theme.
I just create a menu. Its working. But that above box is not moving to
menu to menu. How I do it?
For more explain. Please visit below links.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Menu Tutorial - Cufon Font Script</title>
<link rel="shortcut icon" href="images/favicon.ico" />
<!--CSS-->
<link href="styles/style.css" rel="stylesheet" type="text/css" />
<link href="styles/color.css" rel="stylesheet" type="text/css" />
<link href="styles/noscript.css" rel="stylesheet" type="text/css"
id="noscript" media="screen,all" />
<!--End testimonial-->
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript"
src="js/Ebrima_400-Ebrima_700.font.js"></script>
<script type="text/javascript">
Cufon.replace('h1') ('h2') ('h3') ('h4') ('h5') ('h6')
('.nivo-caption h1', {textShadow: '#000 2px 0px 2px'})
('.nivo-caption .button');
</script>
<script type="text/javascript" src="js/jquery.lavalamp.js"></script>
<script type="text/javascript" src="js/lavalamp-config.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.1.js"></script>
</head>
<body>
<div id="wrapper">
<div id="wrapper-top">
<div id="top">
<div id="top-left"><a href="index.html">
<img src="images/logo.png" alt="" width="223"
height="58" />It's An Image</a></div><!--
#top-left -->
<div id="top-right">
<div id="nav">
<ul id="topnav">
<li class="active"><a
href="index.html" >Home</a></li>
<li><a href="about.html">About Us</a>
</li>
<li><a href="services.html">Services</a>
<ul>
<li><a href="#">Services One</a></li>
<li><a href="#">Services Two</a></li>
<li><a href="#">Services
Three</a></li>
<li><a href="#">Services
Four</a></li>
</ul>
</li>
<li><a href="#">Portfolio</a>
<ul>
<li><a href="#">Portfolio
One</a></li>
<li><a href="#">Portfolio
Two</a></li>
<li><a href="#">Portfolio
Three</a></li>
</ul>
</li>
<li><a
href="contact.html">Contact</a></li>
</ul>
<!-- #topnav -->
</div><!-- #nav -->
</div><!-- #top-right -->
</div><!-- #top -->
</div><!-- #wrapper-top -->
<script type="text/javascript"> Cufon.now(); </script> <!-- to fix
cufon problems in IE browser -->
<script
type="text/javascript">jQuery('#noscript').remove();</script><!-- if
javascript disable -->
</body>
</html>
To View That I Expect
Explains
You can see my updates viewing that link from dropbox.
You can see red box around css depth box.
It's moving well in html page
I want to do it in WP
Seeking your help here

Curly braces continuity

Curly braces continuity

This question may be too vague but I need to hear some ideas.. I have an
intricate issue with my code, I was able to reduce the problem to this
situation:
public void MyMethod()
{
foreach(Obj o in ObjCollection)
{
if(Something)
{
//Do operations
}
MessageBox.Show("1");
}
MessageBox.Show("2");
}
The first message shows up. The second doesn't. How in the world that is
possible? Is there a way of this behavior or I'm missing something?
The actual code is too long for pasting it here but it works if I isolate it.

Collect Form Data, insert in xml fields to post to Payment Gateway

Collect Form Data, insert in xml fields to post to Payment Gateway

I need to take payment information from a form and place it in XML and
then post it to the payment gateway server. I am rather a novice at best
and I am not sure of the easiest way to do this.
I have successfully been able to post to the payment gateway by manually
entering the info into the XML on a static php file, so I know the XML is
correct, the only real issue for me would be finding the easiest way to
take form data and place into the XML.
Below is a sample of the php file and the XML.
<?php
$TransactionId = intval( date(Yms). rand(1,9) . rand(0,9) . rand(0,9) .
rand(0,9) . rand(0,9). rand(0,9) );
$MerchantId="111111";
$TerminalId="111111";
$ApiPassword="111111";
$private_key="asdfasghgfdhggdfgs";
$ApiPassword_encrypt=hash('sha256',$ApiPassword);
$xmlReq='<?xml version="1.0" encoding="UTF-8" ?>
<TransactionRequest
xmlns="https://test.processing.com/securePayments/direct/v1/processor.php">
<Language>ENG</Language>
<Credentials>
<MerchantId>'.$MerchantId.'</MerchantId>
<TerminalId>'.$TerminalId.'</TerminalId>
<TerminalPassword>'.$ApiPassword_encrypt.'</TerminalPassword>
</Credentials>
<TransactionType>LP001</TransactionType>
<TransactionId>'.$TransactionId.'</TransactionId>
<ReturnUrl page="http://www.website.net/response.php">
<Param>
<Key>inv</Key>
<Value>'.$TransactionId.'</Value>
</Param>
</ReturnUrl>
<CurrencyCode>USD</CurrencyCode>
<TotalAmount>44450</TotalAmount>
<CardDetails>
<CardHolderName>John Smith</CardHolderName>
<CardNumber>4653111111111111</CardNumber>
<CardExpireMonth>01</CardExpireMonth>
<CardExpireYear>15</CardExpireYear>
<CardType>VI</CardType>
<CardSecurityCode>030</CardSecurityCode>
<CardIssuingBank>UNKNOWN</CardIssuingBank>
<CardIssueNumber></CardIssueNumber>
</CardDetails>
</TransactionRequest>';
$signature_key=trim($private_key.$ApiPassword.$TransactionId);
$signature=base64_encode(hash_hmac("sha256", trim($xmlReq),
$signature_key, True));
$encodedMessage=base64_encode($xmlReq);

If Method calls are dynamically binded then why the Compiler complains The method xyz is undefined for the type xxx

If Method calls are dynamically binded then why the Compiler complains The
method xyz is undefined for the type xxx

If Method calls are dynamically binded then why the Compiler complains
The method run() is undefined for the type B
Why is compiler checking for the presence of method run in Class b
Here is the code
import java.lang.*;
public class Program
{
public static void main(String [] args)
{
B a = new A();
a.run();//compiler complains at this line.
a.p(10);
a.p(10.0);
}
}
class B {
public void p(int i)
{
System.out.println(i*2);
}
}
class A extends B{
public void p(int i)
{
System.out.println(i);
}
public void run(){
}
}

CustomListView and CursorAdapter Searching issue

CustomListView and CursorAdapter Searching issue

I have a custom ListView and I can access and show data from database. The
problem is When I don't perform any search, onItemClick is working fine.
But, when I try to Search any ListView item and want to access that item.
It shows this
09-14 06:17:50.280: E/AndroidRuntime(1091): FATAL EXCEPTION: main
09-14 06:17:50.280: E/AndroidRuntime(1091):
java.lang.IllegalArgumentException: column 'AF_NAME' does not exist
09-14 06:17:50.280: E/AndroidRuntime(1091): at
android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:303)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
com.yasiradnan.abstracts.AbstractActivity$1.onItemClick(AbstractActivity.java:111)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
android.widget.AdapterView.performItemClick(AdapterView.java:298)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
android.widget.AbsListView.performItemClick(AbsListView.java:1100)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
android.widget.AbsListView$1.run(AbsListView.java:3423)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
android.os.Handler.handleCallback(Handler.java:725)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
android.os.Handler.dispatchMessage(Handler.java:92)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
android.os.Looper.loop(Looper.java:137)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
android.app.ActivityThread.main(ActivityThread.java:5041)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
java.lang.reflect.Method.invokeNative(Native Method)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
java.lang.reflect.Method.invoke(Method.java:511)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-14 06:17:50.280: E/AndroidRuntime(1091): at
dalvik.system.NativeStart.main(Native Method)
here is my Activity.java code
AbstractCursorAdapter cursorAdapter;
ListView listView;
EditText searchOption;
Cursor cursor;
ListView lv;
String authorNames;
String is_Corrospondence;
String getAfNumber;
String getAuthorID;
DatabaseHelper dbHelper = new DatabaseHelper(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.abstract_general);
listView = (ListView)findViewById(R.id.list);
searchOption = (EditText)findViewById(R.id.abSearch);
dbHelper.open();
String query = "select
abstracts_item._id,CORRESPONDENCE,title, type, topic,
text,af_name,REFS,ACKNOWLEDGEMENTS from
abs_affiliation_name,abstract_affiliation,abstracts_item,abstract_author,authors_abstract
where abstracts_item._id = authors_abstract.abstractsitem_id
and abstract_author._id = authors_abstract.abstractauthor_id
and abstract_affiliation._id = abstract_author._id and
abs_affiliation_name._id = abstracts_item._id GROUP By
abstracts_item._id";
cursor = DatabaseHelper.database.rawQuery(query, null);
Log.e("Cursor Count", String.valueOf(cursor.getCount()));
/*
* Check If Database is empty
*/
if (cursor.getCount() <= 0) {
datainList();
cursor = DatabaseHelper.database.rawQuery(query, null);
}
cursorAdapter = new AbstractCursorAdapter(this, cursor);
listView.setAdapter(cursorAdapter);
listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view,
int position, long arg3) {
// TODO Auto-generated method stub
cursor = (Cursor)cursorAdapter.getCursor();
String Text =
cursor.getString(cursor.getColumnIndexOrThrow("TEXT"));
String Title =
cursor.getString(cursor.getColumnIndexOrThrow("TITLE"));
String Topic =
cursor.getString(cursor.getColumnIndexOrThrow("TOPIC"));
String value =
cursor.getString(cursor.getColumnIndexOrThrow("_id"));
String afName =
cursor.getString(cursor.getColumnIndexOrThrow("AF_NAME"));
String email =
cursor.getString(cursor.getColumnIndexOrThrow("CORRESPONDENCE"));
String refs =
cursor.getString(cursor.getColumnIndexOrThrow("REFS"));
String acknowledgements =
cursor.getString(cursor.getColumnIndexOrThrow("ACKNOWLEDGEMENTS"));
Log.e("Position", String.valueOf(position));
int itemNumber = cursor.getCount();
Intent in = new Intent(getApplicationContext(),
AbstractContent.class);
in.putExtra("abstracts", Text);
in.putExtra("Title", Title);
in.putExtra("Topic", Topic);
in.putExtra("value", value);
in.putExtra("afName", afName);
in.putExtra("email", email);
in.putExtra("refs", refs);
in.putExtra("itemNumber", itemNumber);
in.putExtra("acknowledgements",acknowledgements);
startActivity(in);
}
});
/*
* Serach Filter
*/
cursorAdapter.setFilterQueryProvider(new FilterQueryProvider() {
public Cursor runQuery(CharSequence constraint) {
//return dbHelper.fetchDataByName(constraint.toString());
cursor = DatabaseHelper.database.rawQuery("select
ABSTRACTS_ITEM._id, "
+
"GROUP_CONCAT(ABSTRACT_AUTHOR.NAME),ABSTRACTS_ITEM.TITLE,
ABSTRACTS_ITEM.TOPIC, "
+ "ABSTRACTS_ITEM.TYPE, ABSTRACTS_ITEM.TEXT, "
+ "ABSTRACT_KEY_WORDS.KEYWORDS "
+ "from ABSTRACTS_ITEM , ABSTRACT_AUTHOR ,
AUTHORS_ABSTRACT, ABSTRACT_KEY_WORDS "
+ "where ABSTRACTS_ITEM._id =
ABSTRACT_KEY_WORDS._id "
+ "and ABSTRACTS_ITEM._id =
AUTHORS_ABSTRACT.ABSTRACTSITEM_ID "
+ "and ABSTRACT_AUTHOR._id =
AUTHORS_ABSTRACT.ABSTRACTAUTHOR_ID "
+ "and (ABSTRACT_KEY_WORDS.KEYWORDS like '%" +
constraint.toString() + "%' "
+ "or ABSTRACTS_ITEM.TITLE like '%" +
constraint.toString() + "%' or
ABSTRACT_AUTHOR.NAME like '%" +
constraint.toString() + "%')GROUP BY
ABSTRACTS_ITEM._id", null);
return cursor;
}
});
searchOption.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int start, int
before, int count) {
// TODO Auto-generated method stub
AbstractActivity.this.cursorAdapter.getFilter().filter(cs);
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
}
private void datainList() {
try {
InputStream inStream =
this.getResources().openRawResource(R.raw.abstracts);
JSONArray jsonArray = JSONReader.parseStream(inStream);
for (int index = 0; index < jsonArray.length(); index++) {
JSONObject jsonObject = jsonArray.getJSONObject(index);
String topic = jsonObject.getString("topic");
String correspondence =
jsonObject.getString("correspondence");
String url = jsonObject.getString("url");
String coi = jsonObject.getString("coi");
String cite = jsonObject.getString("cite");
String type = jsonObject.getString("type");
String title = jsonObject.getString("title");
String refs = "";
if (jsonObject.has("refs")) {
refs = jsonObject.getString("refs");
}
String acknowledgements = "";
if(jsonObject.has("acknowledgements")){
acknowledgements =
jsonObject.getString("acknowledgements");
}
String text = jsonObject.getString("abstract");
dbHelper.addItems(null, text, topic, correspondence,
url, coi, cite, type, title, refs, acknowledgements);
JSONObject abAfData =
jsonArray.getJSONObject(index).getJSONObject("affiliations");
String af_name = abAfData.toString().replaceAll("\\{",
"").replaceAll("\\}", "");
dbHelper.addAbsAffiliation(af_name, null);
JSONArray getKeywords = new
JSONArray(jsonObject.getString("keywords"));
String keywordsData =
String.valueOf(getKeywords).replaceAll("\\[", "")
.replaceAll("\\]",
"").toString().replace("\"", "");
dbHelper.addKeyWord(keywordsData, null);
JSONArray getAuthorsArray = new
JSONArray(jsonObject.getString("authors"));
for (int counter = 0; counter <
getAuthorsArray.length(); counter++) {
JSONObject authjsonObJecthor =
getAuthorsArray.getJSONObject(counter);
JSONArray getNumbers = new JSONArray(
authjsonObJecthor.getString("affiliations"));
authorNames = authjsonObJecthor.getString("name");
String is_Corrospondence = "";
if (authjsonObJecthor.has("corresponding")) {
is_Corrospondence =
authjsonObJecthor.getString("corresponding");
}
getAfNumber =
getNumbers.toString().replaceAll("\\[",
"").replaceAll("\\]", "");
dbHelper.addAbstractAffiliation(null, getAfNumber);
if (!dbHelper.Exists(authorNames)) {
dbHelper.addAuthors(null, authorNames,
is_Corrospondence);
dbHelper.addAuthorsAbstractItems(dbHelper.items_id,
dbHelper.authors_id,
dbHelper.abstract_affiliation_id);
dbHelper.authorsAffiliation(dbHelper.abstract_affiliation_id,
dbHelper.authors_id);
if (is_Corrospondence.equalsIgnoreCase("True")) {
dbHelper.addCorrespondingAuthor(dbHelper.items_id,
dbHelper.authors_id);
}
} else {
cursor = dbHelper.database.rawQuery(
"select _id from abstract_author where
NAME like '%" + authorNames
+ "%'", null);
try {
if (cursor.moveToFirst()) {
getAuthorID = cursor.getString(0);
}
} finally {
cursor.close();
}
if (is_Corrospondence.equalsIgnoreCase("True")) {
dbHelper.addCorrespondingAuthor(dbHelper.items_id,
Integer.parseInt(getAuthorID));
}
dbHelper.addAuthorsAbstractItems(dbHelper.items_id,
Integer.parseInt(getAuthorID),
dbHelper.abstract_affiliation_id);
dbHelper.authorsAffiliation(dbHelper.abstract_affiliation_id,
Integer.parseInt(getAuthorID));
}
}
}
} catch (FileNotFoundException e) {
Log.e("jsonFile", "file not found");
} catch (IOException e) {
Log.e("jsonFile", "ioerror");
} catch (JSONException e) {
e.printStackTrace();
}
}
}
Here is my Adapter code
Cursor cursorOne;
String getName;
@SuppressWarnings("deprecation")
public AbstractCursorAdapter(Context context, Cursor c) {
super(context, c);
// TODO Auto-generated constructor stub
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
// TODO Auto-generated method stub
TextView title = (TextView)view.findViewById(R.id.abTitle);
title.setText(cursor.getString(cursor.getColumnIndexOrThrow("TITLE")));
TextView topic = (TextView)view.findViewById(R.id.abTopic);
topic.setText(cursor.getString(cursor.getColumnIndexOrThrow("TOPIC")));
TextView type = (TextView)view.findViewById(R.id.abType);
type.setText(cursor.getString(cursor.getColumnIndexOrThrow("TYPE")));
String value = cursor.getString(cursor.getColumnIndexOrThrow("_id"));
String sqlQuery = "select abstracts_item._id AS
ID,abstract_author.NAME AS NAME from
abstracts_item,abstract_author,authors_abstract where
abstracts_item._id = authors_abstract.abstractsitem_id and
abstract_author._id = authors_abstract.abstractauthor_id and ID =
"
+ value;
cursorOne = DatabaseHelper.database.rawQuery(sqlQuery, null);
if (cursorOne != null) {
cursorOne.moveToFirst();
do {
if (cursorOne.getPosition() == 0) {
getName =
cursorOne.getString(cursorOne.getColumnIndexOrThrow("NAME"));
} else if (cursorOne.isLast()) {
getName = getName + " & "
+
cursorOne.getString(cursorOne.getColumnIndexOrThrow("NAME"));
} else {
getName = getName + " , "
+
cursorOne.getString(cursorOne.getColumnIndexOrThrow("NAME"));
}
} while (cursorOne.moveToNext());
}
TextView authorNames = (TextView)view.findViewById(R.id.SubTitle);
/*
* Get Width
*/
WindowManager WinMgr =
(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
int displayWidth = WinMgr.getDefaultDisplay().getWidth();
Paint paint = new Paint();
Rect bounds = new Rect();
int text_height = 0;
int text_width = 0;
paint.getTextBounds(getName, 0, getName.length(), bounds);
text_height = bounds.height();
text_width = bounds.width();
if (text_width > displayWidth) {
//Log.e("Width inside",
String.valueOf(text_width)+"--------------"+String.valueOf(displayWidth));
String output = getName.split(",")[0] + " et al. ";
authorNames.setText(output);
} else {
//Log.e("Width inside",
String.valueOf(text_width)+"--------------"+String.valueOf(displayWidth));
authorNames
.setText(getName.replaceAll("((?:^|[^A-Z.])[A-Z])[a-z]*\\s(?=[A-Z])",
"$1."));
}
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup
viewgroup) {
// TODO Auto-generated method stub
LayoutInflater inflater =
LayoutInflater.from(viewgroup.getContext());
View returnView = inflater.inflate(R.layout.abstract_content,
viewgroup, false);
return returnView;
}
}
Now, My question why this is happening? How can I solve that ? Can you
give me a tutorial project link similar search function and
customListview, So that I can see what they're doing. I tried to find it
on google,but didn't found. Thanks