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
}
}
}

Backbone: Scroll event not firing after back button is pressed

Backbone: Scroll event not firing after back button is pressed

As you can see here, when you click on an image and then click back,
Chrome doesn't let you scroll down anymore. I'm using the following
function to change the primary view of my Backbone application:
changeView: function(view, options) {
if (this.contentView) {
this.contentView.undelegateEvents();
this.contentView.stopListening();
this.contentView = null;
}
this.contentView = view;
if (!options || (options && !options.noScroll)) {
$(document).scrollTop(0);
}
this.contentView.render();
},
This function is called every time the route changes. As you can see, I'm
resetting the scroll position every time the primary view changes (so that
the user doesn't land on the middle of a view after scrolling down on the
previous view). However, when the user presses the back button, the scroll
event isn't firing at all if you try to scroll down. If you try to scroll
up, however, then the scroll positions seems to get reset to a position
further down the page, after which scrolling works normally.
Any ideas on what the cause might be?

Array acting quite oddly in JS

Array acting quite oddly in JS

Ok I have a simple for loop in Javascript that will create an array of
numbers, I need to do this so I can then swap them around to create random
positions. But anyways here is the code
var aliveMonsters = [];
var deadMonsters = 0;
for( var i = 0; i < monsterAmount; i++ )
{
if( monsters[i].hp > 0 )
{
var place = i - deadMonsters;
var placed = i - deadMonsters;
aliveMonsters[place] = placed;
}
else
{
deadMonsters -= 1;
}
//console.log(i);
}
console.log(aliveMonsters);
when all 3 monsters are alive this is printed out
[0, 1, 2]
Which is correct, but when one of them dies (0, 1 or even 2), the array
then becomes this
[0, 3: 3]
this code is called everytime a player makes a move and it works fine
until a monster is dead (HP is set to 0). Can anyone see why this is
happening?
Canvas

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to
host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:

When i run the selenium scripts in jenkins the fallowing error is showing:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to
host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: no display specified
Error: no display specified
at
org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:106)
at
org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244)
at
org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:188)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:179)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)
at
com.ebates.fe.web.integration.howitworks.test.HowItWorksPageTest.setUp(HowItWorksPageTest.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)
at
org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
at org.testng.TestRunner.runWorkers(TestRunner.java:1178)
at org.testng.TestRunner.privateRun(TestRunner.java:757)
at org.testng.TestRunner.run(TestRunner.java:608)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1158)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1083)
at org.testng.TestNG.run(TestNG.java:999)
at
org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62)
at
org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141)
at org.apache.maven.surefire.Surefire.run(Surefire.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
Tests run: 15, Failures: 1, Errors: 0, Skipped: 14, Time elapsed: 46.101
sec <<< FAILURE!
I am using selenium server version 2.35.0, and firefox version is 23 and
OS is linux. i am running the scripts in jenkins.

PL/SQL I am using a INSERT as SELECT from various tables

PL/SQL I am using a INSERT as SELECT from various tables

In PL/SQL I am using a INSERT as SELECT from various tables that uses many
functions and relations. the select returns about 10 rows at a time.
The query looks like
INSERT INTO EIM_TABLE(certain columns)
select a,b,...,fn(x,y,)
Now i need to collect the value of what was returned by fn(x,y) ,
concatenate each of the values into a single variable and carry out my
further processing based on this.
Please suggest the best way to this. Performance is a highly critical
criteria so want to avoid unnecassary overheads

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

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

How can I find the ecj version in eclipse?

How can I find the ecj version in eclipse?

I'm having a small issue where some java classes compiled in eclipse are
slightly different from the classes compiled by a standalone ecj (from the
same source code). How can I find the version of ecj that is being used by
eclipse? (I'm assuming that's where the difference is)

Return an unset value in value converter

Return an unset value in value converter

Using a value converter in WPF, you can return something like
DependecyProperty.UnsetValue or Binding.DoNothing as special values to say
leave the binding alone. Is there a similar mechanism in MVVMCross?
To be more specific about what I'm trying to do, is I have a view model
property that is a three-state enum that I need to bind to 3 binary
controls. So I thought I could bind each of the controls to a MyEnum ->
bool converter that will have a conversion parameter set to the value of
the converter and in the Convert method it will return true if the MyEnum
state is equal to the parameter and false otherwise. So far so good. But I
want this binding to be two-way, so I need to convert back. My convert
back works something like this:
protected override MyEnum ConvertBack(bool value, Type targetType,
object parameter, System.Globalization.CultureInfo culture)
{
if (parameter is MyEnum)
{
if (value)
{
return (MyEnum)parameter; // this is fine
}
else
{
return ???
}
}
return base.ConvertBack(value, targetType, parameter, culture);
}
Basically, what I want to be able to do is say, if the state of my control
is true update the bound property on my view model to be the same as the
parameter, if not, leave the view model property alone.
Maybe this is the problem with using the strongly typed value converters?

System.IO.Directory.GetFiles VS My.Computer.FileSystem.GetFiles

System.IO.Directory.GetFiles VS My.Computer.FileSystem.GetFiles

I wanted to get the names of all the files in a specific directory which
includes over 25,000 files. I tried using these methods:
System.IO.Directory.GetFiles and My.Computer.FileSystem.GetFiles
I've found out that System.IO is significantly faster My.Computer
By significantly I mean around 20 second faster.
Could anyone explain to me the difference between These two methods?

Using "WHERE" with a variable that has multiple values

Using "WHERE" with a variable that has multiple values

I want to know how to select columns from a table where another column has
several possible values. So, for example, this code will return Column X
from table 1 and Column B from Table 2 if Column G has the value given by
the input.
variable input varchar2(60);
exec :input := 'c';
Select Table1.x, Table2.b
FROM Table1, Table2
WHERE Table1.g = :input
What if instead, I wanted to return Column X from table 1 and Column B
from Table 2 if Column G had value "k" or "c" or "d" without doing
WHERE Table1.g = "k" or Table1.g = "c" or Table1.g = "d"
How do i define the input such that I get this effect?
Thank you!
I use: oracle 10g, PL/SQL

getOverlays not defined for the GoogleMaps

getOverlays not defined for the GoogleMaps

I am following this Tutorial
package com.example.maps;
import java.util.List;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import com.google.android.gms.maps.MapView;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
public class PlacesMapActivity extends MapActivity {
// Nearest places
PlacesList nearPlaces;
// Map view
MapView mapView;
// Map overlay items
List<Overlay> mapOverlays;
AddItemizedOverlay itemizedOverlay;
GeoPoint geoPoint;
// Map controllers
MapController mc;
double latitude;
double longitude;
OverlayItem overlayitem;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_activity);
// Getting intent data
Intent i = getIntent();
// Users current geo location
String user_latitude = i.getStringExtra("user_latitude");
String user_longitude = i.getStringExtra("user_longitude");
// Nearplaces list
nearPlaces = (PlacesList) i.getSerializableExtra("near_places");
mapView = (MapView) findViewById(R.id.mapView);
// mapView.setBuiltInZoomControls(true);
mapView.setClickable(true);
mapOverlays = mapView.getOverlays;
// Geopoint to place on map
geoPoint = new GeoPoint((int) (Double.parseDouble(user_latitude) *
1E6),
(int) (Double.parseDouble(user_longitude) * 1E6));
// Drawable marker icon
Drawable drawable_user = this.getResources()
.getDrawable(R.drawable.mark_red);
itemizedOverlay = new AddItemizedOverlay(drawable_user, this);
// Map overlay item
overlayitem = new OverlayItem(geoPoint, "Your Location",
"That is you!");
itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);
itemizedOverlay.populateNow();
// Drawable marker icon
Drawable drawable = this.getResources()
.getDrawable(R.drawable.mark_blue);
itemizedOverlay = new AddItemizedOverlay(drawable, this);
mc = mapView.getController();
// These values are used to get map boundary area
// The area where you can see all the markers on screen
int minLat = Integer.MAX_VALUE;
int minLong = Integer.MAX_VALUE;
int maxLat = Integer.MIN_VALUE;
int maxLong = Integer.MIN_VALUE;
// check for null in case it is null
if (nearPlaces.results != null) {
// loop through all the places
for (Place place : nearPlaces.results) {
latitude = place.geometry.location.lat; // latitude
longitude = place.geometry.location.lng; // longitude
// Geopoint to place on map
geoPoint = new GeoPoint((int) (latitude * 1E6),
(int) (longitude * 1E6));
// Map overlay item
overlayitem = new OverlayItem(geoPoint, place.name,
place.vicinity);
itemizedOverlay.addOverlay(overlayitem);
// calculating map boundary area
minLat = (int) Math.min( geoPoint.getLatitudeE6(), minLat );
minLong = (int) Math.min( geoPoint.getLongitudeE6(),
minLong);
maxLat = (int) Math.max( geoPoint.getLatitudeE6(), maxLat );
maxLong = (int) Math.max( geoPoint.getLongitudeE6(),
maxLong );
}
mapOverlays.add(itemizedOverlay);
// showing all overlay items
itemizedOverlay.populateNow();
}
// Adjusting the zoom level so that you can see all the markers on
map
mapView.getController().zoomToSpan(Math.abs( minLat - maxLat ),
Math.abs( minLong - maxLong ));
// Showing the center of the map
mc.animateTo(new GeoPoint((maxLat + minLat)/2, (maxLong +
minLong)/2 ));
mapView.postInvalidate();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
The Android IDE throws the error at these line
mapOverlays = mapView.getOverlays; mc = mapView.getController();
mapView.getController().zoomToSpan(Math.abs( minLat - maxLat ), Math.abs(
minLong - maxLong ));
Can you please help me in correcting my code ? Thanks for the help.

