NetBeans SVN Error
I tried to configure SVN in netbeans after creating the server on a
machine on the local network. on my computer i do TELNET 3690 she
succeeded.
when configuring netbeans it returns me this error:
org.apache.subversion.javahl.ClientException: E210004: Number is larger
than maximum
Thursday, 3 October 2013
Wednesday, 2 October 2013
Need help validating radio buttons with JavaScript
Need help validating radio buttons with JavaScript
I've read over a large number of other questions like mine that have been
answered, and I still can't seem to get my code to work. Hoping someone
can shed light onto where I'm going wrong.
Here's the section of HTML:
<span class="formbold">Will you be attending the ceremony and
reception?</span><br/>
<input type="radio" name="receptionattend" value="yesboth" /> Yes, both!<br/>
<input type="radio" name="receptionattend" value="yesc" /> Yes, but only
the ceremony! <br/>
<input type="radio" name="receptionattend" value="yesr" /> Yes, but only
the reception!<br/>
<input type="radio" name="receptionattend" value="no" /> No, you guys are
lame!
And here's the simplest validation code I have:
function validateForm()
var y=document.forms["rsvpform"]["receptionattend"].checked;
if (y==null || y=="")
{
alert("Please indicate whether or not you will attend.");
return false;
}
}
HALP!
I've read over a large number of other questions like mine that have been
answered, and I still can't seem to get my code to work. Hoping someone
can shed light onto where I'm going wrong.
Here's the section of HTML:
<span class="formbold">Will you be attending the ceremony and
reception?</span><br/>
<input type="radio" name="receptionattend" value="yesboth" /> Yes, both!<br/>
<input type="radio" name="receptionattend" value="yesc" /> Yes, but only
the ceremony! <br/>
<input type="radio" name="receptionattend" value="yesr" /> Yes, but only
the reception!<br/>
<input type="radio" name="receptionattend" value="no" /> No, you guys are
lame!
And here's the simplest validation code I have:
function validateForm()
var y=document.forms["rsvpform"]["receptionattend"].checked;
if (y==null || y=="")
{
alert("Please indicate whether or not you will attend.");
return false;
}
}
HALP!
how to create an url to modify respons on a google-form
how to create an url to modify respons on a google-form
When you submit a form, you have the possibility to modify the respons via
a link gave when you submit the form.
I create a script on a spreadsheet linked to this form, I need to send to
the user this link (to allow the user to modify later his respons). hope
my english is clear
When you submit a form, you have the possibility to modify the respons via
a link gave when you submit the form.
I create a script on a spreadsheet linked to this form, I need to send to
the user this link (to allow the user to modify later his respons). hope
my english is clear
understanding this C++ module?
understanding this C++ module?
Given a type Money that is a structured type with two int fields,
dollars and cents. Assume that an array named monthlySales with 12
elements , each of type Money has been declared and initialized .
Assume that a Moneyvariable yearlySales has also been declared . Write
the necessary code that traverses the monthlySalesarray and adds it all
up and stores the resulting total in yearlySales. Be sure make sure that
yearlySales ends up with a valid value , i.e. a value of cents that is
less than 100.
Now i'm not asking for the answer but, i'm asking how do i approach it.
simply because i'm not sure how to address the question like how to code
it. I have understand the first paragraph of the question respectively.
here is my snippet of code. now im just stuck on how to compute it. i just
need a bit of guidance. Thanks! the code i have so far it access the array
i have of 12 elements and assigns them random numbers of dollars and cents
respectively.
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
using namespace std;
struct Money
{
int dollars,cents;
};
int main()
{
Money monthlySales[12], yearlySales;
for (int i = 0; i < 12; i++)
{
monthlySales[i].cents =rand()%99;
monthlySales[i].dollars =rand();
}
return 0;
}
Given a type Money that is a structured type with two int fields,
dollars and cents. Assume that an array named monthlySales with 12
elements , each of type Money has been declared and initialized .
Assume that a Moneyvariable yearlySales has also been declared . Write
the necessary code that traverses the monthlySalesarray and adds it all
up and stores the resulting total in yearlySales. Be sure make sure that
yearlySales ends up with a valid value , i.e. a value of cents that is
less than 100.
Now i'm not asking for the answer but, i'm asking how do i approach it.
simply because i'm not sure how to address the question like how to code
it. I have understand the first paragraph of the question respectively.
here is my snippet of code. now im just stuck on how to compute it. i just
need a bit of guidance. Thanks! the code i have so far it access the array
i have of 12 elements and assigns them random numbers of dollars and cents
respectively.
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
using namespace std;
struct Money
{
int dollars,cents;
};
int main()
{
Money monthlySales[12], yearlySales;
for (int i = 0; i < 12; i++)
{
monthlySales[i].cents =rand()%99;
monthlySales[i].dollars =rand();
}
return 0;
}
Event bound to document fragment doesn't work after reappending
Event bound to document fragment doesn't work after reappending
I have a document fragment which is created like this:
var element = $("<div/>", {
class: "test"
});
Then I bind a click event on it and add it to the DOM:
element.click(function () {alert("click event successfully recognized");});
$("body").append(element);
This works perfectly so far. You may try this Live DEMO
Note: Please spare me your comments about the deprecated usage of alert()
for debugging.
The problem: Imagine all elements contained by body need to be removed to
display something else. But when this other displayed thing is not needed
anymore and the element is added to the DOM again the bound events won't
work anymore.
Like this:
$("body").empty();
$("body").append(element);
Live DEMO
Please respect that hiding the element instead of removing them is not an
option. I primarily would appreciate a detailed explanation of why this
happens and how this could be solved. I would prefer to not bind the event
again.
I have a document fragment which is created like this:
var element = $("<div/>", {
class: "test"
});
Then I bind a click event on it and add it to the DOM:
element.click(function () {alert("click event successfully recognized");});
$("body").append(element);
This works perfectly so far. You may try this Live DEMO
Note: Please spare me your comments about the deprecated usage of alert()
for debugging.
The problem: Imagine all elements contained by body need to be removed to
display something else. But when this other displayed thing is not needed
anymore and the element is added to the DOM again the bound events won't
work anymore.
Like this:
$("body").empty();
$("body").append(element);
Live DEMO
Please respect that hiding the element instead of removing them is not an
option. I primarily would appreciate a detailed explanation of why this
happens and how this could be solved. I would prefer to not bind the event
again.
Tuesday, 1 October 2013
Showing actionsheet causes CGContext invalid context errors
Showing actionsheet causes CGContext invalid context errors
I'm using actionsheet to display lists of data for the user to choose
from. The problem is that showing the actionsheet using [self.actionSheet
showInView:self.view]; is causing several CGContext errors. The same code
worked well in iOS 6.
Code:
self.actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[self.actionSheet setActionSheetStyle:UIActionSheetStyleBlackOpaque];
CGRect tableFrame = CGRectMake(0, 40, 320, 214);
self.tableView = [[UITableView alloc] initWithFrame:tableFrame
style:UITableViewStylePlain];
self.tableView.dataSource = self;
self.tableView.delegate = self;
[self.actionSheet addSubview:self.tableView];
UISegmentedControl *closeButton = [[UISegmentedControl alloc]
initWithItems:[NSArray arrayWithObject:@"Done"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.tintColor = [UIColor redColor];
[closeButton addTarget:self action:@selector(dismissActionSheet:)
forControlEvents:UIControlEventValueChanged];
[self.actionSheet addSubview:closeButton];
[self.actionSheet showFromView:self.view];
[UIView beginAnimations:nil context:nil];
[self.actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
[UIView commitAnimations];
Errors:
CGContextSetFillColorWithColor: invalid context 0x0. This is a serious
error. This application, or a library it uses, is using an invalid context
and is thereby contributing to an overall degradation of system stability
and reliability. This notice is a courtesy: please fix this problem. It
will become a fatal error in an upcoming update.
CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious
error. This application, or a library it uses, is using an invalid context
and is thereby contributing to an overall degradation of system stability
and reliability. This notice is a courtesy: please fix this problem. It
will become a fatal error in an upcoming update.
CGContextSaveGState: invalid context 0x0. This is a serious error. This
application, or a library it uses, is using an invalid context and is
thereby contributing to an overall degradation of system stability and
reliability. This notice is a courtesy: please fix this problem. It will
become a fatal error in an upcoming update.
CGContextSetFlatness: invalid context 0x0. This is a serious error. This
application, or a library it uses, is using an invalid context and is
thereby contributing to an overall degradation of system stability and
reliability. This notice is a courtesy: please fix this problem. It will
become a fatal error in an upcoming update.
CGContextAddPath: invalid context 0x0. This is a serious error. This
application, or a library it uses, is using an invalid context and is
thereby contributing to an overall degradation of system stability and
reliability. This notice is a courtesy: please fix this problem. It will
become a fatal error in an upcoming update.
CGContextDrawPath: invalid context 0x0. This is a serious error. This
application, or a library it uses, is using an invalid context and is
thereby contributing to an overall degradation of system stability and
reliability. This notice is a courtesy: please fix this problem. It will
become a fatal error in an upcoming update.
CGContextRestoreGState: invalid context 0x0. This is a serious error. This
application, or a library it uses, is using an invalid context and is
thereby contributing to an overall degradation of system stability and
reliability. This notice is a courtesy: please fix this problem. It will
become a fatal error in an upcoming update.
The original code came from another stackoverflow answer, see
http://stackoverflow.com/a/2074451/654870.
I'm using actionsheet to display lists of data for the user to choose
from. The problem is that showing the actionsheet using [self.actionSheet
showInView:self.view]; is causing several CGContext errors. The same code
worked well in iOS 6.
Code:
self.actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[self.actionSheet setActionSheetStyle:UIActionSheetStyleBlackOpaque];
CGRect tableFrame = CGRectMake(0, 40, 320, 214);
self.tableView = [[UITableView alloc] initWithFrame:tableFrame
style:UITableViewStylePlain];
self.tableView.dataSource = self;
self.tableView.delegate = self;
[self.actionSheet addSubview:self.tableView];
UISegmentedControl *closeButton = [[UISegmentedControl alloc]
initWithItems:[NSArray arrayWithObject:@"Done"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.tintColor = [UIColor redColor];
[closeButton addTarget:self action:@selector(dismissActionSheet:)
forControlEvents:UIControlEventValueChanged];
[self.actionSheet addSubview:closeButton];
[self.actionSheet showFromView:self.view];
[UIView beginAnimations:nil context:nil];
[self.actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
[UIView commitAnimations];
Errors:
CGContextSetFillColorWithColor: invalid context 0x0. This is a serious
error. This application, or a library it uses, is using an invalid context
and is thereby contributing to an overall degradation of system stability
and reliability. This notice is a courtesy: please fix this problem. It
will become a fatal error in an upcoming update.
CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious
error. This application, or a library it uses, is using an invalid context
and is thereby contributing to an overall degradation of system stability
and reliability. This notice is a courtesy: please fix this problem. It
will become a fatal error in an upcoming update.
CGContextSaveGState: invalid context 0x0. This is a serious error. This
application, or a library it uses, is using an invalid context and is
thereby contributing to an overall degradation of system stability and
reliability. This notice is a courtesy: please fix this problem. It will
become a fatal error in an upcoming update.
CGContextSetFlatness: invalid context 0x0. This is a serious error. This
application, or a library it uses, is using an invalid context and is
thereby contributing to an overall degradation of system stability and
reliability. This notice is a courtesy: please fix this problem. It will
become a fatal error in an upcoming update.
CGContextAddPath: invalid context 0x0. This is a serious error. This
application, or a library it uses, is using an invalid context and is
thereby contributing to an overall degradation of system stability and
reliability. This notice is a courtesy: please fix this problem. It will
become a fatal error in an upcoming update.
CGContextDrawPath: invalid context 0x0. This is a serious error. This
application, or a library it uses, is using an invalid context and is
thereby contributing to an overall degradation of system stability and
reliability. This notice is a courtesy: please fix this problem. It will
become a fatal error in an upcoming update.
CGContextRestoreGState: invalid context 0x0. This is a serious error. This
application, or a library it uses, is using an invalid context and is
thereby contributing to an overall degradation of system stability and
reliability. This notice is a courtesy: please fix this problem. It will
become a fatal error in an upcoming update.
The original code came from another stackoverflow answer, see
http://stackoverflow.com/a/2074451/654870.
Is it possible to set a debug point in freemarker template file?
Is it possible to set a debug point in freemarker template file?
I have alot of coding in freemarker template files for view layer in my app.
I was wondering if i can set a debug point with eclipse. Is there any good
plugin that i can use to debug freemarker template files?
I have alot of coding in freemarker template files for view layer in my app.
I was wondering if i can set a debug point with eclipse. Is there any good
plugin that i can use to debug freemarker template files?
Stuck on "Starting HWActivator * [done] message - login window does not appear
Stuck on "Starting HWActivator * [done] message - login window does not
appear
I cannot login.
If I let the normal boot, after the GRU window, I have the "Starting
HWActivator * [done] message;
If I try the recovery mode I cannot enable internet access and it does not
recognize my username+password if I try ctrl+alt+f1.
If I try boot with a preavious ubuntu version, I have the login window.
Nevertheless, when entering the password, it returns "permission denied".
If I enter a wrong password, the custom message of wrong password appears.
If I try mount the ubuntu partition with a live usb key using
gksudo nautilus
I still in hot water because I still do not having permission to access my
data.
If I try change the permissions with
sudo chmod -R a+rw /media/myCrazyPartitionName
I still having the permission denied message.
I have a windows partition and it works perfectly.
Please, any suggestion?
=============================================
I also found this
ubuntu-gets-stuck-in-a-login-loop
but the point is that the system returns the permission denied message
when I try to login using the prompt or any preavious ubuntu version.
Any idea?
appear
I cannot login.
If I let the normal boot, after the GRU window, I have the "Starting
HWActivator * [done] message;
If I try the recovery mode I cannot enable internet access and it does not
recognize my username+password if I try ctrl+alt+f1.
If I try boot with a preavious ubuntu version, I have the login window.
Nevertheless, when entering the password, it returns "permission denied".
If I enter a wrong password, the custom message of wrong password appears.
If I try mount the ubuntu partition with a live usb key using
gksudo nautilus
I still in hot water because I still do not having permission to access my
data.
If I try change the permissions with
sudo chmod -R a+rw /media/myCrazyPartitionName
I still having the permission denied message.
I have a windows partition and it works perfectly.
Please, any suggestion?
=============================================
I also found this
ubuntu-gets-stuck-in-a-login-loop
but the point is that the system returns the permission denied message
when I try to login using the prompt or any preavious ubuntu version.
Any idea?
When walking on the road=?iso-8859-1?Q?=2C_is_it_safer_to_walk_in_the_same_or_opposite_direction_?=as the traffic=?iso-8859-1?Q?=3F_=96_travel.stackexchange.com?=
When walking on the road, is it safer to walk in the same or opposite
direction as the traffic? – travel.stackexchange.com
I don't know this question will qualify for this site or not, but, I have
this question. When you are walking on the road anywhere (any country,
city, etc), Which is safer? Walking in the ...
direction as the traffic? – travel.stackexchange.com
I don't know this question will qualify for this site or not, but, I have
this question. When you are walking on the road anywhere (any country,
city, etc), Which is safer? Walking in the ...
Monday, 30 September 2013
Notebook fn + f1 to switch the display, so why would the letter p?
Notebook fn + f1 to switch the display, so why would the letter p?
I use Dell notebook and Ubuntu 12.04. A few days ago fn+f1 suddenly type
letter p instead of switch display monitor.
Need your help please.
I use Dell notebook and Ubuntu 12.04. A few days ago fn+f1 suddenly type
letter p instead of switch display monitor.
Need your help please.
Why is one stack piece in the Stackoverflow logo slightly off=?iso-8859-1?Q?=3F_=96_meta.stackoverflow.com?=
Why is one stack piece in the Stackoverflow logo slightly off? –
meta.stackoverflow.com
I understand this question has already been asked but in this I have
expounded on the issue and explain more unsightly features of the
Stackoverflow logo. I'm not sure why but every time I visit ...
meta.stackoverflow.com
I understand this question has already been asked but in this I have
expounded on the issue and explain more unsightly features of the
Stackoverflow logo. I'm not sure why but every time I visit ...
How could I read a file with header and then save the final file with header again?
How could I read a file with header and then save the final file with
header again?
I'd like to read file1 with given header and then implement some
mathematical operations on , for example, the x and Imag columns. Finally
I want to save the final file with header again.
How could I do it?
File1:
#ID ra dec x y Umag Bmag Vmag Rmag
Imag
1.0 53.141 -27.7967 3491.37 4060.43 23.1612 23.7058 23.0223 22.5351
22.1785
2.0 53.140 -27.7956 3496.66 4076.57 24.1362 24.8441 25.0093 24.7304
24.5864
3.0 53.142 -27.8008 3471.25 3997.29 24.1729 25.3841 25.3501 25.1032
25.0042
4.0 53.138 -27.7891 3527.16 4175.46 24.4685 26.1972 26.1785 25.5567
25.3188
5.0 53.146 -27.8085 3424.83 3880.66 24.425 25.1966 25.2755 24.9514
24.3456
header again?
I'd like to read file1 with given header and then implement some
mathematical operations on , for example, the x and Imag columns. Finally
I want to save the final file with header again.
How could I do it?
File1:
#ID ra dec x y Umag Bmag Vmag Rmag
Imag
1.0 53.141 -27.7967 3491.37 4060.43 23.1612 23.7058 23.0223 22.5351
22.1785
2.0 53.140 -27.7956 3496.66 4076.57 24.1362 24.8441 25.0093 24.7304
24.5864
3.0 53.142 -27.8008 3471.25 3997.29 24.1729 25.3841 25.3501 25.1032
25.0042
4.0 53.138 -27.7891 3527.16 4175.46 24.4685 26.1972 26.1785 25.5567
25.3188
5.0 53.146 -27.8085 3424.83 3880.66 24.425 25.1966 25.2755 24.9514
24.3456
Force To Read HttpWebResponse.GetResponseStream() When Content-Length Is Zero
Force To Read HttpWebResponse.GetResponseStream() When Content-Length Is Zero
As title said.
Sometime an HTTP response from remote server includes Content-Length
header with zero value, but it still return HTTP body. The body can still
be obtained with jQuery in browser, but using
HttpWebResponse.GetResponseStream() can't read anything. How do I force to
read it? Thanks everyone.
Here's an example of HTTP response which I met.
HTTP/1.1 200 OK Connection: keep-alive Cache-Control: no-cache,no-store
Content-Type: text/plain Content-Length: 0 Date: Mon, 30 Sep 2013 09:34:21
GMT
As title said.
Sometime an HTTP response from remote server includes Content-Length
header with zero value, but it still return HTTP body. The body can still
be obtained with jQuery in browser, but using
HttpWebResponse.GetResponseStream() can't read anything. How do I force to
read it? Thanks everyone.
Here's an example of HTTP response which I met.
HTTP/1.1 200 OK Connection: keep-alive Cache-Control: no-cache,no-store
Content-Type: text/plain Content-Length: 0 Date: Mon, 30 Sep 2013 09:34:21
GMT
Sunday, 29 September 2013
JNDI resource lookup fails with Glassfish
JNDI resource lookup fails with Glassfish
Created a JNDI custom resource:
imageBasePath
java.lang.String
/home/user/NetBeansProjects/Builder/images
Tried looking it up as follows:
InitialContext ctx;
try {
ctx = new InitialContext();
Object o = ctx.lookup("imageBasePath");
} catch (NamingException ex) {
Logger.getLogger(blanketBean.class.getName()).log(Level.SEVERE, null,
ex);
}
It throws exception:
(javax.naming.CommunicationException) javax.naming.CommunicationException:
Communication exception for
SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl,
java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is
java.lang.IllegalArgumentException: type cannot be null]
What am I doing wrong?
Created a JNDI custom resource:
imageBasePath
java.lang.String
/home/user/NetBeansProjects/Builder/images
Tried looking it up as follows:
InitialContext ctx;
try {
ctx = new InitialContext();
Object o = ctx.lookup("imageBasePath");
} catch (NamingException ex) {
Logger.getLogger(blanketBean.class.getName()).log(Level.SEVERE, null,
ex);
}
It throws exception:
(javax.naming.CommunicationException) javax.naming.CommunicationException:
Communication exception for
SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl,
java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is
java.lang.IllegalArgumentException: type cannot be null]
What am I doing wrong?
In programming languages, what is typically the way used to represent binary values?
In programming languages, what is typically the way used to represent
binary values?
I'm not asking about a particular language, but just in general. I know
that, for example, #0x or simply 0x is put before the number, or an h is
placed after the number, to refer to hexadecimal.
Is there a similar "standard" for binary?
binary values?
I'm not asking about a particular language, but just in general. I know
that, for example, #0x or simply 0x is put before the number, or an h is
placed after the number, to refer to hexadecimal.
Is there a similar "standard" for binary?
Bitmap font glyph offset and x axis?
Bitmap font glyph offset and x axis?
I have a bitmapfont, created with the angel'scode bitmap generator. I have
a png with the texture and a .fnt with the information of the font
(texture coordinates, char width and height, offsets, advance, etc...).
That information is stored inside a struct called 'glyph'
I am rendering those glyphs with this code:
float x_cursor = 0.0f;
// Record each char of my string
for(int i=0; i < [mystring length];i++)
{
// Get the char id
int mychar = (int)[mystring characterAtIndex:i];
// Get the glyph information of the char to render
GlyphChar glyph;
if([GlpyhCharBuffer count] < (mychar-first_char)+1)
continue;
NSValue * valuegly = [GlpyhCharBuffer objectAtIndex:(mychar-first_char)];
if(valuegly == nil)
{
continue;
}
[valuegly getValue:&glyph];
// Start with the OpenGL Drawing
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
// Where to draw our char
float y_offsetpos = screen_point[1] + TOGLUNIT(glyph.y_offset) * -1.0f;
float x_glyphpos = screen_point[0] +
TOGLUNIT(x_cursor+(float)glyph.x_offset);
GLKMatrix4 model_modifier = GLKMatrix4MakeTranslation(x_glyphpos,
y_offsetpos, 0.0f);
float glyph_width = TOGLUNIT((float)glyph.char_width);
float glyph_height = TOGLUNIT((float)glyph.char_height);
// Move the cursor in the x axis for the following char
x_cursor += (float)glyph.x_advance;
// Create our model matrix, for scale and translate our char
GLKMatrix4 model_modifier = GLKMatrix4MakeTranslation(x_glyphpos,
y_offsetpos, 0.0f);
model_modifier = GLKMatrix4Scale(model_modifier, glyph_width,
glyph_height,0.0f);
GLuint uniform_dir = glGetUniformLocation(program, "model_matrix");
glUniformMatrix4fv(uniform_dir, 1, GL_FALSE, model_modifier.m);
glBindBuffer(GL_ARRAY_BUFFER, square_buff);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
glBindBuffer(GL_ARRAY_BUFFER, glyph.uvscoord);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)0);
glBindTexture(tex_information.target, tex_information.name);
glDrawArrays(GL_TRIANGLES, 0, 6);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(0);
}
the X Axis is not working good, it gives a bad result:
I already tried with a lot of fonts, generated by the angel'scode and
stills giving the same error. How the X Aligning on a bitmap font works?
I have a bitmapfont, created with the angel'scode bitmap generator. I have
a png with the texture and a .fnt with the information of the font
(texture coordinates, char width and height, offsets, advance, etc...).
That information is stored inside a struct called 'glyph'
I am rendering those glyphs with this code:
float x_cursor = 0.0f;
// Record each char of my string
for(int i=0; i < [mystring length];i++)
{
// Get the char id
int mychar = (int)[mystring characterAtIndex:i];
// Get the glyph information of the char to render
GlyphChar glyph;
if([GlpyhCharBuffer count] < (mychar-first_char)+1)
continue;
NSValue * valuegly = [GlpyhCharBuffer objectAtIndex:(mychar-first_char)];
if(valuegly == nil)
{
continue;
}
[valuegly getValue:&glyph];
// Start with the OpenGL Drawing
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
// Where to draw our char
float y_offsetpos = screen_point[1] + TOGLUNIT(glyph.y_offset) * -1.0f;
float x_glyphpos = screen_point[0] +
TOGLUNIT(x_cursor+(float)glyph.x_offset);
GLKMatrix4 model_modifier = GLKMatrix4MakeTranslation(x_glyphpos,
y_offsetpos, 0.0f);
float glyph_width = TOGLUNIT((float)glyph.char_width);
float glyph_height = TOGLUNIT((float)glyph.char_height);
// Move the cursor in the x axis for the following char
x_cursor += (float)glyph.x_advance;
// Create our model matrix, for scale and translate our char
GLKMatrix4 model_modifier = GLKMatrix4MakeTranslation(x_glyphpos,
y_offsetpos, 0.0f);
model_modifier = GLKMatrix4Scale(model_modifier, glyph_width,
glyph_height,0.0f);
GLuint uniform_dir = glGetUniformLocation(program, "model_matrix");
glUniformMatrix4fv(uniform_dir, 1, GL_FALSE, model_modifier.m);
glBindBuffer(GL_ARRAY_BUFFER, square_buff);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
glBindBuffer(GL_ARRAY_BUFFER, glyph.uvscoord);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)0);
glBindTexture(tex_information.target, tex_information.name);
glDrawArrays(GL_TRIANGLES, 0, 6);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(0);
}
the X Axis is not working good, it gives a bad result:
I already tried with a lot of fonts, generated by the angel'scode and
stills giving the same error. How the X Aligning on a bitmap font works?
perl if eq statement no work in array
perl if eq statement no work in array
I have a string
$seq1= 'ATCGATGCAATTCCGGAAAAAATTTTCCCGGGGGGGAAACCCGGGAAATTT'
so i want to find the frequence of char from user input in this string.
So i change this string to array
$base= <STDIN>; # you can input A or T or C or G
my @Freq1= split //, $seq1;
Then use for loop to calculate the total number of char
for(my $i=0;$i<@Freq1;$i++) {
if($Freq1[$i] eq chomp($base)) {
print "equals $i\n";
$numberbase++;
}
}
But the $Freq1[$i] eq chomp($base) can't work. I don't know why?
I have a string
$seq1= 'ATCGATGCAATTCCGGAAAAAATTTTCCCGGGGGGGAAACCCGGGAAATTT'
so i want to find the frequence of char from user input in this string.
So i change this string to array
$base= <STDIN>; # you can input A or T or C or G
my @Freq1= split //, $seq1;
Then use for loop to calculate the total number of char
for(my $i=0;$i<@Freq1;$i++) {
if($Freq1[$i] eq chomp($base)) {
print "equals $i\n";
$numberbase++;
}
}
But the $Freq1[$i] eq chomp($base) can't work. I don't know why?
Saturday, 28 September 2013
Android sqlite item not being deleted
Android sqlite item not being deleted
Here is my main class
public class HomeScreenActivity extends Activity {
private Button contactButton;
private Button groupContactButton;
private Button historyButton;
private Button optionsButton;
private ListView contactsView;
public static int selectedContactIndex = -1;
DatabaseHandler db;
List<Contact> contactList;
ArrayAdapter<Contact> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_screen);
contactButton = (Button) findViewById(R.id.contactButton);
contactButton.setSelected(true);
groupContactButton = (Button) findViewById(R.id.groupContactButton);
historyButton = (Button) findViewById(R.id.historyButton);
optionsButton = (Button) findViewById(R.id.optionsButton);
contactsView = (ListView) findViewById(R.id.contactsView);
// Set up contact adaptor so the contact list can be viewed in the
// homescreen
db = new DatabaseHandler(this);
contactList = db.getAllContacts();
adapter = new ArrayAdapter<Contact>(this,
R.layout.home_screen_contacts_view, contactList);
contactsView.setAdapter(adapter);
adapter.setNotifyOnChange(true);
// Set Listeners
contactButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setSelected(true);
groupContactButton.setSelected(false);
historyButton.setSelected(false);
}
});
groupContactButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setSelected(true);
historyButton.setSelected(false);
contactButton.setSelected(false);
}
});
historyButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setSelected(true);
groupContactButton.setSelected(false);
contactButton.setSelected(false);
}
});
optionsButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
openOptionsMenu();
}
});
contactsView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
selectedContactIndex = (int) arg3;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.options_menu, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.viewContactDetails:
return true;
case R.id.editContactDetails:
if (selectedContactIndex == -1) {// When no contact is selected,
// inform user.
makeAToast("Please select a contact to edit!");
return true;
}
startActivity(new Intent(this, EditContactActivity.class));
return true;
case R.id.newContact:
startActivity(new Intent(this, NewContactActivity.class));
return true;
case R.id.deleteContact:
if (selectedContactIndex == -1) {// When no contact is selected,
// inform user.
makeAToast("Please select a contact to delete!");
return true;
}
// Create an alert asking for contact deletion confirmation.
AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this,
AlertDialog.THEME_DEVICE_DEFAULT_DARK);
myAlertDialog.setTitle("Confirm Contact Deletion");
myAlertDialog.setMessage("Are you sure you want to delete "
+ db.getContact(selectedContactIndex).getFullName()
+"?"); //ADD THE CONTACT NAME
// Set listener for when they press yes, delete contact and
inform
// user.
myAlertDialog.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
db.deleteContact(db.getContact(selectedContactIndex
+ 1));
makeAToast("Contact successfully deleted.");
Log.d("Reading: ", "Reading all contacts..");
List<Contact> contacts = db.getAllContacts();
for (Contact cn : contacts) {
String log = "Id: "+cn.getID()+" ,First
Name: " + cn.getFirstName()
+" ,Last Name: " + cn.getLastName()
+" ,Mobile Number: " +
cn.getMobileNumber()
+" ,Home Number: " +
cn.getHomeNumber()
+" ,Work Number: " +
cn.getWorkNumber()
+" ,Home Address: " +
cn.getHomeAddress()
+" ,Email Address: " +
cn.getEmailAddress()
+" ,Work Address: " +
cn.getWorkAddress()
+" ,Contact Notes: " +
cn.getContactNotes();
// Writing Contacts to log
Log.d("Name: ", log);
}
}
});
And here is my database handler class:
public class DatabaseHandler extends SQLiteOpenHelper {
// All Static variables
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "contactsManager";
// Contacts table name
private static final String TABLE_CONTACTS = "contacts";
// Contacts Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_FIRST_NAME = "first_name";
private static final String KEY_LAST_NAME = "last_name";
private static final String KEY_MOB_NO = "mobile_number";
private static final String KEY_HOME_NO = "home_number";
private static final String KEY_WORK_NO = "work_number";
private static final String KEY_HOME_ADDR = "home_address";
private static final String KEY_EMAIL_ADDR = "email_address";
private static final String KEY_WORK_ADDR = "work_address";
private static final String KEY_NOTES = "notes";
public DatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
+ KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+ KEY_FIRST_NAME + " TEXT," + KEY_LAST_NAME + " TEXT,"
+ KEY_MOB_NO + " TEXT," + KEY_HOME_NO + " TEXT," +
KEY_WORK_NO
+ " TEXT," + KEY_HOME_ADDR + " TEXT," + KEY_EMAIL_ADDR
+ " TEXT," + KEY_WORK_ADDR + " TEXT," + KEY_NOTES + " TEXT"
+ ");";
db.execSQL(CREATE_CONTACTS_TABLE);
}
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) {
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_CONTACTS);
// Create tables again
onCreate(db);
}
/**
* All CRUD(Create, Read, Update, Delete) Operations
*/
// Adding new contact
void addContact(Contact contact) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_ID, Contact.totalContacts);
values.put(KEY_FIRST_NAME, contact.getFirstName());
values.put(KEY_LAST_NAME, contact.getLastName());
values.put(KEY_MOB_NO, contact.getMobileNumber());
values.put(KEY_HOME_NO, contact.getHomeNumber());
values.put(KEY_WORK_NO, contact.getWorkNumber());
values.put(KEY_HOME_ADDR, contact.getHomeAddress());
values.put(KEY_EMAIL_ADDR, contact.getEmailAddress());
values.put(KEY_WORK_ADDR, contact.getWorkAddress());
values.put(KEY_NOTES, contact.getContactNotes());
// Inserting Row
db.insert(TABLE_CONTACTS, null, values);
db.close(); // Closing database connection
}
// Getting single contact
Contact getContact(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_CONTACTS, new String[] { KEY_ID,
KEY_FIRST_NAME, KEY_LAST_NAME, KEY_MOB_NO, KEY_HOME_NO,
KEY_WORK_NO, KEY_HOME_ADDR, KEY_EMAIL_ADDR, KEY_WORK_ADDR,
KEY_NOTES }, KEY_ID + "=?",
new String[] { String.valueOf(id) }, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
Contact contact = new Contact(Integer.parseInt(cursor.getString(0)),
cursor.getString(1), cursor.getString(2),
cursor.getString(3),
cursor.getString(4), cursor.getString(5),
cursor.getString(6),
cursor.getString(7), cursor.getString(8),
cursor.getString(9));
return contact;
}
// Getting All Contacts
public List<Contact> getAllContacts() {
List<Contact> contactList = new ArrayList<Contact>();
// Select All Query
String selectQuery = "SELECT * FROM " + TABLE_CONTACTS;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
Contact contact = new Contact();
contact.setID(Integer.parseInt(cursor.getString(0)));
contact.setFirstName(cursor.getString(1));
contact.setLastName(cursor.getString(2));
contact.setMobileNumber(cursor.getString(3));
contact.setHomeNumber(cursor.getString(4));
contact.setWorkNumber(cursor.getString(5));
contact.setHomeAddress(cursor.getString(6));
contact.setEmailAddress(cursor.getString(7));
contact.setWorkAddress(cursor.getString(8));
contact.setContactNotes(cursor.getString(9));
// Adding contact to list
contactList.add(contact);
} while (cursor.moveToNext());
}
// return contact list
return contactList;
}
// Updating single contact
public int updateContact(Contact contact) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_FIRST_NAME, contact.getFirstName());
values.put(KEY_LAST_NAME, contact.getLastName());
values.put(KEY_MOB_NO, contact.getMobileNumber());
values.put(KEY_HOME_NO, contact.getHomeNumber());
values.put(KEY_WORK_NO, contact.getWorkNumber());
values.put(KEY_HOME_ADDR, contact.getHomeAddress());
values.put(KEY_EMAIL_ADDR, contact.getEmailAddress());
values.put(KEY_WORK_ADDR, contact.getWorkAddress());
values.put(KEY_NOTES, contact.getContactNotes());
// updating row
return db.update(TABLE_CONTACTS, values, KEY_ID + " = ?",
new String[] { String.valueOf(contact.getID()) });
}
// Deleting single contact
public void deleteContact(Contact contact) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_CONTACTS, KEY_ID + " = ?",
new String[] { String.valueOf(contact.getID()) });
db.close();
}
// Getting contacts Count
public int getContactsCount() {
String countQuery = "SELECT * FROM " + TABLE_CONTACTS;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
cursor.close();
// return count
return cursor.getCount();
}
}
Now, when I delete a contact, not only is it not updating the listview in
my main contacts screen, but when I write all my contacts to log cat, the
contact never even got deleted from the database. Any ideas as to why that
is?
Here is my main class
public class HomeScreenActivity extends Activity {
private Button contactButton;
private Button groupContactButton;
private Button historyButton;
private Button optionsButton;
private ListView contactsView;
public static int selectedContactIndex = -1;
DatabaseHandler db;
List<Contact> contactList;
ArrayAdapter<Contact> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_screen);
contactButton = (Button) findViewById(R.id.contactButton);
contactButton.setSelected(true);
groupContactButton = (Button) findViewById(R.id.groupContactButton);
historyButton = (Button) findViewById(R.id.historyButton);
optionsButton = (Button) findViewById(R.id.optionsButton);
contactsView = (ListView) findViewById(R.id.contactsView);
// Set up contact adaptor so the contact list can be viewed in the
// homescreen
db = new DatabaseHandler(this);
contactList = db.getAllContacts();
adapter = new ArrayAdapter<Contact>(this,
R.layout.home_screen_contacts_view, contactList);
contactsView.setAdapter(adapter);
adapter.setNotifyOnChange(true);
// Set Listeners
contactButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setSelected(true);
groupContactButton.setSelected(false);
historyButton.setSelected(false);
}
});
groupContactButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setSelected(true);
historyButton.setSelected(false);
contactButton.setSelected(false);
}
});
historyButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setSelected(true);
groupContactButton.setSelected(false);
contactButton.setSelected(false);
}
});
optionsButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
openOptionsMenu();
}
});
contactsView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
selectedContactIndex = (int) arg3;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.options_menu, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.viewContactDetails:
return true;
case R.id.editContactDetails:
if (selectedContactIndex == -1) {// When no contact is selected,
// inform user.
makeAToast("Please select a contact to edit!");
return true;
}
startActivity(new Intent(this, EditContactActivity.class));
return true;
case R.id.newContact:
startActivity(new Intent(this, NewContactActivity.class));
return true;
case R.id.deleteContact:
if (selectedContactIndex == -1) {// When no contact is selected,
// inform user.
makeAToast("Please select a contact to delete!");
return true;
}
// Create an alert asking for contact deletion confirmation.
AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this,
AlertDialog.THEME_DEVICE_DEFAULT_DARK);
myAlertDialog.setTitle("Confirm Contact Deletion");
myAlertDialog.setMessage("Are you sure you want to delete "
+ db.getContact(selectedContactIndex).getFullName()
+"?"); //ADD THE CONTACT NAME
// Set listener for when they press yes, delete contact and
inform
// user.
myAlertDialog.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
db.deleteContact(db.getContact(selectedContactIndex
+ 1));
makeAToast("Contact successfully deleted.");
Log.d("Reading: ", "Reading all contacts..");
List<Contact> contacts = db.getAllContacts();
for (Contact cn : contacts) {
String log = "Id: "+cn.getID()+" ,First
Name: " + cn.getFirstName()
+" ,Last Name: " + cn.getLastName()
+" ,Mobile Number: " +
cn.getMobileNumber()
+" ,Home Number: " +
cn.getHomeNumber()
+" ,Work Number: " +
cn.getWorkNumber()
+" ,Home Address: " +
cn.getHomeAddress()
+" ,Email Address: " +
cn.getEmailAddress()
+" ,Work Address: " +
cn.getWorkAddress()
+" ,Contact Notes: " +
cn.getContactNotes();
// Writing Contacts to log
Log.d("Name: ", log);
}
}
});
And here is my database handler class:
public class DatabaseHandler extends SQLiteOpenHelper {
// All Static variables
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "contactsManager";
// Contacts table name
private static final String TABLE_CONTACTS = "contacts";
// Contacts Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_FIRST_NAME = "first_name";
private static final String KEY_LAST_NAME = "last_name";
private static final String KEY_MOB_NO = "mobile_number";
private static final String KEY_HOME_NO = "home_number";
private static final String KEY_WORK_NO = "work_number";
private static final String KEY_HOME_ADDR = "home_address";
private static final String KEY_EMAIL_ADDR = "email_address";
private static final String KEY_WORK_ADDR = "work_address";
private static final String KEY_NOTES = "notes";
public DatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
+ KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+ KEY_FIRST_NAME + " TEXT," + KEY_LAST_NAME + " TEXT,"
+ KEY_MOB_NO + " TEXT," + KEY_HOME_NO + " TEXT," +
KEY_WORK_NO
+ " TEXT," + KEY_HOME_ADDR + " TEXT," + KEY_EMAIL_ADDR
+ " TEXT," + KEY_WORK_ADDR + " TEXT," + KEY_NOTES + " TEXT"
+ ");";
db.execSQL(CREATE_CONTACTS_TABLE);
}
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) {
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_CONTACTS);
// Create tables again
onCreate(db);
}
/**
* All CRUD(Create, Read, Update, Delete) Operations
*/
// Adding new contact
void addContact(Contact contact) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_ID, Contact.totalContacts);
values.put(KEY_FIRST_NAME, contact.getFirstName());
values.put(KEY_LAST_NAME, contact.getLastName());
values.put(KEY_MOB_NO, contact.getMobileNumber());
values.put(KEY_HOME_NO, contact.getHomeNumber());
values.put(KEY_WORK_NO, contact.getWorkNumber());
values.put(KEY_HOME_ADDR, contact.getHomeAddress());
values.put(KEY_EMAIL_ADDR, contact.getEmailAddress());
values.put(KEY_WORK_ADDR, contact.getWorkAddress());
values.put(KEY_NOTES, contact.getContactNotes());
// Inserting Row
db.insert(TABLE_CONTACTS, null, values);
db.close(); // Closing database connection
}
// Getting single contact
Contact getContact(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_CONTACTS, new String[] { KEY_ID,
KEY_FIRST_NAME, KEY_LAST_NAME, KEY_MOB_NO, KEY_HOME_NO,
KEY_WORK_NO, KEY_HOME_ADDR, KEY_EMAIL_ADDR, KEY_WORK_ADDR,
KEY_NOTES }, KEY_ID + "=?",
new String[] { String.valueOf(id) }, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
Contact contact = new Contact(Integer.parseInt(cursor.getString(0)),
cursor.getString(1), cursor.getString(2),
cursor.getString(3),
cursor.getString(4), cursor.getString(5),
cursor.getString(6),
cursor.getString(7), cursor.getString(8),
cursor.getString(9));
return contact;
}
// Getting All Contacts
public List<Contact> getAllContacts() {
List<Contact> contactList = new ArrayList<Contact>();
// Select All Query
String selectQuery = "SELECT * FROM " + TABLE_CONTACTS;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
Contact contact = new Contact();
contact.setID(Integer.parseInt(cursor.getString(0)));
contact.setFirstName(cursor.getString(1));
contact.setLastName(cursor.getString(2));
contact.setMobileNumber(cursor.getString(3));
contact.setHomeNumber(cursor.getString(4));
contact.setWorkNumber(cursor.getString(5));
contact.setHomeAddress(cursor.getString(6));
contact.setEmailAddress(cursor.getString(7));
contact.setWorkAddress(cursor.getString(8));
contact.setContactNotes(cursor.getString(9));
// Adding contact to list
contactList.add(contact);
} while (cursor.moveToNext());
}
// return contact list
return contactList;
}
// Updating single contact
public int updateContact(Contact contact) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_FIRST_NAME, contact.getFirstName());
values.put(KEY_LAST_NAME, contact.getLastName());
values.put(KEY_MOB_NO, contact.getMobileNumber());
values.put(KEY_HOME_NO, contact.getHomeNumber());
values.put(KEY_WORK_NO, contact.getWorkNumber());
values.put(KEY_HOME_ADDR, contact.getHomeAddress());
values.put(KEY_EMAIL_ADDR, contact.getEmailAddress());
values.put(KEY_WORK_ADDR, contact.getWorkAddress());
values.put(KEY_NOTES, contact.getContactNotes());
// updating row
return db.update(TABLE_CONTACTS, values, KEY_ID + " = ?",
new String[] { String.valueOf(contact.getID()) });
}
// Deleting single contact
public void deleteContact(Contact contact) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_CONTACTS, KEY_ID + " = ?",
new String[] { String.valueOf(contact.getID()) });
db.close();
}
// Getting contacts Count
public int getContactsCount() {
String countQuery = "SELECT * FROM " + TABLE_CONTACTS;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
cursor.close();
// return count
return cursor.getCount();
}
}
Now, when I delete a contact, not only is it not updating the listview in
my main contacts screen, but when I write all my contacts to log cat, the
contact never even got deleted from the database. Any ideas as to why that
is?
Cannot submit asp.net login form using $('form').submit();
Cannot submit asp.net login form using $('form').submit();
I have a function that 'pings' the server with a get request and if
successful submit the login form. However in setting the submit button to
return false, the form will not submit using $('form').submit(); The page
just seems to refresh, without actually logging the user in. Why is this?
<asp:Button ID="LoginButton" runat="server" CommandName="Login"
Text="Enter" ValidationGroup="LoginUserValidationGroup"
class="submitButton" />
submitButton.click(function () {
var url = 'https://examplesite.com/';
$.get(url).done(function () {
if (usernameBox.val() === '') {
usernameBox.attr('placeholder', 'Username Required');
passwordBox.attr('placeholder', '');
usernameBox.focus();
return false;
}
else if (passwordBox.length && passwordBox.val() === '') {
passwordBox.attr('placeholder', 'Password Required');
usernameBox.attr('placeholder', '');
passwordBox.focus();
return false;
}
else if (passwordBox.length && passwordBox.val().length <
6) {
passwordBox.focus();
return false;
}
else if (newPasswordBox.length &&
newPasswordBox.val().length < 6) {
passwordBox.focus();
return false;
}
else {
$('form').submit();
}
}).fail(function () {
errorMessage.text('Cannot Connect to Server - Please Try
Again Later').hide().fadeIn(350).delay(5000).fadeOut(350);
});
return false;
});
I have a function that 'pings' the server with a get request and if
successful submit the login form. However in setting the submit button to
return false, the form will not submit using $('form').submit(); The page
just seems to refresh, without actually logging the user in. Why is this?
<asp:Button ID="LoginButton" runat="server" CommandName="Login"
Text="Enter" ValidationGroup="LoginUserValidationGroup"
class="submitButton" />
submitButton.click(function () {
var url = 'https://examplesite.com/';
$.get(url).done(function () {
if (usernameBox.val() === '') {
usernameBox.attr('placeholder', 'Username Required');
passwordBox.attr('placeholder', '');
usernameBox.focus();
return false;
}
else if (passwordBox.length && passwordBox.val() === '') {
passwordBox.attr('placeholder', 'Password Required');
usernameBox.attr('placeholder', '');
passwordBox.focus();
return false;
}
else if (passwordBox.length && passwordBox.val().length <
6) {
passwordBox.focus();
return false;
}
else if (newPasswordBox.length &&
newPasswordBox.val().length < 6) {
passwordBox.focus();
return false;
}
else {
$('form').submit();
}
}).fail(function () {
errorMessage.text('Cannot Connect to Server - Please Try
Again Later').hide().fadeIn(350).delay(5000).fadeOut(350);
});
return false;
});
Find gateway of an interface
Find gateway of an interface
For a bash integration, i need to retrieve the default gateway from an
interface.
here is the output of the command route -n
Table de routage IP du noyau
Destination Passerelle Genmask Indic Metric Ref Use Iface
0.0.0.0 p.p.p.p 128.0.0.0 UG 0 0 0 tun0
0.0.0.0 x.x.x.x 0.0.0.0 UG 100 0 0 eth0
10.43.0.1 10.43.0.5 255.255.255.255 UGH 0 0 0 tun0
10.43.0.5 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
31.220.30.224 88.191.142.1 255.255.255.255 UGH 0 0 0 eth0
x.x.x.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
128.0.0.0 10.43.0.5 128.0.0.0 UG 0 0 0 tun0
I try to capture gateway (Passerelle in French) for Iface tun0.
This regex is working on Rubular:
^[0\.]+\s+([\w\.]+)\s+.*UG.*tun0$
But this shell command doesn't work:
route -n |egrep -oh '^[0\.]+\s+([\w\.]+)\s+.*UG.*tun0$'
Please, tell me why ?
For a bash integration, i need to retrieve the default gateway from an
interface.
here is the output of the command route -n
Table de routage IP du noyau
Destination Passerelle Genmask Indic Metric Ref Use Iface
0.0.0.0 p.p.p.p 128.0.0.0 UG 0 0 0 tun0
0.0.0.0 x.x.x.x 0.0.0.0 UG 100 0 0 eth0
10.43.0.1 10.43.0.5 255.255.255.255 UGH 0 0 0 tun0
10.43.0.5 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
31.220.30.224 88.191.142.1 255.255.255.255 UGH 0 0 0 eth0
x.x.x.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
128.0.0.0 10.43.0.5 128.0.0.0 UG 0 0 0 tun0
I try to capture gateway (Passerelle in French) for Iface tun0.
This regex is working on Rubular:
^[0\.]+\s+([\w\.]+)\s+.*UG.*tun0$
But this shell command doesn't work:
route -n |egrep -oh '^[0\.]+\s+([\w\.]+)\s+.*UG.*tun0$'
Please, tell me why ?
Subscribe to:
Posts (Atom)