Thursday, 3 October 2013

Checking the AsyncTask status seems not working correctly (log doesn't appear on log cat)

Checking the AsyncTask status seems not working correctly (log doesn't
appear on log cat)

I'm trying to see how works an Asynctask class in android. In particular i
want reveal in real time the status of the class for see when it is
running and when it has finished. For do this, i have created a class that
extend the main activity and another class that is the asynctaks class.
This is my main class:
public class PhotoManagement extends Activity{
private String numberOfSelectedPhotos;
private Bitmap currentImage;
private String initConfiguration = "http://www.something.com";
private String response;
private ArrayList<String> formatPhotoList = new ArrayList<String>();
//create a list that will contains the available format of the photos
downloaded from the server
private ArrayList<String> pricePhotoList = new ArrayList<String>();
//create a list that will contains the available price for each format of
the photos
DownloadWebPageTask webPage = new DownloadWebPageTask();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
protected void onResume(){
super.onResume();
new DownloadWebPageTask().execute(initConfiguration);
if(webPage.getStatus() == AsyncTask.Status.PENDING){
Log.i("STATUS","PENDING");
}
if(webPage.getStatus() == AsyncTask.Status.RUNNING){
Log.i("","RUNNING");
}
if(webPage.getStatus() == AsyncTask.Status.FINISHED){
Log.i("","FINISHED");
}
}
}
As you can see i want only see the passages of the status with a simple
log. And here there is the asynctask class.
private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... urls) {
for (String url : urls) {
DefaultHttpClient client = new DefaultHttpClient(); //create a
new http client
HttpGet httpGet = new HttpGet(url); //create a new http
request passing a valid url
try {
HttpResponse execute = client.execute(httpGet); //try to
execute the http get request
InputStream content = execute.getEntity().getContent();
//prepare the input stream to read the bytes of the
request
BufferedReader buffer = new BufferedReader(
new InputStreamReader(content));
String s = "";
while ((s = buffer.readLine()) != null) {
response += s; //until is present a line to read, the
response variable store the value of the lines
}
} catch (Exception e) {
Log.i("MyApp", "Download Exception : " + e.toString());
//Print the error if something goes wrong
}
}
return response; //return the response
}
@Override
protected void onPostExecute(String result) {
result = doInBackground(initConfiguration); //take the result from
the DownloadWebPageTask class
result = result.replace("null", "");
Log.i("RESULT",""+result);
//find the price and format value from the result using XmlPullParser
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput( new StringReader ( result ) );
int attributeNumber = xpp.getAttributeCount();
int eventType = xpp.getEventType();
String currentTag = null;
while(eventType != XmlPullParser.END_DOCUMENT){
if(eventType == XmlPullParser.START_TAG) {
currentTag = xpp.getName();
if (currentTag.equals("product")){
xpp.getAttributeValue(null, "name");
formatPhotoList.add(xpp.getAttributeValue(null,
"name"));
Log.i("FORMAT
PHOTO",""+xpp.getAttributeValue(null, "name"));
}
}
eventType = xpp.next();
}
} catch (XmlPullParserException e) {
e.printStackTrace();
Log.i("","ERROR XML PULL PARSER");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.i("","ERROR IOEXCEPTION");
}
}
}
}
As you can see i have implemented also the method onPostExecute that
should be called when the asynctask method has finished to execute the
instructions right? So at this point i don't understand why my log RUNNING
and my log FINISHED never appear on the log cat. What i'm doing wrong? I'm
tried to follow this topic Android, AsyncTask, check status? but in my
case it isn't working.
Thanks

Wednesday, 2 October 2013

HTML linking titles and subtitles in php

HTML linking titles and subtitles in php

I am trying to make a wikipedia like thing that makes a little list with
clickable links of all the html titles <h1></h1> and <h2></h2>
So
<h1>Title</h1>
[random text about things]
<h2>subtitle</h2>
[random text]
<h2>subtitle2</h2>
<h1>Title2</h1>
[random text about things]
<h2>subtitle3</h2>
[random text]
<h2>subtitle4</h2>
would become
Title - subtitle - subtitle2 Title2 - subtitle3 - subtitle4
with all subtitles being links to that html part.
I'm thinking myself of preg_replace things, but not sure if that is the
best way. Tips?

Best Way to Make AJAX Call from WebForms Page

Best Way to Make AJAX Call from WebForms Page

Is there a recommended way to make an AJAX call within a WebForms
application?
I know there is the built-in ASP.NET AJAX components, but they seem a bit
heavy. I'm used to doing this in MVC and it seems very clean.
I can use Page Methods, but they require that my method is static, which
makes it more difficult to access my database, etc.
I assume I can also just use jQuery to make the call, although attempts at
this have failed in the past, usually due to problems with the way data
was returned (JSON, etc.).
My goal is get pass a string fragment and get back a list of items that
match that fragment. Speed would be nice. Can I get some recommendations?

Tuesday, 1 October 2013

using singleton for creating listener object not working

using singleton for creating listener object not working