Configure Post fix with Python in ubuntu

Configure Post fix with Python in ubuntu

I want to send mails using postfix in my python project.I have installed
postfix on my local system , but I don't know how to use this postfix in
python to send emails.Can anybody tell me how to configue postfix in
python.

Tuesday, 27 August 2013

How to check programatically that 8.3 short path name is enabled on system?

How to check programatically that 8.3 short path name is enabled on system?

I know manually we can enable or disable 8.3 short path name support by
setting NtfsDisable8dot3NameCreation.
But how to read this system information through code? Actually I have to
disable some functionality based on whether the system have 8.3 enabled or
not.
Please help
Thanks

Difference in coordinates of motionEvent and drawLine on a scaled image

Difference in coordinates of motionEvent and drawLine on a scaled image

I try to paint a line this way:
@Override
public boolean onTouch(View view, MotionEvent event) {
int action = event.getAction();
paint.setColor(Color.BLACK);
paint.setStrokeWidth(1);
canvas.setBitmap(rotatedBitmap);
switch (action) {
case MotionEvent.ACTION_DOWN:
downx = event.getX();
downy = event.getY();
break;
case MotionEvent.ACTION_MOVE:
upx = event.getX();
upy = event.getY();
canvas.drawBitmap(notChangedRotatedBitmap, new
Matrix(), paint);
canvas.drawLine(downx / 2, downy / 2, upx / 2, upy /
2, paint);
photoView.invalidate();
break;
case MotionEvent.ACTION_UP:
canvas.drawBitmap(notChangedRotatedBitmap, new
Matrix(), paint);
photoView.invalidate();
float degree = getDegree(downx, downy, upx, upy);
rotateBy(degree);
break;
case MotionEvent.ACTION_CANCEL:
break;
default:
break;
}
return true;
}
It draws ok if I use not changed bitmap.
But if the image is scaled either by bitmapOptions in
BitmapFactory.decodeStream(input, null, bitmapOptions);
or any other way like
Bitmap.createBitmap(rotatedBitmap, (int) shiftDistanceSide, (int)
shiftDistanceTop, rotatedBitmap.getWidth() - 2 * (int) shiftDistanceSide,
rotatedBitmap.getHeight() - 2 * (int) shiftDistanceTop);
The coordinates of the motionEvent seem to be multiplied by a factor, may
be zoom factor. How to avoid it?

org.apache.axis.ConfigurationException: org.xml.sax.SAXException: Fatal Error: URI=null Line=1:

org.apache.axis.ConfigurationException: org.xml.sax.SAXException: Fatal
Error: URI=null Line=1:

I am getting this error on Tomcat startup
FATAL org.apache.axis.InternalException [<init>] - Exception:
org.apache.axis.ConfigurationException: org.xml.sax.SAXException: Fatal
Error: URI=null Line=1: The markup in the document preceding the root
element must be well-formed.
org.xml.sax.SAXException: Fatal Error: URI=null Line=1: The markup in the
document preceding the root element must be well-formed.
at
org.apache.axis.utils.XMLUtils$ParserErrorHandler.fatalError(XMLUtils.java:723)
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown
Source)
at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:369)
at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:388)
at
org.apache.axis.configuration.FileProvider.configureEngine(FileProvider.java:179)
at org.apache.axis.AxisEngine.init(AxisEngine.java:172)
at org.apache.axis.AxisEngine.<init>(AxisEngine.java:156)
at org.apache.axis.server.AxisServer.<init>(AxisServer.java:88)
at
org.apache.axis.server.DefaultAxisServerFactory.createServer(DefaultAxisServerFactory.java:109)
at
org.apache.axis.server.DefaultAxisServerFactory.getServer(DefaultAxisServerFactory.java:73)
at org.apache.axis.server.AxisServer.getServer(AxisServer.java:73)
at
org.apache.axis.transport.http.AxisServletBase.getEngine(AxisServletBase.java:185)
at
org.apache.axis.transport.http.AxisServletBase.getOption(AxisServletBase.java:396)
at
org.apache.axis.transport.http.AxisServletBase.init(AxisServletBase.java:112)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1206)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
What could be the possible cause and it's solution?

Play sound on button click android

Play sound on button click android

tried many tutorials, youtube, stackoverflow, none work :(
help me please to get the button play a sound from raw when click. I just
created a button with id button1, and what code I write all is wrong. :(
import android.media.MediaPlayer;
public class BasicScreenActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_basic_screen);
}
Button one = (Button)this.findViewById(R.id.button1);
MediaPlayer = mp;
mp = MediaPlayer.create(this, R.raw.soho);
zero.setOnCliclListener(new View.OnClickListener() )
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.basic_screen, menu);
return true;
}
}

Monday, 26 August 2013

display items' values in bar chart in Jpgraph

display items' values in bar chart in Jpgraph

I am using jpgraph bar chart. It all works fine but there is one thing I
could not really figure it out. I need to display the value of each bar on
the top of that bar (column) but it seems like I am missing something that
I cant do it.
I have tried using the following:
$bplot->value->Show();
But yet it does not work! Any help is GREATLY appreciated!

sending a file post python

sending a file post python

I'm having some trouble with a script that is attempting to upload a photo
to a Facebook page. I had it working well when it was only strings being
passed. A page post requires a source file (an image) and this is the part
that I'm having trouble with. This returns a 400 Error.
I'm not totally sure how to handle the image (and the goal is doing this
is bulk, so I'd ideally like a zip file of images.)
Here's the equivalent curl request that works correctly: curl -F
'message=Book p://bit.ly/alaska' -F 'source=@alaska.jpg' -F 'published=0'
-F 'access_token=TEST' https://graph.facebook.com/act_id/photos
import os
import requests
import csv
import time
import thread
import zipfile
from datetime import datetime
from json import JSONEncoder
from flask import Flask, request, redirect, url_for, send_from_directory, \
render_template
from flask.ext.mail import Mail, Message
from werkzeug import secure_filename
email = ''
token=''
pageid = ''
filename = 'test.csv'
images = 'test.zip'
from flask import request
raw_input = open(filename, 'rb')
info = csv.DictReader(raw_input)
imagefile = zipfile.ZipFile(images, mode='r')
creation_date = datetime.now().strftime('%m-%d-%Y')
output_csv_name = \
"unpublished_posts_%s_%s.csv" % (pageid, creation_date)
output_csv = open(output_csv_name, 'wb')
writer = csv.writer(output_csv, quoting=csv.QUOTE_NONNUMERIC)
writer.writerow(('message',
'source',
'published',
'scheduled_publish_time',
'genders',
'age_max',
'age_min',
'countries',
'regions',
'cities',
'relationship_statuses',
'interested_in',
'locales',
'education_statuses',
'work_networks',
'college_networks',
'college_majors',
'college_years',
'post_id'
))
posts = []
targeting_params = ['genders',
'age_max',
'age_min',
'countries',
'regions',
'cities',
'relationship_statuses',
'interested_in',
'locales',
'education_statuses',
'work_networks',
'college_networks',
'college_majors',
'college_years']
for idx, row in enumerate(list(info)):
# convert date string to unix time-stamp
if row['scheduled_publish_time'] <> '':
s = row['scheduled_publish_time']
timestamp = \
time.mktime(datetime.strptime(s, "%d/%m/%Y").timetuple())
row['scheduled_publish_time'] = timestamp
post_params = [s for s in row.keys() if s not in targeting_params]
post_params.append('targeting')
for param in targeting_params:
if len(row[param]) > 0:
row[param] = row[param].split(",")
targeting_dict = {k: row[k] for k in targeting_params}
targeting_dict = dict([(k, v) for k, v in targeting_dict.items() \
if len(v) > 0])
row['targeting'] = JSONEncoder().encode(targeting_dict)
row = {k: row[k] for k in post_params}
row = dict([(k, v) for k, v in row.items() if len(v) > 0])
message = row['message']
row[u'message'] = u''.join(unichr(ord(c)) for c in row['message'])
imagename = row[u'source']
imagedata = imagefile.extract(imagename)
files = {'source': open(imagedata, 'rb')}
api_method = 'https://graph.facebook.com/%s/feed?access_token=%s'
response = requests.post(api_method % (pageid,
token),params=row,files=files)
Sorry if this isn't clear enough. Not sure what's pertinent and what's
not. All I've changed from my previously working script is the addition of
"files" in the request, so I'm pretty sure that's where I'm making a
mistake.
Thanks!

