Saturday, 31 August 2013

Strange Stack Overflow Error in Sudoko Backtracker

Strange Stack Overflow Error in Sudoko Backtracker

(Disclaimer: There are maybe 20 different versions of this question on SO,
but a reading through most of them still hasn't solved my issue)
Hello all, (relatively) beginner programmer here. So I've been trying to
build a Sudoku backtracker that will fill in an incomplete puzzle. It
seems to works perfectly well even when 1-3 rows are completely empty
(i.e. filled in with 0's), but when more boxes start emptying
(specifically around the 7-8 column in the fourth row, where I stopped
writing in numbers) I get a Stack Overflow Error. Here's the code:
import java.util.ArrayList;
import java.util.HashSet;
public class Sudoku
{
public static int[][] puzzle = new int[9][9];
public static int filledIn = 0;
public static ArrayList<Integer> blankBoxes = new ArrayList<Integer>();
public static int currentIndex = 0;
public static int runs = 0;
/**
* Main method.
*/
public static void main(String args[])
{
//Manual input of the numbers
int[] completedNumbers = {0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,3,4,
8,9,1,2,3,4,5,6,7,
3,4,5,6,7,8,9,1,2,
6,7,8,9,1,2,3,4,5,
9,1,2,3,4,5,6,7,8};
//Adds the numbers manually to the puzzle array
ArrayList<Integer> completeArray = new ArrayList<>();
for(Integer number : completedNumbers) {
completeArray.add(number);
}
int counter = 0;
for(int i = 0; i < 9; i++) {
for(int j = 0; j < 9; j++) {
puzzle[i][j] = completeArray.get(counter);
counter++;
}
}
//Adds all the blank boxes to an ArrayList.
//The index is stored as 10*i + j, which can be retrieved
// via modulo and integer division.
boolean containsEmpty = false;
for(int i = 0; i < 9; i++) {
for(int j = 0; j < 9; j++) {
if(puzzle[i][j] == 0) {
blankBoxes.add(10*i + j);
containsEmpty = true;
}
}
}
filler(blankBoxes.get(currentIndex));
}
/**
* A general method for testing whether an array contains a
* duplicate, via a (relatively inefficient) sort.
* @param testArray The int[] that is being tested for duplicates
* @return True if there are NO duplicate, false if there
* are ANY duplicates.
*/
public static boolean checkDupl(int[] testArray) {
for(int i = 0; i < 8; i++) {
int num = testArray[i];
for(int j = i + 1; j < 9; j++) {
if(num == testArray[j] && num != 0) {
return false;
}
}
}
return true;
}
/**
* If the puzzle is not full, the filler will be run. The filler is my
attempt at a backtracker.
* It stores every (i,j) for which puzzle[i][j] == 0. It then adds 1
to it's value. If the value
* is already somewhere else, it adds another 1. If it is 9, and
that's already there, it loops to
* 0, and the index beforehand is rechecked.
*/
public static void filler(int indexOfBlank) {
//If the current index is equal to the size of blankBoxes, meaning
that we
//went through every index of blankBoxes, meaning the puzzle is
full and correct.
runs++;
if(currentIndex == blankBoxes.size()) {
System.out.println("The puzzle is full!" + "\n");
for(int i = 0; i < 9; i++) {
System.out.println();
for(int j = 0; j < 9; j++) {
System.out.print(puzzle[i][j]);
}
}
System.out.println("\n" + "The filler method was run " + runs
+ " times");
return;
}
//Assuming the puzzle isn't full, find the row/column of the
blankBoxes index.
int row = blankBoxes.get(currentIndex) / 10;
int column = blankBoxes.get(currentIndex) % 10;
//Adds one to the value of that box.
puzzle[row][column] = (puzzle[row][column] + 1);
//Just used as a breakpoint for a debugger.
if(row == 4 && column == 4){
int x = 0;
}
//If the value is 10, meaning it went through all the possible
values:
if(puzzle[row][column] == 10) {
//Do filler() on the previous box
puzzle[row][column] = 0;
currentIndex--;
filler(currentIndex);
}
//If the number is 1-9, but there are duplicates:
else if(!(checkSingleRow(row) && checkSingleColumn(column) &&
checkSingleBox(row, column))) {
//Do filler() on the same box.
filler(currentIndex);
}
//If the number is 1-9, and there is no duplicate:
else {
currentIndex++;
filler(currentIndex);
}
}
/**
* Used to check if a single row has any duplicates or not. This is
called by the
* filler method.
* @param row
* @return
*/
public static boolean checkSingleRow(int row) {
return checkDupl(puzzle[row]);
}
/**
* Used to check if a single column has any duplicates or not.
* filler method, as well as the checkColumns of the checker.
* @param column
* @return
*/
public static boolean checkSingleColumn(int column) {
int[] singleColumn = new int[9];
for(int i = 0; i < 9; i++) {
singleColumn[i] = puzzle[i][column];
}
return checkDupl(singleColumn);
}
public static boolean checkSingleBox(int row, int column) {
//Makes row and column be the first row and the first column of
the box in which
//this specific cell appears. So, for example, the box at
puzzle[3][7] will iterate
//through a box from rows 3-6 and columns 6-9 (exclusive).
row = (row / 3) * 3;
column = (column / 3) * 3;
//Iterates through the box
int[] newBox = new int[9];
int counter = 0;
for(int i = row; i < row + 3; i++) {
for(int j = row; j < row + 3; j++) {
newBox[counter] = puzzle[i][j];
counter++;
}
}
return checkDupl(newBox);
}
}
Why am I calling it a weird error? A few reasons:
The box that the error occurs on changes randomly (give or take a box).
The actual line of code that the error occurs on changes randomly (it
seems to always happen in the filler method, but that's probably just
because that's the biggest one.
Different compilers have different errors in different boxes (probably
related to 1)
What I assume is that I just wrote inefficient code, so though it's not an
actual infinite recursion, it's bad enough to call a Stack Overflow Error.
But if anyone that sees a glaring issue, I'd love to hear it. Thanks!

Printed page information within PDF file

Printed page information within PDF file

I just opened my PDF file using the default PDF reader on Ubuntu, and when
I tried to print it, the "Pages" box was already filled with "108-115". I
was surprised, because that's the page number that I printed from this
file last time, which was many days ago!
I wonder where the "last printed page information" is stored. Is it in the
PDF file itself, or is it somewhere else in the computer?

How do you add mysql-connector-java-5.1.26 to Eclipse Android Developer Tools

How do you add mysql-connector-java-5.1.26 to Eclipse Android Developer Tools

I want the following line of code to work in Eclipse Java but apparently I
need to import/add mysql-connector-java-5.1.26 to my eclipse android
project so I can send a mySQL query via an android device.
Class.forName("com.mysql.jdbc.Driver");
How can I add the mySQL library to a current project? I've seen other
tutorials about doing this here at stack overflow but they've been kind of
unspecific and just say "just ADD it to your current project" but that's
where I'm stumped.
Most tutorials online just tell you how to start a new project from
scratch, but I'm working with an android application.
Do I go to File>Import? and then select the .zip with the mySQL files? Or
do I select the folder or something? I'm doing this on a Mac.
Thanks.

View not attached to window manager exception even isfinishing is called

View not attached to window manager exception even isfinishing is called

I keep getting this exception "View not attached to window manager"
reports from ACRA and it is always happening around my dialog.dismiss() in
my async task. I have searched SO and I added the (!isFinishing())
condition but I still get it. Can you please tell me how I can solve it?
Here is a sample code where it happens
private class MyAsyncTask extends AsyncTask<String, Void, Void> {
private ProgressDialog dialog;
private PropertyTask asyncTask;
public MyAsyncTask (PropertyTask task){
this.asyncTask = task;
}
@Override
protected void onPreExecute() {
dialog = ProgressDialog.show(ListTasksActivity.this, "Please
wait..", "working..", true);
}
@Override
protected Void doInBackground(String... params) {
//Some DB work here
return null;
}
@Override
protected void onPostExecute(Void result) {
if(!isFinishing()){
dialog.dismiss(); <-------- Problem happens
}
}
}

How to add two UITableViews to ViewController in storyboard?

How to add two UITableViews to ViewController in storyboard?

In my app, I want to handle 2 tables in one ViewController.
First I drag a UITableViewController into NavigationController, so there
is already a UITableView.
Then I drag another UITableView to the scene, but the second UITableView
can't be placed at the same level as first UITableView, it can only be a
subview of first UITableView or replace the first UITableView. Here is the
structs, please help.

What is best Ruby Class design / pattern for this scenario?

What is best Ruby Class design / pattern for this scenario?

I currently have this class for scraping products from a single retailer
website using Nokogiri. XPath, CSS path details are stored in MySQL.
ActiveRecord::Base.establish_connection(
:adapter => "mysql2",
...
)
class Site < ActiveRecord::Base
has_many :site_details
def create_product_links
# http://www.example.com
p = Nokogiri::HTML(open(url))
p.xpath(total_products_path).each {|lnk|
SiteDetail.find_or_create_by(url: url + "/" + lnk['href'], site_id:
self.id)}
end
end
class SiteDetail < ActiveRecord::Base
belongs_to :site
def get_product_data
# http://www.example.com
p = Nokogiri::HTML(open(url))
title = p.css(site.title_path).text
price = p.css(site.price_path).text
description = p.css(site.description_path).text
update_attributes!(title: title, price: price, description: description)
end
end
I will be adding more sites (around 700) in the future. Each site have a
different page structure. So get_product_data method cannot be used as is.
I may have to use case or if statement to jump and execute relevant code.
Soon this class becomes quite chunky and ugly (700 retailers).
What is the best design approach suitable in this scenario?

content is undefined,error is Error:ENOENT,open 'C:\Windows\system32\hello.txt'

content is undefined,error is Error:ENOENT,open
'C:\Windows\system32\hello.txt'

i just started learning node. and here is my problem,i got sample.js file
var fs=require("fs");
console.log("starting");
fs.readFile("hello.txt" , function(error,data){
console.log("content is asdas " + data);
});
console.log("executed");
and hello.txt with content ,they both are on my desktop
hello
when i run as administrator in powershell or cmd this code
C:\Windows\system32\ node C:\Users\X\Desktop\sample.js
i get
starting
executing
content is asdas undefined
when i log error
var fs=require("fs");
console.log("starting");
fs.readFile("hello.txt" , function(error,data){
console.log("content is asdas " + error);
});
console.log("executed");
i get
starting
executing
content is asdas Error:ENOENT,open 'C:\Windows\system32\hello.txt'
So i guess that error is that node is looking in system32,not in desktop...?
Thanks!

multi string replace with one string

multi string replace with one string

multi string replace with one string
I want replace all unwanted string with one
i.e
$string='a','b','c','d','e','@','#','%','!';
$replace='';
str_replace($string,$replace,"afsdfasdfasdfasd #%^#^%#@@ ");

Friday, 30 August 2013

Theme my Login wordpress plugin how to add a filter/change lost password link?

Theme my Login wordpress plugin how to add a filter/change lost password
link?

I really don't know how to add custom filter for Theme my login plugin in
to my function.php.
Can someone give me a solution please ?
Thanks !
:)

Thursday, 29 August 2013

How to plot shapefiles on Bing Map

How to plot shapefiles on Bing Map

How can I use shapefile(.shp) with bing maps without using any third party
reference? I just want to use bing maps api library to perform this
action. So suggest me how can i achieve this?

Production and Development in WAMP

Production and Development in WAMP

I'm trying to output errors in WAMP, I know there's production and
development mode's.
But how do you switch between the modes? How can i define that i'm now in
development and now in production. Or am I getting this totally wrong?
Thanks

Wednesday, 28 August 2013

ListItem not selectable

ListItem not selectable

I have a web based chat application. My issues is that the div that
displays the chat message is not selectable. Nor does it convert email
addresses, urls into links, or render smilies. For the android based
version of the app adding android:textIsSelectable="true" and
android:autoLink="web|all" how do I make this adjustment in html?
var chatmsg='<li id="cmt-'+msgId+'">\
<a href="#gprofile"
onclick="showProfile('+userId+')"><div
class="commentInfo" onclick=""><img src="'+picture+'"
height="40" /><span
style="font-weight:bold;color:blue;text-decoration:underline;"
onchange="fullScreen();"
'+gclass+'>'+userName+'</span><br /><small
class="commentDateStamp">'+datetime+'</small></div></a>\
<div class="comment">\
<p>'+textmsg+'</p>\
</div>\
<div style="clear:both;"></div>\
</li>';
if (userName!="SYSTEM")
$("#ulcmessages").append(chatmsg);

C inserting string into char pointer

C inserting string into char pointer

Hi all I trying to assign string into a char * pointer. Below is how I am
doing but I am getting this warning: assignment makes integer from pointer
without a cast.
What is the correct why to deal with strings in C ?
char* protoName = "";
if(h->extended_hdr.parsed_pkt.l3_proto==0)
*protoName = "HOPOPT";
else if(h->extended_hdr.parsed_pkt.l3_proto==1)
*protoName = "ICMP";
else if(h->extended_hdr.parsed_pkt.l3_proto==2)
*protoName = "IGMP";
else if(h->extended_hdr.parsed_pkt.l3_proto==3)
*protoName = "IGMP";
else if(h->extended_hdr.parsed_pkt.l3_proto==4)
*protoName = "IGMP";
char all[500];
sprintf(all,"IPv4','%s'",* protoName);

How to create External data-source in html5

How to create External data-source in html5

In html5 the input field has the following format
<input type='text', data-provide= "typeahead", data-items="4",
autocomplete="off", data-source='["Business and Commercial Laws",
"Consumer Laws", "Criminal Laws"]', name='userInputName',
placeholder='Court of practice'> Data </input>
How do i create link the above tag with a data-source which is not inline,
but external. I ultimately want to re-use the data-source.

Want to achieve hung div

Want to achieve hung div

I want top: -50px; for cases the scrollbar is between 0 and 50. When the
scrollbar goes down, I want the .articlebutton to hung and stuck to zero
margin of the screen, which will be calculated by the difference between
between scrollbar - 50px, I Think I might have some syntax error. Any help
kindly appreciated.
http://jsfiddle.net/LhL7u/2/
var difference = scrollTop - 50px;
$(window).scroll(function () {
if ($(window).scrollTop() > 50) {
$(".articlebutton").css("top", "difference");
}
else {
$(".articlebutton").css("top", "-50px");
}
});

Why do we need to create android service

Why do we need to create android service

This is very basic question but I am unable to figure it out because as I
read that Service runs on main thread. So why do we need to create a
Service? and because for intense CPU task we need to create Async task or
thread in Service then why don't we create them in activity or application
class?
I wanted to create a service which will continuously perform a set of task
when it is started. I can't find any method in Service which will run in
loop. Is there is such method? or do I have to create a thread in service
to set a loop?

Tuesday, 27 August 2013

How to mix 2 audio files in ios using AVFoundation

How to mix 2 audio files in ios using AVFoundation

I am trying to mix two audio files into one, the code does not work for
me.. can anyone help me on this ?
NSString *documentDirectory =
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,
YES) objectAtIndex:0];
NSURL *audioURL = [[NSBundle mainBundle] URLForResource:@"sample"
withExtension:@"mp3"];
NSURL *audioURL2 = [[NSBundle mainBundle] URLForResource:@"sample2"
withExtension:@"mp3"];
AVURLAsset* audioAsset = [[AVURLAsset alloc]initWithURL:audioURL
options:nil];
AVURLAsset* audioAsset2 = [[AVURLAsset alloc]initWithURL:audioURL2
options:nil];
AVMutableComposition* mixComposition = [AVMutableComposition composition];
AVMutableCompositionTrack *compositionCommentaryTrack = [mixComposition
addMutableTrackWithMediaType:AVMediaTypeAudio
preferredTrackID:kCMPersistentTrackID_Invalid];
[compositionCommentaryTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero,
audioAsset.duration)
ofTrack:[[audioAsset
tracksWithMediaType:AVMediaTypeAudio]
objectAtIndex:0]
atTime:kCMTimeZero error:nil];
AVMutableCompositionTrack *compositionAudioTrack = [mixComposition
addMutableTrackWithMediaType:AVMediaTypeAudio
preferredTrackID:kCMPersistentTrackID_Invalid];
[compositionAudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero,
audioAsset.duration)
ofTrack:[[audioAsset2
tracksWithMediaType:AVMediaTypeAudio]
objectAtIndex:0]
atTime:kCMTimeZero error:nil];
AVAssetExportSession* _assetExport = [[AVAssetExportSession alloc]
initWithAsset:mixComposition
presetName:AVAssetExportPresetPassthrough];
NSString *soundFilePath = [documentDirectory
stringByAppendingPathComponent: @"audioJoined.m4a"];
NSLog(@"soundFilePath:%@", soundFilePath);
NSURL *savetUrl = [NSURL fileURLWithPath:soundFilePath];
if ([[NSFileManager defaultManager] fileExistsAtPath:soundFilePath])
{
[[NSFileManager defaultManager] removeItemAtPath:soundFilePath
error:nil];
}
_assetExport.outputFileType = @"com.apple.m4a-audio";
_assetExport.outputURL = savetUrl;
_assetExport.shouldOptimizeForNetworkUse = YES;
[_assetExport exportAsynchronouslyWithCompletionHandler:
^(void ) {
NSLog(@"fileSaved !");
}
];