i am using a singleton that for some reason is not working, can't figure
out why
private static ConnectionUtility instance;
public static ConnectionUtility getInstance() {
if(instance == null){
instance = new ConnectionUtility();
}
return instance;
}
in the code shown above, the second time the execution of this code takes
place, instance is not null, an instance has been created already, so on
the second time this code is executed it should go to the return instance
line directly and skip the instance = new ConnectionUtility() line.
however on second iteration it will try to create another instance of the
ConnectionUtility object when one already exists. why is it doing this?
how to fix this problem?
full code posted below: for 2 classes ConnectionUtility and MultiThreader
public class ConnectionUtility extends javax.swing.JFrame
implements MultiThreader.OnSendResultListener {
String outputLine = "";
boolean runner = true;
PrintWriter out;
BufferedReader in;
ServerSocket serversocket;
static Socket socket;
boolean startServer = true;
public static String displayString = "";
private static ConnectionUtility instance;
static int counter = 0;
public static ConnectionUtility getInstance() {
if(instance == null){
instance = new ConnectionUtility();
}
return instance;
}
private ConnectionUtility() {
initComponents();
this.setVisible(true);
serverRunner();
File fileOne = new File("C:/DBFiles");
if(!fileOne.exists()){
fileOne.mkdir();
}
File fileTwo = new File("C:/DBFilesOut");
if(!fileTwo.exists()){
fileTwo.mkdir();
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("MS UI Gothic", 0, 36)); // NOI18N
jLabel1.setText("TankInspectionSystem");
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(72, 72, 72)
.addComponent(jLabel1)
.addContainerGap(76, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 383,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel1)
.addGap(34, 34, 34)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 179,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(37, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
// End of variables declaration
public void serverRunner(){
runner = true;
try {
serversocket = new ServerSocket(6789, 100);
System.out.println();
} catch (IOException ex) {
Logger.getLogger(ConnectionUtility.class.getName()).log(Level.SEVERE,
null, ex);
}
while(runner){
try {
socket = serversocket.accept();
addAndDisplayTextToString("new connection, inet socket address >>> " +
socket.getPort());
System.out.println(displayString);
} catch (IOException ex) {
Logger.getLogger(ConnectionUtility.class.getName()).log(Level.SEVERE,
null, ex);
}
// MultiThreader multi = new MultiThreader(socket, this);
MultiThreader multi = new MultiThreader(socket);
Thread t = new Thread(multi);
t.start();
} // end while runner loop
} // end serverRunner method
public static void addAndDisplayTextToString(String setString){
StringBuilder stb = new StringBuilder(displayString);
setString = setString + "\n";
if(stb.toString() == ""){
stb.append(setString);
}else if(stb.toString() != ""){
stb.insert(0, setString);
}
int counter = 0;
for(int i = 0; i < stb.length(); i++){
if(stb.substring(i, i + 1).equals("\n")){
counter++;
}
}
// get the last index of "\n"
int lastIndex = stb.lastIndexOf("\n");
int maximum = 4;
if(counter >= maximum){
stb.delete(lastIndex, stb.length());
System.out.println();
}
displayString = stb.toString();
}
@Override
public void onStringResult(String transferString) {
addAndDisplayTextToString(transferString);
jTextArea1.setText(displayString);
System.out.println("RETURNED TRING " + transferString);
}
} // class ConnectionUtility



public class MultiThreader implements Runnable {
private Socket socket;
public int fileSizeFromClient;
FileOutputStream fos = null;
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
DataInputStream dis = null;
DataOutputStream dos = null;
ScheduledThreadPoolExecutor stpe;
private OnSendResultListener listener;
public MultiThreader(Socket s) {
// public MultiThreader(Socket s, OnSendResultListener resultListener){
socket = s;
stpe = new ScheduledThreadPoolExecutor(5);
listener = ConnectionUtility.getInstance();
// listener = resultListener;
}
@Override
public void run() {
long serialNumber = 0;
int bufferSize = 0;
// get input streams
try {
bis = new BufferedInputStream(socket.getInputStream());
dis = new DataInputStream(bis);
} catch (IOException ex) {
Logger.getLogger(MultiThreader.class.getName()).log(Level.SEVERE,
null, ex);
}
sendStatus("New connection strarted");
// read in streams from server
try {
fileSizeFromClient = dis.readInt();
sendStatus("File size from client " + fileSizeFromClient);
serialNumber = dis.readLong();
sendStatus("Serial mumber from client " + serialNumber);
} catch (IOException ex) {
Logger.getLogger(MultiThreader.class.getName()).log(Level.SEVERE,
null, ex);
}
try {
bufferSize = socket.getReceiveBufferSize();
sendStatus("Buffer size " + bufferSize);
} catch (SocketException ex) {
Logger.getLogger(MultiThreader.class.getName()).log(Level.SEVERE,
null, ex);
}
String serialString = String.valueOf(serialNumber);
File fileDirectory = new File("C:" + File.separator + "DOWNLOAD" +
File.separator + serialNumber + File.separator);
fileDirectory.mkdir();
File file = new File("C:" + File.separator + "DOWNLOAD" +
File.separator + serialNumber + File.separator + "JISSend.pdf");
try {
file.createNewFile();
} catch (IOException ex) {
Logger.getLogger(MultiThreader.class.getName()).log(Level.SEVERE,
null, ex);
}
try {
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
dos = new DataOutputStream(bos);
} catch (FileNotFoundException ex) {
Logger.getLogger(MultiThreader.class.getName()).log(Level.SEVERE,
null, ex);
}
int count = 0;
byte[] buffer = new byte[fileSizeFromClient];
try {
int totalBytesRead = 0;
while(totalBytesRead < fileSizeFromClient){
int bytesRemaining = fileSizeFromClient - totalBytesRead;
int bytesRead = dis.read(buffer, 0, (int)Math.min(buffer.length,
bytesRemaining));
if(bytesRead == -1){
break;
}else{
dos.write(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
}
}
} catch (IOException ex) {
Logger.getLogger(MultiThreader.class.getName()).log(Level.SEVERE,
null, ex);
}
try {
dos = new DataOutputStream(socket.getOutputStream());
} catch (IOException ex) {
Logger.getLogger(MultiThreader.class.getName()).log(Level.SEVERE,
null, ex);
}
stpe.schedule(new CompareFiles(), 0, TimeUnit.SECONDS);
stpe.schedule(new CloseResources(), 2, TimeUnit.SECONDS);
} // end run method
public class CompareFiles implements Runnable {
@Override
public void run() {
int returnInt = 0;
FileInputStream fis = null;
File file = new File("C:/DOWNLOAD/JISSend.pdf");
try {
fis = new FileInputStream(file);
} catch (FileNotFoundException ex) {
Logger.getLogger(MultiThreader.class.getName()).log(Level.SEVERE,
null, ex);
}
int fileLength = (int) file.length();
sendStatus("Size of database file sent " + fileLength);
if(fileLength == fileSizeFromClient){
sendStatus("File sent to server, Successful");
returnInt = 1;
}else if(fileLength != fileSizeFromClient){
sendStatus("ERROR, file send failed");
returnInt = 2;
}
try {
dos.writeInt(returnInt);
} catch (IOException ex) {
Logger.getLogger(MultiThreader.class.getName()).log(Level.SEVERE,
null, ex);
}
} // end run method
} // end of class comparefiles
public class CloseResources implements Runnable {
@Override
public void run() {
try {
fos.flush();
bis.close();
bos.close();
dis.close();
dos.close();
socket.close();
} catch (IOException ex) {
Logger.getLogger(MultiThreader.class.getName()).log(Level.SEVERE,
null, ex);
}
} // end run method
} // end of class closeResources
public interface OnSendResultListener {
public void onStringResult(String transferString);
}
public void sendStatus(String status){
listener.onStringResult(status);
}
} // end class mulitthreader

why is this an example of delegation but not aggregation in Java?

why is this an example of delegation but not aggregation in Java?

I found this example in this SO for delegation. I fail to see why this not
an aggregation relationship? The Secretary object continues to exist even
if boss object is destroyed
public interface Worker() {
public Result work();
}
public class Secretary() implements Worker {
public Result work() {
Result myResult = new Result();
return myResult;
}
}
can someone explain why this is delegation but not aggregation?
public class Boss() implements Worker {
private Secretary secretary;
public Result work() {
return secretary.work();
}
}

Screen shuts off when using proprietary NVidia drivers

Screen shuts off when using proprietary NVidia drivers

pAs soon as I install the proprietary NVidia driver on my laptop (even
after a fresh Kubuntu install), I start to experience random screen
failures, that is, the screen suddenly shuts off, the backlight is still
on, but the display is black, and trying to switch tty changes nothing./p
pHaving skimmed through Xorg.log, I couldn't find any error or warning
that could be related (but then, I am no expert), but there are some 200
NULL (^@) chars at the end, and I don't know if it is normal./p pI have no
such problem when using nouveau, so I suspect it is a driver issue, not a
physical one./p pI am using nvidia-current (so 304.88, but the issue
occurs with every driver available in jockey, that is another 304 and two
319) on Kubuntu Saucy (but the issue occurs on Raring too) with a GeForce
8800M GTX./p pWhat should I do to make the proprietary drivers work?/p

Approximation using Euler's method.

Approximation using Euler's method.

Consider the initial value problem $$\dfrac{dy}{dx} = y,y(0) =1$$
Approximate $y(1)$ using Euler's method with a step size of
$\dfrac{1}{n}$, where $n$ is an arbitrary natural number. Use this
approximation to write Euler's number $e$ as a limit of an expression in
$n$. How large do you have to choose $n$ in order to approximate $e$ up to
an error of at most 0.1? Comment on the quality of approximate in this
example.
What I did is the following:
$y(1) \approx y_1 = y_0 +hf(x_0,y_0) = 1+hf(0,1) = 1+\dfrac{1}{n}$
This is where I stuck, am I on the right direction? What should I do next?

Monday, 30 September 2013

How do I purge the Steam Installer?

How do I purge the Steam Installer?

From the related question here the first I did was purging Steam
How do I remove Steam?
The next step would then be to also remove related files in
~/.local/share/Steam and in addition to the answers from above ~/.steam.
One thing makes me believe there still will be more to do. The reason I
purged Steam in the first place was that on other user's account we get a
message to install Steam on every login:

This will definitely not come from files in my home directory, and can
also not be from a system-wide Steam package, as this was purged as can be
seen from the Synaptic window in the background of the shot above. Also in
the other user's accounts there is no ~/.steam or ~/.local/share/Steam
directory. Autostart applications in ~/.config/autostart/ or
/etc/xdg/autostart have no Steam related entries.
Where do I have to look for this "installer" to also remove it? Will there
be any other Steam-related files cluttering my drives?
Here is running 12.04 LTS amd64 on a productive desktop. Steam was
installed initially from the Software Center.

"Violation of the Florida Atlantic University Honor Code"– meta.stackoverflow.com

"Violation of the Florida Atlantic University Honor Code" –
meta.stackoverflow.com

In the review queue for Suggested Edits, I bumped into this edit. There is
a newly registered user with only 1 reputation that suggests removing the
code in the answer because of "violation of the ...

GUI get displayed as a blank window

GUI get displayed as a blank window

Please have a look at the following code
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TableLayout
android:id="@+id/gameBoard"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
></TableLayout>
</RelativeLayout>
game_buttons.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/buttonLayout" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="34dp"
android:layout_marginTop="18dp"
android:text="Button" />
</RelativeLayout>
MainActivity.java
package com.ace.ticktacktoe;
import android.os.Bundle;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.widget.Button;
import android.widget.GridView;
import android.widget.RelativeLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
public class MainActivity extends Activity {
private LayoutInflater inflater;
private TableLayout gameBoard;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
createUI();
//Create the user interface
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
private void createUI()
{
gameBoard = (TableLayout)findViewById(R.id.gameBoard);
inflater = getLayoutInflater();
RelativeLayout layout =
(RelativeLayout)inflater.inflate(R.layout.game_buttons, null);
//Add the buttons
TableRow tableRow = new TableRow(this);
Button btn = (Button)layout.findViewById(R.id.button1);
((RelativeLayout)btn.getParent()).removeView(btn);
tableRow.addView(btn);
gameBoard.addView(tableRow);
}
}
When I run this code, the added button should be displayed. But, my
display is totally blank! What am I doing wrong here? Please help.

how to is any variable accessed outside the block when "return" is used?

how to is any variable accessed outside the block when "return" is used?

i am beginner in c and have started writing code in c.I am having doubt
regarding scope of variable .when any variable is written inside the block
then its scope is inside that block.but when return word is used how is
accessed outside the block?
for eg:
int add(int a, int b)
{
int c;//scope of c is within this block
c=a+b;
return c;
}//it ends here
void main()
{
int answer;
answer=add(2,3);//how we gets value of "c " here
printf("%d",answer);
}

Sunday, 29 September 2013

Uncaught TypeError: Cannot call method 'appendChild' of null?

Uncaught TypeError: Cannot call method 'appendChild' of null?

I.m using pagedown editor in my project.
My HTML code:
<div style="padding-top:20px;" class="control-group">
<div class="controls">
<textarea class="wmd-input"
id="wmd-input"></textarea>
</div>
</div>
<div style="padding-top:20px;" class="control-group">
<label for="signature" class="control-label
user-label">ѧУרҵ</label>
<div class="controls">
<div id="wmd-preview" class="wmd-panel
wmd-preview"></div>
</div>
</div>
and my javascript code:
<script type="text/javascript">
$(function()
{
var converter1 = Markdown.getSanitizingConverter();
var editor1 = new Markdown.Editor(converter1);
editor1.run();
});
</script>
google chrome browser throw out an error "Uncaught TypeError: Cannot call
method 'appendChild' of null ?", what's wrong in my code?

Commit failed by using SVN Can't open file '/svnlokal/db/txn-current-lock': Permission denied

Commit failed by using SVN Can't open file
'/svnlokal/db/txn-current-lock': Permission denied

using Jenkins i receive following mistake, if i try to make release using
maven-release-plugin. The mistake looks like:
......mavenExecutionResult exceptions not empty
message : Failed to execute goal
org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on
project My project: Unable to commit files
Provider message:
The svn command failed.
Command output:
svn: E000013: Commit failed (details follow):
svn: E000013: Can't open file '/home/kobv/svnlokal/db/txn-current-lock':
Permission denied
cause : Unable to commit files
Provider message:
The svn command failed.
Command output:
svn: E000013: Commit failed (details follow):
svn: E000013: Can't open file '/home/kobv/svnlokal/db/txn-current-lock':
Permission denied
Stack trace :
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute
goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare
(default-cli) on project kobv-albert-frontend-dkfz: Unable to commit files
Provider message:
The svn command failed.
Command output:
svn: E000013: Commit failed (details follow):
svn: E000013: Can't open file '/home/kobv/svnlokal/db/txn-current-lock':
Permission denied
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at
org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:158)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at
hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: org.apache.maven.plugin.MojoFailureException: Unable to commit
files
Provider message:
The svn command failed.
Command output:
svn: E000013: Commit failed (details follow):
svn: E000013: Can't open file '/home/kobv/svnlokal/db/txn-current-lock':
Permission denied
at
org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:219)
at
org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:181)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 26 more
Caused by: org.apache.maven.shared.release.scm.ReleaseScmCommandException:
Unable to commit files
Provider message:
The svn command failed.
Command output:
svn: E000013: Commit failed (details follow):
svn: E000013: Can't open file '/home/kobv/svnlokal/db/txn-current-lock':
Permission denied
at
org.apache.maven.shared.release.phase.ScmCommitPhase.checkin(ScmCommitPhase.java:133)
at
org.apache.maven.shared.release.phase.ScmCommitPhase.execute(ScmCommitPhase.java:109)
at
org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:203)
at
org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:140)
at
org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:103)
at
org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:211)
... 29 more
channel stopped
Finished: FAILURE
In this example i use a local SVN. This SVN has following settings: in
conf/authz:
* =
name = rw
in passwd:
[users]
name = password
in svnserve.conf
anon-access = read
auth-access = write
password-db = passwd
authz-db = authz
realm = My local repo
The svnlokal order has following structure:
drwxr-xr-x 2 root root 4096 Sep 29 00:19 conf
drwxr-sr-x 6 root root 4096 Sep 29 00:17 db
-r--r--r-- 1 root root 2 Sep 29 00:12 format
drwxr-xr-x 2 root root 4096 Sep 29 00:12 hooks
drwxr-xr-x 2 root root 4096 Sep 29 00:12 locks
-rw-r--r-- 1 root root 229 Sep 29 00:12 README.txt
and svnlokal/db:
-rw-r--r-- 1 root root 2 Sep 29 00:17 current
-r--r--r-- 1 root root 22 Sep 29 00:12 format
-rw-r--r-- 1 root root 1959 Sep 29 00:12 fsfs.conf
-rw-r--r-- 1 root root 5 Sep 29 00:12 fs-type
-rw-r--r-- 1 root root 2 Sep 29 00:12 min-unpacked-rev
-rw-r--r-- 1 root root 471040 Sep 29 00:17 rep-cache.db
drwxr-sr-x 3 root root 4096 Sep 29 00:12 revprops
drwxr-sr-x 3 root root 4096 Sep 29 00:12 revs
drwxr-sr-x 2 root root 4096 Sep 29 00:17 transactions
-rw-r--r-- 1 root root 2 Sep 29 00:17 txn-current
-rw-r--r-- 1 root root 0 Sep 29 00:12 txn-current-lock
drwxr-sr-x 2 root root 4096 Sep 29 00:17 txn-protorevs
-rw-r--r-- 1 root root 37 Sep 29 00:12 uuid
-rw-r--r-- 1 root root 0 Sep 29 00:12 write-lock
I tried to find answer in stackoverflow in the same questions, but it
doesn't help. I tried to change user, but it doesn't help too. I tried to
delete or to rename 'txt-current-lock file', but it doesn't help. Jenkins
tries to open this file even if it doesn't exist. I use following tools: -
Jenkins 1.509 - SVN 1.7 - Archiva 1.3.6 - Maven 3.0.5
Thanks for any suggestions and answers.

