Monday, 30 September 2013

Mike asks Billy to help him run his lemonade stand. He’ll either pay him 2/5 of ½ of the

Mike asks Billy to help him run his lemonade stand. He'll either pay him
2/5 of ½ of the

Mike asks Billy to help him run his lemonade stand. He'll either pay him
2/5 of ½ of the stand's profits, or 1/3 of ¾ of the stand's profits. Which
should Billy choose to maximize the amount he will earn, and by what
amount will his earnings be increased?
Billy should choose 1/3 of ¾; he'll earn 1/15 more.
Billy should choose 1/3 of ¾; he'll earn 1/20 more.
Billy should choose 2/5 of ½; he'll earn 1/15 more.
Billy should choose 2/5 of ½; he'll earn 1/20 more.
It doesn't matter; either way, Billy will earn exactly the same amount.
Source: http://www.transtutors.com/questions/math-help-327246.htm

What went wrong=?iso-8859-1?Q?=2C_Falcon_9_1.1_first_flight_with_first_stage_landing_att?=empt=?iso-8859-1?Q?=3F_=96_space.stackexchange.com?=

What went wrong, Falcon 9 1.1 first flight with first stage landing
attempt? – space.stackexchange.com

They are reporting that the three engine relight in the upper atmosphere
worked. But the relight of a single engine, lower down for pretend landing
on the water generated too much torque and the fuel …

Grab, move and drop control in Form by mouse

Grab, move and drop control in Form by mouse

Hello I have found this code that might help me with following issue, I'm
trying to make drag, drop and move label in my Form by mouse.
private Point MouseDownLocation;
private void MyControl_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
MouseDownLocation = e.Location;
}
}
private void MyControl_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
this.Left = e.X + this.Left - MouseDownLocation.X;
this.Top = e.Y + this.Top - MouseDownLocation.Y;
}
}
But when I assing mousemove and mousedown as events to label and i try to
grab the label and move with mouse it moves with the whole Form.
May I ask where is should the code be improved?
Thank you for your time.

Select method of range class failed Error

Select method of range class failed Error

Dim dflrow, agi, ahi, aii, aji As Integer
Dim agd As Date
ActiveWorkbook.Sheets("ElecTM").Range("I104876").Select
dflrow = Selection.End(xlUp).Row + 1
For agi = 6 To dflrow
agd = ActiveWorkbook.Sheets("ElecTM").Range("I" & agi).Value
ActiveWorkbook.Sheets("ElecTM").Range("AG" & agi).Formula
="=CONCATENATE(Year(range(agd)),""w"",WeekNum(range(agd)))"
Next agi
When i execute above code, On third line it shows 'Run time Error Select
method of range class failed'. Can u help??...

Sunday, 29 September 2013

How to declare the nested classes correctly?

How to declare the nested classes correctly?

Following code is a implemention of Binary Tree, coming from a C++ data
structure text. I canot compile the code successfully, getting some error
messages. Mainly, the error lines comes from the last two of the code. How
to fix this problem? My compiler is CODE::BLOCK 12.11.
#include<iostream>
#include<list>
using namespace std;
typedef int Elem;
struct Node
{
Elem elt;
Node *par;
Node *left;
Node *right;
Node():elt(),par(NULL),left(NULL),right(NULL){}
};
class Position
{
private:
Node *v;
public:
Position(Node *_v=NULL):v(_v){}
Elem &operator*(){return v->elt;}
Position left()const{return Position(v->left);}
Position right()const{return Position(v->right);}
Position parent()const{return Position(v->par);}
bool isRoot()const{return v->par==NULL;}
bool isExternal()const{return v->left==NULL&&v->right==NULL;}
friend class LinkedBinaryTree;
};
typedef std::list<Position> PositionList;
class LinkedBinaryTree
{
protected:
struct Node; //This line is by me, the text merely tell you "insert Node
declaration here. . ." I don't know whether this line is correct or not.
public:
class Position; // Also by me, the text merely tell you "insert Position
declaration here. . ." I don't know wwhether this line is correct or not.
public:
LinkedBinaryTree();
int size()const;
bool empty()const;
Position root()const;
PositionList positions()const;
void addRoot();
void expandeExternal(const Position& p);
protected:
void preorder(Node* v,PositionList& pl)const;
private:
Node* _root;
int n;
};
LinkedBinaryTree::LinkedBinaryTree():_root(NULL),n(0){}
int LinkedBinaryTree::size()const{return n;}
bool LinkedBinaryTree::empty()const{return size()==0;}
LinkedBinaryTree::Position LinkedBinaryTree::root()const{Position(_root);}
//canot compile successfully, this error messages is :
C:\Users\user\Documents\aa\main.cpp|58|error: return type 'class
LinkedBinaryTree::Position' is incomplete
void LinkedBinaryTree::addRoot(){_root=new Node;n=1;} //canoot compile
successfully, this error message is
C:\Users\user\Documents\aa\main.cpp|59|error: invalid use of incomplete
type 'struct LinkedBinaryTree::Node'
There are many error messages, I select one of them to represent the error
messages.

Count of menus selected

Count of menus selected

I have 16 drop down menus in a webpage. If the user enters only 10 of them
then how to i get the total count of only the selected items(10). Kindly
help me with this. Give me a javascript to run this. Thank You.

Couldn't find the error in Ajax

Couldn't find the error in Ajax

I'm the dumbo back again with a silly question. I spent more than 6 hrs,
but couldn't find where the problem is.
Can you please help me solving this?
<form>
<select name="pmethod" id="pmethod">
<option value="">- Please Select -</option>
<option value="deposit">Deposit a Cheque at a local ICICI Bank</option>
<option value="transfer">Online Transfer by using your Net Banking
Account</option>
<option value="courier">Courier/Hand Deliver a "Payable At Par in Mumbai"
Cheque</option>
</select>
<div id="chqdetails" class="hide">
<input type="text" name="chqdetails" id="chqdetails" value="" size="60" >
<span id="chqdetailserror" class="etext"><br>Please provide cheque
details.</span>
</div>
<div id="trdetails" class="hide">
<input type="text" name="trno" id="trno" value="" size="60">
<span id="trnoerror" class="etext"><br>Please provide Transaction ID</span>
</div>
<div id="codetails" class="hide">
<input type="text" name="cochqdetails" id="cochqdetails" value="" size="60">
<span id="codetailserror" class="etext"><br>Please provide cheque
details.</span>
</div>
<div id="submitbutton" class="hide"><input type="submit" name="submit"
value="Submit Order"></div>
</form>
JSFiddle
The problems are:
When Deposit option is selected, neither it shows the error msg (if
blank), nor it shows the submit button if text is inserted.
Surprisingly, if Transfer is selected, the error msgs are displayed
properly, and the submit button if text is entered.
If Courier method is selected, it doesn't show the input box at all!!
Where am I doing wrong?
Thanks for your time and help.

Saturday, 28 September 2013

GridBagLayout anchoring is not working, always showing in the JPanel in center

GridBagLayout anchoring is not working, always showing in the JPanel in
center

My application is in fullscreen exclusive mode, i want the JPanel
mainPanel to be in LAST_LINE_START with some padding to the left and
right. but when i run this program it only shows the mainPanel in center
of the screen. I tried other positions also, but they did not work either.
private void mainWindow()
{
gls =(JPanel) mainUi.getGlassPane();
gls.setLayout(new GridBagLayout());
JPanel mainPanel = new JPanel(new GridLayout(4,1));
nwGame = new JButton("New Game");
nwGame.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
gls.setVisible(false);
startGame(0);
mainUi.repaint();
}
});
ldGame = new JButton("Load Game");
ldGame.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae)
{
}
});
changeProfile = new JButton("Change Profile");
changeProfile.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae)
{
}
});
qtGame = new JButton("Quit Game");
qtGame.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae)
{
}
});
GridBagConstraints gbc = new GridBagConstraints();
gbc.ipadx = 10;
gbc.ipady = 10;
gbc.anchor = GridBagConstraints.LAST_LINE_START;
mainPanel.add(nwGame);
mainPanel.add(ldGame);
mainPanel.add(changeProfile);
mainPanel.add(qtGame);
gls.add(mainPanel,gbc);
gls.setVisible(true);
mainUi.add(gls);
if(!mainUi.isVisible())
mainUi.setVisible(true);
}

g++-4.8 C++ stdlib dylib

g++-4.8 C++ stdlib dylib