Most effecient way to migrate related tables from one Microsoft Access Web App to another?

Most effecient way to migrate related tables from one Microsoft Access Web
App to another?

I've got two Microsoft Access 2013 Web Apps, hosted in SharePoint 2013 as
part of Microsoft Office365. Both databases contain roughly the same
tables and structure (with some minor tweaks).
We have two databases because our particular SharePoint server encountered
a fluke error and irreparably corrupted the UI for the first Access Web
App. In the end it was more cost-effective to just build a second Access
Web App from scratch, rather then try to reverse the corruption in the
original.
So now I have the duplicate created and functional, but I need to migrate
data. The SQL backend for the original Web App is still fully functional,
and the UI within Microsoft Access is also fully functional (it's the
SharePoint side that got broken). So with Microsoft Access 2013 and SQL
Management Studio available as my tools, what is the most efficient way to
move data from one database to another? (Excel can connect and pull data,
but can't insert records in the new database as far as I can tell, making
it relatively useless. Let me know if I'm missing something here.)
Some of the problems I run into are, I don't have owner, DBA, or SysAdmin
access to SQL - just data read and data write. I can't run any SQL queries
that alter the table, such as renaming a column or SET IDENTITY_INSERT
etc. (Was tinkering with setting the identity column, as one way of
preserving existing relationships between records.) Additionally, Access
2013 doesn't provide the full ribbon for Web Apps, but instead only
provides extremely limited functionality (screenshot below). Additionally,
the query and macro buttons do not allow you to create queries or macros
directly via code (SQL, VBA, etc.), but rather they force you to only use
the query wizard GUI and macro GUI, and they do not allow you to connect
to another database to pull data.
With these constraints, what is the best way to migrate existing data from
the first database into the second?

Adding whitespace handling to existing Java regex

Adding whitespace handling to existing Java regex

A long time ago I wrote a method called detectBadChars(String) that
inspects the String argument for instances of so-called "bad" characters.
The original list of bad characters was:
'~'
'#'
'@'
'*'
'+'
'%'
My method, which works great, is:
// Detects for the existence of bad chars in a string and returns the
// bad chars that were found.
protected String detectBadChars(String text) {
Pattern pattern = Pattern.compile("[~#@*+%]");
Matcher matcher = pattern.matcher(text);
StringBuilder violatorsBuilder = new StringBuilder();
if(matcher.find()) {
String group = matcher.group();
if (!violatorsBuilder.toString().contains(group))
violatorsBuilder.append(group);
}
return violatorsBuilder.toString();
}
The business logic has now changed, and the following are now also
considered to be bad:
Carriage returns (\r)
New lines (\n)
Tabs (\t)
Any consecutive whitespaces (" ", " ", etc.)
So I am trying to modify the regex to accomodate the new bad characters.
Changing the regex to:
Pattern pattern = Pattern.compile("[~#@*+%\n\t\r[ ]+]");
...throws exceptions. My thinking was that adding "\n\t\r" to the regex
would allot for newlines, tabs and CRs respectively. And then adding "[
]+" adds a new "class/group" consisting of whitespaces, and then
quantitfies that group as allowing 1+ of those whitespaces, effectively
taking care of consecutive whitespaces.
Where am I going awyre and what should my regex be (and why)? Thanks in
advance!