RequestTimeout in WEBrick, after loooong time of request processing

RequestTimeout in WEBrick, after loooong time of request processing

All of a sudden, i had this issue with any request to my local server
after looooong time of processing, but its ok with the staging server...
any help???
===========================
RestClient::RequestTimeout - Request Timeout: (gem)
rest-client-1.6.7/lib/restclient/request.rb:184:in rescue in transmit'
(gem) rest-client-1.6.7/lib/restclient/request.rb:140:intransmit' (gem)
rest-client-1.6.7/lib/restclient/request.rb:64:in execute' (gem)
rest-client-1.6.7/lib/restclient/request.rb:33:inexecute' (gem)
rest-client-1.6.7/lib/restclient.rb:72:in post' (gem)
tire-0.5.8/lib/tire/http/client.rb:19:inpost' (gem)
tire-0.5.8/lib/tire/index.rb:143:in store' (gem)
tire-0.5.8/lib/tire/model/search.rb:148:inblock in update_index' (gem)
activesupport-3.2.12/lib/active_support/callbacks.rb:403:in
_run__1874713149948212873__update_elasticsearch_index__2683693579255723637__callbacks'
(gem)
activesupport-3.2.12/lib/active_support/callbacks.rb:405:in__run_callback'
(gem) activesupport-3.2.12/lib/active_support/callbacks.rb:385:in
_run_update_elasticsearch_index_callbacks' (gem)
activesupport-3.2.12/lib/active_support/callbacks.rb:81:inrun_callbacks'
(gem) tire-0.5.8/lib/tire/model/search.rb:144:in update_index' (gem)
tire-0.5.8/lib/tire/model/callbacks.rb:21:inblock in included' (gem)
activesupport-3.2.12/lib/active_support/callbacks.rb:449:in
_run__1874713149948212873__save__2683693579255723637__callbacks' (gem)
activesupport-3.2.12/lib/active_support/callbacks.rb:405:in__run_callback'
(gem) activesupport-3.2.12/lib/active_support/callbacks.rb:385:in
_run_save_callbacks' (gem)
activesupport-3.2.12/lib/active_support/callbacks.rb:81:inrun_callbacks'
(gem) activerecord-3.2.12/lib/active_record/callbacks.rb:264:in
create_or_update' (gem)
activerecord-3.2.12/lib/active_record/persistence.rb:84:insave' (gem)
activerecord-3.2.12/lib/active_record/validations.rb:50:in save' (gem)
activerecord-3.2.12/lib/active_record/attribute_methods/dirty.rb:22:insave'
(gem) activerecord-3.2.12/lib/active_record/transactions.rb:259:in block
(2 levels) in save' (gem)
activerecord-3.2.12/lib/active_record/transactions.rb:313:inblock in
with_transaction_returning_status' (gem)
activerecord-3.2.12/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in
transaction' (gem)
activerecord-3.2.12/lib/active_record/transactions.rb:208:intransaction'
(gem) newrelic_rpm-3.5.8.72/lib/new_relic/agent/method_tracer.rb:491:in
block in transaction_with_trace_ActiveRecord_self_name_transaction' (gem)
newrelic_rpm-3.5.8.72/lib/new_relic/agent/method_tracer.rb:240:intrace_execution_scoped'
(gem) newrelic_rpm-3.5.8.72/lib/new_relic/agent/method_tracer.rb:486:in
transaction_with_trace_ActiveRecord_self_name_transaction' (gem)
activerecord-3.2.12/lib/active_record/transactions.rb:311:inwith_transaction_returning_status'
(gem) activerecord-3.2.12/lib/active_record/transactions.rb:259:in block
in save' (gem)
activerecord-3.2.12/lib/active_record/transactions.rb:270:inrollback_active_record_state!'
(gem) activerecord-3.2.12/lib/active_record/transactions.rb:258:in save'
(gem)
devise-2.1.2/lib/devise/models/trackable.rb:30:inupdate_tracked_fields!'
(gem) devise-2.1.2/lib/devise/hooks/trackable.rb:7:in block in <top
(required)>' (gem) warden-1.2.1/lib/warden/hooks.rb:14:incall' (gem)
warden-1.2.1/lib/warden/hooks.rb:14:in block in _run_callbacks' (gem)
warden-1.2.1/lib/warden/hooks.rb:9:ineach' (gem)
warden-1.2.1/lib/warden/hooks.rb:9:in _run_callbacks' (gem)
warden-1.2.1/lib/warden/manager.rb:53:in_run_callbacks' (gem)
warden-1.2.1/lib/warden/proxy.rb:179:in set_user' (gem)
warden-1.2.1/lib/warden/proxy.rb:323:in_perform_authentication' (gem)
warden-1.2.1/lib/warden/proxy.rb:104:in authenticate' (gem)
devise-2.1.2/lib/devise/controllers/helpers.rb:56:incurrent_individual'
app/controllers/shared/shared_controller.rb:50:in
his_entities_and_latest_posts' (gem)
activesupport-3.2.12/lib/active_support/callbacks.rb:484:inrun_3623636613210358831__process_action_3715467131744981871_callbacks'
(gem) activesupport-3.2.12/lib/active_support/callbacks.rb:405:in
__run_callback' (gem)
activesupport-3.2.12/lib/active_support/callbacks.rb:385:in_run_process_action_callbacks'
(gem) activesupport-3.2.12/lib/active_support/callbacks.rb:81:in
run_callbacks' (gem)
actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:inprocess_action'
(gem) actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in
process_action' (gem)
actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:inblock
in process_action' (gem)
activesupport-3.2.12/lib/active_support/notifications.rb:123:in block in
instrument' (gem)
activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:ininstrument'
(gem) activesupport-3.2.12/lib/active_support/notifications.rb:123:in
instrument' (gem)
actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:29:inprocess_action'
(gem)
actionpack-3.2.12/lib/action_controller/metal/params_wrapper.rb:207:in
process_action' (gem)
activerecord-3.2.12/lib/active_record/railties/controller_runtime.rb:18:inprocess_action'
(gem)
newrelic_rpm-3.5.8.72/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:in
block in process_action' (gem)
newrelic_rpm-3.5.8.72/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:268:inblock
in perform_action_with_newrelic_trace' (gem)
newrelic_rpm-3.5.8.72/lib/new_relic/agent/method_tracer.rb:240:in
trace_execution_scoped' (gem)
newrelic_rpm-3.5.8.72/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:263:inperform_action_with_newrelic_trace'
(gem)
newrelic_rpm-3.5.8.72/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:in
process_action' (gem)
actionpack-3.2.12/lib/abstract_controller/base.rb:121:inprocess' (gem)
actionpack-3.2.12/lib/abstract_controller/rendering.rb:45:in process'
(gem) actionpack-3.2.12/lib/action_controller/metal.rb:203:indispatch'
(gem)
actionpack-3.2.12/lib/action_controller/metal/rack_delegation.rb:14:in
dispatch' (gem)
actionpack-3.2.12/lib/action_controller/metal.rb:246:inblock in action'
(gem) actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:73:in
call' (gem)
actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:73:indispatch'
(gem) actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:36:in
call' (gem)
actionpack-3.2.12/lib/action_dispatch/routing/mapper.rb:42:incall' (gem)
journey-1.0.4/lib/journey/router.rb:68:in block in call' (gem)
journey-1.0.4/lib/journey/router.rb:56:ineach' (gem)
journey-1.0.4/lib/journey/router.rb:56:in call' (gem)
actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:601:incall'
(gem) newrelic_rpm-3.5.8.72/lib/new_relic/rack/error_collector.rb:8:in
call' (gem)
newrelic_rpm-3.5.8.72/lib/new_relic/rack/agent_hooks.rb:14:incall' (gem)
newrelic_rpm-3.5.8.72/lib/new_relic/rack/browser_monitoring.rb:12:in call'
(gem)
newrelic_rpm-3.5.8.72/lib/new_relic/rack/developer_mode.rb:24:incall'
(gem) mongoid-3.0.9/lib/rack/mongoid/middleware/identity_map.rb:33:in
block in call' (gem)
mongoid-3.0.9/lib/mongoid/unit_of_work.rb:39:inunit_of_work' (gem)
mongoid-3.0.9/lib/rack/mongoid/middleware/identity_map.rb:33:in call'
(gem) sass-3.2.7/lib/sass/plugin/rack.rb:54:incall' (gem)
warden-1.2.1/lib/warden/manager.rb:35:in block in call' (gem)
warden-1.2.1/lib/warden/manager.rb:34:incatch' (gem)
warden-1.2.1/lib/warden/manager.rb:34:in call' (gem)
actionpack-3.2.12/lib/action_dispatch/middleware/best_standards_support.rb:17:incall'
(gem) rack-1.4.5/lib/rack/etag.rb:23:in call' (gem)
rack-1.4.5/lib/rack/conditionalget.rb:35:incall' (gem)
actionpack-3.2.12/lib/action_dispatch/middleware/head.rb:14:in call' (gem)
actionpack-3.2.12/lib/action_dispatch/middleware/params_parser.rb:21:incall'
(gem) actionpack-3.2.12/lib/action_dispatch/middleware/flash.rb:242:in
call' (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:210:incontext'
(gem) rack-1.4.5/lib/rack/session/abstract/id.rb:205:in call' (gem)
actionpack-3.2.12/lib/action_dispatch/middleware/cookies.rb:341:incall'
(gem) activerecord-3.2.12/lib/active_record/query_cache.rb:64:in call'
(gem)
activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:incall'
(gem) actionpack-3.2.12/lib/action_dispatch/middleware/callbacks.rb:28:in
block in call' (gem)
activesupport-3.2.12/lib/active_support/callbacks.rb:405:inrun_1579072322385182133_call_2683693579255723637__callbacks'
(gem) activesupport-3.2.12/lib/active_support/callbacks.rb:405:in
__run_callback' (gem)
activesupport-3.2.12/lib/active_support/callbacks.rb:385:in_run_call_callbacks'
(gem) activesupport-3.2.12/lib/active_support/callbacks.rb:81:in
run_callbacks' (gem)
actionpack-3.2.12/lib/action_dispatch/middleware/callbacks.rb:27:incall'
(gem) actionpack-3.2.12/lib/action_dispatch/middleware/reloader.rb:65:in
call' (gem) rack-1.4.5/lib/rack/sendfile.rb:102:incall' (gem)
actionpack-3.2.12/lib/action_dispatch/middleware/remote_ip.rb:31:in call'
(gem)
better_errors-0.8.0/lib/better_errors/middleware.rb:84:inprotected_app_call'
(gem) better_errors-0.8.0/lib/better_errors/middleware.rb:79:in
better_errors_call' (gem)
better_errors-0.8.0/lib/better_errors/middleware.rb:56:incall' (gem)
actionpack-3.2.12/lib/action_dispatch/middleware/debug_exceptions.rb:16:in
call' (gem)
actionpack-3.2.12/lib/action_dispatch/middleware/show_exceptions.rb:56:incall'
(gem) railties-3.2.12/lib/rails/rack/logger.rb:32:in call_app' (gem)
railties-3.2.12/lib/rails/rack/logger.rb:16:inblock in call' (gem)
activesupport-3.2.12/lib/active_support/tagged_logging.rb:22:in tagged'
(gem) railties-3.2.12/lib/rails/rack/logger.rb:16:incall' (gem)
actionpack-3.2.12/lib/action_dispatch/middleware/request_id.rb:22:in call'
(gem) rack-1.4.5/lib/rack/methodoverride.rb:21:incall' (gem)
rack-1.4.5/lib/rack/runtime.rb:17:in call' (gem)
activesupport-3.2.12/lib/active_support/cache/strategy/local_cache.rb:72:incall'
(gem) rack-1.4.5/lib/rack/lock.rb:15:in call' (gem)
actionpack-3.2.12/lib/action_dispatch/middleware/static.rb:62:incall'
(gem) railties-3.2.12/lib/rails/engine.rb:479:in call' (gem)
railties-3.2.12/lib/rails/application.rb:223:incall' (gem)
rack-1.4.5/lib/rack/content_length.rb:14:in call' (gem)
railties-3.2.12/lib/rails/rack/log_tailer.rb:17:incall' (gem)
rack-1.4.5/lib/rack/handler/webrick.rb:59:in service'
/Users/Mhmoud/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:138:inservice'
/Users/Mhmoud/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:94:in
run'
/Users/Mhmoud/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/server.rb:191:inblock
in start_thread'

