Monday, 30 September 2013

Why is the Atomic Blimp not showing up=?iso-8859-1?Q?=3F_=96_gaming.stackexchange.com?=

Why is the Atomic Blimp not showing up? – gaming.stackexchange.com

When you download the Atomic Blimp DLC, a blimp icon appears at the
Vinewood Racetrack and a new contact is added to your phone, "Blimp". I
know I can get to the Blimp by simply accessing the ...

Webapps on Chrome - not Chromium - with Ubuntu 13.04

Webapps on Chrome - not Chromium - with Ubuntu 13.04

I've been trying to find some info on this, but I only got very confusing
or old pages. I simply would like to know if I can use the webapps on my
Chrome (version 29.0.1547.76) with Ubuntu 13.04

Strange issue with HTML / CSS causing extra space

Strange issue with HTML / CSS causing extra space

I have a problem with some unexplained space at the bottom of a page that
I am working on. I have tried to fix the issue but I can't figure out what
is causing it...
A screenshot of the problem is here: http://bit.ly/18FQ9Ca
A link to the real page is here: http://bit.ly/18FR1qA
I think it might be something to do with the id="CivilService" div layer,
as the problem goes away when I remove the div. But there doesn't seem to
be anything contained which could cause the problem.
Many thanks for any help that you can give...

PHP include a fallback to variable value

PHP include a fallback to variable value

In my PHP file I have a variable called mynumber as shown below.
$mynumber = "SELECT id FROM myTbl WHERE date >= CURDATE() LIMIT 1";
This works fine as mynumber unless I have no date field that is >= than
the curdate. I want to do something like
$mynumber = "SELECT ..." || 1
Currently I am doing.
$mynumberSelect = "SELECT id FROM myTbl WHERE matchdate >= CURDATE()
LIMIT 1";
if(empty($mynumberSelect)) {
$mynumber = "SELECT id FROM myTbl WHERE matchdate >= CURDATE() LIMIT 1";
}
else {
$mynumber = "SELECT id FROM myTbl ORDER BY id DESC LIMIT 1";
}
Which is working, but I thought there might be a better way to acheive this?

Sunday, 29 September 2013

how to work on JList

how to work on JList

I want to add files in JList and when user selects the file and clicks
open then he should be able to open that selected.
I am trying to code this, will I be able to only display the path of the
file in the list? So that when user clicks then we get that path where
user clicked and open the file.
If so then, is it possible to list only the filename and not its paths so
that even then when user clicks on that file name he should be able to
open it.
If its possible just tell me how to do it na.. I don't want coding i just
need a practical idea on this..i am coding all this using java..

sorting using vectors c++

sorting using vectors c++

Hello everyone i'm writing a program of a stock market where i read from a
file and sort with symbols and percent gain/loss. I have completed sorting
with symbols but having trouble establishing the percent gain loss. First
i designed and implemented the stock object. call the class stockType.
main components of a stock are the stock symbol, stock price and number of
shares. Second we have to create a list of stock objects. call the class
to implement a list of stock objects stockListType. To store the list of
stocks, i declared a vector and called the component type of this vector
stockType.
Because the company requires me to produce the list ordered by percent
gain/loss, i need to sort the stock list by this component. However, i'm
not to physically sort the list by component percent gain/loss; instead i
should provide a logic ordering with respect to this component. To do so i
added a data member, a vector to hold the indices of the stock list
ordered by the component percent gain/loss and i called this array
indexByGain. I am going to use the array indexByGain to print the list.
The elements of the array indexByGain will tell which component of the
stock list to print next. I have trouble going about how to implement the
function sortStockGain(). i need assistance and this would be of great
help as i don't know how to start. below is my entire code and the txt
file. I have sort symbols working but dont know how to implement the sort
by gain if one could assist me this would be of great help. By the way
this is my first programming class.
Below is my entire code:
#ifndef STOCKTYPE_H
#define STOCKTYPE_H
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
class stockType
{
public:
stockType(string symbol="", double openPrice=0.0, double closePrice=0.0,
double highPrice=0.0,
double lowPrevPrice=0.0, double closePrevPrice=0.0, int shares=0);
friend istream& operator>>(istream& ins, stockType& stock);
friend ostream& operator<<(ostream& outs, const stockType& stock);
//sets the variables
void setStockInfo(string syms, double open, double close, double high,
double lowPrev, double closePrev, int no_of_shares);
//calculates the gain
void calculateGain(double closeP, double prevP);
bool operator==(const stockType& stock1) const;
bool operator!=(const stockType& stock1) const;
bool operator<=(const stockType& stock1) const;
bool operator<(const stockType& stock1) const;
bool operator>=(const stockType& stock1) const;
bool operator>(const stockType& stock1) const;
//member functions
string getSymbols()const {return symbols;}
double getOpenPrice()const {return open_price;}
double getClosePrice()const {return close_price;}
double getHighPrice()const {return high_price;}
double getLowPrevPrice()const {return low_prev_price;}
double getClosePrevPrice()const {return close_prev_price;}
double getShares()const {return no_shares;}
double getGain()const {return gain;}
private:
string symbols;
double open_price, close_price, high_price, low_prev_price,
close_prev_price, gain;
int no_shares;
};
#include "stockType.h"
stockType::stockType(string symbol, double openPrice, double
closePrice, double highPrice,
double lowPrevPrice, double closePrevPrice, int shares)
{
setStockInfo(symbol, openPrice, closePrice, highPrice, lowPrevPrice,
closePrevPrice, shares);
}
void stockType::setStockInfo(string syms, double open, double close,
double high,
double lowPrev, double closePrev, int no_of_shares)
{
symbols = syms;
open_price = open;
close_price = close;
high_price = high;
low_prev_price = lowPrev;
close_prev_price = closePrev;
no_shares = no_of_shares;
}
istream& operator>>(istream& ins, stockType& stock)
{
ins>>stock.symbols;
ins>>stock.open_price;
ins>>stock.close_price;
ins>>stock.high_price;
ins>>stock.low_prev_price;
ins>>stock.close_prev_price;
ins>>stock.no_shares;
stock.calculateGain(stock.close_price, stock.close_prev_price);
return ins;
}
ostream& operator<<(ostream& outs, const stockType& stock)
{
outs<<stock.getSymbols()
<<fixed<<showpoint<<setprecision(2)
<<setw(10)<<stock.getOpenPrice()<<setw(10)
<<stock.getClosePrice()<<setw(10)
<<stock.getHighPrice()<<setw(10)
<<stock.getLowPrevPrice()<<setw(11)
<<stock.getClosePrevPrice()
<<setw(10)<<stock.getGain()<<"%"<<setw(13)
<<stock.getShares()<<endl<<endl;
return outs;
}
void stockType::calculateGain(double closeP, double prevP)
{
gain = ((closeP - prevP)/(prevP)*100);
}
bool stockType::operator==(const stockType& stock1) const
{
return (symbols==stock1.symbols);
}
bool stockType::operator!=(const stockType& stock1) const
{
return (symbols!=stock1.symbols);
}
bool stockType::operator>=(const stockType& stock1) const
{
return (symbols>=stock1.symbols);
}
bool stockType::operator>(const stockType& stock1) const
{
return (symbols>stock1.symbols);
}
bool stockType::operator<=(const stockType& stock1) const
{
return (symbols<=stock1.symbols);
}
bool stockType::operator<(const stockType& stock1) const
{
return (symbols<stock1.symbols);
}
#ifndef stockListType_H
#define stockListType_H
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include "stockType.h"
using namespace std;
class stockListType
{
public:
stockListType()
{
}
void insert(const stockType& item);
void sortStockSymbols();
void sortStockGain();
void printStockSymbols();
void printStockGain();
private:
vector<int> indexByGain;
vector<stockType> list;
};

How can I have multiple condition in 1 if statement

How can I have multiple condition in 1 if statement

I'm trying to hide a button until both select boxes have an item select.
<select id="comType">
<option>-- Select --</option>
<option>Call</option>
<option>Fax</option>
<option>Email</option>
</select>
<select id="comDirection">
<option>-- Select --</option>
<option>Incoming</option>
<option>Outgoing</option>
</select>
<a href="#"
id="button_that_displays_only_when_both_selects_have_input">Next</a>
What I'm currently using, but I know is not right.
<script>
$(document).ajaxSuccess(function () {
if ($("#comType").change()) || ($("#comDirection").change()))
{ $("#button_that_displays_only_when_both_selects_have_input").show()}
});
</script>
It would be an added bonus if this could ensure actual selection, as in,
not allow the first select option to count as they are just
placeholders....
Thanks, Mark

How to prevent the cursor to go back while pressing backspace key in javascript?

How to prevent the cursor to go back while pressing backspace key in
javascript?