I compiled a "Hello world" C++ file with gcc48 (installed via homebrew)
and when i check the dynamic libraries linked i see:
otool -L Test
Test:
/usr/local/Cellar/gcc48/4.8.1/gcc/lib/libstdc++.6.dylib (compatibility
version 7.0.0, current version 7.18.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 169.3.0)
/usr/local/Cellar/gcc48/4.8.1/gcc/lib/libgcc_s.1.dylib (compatibility
version 1.0.0, current version 1.0.0)
However if i compile this with an apple provided gcc,g++ i get:
Test:
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current
version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 169.3.0)
How can i get g++-4.8 to link/compile with the apple provided .dylib?
Thanks!

strange img src path, not working on localhost

strange img src path, not working on localhost

first of all sorry for the silly title. I found solved by flexbox, I
cloned it to localhost, and the site is just crap for me. It works on a
really strange way, no headers in the index, the images not shown:
<img class="Feature-image" alt="Better, Simpler Grids" src="{{
'/images/grids.jpg' | absolute }}">
it is a really silly question but with what technique is this repo written?

Confusion about Thread

Confusion about Thread

We can create a reference of an interface but not object. But how can we
pass new Runnable() to the Thread constructor. As per as my knowledge is
concert new Class_Name() is object.
Thread t = new Thread(new Runnable(){});

Friday, 27 September 2013

FORCE INDEX mySQL ...where do I put it?

FORCE INDEX mySQL ...where do I put it?

I have the following mySQL query that works perfectly fine. Except that I
need to add a "FORCE INDEX" and I'm unsure on where I have to do this. I
tried just about every location and always receive a mySQL error. What am
I doing wrong?
Here is the original query:
$sql_select_recent_items = $db->query("SELECT * FROM (SELECT owner_id,
product_id, start_time, price, currency, name, closed, active, approved,
deleted, creation_in_progress FROM db_products ORDER BY start_time DESC)
as resultstable
WHERE resultstable.closed=0 AND resultstable.active=1 AND
resultstable.approved=1 AND resultstable.deleted=0 AND
resultstable.creation_in_progress=0
GROUP BY resultstable.owner_id
ORDER BY start_time DESC");
The query is constructed this way so that I can do the "ORDER BY" before
the "GROUP BY", in case you're wondering.
What I need to add is:
FORCE INDEX (products_start_time)
I tried it just about everywhere without success, which leads me to
believe that there's something more complex that I'm missing?

need help using div and iframe

need help using div and iframe

i have created a little website (which will probably stay offline) to make
some things easier; i created a hotbar with links so i can navigate to
important sites more easily problem is: to iframe google into the webpage
i had to use a proxy (i used hidemyass) because google blocks the use of
iframes, but because the proxy site has a huuuugeee banner on top of every
page you open trough it i moved the content inside of the iframe using
margin top in CSS so the banner is still there but you can't see it but
now whenever i open any other website in the same iframe without any
banners it will hide part of the website and i don't want this so how do i
make it hide the banner on top of the proxy page and still fully display
any other page? i tried to give the div and iframe 2 names so that i could
make 2 CSS statements but this doesn't work. here's the code thanks, jordy

jQuery Countdown installed. Having trouble displaying multiple countdowns...

jQuery Countdown installed. Having trouble displaying multiple countdowns...

Please review my Sample Fiddle...
I have a jQuery Countdown timer installed. It's nested inside an accordion
menu.
There's supposed to be a different timer under each accordion. It only
seems to work when I have it under one accordion. Once I placed the code
under multiple accordions, it only accepts the data from the last timer.
I'm trying to get one under each. Can you push me in the right direction?
This body script calls the function...
//Give the date ---------------------------------
year = 2013; month = 09; day = 27;
//Give the point of time ------------------------
hour= 0; min= 0; sec= 0;
//Standard text ---------------------------------
main_titel= 'Next Start Date - Thursday, October 3, 2013';
//-----------------------------------------------
And this script contains the function...
function GetCount(){
dateNow = new Date();
amount = dateFuture.getTime() - dateNow.getTime()+5;
delete dateNow;
/* time is already past */
if(amount < 0){
out=
"<div id='days'><span></span>0<div
id='days_text'></div></div>" +
"<div id='hours'><span></span>0<div
id='hours_text'></div></div>" +
"<div id='mins'><span></span>0<div
id='mins_text'></div></div>" +
"<div id='secs'><span></span>0<div
id='secs_text'></div></div>" ;
document.getElementById('countbox').innerHTML=out;
}
/* date is still good */
else{
days=0;hours=0;mins=0;secs=0;out="";
amount = Math.floor(amount/1000); /* kill the milliseconds */
days=Math.floor(amount/86400); /* days */
amount=amount%86400;
hours=Math.floor(amount/3600); /* hours */
amount=amount%3600;
mins=Math.floor(amount/60); /* minutes */
amount=amount%60;
secs=Math.floor(amount); /* seconds */
out=
"<div id='days'><span></span>" + days +"<div
id='days_text'></div></div>" +
"<div id='hours'><span></span>" + hours +"<div
id='hours_text'></div></div>" +
"<div id='mins'><span></span>" + mins +"<div
id='mins_text'></div></div>" +
"<div id='secs'><span></span>" + secs +"<div
id='secs_text'></div></div>" ;
document.getElementById('countbox').innerHTML=out;
setTimeout("GetCount()", 1000);
}
}
window.onload=function(){GetCount();}

I get this error Parse error: syntax error, unexpected '['

I get this error Parse error: syntax error, unexpected '['

"Log In"]); ?>
/** * Renders template, passing in values. */ function render($template,
$values = []) { // if template exists, render it if
(file_exists("../templates/$template")) { // extract variables into local
scope extract($values);
// render header
require("../templates/header.php");
// render template
require("../templates/$template");
// render footer
require("../templates/footer.php");
}
// else err
else
{
trigger_error("Invalid template: $template", E_USER_ERROR);
}
}

HttpSession remains after server restart

HttpSession remains after server restart

I'm learning Spring. Doing the login/logout functionality. This is what my
controller looks like:
@RequestMapping(value="/successfulLoginAuth", method=RequestMethod.GET)
public ModelAndView postHttpLogin(HttpSession session, Authentication
authInfo)
{
ModelAndView mav = new ModelAndView();
mav.setViewName("redirect:/index.html");
session.setAttribute("authInfo", authInfo);
return mav;
}
The log in is performed via Spring Security using a dao service which I
have implemented. That works fine.
This is the content of index.jsp:
<%
HttpSession session1 = request.getSession(false);
Authentication authInfo;
if( (session1 != null) &&
( (authInfo = (Authentication)session1.getAttribute("authInfo"))
!= null)
)
{
out.print(" yo " + authInfo.getName() + " " +
authInfo.getAuthorities().iterator().next().getAuthority());
}
else
{
%>
<a href="${pageContext.request.contextPath}/registration">New? Sign
Up!</a><br/>
<a href="${pageContext.request.contextPath}/login">Existing? Sign
In!</a><br/>
<%} %>
When i log in, and restart the server, I'm still logged in. Shouldn't the
session information be lost after a server restart? If i restart the
browser, it works as it should (ie the session info is lost).
This is my Spring Security configuration:
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/" access="permitAll" />
<intercept-url pattern="/logout" access="permitAll" />
<intercept-url pattern="/accessdenied" access="permitAll" />
<form-login login-page="/login"
default-target-url="/successfulLoginAuth"
authentication-failure-url="/accessdenied" />
<logout logout-success-url="/logout" />
</http>
<authentication-manager>
<authentication-provider
user-service-ref="myUserDetailsService"></authentication-provider>
</authentication-manager>

c# check if library/namespace/class exists (at compile time)

c# check if library/namespace/class exists (at compile time)

I've written some code in c# that uses a library, but I want to share it
and want it to work regardless of whether that library exists, basically I
want to check in my code whether the library exists, and if it doesn't, I
use alternate code to do what the library was supposed to do.
So how would you do that?
I thought maybe I could use Preprocessor Directives, but to be honest I
have little experience with these and can't seem to find how to this.

Thursday, 26 September 2013

Rapid Xml parse error if you don't use strlen (or similar function) on a download?

Rapid Xml parse error if you don't use strlen (or similar function) on a
download?