Saturday, 28 September 2013

segmentation fault when I return

segmentation fault when I return

this code segfaults when it returns. I have tried to put the code inline
in main however it fails when it leaves the while loop. Any help you have
is appreciated!
code is called from here
if (inputType == 'M')
{
ReadMap(holder, LvlSize, Levels, start);
}
else if (inputType == 'L')
{
LmodeInput(holder, LvlSize, Levels, start);
}
//code should read in coordinate and initialize a map based on
coordinates
void LmodeInput(vector<vector <square> > &holder,int size, int
levels,square&start)
{
int row = 10;
int column = 10;
int level = 10;
char x = '1';
string trash = "10";
initializeVector(holder, size, levels); //initialize all to .
while (1)
{
if (!(cin >> x))
{
cout << "this should execute";
printMap(holder, size, levels);
cout <<endl;
cout << "break should execute" <<endl;
break;
}
if (x == '/')
{
getline(cin, trash);
continue;
}
cin >> row;
cin>>x;
cin>>column;
cin >>x;
cin>>level;
if (row > (size - 1) || column > (size - 1))
{
cout << "out of bounds" <<endl;
exit(1);
}
else if ( row < 0 || column < 0)
{
cout << "out of bounds" <<endl;
exit(1);
}
else if (level > 10 || level < 0)
{
cout << "out of bounds" <<endl;
exit(1);
}
cin >> x; //,
cin >> x;
if (x == '#' || x== 'E' || x == 'S' || x== 'H' ||x == '.')
{
holder[size*((levels-1)-level) + row][column].type = x;
if (x == 'S')
{
start = holder[size*((levels-1)-level) + row][column];
}
}
else
{
cout << "Invalid character" <<endl;
exit(1);
}
cin >> x;
}
cout << "return will execute";
return
}
this function segfaults when it hits the return statement. all gdb tells
me is that the segfault is in the return
valgrind provides this output:
Invalid write of size 1
==26557== at 0x401776: main (project1.cpp:188)
==26557== Address 0x20 is not stack'd, malloc'd or (recently) free'd
==26557==
==26557==
==26557== Process terminating with default action of signal 11 (SIGSEGV)
==26557== Access not within mapped region at address 0x20
==26557== at 0x401776: main (project1.cpp:188)
==26557== If you believe this happened as a result of a stack
==26557== overflow in your program's main thread (unlikely but
==26557== possible), you can try to increase the size of the
==26557== main thread stack using the --main-stacksize= flag.
==26557== The main thread stack size used in this run was 10485760.