Please consider the following html.
<div id="container" contenteditable="true">
<p>This is a paragraph <span class="test">'this text is inside the
span'</span>
This is another paragraph afer the span tag inside this p tag
</p> </div>
As you see, the p and the span tag are editable in the browser.It means we
can write in it in browser. Now my question is about the span inside the p
tag. So can anyone explain If the cursor (while typing in this span in
browser) is just after the span tag i.e after the closing span tag,the
backspace key should not work.
More simple,once the cursor goes outside the span,the backspace key should
not move it again to go to the span. Please help with a simple example in
javascript.
Thanks to all.

Saturday, 28 September 2013

concat pdo not dieing, but still not updating the database

concat pdo not dieing, but still not updating the database

my code is as follows
SQL = 'UPDATE cb_contact_tickets SET ticket_status = :status' .
($_POST['status']=="declined"?', declined=CONCAT(declined, :captain_id),
captain_id=NULL':'') .
' WHERE captain_id = :captain_id AND user_id = :user_id';
$stmt = $dbh->prepare($SQL);
$stmt->bindParam(':user_id', $_POST['user_id']);
$stmt->bindParam(':status', $_POST['status']);
$stmt->bindParam(':captain_id', $capatinID);
if (!$stmt->execute()) {
die(print_r($stmt->errorInfo()));
}
I checked the responses and i consistently get success ( a json encoded
response at the end) but my database doesnt change. The code doesnt die,
and im pulling hair out trying to figure out why. Please help.

Reach nested array item using recursion - javascript

Reach nested array item using recursion - javascript

I'm trying to reach the center of a nested array using recursion. This is
part of a larger problem I'm trying to solve. I'm sure the solution is
somewhat elementary. I've been learning JS/web dev and am stumped.
Here's my code:
var j = [[[["hey!"]]]];
function getNested(obj) {
for (var i = 0; i < obj.length; i++) {
if (Array.isArray(obj[i])) {
obj = obj[i];
getNested(obj);
}
return obj[i];
}
}
The function is supposed to return the 'hey!' string, but I can't seem to
get it right.

Developing android apps

Developing android apps

I want to develop an android app which will be help a shop owner can input
his daily sales expense, employee history, product setting and it show day
to day or monthly profit. when he use this app no need to connect internet
connectivity. data all are store in sd card but if he want in internet
connectivity state he can save data in dropbox. So as like a financial app
when I build this which program I need to know like java, xml ?? there are
need any database program ??? I am a new Apps Developer.

How To Grouping And Then Sorting Query SQL Server 2000 From Different Database Using PHP

How To Grouping And Then Sorting Query SQL Server 2000 From Different
Database Using PHP

I had a case like this. there are several branches database. I already can
create a report using PHP that show name product, total sales, then grand
total for all name product.
Now i want create a report for all branches database. How to do it? I want
create a report like this, The report must be group by each name product
from all branches. And then for each name product, display its, total
sales on the right side. Finally at the bottom of report, display grand
total for all name product group.
The method i have research and try to do this (but i still fail get a report)
First i create query to display top 20 name product from all branches
database. for example i have 10 branches database. By doing this i get
20*10 = 200 name product that already group by name product. Sorted DESC
by its total sales.
I created temp database to save this result temporary to group it again
and sorting DESC to get 20 name product. The problem is, i fail to create
temp database, if this method right, please guide me to create temp
database using php on sql server 2000.
OR
First i create query to display top 20 name product from all branches
database. for example i have 10 branches database. By doing this i get
20*10 = 200 name product that already group by name product. Sorted DESC
by its total sales.
I created an single array to save this result temporary to group it again
and sorting DESC to get 20 name product. The problem is, how to create
array and then grouping its value and sorting it? Please guide me, if this
method is the best way to create a report for my case.
Lastly, Please forgive me if my english bad. I'll appreciate to hear a
suggestion from all of you out there.
Thanks and best regards.

Friday, 27 September 2013

I have a blank page after submitting a php mysqli update form,

I have a blank page after submitting a php mysqli update form,

Hi I am trying to complete this update and It keeps sending me a blank
page with no errors and not submitting the info into the DataBase.
Everything works up to the point of the prepared statement as far as i can
tell, it draws the id and the other variables no problem from the database
and the previous search queries but wont let me go any further. Can anyone
see where I have gone wrong, I just cant see it???
<html>
<head>
<title>
<?php if ($id != '') { echo "Edit Record";
} else { echo "New Record"; } ?>
</title>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8"/>
</head>
<body>
<h1><?php if ($id != '') { echo "Edit Record";
} else { echo "New Record"; } ?></h1>
<?php if ($error != '') {
echo "<div style='padding:4px;
border:1px solid red; color:red'>" .
$error
. "</div>";
} ?>
<form action="" method="post">
<div>
<?php if ($id != '') { ?>
<input type="hidden" name="id"
value="<?php echo $id; ?>" />
<p>ID: <?php echo $id; ?></p>
<?php } ?>
<br><strong>Item Type: *
</strong><input name="item_type"
value="<?php echo $item_type; ?>"
type="text"><br>
<br><strong>Location: *
</strong><input name="location"
value="<?php echo $location; ?>"
type="text"><br>
<br><strong>Date Last Test: *
</strong><input name="date_last_test"
value="<?php echo $date_last_test; ?>"
type="date"><br>
<br><strong>Serial Number:
*</strong><input name="serial_number"
value="<?php echo $serial_number; ?>"
type="text"><br>
<br><strong>Date Next Test:
*</strong><input name="date_next_test"
value="<?php echo $date_next_test; ?>"
type="date"><br>
<br><strong>Comments: *</strong><input
name="comments" value="<?php echo
$comments; ?>" type="text"><br>
<p style="text-align: left;">*
required</p>
<input name="submit" value="Submit"
type="submit"><div style="text-align:
left;">
</div></div><div style="text-align: left;">
</body>
</html>
/*
EDIT RECORD
*/
// if the 'id' variable is set in the URL, we know that we need to
edit a record
if (isset($_GET['id']))
{
// if the form's submit button is clicked, we need to process
the form
if (isset($_POST['submit']))
{
// make sure the 'id' in the URL is valid
if (is_numeric($_POST['id']))
{
// get variables from the URL/form
$id = $_POST['id'];
$item_type = htmlentities($_POST['item_type'],
ENT_QUOTES);
$location = htmlentities($_POST['location'],
ENT_QUOTES);
$date_last_test =
htmlentities($_POST['date_last_test'],
ENT_QUOTES);
$serial_number =
htmlentities($_POST['serial_number'],
ENT_QUOTES);
$date_next_test =
htmlentities($_POST['date_next_test'],
ENT_QUOTES);
$comments = htmlentities($_POST['comments'],
ENT_QUOTES);
// check that firstname and lastname are both
not empty
if ($item_type == '' || $location == ''||
$date_last_test == ''|| $serial_number == ''||
$date_next_test == ''|| $comments == '' )
{
// if they are empty, show an error
message and display the form
$error = 'ERROR: Please fill in all
required fields!';
renderForm($item_type, $location,
$date_last_test, $serial_number,
$date_next_test, $comments, $error,
$id);
}
else
{
// if everything is fine, update the
record in the database
if ($stmt =
$mysqli->prepare("UPDATE
`Calibration_and_Inspection_Register`
SET `item_type` = ?,
`location` = ?,
`date_last_test` = ?,
`serial_number` = ?,
`date_next_test` = ?,
`comments` = ?
WHERE `id`=?"))
{
$stmt->bind_param("issdsds",`$id`,
`$item_type`, `$location`,
`$date_last_test`,
`$serial_number`,
`$date_next_test`,
`$comments`);
$stmt->execute();
$stmt->close();
}
// show an error message if the query
has an error
else
{
echo "ERROR: could not prepare
SQL statement.";
}
// redirect the user once the form is
updated
//header("Location: View Calibration
and Inspection records.php");
}
}
// if the 'id' variable is not valid, show an error
message
else
{
echo "Error with ID !";
}
}
// if the form hasn't been submitted yet, get the info from
the database and show the form
else
{
// make sure the 'id' value is valid
if (is_numeric($_GET['id']) && $_GET['id'] > 0)
{
// get 'id' from URL
$id = $_GET['id'];
// get the recod from the database
if($stmt = $mysqli->prepare("SELECT
`item_type`,`location`,`date_last_test`,`serial_number`,`date_next_test`,`comments`,`id`
FROM `Calibration_and_Inspection_Register`
WHERE id=?"))
{
$stmt->bind_param("i", $id);
$stmt->execute();
$stmt->bind_result($item_type,
$location, $date_last_test,
$serial_number, $date_next_test,
$comments, $id);
$stmt->fetch();
// show the form
renderForm($item_type, $location,
$date_last_test, $serial_number,
$date_next_test, $comments, $id);
$stmt->close();
}
// show an error if the query has an error
else
{
echo "Error: could not prepare SQL
statement";
}
}
// if the 'id' value is not valid, redirect the user back
to the view.php page
else
{
header("Location: View All Calibration and
Inspection Records.php");
}
}
}

Bash script to find apache servers

Bash script to find apache servers

I apologize if I haven't properly searched every possible post on this but
all seem a little different and I'm starting to get crossed eyed looking
at this.
The following bash code is what I have so far.
for server in cat serverlist2.txt; do ssh -q $server if ! ps -ef | grep -q
http ; then echo $server fi done
I'm new to bash scripting and I have to find all the hosts listed in the
file serverlist2.txt that run apache (http) and then print the hostnames
where http is found. Any help would be greatly appreciated.

Google Places API -- Java Version

Google Places API -- Java Version

I am very much interested about Google API'S. Today I saw one new API
(PLACES API). With this we can search places. But I tried to found out the
JAVA version of API but I was unable to find out the JAVA version sample
code. I found the JavaScript version. But I don't the JavaScript. Can any
one point me to the Java Version of "Google Place API"...?
Thanq, Amar.

Selenium. How to swith to a window that contains a partial substring?

Selenium. How to swith to a window that contains a partial substring?

I have three windows open as a result of Selenium manipulations. I need to
switch the the window who's URL contains a substring "Servlet"
driver.switchTo().window("*Servlet*");
How can I code it correctly?

enable the button to be clicked only to once exception?

enable the button to be clicked only to once exception?

I use a dialog to get the user input, but I found the user may click
double click the button and added the content twice, the cause is the
dialog fadeout too slow or the user clicked twice on the mouse.. I don't
want to adjust the fadeout speed, instead, how to enable the button only
can be clicked once?

finding length of wma in java

finding length of wma in java

I am a bit confused about all of the various sound apis available in java.
All I need is something to determine the length of a wma file. I don't
need to play it or convert it or anything else. I understand that the
native java api doesn't support wma. Can anyone recommend a good
library/method that can easily get the length of a wma? (I found JAVE from
searching here, but it seems like overkill in terms of setting up for just
determining the length.) It will run on a Windows computer if that's
relevant.

Maximum size of MYSQL data base

Maximum size of MYSQL data base

I am using VPS with Centos 5 , RAM - 2GB and my server storage space is
10GB what is the maximum size of database , Will it take more than 1
second for execution ?

Thursday, 26 September 2013

Why am I getting "Call to undefined function findOne()" here?

Why am I getting "Call to undefined function findOne()" here?

I've got a little PHP script that has the following code in it:
$m = new MongoClient(Settings::$db);
$db = $m->db;
// get the 'customers' collection
$customers = $db->customers;
// determine if this customer already exists
$c = $customers.findOne(array('email' => $email)); <--- throws
if (is_null($c)) {
$customers.insert(array(
'email' => $email,
'firstname' => $firstName,
'lastname' => $lastName
));
}
// get the 'payments' collection
$payments = $db->payments;
// add a record
$payments->insert(array(
'email' => $email,
'firstname' => $firstName,
'lastname' => $lastName,
'amount' => $price,
'token' => $token
));
but it's throwing the error:
PHP Fatal error: Call to undefined function findOne() in ...
Now, I've downloaded and copied into the ext directory the php_mongo.dll
file. Further, I've added this line to the php.ini:
extension=php_mongo.dll
and I've since rebooted the server numerous times.
It really feels to me like this findOne method isn't available because the
php_mongo extension isn't loaded. But on the other hand, it's not throwing
when creating the MongoClient, nor is it throwing when grabbing the
database and the collection.
What's going on here?

Wednesday, 25 September 2013

how to convert human date to unix by strotime

how to convert human date to unix by strotime

Can anyone help , i want to to make simple script as anyone insert human
date like 2013 - 9 - 25 19:10:00 P.M to milliseconds Unix .
is it possible using strtotime.
I want anyone to show me how to make the whole human date (2013 - 9 - 25
19:10:00 P.M ) be in one variable so i can convert it then echo it

Thursday, 19 September 2013

Detecting Numbers in a String Variable (In Java)

Detecting Numbers in a String Variable (In Java)

So, normally for detecting user input, I use int and double variable types.
Example:
Scanner in = new Scanner(System.in);
int selection;
System.out.println("Welcome to RPG! (prototype name)\nIn this game,
you do stuff.\nChoose a class:\n1. Soldier\n2. Knight\n3. Paladin\n4.
Heavy");
selection = in.nextInt();
if(selection == 1){
System.out.print("you are a soldier");
}
else{
System.out.print(selection);
}
}
This technique usually works fine for me, but I noticed that if the user
inputs a letter into the int variable, the game will crash because
integers can't store letters. (right?) So I tried using a String variable
in its place, like this:
Scanner in = new Scanner(System.in);
String selection;
System.out.println("Welcome to RPG! (prototype name)\nIn this game,
you do stuff. Level up, yo!\nChoose a class:\n1. Soldier\n2.
Knight\n3. Paladin\n4. Heavy");
selection = in.next();
if(selection == "1"){
System.out.print("you are a soldier");
}
else{
System.out.print(selection);
}
}
This seemed to work at first, but as you can see, I have it set so that if
the variable "selection" is equal to 1, that it will print "you are a
soldier", yet this did not work, instead it printed out the collection
variables value (1). Did I do something wrong or should I use a different
type of variable?

iOS - Load UIViewController in Specific Orientation

iOS - Load UIViewController in Specific Orientation

What i'm trying to do - is simply force start my ViewController in
Portrait mode regardless of its orientation:
after its initiated, it could just continue to follow the AutoRotate
functionality
This is probably along the answer I'm looking for : but the answer
contains a broken link



---- if interested, the reason i need this is:
i'm creating a PDF Reader in a UIView
in Portrait mode it can use the screen dimensions to load the PDF
proportionately
the UIView is set to UIViewAutoReSizingNone and UIViewContentModeLeft
this presents the PDF perfectly when the device Orientation changes to
landscape (of course I'm handling panning / zooming / positioning of the
PDF separately for a better presentation)
But when I launch the VC in landscape I have problems . . . .

PHP: use a variable to reference a defined variable, w/o eval

PHP: use a variable to reference a defined variable, w/o eval

That title probably doesn't help much. I'm trying to figure out if there's
a way to get the value of a variable that has been set using define(...),
but using a 2nd variable to build the defined var's name. Example will be
clearer:
define('I_LOVE_YOU', 'xoxox');
$n = 'LOVE';
// how to get 'xoxox', using $n? This won't work:
$defd = 'I_'.$n.'_YOU';
echo $defd; // obviously echos 'I_LOVE_YOU', not 'xoxox'
// this will, but is awful
eval('echo I_'.$defd.'_YOU;'); // echos 'xoxox'
Is there any other way to do this, w/o resorting to eval?

Remove all border on all panelgrids

Remove all border on all panelgrids

I need to hide all borders of all panelgrids using primefaces. I have
tried he following without effects:
table {
border: none;
}
table tr, table td {
border: none;
}
What can I do?

abt naudio input and output devices

abt naudio input and output devices

I am pretty new to Naudio, trying to understand it, I require the
following to be done in my application
I have couple of devices connected to my system say 1) head set - with a
mic 2) inbuilt system mic and speakers
I require to do the following the audio from the two input devices(headset
mic and system mic) should be mixed and a byte array needs to be
constructed. how can this be done using naudio
Also, the system speakers and headset would receive a stream that needs to
played on both any concept ? or classes that i can use ?

Translate cancel and save buttons in [weekCalendar jquery plugin]

Translate cancel and save buttons in [weekCalendar jquery plugin]

I'd like to translate buttons - "save" and "cancel" in weekCalendar jquery
plugin, I'd tried to search in files for I couldnt find in files
translatable "save" or "cancel" text, any one have ever tried doing that
or any suggestions how to achieve using jquery ?
Link to plugin

MQ Queue with multiple consumers but only one active

MQ Queue with multiple consumers but only one active

We have one MQ Queue which receives messages from an external system out
of our control. Our system processing the incoming messages is a critical
one and needs to be up and running 27x7 no matter what.
The order in which the incoming messages are processed is also not
negotiable which means we need to process them in exactly the order they
arrived.
To make sure our system is 100% available we deployed our system to a
bunch of physical machines able to process those messages.
Once the messages reached our system we put in place a mechanism to make
sure the messages processing does not go out of order while also getting
some performance gain as a result of the parallel processing. For us the
performance gain is a good to have, however it is rather a side effect as
our main goal is the high availability while assuring the right processing
order.
My thoughts were to have on every single machine an MDB able to process
the incoming messages but only have one active consumer at a time.
We are using Webshere MQ as a JMS provider and Webshere Application Server
8.5 to deploy our application.
The problem with multiple consumers listening to the same queue does not
seem to be a workable solution as when messages arrive in bulk they would
be round-robin passed to all consumers and there is no way to control how
this is going to happen and the messages easily go out of sequence.
When I manually stopped all the listeners but one obviously the messages
got processed in order. But manually shutting down and starting up such
listeners is definitely not a HA solution.
We could put in place monitoring processes to check for health of the
system and shut things down or start them up as required but this still
looks too weak to me. What we want in fact is to have all listeners up and
running but only one receiving the messages. If that one goes down for
whatever reasons then another one sitting there will become active and
start processing messages.
Initially we considered using a topic rather than a queue but this comes
with other issues like below:
we cannot control the source of our messages
the high volume of messages we have would put us in in trouble with our
going down subscribers that have to be durable and such when coming up
back will have to deal with lots of pending messages
the input queues are already part of a cluster and changing all the
infrastructure would require a lot of work
Anyway in my view it has to be an existing pattern to accommodate
situations like this. Any help, suggestion would be greatly appreciated.
The solution does not have to be a specific MQ one, any idea is welcome.
Thanks in advance

Wednesday, 18 September 2013

Should I make sure to destroy SDL 2.0 objects (renderer, window, textures, etc.) before exiting the program?

Should I make sure to destroy SDL 2.0 objects (renderer, window, textures,
etc.) before exiting the program?

This tutorial on SDL 2.0 uses code that returns from main without first
destroying any of the resource pointers:
int main(int argc, char** argv){
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
std::cout << SDL_GetError() << std::endl;
return 1;
}
window = SDL_CreateWindow("Lesson 2", SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_SHOWN);
if (window == nullptr){
std::cout << SDL_GetError() << std::endl;
return 2; //this
}
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED
| SDL_RENDERER_PRESENTVSYNC);
if (renderer == nullptr){
std::cout << SDL_GetError() << std::endl;
return 3; //and this too
}
Should I tell my terminate function to DestroyRenderer, DestroyWindow,
DestroyTexture, etc. before exiting?

I want to read a file line by line and split the strings to be used as attributes for a new object

I want to read a file line by line and split the strings to be used as
attributes for a new object

I'm trying to read from a txt file that has the following format:
Matthew:1000
Mark:100
Luke:10
John:0
Actually, there is no extra space between the lines, I just couldn't get
it to look like that.
I have a Score object that stores the player's name and score (int). This
is the class for Score:
public class Score {
String playerName;
int playerScore;
public String toString(){
StringBuilder builder = new StringBuilder();
builder.append(playerName + ":" + playerScore);
return builder.toString();
}
public void setName(String name){
this.playerName = name;
}
public void setScore(int score){
this.playerScore = score;
}
}
I would like to read from the file in such a way that I could get the
player's name (Matthew) and their score (1000, stored as an integer), and
make a new Score object. This is the code I've tried so far:
public ArrayList getLoadFile(String filename) {
ArrayList<Score> scores = new ArrayList<Score>();
BufferedReader bufferedReader = null;
try{
bufferedReader = new BufferedReader(new FileReader(filename));
String fileLine;
while((fileLine = bufferedReader.readLine()) != null){
Score newScore = new Score();
newScore.playerName = fileLine.split(":", 0)[0];
newScore.playerScore = Integer.parseInt(fileLine.split(":",
0)[1]);
scores.add(newScore);
}
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
return scores;
}
This function is supposed to load string representations of saved scores
and make an ArrayList of scores, then return them to a test function. When
I run it, it returns: java.lang.ArrayIndexOutOfBoundsException: 1
Any help would be greatly appreciated.

Xsl count based on Filtered node

Xsl count based on Filtered node

I have the following xml:
<Activity>
<item>
<task>XXX</task>
<assignto>User1</assignto>
</item>
<item>
<task>YYY</task>
<assignto>User2</assignto>
</item>
<item>
<task>ZZZ</task>
<assignto>User1</assignto>
</item>
<team>
<member>User1</member>
<member>User2</member>
<team>
</Activity>
I want to generate using XSL a count of task per member in the team.
User- Count
user1- 2
user2- 1

so far I have the following XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table>
<tr>
<th>User</th>
<th>Task Count</th>
</tr>
<xsl:for-each select="Activity/team/member">
<tr>
<td><xsl:value-of select="node()" /></td>
<td><xsl:value-of
select="count(/Activity/item[assignto='user1'])" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
so far I hardcoded 'user1', I would like to filter based on the current
member in the for each loop.
Can someone help, please?
Thanks,

Deploy no Windows Phone 8 rodando dentro do virtualbox

Deploy no Windows Phone 8 rodando dentro do virtualbox

Estou usando linux opensuse como hospedeiro, com sua vm aberta uma com o
windows 8.1 pro e outra com Windows phone 8, usando o virtual box, alguém
sabe como fazer deploy da minha aplicação para o windows phone?

DB4o update vs insert

DB4o update vs insert

Assuming you are using DB4O with the standard configuration and
out-of-the-box - meaning, you are using DB4O's standard internal id
scheme, as per below*.
First, as an assumption, when updating or inserting an object into the
database, the programmer only has one option, to call
"objectContainer.store(object)".
Now, how does DB4O know whether to update an existing object in the DB, or
to insert an entirely new one? My guess is that DB4O looks to see if the
internal id of the object is not null.
However, I could also see the possibility that the burden is on the
programmer to first pull the object from the DB, then update it. So my
question is, how can we reliably update an object in a DB4O database
without first pulling it into Java memory?
*This is very informative:
http://community.versant.com/documentation/Reference/db4o-8.1/java/reference/Content/platform_specific_issues/disconnected_objects/comparison_of_ids.htm

Character Pointers and Case Sensitive when checking if a string is a palindrome in C

Character Pointers and Case Sensitive when checking if a string is a
palindrome in C

my code here checks a string to see if it is a palindrome. However, it
doesn't check for uppercase letters and it also doesn't use character
pointers which I am supposed to use in this program. Can someone give me
some tips?
#include <stdio.h>
#include <string.h>
int main(){
char string1[20];
int i, length;
int flag = 0;
printf("Enter a string: ");
scanf("%s", string1);
length = strlen(string1);
for(i=0;i < length ;i++){
if((string1[i]) != (string1[length-i-1])){
flag = 1;
break;
}
}
if (flag)
printf("%s is not a palindrome \n\n", string1);
else
printf("%s is a palindrome \n", string1);
return 0;
}

I want to finish the activity from an other activity on pressing the back button

I want to finish the activity from an other activity on pressing the back
button

I have an activity named QRCodeReader it has a back button on it. It scans
the qr code and pass the id to MetaioCloudARViewTestActivity to start the
channel. Its working fine. But when i press the back button of the
qrCodeReader it finishes the current activity but it loads the blank arel
camera web view of MetaioCloudARViewTestActivity. So i want to finish that
the web view also. If i use the finish in onResume of
MetaioCloudARViewTestActivity it works fine for back button of
QRCodeReader. But i need that activity when i have to scan the code. I
just want to finish it on pressing the back button in QRCodeReader.

How to post long text to facebook wall thru javascript

How to post long text to facebook wall thru javascript

I try to post custom text to facebook wall. I found good example:
http://www.fbrell.com/fb.ui/feed And this is work, but not exactly what i
expected
If text that I send more then ~300 characters, facebook cut it without
"see more" button And not way to see full text, and this is a problem
I tried play with parameters, but seems that this is not right way Tried
to find other component, but seems that dialog-feed more suitable for my
purpose
Thanks

Tuesday, 17 September 2013

Web services consumption and calling

Web services consumption and calling

I want to ask how can I add web service into my already existing MVC 4.0
project? I have searched on Internet, in all the links they are saying to
create a new application/solution but I want to add a web service and how
It will be available to call from other web sites. Can somebody please
tell me the steps for it. I will be thankful to you. I just have basic
knowledge of .Net.
2)Suppose I have to call a web service from another site so how will I
able to call that service if I do not have my own?
I have searched following links:
http://www.aspdotnet-suresh.com/2011/05/aspnet-web-service-or-creating-and.html
http://www.codeproject.com/Articles/337535/Understanding-the-Basics-of-Web-Service-in-ASP-NET

(Reading CSV file) scanf skip to next line of input after pattern mismatch

(Reading CSV file) scanf skip to next line of input after pattern mismatch

I want to give an error message if scanf encounters a mismatch and then
continue reading the rest of the inputs. My current code goes into an
infinite loop if one of the inputs isn't formatted correctly.
Expected input:
101,Betty,Hay,123 Main St.,23
234,Sheila,Benn,937 Ash Ave.,46
384,Ron,Jewell,3991 Cedar Ave.,30
291,Bill,Read,83 Crescent St.,19
103,Alexander,Ott,100 2nd St.,21
115,Tricia,Munson,585 Oxen Ave.,28
118,Sam,Munson,585 Oxen Ave.,35
110,Valerie,Parker,1513 Copper Rd.,37
Code:
#include <stdio.h>
int main()
{
int sum = 0;
int count = 0;
while (1)
{
int id;
char first[80], last[80], addr[80];
int age;
scanf("%d,%80[^,],%80[^,],%80[^,],%d", &id, first, last, addr, &age);
if (feof(stdin)) break;
printf("id=%d first=%s last=%s addr=%s age=%d\n",
id, first, last, addr, age);
sum += age;
count++;
}
printf("Average age is %f\n", (float)sum / count);
return 0;
}
I tried to fix this by putting scanf inside an if statement comparing it
to the expected number of reads, this worked for displaying the error
message but doesn't help reading the rest of the input. Is there a way to
skip to the next line of input?

decompress GIF with multiple data-blocks

decompress GIF with multiple data-blocks

I wrote python script that takes GIF data like this :
['8c', '2d', '99', '87', '2a', '1c', 'dc']
and turn it to this:
[1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
first I get all the data in all the blocks and turn it to a stream of bits
>> I am not sure about this step .I don't know if I have to decompress all
the blocks at once as one stream or decompress them Individually
for byte in data:
bit=bin(int(m,16))[2:]
while len(bit)<8:
bit='0'+bit
c.append(bit[::-1] )
stream= ''.join(c)
decompress(stream)
here is the decompress function
def decompress(s,InitialCodeSize):
index=[]
table=Initialize(InitialCodeSize)
codesize = InitialCodeSize + 1
ClearCode=int(math.pow(2, InitialCodeSize))
L=int(math.pow(2, codesize))
code = int(s[:codesize][::-1],2)
s=s[codesize:]
c = table[code]
old = c
for i in c:
index.append(i)
while s !='':
code = int(s[:codesize][::-1],2)
s=s[codesize:]
if code == ClearCode:
table=Initialize(InitialCodeSize)
codesize = InitialCodeSize + 1
if code in list(xrange(len(table ))):
c=table[code]
table.append(old + [c[0]])
else:
table.append(old + [old[0]])
c= old + [old[0]]
for i in c:
index.append(i)
old=c
if len(table) == L and codesize< 12:
codesize=codesize+1
L=int(math.pow(2, codesize))
return index
everything work just fine when the image has few blocks but when it has
more blocks it always return smaller number of pixels
for example if the image 522*200 =104400 pixels it give me only 61806
pixels I though maybe the GIF format uses RLE encoding

how do I properly incorporate arrays into for loops in jquery/javascript?

how do I properly incorporate arrays into for loops in jquery/javascript?

I am working on a custom gallery right now, but I cannot seem to get the
array of variables to apply during the loop. What am I missing?
Here is the relevant code:
var racerImage = ['$("img.ryanthumb")', '$("img.pierthumb")',
'$("img.jeremythumb")',
'$("img.mattthumb")', '$("img.andrewthumb")', '$("img.alanthumb")',
'$("img.kevinthumb")', '$("img.mikethumb")', '$("img.dougthumb")'];
var showMe= ['showRacer("ryan")\;', 'showRacer("pier")\;',
'showRacer("jeremy")\;', 'showRacer("matt")\;',
'showRacer("andrew")\;',
'showRacer("alan")\;', 'showRacer("kevin")\;', 'showRacer("mike")\;',
'showRacer("doug")\;'];
for (var i = 0; i < racerImage.length; i++)
{
racerImage[i].click(function(){
switch (i)
{
case 0:
showMe[i];
break;
case 1:
showMe[i];
break;
case 2:
showMe[i];
break;
case 3:
showMe[i];
break;
case 4:
showMe[i];
break;
case 5:
showMe[i];
break;
case 6:
showMe[i];
break;
case 7:
showMe[i];
break;
case 8:
showMe[i];
break;
}
});
}
Basically I am trying to use a for loop to apply the jquery multiple times
instead of writing it over and over again. I don't know if I am going
about this the right way, but any insights would be great. Thanks again!

Delay function in jquery

Delay function in jquery

I'm pretty new to jquery and I couldn't make .delay work. Can you please
check this fiddle? (note: I don't want to use .queue or .settimeout or any
other method, I want to learn how to use .delay)
http://jsfiddle.net/YMmD7/1/
$(document).ready(function(){
$(".box").click(function(){
$(".box").hide().delay(1000).show();
});
});

Worklight 6.0 fixpack 1 install error

Worklight 6.0 fixpack 1 install error

Getting error on install of 6.0 Worklight server to Fix pack 1:
WASX7017E: Exception received while running file "D:\Program
Files\IBM\Worklight1\WorklightServer\uninstall\was-install.py"; exception
information: com.ibm.websphere.wim.exception.WIMApplicationException:
com.ibm.websphere.wim.exception.WIMApplicationException: CWWIM5505E To
manage users and groups, either federated repositories must be the current
realm definition or the current realm definition configuration must match
the federated repositories configuration. If you use Lightweight Directory
Access Protocol (LDAP), configure both the federated repositories and
standalone LDAP registry configurations to use the same LDAP server.
Security is LDAP (Active Directory), but, looking at script
(was-install.py), it is hard-coded looking for a user called
"appcenteradmin", which, which we do not use (we've allowed admin access
to another user). Is this user "appcenteradmin" now required?
The was-install.py has this comment:
If the custom panels have told the user that an account 'appcenteradmin' will
be created, do so now.
But, there is no panel indicating this in the IBM Installation Manager
screens.

Sunday, 15 September 2013

How does --data option work in curl

How does --data option work in curl

curl --data "<xml>" --header "Content-Type: text/xml" --request PROPFIND
url.com
By reading the curl man page I could not understand how the above
commandline is using --data option.
Question:
What does above commandline do ?
Why doesn't man page describe this usage? If it does then what did I not
understand after reading the man page?

Android - Stopping Little Fluffy Location Service

Android - Stopping Little Fluffy Location Service

I am testing out the really nice Little Fluffy Location Service
(https://code.google.com/p/little-fluffy-location-library/), but I can't
figure out how to stop the service. It seems to continue forever.
How can this service be stopped, and also started later?

Android ListView showing images results in out of memory

Android ListView showing images results in out of memory

Okay,
I have what I think is an odd problem.
I load photos into a list view as the user scroll (meaning if picked up
from disk or online, it takes a little time and they "pop in")
1)
I ensure that I only fetch one image online + resize to 1/3 width at a
time (a lock) -- this is to ensure not e.g. 5 threads each are converting
a .jpg to bitmap at the same time. (Imagine a user scrolling very fast, it
would then be conceivable this could happen.)
2)
All images on disk are only 1/3 width
3)
While the bitmaps are scaled up to fit device width, I call recycle and
set bitmaps to null when used in the getView. (I am converting bitmaps to
a BitmapDrawable object which the listitem imageview uses in a
setImageDrawable call)
I am testing on a Samsung Galaxy II. Do you guys have any ideas on what
more I could try? Since I only max need to show 10 items, I would think it
should be possible...

Adding KeyListeners to JPanel not working

Adding KeyListeners to JPanel not working

I've just completed an online tutorial on making a networked game. The
game it's self is just a small circle that follows the mouse when on the
screen.
I've been modifying the code to use keys to move the circle instead of the
mouse. However whilst I've done this before I've never used "JPanel" and
I'm struggling to get the keys to move the circle around.
The game's 'client' side only consists of two files, Client.java and
DataPackage.java, the problem (to my knowledge) appears to be in
Client.java.
I wont paste the whole code as it is quite big (i will if you think it is
necessary), but here is the bit that makes the ball follow the mouse
public Client()
{
this.addMouseMotionListener(new MouseMotionListener()
{
@Override
public void mouseDragged(MouseEvent e)
{
x = e.getX();
y = e.getY();
}
@Override
public void mouseMoved(MouseEvent e) {}
});
}
now I've tried just changing
this.addMouseMotionListener(new MouseMotionListener()
{
@Override
public void mouseDragged(MouseEvent e)
{
x = e.getX();
y = e.getY();
}
@Override
public void mouseMoved(MouseEvent e) {}
});
to
this.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) { System.out.println(
"tester"); }
public void keyReleased(KeyEvent e) {
System.out.println("2test2"); }
public void keyTyped(KeyEvent e) {
System.out.println("3test3"); }
});
but this didn't appear to work, then i tried changing the location of the
keying code by putting it outside of the
public Client() { }
Then I thought it could be the 'implements' tags at the top of the file.
so I added
implements KeyListener
to the end of
public class Client extends JComponent
but again, this did not work then I did some more research and it seems
that I need to set the panel to be focused by using
panel.setFocusable(true);
but the source of this information, failed to say where to put it and
everywhere I put it throws an error
Can someone shed some light on this for me please?