scp files from a host via another host

scp files from a host via another host

I am on machine A, i can access machine B by ssh and from machine B to C
via ssh. But i cannot access machine C directly from A.
The problem is that i have to transfer a folder of size 5 GB to my local
machine A from C. I can do this by first transferring them to B and then
transferring to A from B. But B has limited disk space. I have a user
account on B and C, no root account. But i can do my stuff with the user
accounts.
Now please tell me how can i get that folder from C to A? I heard about
ssh tunneling here , but it is not clear to me. What should I do?

Is it good practice to use requirejs to extend single pages instead of pure javascript applications?

Is it good practice to use requirejs to extend single pages instead of
pure javascript applications?

pSo my question is mainly about the use case of RequireJS./p pI read a lot
about pure javascript driven web pages. Currently I extend single web
pages (provided by a template engine from any backend) with AngularJS
which adds a lot of value. Sadly the dependency management gets harder and
harder with every codelt;scriptgt;/code tag on other 'single pages'. Even
more when there is a codemain.js/code file which provides common libraries
(e.g. jQuery and AngularJS itself). /p pI thought this doesn't fit into
RequireJS philosophy to have emone main file/em which requires all
dependencies./p pA good example would be an administration panel which
uses some modules (defined by AngularJS's dependencies)./p
pstrongExample:/strong/p precodescripts/ adminpanel/ panel.app.js
panel.filters.js panel.directives.js antoherModule/ andAntoherModule/
require.js /code/pre h3tl;dr/h3 pWhen you use AngularJS to extend single
pages, instead of building a completely javascript driven web application,
is it good practice to use RequireJS for AMD loading modules which will be
used on the single page ? And how is the best way to do it so ?/p

Broadcom 2046 - Bluetooth doesn't connect / discover devices, 13.04

Broadcom 2046 - Bluetooth doesn't connect / discover devices, 13.04

I found many attempts to the well-known problem with Broadcom 43xx
chipsets - wireless/bluetooth not working, but I have an older version BC
2046 and can't figure out what to do.
Bluetooth won't discover or connect to previously paired devices
(apparently in prev versions of Ubuntu there wasn't an issue).
I tried to follow some advice from this thread: How to Install Broadcom
Wireless Drivers but this is a different chipset, so I really don't know
where to start.
Any suggestions?

Java lwjgl applet noclassdeffound

Java lwjgl applet noclassdeffound

I'm trying to use my java applet on a html document but It just keeps
giving the same errors over and over again. I'm using eclipse. When i
debug/run the applet it all works fine, but when I export it to a jar file
and try to use it with a html document it gives this error:
java.lang.NoClassDefFoundError: org/newdawn/slick/opengl/Texture
Here is my java code: http://pastebin.com/B3R6nj1a
This is what the .jar file contains:
-lib
-jars
lwjgl.jar
lwjgl_util.jar
slick-util.jar
-natives-win
*all the dlls*
-META-INF
-*files*
-res
grass.png
wood.png
.classpath
.project
Camera.class
Main$1.class
Main$2.class
Main.class
I do have everything right in the build path from my project. (So added
the three external jars. And added native-win to lwjgl.jar)
This is my html code:
<html>
<head>
</head>
<body>
<applet archive='3dtest.jar' Code='Main' width = "640" height =
"480"></applet>
</body>
</html>
I've also tried to change "Code='Main' " to "Code='Main.class'" also
didn't work.
Does anybody has any idea why I'm getting the error? Thanks in advance.
-Tim

iOS >> UINavigation Item Back Button Title Doesn't Change

iOS >> UINavigation Item Back Button Title Doesn't Change

I'm trying to set the BACK button for a pushed VC set within a
UINavigationController stack. I use the following code, and it's not
working - I still get the previous VC name appearing as the back button
title.
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.title = @"VC Title";
UIBarButtonItem* myBackButton = [[UIBarButtonItem alloc]
initWithTitle:@"Back"
style:UIBarButtonItemStyleBordered
target:nil
action:nil];
self.navigationItem.backBarButtonItem = myBackButton;
}
Anyone?

Keeping sorted values in Column Family

Keeping sorted values in Column Family

I need data to be sorted in columnfamily. While discovering about
cassandra I found clustering order by option for columnfamily. But while
creating columnfamilies dynamically I am unable to set this option.
Via cqlsh when I create "CREATE TABLE con1(day timestamp,ts
timestamp,value double, PRIMARY KEY(day,ts)) WITH CLUSTERING ORDER BY (ts
DESC); It stores ts values as sorted.
When I created columnfamily via hector dynamically it defaults to compact
storage.I am unable to define clustering order by using hector.
Any solution for this problem?
Is there any other way to keep values sorted in columnfamily?

Is it Possible to get GFM(Github Flavored Markdown) in Google Blogger

Is it Possible to get GFM(Github Flavored Markdown) in Google Blogger

I'm in love with the allegiance and simplicity of GFM (Github Flavored
Markdown)
to such an extension that I want to incorporate them in my Blogger (Google
Blogger)
Now by any changes is it possible to use GFM in Google Blogger other then
embedding the Gist via iframe to achieve the same (Which I'm not looking
for)
Any Suggestion

Sunday, 25 August 2013

Toggle div visibility of bootstrap slideshows

Toggle div visibility of bootstrap slideshows

I'm building a gallery page that contains many bootstrap carousels, I need
to display one at a time through a div visibility swap and I can't seem to
get it working.
I've got the multiple carousels working, and I've got the buttons I'd like
to use displayed on the right of my page. But all the attempts I've made
at toggling visibility onclick has only resulted in none of the galleries
showing.
I'd really appreciate some guidance on what I'm dong wrong Here's the page
with the two galleries: http://pink-revolver.com/fleurish/?page_id=149
Thanks!! Steph

Edit an object's methods after they've been created in Java

Edit an object's methods after they've been created in Java

In JavaScript one can create and edit an object's functions on the fly. Is
this possible with a Java object's methods? I am essentially wanting
something like this:
public class MyObject{
private int x;
public MyObject(){x = 0;}
public myMethod(){}
}
MyObject foo = new MyObject();
and later call something along the lines of:
foo.myMethod = new method({x = 42;});

Saturday, 24 August 2013

literal character in c is int or char

literal character in c is int or char

I have a question.
For example if I declare this:
int i = 0 + 'A';
'A' is considered char or int ?
some people will use:
int i = 0 + (int)'A';
but is really necessary ?

Apache configuration that avoids BEAST while giving perfect forward secrecy

Apache configuration that avoids BEAST while giving perfect forward secrecy

Gmail has an excellent rating on SSL Labs' SSL Report. It isn't vulnerable
to BEAST attacks and it has perfect forward secrecy with nearly all
current browsers.
The best Apache 2 configuration I've been able to find so far avoids BEAST
attacks, but only supports Chrome and Safari perfect forward secrecy.
Somehow Gmail was able to support current versions of IE and Firefox as
well.
Though Gmail apparently doesn't use Apache 2, I was wondering if anyone
could present an Apache configuration that has as high a quality as
Gmail's.