Hello fellow code monkeys,
I've run into the oddest problem I've ever seen today. I'm using a
codebase that uses rapidXml (unmodified to my knowledge). (C++ code base)
If I download a file (using proprietary code but that we've used for many
years) leaving it in the buffer, and then parse it with rapid xml, I get
back a parse error at the base tag. I've walked through the code and
satisfied myself to seeing that something is messed up.
If I download the file in Chrome, I can open the file, and validate the
XML easily. I can also download the file, open it with my program using
basic file commands and parse it into the rapidXML that way, and that
works.
If I open the file, and download the file at the same time with my program
the files strncmp perfectly. There is a trailing null on the file IO, but
adding that to download doesn't fix anything.
But this is where the query is.
If I strncmp and then parse the download buffer with rapid XML, the parse
completes correctly. If I do the same but instead run strlen, and then
parse the buffer, it also completes correctly.
It's not a time issue, as the download phase is finished, and I can open
the file and parse that, after the download, but before parsing the
downloaded buffer, and I'll still parse the download buffer incorrectly.
So the question is, I know strlen is a non destructive operation, it
actually shouldn't even change any of the data. It does return back the
shorter file size (by a byte) as expected. However is there any idea what
strlen (or strncmp) can be doing that causes the system to correctly parse
the buffer correctly?
Some factoids if necessary, the files are currently 141k, the download is
off of a storage cloud that's reliable, and my code does not operate until
the download is finished, and that code has stopped running, strlen and
strncmp is the standard variants, non destructive operations.

Wednesday, 25 September 2013

jquery doesn't seem to load after loading the page in ajax

jquery doesn't seem to load after loading the page in ajax

Hi im having a problem with the page loading another page i have a page a
and page b with page a it has an ajax that loads page b ,and page b loads
and runs jquery perfectly until i click on page a and then the jquery in
page b doesnt seem to can anyone help me with this?
AJAX
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest(); //Not IE
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP"); //IE
alert("Your browser doesn't support the
XmlHttpRequest object. Better upgrade to Firefox.");
}
}
var receiveReq = getXmlHttpRequestObject();
function get() {
if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
receiveReq.open("GET", 'b.php', true);
receiveReq.onreadystatechange = handleGet;
receiveReq.send(null);
}
}
function handleGet() {
if (receiveReq.readyState == 4) {
document.getElementById('content').innerHTML =
receiveReq.responseText;
}
}
PAGE 1 THAT LOADS THE AJAX AND THE SECOND PAGE
<script src="add.js"></script>
<a href="javascript:get()">Live Chat</a>
<div id='content' class='content'></div>
PAGE 2 THAT THE PAGE 1 LOADS WITH THE WORKING JQUERY IF LOADED BY IT SELF
BUT DOESNT WORK AFTER THE AJAX LOADS THIS PAGE
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>Test selctions</title>
<head>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#' + $('#selection
option:selected').text().toLowerCase()).show();
$('#selection').change(function () {
$('.op').hide();
$('#' + $('#selection
option:selected').text().toLowerCase()).show();
});
});
</script>
<style type="text/css">
#plane ,#boat,#car ,#other {
display: none;
}
</style>
</head>
<body>
options:
<select id='selection'>
<option>Pls choose</option>
<option value='1' id='1'>Car</option>
<option value='2' id='2'>Plane</option>
<option value='3' id='3'>Boat</option>
<option value=''>Other</option>
</select><div>
<div id='car' class='op'>you have chosen a car</div>
<div id='plane' class='op'>you have chosen a plane</div>
<div id='boat' class='op'>you have chosen a boat</div>
<div id='other' class='op'>others</div>
</div>
</body>
</html>
Can someone help me with this one and we would really appreciate it! and
thanks!

Thursday, 19 September 2013

xcode 5 documentation: where is the table of contents for the entire documentation?

xcode 5 documentation: where is the table of contents for the entire
documentation?

There is a table of contents on the right, but it is internal to the
current page.
In the previous version of the documentation you could view the main
titles. See the screenshots in this post: Xcode organizer documentation,
show Table of Contents
Is there a way to show the TOC for the entire documentation installed?
Also is there a way to move the page internal TOC to the left?
Thanks!

C# tricky way to convert char to lowercase - and how do the opposite

C# tricky way to convert char to lowercase - and how do the opposite

In this http://stackoverflow.com/a/25486/142014 answer there is a pice of
code to transform a char to lowercase:
// tricky way to convert to lowercase
sb.Append((char)(c | 32));
What is happening in (char)(c | 32) and how is it possible to do the
opposite to transform to uppercase?

ASP.net Web page error Use of unassigned local variable 'some'

ASP.net Web page error Use of unassigned local variable 'some'

I have razor code like this
bool some;
if (IsPost == false)
{
some = True
}
then html
<h1>@some.ToString()</h1>
and when i run it it get's me error Use of unassigned local variable 'some'
could anyone explain why? doesn't razor code executes first and then html?

how to display the saved db values in other jsp using spring in MultiActionController without annotation instead display on same create...

how to display the saved db values in other jsp using spring in
MultiActionController without annotation instead display on same create...