Scanners and multiple if statements

Scanners and multiple if statements

I am trying to get a Scanner to read through each line of data and only
print out the lines that contain the word "model" followed by a year
within the boundaries I set. I am not sure if there is a more efficient
way to do this, but I made one Scanner for the whole set of data and then
within that I declared another one that reads each line. I then tried to
set it to look for a String comprised of the word "model" plus the year if
the line contains the right year. Since tokens in Scanners are divided by
spaces, I thought the correct way to do it would to declare a different
String, tokenToken, that combines the first token with a space and the
year, if such a combination exists.
Currently when I run it, it just runs forever, not compiling, so I don't
know what's wrong with it. I think it may have to do with the innermost if
statement but I'm not sure. I'm new to this.
public static void main(String[] args) {
Scanner inStream = new Scanner(System.in);
while (inStream.hasNext()) {
String line = inStream.nextLine();
Scanner lineStream = new Scanner(line);
while (lineStream.hasNext()) {
String token = lineStream.next();
if (token.matches("model") && lineStream.hasNextInt()) {
int year= lineStream.nextInt();
if ((year>= 1976) && (year <= 2013)) {
String tokenToken = (token + " " + year);
if (lineStream.hasNext(tokenToken)) {
System.out.println(line);
} else {
}
}
}
}
lineStream.close();
}
inStream.close();
}