How to make an archive button on Tumblr?

How to make an archive button on Tumblr?

I'm making a Tumblr theme, and I want to know how to make the "Archive"
button, what URL we should give it, and how to access to the page and
style it, or its the same on all tumblr themes? (:

phone stuck while loading cyanogenmod

phone stuck while loading cyanogenmod

I am using a Samsung Galaxy Y. Everytime I switch on my phone it goes from
samsung logo to cyanogenmod loading.
What do i do? I have waited for an hour.

How to Increase session memory on iis server

How to Increase session memory on iis server

I have a asp.net project who hosted on iis7.5 server where number of user
is register simultaneously (Approx 2 user in a minutes) and after
submitting the form i have saved user id (which is unique) in session. I
will treated this user id as invoice no for the payment gateway. but here
is trouble! the payment gateway will deducted the amount and redirecting
to my thanks page but it will not updated the data of my thanks page
because it is giving error sometime. Also the bank has provided us the
pages where they received responded data through below chunk of code
Session["MerchTxnRef"] =
Page.Request.QueryString["vpc_MerchTxnRef"].Length > 0 ?
Page.Request.QueryString["vpc_MerchTxnRef"] : "Unknown";
Session["AuthorizeId"] =
Page.Request.QueryString["vpc_AuthorizeId"].Length > 0 ?
Page.Request.QueryString["vpc_AuthorizeId"] : "Unknown";
Session["ReceiptNo"] = Page.Request.QueryString["vpc_ReceiptNo"].Length >
0 ? Page.Request.QueryString["vpc_ReceiptNo"] : "Unknown";
Session["Amount"] = Page.Request.QueryString["vpc_Amount"].Length > 0 ?
Page.Request.QueryString["vpc_Amount"] : "Unknown"; Session["CardType"] =
Page.Request.QueryString["vpc_Card"].Length > 0 ?
Page.Request.QueryString["vpc_Card"] : "Unknown";
Please observer that there is 5-6 session variable using for one user,
some of created before submitting and some are using after the payment
deduction.
my problem is that some time this page(which is provided by the bank)
didn't collect the responded data and it will give the object reference
error. It is very strange that it is happening for few users.The approx
average is 10 out of hundred 100.
My assumption is there is heavy load on IIS server and session didn't work
properly. So 1. Can i increase the session memory so that it will work if
yes then how? 2. Should i call to our hosting provider?
Please response

Friday, 23 August 2013

What is this icon on the task bar?

What is this icon on the task bar?

I'm talking about the 3rd icon from the left, that looks sort of like an
envelope. It's curious, because I often get several of these, but they
mysteriously "evaporate" when you mouse over them, so it's impossible to
"ask" them what they are.

keeping image contained within another image.

keeping image contained within another image.

How can I keep a close button contained inside an image even is I change
the img size using jquery
#full_image {
width: 200px;
height: 200px;
left: 0px;
top:10px;
position: relative;
opacity: 1;
z-index: 9;
}
#full_image img {
left: 20px;
width: 339px;
height: 211px;
position: relative;
overflow: hidden;
}
#full_image .close{
background: url("http://www.sobral.ce.gov.br/saudedafamilia/close.jpg")
no-repeat;
top: 5px;
right: 0px;
cursor: pointer;
height: 29px;
opacity: 1;
position: absolute;
width: 29px;
z-index: 999;
}
<div id="full_image"><img
src="http://coe.berkeley.edu/forefront/fall2005/images/woz1.jpg" />
<span> <a href="#" class="close"></a></span>
</div>
JSFIDDLE

Xml Deserialition with c#

Xml Deserialition with c#

I am having some troubles with the deserialization of my xml string to my
object. I am not getting any errors but the values aren't populating (the
values aren't null they are just ""). I've looked a few questions that had
the same issue but those problems usually consisted of people not having
the [XmlRoot] or [XmlElement] defined.
Here is a bit of my xml string
string xmlString = @"<results><dpv_answer value=""Y"" /><zip
value=""95118-4007"" /></results>
Here is the function to deseralize.
StandardAddress address = new StandardAddress();
using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
{
try
{
address = (StandardAddress)new
XmlSerializer(typeof(StandardAddress)).Deserialize(reader);
}
catch (InvalidOperationException x)
{
// String passed is not XML, simply return defaultXmlClass
}
}
return address;
Here is a bit of the object declaration
[XmlRoot("results")]
public class StandardAddress
{
[XmlElement(ElementName = "dpv_answer")]
public string dpv_answer { get; set; }
[XmlElement(ElementName = "zip")]
public string zip { get; set; }
}

Dell QuietKey Keyboard

Dell QuietKey Keyboard

I was wondering if there is any way that I can take the keys off of my
Dell QuietKey Keyboard so I can clean the keyboard. I have tried just
prying them off, but I don't want to break them.

Error while laoding properties file from jar file

Error while laoding properties file from jar file