Making a Class Based on Arrays Enumerable in C#

Making a Class Based on Arrays Enumerable in C#

Okay, I have made an earnest effort to understand this over the past hour
or so. So I am wondering if someone can explain this to me.
I'm trying to make a class in C# be Enumerable. Specifically, I'm trying
to make it work with a foreach loop. I have a test going with a simple
class, with takes in characters into the constructor.
EmployeeArray ArrayOfEmployees = new EmployeeArray('a','b','c');
foreach(char e in EmployeeArray) //Nope, can't do this!
{
Console.WriteLine(e);
}
//---Class Definition:---
class EmployeeArray
{
private char[] Employees;
public EmployeeChars(char[] e)
{
this.Employees = e;
}
//Now for my attempt at making it enumerable:
public IEnumerator GetEnumerator(int i)
{
return this.Employees[i];
}
}

PHP - number_format fails with math operations

PHP - number_format fails with math operations

The PHP function number_format produces weird results when using it with
math operations.
Run this...
echo number_format(32545000 - 24343400) . '<br>';
echo number_format(32545000) - number_format(24343400);
Why does the second one produce an answer of "8" instead of the correct
answer?

in scringo API for android how i can catch the tap on custom tab

in scringo API for android how i can catch the tap on custom tab

i am using scringo API for android in my App. I want to know that how to
implement the click event on custom tabs? I have made some custom tabs
from Scringo Admin Panel on web.

Friday, 27 September 2013

Does a jQuery object have a property that points to a corresponding JavaScript object

Does a jQuery object have a property that points to a corresponding
JavaScript object

Being curious. jQuery is written on top of JavaScript. So, for a given
selected DOM element, does jQuery keep a property (attribute) that acts as
a handle to the corresponding (internal) JavaScript DOM object? If so,
what property in the jQuery object acts as a handle to the corresponding
JavaScript object.
To facilitate further, I have quickly written an example at jsfiddle:
http://jsfiddle.net/mMvaD/1/ . The example basically retrieves a DOM
object using both jQuery and prints its (enumerable) properties. Could
someone point me to the property in the jQuery object points to a
JavaScript object, if we have one? For the sake of completeness, I have
also shown properties belonging to a corresponding JavaScript object.
Here is the code:
<html>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<body>
<div id="idDiv"></div>
<script type="text/javascript">
$(document).ready(function() {
$("body").append("jQuery Object:<br>");
elem1 = $("#idDiv");
for (var item in elem1) {
$("body").append(item + ", ");
}
$("body").append("<br><br>JavaScript Object:<br>");
elem2 = document.getElementById("idDiv");
for (var item in elem2) {
$("body").append(item + ", ");
}
});
</script>
</body>
</html>

C# EF Code First Seeding Data - Keeps Adding (Instead of updating)

C# EF Code First Seeding Data - Keeps Adding (Instead of updating)

I have a list of type User and when I try to seed my db to reflect
updates, it is simply adding all the entries again. I will share my code I
am executing in my Seed() method. I wish to just update the records (but
keep the add functionality), if they already exist. Any thoughts?
List<User> users = new List<User>();
users.Add(new User { FirstName = "Dee", LastName = "Reynolds" });
users.Add(new User { FirstName = "Rickety", LastName = "Cricket" });
users.ForEach(b => context.Users.AddOrUpdate(b));

Detecting Javascript as Part of Validation?

Detecting Javascript as Part of Validation?

Like everyone else who develops forms, I worry about validation and
preventing users from entering malicious data. Javascript validation is so
much more immediate and neat, but of course there is the issue that
someone can just turn off Javascript.
What I've wondering, is it a legitimate option to disable forms for users
who have Javascript disabled? Does it work, or can malicious visitors get
around it anyway? Is it a bad idea for other reasons?
I've seen older discussions on this general topic:
How to detect if JavaScript is disabled?
How do I know if Javascript has been turned off inside browser?
What are the current methods and thinking on this?

How can I make a drawn shape extends with the component?

How can I make a drawn shape extends with the component?

I'm drawing lines using Graphics2D. I'm starting at y = 0, but I want the
end of the line to be as maximum as frame it's contained in. So if the
user stretches the frame, I want the lines to also stretch. How can I do
that?
I include the current look of what I did:

public class DrawingApp {
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater( new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
} );
}
private static void createAndShowGUI() {
JFrame frame = new JFrame("Drawing App");
frame.setPreferredSize( new Dimension(700, 500));
frame.setLayout( new BorderLayout() );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
DrawingApp app = new DrawingApp();
GraphAreaTest area = app.new GraphAreaTest();
frame.getContentPane().add(area);
frame.pack();
frame.setVisible(true);
}
class GraphAreaTest extends Component {
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.drawLine(50, 0, 50, 100);
}
}
}

how to adding parameters to razor helpers

how to adding parameters to razor helpers

I want to know how write HTML Helper like @Html.TextBoxFor(model =>
model.signature) to have data-id parameter in produced input like below by
helper.
<input type="text" name="signature" data-id="No Signature" />
Note 1: parameter like dataId is work by htmlAttributes because it is a
simple variable.
Note 2: I know extended method and use attribute like @{var attributes =
new Dictionary<string, object>{{ "data-id", "blah" }};}
I feel that there is better way to solve this. Any idea...
Tnx a lot.

Thursday, 26 September 2013

Create a drawable with rounded top corners and a border on bottom

Create a drawable with rounded top corners and a border on bottom

This is what I came up with.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<solid android:color="@color/grey" />
<padding
android:bottom="1dp" />
<corners
android:radius="0dp"/>
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<solid android:color="@color/white" />
<corners
android:radius="1dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="0dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp"/>
</shape>
</item>
</layer-list>
This is working however the bottom radius is showing up whatever values I
place on it.

Wednesday, 25 September 2013

the below function is not working in IE version

the below function is not working in IE version

function chooseFreqMenu(freqValues,freqTexts) { var cf = document.myform;
alert(freq1);// displaying freq1 value is "d" (ex:selected 'd' in html
dropdown)
// checking some condition for freqValues.
for(var i=4;i<freqValues.length;i++)
selectStr += '<option value="'+freqValues[i]+'">'+freqTexts[i]+'\n';
}
selectStr += '</select>';
//Its working fine in IE=10 browsers but not in less
document.getElementById("freq").innerHTML= selectStr;

Thursday, 19 September 2013

Creating a form with jquery. Cannot append after input element

Creating a form with jquery. Cannot append after input element

Here is the HTML version form I need to create using jquery...
<form id="loginForm" class="loginLabel" action="login/login.php"
method="post">
Username : <input type="text" name="Username" ><br>
Password : <input type="password" name="Password" ><br>
<input type="Submit" name="login_Submit" value="Login">
</form>
And here is the jquery I have written for it...
var loginForm = document.createElement("form");
var userInput = document.createElement("input");
$(userInput).attr("id", "userInput")
.attr("type", "text")
.attr("name", "Username");
var br = document.createElement('br');
var passInput = document.createElement("input");
$(passInput).attr("id", "passInput")
.attr("type", "text")
.attr("name", "Password");
$(loginForm).attr("id","loginForm" )
.attr("class", "loginLabel")
.text("Username : ")
.append(userInput)
.append(br)
.text("Password : ")
.append(passInput);
$(loginWrapper).append(loginForm);
Unfortunately, jquery overwrites the username input (userInput) with the
password input (passInput). I checked the CSS and there is plenty of room
to go around.

How create WebSocket-server and WebSocket client at objective-C?

How create WebSocket-server and WebSocket client at objective-C?

I'm working in small IT-company, and I got a new project. This project is
application for IOS. But, I'm never programmed for iOS. Therefore now, I'm
learning objective-c and programming for iOS. And for our project, we need
use WebSocket protocol. In GitHub i can found project SocketRocket. But I
can't understand how its work. Maybe anybody can send to me the working
test example or tell me, how i can create the easy echo-server?

Having trouble making a background image (line) span screen width with horizontal scroll