spring mongodb: getting sorted and paginated list of inner document

spring mongodb: getting sorted and paginated list of inner document

I have two document. User and Activities. Activities is a inner document.
@Document(collection="users")
public class User {
@Id
private String id;
private String usertoken;
private String firstname;
private List<Activity> activities;
}
@Document
public class Activity {
private Date date;
private String text;
}
I am using spring mongo layer in my project. I wanted to query and get a
paginated list of activities (in descending order of date) for a given
user using query annotations. How could I achieve this?
@Query()
List<Activities> getActivities(usertoken, Pageable);
I am fine with getting User document with inner document activities if the
above is not possible.

Update numpy array row by condition

Update numpy array row by condition

I need help) I have NumPy array:
False False False False
False True True False
True True True True
False True True False
False False False False
How can I get this (take first and last rows, that contains True, and set
all of them elements to False)?
False False False False
False False False False
True True True True
False False False False
False False False False

Saturday, 14 September 2013

Starting my app on boot in android in xamarin (c#)

Starting my app on boot in android in xamarin (c#)

I am a c# developer and i using from xamarin for developmen my android
app. now i want to start my app automaticly on android boot or start a
service, but my app show error after restarting phone and wont open.
For start on boot i use from this articles:
How to Start an Application on Startup?
And
http://morewally.com/cs/blogs/wallym/archive/2011/07/28/start-an-application-on-boot-with-mono-for-android-android-monodroid.aspx
And handle that codes for my application but my app boot start doset work
and show a force close. Please help me.

Creating a mobile layout that looks like the landscape version while in portrait

Creating a mobile layout that looks like the landscape version while in
portrait

I'm working on a website for job listings that needs to integrate a widget
from SmartRecruiters and have run into an issue with the mobile layout.
I'm using the viewport tag as <meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1" /> which
works really well for a landscape orientation. The issue is that the
SmartRecruiters table that lists the job openings does not shrink to be
narrow enough when in portrait mode and requires the user to scroll
horizontally.
How can I make the portrait layout zoom out to the same width as the
landscape layout that works really well?
Thank you in advance.

jquery onclick function braking after addClass next click

jquery onclick function braking after addClass next click

Click on the element adds the class play the css can handle it well. With
the next click I would like to remove the class play and that just doesn't
wants to happen.
What am I doing wrong? Also how could I do better ?
Thank YOU
<span class="icon small-player-icons pause" style="display: inline;">click
here</span>
$('.small-player-icons.pause').on('click',function(){
$(this).addClass('play');
});
$('.small-player-icons.pause.play').on('click', function(){
alert("clicked");
$(this).removeClass('play');
});
span.small-player-icons.pause {
background-color:green;
padding:10px;
}
span.small-player-icons.play {
background-color:orange;
}
Here is the fiddle

How to check if the user logged in or out with PHP?

How to check if the user logged in or out with PHP?

how to check if the user logged in with php if the user logged in with
javascript SDK? and why i do need appId if i use login plugin for m site?

Display content of a html page in a div

Display content of a html page in a div

I have an index.html page:
<body>
<ul>
<li><a id="page" href="#">About</a></li>
</ul>
<div id="show">
</div>
</body>
a jQuery:
<script type="text/javascript">
$(document).ready(function(){
$("#page").click(function(){
$('#show').load('test.html');
});
});
</script>
What I need is to display content from test.html in #show div, but above
code doesn't work.



So my question is: what did I do wrong?
PS: I'm using jQuery 1.9.1 library from link <script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
type="text/javascript"></script> and it works with other jQuery scripts.

Global AJAX event listeners in Can.JS?

Global AJAX event listeners in Can.JS?

Is it possible to bind listeners to when an AJAX request is started in
Can.JS? I want to integrate a little loading indicator in my Can.JS
project so that users can see when data is being loaded from my server.
Using the jQuery $.ajaxStart and $.ajaxSend events didn't work, however
the $.ajaxComplete event did fire correctly.

VBA excel read file text in folder

VBA excel read file text in folder

I'm new in VBA, I wonder if someone can help me out, I want to read a few
text file in one folder and put it on excel sheet using VBA code. let say
I have about 100 - 200 of single line text file that contain like below
(just example) file= james.txt, contain = Mr.James phone number is
789101112, ID card:123456789 live at California file= Andy.txt contain =
Mr.Andy phone number is 789456123, ID card:45678978622331 live at Los
angeles file = and so on.. I need to get the contain file at put in excel
to became like below A B C D 1 James Mr.James 789101112 123456789 2 Andy
Mr.Andy 789456123 45678978622331 3 and so on... Can anyone help me
please...

Not able to install requests on cygwin

Not able to install requests on cygwin

I know this question has been asked already. But nothing seems to work for
me. When I tried the following command
pip install requests
I am getting the following error
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 343, in
load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2307, in
load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2013, in
load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File
"/usr/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip/__init__.py",
line 10, in <module>
from pip.util import get_installed_distributions, get_prog
File "/usr/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip/util.py",
line 8, in <module>
import zipfile
File "/usr/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/usr/lib/python2.7/io.py", line 60, in <module>
import _io
ImportError: No module named _io

Friday, 13 September 2013

Why does the TDBGrid take up more space at run-time?

Why does the TDBGrid take up more space at run-time?

I have bumped into a pretty confusing problem.
At design time, I clearly indicate the size of columns (width and Max
width) for the TDBGrid.
Here's the problem... As you see, the design time and run-time grids are
different in size. And also note that the form is the same size.
Please ignore the rest of the screen. My only concern is the window with
the grid :)
Is there any way I can fix this?
BTW, I'm working on Ubuntu with Lazarus but the software may be on Ubuntu
or Windows.
I'd really appreciate nay inputs on this. Thanks!

PHP - sum values except one in foreach

PHP - sum values except one in foreach

Ok I have this code
$var[0] = array('my_value=500,other_values,..');
$var[1] = array('my_value=700,other_values,..');
$sumValues = 0;
foreach ($vars as $key=>$var) {
$trek = $var->my_value;
if ( $key = 0 ) {
$sumValues = $some_external_value;
} else {
$sumValues = $sumValues + $trek[$key-1];
}
}
Expected returned values
$var[0] - $sumValues = 0
$var[1] - $sumValues = 500
$var[2] - $sumValues = 700
I want to sum up the values of $trek to be used for each $var as a value
only determined by the sum of the previous $var elements and not itself.
As always, thanks for any reply :)