I am trying to load a property file from within a jar file but not able do
so. Following is the code of class in which i am loading the file
public class PropertyClass {
private static Properties properties = null;
public String getProperty(String propertyName) {
try {
InputStream inputStream =
this.getClass().getClassLoader().getResourceAsStream("resources/test.properties");
System.out.println("Input Stream " + inputStream);
properties.load(inputStream);
inputStream.close();
if (properties == null) {
System.out.println("Properties null");
}
} catch (IOException e){
e.printStackTrace();
}
return properties.getProperty(propertyName);
}
The class file and the property file both are packed inside the jar. But
when i am trying load the file from another method it gives following
error :-
Input Stream -
sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream@9304b1
Exception in thread "main" java.lang.NullPointerException
at PropertyClass.getProperty(PropertyClass.java:16)
It does not show input stream as null Following bit is the line 16 in my
code - properties.load(inputStream);
Any help on this

Statement for uncheck checkbox codeigniter

Statement for uncheck checkbox codeigniter

i want to do is a condition for unchecked. checkbox. only the
checked(checkbox) could be work for looping. And how do I stop the foreach
from running if a checkbox has not been checked?
sample looping. $count = (count($waybillno)>false);
for ($i = 0; $i < $count; $i++) {
$data = array(
'waybillno' => $waybillno[$i],
'quantity' => $quantity[$i],
'waybilldate' => $waybilldate[$i],
'declared_value' => $declared_value[$i],
'consignee' => $consignee[$i],
);

Thursday, 22 August 2013

cannot access sub folder of wordpress where I have installed another cms

cannot access sub folder of wordpress where I have installed another cms

I have installed whmcs in a wordpress site . When I try to access the
admin mysite.com/whmcs/admin I am redirected to my site error page of
wordpress . would you please guide me what should I write on .hacess file
or what should I do on myste.com/whmcs
thank you in advance for help

Code change for MySQL

Code change for MySQL

I have written some code for SQL server and would like some help to get
this code working for a MySQL database. I am not sure of the differences
and what needs to be changed.
What needs to be changed?
Here is my code:
Create Database db_person_cdtest;
USE [db_person_cdtest]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [Person](
[PersonID] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[ID] [varchar](20),
[FirstName] [varchar](50) NOT NULL,
[LastName] [varchar](50) NOT NULL,
[AddressLine1] [varchar](50),
[AddressLine2] [varchar](50),
[AddressLine3] [varchar](50),
[MobilePhone] [varchar](20),
[HomePhone] [varchar](20),
[Description] [varchar](10),
[DateModified] [datetime],
[PersonCategory] [varchar](30) NOT NULL,
[Comment] [varchar](max),
CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED
(
[PersonID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY];
CREATE PROCEDURE usp_InsertPerson
(
@ID VARCHAR(20),
@FirstName VARCHAR(50),
@LastName VARCHAR(50),
@AddressLine1 VARCHAR(50),
@AddressLine2 VARCHAR(50),
@AddressLine3 VARCHAR(50),
@MobilePhone VARCHAR(20),
@HomePhone VARCHAR(20),
@Description VARCHAR(10),
@Comment VARCHAR(max)
)
AS
BEGIN
Declare @PersonCategory VARCHAR(30)
SET @PersonCategory = dbo.usp_PersonCategoryLookup(@ID, @Description)
INSERT INTO Person(ID, FirstName, LastName, AddressLine1, AddressLine2,
AddressLine3, MobilePhone, HomePhone, Description, DateModified,
PersonCategory, Comment)
VALUES (@ID, @FirstName, @LastName, @AddressLine1, @AddressLine2,
@AddressLine3, @MobilePhone, @HomePhone, @Description, GETDATE (),
@PersonCategory, @Comment)
END
CREATE PROCEDURE usp_UpdatePerson
(
@PersonID numeric(18, 0),
@ID VARCHAR(20),
@FirstName VARCHAR(50),
@LastName VARCHAR(50),
@AddressLine1 VARCHAR(50),
@AddressLine2 VARCHAR(50),
@AddressLine3 VARCHAR(50),
@MobilePhone VARCHAR(20),
@HomePhone VARCHAR(20),
@Description VARCHAR(10),
@Comment VARCHAR(max)
)
AS
BEGIN
Declare @PersonCategory VARCHAR(30)
SET @PersonCategory = dbo.usp_PersonCategoryLookup(@ID, @Description)
Update Person set ID=@ID, FirstName=@FirstName, LastName=@LastName,
AddressLine1=@AddressLine1, AddressLine2=@AddressLine2,
AddressLine3=@AddressLine3, MobilePhone=@MobilePhone,
HomePhone=@HomePhone, Description=@Description, DateModified=GETDATE (),
PersonCategory=@PersonCategory, Comment=@Comment where PersonID=@PersonID
END
CREATE PROCEDURE usp_SearchPerson
(
@SearchCriteria VARCHAR(50)
)
AS
BEGIN
Select * from Person where FirstName like @SearchCriteria or LastName like
@SearchCriteria or PersonCategory like @SearchCriteria
END
CREATE PROCEDURE usp_SelectPerson
(
@PersonID numeric(18, 0)
)
AS
BEGIN
select * from Person where PersonID=@PersonID
END
CREATE FUNCTION usp_PersonCategoryLookup
(
@ID VARCHAR(20),
@Description VARCHAR(10)
)
RETURNS VARCHAR(30)
AS
BEGIN
return @ID + @Description
END

U-boot with redundant environment, fw_setenv does not update both environments

U-boot with redundant environment, fw_setenv does not update both
environments

why fw_setenv tool set value of variable only for one environment?
I am using uboot with redundant env (#define CONFIG_ENV_OFFSET 0xc0000,
#define CONFIG_ENV_OFFSET_REDUND 0x100000 ), and I am going to set value
of uboot env variable from linux. There is fw_setenv/fw_printenv tool
which can do this:
# fw_printenv rootfs
rootfs=mtd6
# fw_setenv rootfs mtd7
Check that it is realy was set:
# fw_printenv rootfs
rootfs=mtd7
Seems OK, but after reboot system and entering to u-boot console, the
value of rootfs variable is former. uboot read former value:
=> printenv
rootfs=mtd6
Then I have looked at the hexdump output of mtd devices where uboot envs
placed.
Before setting rootfs mtd7:
# hexdump -C /dev/mtd3 | head -n 200
. . . . .
000000a0 65 6c 61 79 3d 35 00 62 61 75 64 72 61 74 65 3d
|elay=5.baudrate=|
000000b0 31 31 35 32 30 30 00 72 6f 6f 74 66 73 3d 6d 74
|115200.rootfs=mt|
000000c0 64 36 00 00 ff ff ff ff ff ff ff ff ff ff ff ff
|d6..............|
000000d0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|................|
Here rootfs=mtd6, seems OK.
# hexdump -C /dev/mtd4 | head -n 200
. . . . .
00000090 6f 66 66 3b 20 62 6f 6f 74 6d 00 62 6f 6f 74 64 |off;
bootm.bootd|
000000a0 65 6c 61 79 3d 35 00 62 61 75 64 72 61 74 65 3d
|elay=5.baudrate=|
000000b0 31 31 35 32 30 30 00 00 00 ff ff ff ff ff ff ff
|115200..........|
000000c0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|................|
There is no rootfs variable defined in env on redundant part. Why??
After using fw_setenv rootfs mtd7
# hexdump -C /dev/mtd3 | head -n 200
000000a0 65 6c 61 79 3d 35 00 62 61 75 64 72 61 74 65 3d
|elay=5.baudrate=|
000000b0 31 31 35 32 30 30 00 72 6f 6f 74 66 73 3d 6d 74
|115200.rootfs=mt|
000000c0 64 36 00 00 ff ff ff ff ff ff ff ff ff ff ff ff
|d6..............|
000000d0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|................|
The environment on mtd3 stay unchanged (rootfs=mtd6).
# hexdump -C /dev/mtd4 | head -n 200
000000a0 65 6c 61 79 3d 35 00 62 61 75 64 72 61 74 65 3d
|elay=5.baudrate=|
000000b0 31 31 35 32 30 30 00 72 6f 6f 74 66 73 3d 6d 74
|115200.rootfs=mt|
000000c0 64 37 00 00 ff ff ff ff ff ff ff ff ff ff ff ff
|d7..............|
000000d0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|................|
The new rootfs variable has been wrote on mtd4.
So the content in the uboot environments is not the same. How to properly
set env from linux?

Backbone: using setInterval

Backbone: using setInterval

I need the view to refetched the collection and re-render every 30
seconds. The problem is that once I change page (without a full page
refresh) the setInterval stays on memory and keeps refetching in the
background. However the view has long been destroyed.
Code:
define(
[
"underscore",
"collection/system/feed",
"view/list",
"text!template/index/system-feed.html"
],
function (_, Collection, ListView, Template) {
return ListView.extend({
el: '<div id="main-inner">',
collection: new Collection(),
loading: true,
client: false,
initialize: function (options) {
this.collection.fetch();
this.collection.on('reset', this.onFetchCollection, this);
var self = this;
setInterval(function() {
self.collection.fetch();
}, 30000);
},
/*collection is returned, so reset the loading symbol and set
the posts to the render*/
onFetchCollection: function () {
this.list = this.collection.toJSON();
this.loading = false;
this.render();
},
render: function () {
var html = _.template(Template, {loading: this.loading,
client: this.client, list: this.list});
this.$el.html(html);
return this;
}
});
}
);

trouble with using textFieldShouldEndEditing after my popover gets dismissed

trouble with using textFieldShouldEndEditing after my popover gets dismissed

I'm bringing up a popover that has a field in it. I'm using
"textFieldShouldEndEditing" to do some validation of the text. If the
entered text is invalid, I return "NO".
The problem when I dismiss my popover. If the text is invalid,
textFieldShouldEndEditing returns "NO". After I dismiss my popover, and
click in any other text field, the field doesn't not get selected. I can't
type in any other field, the keyboard doesn't show up.
What's the best way to avoid this behavior?

Check for Updates functrionality For Windows application

Check for Updates functrionality For Windows application

I am using Install shield limited edition to install my WPF application.
My current scenario is like this.
The created set up is available in our website for downloading.
User can download and then Install the set up on their own machines.
I have option to modify the software and will update the modified
installer into the website , so that users will get the updated
software.
My Next step:
In my application I am going to include "Maintenance release (Download
Updates)" functionality. So that users can download the latest updations
automatically from the software itself.
How Can I do this.? Any help would be appreciated. Is there any facility
in the Install shield for this?

Wednesday, 21 August 2013

Centering an ImageView in FullScreen mode

Centering an ImageView in FullScreen mode

I am simply trying to center an ImageView in a FullScreen app. I've read
several posts on this site on people asking what seems like same question,
and I've tried everything I've read, but I can't seem to get it to center.
Here is my code for the layout. I realize there might be some overkill
here to get the centering, as a result of trying various other posts. This
code puts the image on the top left part of the screen.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:background="#000000"
android:orientation="vertical" >
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="false"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:contentDescription="@string/descImage"
android:cropToPadding="false"
android:gravity="center"
android:src="@drawable/placeholder" />
Here is my full screen code in AndroidManifest.xml.
android:screenOrientation="landscape"
android:theme="@style/Theme.FullScreen">
Theme.FullScreen is defined as
<style name="Theme.FullScreen" parent="@android:style/Theme.Holo">
<item name="android:windowNoTitle">false</item>
<item name="android:windowFullscreen">true</item>
</style>
Thanks.

Autodocument entire python project with Sphinx

Autodocument entire python project with Sphinx

I want to generate a Spinx documentation website for my entire project.
This seems really basic but somehow it is quite complicated!
I have a well-documented python project inside a directory so everything
is like:
projectFolder:
-__init__.py
-folderA:
--__init__.py
--somefile.py
-folderB:
--__init.py
--anotherfile.py
The closest I have got is creating a sphinx project like:
$ mkdir docs
$ cd docs
$ spinx-quickstart
Then runnng:
$ sphinx-apidoc -o . /path/to/my/source/files
$ make html
This will generate a set of html files for each module with a list of
functions inside but those functions are blank.

Having issues converting ModalView code

Having issues converting ModalView code

I am trying to implement the modalview asp.net mvc version of the modal
view here: http://demos.kendoui.com/mobile/modalview/index.html#/ . The
razor code is written in C# but I want it to be in vb.
Here's it's code
@(Html.Kendo().MobileView()
.Name("modalview-camera")
.Title("HTML5 Camera")
.Content(
@<text>
<img
src="@Url.Content("~/content/mobile/modalview/lens.png")"
class="camera-image" /><br />
@(Html.Kendo().MobileButton()
.Text("Login")
.Name("modalview-open-button")
.Rel(MobileButtonRel.ModalView)
.Url("#modalview-login")
)
</text>)
)
@(Html.Kendo().MobileModalView()
.Name("modalview-login")
.HtmlAttributes(new { style = "width: 95%; height: 18em;" })
.Header(obj =>
Html.Kendo().MobileNavBar()
.Content(navbar =>
@<text>
<span>Login</span>
@(Html.Kendo().MobileButton()
.Text("Cancel")
.Align(MobileButtonAlign.Right)
.Events(events =>
events.Click("closeModalViewLogin"))
)
</text>)
)
.Content(
@<text>
@ModalViewContentTempalte()
</text>)
)
@helper ModalViewContentTempalte()
{
@(Html.Kendo().MobileListView().Style("inset")
.Items(items =>
{
items.Add().Content(
@<text>
<label for="username">Username:</label> <input
type="text" id="Text1" />
</text>);
items.Add().Content(
@<text>
<label for="password">Password:</label> <input
type="password" id="password1" />
</text>);
})
)
@(Html.Kendo().MobileButton()
.Text("Login")
.Name("modalview-login-button")
.Events(events => events.Click("closeModalViewLogin"))
)
@(Html.Kendo().MobileButton()
.Text("Register")
.Name("modalview-reg-button")
.Events(events => events.Click("closeModalViewLogin"))
)
}
Here's what I have so far:
@Code
Html.Kendo.MobileView.Name("modalview-camera").
Title("Sample Login").
Content(@: @Code Html.Kendo.MobileButton().
Text("Login").
Name("modalview-open-button").
Rel(MobileButtonRel.ModalView).
Url("#modalview-login")
END Code )
End Code
@Code
Html.Kendo.MobileModalView.
Name("modalview-login").
HtmlAttributes(New With {.style = "width: 95%; height: 18em;"}).
Header(Function(obj) Html.Kendo.MobileNavBar.
Content(Function(navbar)@: <span>Login</span> @CODE
Html.Kendo.MobileButton().
Text("Cancel").
Align(MobileButtonAlign.Right).
Events(Function(events)
events.Click("closeModalViewLogin"))
END code
End Function)).
Content(@: @ModalViewContentTemplate )
End Code
@helper ModalViewContentTemplate()
@Code
Html.Kendo.MobileListView.Style("inset").
Items(Function(items)
items.Add.Content(@:<label
for="username">UserName:</label><input type="text"
id="txt1" />)
items.Add.Content(@:<label
for="password">Password:</label><input
type="password" id="password1" />)
End Function)
End Code
@CODe
Html.Kendo.MobileButton().
Text("Login").
Name("modalview-login-button").
Events(Function(events) events.Click("closeModalViewLogin"))
End Code
@CODe
Html.Kendo.MobileButton().
Text("Register").
Name("modalview-reg-button").
Events(Function(events) events.Click("closeModalViewLogin"))
End Code
End Helper
I'm getting Expression expected errors. Two are at items.add.content. One
is in the content in the mobileview portion. Last one is in the content of
the mobilemodalview. I am still learning this. I thought I converted it
properly but there is something I am not doing correctly. Do any know what
I may be doing wrong with this?

How do I run tests without exporting all the symbols

How do I run tests without exporting all the symbols

I have (at least) one package where my main program lives. I have another
package for running tests. I :use the package of the main program in the
defpackage form of the test package but that only imports the exported
symbols. So I can't test all of functions, only the ones I have explicitly
exported (the public API). How to I solve this issue?

jquery wait for SVG to be created then run function

jquery wait for SVG to be created then run function

Simply, I'm trying to get some jQuery to run after an SVG has been
generated by D3.
I've tried placing function 2 inside function 1:
function 1(){
D3 Code here...
function2();
};
However this is running too soon, I've tried using $(document).load() and
$(window).load(), again it's still too soon, the code works when I call
the function from the terminal in Chrome, I've also tried creating an
event listener, waiting for
<g ... id='csv'>
to be created.
http://msc-media.co.uk/4SQ/city_profile.php : the donut in the middle is
where the tooltips should be working. If you want to see them, call
'tooltip();' in the console.
Here's the full code (ignore the PHP calls):
function tooltip(){
$(".graph-cardiff").qtip({ // Grab some elements to apply the
tooltip to
content: {
attr: "data-title"
}
});
}
function donut_'.$city.'(){
var width = '.$width.',
height = '.$height.',
radius = Math.min(width, height) / 2,
color = d3.scale.category20c();
var svg = d3.select("'.$div.'").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height * .52 +
")")
.attr("id", "svg");
var partition = d3.layout.partition()
.sort(null)
.size([2 * Math.PI, radius * radius])
.value(function(d) { return 1; });
var arc = d3.svg.arc()
.startAngle(function(d) { return d.x; })
.endAngle(function(d) { return d.x + d.dx; })
.innerRadius(function(d) { return Math.sqrt(d.y); })
.outerRadius(function(d) { return Math.sqrt(d.y + d.dy); });
d3.json("js/'.$city.'.json", function(error, root) {
var path = svg.datum(root).selectAll("path")
.data(partition.nodes)
.enter().append("path")
.attr("display", function(d) { return d.depth ? null : "none";
}) // hide inner ring
.attr("d", arc)
.attr("class", "graph-'.$city.'")
.attr("data-title", function(d) { return d.name })
.attr("data-size", function(d) { return d.size; })
.style("stroke", "#fff")
.style("fill", function(d) { return color((d.children ? d :
d.parent).name); })
.style("fill-rule", "evenodd")
.each(stash);
d3.selectAll(".button-'.$city.'").on("change", function change() {
var value = this.value === "count"
? function() { return 1; }
: function(d) { return d.size; };
path
.data(partition.value(value).nodes)
.transition()
.duration(1500)
.attrTween("d", arcTween);
});
});
// Stash the old values for transition.
function stash(d) {
d.x0 = d.x;
d.dx0 = d.dx;
}
// Interpolate the arcs in data space.
function arcTween(a) {
var i = d3.interpolate({x: a.x0, dx: a.dx0}, a);
return function(t) {
var b = i(t);
a.x0 = b.x;
a.dx0 = b.dx;
return arc(b);
};
}
d3.select(self.frameElement).style("height", height + "px");
tooltip();
}
donut_'.$city.'();

prove $\int^\infty_0\frac x{e^x-1}dx=\frac{\pi^2}{6}$

prove $\int^\infty_0\frac x{e^x-1}dx=\frac{\pi^2}{6}$

I know that $$\int^\infty_0\frac x{e^x-1}dx=\frac{\pi^2}{6}$$ For
substitute $u=2$ into
$$\zeta(u)\Gamma(u)=\int^\infty_0\frac{x^{u-1}}{e^x-1}dx$$
However, I suspect that there is an easier proof, maybe by the use of
complex analysis. I haven't learnt zeta function yet. All I know is the
above formula and $\zeta(2)=\frac{\pi^2}{6}$. But I am wondering if we can
use the above integral to find out some of the $\zeta$'s value.

Tuesday, 20 August 2013

Base64 image data not working with loadfromJSON in fabricjs

Base64 image data not working with loadfromJSON in fabricjs

I am trying to load a json object which has a image object. Image object
is having base 64 image data as background. But i am unable laod the
loadFromJSON method.
Code:
var jsonDataSet =
'{"objects":[{"type":"image","originX":"left","originY":"top","left":0,"top":0,"width":700,"height":600,"fill":"rgb(0,0,0)","overlayFill":null,"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,"selectable":false,"hasControls":true,"hasBorders":true,"hasRotatingPoint":true,"transparentCorners":true,"perPixelTargetFind":false,"shadow":null,"visible":true,"clipTo":null,"src":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAn4AAAFPCAYAAADTHsP1AAAgAElEQ…Lv/vuU1wVsyvXK+Kks1f6gffSCThZ1km3u6NFklCnFes//AbZzi+iGF3/7AAAAAElFTkSuQmCC","filters":[]}],"background":""}';
canvas.loadFromJSON (jsonDataSet);
canvas.renderAll();
It is displaying an error as "Error loading
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAn4AAAFPCAYAAADTHsP1AAAgAElEQ…Lv/vuU1wVsyvXK+Kks1f6gffSCThZ1km3u6NFklCnFes//AbZzi+iGF3/7AAAAAElFTkSuQmCC
"

AJAX Autosave and Rails API callback

AJAX Autosave and Rails API callback

So assume that I have a Rails app in which users can write their own blog
posts of sorts. I'd like the user to be able to open a new page for
creating blog posts, and have the blog post automatically be created
through a AJAX call on keyup. However, once the post is created I'd like
every keyup after that to automatically update the post that was
originally created.
I know how to perform the AJAX call on keyup, and I know how to perform an
AJAX call every so often after a keyup, but I don't know how to get the
unique ID of the post back so each save after the first is an update to
the original post.
This is a typical Rails app with publicly accessible API routes, I just
need to be given the created posts ID on a successful AJAX PUT request.
Advice? This seems like it should be relatively simple.

Compiling and Building a Slim version of avconv/ffmpeg for STM32F4-Discovery - an armv7 thumb 1/2 architecture

Compiling and Building a Slim version of avconv/ffmpeg for
STM32F4-Discovery - an armv7 thumb 1/2 architecture

This is my first attempt at posting for help on Stack Overflow.
My Project: Using an STM32F4-Discovery with the STM32F407VGT6 chip with
the FPv4-SP and a camera/LCD peripheral setup, I need to record video at
QVGA and output into a compressed MPEG-4 format with at least a 25:1
ratio.
I have identified the desired codec library (avconv, unless ffmpeg proves
more useable) and am now in the process of trying to build the compiler
options to give me a light-weight version that will be able to execute on
the chip in ANSI-C and Thumb architecture.
This board has very limited space (192KB SRAM and 1MB of Flash - there is
the possibility of expansion, but it would be preferred to use just what I
have) and currently the "main" executable of either library is over 1MB.
Judging by the output with the different solutions I have tried - it does
not appear many of the compiler options are successfully applying to the
build. So my questions are:
1) Is it even possible to compile either library into the space desired
using only rawvideo decoders, mpeg4 encoders, and the most basic utilities
possible? If not, is there a guesstimate out there of how much would be
required?
2) I've spent many hours scouring the internet, and it doesn't appear that
anyone has attempted this - is there anyone out there who can tell me
otherwise?
I have my configure/build script on hand for anyone who wants to take a
look and see if I have missed something basic. Just ask and I will email
it, I don't want to clutter the thread more than my seemingly verbose
inquisition already has.
I would assume that neither library is likely broken. I have been
attempting this on Ubuntu 12.04 32-bit.
I am a software intern and would be extremely appreciative of any help
available.
One final question, should my solution prove unworkable, is there another
open-source mpeg4 compression library that can easily compile for embedded
ARMv7E-M/Thumb set architecture?

Android SQLite Database Conection Error

Android SQLite Database Conection Error

I want to Connect my App with a Database on the Android Phone, so I've
written a Class called DBHelper.
But I get An Error, wich Says "MODE_PRIVATE" connot be resolved to a
variable. So i made "Context.MODE_PRIVATE". Now, the Variable can be
resolved, but I get a new Error: "The method openOrCreateDatabase(String,
int, null) is undefinded for the Type DBHelper". It dont helps if I use
DBHelper.this.openOrCreateDatabase to open it.
Can anybody help me?
This is my Code:
public class DBHelper {
SQLiteDatabase db;
public void insert(String news, Context con){
db = openOrCreateDatabase("PlanB", con.MODE_PRIVATE, null);
db.execSQL("DROP TABLE IF EXISTS News");
db.execSQL("CREATE TABLE IF NOT EXISTS INBOX(id INTEGER,title
VARCHAR,text VARCHAR,date VARCHAR);");
String[] divided = news.split("/newentry/");
int length = divided.length;
int pos = 0;
while(pos <= length){
String[] entry = divided[pos].split("/;/");
db.execSQL("INSERT INTO INBOX
VALUES('"+entry[0]+"','"+entry[1]+"','"+entry[2]+"','"+entry[3]+"');");
pos++;
}
db.close();
}
}

how to wait for some event to complete in jmeter load tests

how to wait for some event to complete in jmeter load tests

How can I waitforapagetoload in jmeter. I have entered some data and after
this it usually takes some random time to execute e.g stored procedures
etc. I don't know how can I do this in jemeter load tests. I tried putting
constant time but still it keeps failing. Please guide.

How to query below Web Service in java

How to query below Web Service in java

i want to connect to below web service in java. i just have below XML code :
<acc>
<tel>{Number}</tel>
<code>6575</code>
<password/>
<balance>-1</balance>
<rate>-1</rate>
</acc>
i want to create its function and use it.how could i use it?
i have below URL To connect to web service :
xyz:xx/vacc/create-code/%7bNumber%7d
i want java create the class automatically.

Specific If Else Case in Jsf to control the visibility of jsf components

Specific If Else Case in Jsf to control the visibility of jsf components

i have the following panelGroup in jsf:
<h:panelGroup rendered="#{true}">
<h:outputFormat value="#{txt.text_a}">
<f:param value="#{bean.get_a}" />
</h:outputFormat>
</h:panelGroup>
Now i have an another jsf tag:
<h:outputText value="#{bean.get_b}" />
I need inside the outputFormat tag a kind of if-else case to control, wheter
<h:outputFormat value="#{txt.text_a}">
<f:param value="#{bean.get_a}" />
</h:outputFormat>
or
<h:outputText value="#{bean.get_b}" />
is visible. Inside the java bean class, which called "testBean" i have an
value "visible", which a value, which can represent the the checksum for
the if statement.
Is it possible to create this kind of if Else Statment in JSF?
Thanks for helping me!
Greetz Marwief

Monday, 19 August 2013

enabling shell access for cyrus user

enabling shell access for cyrus user

My current cyrus user in /etc/passwd looks like this:
cyrus:x:76:12:Cyrus IMAP Server:/var/lib/imap:/sbin/nologin
I want to be able to give it shell access but restrict it to /var/lib/imap
and /var/spool/imap. How do I enable the shell to allow this using
usermod? And once this is done, will the cyrus user be able to ssh into
the server or should I make changes in sshd_config?
Purpose: Need to rsync mail for backup using cyrus user

possible to refresh (not reload) a parent page with javascript?

possible to refresh (not reload) a parent page with javascript?

I have a page that shows images. if a certain record doesn't have an image
associated with it yet, I provide the user with a pop-up window link so
that they can upload an image. When the user submits the form on the
pop-up, it refreshes, uploads the image and then automatically closes.
Before the pop-up closes, i want to refresh (not reload) the parent. The
reason I don't want to reload is because I'm using post data to
dynamically populate the page content. If I reload, all the previous data
is lost. I tried to change window.opener.location.reload(true); to
window.opener.location.refresh(true); ... but apparently that's not a
valid command.
Is there a way to refresh the parent page instead of simply reloading it?

Google Guice - Use generic as parameter of injected field

Google Guice - Use generic as parameter of injected field

I want to use a generic parameter of a class for a field that is injected,
but guice complains about a unbound key. Is it possible to inject the
field in Test2?
Example:
public static class Test1<T1> {
}
public static class Test2<T2> {
@Inject
public Test1<T2> test;
}
public static void main(String[] args) throws Exception {
Injector injector = Jsr250.createInjector(Stage.PRODUCTION, new
TestModule());
Test2<String> test = injector.getInstance(Key.get(new
TypeLiteral<Test2<String>>(){}));
}
private static class TestModule extends AbstractModule {
@Override
protected void configure() {
bind(new TypeLiteral<Test1<String>>(){}).toInstance(new
Test1<String>());
bind(new TypeLiteral<Test2<String>>(){}).toInstance(new
Test2<String>());
}
}

GOTO was unexpected at this time

GOTO was unexpected at this time

We are trying to run a custom .BAT file that has worked fine under Win98
for years, but we just got a new server over the weekend and Win98 virtual
machine does not work now apparently. So, I'm trying to set this up so
it'll work through WinXP command prompt. What do I need to change to make
this work with XP?

I type in the .BAT file and it runs fine. It allows me to type in the
date, but when I type in the date as we normally do and hit enter, I get
"GOTO was unexpected at this time":

:CRLIST.BAT - DAILY C/R DEPOSIT LIST
:
@ECHO OFF
CALL SEARCH
CRDATE.EXE
IF EXIST DEPOS.LS DEL DEPOS.LS
CASHLIST.EXE
CALL QPR DEPOS.LS 2

I found GOTO in the QPR.BAT file. Here's the code for QPR.BAT:

:QPR.BAT - COPY SPECIFIED LISTING FILE ( .LS) TO SPECIFIED PRINTER PORT (1-9)
: WITH FF FOLL'G - LPTx MUST ALREADY BE CAPTURED TO DESIRED PRINTER
:
@ECHO OFF
IF "%1==" GOTO OPERR
IF "%2==" GOTO OPERR
COPY %1 LPT%2
CALL FF%2
GOTO END

:OPERR
ECHO Please re-enter this Print Queue command as follows:
ECHO QPR xxxxx.LS n
ECHO.
ECHO where xxxxx.LS is the name of the report listing file,
ECHO and n is the Network Printer No. on which to print.
:END

I've been reading different threads and I've tried changing "%1==" to
"%1"=="", same for %2, and it'll then give me a new message saying:

The system cannot find the specified file.
0 file(s) copied.
The system cannot find the specified file.
0 files(s) copied.

If I add "%%1"=="", "%%2"=="", and then add an extra % anywhere there is a
single one, it'll display:

The system cannot find the specified file.
The system cannot find the specified file.
0 files(s) copied.

Do I need to provide the code for anything else? There are a lot of .BAT
files so if I can get this figured out, they hopefully we can apply to the
rest of the commands.

c# object.Dispose() or object = null

c# object.Dispose() or object = null

Hi I have an object has is Disposable and I would like to know what is
better:
this.object.Dispose();
or
this.object = null;
or
this.object.Dispose();
this.object = null;
Thanks

PHP Mysql with fetch array

PHP Mysql with fetch array

$bagianWhere = "";
if (isset($_POST['chkBadge']))
{
$badge_id = $_POST['badge_id'];
if (empty($bagianWhere))
{
$bagianWhere .= "t_emp.badge_id = t_balance.badge_id and
E.badge_id = '$badge_id'";
}
}
$query = "SELECT t_emp.badge_id, t_emp.emp_name,
t_balance.badge_id,
t_balance.balance_amount
from t_emp, t_balance WHERE
".$bagianWhere ;
$hasil = mysql_query($query);
while ($data = mysql_fetch_array($hasil))
I don't know what happened with my PHP code. I tried hard, but still
facing problem with error like this :
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean
given in ...
Anyone advice please.

Sunday, 18 August 2013

Return redirect url sing jquery (javascript)

Return redirect url sing jquery (javascript)

I need to get the redirect url's for a list of 100 websites using
javascript. For example wnbc.com is redirected to nbcnewyork.com. So this
code below should return "nbcnewyork.com"
$.ajax({
type: "POST",
url: "http://www.wnbc.com",
dataType: "script",
success: function (data, textstatus, xhrreq) {
alert('You are now at URL: ' + xhrreq.getResponseHeader());
}
});

Asymptotic behavior of a sum

Asymptotic behavior of a sum

This is the extension of my previous question. Let $A= \sum_{x_1=0}^m \sum
_{x_2=0}^m \cdots \sum_{x_n=0}^m \min_r(x_1, x_2,.., x_n)$ where $\min_r$
is the $r^{th}$ minimum of $(x_1, x_2,.., x_n)$. For example if $x_1\leq
x_2 \leq \cdots x_r \leq \cdots $ then $\min_r(x_1, \ldots, x_n)=x_r.$
Now let $B =\sum_{k=0}^m n \binom{n-1}{r-1}k^{r-1}(m-k)^{n-r}k.$ Is it
true $\frac{A}{B} \rightarrow 1$ as $m $ approaches to infinity?

How to show a button on screen touch, while keeping the swipe?

How to show a button on screen touch, while keeping the swipe?

I have an activity with some images and I'm using swipe to load the next
image. I need when I touch the image to show a button, for image saving.
How can I do that? Here's my code:
public class Photo_gallery extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.photo_gallery);
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
ImagePagerAdapter adapter = new ImagePagerAdapter();
viewPager.setAdapter(adapter);
}
private class ImagePagerAdapter extends PagerAdapter {
private int[] mImages = new int[] {
R.drawable.p1,
R.drawable.p2,
R.drawable.p3,
R.drawable.p4,
.
.
.
R.drawable.p108
};
@Override
public int getCount() {
return mImages.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((ImageView) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
Context context = Photo_gallery.this;
ImageView imageView = new ImageView(context);
int padding = context.getResources().getDimensionPixelSize(
R.dimen.padding_medium);
imageView.setPadding(padding, padding, padding, padding);
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
imageView.setImageResource(mImages[position]);
((ViewPager) container).addView(imageView, 0);
return imageView;
}
@Override
public void destroyItem(ViewGroup container, int position, Object
object) {
((ViewPager) container).removeView((ImageView) object);
}
}
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
}