how to check if a UIViewController is in the middle of being animated on screen

how to check if a UIViewController is in the middle of being animated on
screen

Can I see somehow from, say UIViewController A, if UIViewController B is
in the middle of the animation of being presented on screen?
I know I can add code to UIViewController B (for example some boolean
value used in viewWillAppear, viewDidAppear or in the completion block of
presentViewController:animated:completion:), but I also have
UIViewController C, D, E, F etc. So I prefer to check this only in
UIViewController A if possible.
Does anyone if this can be done and in case of 'yes, it can', how..?
Thanks in advance.

less.css change theme variable in case of id

less.css change theme variable in case of id

In my less file I define a variable theme colour as: @primaryColour: red;
But when the id of my body changes, I want to change the overall theme
colour to '@primaryColour: blue;
How do I re-define this theme colour? This doesn't work:
@primaryColour: red;
body#secondTheme {
@primaryColour: yellow;
}

Add View to Main User Control difficulty

Add View to Main User Control difficulty

Im building an extension for an app here's my problem.
There is a main Layout xaml page and this binds to the main applications
datasource(meaning you can use different layouts on the app)
I created a View that I would like to place on this layout page. My view
has its own view model which gets set once the "tool" gets clicked in the
application.
From debugging it hits my viewmodel everytime but never updates anything.
I add my view to the main layout like
<!--Begin Custom Tab Item-->
<sdk:TabItem Name="StatisticsTabItem" Cursor="Hand"
Visibility="Visible">
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Add Stats view here-->
<views:StatisticsView x:Name="StatsView"
DataContext="{Binding
BindsDirectlyToSource=True}" Grid.Row="1"/>
</Grid>
</sdk:TabItem>
So currently It sets a label on my view everytime and set its correctly
but nothing gets updated on the actual view within the main layout xaml
I did set up my label as
private string totalPop;
public string TotalPop
{
get { return totalPop; }
set
{
if (totalPop != value)
{
totalPop = value;
OnNotifyPropertyChanged("TotalPop");
}
}
}
<sdk:Label x:Name="lbltotPop" Grid.Row="1" Grid.Column="0"
Grid.ColumnSpan="2" Content="{Binding TotalPop}" />
In my other applications it works fine but dont know how to set the
binding to my view gets updated.

Monday, 26 August 2013

Using Flot with multiple with orderbars.js and categories

Using Flot with multiple with orderbars.js and categories

I am having trouble creating multiple bars with flot. There is a plugin
that can be downloaded here:
http://www.benjaminbuffet.com/public/js/jquery.flot.orderBars.js that
makes graphs with multiple bars per x category like this:
http://www.pikemere.co.uk/blog/tutorial-flot-how-to-create-bar-charts/
(see under the customized bar charts). However, his example is a bit
different in that it uses the time function rather than categories.
Here is my code:
<!doctype html>
<head>
<script language="javascript" type="text/javascript"
src="/flot/jquery.js"></script>
<script language="javascript" type="text/javascript"
src="/flot/jquery.flot.js"> </script>
<script language="javascript" type="text/javascript"
src="/flot/jquery.flot.categories.js"></script>
<script language="javascript" type="text/javascript"
src="/flot/jquery.flot.orderBars.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var data1 = [
{
label: "Male" ,
data: [["True", 1],["False", 2]] ,
bars: {
show: true,
barWidth: 0.13,
order: 1
}
},
{
label: "Female" ,
data: [["True", 3],["False", 4]],
bars: {
show: true,
barWidth: 0.13,
order: 2
}
}
];
$.plot($("#placeholder"), data1, {
xaxis: {
mode: "categories"
},
});
});
</script>
<title>Test</title>
</head>
<body>
<div id="placeholder" style="width:600px;height:300px"></div>
</body>
</html>
With the above code, the graph displays, but without any bars. If I remove
the order:1 and order:2, it displays correctly, except with the bars
overlapping each other rather than being offset by each other (I think it
just ignores the orderbars plugin).
This is a very simplified example of what I really want to do, but if
someone knows how I can get it to do what I want fairly simply, I would be
very much appreciative.
To sum up, what I want is to have two sets of two bars. The first set with
"True" under them and the second second set with "False" under them. I do
not want to use numbers to represent the values, if possible as it will
greatly complicate my more complex situation. But if I must, I would still
like to know how to do it that way.

NSObject's category is available for every NSObject subclass even without any import of this category's .h file anywhere

NSObject's category is available for every NSObject subclass even without
any import of this category's .h file anywhere