In C#, how can I get the name of the calling project from within a referenced project?

In C#, how can I get the name of the calling project from within a
referenced project?

I have three projects: My.Business, My.WebSite and My.WebService
I need my logging class to be able to identify when a request is made from
the website versus the web service. I used to have the web service running
as a separate application underneath the web site, so I'd just use
different config files, which worked fine. But I want the web service now
to run under the same application.
If I could figure out if the request was coming from My.WebSite or
My.WebService, I'd be set, but I'm not sure how to do this.
Assembly.GetExecutingAssembly() returns back My.Business
Assembly.GetEntryAssembly() is null
I could check the StackTrace, but that seems sloppy and how for back would
I have to go? Especially because the logging may be triggered by code in
My.Business that was originally invoked from one of the other projects.
Since the web service requests end in ".asmx", the following concept
works, but it just doesn't feel right.
return HttpContext.Current.Request.Path.IndexOf(".asmx") >= 0 ?
"My.WebService" : "My.WebSite";
Thanks!

How to Echo a Distinct Count in PHP?

How to Echo a Distinct Count in PHP?

I have a Mysql that returns a count of items we have in stock
select count(distinct style) from bottles
I want to echo that value out to my website. I tried.
<?php
#///////////////////////////////////
#// Show Amount of Bottles
#///////////////////////////////////
$distinct = mysql_query("select count(distinct style) from bottles", $con);
$num_rows = count($distinct);
echo "$num_rows Bottles In Stock";
?> as of <?php print date('l F jS, Y', time()-86400);
But its only showing me the value of 1? Can someone point me in the right
direction?
Also if I would like to have one statement echo multiple rows how can i do
this?
Item Name | Style | Location
So I would like to echo on our site:
As of today we have 400 bottles of beer in stock X different styles from Y
locations?
Thanks in advance for any help. I just started teaching myself php and
mysql about a month ago.
Ryan