here is my code it dispaly's saved value in create page only, i want list
should be displayed in another jsp.
just want information what i should change in controller class so that it
goes to another jsp page
Controller Class
package com.vaannila.web;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import com.vaannila.dao.UserDAO;
import com.vaannila.domain.User;
public class UserController extends MultiActionController {
private UserDAO userDAO;
public void setUserDAO(UserDAO userDAO) {
this.userDAO = userDAO;
}
public ModelAndView add(HttpServletRequest request,
HttpServletResponse response, User user) throws Exception {
System.out.println("THIS IS ADD METHOD");
userDAO.saveUser(user);
return new ModelAndView("userForm",,user);
}
public ModelAndView list(HttpServletRequest request,
HttpServletResponse response) throws Exception {
ModelMap modelMap = new ModelMap();
System.out.println("THIS IS LIST METHOD");
modelMap.addAttribute("userList", userDAO.listUser());
modelMap.addAttribute("user", new User());
return new ModelAndView("userForm",modelMap);
}
JSP PAGE(userForm):
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
.even {
background-color: silver;
}
</style>
<title>Registration Page</title>
</head>
<body>
<form:form action="add.htm" commandName="user">
<table>
<tr>
<td>User Name :</td>
<td><form:input path="firstname" /></td>
</tr>
<tr>
<td>Last Name :</td>
<td><form:input path="lastname" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Register"></td>
</tr>
<c:if test="${fn:length(userList) > 0}">
<table cellpadding="5">
<tr class="even">
<th>First Name</th>
<th>Last Name</th>
</tr>
<c:forEach items="${userList}" var="user" varStatus="status">
<tr class="<c:if test="${status.count % 2 == 0}">even</c:if>">
<td>${user.firstname}</td>
<td>${user.lastname}</td>
</tr>
</c:forEach>
</table>
</c:if>
Dispatcher-servlet:
<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
<bean id="myDataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/test"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</bean>
<bean id="mySessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="annotatedClasses">
<list>
<value>com.vaannila.domain.User</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop
key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
<bean id="myUserDAO" class="com.vaannila.dao.UserDAOImpl">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>
<bean name="/user/*.htm" class="com.vaannila.web.UserController" >
<property name="userDAO" ref="myUserDAO" />
</bean>
</beans>
DAOImpl:
package com.vaannila.dao;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;
import com.vaannila.domain.User;
public class UserDAOImpl implements UserDAO {
private HibernateTemplate hibernateTemplate;
public void setSessionFactory(SessionFactory sessionFactory) {
this.hibernateTemplate = new HibernateTemplate(sessionFactory);
}
@Override
public void saveUser(User user) {
hibernateTemplate.saveOrUpdate(user);
}
@Override
@SuppressWarnings("unchecked")
public List<User> listUser() {
return hibernateTemplate.find("from User");
}
}

Can and cannot see pictures in jsp project depending on port

Can and cannot see pictures in jsp project depending on port

I inherited a project from a previous programmer, when I run the code on
the server, there are a list of images that are shown and not shown.
I checked they're path and they have:
http://localhost:8888/images/small/classified/1135/...
in common.
The images for
http://localhost:8080/...
are showing fine, port 8888 doesn't show anything.
Could you please advise me what to check?
here's my properties file
jdbc.driverClassName = org.gjt.mm.mysql.Driver
#jdbc.url = jdbc:mysql://localhost:3306/pets_db
#jdbc.username =root
#jdbc.password =12345
#image.path=http://localhost/images/
#image.itemDirectory=C:/wamp/www/images/
#image.profile=profiles
#image.classified=classified
#domain=localhost.com

jdbc.url = jdbc:mysql://localhost:3306/mypets_db
jdbc.username = root
jdbc.password = 12345
image.path=http://localhost:8888/images/
image.itemDirectory=C
:\wamp\www\images
image.profile=profiles
image.classified=classified
domain=mypets.pk
discussions.url=http://www.mypets.pk/discussions/
forums.registration=http://localdomain.com/forums/
ftp.fileName=public_html/sitemap.xml

ftp.url=mypets.pk
ftp.username=root
ftp.password=
syndication.url = http://localhost:8080/syndication-engine/event.do
url.default = http://www.myPets.pk/pets/
activation.url = http://www.myPets.pk/pets/accountActivation
myclassified.url = http://www.myPets.pk/pets/myClassifieds
mailserver.host=mail.mypets.pk

mailserver.username = support@mypets.pk
mailserver.password = zxcvbn
default.category = 16
brand.other = 2
user.super = 01
# Classified type 2 for Pets
# From classified type we will get whether additional info section be
shown to user
classified.type = 2
classified.restType = 2

Ruby add an integer to a hex value or convert integer to hex

Ruby add an integer to a hex value or convert integer to hex

I am trying to convert an integer to hex in ruby but i am having trouble.
I need it to be in the format \x00 but it seems this is not possible if
you do not set it manually?
count = 5
hex = "\x0#{count}"
puts hex.inspect # "\x005" but i need it to be "\x05"
Thanks!

Update Multiple Row Records

Update Multiple Row Records

First of all, I use PHP Dreamweaver to make a program with phpMyAdmin
Database. This program gets my records in a 1st row blank when I submit
the button, and the remaining records in a rows are still there which is
2nd row and below, but the records in a 1st row is still on the database,
why should it happen? any idea for me to solve this program, it also won't
update my record. this makes me sick, i need help please! tnx...
<?php require_once('Connections/tlsc_conn.php');
mysql_select_db($database_tlsc_conn, $tlsc_conn);
$query_Recordset1 = "SELECT * FROM tbl_name";
$Recordset1 = mysql_query($query_Recordset1, $tlsc_conn) or
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
if(isset($_POST['submit'])) {
$count = count($_POST['id']);
$submit = $_GET['id'];
for($i=0;$i<$count;$i++){
$sql1="UPDATE $tbl_name SET name='$name[$i]',
lastname='$lastname[$i]', email='$email[$i]' WHERE
id='$id[$i]'";
$row_Recordset1=mysql_query($sql1);
}
if($row_Recordset1){
header("location:lulu.php");
exit;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form name="form2" method="post" action="">
<table width="634" border="1">
<tr>
<td>id</td>
<td>name</td>
<td>lastname</td>
<td>email</td>
</tr>
<?php do { ?>
<tr>
<td><?php $id[]=$row_Recordset1['id']; ?><?php echo
$row_Recordset1['id']; ?>
<input name="id[]" type="hidden" value="<?php echo
$row_Recordset1['id']; ?>" />
</td>
<td>
<input name="name[]" type="text" value="<?php echo
$row_Recordset1['name']; ?>">
</td>
<td>
<input name="lastname[]" type="text" value="<?php echo
$row_Recordset1['lastname']; ?>">
</td>
<td>
<input name="email[]" type="text" value="<?php echo
$row_Recordset1['email']; ?>"> </td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<p>
<input type="submit" name="submit" value="Submit" />
</p>
</form>
<p>
</body>
</html>

Wednesday, 18 September 2013

Adding a map function to a vector in C++11

Adding a map function to a vector in C++11

I have a custom vector class that for all intents and purposes acts just
like std::vector. I want to add a simple map function:
template <class T> class Vector
{
public:
template<class mapFunction> Vector<typename mapFunction::result_type>
map(mapFunction function)
{
Vector<mapFunction::result_type> result(_Length);
for(UINT i = 0; i < _Length; i++)
{
result[i] = function(_Data[i]);
}
return result;
}
...
}
Usage:
Vector<int> v(5);
for(int i = 0; i < 5; i++) v[i] = i;
auto mappedVector = v.map(function<double(int)>([](int a) { return a *
2.0; }));
This works but I'm trying to avoid the need for the cast from a lambda
expression to std::function. Ideally it would just be v.map([](int a) {
return a * 2.0; })); I realize that I could probably write a
"make_function" similar to "make_pair" to avoid the need for template
parameters, but you'd still need to cast all your lambdas.
I cast it to a std::function because I don't know how to extract the
return type from a raw lambda type; hence I'm using
std::function::result_type.
I thought the following would work, but it doesn't -- the compiler just
complains that it cannot deduce the template argument for "returnType":
template<class mapFunction, class returnType> Vector<returnType>
Map2(mapFunction function)
{
Vector<returnType> result(_Length);
for(UINT i = 0; i < _Length; i++)
{
result[i] = function(_Data[i]);
}
return result;
}
I realize that std::transform does this (I could easily replace the body
of map with a call to std::transform), but my problem is really with the
right way to specify the template parameters.

How do I place the elements of a list into the middle of another list? A one dimensional battleship game. (Python)

How do I place the elements of a list into the middle of another list? A
one dimensional battleship game. (Python)

So I'm creating this simple little battleship program. I'm getting a
little frustrated at the aspect of a player placing their boats. What I'd
like is for the function ship_place() to take a boat as a parameter, ask
for the index of the array the player would like to place the boat, and
then place the boat in the ocean starting at the specified index. I want
the contents of the boat (which is a list) to be "exported" to the ocean
(which is also a list).
I created this function and it's been giving me two errors. The first is
that for some reason it's placing the entire boat array into the specified
index. The second is that the list taken_spots1 is not receiving all of
the taken spots it should be.
P.S. I originally had for loops within the function but was getting the
same error, so I tried while loops to see if anything would change.
Nothing did.
ocean = ['O']*100
taken_spots1 = []
boat1 = ['<','>'],
boat2 = ['<','=','>'],
boat3 = ['<','::','>'],
boat4 = ['<','@','@','>'], #cannons
boat5 = ['<','G','U','N','>']
ship_yard = [boat1,boat2,boat3,boat4,boat5]
def ship_place(boat):
spot = ""
while spot == "":
spot = input("Place a boat: ")
spot = eval(spot)
if spot in taken_spots1:
spot = ""
print("That spot's already taken, dummy")
else:
j=0
while j < len(boat):
taken_spots1.append(spot + j)
j += 1
i = 0
while i < len(boat):
ocean[spot - 1 + i] = boat[i]
i += 1
for i in range(5):
ship_place(ship_yard[i])
print(ocean)
print(taken_spots1)

C++ Segfault No compile errors can't find cause

C++ Segfault No compile errors can't find cause

Hoping someone can help. I'm able to compile with no error, I'm not
finding any syntax errors but when I run this, it crashes. Debug segfaults
on launch. Full disclosure, this is homework. I'm not asking for someone
to code this, just look at my problem and my existing code and maybe point
me toward what I did that broke this so badly?
Question: You found an exciting summer job for five weeks. It pays, say,
$15.50 per hour. Suppose that the total tax you pay on your summer job
income is 14%. After paying the taxes you spend 10 % of your net income to
buy new clothes and other accessories for the next school year and 1% to
buy school supplies. After buying clothes and school supplies, you use 25%
of the remaining money to buy savings bonds. For each dollar you spend to
buy savings bonds, your parents spend $0.50 to buy additional savings
bonds for you. Write a program that prompts the user to enter the pay rate
for an hour and the number of hours you worked each week. The program then
outputs the following: a. Your income before and after taxes from your
summer job. b. The money you spend on clothes and other accessories. c.
The money you spend on school supplies. d. The money you spend to buy
savings bonds. e. The money your parents spend to buy additional savings
bonds for you.
Code:
// Libraries defined
#include <iomanip>
#include <iostream>
using namespace std;
//Main function
int main ()
{
//Input variables
double hourlyrate;
double hweek1;
double hweek2;
double hweek3;
double hweek4;
double hweek5;
//Output variables
double beforetax;
double netincome;
double clothmoney;
double suppliesmoney;
double moneyonbonds;
double additionalbonds;
double remain;
//This statement takes care of the decimal places
cout << fixed << showpoint << setprecision(2);
//Input from user
cout << "Enter your hourly rate: " << hourlyrate;
cin >> hourlyrate;
cout << "Week 1: " << hweek1;
cin >> hweek1;
cout << "Week 2: " << hweek2;
cin >> hweek2;
cout << "Week 3: " << hweek3;
cin >> hweek3;
cout << "Week 4: " << hweek4;
cin >> hweek4;
cout << "Week 5: " << hweek5;
cin >> hweek5;
//Mathematics
beforetax = hourlyrate * (hweek1 + hweek2 + hweek3 + hweek4+
hweek5) ;
netincome = beforetax - beforetax * 0.14;
clothmoney = netincome * 0.1;
suppliesmoney = netincome * 0.01;
remain = netincome - clothmoney - suppliesmoney;
moneyonbonds = remain * 0.25;
additionalbonds = static_cast<double>(moneyonbonds) * .50;
//Output to user
cout << endl << "Income before tax = $" << beforetax << endl
<< "Net income = $" << netincome << endl << "Money for
clothes/accesories = $"
<< clothmoney << endl << "Money for supplies = $"<< suppliesmoney << endl
<< "Money for saving bonds = $" << moneyonbonds << endl
<< "Additional saving bonds money = $" << additionalbonds;
return 0;
}

Links don't work on iPad for the dragend JS framework

Links don't work on iPad for the dragend JS framework

I know this is really stupid question, but have someone used dragend JS
for websites to be used in iPad?
I have worked on the site and now stuck on a problem that no link is
working in iPad on my site. On normal desktop computers, it works.
When I went to the official site, to my surprise, the links also don't
work there too ... You can test this site
http://stereobit.github.io/dragend/ on your iPad.
I'll be very thankful for any assistance as I've been literally using
different scenarios but to no avail.
Many Thanks

How to write regex in JAVA for extracting comments

How to write regex in JAVA for extracting comments

I have a comment coming in as follows
//= abcd .
Now I need to extract abcd . ANy idea? I have written the following
//\\=.*?\\s{2}
in java :)
But it does not work.
Any idea? There is a whitespace between = and after letter d.

Rails 4: coffeescript only works when there is a post request or when i reload the page

Rails 4: coffeescript only works when there is a post request or when i
reload the page

i am mostly a backend developper and am not so skilled in javascript
related stuff (and all the galaxy of frameworks that exists on the place).
I know that's bad but it is what it is.
i'm becoming crazy about the issue I have and i'm probably missing
something very basic. i made some researches (Google + the stack overflow
bible) and didn't find any case similar to the issue I have. i suppose i
just don't know what I'm doing. let me explain.
What's happening
I am using Rails 4 for a small (useless) project and I try to write some
javascript "code" in the coffeescript files.
apparently, the coffeescript "code" i wrote only works when I reload a
page, or after a POST request (when you submit a form for example). On GET
requests, during navigation from page to page for example, nothing is
happening.
I tried with a very simple basic elementary 101 test: displaying an alert
message (Hello!) on a page (It started by including a date picker).
let's say i have an Article model and an associated ArticlesController to
edit/create/delete data. I have the following files :
app/assets/javascripts/application.js
app/assets/javascripts/articles.js.coffeee
app/controllers/articles_controller.rb
app/models/article.rb
app/views/articles/new.html.erb
app/views/articles/index.html.erb
etc.
I am just adding one line in app/assets/javascripts/articles.js.coffee :
alert "Hello!"
If I submit a form or I reload a page, I see the alert "Hello!". If I just
click on a link, to edit an article for example, nothing is happening.
The logs
When I look at the rails logs in the two cases, I have two different
scenarios:
In the "it's not working" case, when I do a simple get request (by
clicking on the edit link), I have this in the logs :
Started GET "/articles/1/edit" for 127.0.0.1 at 2013-09-17 14:35:28 -0400
Processing by ArticlesController#edit as HTML
Parameters: {"id"=>"1"}
Author Load (0.3ms) SELECT "authors".* FROM "authors" WHERE
"authors"."remember_token" = 'ab6fa1c5257585de99459c60f24121c' LIMIT 1
Article Load (0.2ms) SELECT "articles".* FROM "articles" WHERE
"articles"."author_id" = ? AND "articles"."id" = 1 ORDER BY published_at
DESC LIMIT 1 [["author_id", 1]]
Rendered shared/_error_messages.html.erb (0.1ms)
Rendered articles/edit.html.erb within layouts/application (6.6ms)
Rendered layouts/_shim.html.erb (0.1ms)
Rendered layouts/_header.html.erb (0.6ms)
Rendered layouts/_footer.html.erb (0.1ms)
Completed 200 OK in 44ms (Views: 40.4ms | ActiveRecord: 0.4ms)
In the "it does work" case, when I reload the same edit page for example,
it reloads everything..
Started GET "/articles/1/edit" for 127.0.0.1 at 2013-09-17 14:37:28 -0400
Processing by ArticlesController#edit as HTML
Parameters: {"id"=>"1"}
Author Load (0.3ms) SELECT "authors".* FROM "authors" WHERE
"authors"."remember_token" = 'ab6fa1c5257585de99459c60f24121c' LIMIT 1
Article Load (0.1ms) SELECT "articles".* FROM "articles" WHERE
"articles"."author_id" = ? AND "articles"."id" = 1 ORDER BY published_at
DESC LIMIT 1 [["author_id", 1]]
Rendered shared/_error_messages.html.erb (0.1ms)
Rendered articles/edit.html.erb within layouts/application (5.0ms)
Rendered layouts/_shim.html.erb (0.1ms)
Rendered layouts/_header.html.erb (0.4ms)
Rendered layouts/_footer.html.erb (0.1ms)
Completed 200 OK in 26ms (Views: 23.4ms | ActiveRecord: 0.4ms)
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2013-09-17
14:37:28 -0400
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2013-09-17
14:37:28 -0400
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2013-09-17
14:37:28 -0400
Started GET "/assets/articles.css?body=1" for 127.0.0.1 at 2013-09-17
14:37:28 -0400
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2013-09-17
14:37:28 -0400
Started GET "/assets/articles.js?body=1" for 127.0.0.1 at 2013-09-17
14:37:28 -0400
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2013-09-17
14:37:28 -0400
Started GET "/assets/turbolinks.js?body=1" for 127.0.0.1 at 2013-09-17
14:37:28 -0400
(i removed some of the lines to make it clearer)
What I tried
I tried to generate the js files with
rake assets:precompile
but it was the same.
I tried to install some gems like therubyracer, barista, it was the same.
Am I missing something very basic? Should I read a book about the bases of
javascript? Should I be deported in Alaska for not understanding something
very easy ? Should I retire or change job ?
Thanks for the help. I am sinking into depression.

System calls - Opensuse

System calls - Opensuse

My initial attempts to build a system call with the help of this question
My distro information: Linux linux-epq2.site 3.7.10-1.16-default #1 SMP
Fri May 31 20:21:23 UTC 2013 (97c14ba) x86_64 x86_64 x86_64 GNU/Linux
In the current version of my program, that will allow me to embed this as
a system call does have a main (stupidity to even say that, but just to
make things more explicit).
In my current program:
It takes in two inputs from the user, and does some calculations and gives
the output as the graph and some data.
My initial attempt was to call that program via execlp available in unistd
library like this:
#include<linux/linkage.h>
#include<linux/kernel.h>
#include<unistd.h>
asmlinkage long graph(const char* granularity, char* application)
{
pid_t child;
child = fork();
if (!child) {
execlp("./system-call", granularity, application, NULL);
}
sleep(0.2);
return 0;
}
But when I am trying to compile the kernel (note: same kernel version) and
the old config file (if necessary i'll also upload the config file). I get
the following error:
linux-3.7.10 % make
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `relocs'.
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
make[3]: `arch/x86/realmode/rm/realmode.bin' is up to date.
CHK kernel/config_data.h
CC test/graph.o
test/graph.c:10:19: fatal error: unistd.h: No such file or directory
compilation terminated.
make[1]: *** [test/graph.o] Error 1
make: *** [test] Error 2
make 4.50s user 1.27s system 75% cpu 7.626 total`
I checked if glibc was installed or no, i see that all the kernel header
files ARE available.
zypper search glibc
Loading repository data...
Reading installed packages...
S | Name | Summary
| Type
--+--------------------------+-------------------------------------------------------+--------
i | glibc | Standard Shared Libraries (from the GNU C
Library) | package
i | glibc-32bit | Standard Shared Libraries (from the GNU C
Library) | package
i | glibc-devel | Include Files and Libraries Mandatory for
Development | package
i | glibc-devel-32bit | Include Files and Libraries Mandatory for
Development | package
i | glibc-devel-static | C library static libraries for -static
linking | package
i | glibc-devel-static-32bit | C library static libraries for -static
linking | package
i | glibc-extra | Extra binaries from GNU C Library
| package
i | glibc-info | Info Files for the GNU C Library
| package
i | glibc-locale | Locale Data for Localized Programs
| package
i | glibc-locale-32bit | Locale Data for Localized Programs
| package
i | glibc-utils | Development utilities from GNU C library
| package
i | linux-glibc-devel | Linux headers for userspace development
| package
I checked to see if it is availble in the new kernel dump, and it is not
available.
IS IT safe to copy unistd.h from /usr/include/unistd.h to the new kernel
dump which I want to compile?
OR is there another way around it?

scalatra squeryl select where parameter type missing

scalatra squeryl select where parameter type missing

I am a Scalatra beginner and I have the following route:
get("/todos") {
contentType = formats("json")
val userid : Int = params.getOrElse("userid", halt(400)).toInt
val limit : Int = params.getOrElse("limit", "0").toInt
val offset : Int = params.getOrElse("offset", "0").toInt
if(limit != 0 && offset != 0)
from(TodoDb.todos)(todo => where(todo => todo.userid == userid)
select(todo)).toList
else {
from(TodoDb.todos)(todo => where(todo => todo.userid == userid)
select(todo) orderBy(todo.modified)).page(offset, limit).toList
}
}
I can't compile it, I got the following error messages:
[info] Compiling 1 Scala source to
/home/coelho/www/p.zomg.hu/gfmwa-todo-app/target/scala-2.10/classes...
[error]
/home/coelho/www/app/src/main/scala/hu/gfmwa/todoapp/TodoScalatraServlet.scala:25:
missing parameter type
[error] from(TodoDb.todos)(todo => where(todo => todo.userid ==
userid) select(todo)).toList
[error] ^
[error]
/home/coelho/www/app/src/main/scala/hu/gfmwa/todoapp/TodoScalatraServlet.scala:27:
missing parameter type
[error] from(TodoDb.todos)(todo => where(todo => todo.userid ==
userid) select(todo) orderBy(todo.modified)).page(offset, limit).toList
[error] ^
[error] two errors found
[error] (compile:compile) Compilation failed
I learn from here: http://squeryl.org/selects.html and here:
http://squeryl.org/pagination.html
I can't see parameter type information on these pages, I can't figure out,
what can be the problem. What I am doing wrong?

Creating RelayCommand without implementing ICommand

Creating RelayCommand without implementing ICommand

My query is how can I create a class behaving same as RelayCommand but
without implementing ICommand for my MVVM application? Any suggestions are
much appreciated.
My RelayCommand [which implements ICommand] is as below:
public class RelayCommand:ICommand
{
private readonly Action<object> m_Execute;
private readonly Predicate<object> m_CanExecute;
public RelayCommand(Action<object> exec) : this(exec, null) { }
public RelayCommand(Action<object> exec, Predicate<object> canExec)
{
if (exec == null)
throw new ArgumentNullException("exec");
m_Execute = exec;
m_CanExecute = canExec;
}
#region ICommand Members
public bool CanExecute(object parameter)
{
if (parameter == null)
return true;
else
return m_CanExecute(parameter);
}
public event EventHandler CanExecuteChanged
{
add
{
if (m_CanExecute != null)
CommandManager.RequerySuggested += value;
}
remove
{
if (m_CanExecute != null)
CommandManager.RequerySuggested -= value;
}
}
public void Execute(object parameter)
{
m_Execute(parameter);
}

Tuesday, 17 September 2013

What is the need of rowKey attribute in primefaces datatable?

What is the need of rowKey attribute in primefaces datatable?

I am new to primefaces. i tried to select rows in datatable, it shows
error, then i added rowkey attribute to datatable, error rectified. can
any one tell what is the actual use of rowkey attribute

Google Maps not shown in android

Google Maps not shown in android

i am using Google maps in my sample android project but it just displays
titles nothing else no maps are been display ,i have followed lynda
tutorials , Map key is also generated using google map emulator and tested
on real deceive as well still they does not work . Here is the code below
.please help
Layout file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<com.google.android.maps.MapView
android:id="@+id/map"
android:clickable="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="MyMApKey" />
</RelativeLayout>
Map Activity :
package com.example.maptest;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.Menu;
public class MainActivity extends MapActivity {
LocationListener listener ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MapView view = (MapView) findViewById(R.id.map);
view.setBuiltInZoomControls(true);
final MapController control = view.getController();
final LocationManager manager = (LocationManager) this
.getSystemService(Context.LOCATION_SERVICE);
listener = new LocationListener() {
@Override
public void onStatusChanged(String provider, int status,
Bundle extras) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
control.setCenter(new
GeoPoint((int)location.getLatitude(),
(int)location.getLongitude()));
manager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
0,0,listener);
}
};
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.maptest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="14" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name="com.example.maptest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Here is output

Why is declaration of class in file included in separate function clashing with include in other function? (example code included)

Why is declaration of class in file included in separate function clashing
with include in other function? (example code included)

My understanding of including a file in a function was that it stays
within that function scope:
If the include occurs inside a function within the calling file, then all
of the code contained in the called file will behave as though it had been
defined inside that function. So, it will follow the variable scope of
that function.
But when I do this, the second one clashes with the first and tells me the
class is already declared!
Run this php page to see the errors (you'll need all three PHP pages)
<?php
class TestOnce
{
function __construct()
{
$this->includeOnce();
}
function includeOnce()
{
//This should include it once
include_once "once.php";
var_dump( $once );
}
function includeSomethingThatIncludesOnce()
{
include_once "includeonce.php";
var_dump( $once );
}
}
$test = new TestOnce();
$test->includeSomethingThatIncludesOnce();
?>
This also inlcudes once, but is told it's already included which it
shouldn't be in that function/
<?php
//This should include it once
include "once.php";
var_dump( $once );
?>
This is "once" which declares the class and an instance variable
<?php
class Once
{
}
$once = new Once();
?>
Why aren't the includes restricted to the scope of the function? How would
I achieve that?

How to write services with $q and $http calls without being repetitive

How to write services with $q and $http calls without being repetitive

I'm trying to figure out an elegant way to write AngularJS services
without being so repetitive with the $q syntax.
Currently, I'm writing services like follows:
(function() {
function ServiceFactory($q, $timeout, $http) {
return {
getFoo: function() {
var deferred = $q.defer();
$timeout(function() {
$http.get('/the/foo/thing').then(function(response) {
if (response.isError) {
deferred.reject();
} else {
deferred.resolve(response.data.foo);
}
}, function() {
deferred.reject();
});
});
return deferred.promise;
}
};
}
angular.module('myapp').service('MyService', ['$q', '$timeout',
'$http', ServiceFactory]);
}.call(this));
It works very well, buy I'm always writing down a bunch of code just to
delay $http.get and expose a Promise. Sometimes I will have some extra
stuff into success callback, like handling data, creating a different
response object... But most of the time, is just like the code above: call
$q.defer + $http.get().then... + return promise
So, I'm thinking about a way to clean up/reduce the code without affecting
the clarity of what I'm doing, e.g if another developer open the file, it
should not be a mystery.
As a side note, the $http service here is actually a decorator, handling
server responses to give me a more structured object with things like
response.isError and response.data.
Also, I have seen a similar solution in another question {1}, but this is
not as same. Just returning the response of $http.get().then() will expose
the entire response to controllers on response, and it is not the desired
effect. Instead, when I call MyService.getFoo().then(...), I'm expecting a
foo object as a response from service, fed by server via
response.data.foo, or a call to errorCallback.
{1} Similar question

How can I use regular expressions in Textpad to remove anything, line by line, after specified characters?

How can I use regular expressions in Textpad to remove anything, line by
line, after specified characters?

Suppose I have the following text in Textpad:
kwejkewrjl:ksajdlakj
e833ekjh:skdjkahak
2098e123809:ksjdkas
dkjwhfdkjqhio:skjddksjal
98a09asfdsaok:kwqjeo912ui
I would like to remove all characters from each line that occur after the
colon. The new text should be:
kwejkewrjl:
e833ekjh:
2098e123809:
dkjwhfdkjqhio:
98a09asfdsaok:

Can't update DOUBLE field in SQL database, getting rounded

Can't update DOUBLE field in SQL database, getting rounded

Every time a user rates someone else, all of the ratings for that person
get averaged, and the average gets stored in the database as a DOUBLE. The
problem is, the rating appears to be rounded down after updating.
$totalavg = (float)((float)$ratingtotal/(float)$numratings);
echo $totalavg;
queryDB("UPDATE rated_users
SET user_avg='$totalavg'
WHERE user_name='$rated';");
I have 3 ratings for the test user I'm working on, a 5.0 and two 4.5s.
However, it appears to be forced on 5, despite the fact that it should be
a 4.667. Can anyone offer their assistance?
EDIT: Length/Values of user_avg is 10,0

Sunday, 15 September 2013

Can i blur the object (or texture, screen)

Can i blur the object (or texture, screen)

Can i blur the object (or texture, screen) in three.js? I want to make the
movement effect, like when you inside a moving car and surroundings is
moving and blurred.

Java object returning zeros for calculated variables

Java object returning zeros for calculated variables

this is my first question here and I'm very new to programming so please
bear with me.
I'm taking a java class, and in my current assignment I have to create
three instances of a circle, compute their diameters and areas, and print
the values. The first two instances are supposed to have the radius set by
a setRadius method, while the third is supposed to retain the default
calculations based on a radius of 1.
Here is the code, thanks in advance!
//this class implements the Circle class
public class TestCircle
{
public static void main(String[] args)
{
Circle Circle1 = new Circle();
Circle Circle2 = new Circle();
Circle Circle3 = new Circle();
Circle1.setRadius(2);
Circle2.setRadius(10);
Circle1.display();
Circle2.display();
Circle3.display();
}
}
import java.lang.Math.*;
public class Circle
{
double radius;
double diameter;
double area;
public void Circle()
{
radius = 1;
diameter = radius * 2;
area = (radius * radius) * Math.PI;
}
public void setRadius(double rad)
{
this.radius = rad;
diameter = radius * 2;
area = (radius * radius) * Math.PI;
}
public void display()
{
System.out.println("Radius: " + radius);
System.out.println("Diameter: " + diameter);
System.out.println("Area: " + area);
}
}

Linkedin Share button not including image

Linkedin Share button not including image

I have the linkedin share button on my site and its not including the
image when clicking the share button (facebook share IS including the
image).
I know you're supposed to use <meta property="og:image" which is currently
setup but linkedin not recognizing..
Any ideas? Thanks!!
http://stackstreet.com

Should I compile coffeescript files to js before using in production?

Should I compile coffeescript files to js before using in production?

When deploying coffeescript code, is there any benefit to using coffee
--compile, compiling it to js and then running with node, instead of using
coffee directly?

Finding the mean of the log-normal distribution in survival analysis in R

Finding the mean of the log-normal distribution in survival analysis in R

I am a novice with R. Currently I am fitting a log-normal distribution to
some survival data I have, however I have become stuck when trying to
calculate statistics such as the median and the mean. This is the code I
have used so far, can anyone tell me what I should type next to find the
mean?
rm(list=ls(all=TRUE)) library(survival)
data<-read.table("M:\w2k\Diss\Hoyle And Henley True IPD with number at
risk known.txt",header=T) attach(data) data times_start <-c(
rep(start_time_censor, n_censors), rep(start_time_event, n_events) )
times_end <-c( rep(end_time_censor, n_censors), rep(end_time_event,
n_events) ) model <- survreg(Surv(times_start, times_end,
type="interval2")~1, dist="lognormal") intercept <-
summary(model)$table[1]
log_scale <- summary(model)$table[2]
this is where I got stuck, I have tried:
meantime<-exp(intercept+log_scale/2)
but this does not seem to give a realistic mean
Thanks for any help!

Activity not opening up in android

Activity not opening up in android

I have just started with android app development So i made an app in
eclipse with android 10 as base (gingerbread) Then i edited my main
activity (main.java) to show up a menu with two options A)settings B)about
Then i created a resource at /res/xml/settings.xml and then made
Prefs.java which uses addPreferencesFromResource() method..
But when i click on settings , i dont see anything.. I have also defined
the activity in Android manifest of my app..
Here is my code : //Prefs.java
package com.mhrsolanki2020.thecaller;
import android.preference.PreferenceActivity;
import android.os.Bundle;
public class Prefs extends PreferenceActivity {
protected void onCreate(Bundle savedInstance)
{
super.onCreate(savedInstance);
addPreferencesFromResource(R.xml.settings);
}
}
//Main.java
package com.mhrsolanki2020.thecaller;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuInflater;
public class Main extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return true;
}
public boolean onOptionsItemSecelted(MenuItem item){
switch(item.getItemId()){
case R.id.action_settings:
startActivity(new Intent(this,Prefs.class));
return true;
}
return false;
}
}
//Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mhrsolanki2020.thecaller"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="10" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.mhrsolanki2020.thecaller.Main"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.mhrsolanki2020.thecaller.Prefs"
android:label="@string/prefs_label"> </activity> </application>
</manifest>
// /res/xml/settings.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:defaultValue="true"
android:title="@string/activation"
android:summary="@string/activatoinSummary"/>
</PreferenceScreen>
// /menu/main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"/>
<item
android:id="@+id/action_about"
android:orderInCategory="101"
android:title="@string/action_about"/>
</menu>

Update actions from on sql table to another using Message Broker

Update actions from on sql table to another using Message Broker

i wanna use Wepshoere Message Broker to get the actions that any user
perform on any table to be applied on another table
Example 1- User insert a record on Table x in TestDB 2- Message broker
take this newly added record and add it to Table y in TestDB
could you support me with detailed information. and thanks in advance

Saturday, 14 September 2013

Will saving innerhtml allow to save all elements on page

Will saving innerhtml allow to save all elements on page

I need to save a web page the content of which changes dynamically. For
example, a user can add custom functions and they are added to the custom
functions drop down list. I would like to save the "newly" updated page
using PHP and AJAX. I tried getting the innerHTML of all the elements by
wrapping them in a "main-body" div. When I display the result with the
alert box, all the data seems to be captured. But when I post the data to
my savedata.php file using the POST AJAX method the data is not saved.
Only the first few lines of the data is saved.
The new options in the select boxes and the content of the textarea are
not saved either. However, if I individually try to save the textarea and
select box data using .value instead of innerHTML that works.
My question in a nutshell, is why doesn't the innerHTML data get saved
despite the fact that the alert box shows all the data when I use
documentGetById("main-body").innerHTML to get all the contents of my page.
Here is some code
Javascript and AJAX Code
function savehtml()
{
//Make ajax call after setting up variables
var saveme=document.getElementById('txtArea').innerHTML
var filename = document.getElementById('nameoff').value
var parameters="saveme="+saveme+"&filename="+filename
ajaxr('savedata.php', "result", parameters)
}
function ajaxRequest(){
var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]
if (window.ActiveXObject){
for (var i=0; i<activexmodes.length; i++){
try{
return new ActiveXObject(activexmodes[i])
}
catch(e){
//suppress error
}
}
}
else if (window.XMLHttpRequest) // if Mozilla, Safari etc
return new XMLHttpRequest()
else
return false
}
function ajaxr(phpfilename, idofinnerhtml, parameters)
{
var mygetrequest=new ajaxRequest()
mygetrequest.onreadystatechange=function(){
if (mygetrequest.readyState==4){
if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
alert(parameters)
document.getElementById(idofinnerhtml).innerHTML="Result:
"+mygetrequest.responseText
/*document.getElementById("catbody").value="Result :
"+mygetrequest.responseText*/
}
else{
document.getElementById(idofinnerhtml).innerHTML="Result: Failed "
}
}
}
mygetrequest.open("POST", phpfilename, true)
mygetrequest.setRequestHeader("Content-type",
"application/x-www-form-urlencoded")
mygetrequest.send(parameters)
}
HTML Code
<body>
<div id="main-body">
<table>
<tr>
<td>
<textarea id="txtArea" name="txtArea" rows="10" cols="100"><?
?></textarea><br><br>
</td>
<h2>Quick tools</h2>
<button onclick="addsigns();">Add a sign</button><br>
<input type="radio" id="andsign" name="whichsign" value="&&">&&
<input type="radio" id="orsign" name="whichsign" value="||">||
<input type="radio" id="notsign" name="whichsign" value="!">!
....
Php Code
$data=$_POST['saveme'];
$filename=$_POST['filename'];
echo $data;
$handle = fopen($filename, 'w+');
flock($handle, LOCK_EX);
fwrite($handle, $data);
flock($handle, LOCK_EX);
fclose($handle);

Sort NSNumber with NSSortDescriptor

Sort NSNumber with NSSortDescriptor

I have a Route as my top level Core Data entity. Then a Route has
Locations. The Locations have a
@property (nonatomic, retain) NSNumber *index;
I need the index because I need to make sure the user's route is in order.
I was wondering how I can best sort on the Locations entity. In my
tableView, I show the name of the Route. Then when the user clicks on the
Route, I show the Locations. I saw NSSet has
sortedArrayUsingDescriptors
but I wasn't aware of how I could sort NSNumber with a sortDescriptor. I
have seen people just use code like
sortedArrayUsingSelector:@selector(compare:) // or something like that
I can write a simple convenience method to iterate through the NSSet and
return the Location objects by their index, but wasn't sure if there was a
better way. Thanks in advance!

Access: Entering multiple subform values with one entry in the form

Access: Entering multiple subform values with one entry in the form

I've been using Access to create simple databases for a while with great
success, but have run into a problem I can't find an answer to.
We ship individualized serialized units to various end-users, and
occasionally to resellers that stock them for end-users. I must keep track
of which serial numbers end up with each end-users.
The first database I created to handle this recorded company information
in one table using their account number as primary key, order information
in a second table using the order number as the primary key and linked via
the company name, and unit information in a third table with the serial
number as the primary key and linked via the order number.
This worked very well until I had to account for these stock orders with a
reseller. As it was structured, every unit was linked to one company via
the sales order. The issue is that I may ship 20 units on one order to
Company A, who then sells 5 to Company B and 3 to Company C.
I realized I needed to link the company name directly to the units, not
the orders and have fixed that.
My issue now is simplicity in entering information in the form. My
previous database involved the employee in our shipping department merely
entering the sales order, selecting the customer name from a drop down
menu, then scanning the serial numbers in a subform. This was to ensure
simplicity and try to eliminate human error. He had only three things to
input, and most of the input was done by scanning barcodes.
As it is currently structured now, the employees out in shipping would
have to populate the company name for every record in the subform with the
serial number and that complicates things in a way that is unacceptable.
At the point of shipping, the company name will always be the same for
every unit in the subform.
So.
How would I go about creating a form where the company name is entered
once in the form, and automatically populates itself for every record in
the subform? The caveat here is that I must also be able to go back
occasionally and change the company name of individual units in an order
without necessarily affecting the rest of the order. I suppose it starts
out as a one-to-many relationship that then must be able to change.
I hope that makes sense.
I have looked for answers using various approaches with auto-fill and
relationships and not preserving data integrity, but I feel the answer is
just beyond my reach.
The only solution I can think of is to create another field in the unit
table for the end-user, and perhaps write a formula that sets this default
value as the company name from the order that shipped it. This seems
unnecessarily complicated and redundant, there has to be a better way.

function gets undefined with jquery widget factory plugin

function gets undefined with jquery widget factory plugin

Im creating an plugin using jquery widget factory an i'm stuck on a
function that seems to be undefined.
(function ($, undefined) {
$.widget("cms.treeview", {
options: {
url: ""
},
_create: function () {
//--- Requesting data
this._requestData(this.options.url);
},
_requestData: function (url) {
$.ajax({
url: url,
dataType: "json",
contentType: "application/json charset=utf-8",
success: this._requestReady
});
},
_requestReady: function (data) {
//--- Create the treeview root nodes
this._createTree(data, null, this.element);
// ERROR : TypeError: this._createTree is not a function
},
//--- create root tree
_createTree: function (nodes, parentId, container) {
// . . .
}
});
})(jQuery);
It might be something easy just can get this to work, can someon help with
this?
/Martin

Decoding the error from an api duplicate status update?

Decoding the error from an api duplicate status update?

I'm having a problem with processing the error caught when posting a
duplicate status...
try {
$twitter->post_statusesUpdate(array('status' => $tweet));
} catch (EpiTwitterForbiddenException $e) {
$msg = json_decode($e->getMessage());
//wp_die('Error: ' . $msg . ''); // Server errors out
wp_die('Error: ' . $e . ''); // Returns code in lower segment
if ($msg->error != 'Status is a duplicate.') {
//throw $e; // Disabled to prevent
}
}
The first wp_die errors out and the server crashes The second wp_die returns:
Exception 'EpiTwitterForbiddenException' with message
'{"errors":[{"code":187,"message":"Status is a duplicate"}]}' in
/home5/site/public_html/wp-content/plugins/download/libs/api/EpiTwitter.php:265
Stack trace: #0
/home5/site/public_html/wp-content/plugins/download/libs/api/EpiTwitter.php(226):
EpiTwitterException::raise(Object(EpiCurlManager), false) #1
/home5/site/public_html/wp-content/plugins/download/libs/api/EpiTwitter.php(127):
EpiTwitterJson->__get('response') #2
/home5/site/public_html/wp-content/plugins/download/libs/api/EpiTwitter.php(109):
EpiTwitter->request('POST', '/statuses/updat...', Array) #3
/home5/site/public_html/wp-content/plugins/download/download.php(109):
EpiTwitter->__call('post_statusesUp...', Array) #4
/home5/site/public_html/wp-content/plugins/download/download.php(109):
EpiTwitter->post_statusesUpdate(Array) #5 {main}
How am I supposed to decode that to get the error from within it?

How to pass a function and a list of its vector arguments?

How to pass a function and a list of its vector arguments?

I'm trying to write a function in R that will take as arguments, a second
function and its arguments, some of which are vectors. The ultimate result
I want is to write a rolling function that calls a function to act on a
time series, but I've tried all permutations of "apply" functions I can
think of with no success, since "apply" functions all seem to apply a
function to a vector element by element and what I want is to apply
functions to vectors as a whole. For example,
a = c(1,2,3); b = c(4,5,6)
sapply(a,function(x,y,c) c*t(x)%*%y,b,c=2)
[,1] [,2] [,3]
[1,] 8 16 24
[2,] 10 20 30
[3,] 12 24 36
but what I really want is:
2*t(a)%*%b
[,1]
[1,] 64
and be able to roll the function along a time series. I've also tried
writing a generic function that contains a second function and its
parameters as arguments, but I can't seem to get it to accept the
parameters. For example,
foo <- function(func,parm){
return(func(parm))
}
foo(function(x,y,c) c*t(x)%*%y,parm=list(a,b,c=2))
Error in c * t(x) %*% y : 'c' is missing
The problem here is that func won't accept a list of arguments, but how
does one pass a list of arguments to a function? Hope this isn't too
confusing. Thanks for any help offered.

Javascript and Garbage collection

Javascript and Garbage collection

Is there any way to control when Javascript performs garbage collection? I
would like to enable it to perform garbage collection at certain times to
ensure the smooth operation of my web site

Friday, 13 September 2013

video set to "true" in Skype video chat URI, but video is not enabled when call starts

video set to "true" in Skype video chat URI, but video is not enabled when
call starts

I'm using the Skype API from their site: skype apir/uri for video call
which saiys the following URI "Calls other people on Skype, and
automatically turns on the call originator's video":
skype:skypeUserName?call&video=true
when I start the intent, it places the call successfully, but the video is
NOT enabled, on either phone by default.
One suspicion I have is maybe everything after the question mark is
getting stripped. this is how I pass it in:
static String skypeURI = "skype:stablesentryremote?call&video=true";
public void initiateSkypeUri(Context myContext, String mySkypeUri) {
// Create the Intent from our Skype URI
Uri skypeUri = Uri.parse(mySkypeUri);
Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);
}
But this could just be a skype bug.

Where can I download the include file Everything.h and Environment.h for Microsoft?

Where can I download the include file Everything.h and Environment.h for
Microsoft?

I'm trying to follow the book "Windows System Programming" and the code
examples includes "Everything.h" and "Environment.h". The only problem is,
it doesn't show up in when I try to include theses headers.

Double for loop not working in Java

Double for loop not working in Java

import java.io.File;
import java.util.Scanner;
public class LongestCommonSubsequence {
public static void main(String []args){
Scanner input=null;
String x=null;
String y=null;
int M;
int N;
int [] x_marker;
int [][] lcs;
try{
input=new Scanner(new File(args[0]));
while(input.hasNext()){
String[] strs= input.nextLine().split(";");
x=strs[0];
y=strs[1];
M=x.length();
N=y.length();
x_marker=new int[M];
lcs=new int[M+1][N+1];
/*Initialize the first row and col of lcs matrix*/
for(int i=0;i<=M;i++)lcs[i][0]=0;
for(int i=0;i<=N;i++)lcs[0][i]=0;
System.out.println("M "+M);
System.out.println("N "+N);
for(i=1;i<=M;i++){
for(int j=1;j<=N;j++){
if(x.charAt(i)==y.charAt(j)){
x_marker[i]=1;
lcs[i][j]=1+lcs[i-1][j-1];
}else {
int l=lcs[i-1][j];
int r=lcs[i][j-1];
if(l<r)lcs[i][j]=r;
else lcs[i][j]=l;
}
}
}
System.out.println("Length of LCS is "+lcs[M][N]);
}
}catch(Exception e){
}
}
}
This is the code for finding Longest common subsequence. Strings are read
from input file. Two strings per line seperated by ";" The outer for loop
executes only once, though i and M are correct.