Background.
Please consider the following steps:
1) In Xcode create a new "Single View Application".
2) Create a category NSObject+Extension.h and .m files:
// .h
@interface NSObject (Extension)
- (void)someMethod;
@end
// .m
@implementation NSObject (Extension)
- (void)someMethod {
NSLog(@"someMethod was called");
}
@end
3) Ensure that NSObject+Extension.m file is included into a main target.
4) Add the following line to AppDelegate:
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSString new] performSelector:@selector(someMethod)];
return YES;
}
5) Ensure that #import "NSObject+Extension.h line does not exists anywhere
in the app!
6) Run Application.
The output is
2013-08-27 04:12:53.642 Experimental[32263:c07] someMethod was called



Questions
I wonder if there is no any #import of this category anywhere in the app,
how is it even possible that NSString does still have NSObject+Extension
available? This behavior makes me feeling very bad about every Objective-C
category I declare because I want the categories I declare to be available
only in the scopes they are declared within. For example, I want NSObject
to be extended by Extension only in some class but not in the whole app
because its globalspace becomes "polluted" otherwise.
Is there a way to avoid this behavior? I do want my categories to work
only when I explicitly import them, not when I just have them linked to a
target I use to run.

How can I disable the automatic ReadyBoost test in Windows 7?

How can I disable the automatic ReadyBoost test in Windows 7?

Whenever I request the Properties dialog (which includes a ReadyBoost tab)
for a flash device in Windows 7, it does an automatic test to determine
whether the device is suitable for ReadyBoost.
I never want to use ReadyBoost. This is an unnecessary delay, and
potentially a cause of unnecessary writes to devices that can only take so
many writes (admittedly a lot) before they wear out.
Is it possible to disable these automatic tests, e.g. with a registry hack?

tikz problem (non-continuous function)

tikz problem (non-continuous function)

I want to plot a function (x^3)/((x^2)-1) but it doesn't work.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[domain=-5:5,smooth]
\draw[->] (-5,0) -- (5,0) node[right] {$x$};
\draw[->] (0,-5) -- (0,5) node[above] {$y$};
\draw [color=blue, thick] plot ({\x},{pow(\x,3)/(pow(\x,2)-1)});
\end{tikzpicture}
\end{document}
It does something like this. It should be non-continuous function, not this.

How to fix it? Thanks.

How to update values in a software from a site?

How to update values in a software from a site?

I have a project in which i have to update multiple (numerical) values in
a software.This is is similar to a Stock market trading or demat terminal.
How to they update the values of so many stocks every time they change ,
or at least a few times a second??
I tried doing the same firstly in C by using fscanf , but it took infinite
time and was very inefficient.
I also tried doing it in php but that also took a long time. Moreover in
this case and even in the previous case , it first tried to open the page
from which the values are updated, which itself took long time on slow
internet speeds.
I am planning to start the whole thing again , from scratch.
Please help me with the following
firstly , some details about how the update is performed in existing demat
trading softwares? next, which platform would be the best for the job ?
and how to do it?

Is it better to embed a view controller or add a subview?

Is it better to embed a view controller or add a subview?

For example, if I required a UITableView to appear beneath additional
content in a view, would it be best practice to either:
add a UITableView as a subview, or
add a container view holding a UITableViewController?
As far as I know, both would provide the same user experience, however I
am interested to know which method would be considered best practice?

Could not load file or assembly 'Microsoft.Threading.Tasks.Extensions.Desktop' or one of its dependencies. The parameter is incorrect

Could not load file or assembly
'Microsoft.Threading.Tasks.Extensions.Desktop' or one of its dependencies.
The parameter is incorrect

I am developing Web Application to upload file on Google Drive but it
gives exception as :- Could not load file or assembly
'Microsoft.Threading.Tasks.Extensions.Desktop' or one of its dependencies.
The parameter is incorrect. (Exception from HRESULT: 0x80070057
(E_INVALIDARG)) I don't know What it means? Please help me...

Text is overflowing out of my panel in bootstrap

Text is overflowing out of my panel in bootstrap

The text inside the div panel is overflowing out of its boundary at
sometimes unpredictably. I can't even pinpoint the source of the problem.
Can anyone tell me why is it happening or how can i permanently solve
this? Here's the screenshot!

Typescript generating redundant variable

Typescript generating redundant variable

Consider the following Typescript code:
module demoAppModule{
'use strict';
export module nest{
export var hello = function () {
alert('Hello!');
};
}
}
demoAppModule.nest.hello();
After transpiling we have the following javascript code:
var demoAppModule;
(function (demoAppModule) {
'use strict';
(function (nest) {
nest.hello = function () {
alert('Hello!');
};
})(demoAppModule.nest || (demoAppModule.nest = {}));
var nest = demoAppModule.nest;
})(demoAppModule || (demoAppModule = {}));
demoAppModule.nest.hello();
Why is this line generated? It hurts my eyes.
var nest = demoAppModule.nest;

Sunday, 25 August 2013

Multidimensional array search and replace does not works

Multidimensional array search and replace does not works

I have a function which recognize my $schema,
According my $schema['replace'] it replaces values.
My function fails. Doesnot works as expected.
Any one can help me? to complete my function
$schema = array(
array(
'tag' => 'div',
'class' => 'lines',
'repeat' => array(
'tag' => 'div',
array(
'tag' => 'span',
'style' => 'margin:10px; padding:10px',
'key' => 'title',
),
'key' => 'subject',
)
)
);
$repeat = array('Country Name' => 'Usa', 'City Name' => 'Newyork');
function repeat($schema, $repeat){
foreach($schema as $k => $v){
if($k == 'repeat'){
foreach($repeat as $rk => $rv){
$repeat[] =
array_replace($schema,array_fill_keys(array_keys($schema,
'title'),$rk));
$repeat[] =
array_replace($schema,array_fill_keys(array_keys($schema,
'subject'),$rv));
}
}
}
unset($schema[0]['repeat']);
$schema['repeat'] = $repeat;
return $schema;
}
print_r(repeat($schema, $repeat));
EXPECTED OUTPUT
Array
(
[0] => Array
(
[tag] => div
[class] => lines
[0] => Array
(
[tag] => div
[0] => Array
(
[tag] => span
[style] => margin:10px; padding:10px
[key] => Country Name
)
[key] => Usa
)
[1] => Array
(
[tag] => div
[0] => Array
(
[tag] => span
[style] => margin:10px; padding:10px
[key] => City Name
)
[key] => Newyork
)
)
)
Whats wrong with my function?

If element is set in C++ std::map?

If element is set in C++ std::map?

How to find out if an element in std::map storage is set? Example:
#include <map>
#include <string>
using namespace std;
map<string, FOO_class> storage;
storage["foo_el"] = FOO_class();
Is there something like if (storage.isset("foo_el")) ?

mailchimp api 2.0 subscribe through php?

mailchimp api 2.0 subscribe through php?