calendarview stops scrolling when nested in scrolview in android

calendarview stops scrolling when nested in scrolview in android

I have nested calendarview in ScrollView . My problem begins when height
of view increases. I can scroll calendar months vertically but wen
scrollview scrollbar comes it does not let scroll calendar. Instead of
scrolling calendar the whole view scrol up or down.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout android:orientation="vertical" android:id="@+id/ReminderLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/TaskName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:singleLine="true"
android:textSize="26.0sp" />
<View
android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip" />
<TextView
android:id="@+id/lblNotes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Notes" />
<EditText
android:id="@+id/TaskNotes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:textSize="26.0sp" />
<View
android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip" />
<TextView
android:id="@+id/lblReminder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Reminder" />
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">"
<CalendarView
android:id="@+id/calendarReminder"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:scrollbars="vertical"
android:isScrollContainer="true" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TimePicker
android:id="@+id/timePickerReminder"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="center" />
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<View android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<TextView android:id="@+id/ReminderTime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="On Time" android:paddingLeft="20dip"/>
<View android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<TextView android:id="@+id/Recurring"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Only Once" android:paddingLeft="20dip"/>
</LinearLayout>
</LinearLayout>
</ScrollView>

Thursday, 12 September 2013

How to do Animation like BooK front cover?