Having trouble making a background image (line) span screen width with
horizontal scroll

I need to create a red line that spans the entire screen.
http://jsfiddle.net/k86gc/
<!DOCTYPE html>
<head>
<style type="text/css">
#redBar{ width: 100%; height: 10px; z-index: -1; margin-top: 80px;
background: #D2232A;}
#heading{ width: 768px; margin-left: auto; margin-right: auto; margin-top:
80px;}
</style>
</head>
<body>
<div id="redBar"></div>
<div id="heading"> Heading</div>
</body>
</html>
Notice that when you scroll to the right with the horizontal scroll bar
the red bar does not show up.

Access Denied OAuth 2.0 Google Adwords

Access Denied OAuth 2.0 Google Adwords

I am using a console application I am not able to authenticate the Oauth
2, it's access denied, is there any way to get authentication on console
application project without accessing the url? because my code console
will turn a windows service.
Follow the example of my code:
AdsOAuthProviderForApplications oAuth2Provider =
(user.OAuthProvider the AdsOAuthProviderForApplications);
oAuth2Provider.RedirectUri = null; oAuth2Provider.RefreshToken =
"1/3R_SwvsHk4sFg01RTlSVNmBx8sR7okB7NmBrefvG81E";
oAuth2Provider.RefreshAccessTokenInOfflineMode ();
Thanks

How to encode audio in AAC-LC, AAC-HE-V1, AAC-HE-V2 using libavcodec?

How to encode audio in AAC-LC, AAC-HE-V1, AAC-HE-V2 using libavcodec?

I am trying to encode audio in AAC-LC,AAC-HE-V1, AAC-HE-V2 using
libavcodec/ffmpeg APIs.
But when I am using the following configuration and API calls.It says
"invalid AAC profile."
AVCodecContext *encoder_ctx;
encoder_ctx->codec_id = AV_CODEC_ID_AAC;
encoder_ctx->sample_fmt = AV_SAMPLE_FMT_S16;
encoder_ctx->profile = FF_PROFILE_AAC_HE;
encoder = avcodec_find_encoder(encoder_ctx->codec_id);
avcodec_open2(encoder_ctx, encoder, NULL);
Could you please explain what is wrong with this?

PRC REPORT: Carriage Return in Column to add to concatenated fields

PRC REPORT: Carriage Return in Column to add to concatenated fields

I'm created a PROC REPORT that has a number of columns that are in the
input dataset and some others that are created in COMPUTE blocks. Some of
the columns are created using cats() to concatenate the values of others
etc.
Is it possible to insert a carriage return into a column using ods
escapechar='^' ;? I haven't been successful in doing this. For one of the
columns, I would like to do this, but I can't make it work: _C4_ =
cats(_C2_,"^", _C3); Columns C2 and C3 are computed, numeric columns.
Thanks for any help.

Determining the source of the click event dynamically

Determining the source of the click event dynamically

I have a set of buttons that are added dynamically. As the user keeps
clicking the buttons, new buttons are added to the window. I am using a
winforms. I am binding the onclick event of all these buttons to the same
function. I am using the following code.
System.EventHandler myEventHandle= new
System.EventHandler(this.Button_Clicked);
Once a new dynamic button is created I add the event handler with the
following code:
b1.Click += myEventHandle;
Now in the function Button_Clicked() I want to get the Button which
invoked this event. I want to disable this Button so that it cannot be
clicked again and I want the name of the Button that was clicked as I want
to do various actions depending on button name. I am newbie in C# can you
please help me out. Its urgent.

Wednesday, 18 September 2013

iOS 7 status bar overlapping UI

iOS 7 status bar overlapping UI

I recently upgraded to xcode 5 and when I run my app in the iOS simulator
the splash screen overlaps the status bar and when you are in the app the
status bar overlaps onto elements on my app, like a back button I have on
the top left hand corner of my app. I build my app using phonegap 2.9. Any
ideas how i can get this to render correctly.

Is there a way to put grid lines on top of a contour plot?

Is there a way to put grid lines on top of a contour plot?

I am using the contourf function to create a contour plot:

I would like to get grid lines to appear on top of the plane that shows
the contours.
I came across one solution, but it only works in 2D (that is when you view
the contour plot in 2D) which involved the following two commands:
grid on
set(gca,'layer','top');
However, the grid lines do not appear when viewing the axes in 3D. Is
there any way to do this simply?

Getting list of files in a directory WITHOUT paths in Ruby

Getting list of files in a directory WITHOUT paths in Ruby

(I can't believe how long I've spent on this so I'm just gonna ask it...)
Given a directory path, how do I get the list of the file names underneath
it excluding the path prefix. Yeah I could strip them off but I feel like
I'm missing a cleaner way?
Specifically, I want all the files under the /config directory in Rails:
files = Dir[Rails.root.join("config").to_s + "/*"]
files = Dir.glob(Rails.root.join("config").to_s + "/*")
Each of these returns full-path file names...

Export string to CSV not working

Export string to CSV not working

I am trying to download a string into CSV file with the following code:
string attachment = "attachment; filename=Test.csv";
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition",
attachment);
HttpContext.Current.Response.ContentType = "text/csv";
HttpContext.Current.Response.AddHeader("Pragma", "public");
HttpContext.Current.Response.Write("my,csv,file,contents");
HttpContext.Current.Response.End();
My Fiddler capture gave me the following:
HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Wed, 18 Sep 2013 22:06:19 GMT
X-AspNet-Version: 4.0.30319
content-disposition: attachment; filename=Test.csv
Pragma: public
Cache-Control: private
Content-Type: text/csv; charset=utf-8
Content-Length: 20
Connection: Close
my,csv,file,contents
But, the browser is not downloading any CSV file. Please help. Thanks,

Multi entity manager, wrong database selected

Multi entity manager, wrong database selected



Hello, i'm using multiple entity managers in Symfony 2, but during a form
validation, the handleRequest method use the wrong one.
Here is my ORM configuration :
dbal:
default_connection: customer_database
connections:
customer_database:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
shared_database:
driver: %shared_database_driver%
host: %shared_database_host%
port: %shared_database_port%
dbname: %shared_database_name%
user: %shared_database_user%
password: %shared_database_password%
orm:
auto_generate_proxy_classes: %kernel.debug%
default_entity_manager: customer_em
entity_managers:
shared_em:
connection: shared_database
mappings:
KnFEngineBundle:
type: "annotation"
dir: "Entity/Shared"
customer_em:
connection: customer_database
mappings:
KnFEngineBundle:
type: "annotation"
dir: "Entity/Customer"
KnFModTextBundle: ~
KnFModMapBundle: ~
KnFModFormBundle: ~
And the function in my controller that validate the form :
public function addAction( $isLink )
{
$kernel = $this->container->get( 'knf_engine.kernel' );
$form = $this->createForm( new PageType( $isLink,
$kernel->getAvailablePageOwner() ) );
$request = $this->get( 'request' );
if( $request->getMethod() == 'POST' )
{
$page = new Page( $isLink );
$form->setData( $page );
$form->handleRequest( $request ); //the function call that throw
error
if( $form->isValid() )
{
$kernel->addPage( $page );
return $this->redirect( $this->generateUrl(
'knf_engine_admin_page' ) );
}
}
$args = array( 'form' => $form->createView(),
'url' => $this->getURL(),
'isLink' => $isLink );
if( $request->isXmlHttpRequest() )
{
return $this->render(
'KnFEngineBundle:admin:includes/pageadd_modal.html.twig', $args );
}
else
{
return $this->render( 'KnFEngineBundle:admin:pageadd.html.twig',
$args );
}
}
And the error :
An exception occurred while executing 'SELECT t0.id AS id1, t0.isLink AS
isLink2, t0.externalLink AS externalLink3, t0.isPopup AS isPopup4,
t0.address AS address5, t0.position AS position6, t0.title AS title7,
t0.active AS active8, t0.owner_id AS owner_id9 FROM Page t0 WHERE
t0.address = ?' with params ["dhfg"]:
SQLSTATE[42S02]: Base table or view not found: 1146 Table
'kreanet_framework_global.page' doesn't exist
But the entity is "Page" is defined in the Entity/Customer folder, that is
mapped to the customer entity manager (default em). As you can see,
doctrine try to access the data in the other entity manager.
After investigation, i understood that doctrine bind the form with the
database in the handleRequest() method (i used bind() before but is now
deprecated). I really don't know why doctrine is looking in that database.
Thanks for reading and sorry for my english, it's not my native language
but i hope you can understand my problem.

How to find the longest string in a column with Ruby on Rails?

How to find the longest string in a column with Ruby on Rails?

Is there a function in Ruby to find the longest string, i.e. the one with
the most digits, in a column?
Thanks for any help.

loading indicator when drawing too many objects on the canvas

loading indicator when drawing too many objects on the canvas

I have too many objects on canvas to draw and I want to have some loading
indicator while drawing. My browser waiting and somethimes get frozen for
a while and I need to show loading.gif. Usually aproach doesn't work,
show() div on start and hide() on the end of drawing.

is there a reason for math.round *1000 /1000 doesn't make sense

is there a reason for math.round *1000 /1000 doesn't make sense