I need an example of how to subscribe a email address to mailchimp
newsletter.
Please check new api link here:
https://bitbucket.org/mailchimp/mailchimp-api-php
This is new malichimp api and I am not sure how to use it. :(
For MailChimp 2.0 API, not for 1.3.
Please somebody provide an example on how to subscribe user to mailchimp.
Thank You.

Website Error giving error 400 bad request on submit [PHP]

Website Error giving error 400 bad request on submit [PHP]

Till last week my website was working ok.Now there is one problem like
after adding enctype="multipart/formdata" the action page is giving error
400 badrequest
Main page:http://hmd.ae/test.php
at the bottom of page there is one submit
Any help is appreciated .Is there anyway that i can have a workaround
using .htaccess.
Regards
Liya

Saturday, 24 August 2013

Why %d is require before entering character?

Why %d is require before entering character?

I have tried following code there is require %d before entering character.
That is an after switch loop in code.
#include<stdio.h>
#include<conio.h>
void sum();
void mul();
void main()
{
char ch;
int c;
clrscr();
do
{
printf("\n\n Enetr choice ");
printf("\n\n\t 1: SUM \n\n\t 2: MUL");
scanf("\n\n\t %d",&c);
switch(c)
{
case 1:
sum();
break;
case 2:
mul();
break;
default:
printf("\n\n hhhh..... ");
}
printf("\n\n Want u calcualte again");
//scanf("%d");
scanf("%c",&ch);
printf("\n ch value is %c",ch);
}while(ch=='y'|| ch=='Y');
getch();
}
void sum()
{
int s;
s=10+50;
printf(" SUM: %d",s);
}
void mul()
{
int s;
s=10*50;
printf(" SUM: %d",s);
}
Here in this code after switch I tried to input character but without the
scanf statement which is in comment is require while you input character.
without that scanf statement compiler does not take character input. so
please give me solution.

update does not match the base in sql server.

update does not match the base in sql server.

//the email binds to the variable. however the "base" does not enter code
here//Question1 - Checkbox1 if (CheckBox1.Checked == true) {
SqlConnection con = new SqlConnection("Server=(local);
Database=SURVEY; Trusted_Connection=True;");
String sql = "UPDATE INQUIRY2 set Question1 = @str WHERE email =
@email AND base = @base;";
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
DataTable theDataTable = null;
// Verify that dt is actually in session before trying to get it
if(Session["dt"] != null)
{
theDataTable = Session["dt"] as DataTable;
}
//Verify that the data table is not null
if(theDataTable != null)
{
email = theDataTable.Rows[0]["email"].ToString();
base1 = theDataTable.Rows[0]["base"].ToString();
}
str = str + CheckBox1.Text + 'x';
cmd.Parameters.AddWithValue("@email", email);
cmd.Parameters.AddWithValue("@str", str);
cmd.Parameters.AddWithValue("@base", base1);
cmd.ExecuteNonQuery();
con.Close();
}

How to get a timestamp that is guaranteed to differ every time it's fetched?

How to get a timestamp that is guaranteed to differ every time it's fetched?

To generate global unique ids, I need something like a timestamp of their
creation. But those ids can be generate directly after each other in
source code. So the time with milliseconds isn't accurate enough and could
unintentionally produce equal ids.
Thefore I need a timestamp exact enough that it differs every time it is
fetched. I though about CPU cycles, but I don't know if there is a way to
get this information.

Refactor an MVC app to use the Command pattern

Refactor an MVC app to use the Command pattern

I have an MVC based application that I need to refactor to add support for
multiple levels of undo/redo. I have settled on the Command Pattern to
provide this functionality.
The application in question has functionality that adds/removes items
to/from a model. The controller provides these via methods like add_item,
remove_item etc. The implementation in the model provides the actual
implementation of the stack.
This functionality now needs to go into commands like, an AddItemCommand,
seen below.
class AddItemCommand
def execute(event)
self.item = event.item
model.add(self.item)
end
def unexecute()
model.remove(self.item)
end
end
Here an event object is provided to the command on execute, which contains
the item to be added to the model. In unexecute this item is removed from
the model. I'm glossing of over some details that aren't relevant to the
question.
What is a good way to get access to said model object from inside the
command instance?
Previously the model object was an instance present on the Controller so
the add_item method could just use self.model.add_item. But now it needs a
way to get to this model.
The model isn't a singleton but it is singular in that, there aren't
multiple instance of it. The items are added to the same instance. Should
I get a reference to a singleton of the model in the command's
execute/unexecute methods?
The textbook implementations I have seen suggest passing in the model to
the command's constructor when creating it like so,
def initialize(model)
self.model = model
end
// at instatiation
cmd = new AddItemCommand(model)
commands.add(cmd)
The drawback I see with is that I need the ability to add the command
lazily. ie:- The command is only added and executed when a corresponding
event is fired. I can maintain a mapping of events to commands to make
this happen. But I lose this flexibility when the command needs to
constructed with the model upfront.
What would be a good way to achieve flexibility to allow commands to get
at the model(s) without loosing the ability to add them lazily?
Thanks.

xcode: Mysql connector library not work on iphone5 (armv7s) ,any solution?

xcode: Mysql connector library not work on iphone5 (armv7s) ,any solution?

I built my App using Mysql Connector/C to connect a remote Mysql database,
its works fine on the simulator (no errors, no warnings) but when i try to
run it on my device (iphone5) i got this error:
No architectures to compile for (ARCHS=armv7 armv7s, VALID_ARCHS=armv7
armv7s)
i tried -as in some answers- to change setting (Architectures - Build
Active Architectures- Valid Architectures) but the error still, only when
i change the setting (Architectures & Valid Architectures) to "armv6" its
build without error but many warnings appears says:
warning: no rule to process file '(my App dir)/main.m' of type
sourcecode.c.objc for architecture armv6
and also for all .m files, when i tried to start the App i got message:
Xcode cannot run using selected device
I know that the Connector library need to update , but are there any
solution ?

HTML Text Editor in php

HTML Text Editor in php

I am working on a php project using codeigniter framework. I need a HTML
Rich Text Editor so I can copy the content from the word document and
paste it into the editor. Formatting of the text will be the same as in
word document.
Can you please let me know the Editor which one is good for my project?
Thanks in advance.

Where is guest ring-3 code run in VM environment?

Where is guest ring-3 code run in VM environment?

According to the white paper that VMWare has published, binary translation
techinology is only used in kernel (ring 0 codes), ring 3 code is
"directly executed" on cpu hardware.
As I observed, no matter how many processes are run in the guest OS, there
is always only 1 process in the host OS. So I assume all the guest ring 3
code are run in the single host process context. (for VMWare, it's
vmware-vmx.exe).
So my question here is, how do you execute so many ring 3 code natively in
a single process? Considering most of the windows exe file don't contain
relocation information, it cannot be executed somewhere else, and binary
translation is not used in ring3 code.
Thanks.

Friday, 23 August 2013

Can't access DOM element with jQuery

Can't access DOM element with jQuery

Html:
<section id="playing" class="gradient">
<div id="playing-header"> … </div>
<div id="playing-carousel"> … </div>
<div id="playing-info">
<a id="radio-star" class="" href="radio:star"></a>
<div id="radio-track-info">
<h2 id="radio-track"> … </h2>
<h2 id="radio-artist">
<a class="outgoing">
JAY Z
</a>
</h2>
</div>
<div id="thumb-container"> … </div>
</div>
<div id="loading" style="display: none;"></div>
<div id="loading-throbber" style="display: none;"></div>
<div id="station-error" style="visibility: hidden;"> … </div>
jQuery:
alert($('#radio-artist .outgoing').text());
jsfiddle: http://jsfiddle.net/CT95N/
Works on jsfiddle, but not on website. returns empty. what could be the
problem? what could i check to call my jquery after dom?
thanks

Prepared Statement INSERT JDBC MySQL

Prepared Statement INSERT JDBC MySQL

I am getting an error on doing ' mvn tomcat:run " . The error I am getting
is:
exception
org.springframework.web.util.NestedServletException: Request processing
failed; nested exception is
org.springframework.jdbc.BadSqlGrammarException:
PreparedStatementCallback; bad SQL grammar [INSERT INTO
ibstechc_dev.device (key, ip_address, type, name) VALUES (?, ?, ?, ?)];
nested exception is
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an
error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near 'key, ip_address, type,
name) VALUES ('abcd', 'abcd', 1234, 'abcd')' at line 1
root cause
org.springframework.jdbc.BadSqlGrammarException:
PreparedStatementCallback; bad SQL grammar [INSERT INTO
ibstechc_dev.device (key, ip_address, type, name) VALUES (?, ?, ?, ?)];
nested exception is
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an
error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near 'key, ip_address, type,
name) VALUES ('abcd', 'abcd', 1234, 'abcd')' at line 1
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:237)
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72
My code segment is:
public Device mapRow(ResultSet rs, int rowNum) throws SQLException {
Device device = new Device();
device.setId(Long.valueOf(rs.getInt(1)));
device.setKey(rs.getString(2));
device.setIPAddress(rs.getString(3));
device.setType(rs.getInt(4));
device.setName(rs.getString(5));
return device;
}
});
System.out.println("Found for user..." + userId);
return devices;
}
public void create(Device device) {
this.jdbcTemplate.update("INSERT INTO xyz.device (key, ip_address,
type, name) VALUES (?, ?, ?, ?)",
new Object[]{device.getKey(), device.getIPAddress(),
device.getType(), device.getName()});
}
public void delete(Device device) {
this.jdbcTemplate.update("DELETE FROM xyz.device WHERE
device_id = ?", new Object[] {device.getId()});
}
public void update(Device device) {
this.jdbcTemplate.update(
"UPDATE xyz.device SET key = ?, ip_address = ?, type =
?, name =? WHERE device_id = ?", new
Object[]{device.getId(),device.getKey(),
device.getIPAddress(), device.getType(),
device.getName()});
And my Debug.java code is:
public String getNavBarData(){
Device device = new Device();
device.setKey("abcd");
device.setIPAddress("abcd");
device.setType(1234);
device.setName("abcd");
deviceDao.create(device);
return "";
The MySQL table has the same columns as in my code above with NOT NULL for
each field. I have used the same code for a different functionality and it
works there. Why am I getting this error for this one? Pls. Help.

HTML 5 drag and drop to exact position

HTML 5 drag and drop to exact position

I want my element that I am dragging to drop into exactly the position it
was released. I'm not sure if I'm doing this right. So far I'm get the
drop coordinates in the drop event and then setting the top and left
properties. It works, sort of, except I have to offset the left and top
which makes me suspect there is something not right. Here is my function.
Can anyone point me in the right direction
var dropped = function (e) { cancel(e);
machine.parentNode.removeChild(machine);
e.target.appendChild(machine);
$(machine).css("top", (e.offsetY - 40) + 'px');
$(machine).css("left", (e.offsetX - 30) + 'px');
$("#text").html(e.offsetX + ' - ' + e.offsetY);
return false;
}

Log in with cURL and echo response with cookie

Log in with cURL and echo response with cookie

I am trying to write an "auto-login" script, that uses curl to log in to a
specific site and then echoing the response, so that the user can "bypass"
the login. (For example, to grant one-time logins etc)
Obviously, using the following method, the cookie is stored on the server,
not on the client, in cookie.txt.
I've tried setting $_COOKIE, but that won't work, since the URLs (actually
subdomains) of the auto-login script and the service to be logged into,
are different.
Login works fine. You see the screen as if you were logged in, but
clicking any link requires you to login again.
Any ideas? Thanks
The code I've used to auto-login:
<?php
$username="email@domain.com";
$password="password";
$url="http://sub.domain-to-login.com/index.php/sessions/login";
$cookie="cookie.txt";
$postdata = "email=".$username."&password=".$password.'&btn_login=Login';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, $url);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
curl_close($ch);
echo $result;
?>

Is it possible to add animation to a slider created by for loop?

Is it possible to add animation to a slider created by for loop?

I have create a UISlider for something like a "slider to unlock" element.
The animation I've written works well when it point to just one slider.
But I need to use a for loop to create sliders dynamically. And the
animation does not work, when I create the sliders add tags for the
sliders and add the animation function to the sliders in the for loop,
like this:
[slider addTarget:self action:@selector(UnlocklinkSlider:)
forControlEvents:UIControlEventTouchUpInside];
And the animation function is:
- (void)UnlocklinkSlider:(UISlider*)slider
{
for (int i = 0; i < rownumber; i++){
UIImageView *frontimg = (UIImageView *)[self.view
viewWithTag:i*10+1];
...
if (slider.tag==i*10) {
if(slider.value >= 0.5){
// user did not slide far enough, so return back to 0
position
[UIView beginAnimations: @"SlideCanceled" context: nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration: 0.35];
// use CurveEaseOut to create "spring" effect
[UIView setAnimationCurve: UIViewAnimationCurveEaseOut];
...
[UIView commitAnimations];
...
}
else{
...
}
}
}
}
But the animation does not work in this way.

Disabling default action (return false) even when action is set to .off

Disabling default action (return false) even when action is set to .off

I have a registration submit button on my website that is handled with
Jquery. The problem is that I want to prevent people from clicking on it
more than once while it is going through the process of registering their
account. For this reason I disable the click event once they have clicked
it, and do not re-enable the click unless there is an error. See bwlow
function registerClick() {
$('#register_submit').off('click',registerClick);
$.ajax( {
type: "POST",
url: "/ajax/register.ajax.php",
data: $("#register_form").serialize(),
success: function(data) {
var result = jQuery.parseJSON(data);
if (result.success) {
alert('Account registered. You are now being transferred
to Paypal for payment.');
window.location = result.success;
} else if (result.error) {
alert(result.error);
$('#register_submit').on('click',registerClick);
} else {
alert('Unhandled exception');
$('#register_submit').on('click',registerClick);
}
}
});
return false;
};
// signup
$('#register_submit').on('click',registerClick);
What unfortunately happens now is that if they double click the button,
the second click triggers the default button action which is to submit the
form to #.
I'm thinking that maybe I need to disable the button all together, but I'm
new to Jquery so this is uncharted territory for me.

Thursday, 22 August 2013

ALSR and NX-bit in modern Windows?

ALSR and NX-bit in modern Windows?

How is NX-bit protection turned off when the attacker gains control over
the instruction pointer in Windows on x86-64, protected with both NX-bit
and ASLR? I'm assuming that the system call to disable this feature is
simply at a non-ASLRed address, and can be called directly?
It seems that heap spraying is frequently used to exploit modern Windows
machines (e.g. with bugs in Javascript implementations), obviously this
entails an executable heap, so how is the heap made executable prior to
the heap spray? Is there some paper that clearly shows how this is done,
on Windows?

Java - JTextArea suddenly resizes upon dialog resizing

Java - JTextArea suddenly resizes upon dialog resizing

I have a problem with using JTextArea. My actual setup is different, but
the effects remain. Here is an image of the problem:

The moment the owning JDialog resizes just 1 pixel below what the
JTextArea's require for their preferred sizes, the text areas suddenly
resize. In my actual setup, they suddenly grow in height. I am using a
GridBagLayout, but it seems to happen in other layouts. Why is this?
Here is the easy-to-compile code to reproduce the above effect.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.JTextComponent;
public class TextDemo extends JDialog implements ActionListener {
private static final long serialVersionUID = -589374238138963529L;
protected JTextField textField;
protected JTextArea textArea;
private final static String newline = "\n";
private static final java.awt.Dimension SCREENSIZE =
java.awt.Toolkit.getDefaultToolkit().getScreenSize();
private static final java.awt.Point SCREENCENTER =
new java.awt.Point(SCREENSIZE.width/2,SCREENSIZE.height/2);
public TextDemo(Window owner, String shortMessage, String message,
JComponent accessory) {
super(owner);
setTitle("Test");
setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
Icon icon = UIManager.getIcon("OptionPane.warningIcon");
JTextArea shortText = makeMultiLineLabel(true);
shortText.setBorder(BorderFactory.createEtchedBorder());
shortText.setFont(shortText.getFont().deriveFont(Font.BOLD));
FontMetrics fm = shortText.getFontMetrics(
shortText.getFont());
shortText.setPreferredSize(new Dimension(
Math.min(fm.stringWidth(shortMessage), 300),
fm.getHeight()));
shortText.setText(shortMessage);
JTextArea messageText = makeMultiLineLabel(true);
messageText.setBorder(BorderFactory.createEtchedBorder());
messageText.setFont(shortText.getFont().deriveFont(Font.PLAIN));
fm = messageText.getFontMetrics(
messageText.getFont());
messageText.setPreferredSize(new Dimension(
Math.min(fm.stringWidth(message), 300),
fm.getHeight()));
messageText.setText(message);
JPanel buttonPanel = new JPanel();
buttonPanel.add(new JButton("OK"));
buttonPanel.add(new JButton("Cancel"));
JPanel contentPanel = new JPanel();
contentPanel.setOpaque(true);
contentPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 8,
9));
contentPanel.setLayout(new GridBagLayout());
GridBagConstraints c;
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.FIRST_LINE_START;
c.gridheight = 2;
contentPanel.add(new JLabel(icon), c);
c = new GridBagConstraints();
c.gridx = 1;
c.gridy = 0;
c.fill = GridBagConstraints.BOTH;
c.weighty = 1.0;
contentPanel.add(shortText, c);
c = new GridBagConstraints();
c.gridx = 1;
c.gridy = 1;
c.fill = GridBagConstraints.BOTH;
c.weighty = 1.0;
contentPanel.add(messageText, c);
if (accessory != null) {
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 2;
c.gridwidth = 2;
c.fill = GridBagConstraints.BOTH;
c.weighty = 1.0;
c.weightx = 0.6;
contentPanel.add(accessory, c);
}
c = new GridBagConstraints();
c.gridwidth = 2;
c.gridx = 0;
c.gridy = 3;
contentPanel.add(buttonPanel, c);
setContentPane(contentPanel);
}
public void actionPerformed(ActionEvent evt) {
String text = textField.getText();
textArea.append(text + newline);
textField.selectAll();
//Make sure the new text is visible, even if there
//was a selection in the text area.
textArea.setCaretPosition(textArea.getDocument().getLength());
}
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event dispatch thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("TextDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
TextDemo t = new TextDemo(frame, "You won't get away with this!",
"Alert! Alert! A chocy nut bar has been removed without
payment!" +
" A chocy nut bar... has been REMOVED! WITHOUT PAYMENT!
Alert, alert!",
null);
//Display the window.
frame.pack();
frame.setLocation(SCREENCENTER.x - frame.getSize().width/2,
SCREENCENTER.y - frame.getSize().height/2);
frame.setVisible(true);
t.setModal(true);
t.pack();
t.setLocation(getPos(t, t.getOwner()));
t.setVisible(true);
}
public static final JTextArea makeMultiLineLabel(boolean selectable) {
JTextArea area = new JTextArea();
area.setWrapStyleWord(true);
area.setLineWrap(true);
area.setFont(UIManager.getFont("Label.font"));
area.setEditable(false);
area.setCursor(null);
area.setOpaque(false);
area.setFocusable(selectable);
area.setAlignmentX(JTextComponent.LEFT_ALIGNMENT);
area.setMinimumSize(new Dimension(0,0));
return area;
}
private static Point getPos(JDialog d, Window w) {
return new Point(w.getX()+(w.getWidth ()-d.getWidth ())/2,
w.getY()+(w.getHeight()-d.getHeight())/2);
}
public static void main(String[] args) {
//Schedule a job for the event dispatch thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
Many thanks for any help!

iOS - Using Search API for Google Shopping

iOS - Using Search API for Google Shopping

My ultimate goal is to search for an item (using a query in code) and
display some information from a JSON object using the Google Shopping API
- Objective-C Client.
I know that the search API for shopping is going to be deprecated very
shortly but wanted to at least get something to work just to show that it
does work. So short term I would like to get this to work and long term
use something similar (such as an Amazon API).
I am targeting iOS 6.0+ and am currently using XCode 4.6. I followed this
blog tutorial here for XCode 4.5 and got everything set up as stated here.
(Although maybe there is another way to get the pre-built library built -
but the blog author said that that did not work)
If you look at the first link they give you an example of how to use the
API(under Basics - Objects and Queries) but I have a problem in that I
cannot find the GTLServiceGoogleShopping object anywhere. If you use the
svn command to checkout the library files you don't get this object nor do
you get any example code for this particular service.
I am wondering if anyone has done this in iOS before and/or if anyone
would like to recommend an alternative way to do a product search on the
web that returns a JSON Object, that is compatible with XCode/iOS and that
is as easy to use as the Google Shopping API seems to be. (i.e. use a few
objects to make a http request then parse the JSON object as needed).
Any help/information/guidance would be greatly appreciated.

change maxlength of input text field onblur event

change maxlength of input text field onblur event

instance= i need to accept maximum 5 digit value(12345) in my input field
and convert to float variable with fixed 3. (12.345) conversion is done by
calling javascript method convert();. But now the field value size is 6
including "."(dot). So how to change the maxlenth of this input field
ONBLUR event.
plz help me in sorting it out. Thank you.

Speech recognition using a recorder audio stream

Speech recognition using a recorder audio stream

I am developing an app which uses the speech recognition features.
I just want to know how can i Convert a long enough speech into text, for
example a 30 min lecture into text.
as i am trying this with Speech Recognizer but it do not work more than 9
to 10 seconds.
Can anyone suggest some solution or provide any link or any example?
Or is it possible to record an audio an convert it into a text message.
please provide some suggestions.
Thanks in advance...

String of binary to integer

String of binary to integer

I have a string which contains of 0 and 1. I wanna know if there is any
method in c# to convert this in Uint32 . I know how to do that without any
method but just I wanna know if there is any method does that
automatically?

Wednesday, 21 August 2013

add another input in php

add another input in php

I have a doubt. I have a file called login.php that the root of the site.
he has some input login and password
php it is this:
I would use the input file in this folder / acpcode / the code is this:
<td style='width: 33%;'>
<fieldset style='width: 170px; margin: 0px auto;'>
<form id='login'>
<div class='input'><input type='text' id='account'
/><span>{$_lang['account']['inputAccount']}</span></div>
<div class='input'><input type='password' id='password'
/><span>{$_lang['account']['inputPassword']}</span></div>
<button>{$_lang['account']['buttonLogin']}</button>
</form>
</fieldset>
</td>

How to prevent copying images each time?

How to prevent copying images each time?

I have a Windows Store App with many, many images (large and small icons
in 4 scales). Simply building my app takes upwards of 5 minutes each time.
I believe it is recopying each image each time I'm building the app, even
if I've only changed a view or a code-behind. Is there a way to prevent it
from doing this? I realize it's likely repackaging the App every single
time (about a 20MB package). Hopefully there is a way to reduce this time
though.

Please explain what each technique and skill in Phantasy Star IV does

Please explain what each technique and skill in Phantasy Star IV does

I find it very difficult to remember what each technique or skill does
just by looking at its name, so I've been playing with a PDF version of
the game's manual always open on my tablet. The thing is, not every
technique and skill is explained in the manual either, like Gryz's "Crash"
skill.
Can you provide a list of every technique and skill found in the game and
its effect?
Thanks.

Save new files to ubuntu one from ipad apps

Save new files to ubuntu one from ipad apps

On my iPad I have various apps, that can create new files. But I can't
find a way to save this new file to ubuntuone. Is there anything, that I
missed? Thanks, Armin

Does ODP.NET support EF Model-First with DbContext?

Does ODP.NET support EF Model-First with DbContext?

We're trying to use an Entity Framework Model-First approach with Oracle
11g and ODP.NET 11.2.0.3.20. We'd like to use EF 4.1 or EF 5.0 with
DbContext.
Short version: Has anyone managed to do that?
Long version: On VS2010 and Entity Framework 4.0, everything works fine.
I'm able to Generate Database from Model.
When I try it with EF 4.1 or EF 5.0, I always end up with an Object
reference not set to an instance of an Object error message in Visual
Studio:

I tried it the following ways:
Created a new EF 5.0 model in VS2012, set code generation workflow and
templates to the Oracle stuff (Generate Oracle via T4 (TPT).xaml and
SSDLToOracle.tt). Then I clicked on Generate Database from Model and chose
a working Oracle connection, but Visual Studio just shows that error.
Created an EF 4.1 model in VS2012, same error.
Created an EF 4.1 model in VS2010, same error.
Tried a Database-First approach in EF 5.0 and EF 4.1, same error.
It only works if I'm using VS2010 and EF 4.0.
However, Oracle claims that it should work, see
http://www.oracle.com/technetwork/topics/dotnet/downloads/install112030-1440546.html
:
ODAC supports DbContext APIs.
Has anyone managed to use EF 4.1 or 5.0 with Oracle ODP.NET?

uniform continuity of quotient of two uniform continuous functions

uniform continuity of quotient of two uniform continuous functions

as we know quotient of two real valued continuous functions defined on the
$\mathbb R$is continuous . what can we say about the quotient of two
uniformly continuous functions.

Tuesday, 20 August 2013

Elasticsearch Tire undefined method `delete_if' for String

Elasticsearch Tire undefined method `delete_if' for String

Im using elasticsearch and tire gem in my rails project and added to my
model all required things as it described in tire documentation, but when
I use default tire's search method:
Model.search "foo"
returns:
undefined method 'delete_if' for "foo":String

Pagination codeigniter with query search

Pagination codeigniter with query search

i want to create codeigniter pagination in my search form, when i clicked
submit,it successfully shows the query search but when i clicked the
number page link or next page, it shows message "undefined variable rec"
and "Fatal error: Call to a member function num_rows() on a non-object"
,i'm sure the query has been passed to variable $rec.
here is my controller:
public function search(){
$kat=$this->input->post('kategori');
$prov=$this->input->post('prov');
$kot=$this->input->post('kota');
if($kat=='' && $prov!='' && $kot!=''){
$rec=$this->db->query("select * from showall where id_prov='$prov' and
id_kota='$kot' ");
}
else if($kot=='' && $kat!='' && $prov!=''){
$rec=$this->db->query("select * from showall where id_kat='$kat' and
id_prov='$prov' ");
}
else if($kat=='' && $kot=='' && $prov!=''){
$rec=$this->db->query("select * from showall where id_prov='$prov' ");
}
else if($kat!='' && $prov=='' && $kot==''){
$rec=$this->db->query("select * from showall where id_kat='$kat' ");
}
else if($kat!='' && $prov!='' && $kot!=''){
$rec=$this->db->query("select * from showall where id_kat='$kat' and
id_prov='$prov' and id_kota='$kot' ");
}
$dat=$rec;
$data['count']=$dat->num_rows();
if($data['count'] >0){
$data['db']=$rec;
$config['total_rows'] = $data['db']->num_rows();
$config['base_url'] = base_url().'index.php/lowongan/cari';
$config['per_page'] = 1;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$data['paging'] = $this->pagination->create_links();
if($kat=='' && $prov!='' && $kot!=''){
$d =
$this->db->get_where('showall',array('id_prov'=>$prov,'id_kota'=>$kot)
,$config['per_page'], $this->uri->segment(3));
}
else if($kot=='' && $kat!='' && $prov!=''){
$d= $this->db->get_where('showall',array('id_kat'=>$kat,'id_prov'=>$prov)
,$config['per_page'], $this->uri->segment(3));
}
else if($kat=='' && $kot=='' && $prov!=''){
$d = $this->db->get_where('showall',array('id_prov'=>$prov)
,$config['per_page'], $this->uri->segment(3));
}
if($kat!='' && $prov=='' && $kot==''){
$d = $this->db->get_where('showall',array('id_kat'=>$kat)
,$config['per_page'], $this->uri->segment(3));
}
else if($kat!='' && $prov!='' && $kot!=''){
$d =
$this->db->get_where('showall',array('id_kat'=>$kat,'id_prov'=>$prov,'id_kota'=>$kot)
,$config['per_page'], $this->uri->segment(3));
}
$data['record']=$d;
$data1['kat']=$this->query->kategoriAll();
$data1['prov']=$this->query->showProv();
$data['q1']=$this->query->lokasi();
$data['q2']=$this->query->perusahaan();
$data['q3']=$this->query->kategori();
$this->load->view("user/head");
$this->load->view("user/bar",$data1);
$this->load->view( 'user/hal_cari',$data);
$this->load->view("user/footer");
}
else{
$data1['kat']=$this->query->kategoriAll();
$data1['prov']=$this->query->showProv();
$data['q1']=$this->query->lokasi();
$data['q2']=$this->query->perusahaan();
$data['q3']=$this->query->kategori();
$this->load->view("user/head");
$this->load->view("user/bar",$data1);
$this->load->view( 'user/kosong',$data);
$this->load->view("user/footer");
}
}

SSIS Package not wanting to fetch metadata of temporary table

SSIS Package not wanting to fetch metadata of temporary table

I have an SSIS Package, which contains multiple flows.
Each flow is responsible for creating a "staging" table, which gets filled
up after creation. These tables are global temporary tables.
I added 1 extra flow (I did not make the package) which does exactly as
stated above, for another table. However, for some reason, the package
fails intermittently on this flow, while it is exactly the same as others,
besides some table names.
The error that keeps popping up:
Update - Insert Data Flow:Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE
DB error has occurred. Error code: 0x80004005. An OLE DB record is
available. Source: "Microsoft SQL Server Native Client 11.0" Hresult:
0x80004005 Description: "Unspecified error". An OLE DB record is
available. Source: "Microsoft SQL Server Native Client 11.0" Hresult:
0x80004005 Description: "The metadata could not be determined because
statement 'select * from
'##TmpMcsConfigurationDeviceHistory86B34BFD041A430E84CCACE78DA336A1'' uses
a temp table.".
Creation expression:
"CREATE TABLE " + @[User::TmpMcsConfigurationDeviceHistory] + " ([RecId]
[bigint] NULL,[DataAreaID] [nvarchar](4) COLLATE database_default
NULL,[Asset] [bigint] NULL,[Code] [nvarchar](255) COLLATE database_default
NULL,[Configuration] [bigint],[StartdateTime] [datetime]
NULL,[EndDateTime] [datetime] NULL)
"
Parsed expression (=evaluated):
CREATE TABLE
##TmpMcsConfigurationDeviceHistory764E56F088DC475C9CC747CC82B9E388
([RecId] [bigint] NULL,[DataAreaID] [nvarchar](4) COLLATE database_default
NULL,[Asset] [bigint] NULL,[Code] [nvarchar](255) COLLATE database_default
NULL,[Configuration] [bigint],[StartdateTime] [datetime]
NULL,[EndDateTime] [datetime] NULL)

RuntimeException could not be mapped to a response, re-throwing to the HTTP container java.lang.NullPointerException

RuntimeException could not be mapped to a response, re-throwing to the
HTTP container java.lang.NullPointerException

I am trying to validate a user record from my database using Spring
Framework, RESTful Web Services and Jersey Implementation.
I am using MySQL v5.6.0, Eclipse Galileo, Apache tomcat v6.0
UserAccessWS.java
@Path("/user")
@Service
public class UserAccessWS {
@Autowired
private IUserService userService;
private static Logger LOGGER = Logger.getLogger(UserAccessWS.class);
@POST
@Path("/validateUser")
@Produces({ MediaType.APPLICATION_JSON })
public String getValidateUser(@Context HttpServletRequest request,
@FormParam("userName") String userName,
@FormParam("password") String password) throws JSONException {
LOGGER.info("getValidateUser method");
Users users = new Users();
users.setUserName(userName);
users.setPassword(password);
List<Users> userList = new ArrayList<Users>();
userList = userService.validateUser(users);
JSONObject userInfo = new JSONObject();
userInfo.put("authorize", true);
return userInfo.toString();
}
@POST
@Path("/login")
@Produces({ MediaType.APPLICATION_JSON })
public String userLogin(
@FormParam("userName") String userName,
@FormParam("password") String password)
throws Exception
{
LOGGER.info("in UserAccessWS::userLogin()");
JSONObject json = new JSONObject();
JSONArray jsonArr = new JSONArray();
List<Users> userList = new ArrayList<Users>();
userList = userService.userLogin(userName, password);
Null error is being pointed out in this line "userList =
userService.userLogin(userName, password);"
//System.out.println(userList);
if (userList.size() == 0)
{
json.put("status", "fail");
}
else
{
json.put("status", "success");
jsonArr.add(userList.get(0));
json.put("data", jsonArr);
}
//System.out.println(jsonArr.get(0).userId);
return json.toString();
}
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/tx/spring-aop-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.0.xsd"
default-autowire="byName">
<bean id="applicationProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="searchSystemEnvironment" value="true" />
</bean>
<context:component-scan base-package="com.cisco" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/pooler_mgmt" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="systemProperties" class="java.util.HashMap"></bean>
<bean id="systemEnvironment" class="java.util.HashMap"></bean>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>CiscoPoolerMgmt</display-name>
<description>CiscoPoolerMgmt</description>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/CiscoPoolerMgmt/config/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath*:/CiscoPoolerMgmt/config/log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- REST web service -->
<servlet>
<servlet-name>REST_stat_web_service</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.cisco.ws</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>REST_stat_web_service</servlet-name>
<url-pattern>/cisco_BI/rest/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
Error which I am get is:
SEVERE: The RuntimeException could not be mapped to a response,
re-throwing to the HTTP container
java.lang.NullPointerException
at com.cisco.ws.UserAccessWS.userLogin(UserAccessWS.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:149)
at
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
at
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:259)
at
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:133)
at
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:83)
at
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:133)
at
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:71)
at
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:990)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:941)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:932)
at
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:384)
at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:451)
at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:632)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Aug 21, 2013 12:54:21 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet REST_stat_web_service threw exception
java.lang.NullPointerException
at com.cisco.ws.UserAccessWS.userLogin(UserAccessWS.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:149)
at
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
at
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:259)
at
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:133)
at
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:83)
at
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:133)
at
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:71)
at
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:990)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:941)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:932)
at
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:384)
at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:451)
at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:632)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
The database from where it has to validate the details entered by user is
NOT empty. It has the records in them. But via this query it always gives
a NullPointerException.
Please help me out.
Thanks in advance.