How to do Animation like BooK front cover?

I want the Page flip animation for Photo Allbum Book cover even though i
have added animation for pages(Used UIpageViewController) but need to have
main page animation as well. Please see this link exactly like this I want
see this
1: Please help.

Issue referencing images in JQuery code

Issue referencing images in JQuery code

Probably a silly question but I'm having quite a bit of trouble trying to
figure out how to reference an image from my folder in JQuery code.
I want to turn images to greyscale, that revert to colour on mouse
rollover. However, my image referencing isn't working. I've tried the
usual ('folderofimages/myimage') but that isn't working. I've tried the
suggested way ('.myimage folderofimages') and that's not working either.
This is the website that supplied the code,
http://webdesignerwall.com/tutorials/html5-grayscale-image-hover/comment-page-4#comments
Any help is greatly appreciated!
Here is my code,
// On window load. This waits until images have loaded which is essential
$(window).load(function(){
// Fade in imagimages/homeannual.jpeges so there isn't a color "pop"
document load and then on window load
$("images.homeannual").fadeIn(500);
// clone image
$('images.homeannual').each(function(){
var el = $(this);
el.css({"position":"absolute"}).wrap("<div class='img_wrapper'
style='display:
inline-block'>").clone().addClass('img_grayscale').css({"position":"absolute","z-index":"998","opacity":"0"}).insertBefore(el).queue(function(){
var el = $(this);
el.parent().css({"width":this.width,"height":this.height});
el.dequeue();
});
this.src = grayscale(this.src);
});
// Fade image
$('images.homeannual').mouseover(function(){
$(this).parent().find('img:first').stop().animate({opacity:1}, 1000);
})
$('.img_grayscale').mouseout(function(){
$(this).stop().animate({opacity:0}, 1000);
});
});
// Grayscale w canvas method
function grayscale(src){
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
var imgObj = new Image();
imgObj.src = src;
canvas.width = imgObj.width;
canvas.height = imgObj.height;
ctx.drawImage(imgObj, 0, 0);
var imgPixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
for(var y = 0; y < imgPixels.height; y++){
for(var x = 0; x < imgPixels.width; x++){
var i = (y * 4) * imgPixels.width + x * 4;
var avg = (imgPixels.data[i] + imgPixels.data[i + 1] +
imgPixels.data[i + 2]) / 3;
imgPixels.data[i] = avg;
imgPixels.data[i + 1] = avg;
imgPixels.data[i + 2] = avg;
}
}
ctx.putImageData(imgPixels, 0, 0, 0, 0, imgPixels.width,
imgPixels.height);
return canvas.toDataURL();
}

Backbone Marionette get region view

Backbone Marionette get region view

I have a marionette layout that has a region with a view inside. How can I
get a reference to that view?
For example:
var layoutView = Backbone.Marionette.Layout.extend({
regions: {
myRegion: '.some-element'
},
initialize: function(){
this.render();
this.myView.show(new someView());
},
test: function(){
var view = this.myRegion.get() // or something to retrieve the view?
}
});
I mean, I can save the view instance into "this", but surely marionette
must have a way of retrieving it...right?

Url binding on web.config location element

Url binding on web.config location element

I have one site containing several bindings, in example
www.page.com
private.page.com
The www.page.com does have a gallery, ie www.page.com/gallery and so does
the private subsite, private.page.com/gallery
Since I've implemented a .net membership system I like to use the built in
location elements to restrain access, the example below does the trick
just fine
<location path="gallery">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
But I'd like to have it affecting the private.page.com site only. Is there
a way to handle this in web.config?
Thanks

How to include angular syntax in Razor

How to include angular syntax in Razor

Can Angular syntax be included in Razor:
In the code below I am trying to say if "p.name" is not equal to "Select
All" display an image but I dont think I can include {{p.name}} in the if
statement
<div ng-repeat="p in Data.platforms">
<div style="font-size: smaller">
<input type="checkbox" ng-model="p.selected" />
@if ("p.name" != "Select All") {
<img ng-src="{{'/Content/img/'+p.name+'.jpg'}}" width="16"
height="16" alt="{{p.name}}" />
}
{{p.name}}
</div>
</div>

Disable operations of entire table's row

Disable operations of entire table's row

I have a table with user interaction controls in its cells (button, link,
etc.) and I want to "grayed" some rows of that table so all operations of
these rows will be disabled.
Any idea what's the best way to do this in Javascript?

Objective C Sectioned tableview

Objective C Sectioned tableview

I want a sectioned tableview but I don't know how, my situation:
I have 2 arrays
array Date ("12/08/13", "13/08/13", "17/08/13") array Count("2", "1", "5")
The count means how many rows are there in the section.
I have
- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section
{
return [dateArray objectAtIndex:section];
}
But how can make in the first section, 2 rows in the second section 1 row
and in the third section 5 rows.
I hope someone can help me. If you have questions just ask.
Thanks.

Wednesday, 11 September 2013

markerclusterer_compiled.js throwing error for Markers

markerclusterer_compiled.js throwing error for Markers

We are using Google Maps API V3 Markers to show markers in the google map
when we search using location.
Below is the code we are using to call Google api.
script.Append("<script type=\"text/javascript\" language=\"javascript\"
src=\"http://maps.google.com/maps/api/js?v=3&sensor=false\"></script>" +
Environment.NewLine + Environment.NewLine);
script.Append("<script type=\"text/javascript\" language=\"javascript\"

src=\"http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer_compiled.js\"></script>"
+ Environment.NewLine + Environment.NewLine);
script.Append("<script language=\"javascript\" type=\"text/javascript\">" +
Below is the issue :
From 12th Sept 2013, suddenly Markers stopped working and not showing in
the map. Please advice, whether there is any change in code before 12th
Sept 2013. Below is the error we are getting when we tried to search any
location.
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;
Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30;
.NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E;
InfoPath.3) Timestamp: Thu, 12 Sep 2013 03:04:51 UTC
Message: Script error Line: 0 Char: 0 Code: 0 URI:
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer_compiled.js
Error is coming from markerclusterer_compiled.js
Please advice how to fix the issue.

How can i write this code? if(strncmp(wtemp, (temp1->parola), (PAROLA))== 0)

How can i write this code? if(strncmp(wtemp, (temp1->parola), (PAROLA))== 0)

char *wtemp;
struct word *temp1;
//PAROLA is a int
if(strncmp(wtemp, (temp1->parola), (PAROLA))== 0) //this!!
How can i write this code without the function strncmp?

submit model with RenderPartial on View

submit model with RenderPartial on View

So imagine this:
There is a View. There is a model with this view in the following form:
Id
List<Food>
within each Food, there is:
Id
Name
List<Ingredients>
each ingredient contains:
Id
Name
Qty
This is in 1 model.
I have a view which takes in this Model. I then have a partial view which
takes in the List and renders it on the screen. That works however when
the form is submitted (the button is on the main view), the data fails to
bind/is not shown in the Model.
what is the correct way to be able to bind the data back?
it does work when I take the whole thing and put it in the main view
itself but due to reusability reasons, it makes sense having it in a
partial view so I can just "drop" it on any page and pass the data.
Thanks

Clip an image and expand it on click

Clip an image and expand it on click