I am looking at this line of code and I cannot make sense of it. This
particular code is javascript, but I eventually would like to make a java
android app.
$("#TxtHalfDot").val(Math.round((60000/bpm)*3*1000)/1000);
//bpm being a user entered value
I understand the process of the math and have been through it with a
calculator many times. However, I can not make sense of the *1000 followed
by /1000.
My Question
Is this a strange behavior of the "math.round" function or is it just
simply not needed. I have seen it a lot but when I look at it I feel it
can be omitted, but I am not a computer...
(60000/bpm) * 3 gives the same result ((60000/bpm) *3*1000)/1000

OpenSSL retrieving data from a certificate

OpenSSL retrieving data from a certificate

I am trying to enable https protocol in my local website. I have
implemented uploading mechanism of the certificates and it works like
charm. The next thing that I want to implement is to show some key
information which are retrieved from the uploaded certificate. By this way
the user can see that the certificate is successfully uploaded and
working. So for example, I want to show the organization name, expiry
date. I tried the following but it returns all the name information. I
want to pick the organization name up from this list. Can anyone guide me
through?
$certInfo = openssl_x509_parse(file_get_contents($cert_directory .
'ssl.pem'));
echo $certInfo['name'];
Another question is, what information would be meaningful for the user to
see? I am planning to show organization name and expiry date but perhaps
it would be useful to show some other information as well. Can you comment
on this?

Tuesday, 17 September 2013

Change X,Y Coordinates of image in ireport on base of Parameter

Change X,Y Coordinates of image in ireport on base of Parameter

I have this problem that x,y coordinates of images are coming from db, I
have to show image on the screen I know the image but the position will be
given by parameters at runtime. Is there anyway I can achieve this. Any
help will be appreciated.

How do I create a prefix like jQuery does?

How do I create a prefix like jQuery does?

How do I create a prefix like the one jQuery uses? For example, in jQuery
I can use:
$(".footer").css('display', 'none');
and I'd like to enable a similar syntax, like this:
google('.footer').chrome('display', 'none');
I have searched Google for an answer, but couldn't find it.

How to use XPDM driver on Windows Vista/7?

How to use XPDM driver on Windows Vista/7?

I want to start out by saying that I know XPDM drivers are not meant for
Windows Vista and 7 and that they need to be following the WDDM model.
With that said, I have been doing alot of looking into display drivers and
alot of these driver development companies that are providing these
display drivers have said they have came up with a permanent work around
to use these drivers on windows Vista and 7 and that they are actually
XPDM drivers. How exactly are they doing this? I have requested some
samples to further analyze what is different, but it seems like more than
one company is doing this.
So I am wondering if anyone may know the technique they are using? I would
love to be able to use an XPDM display driver without having to port it
over to WDDM.

Get localized short date pattern as String?

Get localized short date pattern as String?

I'd like to get the pattern of a "short date" as a String that is
customized to the user's locale (e.g. "E dd MMM"). I can easily get a
localized DateFormat-object using
DateFormat mDateFormat =
android.text.format.DateFormat.getDateFormat(mContext);
but DateFormat doesn't have a .toPattern()-method.
If I use
SimpleDateFormat sdf = new SimpleDateFormat();
String mDateFormatString = sdf.toPattern();
I don't know how to only get the short date pattern String instead of the
full M/d/yy h:mm a

NullPointerException (etc) from Parcel.readException

NullPointerException (etc) from Parcel.readException

Exceptions that look like this are confusing:
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.os.Parcel.readException(Parcel.java:1437)
at android.os.Parcel.readException(Parcel.java:1385)
at
com.yourpackage.ipc.IYourClass$Stub$Proxy.yourMethod(IYourClass.java:488)
at com.yourpackage.ipc.YourClassShim.yourMethod(YourClassShim.java:269)
I found a bunch of related questions for this, but none with the answer to
"how do you debug this". So I'm making this Question/Answer.
By looking at the android source here and here you'll see that it can be
throwing any of these (the NullPointerException is just what I had):
SecurityException(msg);
BadParcelableException(msg);
IllegalArgumentException(msg);
NullPointerException(msg);
IllegalStateException(msg);
RuntimeException("Unknown exception code: " + code + " msg " + msg);
But what's causing these?

Xively extract current datastream value

Xively extract current datastream value

I'm able to extract the latest value of the datastream using the following
code BUT the problem is that if I change the value or update the value at
the Xively dashboard console then the code isn't able to capture the
change but still remains displaying the old value!
# main program entry point - runs continuously updating our datastream
with the
def run():
print "Starting Xively tutorial script"
feed = api.feeds.get(FEED_ID)
datastream = get_datastream(feed)
datastream.max_value = None
datastream.min_value = None
while True:
if DEBUG:
print "Updating Xively feed with value: %s"
datastream.at = datetime.datetime.utcnow()
datastream.update()
check_point = datastream.current_value
print "AAGYa: %s" % check_point
if check_point == '50':
outPin = file("/sys/class/gpio/gpio44/value", "w")
outPin.write("1")
elif check_point == '':
outPin = file("/sys/class/gpio/gpio44/value", "w")
outPin.write("1")
elif check_point == '':
outPin = file("/sys/class/gpio/gpio44/value", "w")
outPin.write("1")
run()
THE code is in PYTHON

Sunday, 15 September 2013

Re-installing jenkins in Ubuntu

Re-installing jenkins in Ubuntu

Well, I forgot my password for Jenkins and I tried(for one full day) with
all usual passwords, failed in all attempts. Hence, I wanted to reinstall
jenkins from scratch, luckily I was just setting up and I had no jobs
configured yet.
So I removed (rm -Rf) of jenkins folder from tomcat webapps directory, and
restarted tomcat. To my surprise Jenkins asks for login again.
What is the proper way to remove and reinstall jenkins? I have jenkins.war
and I installed it by just copying it over to tomcat webapps.
Well either - I want to reset my password because I am the only admin or I
want to reinstall jenkins from scratch. I have sudo access to the machine,
could someone point me on how I can do this?

custom font in my android listview

custom font in my android listview