Session visible on other computers?

Session visible on other computers?

I have a strange issue, where basically i have a shopping cart using a
session. When i deploy the site using IIS7 all looks fine. I add a product
to the session on one pc and it displays in my basket. When i access the
site from another pc the basket has this item in it!!??
its my understanding that a session instance is unique per user browser is
this correct? and if so, how have i managed to do this? I know its
probably something stupid but i can't figure it out, any help is much
appreciated!
My session cart code is as follows
#region Singleton Implementation
public static readonly ShoppingCart Instance;
static ShoppingCart()
{
// If the cart is not in the session, create one and put it there
// Otherwise, get it from the session
if (HttpContext.Current.Session["sCart"] == null)
{
Instance = new ShoppingCart();
Instance.Items = new List<CartItem>();
HttpContext.Current.Session["sCart"] = Instance;
}
else
{
Instance =
(ShoppingCart)HttpContext.Current.Session["sCart"];
}
}
protected ShoppingCart() { }

How can we get navigation toggle when more tabs are opened likein Firefox browser

How can we get navigation toggle when more tabs are opened likein Firefox
browser

Hi I have a requirement in a DIV tag there are tabs loading dynamically
from backed.When the tab number exceeds certain width a navigation toggler
has to applied similar to Firefox browser as shown below

How can we acheive this in Jquery.Any plugin is available? Thanks