What I'm looking for is basically a slightly modified lightbox for image
expansion.
The lightbox implementations I've seen basically take an image and pop it
out to its full size when clicked. I've been searching and searching for a
way to accomplish the below, without luck so far.
The problem:
What I want is for the image to be cropped until clicked on, at which
point it should expand to full size (out of flow, like a lightbox) and
uncrop to make the entire image visible.
Here is an example...
At start, the image is displayed as:

--
...then when clicked, it becomes:

Is there a jQuery plugin or some other approach that accomplishes this
clipping/cropping effect (and then expansion upon click)?
Thank you.

Using Start-Process in PSSession

Using Start-Process in PSSession

I've created a pssession on a remote computer and entered that possession.
From within that session I use start-process to start notepad. I can
confirm that notepad is running with the get-process command, and also
with taskmgr in the remote computer. However, the GUI side of the process
isn't showing. This is the sequence I've been using:
$server = New-PSSession -ComputerName myserver -Credential mycreds
Enter-PSSession $server
[$server]: PS C:\>Start-Process notepad -Wait -WindowStyle Maximized
The process is running, but while RDP'd to the box, notepad does not open.
If I open notepad from the server, a new notepad process begins. I also
tried by using the verb parameter like this:
[$server]: PS C:\>Start-Process notepad -Wait -WindowStyle Maximized -Verb
Open
Same result tho... Process starts, but no notepad shows. I've tried this
while remoted into the box (but issued from my local host) as well as
before remoting into the server.

Is there any technical difference between these methods?

Is there any technical difference between these methods?

I have been trying to learn OO JS. I was playing with different patterns,
wrote following example.
var obj = function() {
this.a= function() {
return 'a';
}
}
obj.prototype.b = function() {
return 'b';
}
var instance = new obj();
console.log(instance.a());
console.log(instance.b());
Is there any difference here in function a and b?

Trouble with D3DX10CreateEffectFromFile

Trouble with D3DX10CreateEffectFromFile

I've been having a problem loading an effect file. My call to
D3DX10CreateEffectFromFile() passes with S_OK, but the ID3D10Effect* I
pass into it remains null after the function call. Here is my source (I've
been debugging, so there's stuff commented out, but the relevant code is
still executing).
HRESULT hResult;
void fxMgr::LoadEffectFile( char* fxFileName,
char* techniqueName,
ID3D10Effect* pEffect,
dgInputLayoutType layoutType)
{
/*if (L"fx"!=GetFileExtension(fxFileName))
{
pEffect=NULL;
throw dgGameError(L"Could not load specified shader!");
return;
}
*/
if (NULL==fxFileName)
{
pEffect=NULL;
m_pCurEffect=NULL;
m_pCurEffectTechnique=NULL;
m_pCurPass=NULL;
}
return;
HRESULT r = 0;
DWORD shaderFlags = 0;//D3D10_SHADER_ENABLE_STRICTNESS;
/* #if defined( DEBUG ) || defined( _DEBUG )
// Turn on extra debug info when in debug config
shaderFlags |= D3D10_SHADER_DEBUG;

Tuesday, 10 September 2013

How can I skip the zeros in a matrix?

How can I skip the zeros in a matrix?

I have a matrix with columns filled with zeros and I want to copy the
matrix into a new matrix but to skip the columns with the zeros.
Is there any command that can help me? I tried to do it with the sparse
command but I didn't really understand what happens there. It skips the
zeros but when you want to know how many columns you have in the new
matrix it still shows the initial size.

Set Height Parameters for Android Webview

Set Height Parameters for Android Webview

I try to make specific web pages fit my android webview. Some read the
screen size by using javascript's screen object (screen.width). The
webview delivers the devices Display Properties which i would rather set
myself.
I am also searching for a way to modify the window.innerHeight and width.
Is there any way?

Cant instantiate class: org.primefaces.examples.view.TableBean

Cant instantiate class: org.primefaces.examples.view.TableBean

i have JSF 2 web Page that user choose from menu class_id and data FROM ,
TO .
then prees button that redirects to MainReports page thats have and ready
database Queries that taking Arguments from the Previous page .
but when just choose menu item and and Data FROM and To , o getting that
error in MainReports Page .
Note : MainReports Pgae = TableBean class . Method " doitforclass() " it's
for Menu and Date FROM and TO fileds .
it tells me :
com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class:
org.primefaces.examples.view.TableBean.
at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:193)
at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:102)
at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
at
com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
at
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
at
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72)
at org.apache.el.parser.AstValue.getValue(AstValue.java:161)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIData.getValue(UIData.java:730)
at org.primefaces.component.datatable.DataTable.getValue(DataTable.java:867)
at org.primefaces.component.api.UIData.getDataModel(UIData.java:579)
at javax.faces.component.UIData.getRowCount(UIData.java:355)
at
org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:629)
at
org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:234)
at
org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:196)
at
org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:82)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:437)
at
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
at
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NullPointerException
at org.primefaces.examples.view.TableBean.<init>(TableBean.java:92)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:374)
at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:188)
... 50 more
Method that passing values TO and FROM and Class_id :
public String doitforclass(){
int class_id = 0 ;
try{
Dbconnection NewConnect = new Dbconnection();
Connection con = NewConnect.MakeConnect();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select class_id from
class where class_name ='" + classname + "'" );
while(rs.next()){
class_id = rs.getInt(1);
}
//classname = String.valueOf(class_id);
System.out.println(String.valueOf(class_id));
System.out.println(from);
System.out.println(to);
return "MainReports.xhtml?faces-redirect=true&class_id=" +
String.valueOf(class_id)
+ "&from=" + from + "&to=" + to;
} catch(Exception ex){
System.out.println(ex);
}
return "MainReports.xhtml?faces-redirect=true&class_id=" +
String.valueOf(class_id)
+ "&from=" + from + "&to=" + to;
}
TableBean Constractor:
public TableBean() {
String SID = FacesContext.getCurrentInstance().getExternalContext()
.getRequestParameterMap().get("SID");
String from = FacesContext.getCurrentInstance().getExternalContext()
.getRequestParameterMap().get("from");
String to = FacesContext.getCurrentInstance().getExternalContext()
.getRequestParameterMap().get("to");
String class_id = FacesContext.getCurrentInstance()
.getExternalContext().getRequestParameterMap().get("class_id");
if (SID.equalsIgnoreCase("null")) {
try {
Dbconnection NewConnect = new Dbconnection();
Connection con = NewConnect.MakeConnect();
Statement stmt = con.createStatement();
ResultSet rs = stmt
.executeQuery("SELECT a.course_id, a.teacher_id,
a.class_id, a.day_id, a.state, a.apssent_date,
a.interval_id,s.student_id,s.first_name FROM Student
AS s INNER JOIN Apsent AS a ON s.student_id =
a.student_id where apssent_date between '"
+ from
+ "' and '"
+ to
+ "' and a.class_id = "
+ Integer.parseInt(class_id));
List<Integer> ids = new ArrayList<Integer>();
List<String> names = new ArrayList<String>();
List<Integer> intervals = new ArrayList<Integer>();
List<Integer> teachers = new ArrayList<Integer>();
List<String> dates = new ArrayList<String>();
final List<String> state = new ArrayList<String>();
while (rs.next()) {
ids.add(rs.getInt(8));
names.add(rs.getString(9));
intervals.add(rs.getInt(7));
teachers.add(rs.getInt(2));
dates.add(rs.getString(6));
state.add(rs.getString(5));
}
} catch (Exception ex) {
System.out.println(ex);
}
}
System.out.println(SID + from + class_id + to);
if (Integer.parseInt(SID) > 0) {
try {
Dbconnection NewConnect = new Dbconnection();
Connection con = NewConnect.MakeConnect();
Statement stmt = con.createStatement();
ResultSet rs = stmt
.executeQuery("SELECT a.course_id, a.teacher_id,
a.class_id, a.day_id, a.state, a.apssent_date,
a.interval_id,s.student_id,s.first_name FROM Student
AS s INNER JOIN Apsent AS a ON s.student_id =
a.student_id where apssent_date between '"
+ from
+ "' and '"
+ to
+ "' and s.student_id = " + SID);
List<Integer> ids = new ArrayList<Integer>();
List<String> names = new ArrayList<String>();
List<Integer> intervals = new ArrayList<Integer>();
List<Integer> teachers = new ArrayList<Integer>();
List<String> dates = new ArrayList<String>();
final List<String> state = new ArrayList<String>();
while (rs.next()) {
// System.out.println(rs.getInt(1));
ids.add(rs.getInt(8));
names.add(rs.getString(9));
intervals.add(rs.getInt(7));
teachers.add(rs.getInt(2));
dates.add(rs.getString(6));
state.add(rs.getString(5));
}
carsSmall = new ArrayList<Car>();
populateRandomCars(carsSmall, ids.size(), ids, names,
intervals, teachers, dates, state);
} catch (Exception ex) {
System.out.println(ex);
}
}
}