Tuesday, 1 October 2013

Can I change notification dialog text?

Can I change notification dialog text?

I am using the latest Xubuntu 13.04. When I go to shut down, I receive the
confirmation notification stating "Are you sure you want to shut down?" I
would like to keep this dialog box, but I want to customize the message it
displays. Can this be done?

Monday, 30 September 2013

Disable Password Authentication for Remote Users Only

Disable Password Authentication for Remote Users Only

I've read how it is possible to disable password authentication on an
Ubuntu server. However, is it possible to disable this for remote users
only?
I'm afraid that, if I enable this both locally and remotely (as designed),
I will ultimately lose the key and lock myself out (over time). If I were
able to disable password authentication for remote users only, losing the
key wouldn't be so tragic; I could simply go to the LAN and login with a
password and create a new key.

Wanting an explanation to the solution method of the system of differential equations.

Wanting an explanation to the solution method of the system of
differential equations.

Please can anybody help me with explaining, in detail, why and how the
author solves the system of differential equations by such a step (see
below)? How the equation 6.3 is formed step by step? Why such a column
basis is valid? It would be extremely helpful if someone knows the name of
the method or could give an exemplification.

ngResource retrive unique ID from POST response after $save()

ngResource retrive unique ID from POST response after $save()

So I have a Resource defined as follows:
angular.module('questionService', ['ngResource'])
.factory('QuestionService', function($http, $resource) {
var QuestionService = $resource('/api/questions/:key', {}, {
query: {
method:'GET',
isArray:true,
},
save: {
method: 'POST',
}
});
return QuestionService
});
And later on I take some form input and do the following
var newQ = {
txt: $scope.addTxt
};
QuestionService.save(newQ)
The server responds to the POST request both by reissuing the JSON for the
object and setting the location header with the new unique ID. The problem
is that Angular is not saving that returned JSON or the location header
into the object and it is not getting set with the ID from the server for
future operations. I've tried a number of things such as:
transformResponse: function(data, headersGetter) {
locationHeader = headersGetter().location;
key = locationHeader.split('/').slice(-1)[0];
data.key = key;
return data;
}
However the returned data item doesn't seem to be getting used. Am I
missing something? This seems like a pretty common use case for
interacting with a REST api.
Thanks!

Using nested if statements to structure code

Using nested if statements to structure code

I'm trying to structure my code in a readable way. I've read that one way
of doing it is as follows:
if(Init1() == TRUE)
{
if(Init2() == TRUE)
{
if(Init3() == TRUE)
{
...
Free3();
}
Free2();
}
Free(1);
}
I like this way of doing things, because it keeps each FreeX inside its
matching InitX loop, but if the nesting goes beyond three levels it
quickly becomes unreadable and goes way beyond 80 columns. Many functions
can be broken up into multiple functions so that this doesn't happen, but
it seems dumb to break up a function just to avoid too many levels of
nesting. In particular, consider a function that does the initialization
for a whole class, where that initialization requires ten or more function
calls. That's ten or more levels of nesting.
I'm sure I'm overthinking this, but is there something fundamental I'm
missing in the above? Can deep nesting be done in a readable way? Or else
restructured somehow whilst keeping each FreeX inside its own InitX loop?
By the way, I realise that the above code can be compacted to if(Init1()
&& Init2()..., but the code is just an example. There would be other code
between each InitX call that would prevent such a compaction.

Sunday, 29 September 2013

Implementing IFB_LLLLCHAR

Implementing IFB_LLLLCHAR

We are using jpos server with ASCIChannel and custom package which
contains one field with max length 9999 to do this we implemented
IFB_LLLLCHAR as follow
public class IFB_LLLLCHAR extends ISOStringFieldPackager {
public IFB_LLLLCHAR() {
super(NullPadder.INSTANCE, AsciiInterpreter.INSTANCE,
BcdPrefixer.LLLL);
}
public IFB_LLLLCHAR(int len, String description) {
super(len, description, NullPadder.INSTANCE,
AsciiInterpreter.INSTANCE, BcdPrefixer.LLLL);
checkLength(len, 9999);
}
public void setLength(int len)
{
checkLength(len, 9999);
super.setLength(len);
}
}
Problem is that i couldn't use the whole 9999 because if the size of whole
message goes over 9999 it throws following exception while sending it
<exception name="len exceeded">
java.io.IOException: len exceeded
at
org.jpos.iso.channel.ASCIIChannel.sendMessageLength(ASCIIChannel.java:80)
at org.jpos.iso.BaseChannel.send(BaseChannel.java:528)
at
com.advam.gateway.terminalmanagementserver.gateway.LogUploadFuncTest.testLogUpload(LogUploadFuncTest.java:39)
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 junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
</exception>
Can anybody tell me why i am getting this exception and how to fix it.
Kindly keep in mind while answering that I don't have much knowledge about
inside of jpos. Thanks

triangle numbers in java

triangle numbers in java

I am new to Java and now I want to learn better for loop. I made some
examples , but I don't know how to do a triangle that look like this: for
n=6:
111111
22222
3333
222
11
6
My code until now:
class Pyramid
{
public static void main (String[] args)
{
int i,n=9,j;
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++) {
System.out.print(i); }
System.out.print("\n");
}}}
But what I managed to do it looks like this:
666666
55555
4444
333
22
1
How to make it in reverse order and to print the given number n when just
one character has to be print?