How can I use a custom font in an android ListView?
This is my code:
MainActivity.java
package com.sj.customlistview;
import java.util.ArrayList;
import java.util.List;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.AdapterView;
public class MainActivity extends ListActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
private void initView() {
List<Application> apps = populateSampleApplication();
AppAdapter adapter = new AppAdapter(this, apps);
setListAdapter(adapter);
}
private List<Application> populateSampleApplication(){
String[] apps = new String[] {
"Google,3502,5,google",
"Apple,3502,4,apple",
"Twitter,3502,3,twitter",
"Skype,3502,0,skype",
"Facebook,500560,1,facebook"
};
List<Application> list = new ArrayList<Application>();
for(String app:apps) {
String[] rApp = app.split(",");
Application ap = new Application();
ap.setTitle(rApp[0]);
ap.setTotalDl(Integer.parseInt(rApp[1]));
ap.setRating(Integer.parseInt(rApp[2]));
ap.setIcon(rApp[3]);
list.add(ap);
}
return list;
}
}
Application.java
package com.sj.customlistview;
public class Application {
private String title;
private long totalDl;
private int rating;
private String icon;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public long getTotalDl() {
return totalDl;
}
public void setTotalDl(long totalDl) {
this.totalDl = totalDl;
}
public int getRating() {
return rating;
}
public void setRating(int rating) {
this.rating = rating;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
}
ArrayAdapter.java
package com.sj.customlistview;
import java.text.NumberFormat;
import java.util.List;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class AppAdapter extends ArrayAdapter<Application>{
private List<Application> items;
public AppAdapter(Context context, List<Application> items) {
super(context, R.layout.app_custom_list, items);
this.items = items;
}
@Override
public int getCount() {
return items.size();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if(v == null) {
LayoutInflater li = LayoutInflater.from(getContext());
v = li.inflate(R.layout.app_custom_list, null);
}
Application app = items.get(position);
if(app != null) {
ImageView icon = (ImageView)v.findViewById(R.id.appIcon);
TextView titleText = (TextView)v.findViewById(R.id.titleTxt);
LinearLayout ratingCntr =
(LinearLayout)v.findViewById(R.id.ratingCntr);
TextView dlText = (TextView)v.findViewById(R.id.dlTxt);
if(icon != null) {
Resources res = getContext().getResources();
String sIcon = "com.sj.customlistview:drawable/" +
app.getIcon();
icon.setImageDrawable(res.getDrawable(res.getIdentifier(sIcon,
null, null)));
}
if(titleText != null) titleText.setText(app.getTitle());
if(dlText != null) {
NumberFormat nf = NumberFormat.getNumberInstance();
dlText.setText(nf.format(app.getTotalDl())+" dl");
}
if(ratingCntr != null && ratingCntr.getChildCount() == 0) {
/*
* max rating: 5
*/
for(int i=1; i<=5; i++) {
ImageView iv = new ImageView(getContext());
if(i <= app.getRating()) {
iv.setImageDrawable(getContext().getResources().getDrawable(R.drawable.start_checked));
}
else {
iv.setImageDrawable(getContext().getResources().getDrawable(R.drawable.start_unchecked));
}
ratingCntr.addView(iv);
}
}
}
return v;
}
}

Java MySQL JDBC Slow/Taking turns

Java MySQL JDBC Slow/Taking turns

We're currently trying to make our server software use a connection pool
to greatly reduce lag however instead of reducing the time queries take to
run, it is doubling the time and making it even slower than it was before
the connection pool.
Are there any reasons for this? Does JDBC only allow a single query at a
time or is there another issue?

Blackberry (BBOS) Webworks error: java.io.FileNotFoundException initialization.log

Blackberry (BBOS) Webworks error: java.io.FileNotFoundException
initialization.log

I developed a basic Hello World application. When trying to launch the app
on the simulator I got this error:

config.xml
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello World</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello World</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>

BinaryReader throws NullReferenceException when being disposed

BinaryReader throws NullReferenceException when being disposed

I have a class MyClass that needs data from a file that will be used
throughout the run of the program. To read in the data I have another
class OpenFileService that derives from IDisposable and uses a
BinaryReader to read in all the data:
internal class OpenFileService : IDisposable
{
#region disposing data
bool disposed = false;
public void Dispose()
{
if (!disposed)
{
Dispose(true);
GC.SuppressFinalize(this);
disposed = true;
}
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
br.Dispose();
}
}
~OpenFileService()
{
Dispose(false);
}

Deny access to folders and content in it, lying in my Website folder

Deny access to folders and content in it, lying in my Website folder

I short, i don't want a user to access folders and the data or files in
it....
I searched a bit and i come up with "deny from all" but it is not working
when i put it on ftp.....but on localhost its working... I write the below
given code in my upload folder
# .htaccess mod_rewrite
RewriteEngine On
deny from all

TokenHelper - Could not find token mapped to token name struts.token

TokenHelper - Could not find token mapped to token name struts.token

If I add the "execAndWait" interceptor, it gives me the above error.
"TokenHelper - Could not find token mapped to token name struts.token"
<action name="flightsearch" method="getFlightResult"
class="com.test.FlightSearchAction">
<interceptor-ref name="execAndWait">
<param name="delay">500</param>
<param name="delaySleepInterval">500</param>
</interceptor-ref>
<!-- <interceptor-ref name="token">
<param name="excludeMethods">getFlightResult</param>
</interceptor-ref> -->
<result name="wait" type="tiles">flightwait</result>
<result name="success" type="tiles">flightsearchresult</result>
</action>
<interceptors>
<interceptor-stack name="tokenCheck">
<interceptor-ref name="token" />
<interceptor-ref name="defaultStack" />
<interceptor-ref name="basicStackHibernate" />
</interceptor-stack>
<interceptor-stack name="loggingRequired">
<interceptor-ref name="defaultStack" />
<interceptor-ref name="basicStackHibernate" />
</interceptor-stack>
</interceptors>
As I have read, some says this is an warning, and we can avoid it by
changing the TokenHelper class. If so how to do that?
Thanks.

Saturday, 14 September 2013

select from string field , separated SqlServer

select from string field , separated SqlServer

i have table1 that has field contains value separated with ','
name value
--------------------------
test 1,2
flower 3
car 4,2
dog 2
i want select command that find rows contains specific value in this column
string @value = 2
select * from table1 where ?
name value
--------------------------
test 1,2
car 4,2
dog 2

How to use regex for multiple line pattern in shell script

How to use regex for multiple line pattern in shell script

I want to write a bash script that finds a pattern in a html-file which is
going over multiple lines.
File for regex:
<td class="content">
some content
</td>
<td class="time">
13.05.2013 17:51
</td>
<td class="author">
A Name
</td>
Now I want to find the content of <td>-tag with the class="time".
So in principle the following regex:
<td class="time">(\d{2}\.\d{2}\.\d{4}\s+\d{2}:\d{2})</td>
grep seems not to be the command I can use, because...
It only returns the complete line or the complete result using -o and not
only the result inside the round brackets (...).
It looks only in one line for a pattern
So how is it possible that I will get only a string with 13.05.2013 17:51?

Count vowels, consonsants, digits, and other char in a entered string of text

Count vowels, consonsants, digits, and other char in a entered string of text

Can someone please look at my code? I need to count the characters and
have them display in the correct label box. I did have the digit one
working and them messed it up working on the vowels. I am so frustrated.
Thanks, Tish
int consCount = 0;
int vowelCount = 0;
int digitCount = 0;
int otherCount = 0;
string inputString;
inputString = this.entryTextBox.Text.ToLower();
char[] vowels = new char[] {'a', 'e', 'i', 'o', 'u'};
string vow = new string(vowels);
for (int index = 0; index < inputString.Length; index++)
{
if (char.IsLetterOrDigit(inputString[index]))
{
if (inputString.Contains(vow))
vowelCount++;
}
}
else if (char.IsDigit(inputString[index]))
{
digitCount++;
}
this.voweldisplayLabel.Text = vowelCount.ToString();
this.digitsdisplayLabel.Text = digitCount.ToString();
this.constdisplayLabel.Text = consCount.ToString();

Position without using position relative?

Position without using position relative?

I have a problem where I can't seem to position things on my site with out
position relative, certain things I can position with float left and
margin (right, left, bottom and top) but some I need to use position
relative and the problem is that I have a big gap I can't get ride of at
the bottom.
I've tried using height but then it dis aligns where something's are. Is
there any way of doing this with out position relative?

Sorting using jQUery

Sorting using jQUery

Please help sort the html code below using jQUery when the page is loaded.
<table class="productlist">
<tbody>
<tr>
<td class="productItem" id="catProdTd_5437359">
<div class="shop-product-small clear">
<div class="image">
<a
href="/dining/bambury-microfibre-dish-drying-mat-range"><img
border="0" alt="Bambury Microfibre Dish Drying Mat Range"
src="/images/products/bambury-microfibredishdryingmat-sm.jpg"
id="catsproduct_5437359"></a><br>
<p class="custom2">Linux</p>
</div>
</div>
</td>
<td class="productItem" id="catProdTd_5437366">
<div class="shop-product-small clear">
<div class="image">
<a
href="/dining/bambury-microfibre-terry-tea-towel-range"><img
border="0" alt="Bambury Microfibre Terry Tea Towel Range"
src="/images/products/bambury-microfibreteatowel-sm.jpg"
id="catsproduct_5437366"></a><br>
<p class="custom2">Apple</p>
</div>
</div>
</td>
<td class="productItem" id="catProdTd_3328776">
<div class="shop-product-small clear">
<div class="image">
<a
href="/dining/hyde-park-buzz-off-140x140cm-food-cover-range"><img
border="0" alt="Hyde Park Buzz Off 140x140cm Food Cover
Range" src="/images/products/hydepark-buzzoffs-sm.jpg"
id="catsproduct_3328776"></a><br>
<p class="custom2">Windows</p>
</div>
</div>
</td>
</tr>
</tbody>
</table>

CoreData - TableView init with Objects?

CoreData - TableView init with Objects?

It is easy to create tableView with some data already using NSMutableArray
and initWithObjects method.
However, is it possible to do the same when using core data?
i.e. let's say that entity is called MyEntity and Attributes are name and
value.
table cell has identifiew myCell.

Google Drive SDK login with email address and password

Google Drive SDK login with email address and password

I was able to upload a picture to my Google Drive with this example based
on the Google Drive SDK. My problem now is that the user has to select an
account on the phone at the beginning. I want to give my users the option
to login with an other account as they have on the phone. So I want that
my user can login with a gmail address and the password. Is that possible
or do I have to go over the account chooser?

Friday, 13 September 2013

How to have the option of having a user add an image in android

How to have the option of having a user add an image in android

I am developing an android application for the first time and I was
wondering how can I have a option of having the user upload an image. Like
for example, in a contact manager the user has the option of uploading an
image of a contact. I was wondering how can I do that in my android
application. Any help would be appreciated.

Raspbery pi to regularly update time from network

Raspbery pi to regularly update time from network

I have a raspberry pi on the wheezy distribution with ntpdate installed,
this later runs on boot time and updates the time from the internet.
However my pi runs without reboot for an extended time and as such the
clock does not become accurate overtime.
I am wondering if there is a code i can run (i.e. crojob) or something so
that the time is update say every couple of hours.

Passing Multiple Parameters in SSRS Called from Stored Procedure Returns Blank

Passing Multiple Parameters in SSRS Called from Stored Procedure Returns
Blank

I've created two datasets.
Dataset1 (from a stored procedure):
CREATE PROCEDURE [dbo].[usp_GetPerson](
@Category varchar(20))
AS
BEGIN
SELECT FirstName, LastName, Category
FROM tblPerson
WHERE (Category IN (@Category))
END
Dataset2:
SELECT DISTINCT Category
FROM tbl Person
In SSRS, I've edited the parameter to allow multiple values and to pull
available values from Dataset2.
I've tried filtering based on Dataset1 alone, but receive all the inputs
which are repetitive (which is why I opted using dataset 2).
When I use the stored procedure, I can't seem to select multiple values.
I'm only able to select single values, otherwise the report goes blank.
So I recreated Dataset1, but did not use the stored procedure. Instead I
just wrote the SQL statement in the text editor, and I'm able to select
the multiple values just fine.
Does anyone know why this happens and could help me fix this?
Note: I'm using stored procedures for when my SQL statements become more
complex where I will be joining multiple databases. I tried doing this in
SSRS, but it was much faster using stored procedures.
Thank you!