Facebook API JavaScript send message

Facebook API JavaScript send message

I want to send a link with a little text to a specific friend via Facebook
API. Here is my code:
function facebook_send_message(to) {
FB.ui({
app_id:'XXXXXXXXXXXX',
method: 'send',
name: "a name",
link: 'http://www.example.com/',
to:to,
description:'description'
});
}
Code idea from http://stackoverflow.com/a/9328349/2056125
Is there a way to put a little text through the message, that will be send
with the link? For example "Hey friendname! This is an example message" -
http://www.example.com/

Error in my MySQL statement

Error in my MySQL statement

This is an error I am getting:
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 'SET belongs_to
= 'kl', SET college = 'klnmhj' , SET works_a' at line 4
I'm not able to figure out how to deal with this error. Help please!

Extract phone number from text

Extract phone number from text

I want to build a method that will get a string (preferably the text of a
textblock) and it will identify and highlight any phone numbers in the
string. The goal is to enable the user to tap any number and directly call
or text it(by using the appropriate launcher).
How can I work this out? Any ideas? Thank you in advance!

Saturday, 17 August 2013

Java - What Should I Learn Next?

Java - What Should I Learn Next?

Well, I've been trying to teach myself Java. I'm really at a place now
where I'm stumped. I basically don't know where to go/what to learn next.
I know 'if/else statements' 'strings,ints,floats' 'loops' - I can
basically do the very basic stuff in console.
I don't know what to learn next though? Arrays? I want to learn more, but
don't know what. I'm trying to expand OUT of console, would arrays be the
place to go?
Thanks

How to manage ATM Bank accounts w/ Java

How to manage ATM Bank accounts w/ Java

This is a two part question. Pt. 1: I am trying to make an ATM program in
Java just for fun and practice in the language, but I do not know how to
create and store 'users' if you will. I have this class made.
public class User {
// Creating userCode var as data type integer.
private int userCode;
// Creating PIN var as data type integer.
private int PIN;
// Creating a savings account balance.
private double savingsAccount;
// Creating a checking account balance.
private double checkingAccount;
I need to know how to create new accounts with a chosen userCode and PIN,
'save' them, and then when a user enters their code, find their account
and load in their current balances and PIN.
Pt. 2: How can I create a database to store the user's balances, etc.
permanetly on my computer in a pList, or some other data storage file.
Thanks!!