Click on NSBezierPath
I'm drawing a NSBezierPath line on my NSImageView. I'm creating
NSBezierPath object, setting moveToPoint, setting lineToPoint, setting
setLineWidth: and after that in drawRect of my NSImageView subclass I'm
calling [myNSBezierPath stroke]. It all works just like I want, but I
can't seem to use containsPoint: method... I tried implementing
if([myNSBezierPath containsPoint:[theEvent locationInWindow]]{
//do something
}
in -(void)mouseUp:(NSEvent*)theEvent of my NSImageView subclass but it's
never reacting and I'm sure I'm hitting that line... Am I doing something
wrong? I just need to detect if NSBezierPath is being clicked.
Cheers.
Saturday, 31 August 2013
How to free Watch Henderson vs Pettis live streaming UFC?
How to free Watch Henderson vs Pettis live streaming UFC?
Watch UFC live Fighting Click Here To: Watch Henderson vs Pettis
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
Henderson vs Pettis Live Fight DETAILS Date : Saturday, August 31, 2013
Competition: UFC MMA Major Events live Live / Repeat:Live 10:00pm ET
Watch UFC live Fighting Click Here To: Watch Henderson vs Pettis
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
Henderson vs Pettis Live Fight DETAILS Date : Saturday, August 31, 2013
Competition: UFC MMA Major Events live Live / Repeat:Live 10:00pm ET
Simple fields Wordpress
Simple fields Wordpress
I am trying to use simple fields in my theme but I cant put it in the
theme, I tried everything.
I have made this in my new post to show up:
http://pokit.org/get/?1cbbe77cc829c2c875e11d9a58ac5866.jpg
How can I make simple fields generate this in my single.php :
simple fileds content (value)
and when i go add+ go generate another
simple fileds content (value)
Thanks !
I am trying to use simple fields in my theme but I cant put it in the
theme, I tried everything.
I have made this in my new post to show up:
http://pokit.org/get/?1cbbe77cc829c2c875e11d9a58ac5866.jpg
How can I make simple fields generate this in my single.php :
simple fileds content (value)
and when i go add+ go generate another
simple fileds content (value)
Thanks !
Java and databases - initializing tables
Java and databases - initializing tables
Hi I'm trying to create an address book type program in Java using SQLite.
For now, all it should do is ask the user for a contact name and telephone
number to add to the table.
I haven't started the coding but the thing I cannot get my head around is
the table creations. Suppose I write a program that
1) Connects to a database 2) Creates a table 3) Asks the user for details
about adding contact data (to the table).
I compile it once without errors. But then every time I run the program it
will create a new table. The only thing I can think of is that database
and table creation is done outside of the Java program.
Hi I'm trying to create an address book type program in Java using SQLite.
For now, all it should do is ask the user for a contact name and telephone
number to add to the table.
I haven't started the coding but the thing I cannot get my head around is
the table creations. Suppose I write a program that
1) Connects to a database 2) Creates a table 3) Asks the user for details
about adding contact data (to the table).
I compile it once without errors. But then every time I run the program it
will create a new table. The only thing I can think of is that database
and table creation is done outside of the Java program.
Retrieve element from array in Coldfusion
Retrieve element from array in Coldfusion
I get the following struct return from disqus.com API and I just don't
know how to retrieve only the following value in red using Coldfusion.
This is the full array returned.
{
"cursor":{
"prev":null,
"hasNext":false,
"next":"1213061503000000:1:0",
"hasPrev":false,
"total":null,
"id":"1213061503000000:1:0",
"more":false
},
"code":0,
"response":[
{
"category":"1",
"reactions":0,
"identifiers":[],
"forum":"bobross",
"title":"Donkeys live a long time",
"dislikes":0,
"isDeleted":false,
"author":"1",
"userScore":0,
"id":"2",
"isClosed":false,
"posts":0,
"link":null,
"likes":0,
"message":"\"Donkeys live a long time. None of you have ever seen a
dead donkey.\"",
"ipAddress":"127.0.0.1",
"slug":"donkeys_live_a_long_time",
"createdAt":"2008-06-10T02:31:43"
},
{
"category":"1",
"reactions":0,
"identifiers":[
"my-identifier"
],
"forum":"bobross",
"title":"Happy Accidents",
"dislikes":0,
"isDeleted":false,
"author":"1",
"userScore":0,
"id":"1",
"isClosed":false,
"posts":76,
"link":null,
"likes":0,
"message":"\"If you've painted before you know that we don't make
mistakes -- we have happy accidents.\"",
"ipAddress":"127.0.0.1",
"slug":"happy_accidents",
"createdAt":"2008-06-10T01:31:43"
}
]
}
I get the following struct return from disqus.com API and I just don't
know how to retrieve only the following value in red using Coldfusion.
This is the full array returned.
{
"cursor":{
"prev":null,
"hasNext":false,
"next":"1213061503000000:1:0",
"hasPrev":false,
"total":null,
"id":"1213061503000000:1:0",
"more":false
},
"code":0,
"response":[
{
"category":"1",
"reactions":0,
"identifiers":[],
"forum":"bobross",
"title":"Donkeys live a long time",
"dislikes":0,
"isDeleted":false,
"author":"1",
"userScore":0,
"id":"2",
"isClosed":false,
"posts":0,
"link":null,
"likes":0,
"message":"\"Donkeys live a long time. None of you have ever seen a
dead donkey.\"",
"ipAddress":"127.0.0.1",
"slug":"donkeys_live_a_long_time",
"createdAt":"2008-06-10T02:31:43"
},
{
"category":"1",
"reactions":0,
"identifiers":[
"my-identifier"
],
"forum":"bobross",
"title":"Happy Accidents",
"dislikes":0,
"isDeleted":false,
"author":"1",
"userScore":0,
"id":"1",
"isClosed":false,
"posts":76,
"link":null,
"likes":0,
"message":"\"If you've painted before you know that we don't make
mistakes -- we have happy accidents.\"",
"ipAddress":"127.0.0.1",
"slug":"happy_accidents",
"createdAt":"2008-06-10T01:31:43"
}
]
}
How to add a rangeInput using rails simple_form?
How to add a rangeInput using rails simple_form?
Is it possible to add a rangeInput or anything similar, using rails simple
form gem?
Thanks!
Is it possible to add a rangeInput or anything similar, using rails simple
form gem?
Thanks!
The rails $RAILS_ENV.rb file
The rails $RAILS_ENV.rb file
I'm following this tutorial and I don't really understand what this means:
Action Mailer Configuration for Gmail As Action Mailer now uses the Mail
gem, this becomes as simple as adding to your
config/environments/$RAILS_ENV.rb file:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'example.com',
user_name: '<username>',
password: '<password>',
authentication: 'plain',
enable_starttls_auto: true }
...but I don't have a $RAILS_ENV.rb file. Do I simply add one to my
environments directory, and paste in and append the above information?
Now, I've had a bit of a hiatus from rails, and I've forgotten quite a lot :(
Could someone please explain just what happens inside my environments
directory? Quite detailed, please. I really don't know what it does at
all, so I'd like to know where these parameters are going.
I'm following this tutorial and I don't really understand what this means:
Action Mailer Configuration for Gmail As Action Mailer now uses the Mail
gem, this becomes as simple as adding to your
config/environments/$RAILS_ENV.rb file:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'example.com',
user_name: '<username>',
password: '<password>',
authentication: 'plain',
enable_starttls_auto: true }
...but I don't have a $RAILS_ENV.rb file. Do I simply add one to my
environments directory, and paste in and append the above information?
Now, I've had a bit of a hiatus from rails, and I've forgotten quite a lot :(
Could someone please explain just what happens inside my environments
directory? Quite detailed, please. I really don't know what it does at
all, so I'd like to know where these parameters are going.
Why does MemoryUsageLimit decrease when background process is launched?
Why does MemoryUsageLimit decrease when background process is launched?
According to this, we use ApplicationMemoryUsageLimit to get the maximum
amount of memory that your application process can allocate. As note in
Caution section
The value returned by this property can vary depending on the type of
process that called the property, and the current amount of available
memory on the device. For example, the amount of memory that a background
agent process can allocate could be different than the amount that a
foreground application process can allocate
Using ApplicationMemoryUsageLimit in the UI code, I see 150MB. But after I
launch VoIP process (by calling VoipBackgroundProcess.Launch), I see
100MB.
The coincidence is that when I log ApplicationMemoryUsageLimit in
VoipForegroundLifetimeAgent code, I see 50MB, exactly the amount of memory
that has been decreased.
Why is that ?
According to this, we use ApplicationMemoryUsageLimit to get the maximum
amount of memory that your application process can allocate. As note in
Caution section
The value returned by this property can vary depending on the type of
process that called the property, and the current amount of available
memory on the device. For example, the amount of memory that a background
agent process can allocate could be different than the amount that a
foreground application process can allocate
Using ApplicationMemoryUsageLimit in the UI code, I see 150MB. But after I
launch VoIP process (by calling VoipBackgroundProcess.Launch), I see
100MB.
The coincidence is that when I log ApplicationMemoryUsageLimit in
VoipForegroundLifetimeAgent code, I see 50MB, exactly the amount of memory
that has been decreased.
Why is that ?
Friday, 30 August 2013
Differentiate the functionality of home button and back button in android activitys?
Differentiate the functionality of home button and back button in android
activitys?
I have 6 activitys A,B,C,D,E,F.In this A is a login activity after login
in A activity i go to the activity chain B,C,D,E,F..In this B,C,D,E,F
activitys whenever the user press back button it will go back to to
previous activity if user press home button after opening the application
it will again ask the password how it is possible..?? help me please
activitys?
I have 6 activitys A,B,C,D,E,F.In this A is a login activity after login
in A activity i go to the activity chain B,C,D,E,F..In this B,C,D,E,F
activitys whenever the user press back button it will go back to to
previous activity if user press home button after opening the application
it will again ask the password how it is possible..?? help me please
searched everywhere. i want to email 2 fields. this is just a azure website not VM.Have php script that runs fine except on azure websites
searched everywhere. i want to email 2 fields. this is just a azure
website not VM.Have php script that runs fine except on azure websites
"; $to = "Ramona Recipient "; $subject = "Hi!"; $body = "Hi,\n\nHow are
you?"; $host = "mail.essexmortgage.com"; $username =
"blake@essexmortgage.com"; $password = "dreams123"; $headers = array
('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp =
Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username'
=> $username, 'password' => $password)); $mail = $smtp->send($to,
$headers, $body); if (PEAR::isError($mail)) { echo("
" . $mail->getMessage() . "
"); } else { echo("
Message successfully sent!
"); } ?>
website not VM.Have php script that runs fine except on azure websites
"; $to = "Ramona Recipient "; $subject = "Hi!"; $body = "Hi,\n\nHow are
you?"; $host = "mail.essexmortgage.com"; $username =
"blake@essexmortgage.com"; $password = "dreams123"; $headers = array
('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp =
Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username'
=> $username, 'password' => $password)); $mail = $smtp->send($to,
$headers, $body); if (PEAR::isError($mail)) { echo("
" . $mail->getMessage() . "
"); } else { echo("
Message successfully sent!
"); } ?>
Thursday, 29 August 2013
Facebook Like Action not getting Activated, need to get approved in App developer section
Facebook Like Action not getting Activated, need to get approved in App
developer section
Can anybody just explain a bit more how to get access the Like action from
our web app. We are not able to get the app action approved in Facebook
Developer forum.
The problem is we are not able to get the like counts & also not able to
post the like action to the user timeline.
developer section
Can anybody just explain a bit more how to get access the Like action from
our web app. We are not able to get the app action approved in Facebook
Developer forum.
The problem is we are not able to get the like counts & also not able to
post the like action to the user timeline.
Wednesday, 28 August 2013
JPA: fetching bidirectional many to one relationship
JPA: fetching bidirectional many to one relationship
I'm a beginner to the JPA/JPQL stuff and I'm having problems fetching
many-to-one relationships when I make the relationship bi-directional.
Here is the JPQL:
select c from Child c join fetch c.parent
Here are the two simple classes:
@Entity
public class Parent {
@Id
private int id;
private String title;
@OneToMany(mappedBy = "parent")
private Set<Child> children;
}
@Entity
public class Child {
@Id
private int id;
@ManyToOne(fetch = FetchType.LAZY)
private Parent parent;
}
The equivalent SQL query executed by datanucleus is:
SELECT 'com.*.Child' AS NUCLEUS_TYPE,`C`.`ID`,`C`.`PARENT_ID` FROM `CHILD`
`C` INNER JOIN `PARENT` `B0` ON `C`.`PARENT_ID` = `B0`.`ID`
Now if I completely remove the reference to "children" in Parent, the SQL
is exactly what I need:
SELECT 'com.*.Child' AS NUCLEUS_TYPE,`C`.`ID`,`B0`.`ID`,`B0`.`TITLE` FROM
`CHILD` `C` INNER JOIN `PARENT` `B0` ON `C`.`PARENT_ID` = `B0`.`ID`
To be clear: what I'm trying to achieve is to fetch the child's parent
with my JPQL query.
I'm a beginner to the JPA/JPQL stuff and I'm having problems fetching
many-to-one relationships when I make the relationship bi-directional.
Here is the JPQL:
select c from Child c join fetch c.parent
Here are the two simple classes:
@Entity
public class Parent {
@Id
private int id;
private String title;
@OneToMany(mappedBy = "parent")
private Set<Child> children;
}
@Entity
public class Child {
@Id
private int id;
@ManyToOne(fetch = FetchType.LAZY)
private Parent parent;
}
The equivalent SQL query executed by datanucleus is:
SELECT 'com.*.Child' AS NUCLEUS_TYPE,`C`.`ID`,`C`.`PARENT_ID` FROM `CHILD`
`C` INNER JOIN `PARENT` `B0` ON `C`.`PARENT_ID` = `B0`.`ID`
Now if I completely remove the reference to "children" in Parent, the SQL
is exactly what I need:
SELECT 'com.*.Child' AS NUCLEUS_TYPE,`C`.`ID`,`B0`.`ID`,`B0`.`TITLE` FROM
`CHILD` `C` INNER JOIN `PARENT` `B0` ON `C`.`PARENT_ID` = `B0`.`ID`
To be clear: what I'm trying to achieve is to fetch the child's parent
with my JPQL query.
Check duplicate data in CodeIgniter try to make a callback function
Check duplicate data in CodeIgniter try to make a callback function
I have a registration form. Here I'm able to check duplicate email by my
custom is unique call back function (Don't try to use is_unique). But it
doesn't returns anything. Here is my code.
Controller -
public function add_member () {
$this->load->library('form_validation');
$post_email = $this->input->post('email_id');
$this->form_validation->set_rules('email_id', 'Email ID',
'required|trim|xss_clean|valid_email|callback_check_duplicate_email['
. $post_email . ']');
$this->form_validation->set_message('check_duplicate_email', 'This
email is already exist. Please write a new email.');
if ($this->form_validation->run() == FALSE) {
// validation failed then do that
$this->load->view('member/reg_form');
} else {
$data['email_id'] = $post_email;
$insert = $this->Con_member->insert_data_to_db($data);
if ($insert) {
$success = "Wao ! You are successfully added to our community.";
$this->session->set_flashdata('message_success', $success);
$this->load->view('member/success_page');
} else {
$error = "Hey this email is already exists in our community.";
$this->session->set_flashdata('message_error', $error);
$this->load->view('member/reg_form');
}
}
}
public function check_duplicate_email($post_email) {
return $this->Model_member->checkDuplicateEmail($post_email);
}
Model -
public function checkDuplicateEmail($post_email) {
$this->db->where('email_id', $email_id);
$query = $this->db->get('my_registration_table');
$count_row = $query->num_rows();
if ($count_row > 0) {
return TRUE;
} else {
return FALSE;
}
}
When I try to submit form with email which is already exists. This
function doesn't stop me and doesn't show the validation error message.
Would anyone here to see what's the problem? Waiting for your help.
Thanks.
I have a registration form. Here I'm able to check duplicate email by my
custom is unique call back function (Don't try to use is_unique). But it
doesn't returns anything. Here is my code.
Controller -
public function add_member () {
$this->load->library('form_validation');
$post_email = $this->input->post('email_id');
$this->form_validation->set_rules('email_id', 'Email ID',
'required|trim|xss_clean|valid_email|callback_check_duplicate_email['
. $post_email . ']');
$this->form_validation->set_message('check_duplicate_email', 'This
email is already exist. Please write a new email.');
if ($this->form_validation->run() == FALSE) {
// validation failed then do that
$this->load->view('member/reg_form');
} else {
$data['email_id'] = $post_email;
$insert = $this->Con_member->insert_data_to_db($data);
if ($insert) {
$success = "Wao ! You are successfully added to our community.";
$this->session->set_flashdata('message_success', $success);
$this->load->view('member/success_page');
} else {
$error = "Hey this email is already exists in our community.";
$this->session->set_flashdata('message_error', $error);
$this->load->view('member/reg_form');
}
}
}
public function check_duplicate_email($post_email) {
return $this->Model_member->checkDuplicateEmail($post_email);
}
Model -
public function checkDuplicateEmail($post_email) {
$this->db->where('email_id', $email_id);
$query = $this->db->get('my_registration_table');
$count_row = $query->num_rows();
if ($count_row > 0) {
return TRUE;
} else {
return FALSE;
}
}
When I try to submit form with email which is already exists. This
function doesn't stop me and doesn't show the validation error message.
Would anyone here to see what's the problem? Waiting for your help.
Thanks.
Assistance understanding Functional Dependencies & Anomalies?
Assistance understanding Functional Dependencies & Anomalies?
I'm working through an old Database book of mine to get a better grasp on
Database concepts. I read through a chapter on Functional Dependencies and
how to normalize the database (a couple times...) but one of the chapter
review questions has me particularly stumped:
Consider the relation: PERSON_2 (Name, Sibling, ShoeSize, Hobby)
Assume that the following functional dependencies exist:
`Name->->Sibling`
`Name->ShoeSize`
`Name->->Hobby`
Describe deletion, modification, and insertion anomalies for the relation.
My thinking goes along like this:
INSERTION: ???
MODIFICATION: Since 'Name' has not been shown as a Primary Key, if you
modified records where 'Name' = 'John' and you had 2 or more Johns in the
table (thinking older times with large families) then each one would then
be modified.
DELETION: Same as Modification?
I seem to be having a lot of difficulty wrapping my head around this kind
of thinking and understanding the idea. Could anyone be of assistance?
I'm working through an old Database book of mine to get a better grasp on
Database concepts. I read through a chapter on Functional Dependencies and
how to normalize the database (a couple times...) but one of the chapter
review questions has me particularly stumped:
Consider the relation: PERSON_2 (Name, Sibling, ShoeSize, Hobby)
Assume that the following functional dependencies exist:
`Name->->Sibling`
`Name->ShoeSize`
`Name->->Hobby`
Describe deletion, modification, and insertion anomalies for the relation.
My thinking goes along like this:
INSERTION: ???
MODIFICATION: Since 'Name' has not been shown as a Primary Key, if you
modified records where 'Name' = 'John' and you had 2 or more Johns in the
table (thinking older times with large families) then each one would then
be modified.
DELETION: Same as Modification?
I seem to be having a lot of difficulty wrapping my head around this kind
of thinking and understanding the idea. Could anyone be of assistance?
Why does Apps Main Activity not take new values of variables after they are changed when the activity starts?
Why does Apps Main Activity not take new values of variables after they
are changed when the activity starts?
Hi does anyone know why even though Ive created methods which change some
co-ordinate values (which are executed before my main method). My Main
method is still taking the default values i gave my co-ordinate variables
at the start of the Activity?
Here is my code:
For the first Activity Shown on the App (Start Activity) which allows you
to change the lat and long co-ordinates by typing in an alert dialog, as
well as starting up the main Map Activity:
public class StartViewActivity extends Activity {
MainActivity longlat = new MainActivity();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.startview);
Button button = (Button) findViewById(R.id.button1);
Button button1 = (Button) findViewById(R.id.button2);
Button button2 = (Button) findViewById(R.id.button3);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
AlertDialog.Builder alert = new
AlertDialog.Builder(StartViewActivity.this);
alert.setTitle("Longitude");
alert.setMessage("Input Longitude");
final EditText input = new EditText(StartViewActivity.this);
alert.setView(input);
alert.setPositiveButton( "Continue..", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
String lng1 = input.getText().toString();
longlat.lngSetter(lng1);
}
});
alert.show();
}
});
button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
AlertDialog.Builder alert = new
AlertDialog.Builder(StartViewActivity.this);
alert.setTitle("Latitude");
alert.setMessage("Input Latitude");
final EditText input = new EditText(StartViewActivity.this);
alert.setView(input);
alert.setPositiveButton( "Continue..", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int
which) {
String lat1 = input.getText().toString();
longlat.latSetter(lat1);
}
});
alert.show();
}});
button2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new
Intent(StartViewActivity.this,MainActivity.class);
startActivity(intent);
}});
}}
This is the code from my Main Activity, which also contains the methods
called in the Start Activity that should change my lat and lng values (but
takes the original lat and lng values every time the Activity starts) :
package com.example.workinggooglemaps;
import java.util.Random;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.PolylineOptions;
public class MainActivity extends Activity {
double[] tokens = new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31 };
private double lat = 50.597636;
private double lng = -2.447766;
private GoogleMap theMap;
private Random number = new Random();
private int counter = 0;
public void lngSetter(String f){
lng = Double.parseDouble(f);
System.out.println(lng);
}
public void latSetter(String g){
lat = Double.parseDouble(g);
System.out.println(lat);
}
public void polyLineDrawer() {
theMap.addPolyline(new PolylineOptions()
.add(new LatLng(tokens[0], tokens[1]))
.add(new LatLng(tokens[2], tokens[3]))
.add(new LatLng(tokens[4], tokens[5]))
.add(new LatLng(tokens[6], tokens[7]))
.add(new LatLng(tokens[8], tokens[9]))
.add(new LatLng(tokens[10], tokens[11]))
.add(new LatLng(tokens[12], tokens[13]))
.add(new LatLng(tokens[14], tokens[15]))
.add(new LatLng(tokens[16], tokens[17]))
.add(new LatLng(tokens[18], tokens[19]))
.add(new LatLng(tokens[20], tokens[21]))
.add(new LatLng(tokens[22], tokens[23]))
.add(new LatLng(tokens[24], tokens[25]))
.add(new LatLng(tokens[26], tokens[27]))
.add(new LatLng(tokens[28], tokens[29])).width(3)
.color(0xffff0000).zIndex(0));
}
public void Drawer() {
for (; counter < 30; counter = counter + 2)
tokens[0] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[1] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[2] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[3] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[4] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[5] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[6] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[7] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[8] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[9] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[10] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[11] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[12] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[13] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[14] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[15] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[16] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[17] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[18] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[19] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[20] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[21] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[22] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[23] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[24] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[25] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[26] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[27] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[28] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[29] = (((number.nextDouble()) / 250) + lng) - 0.002;
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (theMap == null) {
theMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.the_map)).getMap();
}
if (theMap != null) {
}
LatLng co_ords = new LatLng(lat, lng);
theMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
theMap.addCircle(new CircleOptions().center(co_ords).radius(200)
.strokeWidth(3).zIndex(1));
theMap.addCircle(new CircleOptions().center(co_ords).radius(150)
.strokeWidth(3).zIndex(1));
theMap.addCircle(new CircleOptions().center(co_ords).radius(100)
.strokeWidth(3).zIndex(1));
theMap.addCircle(new CircleOptions().center(co_ords).radius(50)
.strokeWidth(3).zIndex(1));
theMap.addMarker(new MarkerOptions().position(co_ords)
.title("Cerberus"));
theMap.animateCamera(CameraUpdateFactory.newLatLngZoom(co_ords, 17));
Drawer();
polyLineDrawer();
}
@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;
}
}
I'm not sure if it will matter but ill include my Manifest file and my XML
files for both activities as well:
Here is my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.workinggooglemaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<permission
android:name="com.example.workinggooglemaps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission
android:name="com.example.workinggooglemaps.permission.MAPS_RECEIVE"
/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"
/>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.workinggooglemaps.StartViewActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.workinggooglemaps.MainActivity"
android:label="@string/app_name" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAgtM2ZtsmEveqylJDvNkosyxAdLu2j_rc" />
</application>
</manifest>
Here is my Start Activity 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" >
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_alignRight="@+id/button1"
android:layout_below="@+id/button1"
android:text="Set Latitude" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="72dp"
android:text="Set Longitude" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/button2"
android:layout_marginBottom="83dp"
android:text="Show on Map" />
</RelativeLayout>
Finally here is my Main Activity XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/the_map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.49" />
</LinearLayout>
Here is my Main Activity XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/the_map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.49" />
</LinearLayout>
Any help would be greatly appreciated :)
are changed when the activity starts?
Hi does anyone know why even though Ive created methods which change some
co-ordinate values (which are executed before my main method). My Main
method is still taking the default values i gave my co-ordinate variables
at the start of the Activity?
Here is my code:
For the first Activity Shown on the App (Start Activity) which allows you
to change the lat and long co-ordinates by typing in an alert dialog, as
well as starting up the main Map Activity:
public class StartViewActivity extends Activity {
MainActivity longlat = new MainActivity();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.startview);
Button button = (Button) findViewById(R.id.button1);
Button button1 = (Button) findViewById(R.id.button2);
Button button2 = (Button) findViewById(R.id.button3);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
AlertDialog.Builder alert = new
AlertDialog.Builder(StartViewActivity.this);
alert.setTitle("Longitude");
alert.setMessage("Input Longitude");
final EditText input = new EditText(StartViewActivity.this);
alert.setView(input);
alert.setPositiveButton( "Continue..", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
String lng1 = input.getText().toString();
longlat.lngSetter(lng1);
}
});
alert.show();
}
});
button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
AlertDialog.Builder alert = new
AlertDialog.Builder(StartViewActivity.this);
alert.setTitle("Latitude");
alert.setMessage("Input Latitude");
final EditText input = new EditText(StartViewActivity.this);
alert.setView(input);
alert.setPositiveButton( "Continue..", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int
which) {
String lat1 = input.getText().toString();
longlat.latSetter(lat1);
}
});
alert.show();
}});
button2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new
Intent(StartViewActivity.this,MainActivity.class);
startActivity(intent);
}});
}}
This is the code from my Main Activity, which also contains the methods
called in the Start Activity that should change my lat and lng values (but
takes the original lat and lng values every time the Activity starts) :
package com.example.workinggooglemaps;
import java.util.Random;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.PolylineOptions;
public class MainActivity extends Activity {
double[] tokens = new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31 };
private double lat = 50.597636;
private double lng = -2.447766;
private GoogleMap theMap;
private Random number = new Random();
private int counter = 0;
public void lngSetter(String f){
lng = Double.parseDouble(f);
System.out.println(lng);
}
public void latSetter(String g){
lat = Double.parseDouble(g);
System.out.println(lat);
}
public void polyLineDrawer() {
theMap.addPolyline(new PolylineOptions()
.add(new LatLng(tokens[0], tokens[1]))
.add(new LatLng(tokens[2], tokens[3]))
.add(new LatLng(tokens[4], tokens[5]))
.add(new LatLng(tokens[6], tokens[7]))
.add(new LatLng(tokens[8], tokens[9]))
.add(new LatLng(tokens[10], tokens[11]))
.add(new LatLng(tokens[12], tokens[13]))
.add(new LatLng(tokens[14], tokens[15]))
.add(new LatLng(tokens[16], tokens[17]))
.add(new LatLng(tokens[18], tokens[19]))
.add(new LatLng(tokens[20], tokens[21]))
.add(new LatLng(tokens[22], tokens[23]))
.add(new LatLng(tokens[24], tokens[25]))
.add(new LatLng(tokens[26], tokens[27]))
.add(new LatLng(tokens[28], tokens[29])).width(3)
.color(0xffff0000).zIndex(0));
}
public void Drawer() {
for (; counter < 30; counter = counter + 2)
tokens[0] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[1] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[2] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[3] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[4] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[5] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[6] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[7] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[8] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[9] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[10] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[11] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[12] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[13] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[14] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[15] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[16] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[17] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[18] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[19] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[20] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[21] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[22] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[23] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[24] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[25] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[26] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[27] = (((number.nextDouble()) / 250) + lng) - 0.002;
tokens[28] = (((number.nextDouble()) / 250) + lat) - 0.002;
tokens[29] = (((number.nextDouble()) / 250) + lng) - 0.002;
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (theMap == null) {
theMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.the_map)).getMap();
}
if (theMap != null) {
}
LatLng co_ords = new LatLng(lat, lng);
theMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
theMap.addCircle(new CircleOptions().center(co_ords).radius(200)
.strokeWidth(3).zIndex(1));
theMap.addCircle(new CircleOptions().center(co_ords).radius(150)
.strokeWidth(3).zIndex(1));
theMap.addCircle(new CircleOptions().center(co_ords).radius(100)
.strokeWidth(3).zIndex(1));
theMap.addCircle(new CircleOptions().center(co_ords).radius(50)
.strokeWidth(3).zIndex(1));
theMap.addMarker(new MarkerOptions().position(co_ords)
.title("Cerberus"));
theMap.animateCamera(CameraUpdateFactory.newLatLngZoom(co_ords, 17));
Drawer();
polyLineDrawer();
}
@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;
}
}
I'm not sure if it will matter but ill include my Manifest file and my XML
files for both activities as well:
Here is my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.workinggooglemaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<permission
android:name="com.example.workinggooglemaps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission
android:name="com.example.workinggooglemaps.permission.MAPS_RECEIVE"
/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"
/>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.workinggooglemaps.StartViewActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.workinggooglemaps.MainActivity"
android:label="@string/app_name" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAgtM2ZtsmEveqylJDvNkosyxAdLu2j_rc" />
</application>
</manifest>
Here is my Start Activity 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" >
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_alignRight="@+id/button1"
android:layout_below="@+id/button1"
android:text="Set Latitude" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="72dp"
android:text="Set Longitude" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/button2"
android:layout_marginBottom="83dp"
android:text="Show on Map" />
</RelativeLayout>
Finally here is my Main Activity XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/the_map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.49" />
</LinearLayout>
Here is my Main Activity XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/the_map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.49" />
</LinearLayout>
Any help would be greatly appreciated :)
What is the fastest possible shutter speed=?iso-8859-1?Q?=3F_=96_photo.stackexchange.com?=
What is the fastest possible shutter speed? – photo.stackexchange.com
Is there a theoretical maximum at which a shutter cannot go faster (aside
from the speed of light :-))? Is there a camera which has the fastest
shutter speed? What is the advantage of this?
Is there a theoretical maximum at which a shutter cannot go faster (aside
from the speed of light :-))? Is there a camera which has the fastest
shutter speed? What is the advantage of this?
Tuesday, 27 August 2013
HTML5 validation and modal window - can't get them to work together [on hold]
HTML5 validation and modal window - can't get them to work together [on hold]
I have a simple form, and lean.Modal jQuery script for displaying form in
pop-up window. Now I need to apply validation in this form. The problem
is: if I enable html5 validation like this:
<input type="text" id="first_name" class="txtfield" required
x-moz-errormessage="Please enter your name here" >
when I press "Submit" without filling any data in form, modal window
closed and no data send because (as I think) form has validation errors.
Without validation when I press submit all data are send successfully and
modal window closed (Submit button are the closed button too).
If I disable closed button (remove modal_close html class from button)
validation works fine and data are send, but now I can't close modal
window at all.
Full form:
<div id="loginmodal-2" style="display:none;">
<h1>Simple form</h1>
<form id="loginform-2" >
<label for="first_name">Name: * </label>
<input type="text" name="first_name" id="first_name"
class="txtfield" required x-moz-errormessage="Please enter your name
here" tabindex="10">
<label for="telephone">Phone: * </label>
<input type="text" name="telephone" id="telephone" class="txtfield"
tabindex="20">
<div class="center"><input type="submit" id="loginbtn"
class="hidemodal-2" value="Submit" tabindex="30"></div>
</form>
</div>
And modal:
<script type="text/javascript">
$(function(){
$('#modaltrigger-2').leanModal({ top: 50, overlay: 0.45, closeButton:
".hidemodal-2" });
});
</script>
Lean.Modal script: http://pastebin.com/9JT04nZi
Realy need some help. Thank you in advance. :o)
I have a simple form, and lean.Modal jQuery script for displaying form in
pop-up window. Now I need to apply validation in this form. The problem
is: if I enable html5 validation like this:
<input type="text" id="first_name" class="txtfield" required
x-moz-errormessage="Please enter your name here" >
when I press "Submit" without filling any data in form, modal window
closed and no data send because (as I think) form has validation errors.
Without validation when I press submit all data are send successfully and
modal window closed (Submit button are the closed button too).
If I disable closed button (remove modal_close html class from button)
validation works fine and data are send, but now I can't close modal
window at all.
Full form:
<div id="loginmodal-2" style="display:none;">
<h1>Simple form</h1>
<form id="loginform-2" >
<label for="first_name">Name: * </label>
<input type="text" name="first_name" id="first_name"
class="txtfield" required x-moz-errormessage="Please enter your name
here" tabindex="10">
<label for="telephone">Phone: * </label>
<input type="text" name="telephone" id="telephone" class="txtfield"
tabindex="20">
<div class="center"><input type="submit" id="loginbtn"
class="hidemodal-2" value="Submit" tabindex="30"></div>
</form>
</div>
And modal:
<script type="text/javascript">
$(function(){
$('#modaltrigger-2').leanModal({ top: 50, overlay: 0.45, closeButton:
".hidemodal-2" });
});
</script>
Lean.Modal script: http://pastebin.com/9JT04nZi
Realy need some help. Thank you in advance. :o)
Making a simple line graph with NO core plot
Making a simple line graph with NO core plot
I need to make a line graph in my application to track data. I looked at
core plot, and it seems WAY to complicated. Is there a simpler way to just
make a line graph that can move horizontally and it will need to be able
to add new segments. And not cause a huge memory overload because a lot
will be added frequently, tho I could make it so they delete after a moth
or something. So my question is basically : is there a easier method than
core plot, and if Someone can lead me in the direction of being able to
add more segments with custom data. Thanks in advance.
I need to make a line graph in my application to track data. I looked at
core plot, and it seems WAY to complicated. Is there a simpler way to just
make a line graph that can move horizontally and it will need to be able
to add new segments. And not cause a huge memory overload because a lot
will be added frequently, tho I could make it so they delete after a moth
or something. So my question is basically : is there a easier method than
core plot, and if Someone can lead me in the direction of being able to
add more segments with custom data. Thanks in advance.
Select only the second child of an element with CSS
Select only the second child of an element with CSS
I have something like this:
<div id="someID">
<div class="text">
-----other html tags
</div>
<div class="text">
-----other html tags
</div>
<div class="text">
-----other html tags
</div>
</div>
And some CSS for the text div. It is possible to set different CSS for the
second div with the class of text?
I have something like this:
<div id="someID">
<div class="text">
-----other html tags
</div>
<div class="text">
-----other html tags
</div>
<div class="text">
-----other html tags
</div>
</div>
And some CSS for the text div. It is possible to set different CSS for the
second div with the class of text?
How to refresh the screen continuously and update it in real time stackoverflow.com
How to refresh the screen continuously and update it in real time –
stackoverflow.com
I want to make a C program which refreshes the screen continuously and
updates it in real time (for example, similar to the top command in the
terminal). Can anyone point me in the right direction.
stackoverflow.com
I want to make a C program which refreshes the screen continuously and
updates it in real time (for example, similar to the top command in the
terminal). Can anyone point me in the right direction.
Monday, 26 August 2013
Querying a database via a constructor
Querying a database via a constructor
I'm trying create a database query class that I can re-use to search or
display items from the database.
I'd like to be able to pass the query specifications via a constructor.
However, I'm gettin this error:
run:
Connecting to a selected database...
Connected database successfully...
Creating statement...
org.h2.jdbc.JdbcSQLException: Data conversion error converting ; SQL
statement:
This is my code so far:
import java.sql.*;
public class RsToAList {
private final String table;
private final String columns;
private final String whereColumn;
private final String equalsEntry;
public RsToAList (String columns, String table, String whereColumn,
String equalsEntry) {
this.table = table;
this.columns = columns;
this.whereColumn = whereColumn;
this.equalsEntry = equalsEntry;
}
// JDBC driver name and database URL
static String JDBC_DRIVER = "org.h2.Driver";
static String DB_URL = "jdbc:h2:file:C:/tryDb/tryDb";
// Database credentials
static String USER = "sa";
static String PASS = "";
public static void main (String[] args) {
RsToAList tryAndGet = new RsToAList("fullNames", "CLIENT",
"postOfficeBoxNumber", "6448");
tryAndGet.ourQuerryMethod();
}
public void ourQuerryMethod () {
Connection conn = null;
Statement stmt = null;
try {
// STEP 2: Register JDBC driver
Class.forName(getJDBC_DRIVER());
// STEP 3: Open a connection
System.out.println("Connecting to a selected database...");
conn = DriverManager.getConnection(getDB_URL(), getUSER(),
getPASS());
System.out.println("Connected database successfully...");
// STEP 4: Execute a query
System.out.println("Creating statement...");
stmt = conn.createStatement();
String sql = "SELECT " + (columns) + " FROM " + (table) + "
WHERE "+ (whereColumn) +" = "+ (equalsEntry) +"";
ResultSet rs = stmt.executeQuery(sql);
//STEP 5: Extract data from result set
while (rs.next()) {
// Retrieve by column name
String first = rs.getString(columns);
// Display values
System.out.print("ID: " + first);
}
rs.close();
} catch (SQLException se) {
// Handle errors for JDBC
se.printStackTrace();
} catch (Exception e) {
// Handle errors for Class.forName
e.printStackTrace();
} finally {
// finally block used to close resources
try {
if (stmt != null)
conn.close();
} catch (SQLException se) {
} // do nothing
try {
if (conn != null)
conn.close();
} catch (SQLException se) {
se.printStackTrace();
} // end finally try
} // end try
System.out.println("Goodbye!");
} // end main
/**
* @return the JDBC_DRIVER
*/
public static String getJDBC_DRIVER() {
return JDBC_DRIVER;
}
/**
* @param aJDBC_DRIVER the JDBC_DRIVER to set
*/
public static void setJDBC_DRIVER(String aJDBC_DRIVER) {
JDBC_DRIVER = aJDBC_DRIVER;
}
/**
* @return the DB_URL
*/
public static String getDB_URL() {
return DB_URL;
}
/**
* @param aDB_URL the DB_URL to set
*/
public static void setDB_URL(String aDB_URL) {
DB_URL = aDB_URL;
}
/**
* @return the USER
*/
public static String getUSER() {
return USER;
}
/**
* @param aUSER the USER to set
*/
public static void setUSER(String aUSER) {
USER = aUSER;
}
/**
* @return the PASS
*/
public static String getPASS() {
return PASS;
}
/**
* @param aPASS the PASS to set
*/
public static void setPASS(String aPASS) {
PASS = aPASS;
}
}
I'm trying create a database query class that I can re-use to search or
display items from the database.
I'd like to be able to pass the query specifications via a constructor.
However, I'm gettin this error:
run:
Connecting to a selected database...
Connected database successfully...
Creating statement...
org.h2.jdbc.JdbcSQLException: Data conversion error converting ; SQL
statement:
This is my code so far:
import java.sql.*;
public class RsToAList {
private final String table;
private final String columns;
private final String whereColumn;
private final String equalsEntry;
public RsToAList (String columns, String table, String whereColumn,
String equalsEntry) {
this.table = table;
this.columns = columns;
this.whereColumn = whereColumn;
this.equalsEntry = equalsEntry;
}
// JDBC driver name and database URL
static String JDBC_DRIVER = "org.h2.Driver";
static String DB_URL = "jdbc:h2:file:C:/tryDb/tryDb";
// Database credentials
static String USER = "sa";
static String PASS = "";
public static void main (String[] args) {
RsToAList tryAndGet = new RsToAList("fullNames", "CLIENT",
"postOfficeBoxNumber", "6448");
tryAndGet.ourQuerryMethod();
}
public void ourQuerryMethod () {
Connection conn = null;
Statement stmt = null;
try {
// STEP 2: Register JDBC driver
Class.forName(getJDBC_DRIVER());
// STEP 3: Open a connection
System.out.println("Connecting to a selected database...");
conn = DriverManager.getConnection(getDB_URL(), getUSER(),
getPASS());
System.out.println("Connected database successfully...");
// STEP 4: Execute a query
System.out.println("Creating statement...");
stmt = conn.createStatement();
String sql = "SELECT " + (columns) + " FROM " + (table) + "
WHERE "+ (whereColumn) +" = "+ (equalsEntry) +"";
ResultSet rs = stmt.executeQuery(sql);
//STEP 5: Extract data from result set
while (rs.next()) {
// Retrieve by column name
String first = rs.getString(columns);
// Display values
System.out.print("ID: " + first);
}
rs.close();
} catch (SQLException se) {
// Handle errors for JDBC
se.printStackTrace();
} catch (Exception e) {
// Handle errors for Class.forName
e.printStackTrace();
} finally {
// finally block used to close resources
try {
if (stmt != null)
conn.close();
} catch (SQLException se) {
} // do nothing
try {
if (conn != null)
conn.close();
} catch (SQLException se) {
se.printStackTrace();
} // end finally try
} // end try
System.out.println("Goodbye!");
} // end main
/**
* @return the JDBC_DRIVER
*/
public static String getJDBC_DRIVER() {
return JDBC_DRIVER;
}
/**
* @param aJDBC_DRIVER the JDBC_DRIVER to set
*/
public static void setJDBC_DRIVER(String aJDBC_DRIVER) {
JDBC_DRIVER = aJDBC_DRIVER;
}
/**
* @return the DB_URL
*/
public static String getDB_URL() {
return DB_URL;
}
/**
* @param aDB_URL the DB_URL to set
*/
public static void setDB_URL(String aDB_URL) {
DB_URL = aDB_URL;
}
/**
* @return the USER
*/
public static String getUSER() {
return USER;
}
/**
* @param aUSER the USER to set
*/
public static void setUSER(String aUSER) {
USER = aUSER;
}
/**
* @return the PASS
*/
public static String getPASS() {
return PASS;
}
/**
* @param aPASS the PASS to set
*/
public static void setPASS(String aPASS) {
PASS = aPASS;
}
}
Unable to open any applications or shut down
Unable to open any applications or shut down
I'm using Ubuntu 12.04 LTS.
Recently, I've been having a problem where everything will be functioning
normally, and then I get the same string of problems:
1.) I can't open any new applications, or at least not by clicking on one
in my sidebar.
2.) I can go to the dropdown where I can select 'Shut Down' but I click on
it and nothing happens.
3.) Sometimes before everything stops functioning normally, I will go to
shut down and it will stall in the full screen terminal like thing which
it usually passes through when shutting down.
4.) In both cases 2 and 3, I am forced to resort to just powering off by
holding down power button.
I'm using Ubuntu 12.04 LTS.
Recently, I've been having a problem where everything will be functioning
normally, and then I get the same string of problems:
1.) I can't open any new applications, or at least not by clicking on one
in my sidebar.
2.) I can go to the dropdown where I can select 'Shut Down' but I click on
it and nothing happens.
3.) Sometimes before everything stops functioning normally, I will go to
shut down and it will stall in the full screen terminal like thing which
it usually passes through when shutting down.
4.) In both cases 2 and 3, I am forced to resort to just powering off by
holding down power button.
How to secure paypals purchase forms
How to secure paypals purchase forms
I'm trying to help someone with a problem, where you can donate for some
points, but you the source code will allow you to edit the values of the
paypal button. For instance, i choose 5 points which should cost 5 dollar,
but when I edit source code I can see the whole paypal form with values,
and edit the values. So how can I secure the form so that it cannot be
edited?
Here's the code:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="at"
value="nBWAy2wwJn1O1LdoLcMn8AOdPxBBUxhnZfqFvAlGQq1oDm0czxn5FBcpgIW">
<input type="hidden" name="business" value="admin@worldofthegods.com">
<input type="hidden" name="item_name" value="DP|1|452160">
<input type="hidden" name="amount" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return"
value="http://www.worldofthegods.com/donate.php?action=done">
<input type="hidden" name="cancel_return"
value="http://www.worldofthegods.com/donate.php?action=cancel">
<input type="hidden" name="notify_url"
value="http://www.worldofthegods.com/ipn_donator.php">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="tax" value="0">
<input type="image"
src="http://worldofthegods.com/images/PaypalButton.gif" border="0"
name="submit" alt="Make payments with PayPal - it's fast, free and
secure!">
</form>
I'm trying to help someone with a problem, where you can donate for some
points, but you the source code will allow you to edit the values of the
paypal button. For instance, i choose 5 points which should cost 5 dollar,
but when I edit source code I can see the whole paypal form with values,
and edit the values. So how can I secure the form so that it cannot be
edited?
Here's the code:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="at"
value="nBWAy2wwJn1O1LdoLcMn8AOdPxBBUxhnZfqFvAlGQq1oDm0czxn5FBcpgIW">
<input type="hidden" name="business" value="admin@worldofthegods.com">
<input type="hidden" name="item_name" value="DP|1|452160">
<input type="hidden" name="amount" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return"
value="http://www.worldofthegods.com/donate.php?action=done">
<input type="hidden" name="cancel_return"
value="http://www.worldofthegods.com/donate.php?action=cancel">
<input type="hidden" name="notify_url"
value="http://www.worldofthegods.com/ipn_donator.php">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="tax" value="0">
<input type="image"
src="http://worldofthegods.com/images/PaypalButton.gif" border="0"
name="submit" alt="Make payments with PayPal - it's fast, free and
secure!">
</form>
node.js timezone independant Date.now()
node.js timezone independant Date.now()
What is a common way to sync timeStamps across servers and clients in
node.js, not dependant on timezone?
e.g., a Date.now() equivalent that would provide the same time on the
server and client. Preferably without any node.js modules, or client side
libraries.
What is a common way to sync timeStamps across servers and clients in
node.js, not dependant on timezone?
e.g., a Date.now() equivalent that would provide the same time on the
server and client. Preferably without any node.js modules, or client side
libraries.
Error bars disappear Qtiplot Ubuntu 12.04
Error bars disappear Qtiplot Ubuntu 12.04
I faced this problem while using QtiPlot in Ubuntu 12.04 (WUBI) and could
not find any help on google search. I have created a very nice plot with
QtiPlot which included error bars both for x and y values. The tricky part
comes now: if I save the file as is at this moment and I load it on a
later session it opens as I created, but if I edit the error bar
properties such as the linewidth and color (and save of course) when I
load it on a later session it loads without any errorbar.
Does anybody has faced or knows the solution for this problem?
Regards
I faced this problem while using QtiPlot in Ubuntu 12.04 (WUBI) and could
not find any help on google search. I have created a very nice plot with
QtiPlot which included error bars both for x and y values. The tricky part
comes now: if I save the file as is at this moment and I load it on a
later session it opens as I created, but if I edit the error bar
properties such as the linewidth and color (and save of course) when I
load it on a later session it loads without any errorbar.
Does anybody has faced or knows the solution for this problem?
Regards
Remove item in ArrayAdapter in ListView
Remove item in ArrayAdapter in ListView
I would like to delete a clicked item in ListView.
Here is my code:
View mView = inflater.inflate(R.layout.fragment_dialog, null);
ListView mListView = (ListView) mView.findViewById(R.id.lvListe);
String[] mValues = {"Orientation", "Nombre de Chambres", "Nombre de
Salle de bains", "Nombre de toilettes", "Cave", "Parking", "Garage",
"Jardin"};
final ArrayAdapter<String> adapter = new
ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1, mValues);
mListView.setAdapter(adapter);
mListView.setOnItemClickListener(new
android.widget.AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int
position, long id) {
String item = (String) parent.getItemAtPosition(position);
adapter.remove(adapter.getItem(position));
adapter.notifyDataSetChanged();
Toast.makeText(getActivity(), "You selected : " + item,
Toast.LENGTH_SHORT).show();
}
});
builder.setView(mListView);
return builder.create();
But adapter.remove() makes the application crash with this error:
java.lang.UnsupportedOperationException
What should I do if I want remove an item ?
Thanks in advance :)
I would like to delete a clicked item in ListView.
Here is my code:
View mView = inflater.inflate(R.layout.fragment_dialog, null);
ListView mListView = (ListView) mView.findViewById(R.id.lvListe);
String[] mValues = {"Orientation", "Nombre de Chambres", "Nombre de
Salle de bains", "Nombre de toilettes", "Cave", "Parking", "Garage",
"Jardin"};
final ArrayAdapter<String> adapter = new
ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1, mValues);
mListView.setAdapter(adapter);
mListView.setOnItemClickListener(new
android.widget.AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int
position, long id) {
String item = (String) parent.getItemAtPosition(position);
adapter.remove(adapter.getItem(position));
adapter.notifyDataSetChanged();
Toast.makeText(getActivity(), "You selected : " + item,
Toast.LENGTH_SHORT).show();
}
});
builder.setView(mListView);
return builder.create();
But adapter.remove() makes the application crash with this error:
java.lang.UnsupportedOperationException
What should I do if I want remove an item ?
Thanks in advance :)
On scroll change opacity of header?
On scroll change opacity of header?
Im so new to JQuery and im sure the answer is super basic. But if someone
can point me in the right direction that would be great. I just want the
opacity of my header to change from 0 to 1 as the user scrolls past 400
pixels. HELP? www.HULU.com has a perfect example.
<code>
<script>
$(document).ready(function() {
$(window).scroll(function() {
if ($(this).scrollTop() > 400) {
$('.header').css("background", "#000");
} else {
$('.header').css("background", "transparent");
}
});
});
</script>
</code>
Im so new to JQuery and im sure the answer is super basic. But if someone
can point me in the right direction that would be great. I just want the
opacity of my header to change from 0 to 1 as the user scrolls past 400
pixels. HELP? www.HULU.com has a perfect example.
<code>
<script>
$(document).ready(function() {
$(window).scroll(function() {
if ($(this).scrollTop() > 400) {
$('.header').css("background", "#000");
} else {
$('.header').css("background", "transparent");
}
});
});
</script>
</code>
parallel transportation on submanifold
parallel transportation on submanifold
$M$ is a Riemannian manifold, $N$ is a submanifold of $M$, not totally
geodesic. Given two points $p,q \in N$, let $\gamma_N$, $\gamma_M$ be the
geodesics connecting $p$, $q$ in $N$ and $M$, respectively. Let $\xi \in
{T_p}N$, $\xi $ orthogonal to ${{\dot \gamma }_N}(p)$. Is $\xi $
orthogonal to ${{\dot \gamma }_M}(p)$? Does the result of parallel
transportation of $\xi$ from $p$ to $q$ in $N$ coincide with that in $M$?
If not, please give counter-examples.
$M$ is a Riemannian manifold, $N$ is a submanifold of $M$, not totally
geodesic. Given two points $p,q \in N$, let $\gamma_N$, $\gamma_M$ be the
geodesics connecting $p$, $q$ in $N$ and $M$, respectively. Let $\xi \in
{T_p}N$, $\xi $ orthogonal to ${{\dot \gamma }_N}(p)$. Is $\xi $
orthogonal to ${{\dot \gamma }_M}(p)$? Does the result of parallel
transportation of $\xi$ from $p$ to $q$ in $N$ coincide with that in $M$?
If not, please give counter-examples.
Sunday, 25 August 2013
Dropdownlist using viewbag data in mvc4 using c#
Dropdownlist using viewbag data in mvc4 using c#
Hi i want to fill a dropdown list in my view page my code is
public class MemberBasicData
{
public int Id { get; set; }
public string Mem_NA { get; set; }
public string Mem_Occ { get; set; }
}
//controller
public ActionResult Register()
{
var users = new Member().GetAllMembers();
ViewBag.Users = users;
return View();
}
//View
@model IEnumerable<Puthencruz.Rotary.Members.Models.MemberBasicData>
@Html.DropDownListFor(model => model.Mem_Na, (SelectList)ViewBag.Users,
"--Select Users--")
i want to add Mem_NA to dropdownlist, Viewbag contains all the user
details. Problem is in View page. An error shows in model.Mem_Na. Please
help me to solve this.
Hi i want to fill a dropdown list in my view page my code is
public class MemberBasicData
{
public int Id { get; set; }
public string Mem_NA { get; set; }
public string Mem_Occ { get; set; }
}
//controller
public ActionResult Register()
{
var users = new Member().GetAllMembers();
ViewBag.Users = users;
return View();
}
//View
@model IEnumerable<Puthencruz.Rotary.Members.Models.MemberBasicData>
@Html.DropDownListFor(model => model.Mem_Na, (SelectList)ViewBag.Users,
"--Select Users--")
i want to add Mem_NA to dropdownlist, Viewbag contains all the user
details. Problem is in View page. An error shows in model.Mem_Na. Please
help me to solve this.
The Difference Between Extensible and Pluggable Applications
The Difference Between "Extensible" and "Pluggable" Applications
I misunderstand between "Extensible" and "Pluggable" terms . Can anyone
explain for me ?
I misunderstand between "Extensible" and "Pluggable" terms . Can anyone
explain for me ?
FTP help 12.04 Server
FTP help 12.04 Server
I am very new to Linux / Ubuntu so please excuse my ignorance.
I have installed ubuntu server 12.04. I have installed vsftpd. I have
edited vsftpd.conf and made sure I have uncommented local_enable &
write_enable are set to YES. The vsftpd service is running. Ports 20 & 21
have been allowed in ufw. I am able to ping to my router and also ping to
www.google.co.uk so as far as I am aware that means DNS is being resolved.
I can also log on via SSH with no problems at all (Not sure if that has
any relevance but thought I'd mention it)
What I can't do is connect using 'filezilla' , 'cuteFTP' etc. This is the
msg I get back from Filezilla
Status: Connecting to 192.168.0.2:21...
Status: Connection established, waiting for welcome message...
Response: 220 (vsFTPd 2.3.5)
Command: USER grant
Response: 331 Please specify the password.
Command: PASS *************
Error: Could not connect to serverAs I say I am very new at this so any
help would be much appreciated.
I am very new to Linux / Ubuntu so please excuse my ignorance.
I have installed ubuntu server 12.04. I have installed vsftpd. I have
edited vsftpd.conf and made sure I have uncommented local_enable &
write_enable are set to YES. The vsftpd service is running. Ports 20 & 21
have been allowed in ufw. I am able to ping to my router and also ping to
www.google.co.uk so as far as I am aware that means DNS is being resolved.
I can also log on via SSH with no problems at all (Not sure if that has
any relevance but thought I'd mention it)
What I can't do is connect using 'filezilla' , 'cuteFTP' etc. This is the
msg I get back from Filezilla
Status: Connecting to 192.168.0.2:21...
Status: Connection established, waiting for welcome message...
Response: 220 (vsFTPd 2.3.5)
Command: USER grant
Response: 331 Please specify the password.
Command: PASS *************
Error: Could not connect to serverAs I say I am very new at this so any
help would be much appreciated.
Code stop if 404 not found
Code stop if 404 not found
Hi I use the code below to check 5 url but if the ex: url no 3 is 404 not
found the code will stop from checking the 4th url, anyway I can do to
make the code run untill the url lists finished?
private void button2_Click(object sender, EventArgs e)
{
try
{
for (i = 0; i < listBox1.Items.Count; i++)
{
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create(listBox1.Items[i].ToString());
if (response.StatusCode == HttpStatusCode.OK)
{
listBox3.Items.Add(listBox1.Items[i].ToString());
}
}
}
catch (WebException x)
{
}
}
Hi I use the code below to check 5 url but if the ex: url no 3 is 404 not
found the code will stop from checking the 4th url, anyway I can do to
make the code run untill the url lists finished?
private void button2_Click(object sender, EventArgs e)
{
try
{
for (i = 0; i < listBox1.Items.Count; i++)
{
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create(listBox1.Items[i].ToString());
if (response.StatusCode == HttpStatusCode.OK)
{
listBox3.Items.Add(listBox1.Items[i].ToString());
}
}
}
catch (WebException x)
{
}
}
Saturday, 24 August 2013
Long code line wrapping in AUCTeX
Long code line wrapping in AUCTeX
I am writing slides in beamer with AUCTeX, I use visual line mode for
wrapping and it works fine for text. However, when I have long code for
example \includegraphics[height]{a long path and file name}, it doesn't
wrap properly and messes up the indentation (it basically makes a new line
pushes the code up against the wall). It doesn't affect the compiled
output but I would still like to know if there's a way to make it wrap
around properly.
I am writing slides in beamer with AUCTeX, I use visual line mode for
wrapping and it works fine for text. However, when I have long code for
example \includegraphics[height]{a long path and file name}, it doesn't
wrap properly and messes up the indentation (it basically makes a new line
pushes the code up against the wall). It doesn't affect the compiled
output but I would still like to know if there's a way to make it wrap
around properly.
Find CFG for Lisp-like expressions
Find CFG for Lisp-like expressions
All Lisp-like expressions.
A Lisp expression may be an unsigned integer or a list. A list, enclosed
by left and right parentheses, consists of one operator ($+$, $-$, $*$,
$/$, $\max$, $\min$) followed by a sequence of at least one Lisp
expression. For instance, $13$, $(- \;8)$, $(*\; 9\; 3)$, $(+\; (*\; 2\;
2)\; 4)$, and $(\min\; (\max\; 3\; 1\; 4) (\max\; 2\; 7\; 1))$ are Lisp
expressions.
This is my solution:
\begin{gather} S \to X \mid Y \\ X \to 0\text{–}9 X \mid \epsilon \\ Y \to
( E )\mid \epsilon \\ E \to +,-,*,/,\max,\min YX \end{gather}
All Lisp-like expressions.
A Lisp expression may be an unsigned integer or a list. A list, enclosed
by left and right parentheses, consists of one operator ($+$, $-$, $*$,
$/$, $\max$, $\min$) followed by a sequence of at least one Lisp
expression. For instance, $13$, $(- \;8)$, $(*\; 9\; 3)$, $(+\; (*\; 2\;
2)\; 4)$, and $(\min\; (\max\; 3\; 1\; 4) (\max\; 2\; 7\; 1))$ are Lisp
expressions.
This is my solution:
\begin{gather} S \to X \mid Y \\ X \to 0\text{–}9 X \mid \epsilon \\ Y \to
( E )\mid \epsilon \\ E \to +,-,*,/,\max,\min YX \end{gather}
Anti-Ghosting Keyboard Not Working
Anti-Ghosting Keyboard Not Working
I bought a Rosewill RK-8100 Keyboard, but it doesn't work with Ubuntu
13.04. The blue light turns on (so it is plugged in correctly), but key
presses do nothing. This keyboard works with Windows 8, but I obviously
can't use that OS for daily work.
I think it's because it's an anti-ghosting keyboard, but I'm not really sure.
Anyone know how to make it work, or perhaps disable the anti-ghosting
feature? I tried Ctrl + Shift + Alt + N, as a different thread suggested,
but that did nothing.
I bought a Rosewill RK-8100 Keyboard, but it doesn't work with Ubuntu
13.04. The blue light turns on (so it is plugged in correctly), but key
presses do nothing. This keyboard works with Windows 8, but I obviously
can't use that OS for daily work.
I think it's because it's an anti-ghosting keyboard, but I'm not really sure.
Anyone know how to make it work, or perhaps disable the anti-ghosting
feature? I tried Ctrl + Shift + Alt + N, as a different thread suggested,
but that did nothing.
How to make a realtime preview of a web-based text editor?
How to make a realtime preview of a web-based text editor?
Well, just like this Stackoverflow editor. Furthermore, how to do this
with additional js loaded? (like realtime math preview on
math.stackexchange)
Well, just like this Stackoverflow editor. Furthermore, how to do this
with additional js loaded? (like realtime math preview on
math.stackexchange)
How long to cook pork ribs in the oven?
How long to cook pork ribs in the oven?
tl;dr: I've got 6 lb of super-thick pork shoulder country style ribs. How
long should I cook them in the oven if I want them to taste good?
I recently bought a 6 lb. package of delicious, super-thick pork shoulder
country-style ribs. But I bought them without any idea on how to cook
them. So I started looking online for recipes but the cooking times vary
considerably. My best assumption is that the cooking times vary due to the
quantity of meat and temperature. However, I've had trouble estimating
exactly how much meat is present since some of the recipes list the rib
ingredient as simply "one rack" or something ambiguous like that. I don't
really know how much "one rack" is. "One rack" of baby back ribs is, I'm
quite sure, much less mean than what I've got sitting in my refrigerator.
So, how long should I cook these babies for?
tl;dr: I've got 6 lb of super-thick pork shoulder country style ribs. How
long should I cook them in the oven if I want them to taste good?
I recently bought a 6 lb. package of delicious, super-thick pork shoulder
country-style ribs. But I bought them without any idea on how to cook
them. So I started looking online for recipes but the cooking times vary
considerably. My best assumption is that the cooking times vary due to the
quantity of meat and temperature. However, I've had trouble estimating
exactly how much meat is present since some of the recipes list the rib
ingredient as simply "one rack" or something ambiguous like that. I don't
really know how much "one rack" is. "One rack" of baby back ribs is, I'm
quite sure, much less mean than what I've got sitting in my refrigerator.
So, how long should I cook these babies for?
Why is list element replacement slower than string element replacement in python?
Why is list element replacement slower than string element replacement in
python?
I am trying to replace a set of elements in a data-structure to some other
value. It seems that doing such kind of replacement is significantly
faster in strings than in lists in case of python (as revealed by the
benchmarking tests below). Can someone please explain why.
Note: These tests were performed on using python 2.7.
def string_replace_test(s, chars):
"""Replaces a set of chars to 0"""
new = s
for c in chars:
new = new.replace(c, '0')
return new
def list_replace_test(s, chars):
"""Replaces a set of chars to 0"""
for a in xrange(len(s)):
if s[a] in chars:
s[a] = '0'
if __name__ == '__main__':
import timeit
s = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
etfringilla purus. Pellentesque bibendum urna at neque consectetur
at tincidunt nulla luctus. Pellentesque augue lacus, interdum id
lectus vitae, laoreet suscipit arcu.
"""
s2 = list(s)
chars = ['a', 'e', 'i', 'o', 'u']
print(timeit.timeit("string_replace_test(s, chars)", setup="from
__main__ import string_replace_test, s, chars"))
print(timeit.timeit("list_replace_test(s2, chars)", setup="from
__main__ import list_replace_test, s2, chars"))
python?
I am trying to replace a set of elements in a data-structure to some other
value. It seems that doing such kind of replacement is significantly
faster in strings than in lists in case of python (as revealed by the
benchmarking tests below). Can someone please explain why.
Note: These tests were performed on using python 2.7.
def string_replace_test(s, chars):
"""Replaces a set of chars to 0"""
new = s
for c in chars:
new = new.replace(c, '0')
return new
def list_replace_test(s, chars):
"""Replaces a set of chars to 0"""
for a in xrange(len(s)):
if s[a] in chars:
s[a] = '0'
if __name__ == '__main__':
import timeit
s = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
etfringilla purus. Pellentesque bibendum urna at neque consectetur
at tincidunt nulla luctus. Pellentesque augue lacus, interdum id
lectus vitae, laoreet suscipit arcu.
"""
s2 = list(s)
chars = ['a', 'e', 'i', 'o', 'u']
print(timeit.timeit("string_replace_test(s, chars)", setup="from
__main__ import string_replace_test, s, chars"))
print(timeit.timeit("list_replace_test(s2, chars)", setup="from
__main__ import list_replace_test, s2, chars"))
Friday, 23 August 2013
SQL HAVING Unknown column
SQL HAVING Unknown column
I'm using WHERE XXX IN (SQL), so (SQL) must select only one Column
In this case I'm select some customer_id from a group, and those customer
only belongs to that group only
WHERE `id_customer` IN(
SELECT g.`id_customer` // this must select *only one* column
FROM ps_customer_group AS g
Group By g.`id_customer`
Having COUNT(g.`id_customer`) = 1
AND g.`id_group`=3 // **- Unknown column 'g.id_group' in 'having clause'**
)
the raw data look like this, btw this is not the result
I'm using WHERE XXX IN (SQL), so (SQL) must select only one Column
In this case I'm select some customer_id from a group, and those customer
only belongs to that group only
WHERE `id_customer` IN(
SELECT g.`id_customer` // this must select *only one* column
FROM ps_customer_group AS g
Group By g.`id_customer`
Having COUNT(g.`id_customer`) = 1
AND g.`id_group`=3 // **- Unknown column 'g.id_group' in 'having clause'**
)
the raw data look like this, btw this is not the result
How to initialize a char array using a char pointer in C
How to initialize a char array using a char pointer in C
Let's say I have a char pointer called string1 that points to the first
character in the word "hahahaha". I want to create a char[] that contains
the same string that string1 points to.
How come this does not work?
char string2[] = string1;
Let's say I have a char pointer called string1 that points to the first
character in the word "hahahaha". I want to create a char[] that contains
the same string that string1 points to.
How come this does not work?
char string2[] = string1;
Subprocess module from python fails to run bash commands like " | "
Subprocess module from python fails to run bash commands like " | "
The following python script:
#!/usr/bin/env python
import os
cmd = "echo Hello world | cut -d' ' -f1"
test=os.system(cmd)
print(test)
it runs ok (the output is Hello). But when I use subprocess module this one:
#!/usr/bin/env python
import subprocess
cmd = "echo Hello world | cut -d' ' -f1"
process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
test = process.communicate()[0]
print (test)
is not ok. The output is Hello world | cut -d' ' -f1 and I expect to be
only Hello. How can I correct it?
I saw that in general subprocess module will fail when I'm using a bash
command like:
<cmd1> | <cmd2>
The following python script:
#!/usr/bin/env python
import os
cmd = "echo Hello world | cut -d' ' -f1"
test=os.system(cmd)
print(test)
it runs ok (the output is Hello). But when I use subprocess module this one:
#!/usr/bin/env python
import subprocess
cmd = "echo Hello world | cut -d' ' -f1"
process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
test = process.communicate()[0]
print (test)
is not ok. The output is Hello world | cut -d' ' -f1 and I expect to be
only Hello. How can I correct it?
I saw that in general subprocess module will fail when I'm using a bash
command like:
<cmd1> | <cmd2>
Booleans in Java
Booleans in Java
I am a beginner and started to learn the java language. I encountered a
problem in the book about booleans. I don't know how to find the value of
the questions and I was wondering if someone can give me a sample of how
the code is supposed to look like. Help would really be appreciated.
Question in the book:
Suppose the value of b is false and the value of x is 0. What is the value
of each of the following expressions a) b && x == 0
b) b || x == 0
c) !b && x == 0
d) !b || x == 0
e) b && x != 0
f) b || x != 0
g) !b && x != 0
h) !b || x != 0
I just don't know how I would execute this problem, help! Thanks
I am a beginner and started to learn the java language. I encountered a
problem in the book about booleans. I don't know how to find the value of
the questions and I was wondering if someone can give me a sample of how
the code is supposed to look like. Help would really be appreciated.
Question in the book:
Suppose the value of b is false and the value of x is 0. What is the value
of each of the following expressions a) b && x == 0
b) b || x == 0
c) !b && x == 0
d) !b || x == 0
e) b && x != 0
f) b || x != 0
g) !b && x != 0
h) !b || x != 0
I just don't know how I would execute this problem, help! Thanks
Dojo store duplication in cache
Dojo store duplication in cache
I am using a combination of dojo and cbtree to build a treeview with
checkboxes. Because the data is on the server I use a JsonRest store to
retrieve it. Because I don't want every action going to the server the
JsonRest is combined with a Memory in a Cache.
A simplified example looks like the following:
define([
'dojo/_base/declare',
'dojo/store/JsonRest', 'dojo/store/Memory', 'dojo/store/Cache',
'cbtree/model/TreeStoreModel', 'cbtree/Tree'
], function(declare,
JsonRest, Memory, Cache,
TreeStoreModel, Tree) {
return declare(null, {
buildTree: function() {
var self = this;
this._memory = new Memory();
this._restStore = new JsonRest({
target: '/process_trees/',
getSelectedItems: function() {
var checkedIds = [];
array.forEach(self._memory.query(), function(item) {
if(item.checked || item.checked == 'mixed') {
checkedIds.push(item);
}
})
return checkedIds;
}
});
var cache = Cache(restStore, memory);
this._treeModel = new TreeStoreModel({
store: cache
});
}
})
}
During the execution of the tree I check some items in the tree and I see
in the Cache the put function being called with the new item in which the
checked property is set to true and this value is stored in memory.
After a while I want to get all the items that are checked so I call the
getSelectedItems function but when I look in the local memory in the
function, self._memory, not a single item is checked even though I have
checked several items.
Does anybody know why this is happening?
I am using a combination of dojo and cbtree to build a treeview with
checkboxes. Because the data is on the server I use a JsonRest store to
retrieve it. Because I don't want every action going to the server the
JsonRest is combined with a Memory in a Cache.
A simplified example looks like the following:
define([
'dojo/_base/declare',
'dojo/store/JsonRest', 'dojo/store/Memory', 'dojo/store/Cache',
'cbtree/model/TreeStoreModel', 'cbtree/Tree'
], function(declare,
JsonRest, Memory, Cache,
TreeStoreModel, Tree) {
return declare(null, {
buildTree: function() {
var self = this;
this._memory = new Memory();
this._restStore = new JsonRest({
target: '/process_trees/',
getSelectedItems: function() {
var checkedIds = [];
array.forEach(self._memory.query(), function(item) {
if(item.checked || item.checked == 'mixed') {
checkedIds.push(item);
}
})
return checkedIds;
}
});
var cache = Cache(restStore, memory);
this._treeModel = new TreeStoreModel({
store: cache
});
}
})
}
During the execution of the tree I check some items in the tree and I see
in the Cache the put function being called with the new item in which the
checked property is set to true and this value is stored in memory.
After a while I want to get all the items that are checked so I call the
getSelectedItems function but when I look in the local memory in the
function, self._memory, not a single item is checked even though I have
checked several items.
Does anybody know why this is happening?
Delete object properties similiar like deleting array elements with splice?
Delete object properties similiar like deleting array elements with splice?
We have object type variable in Jquery:
var obj = {"1234" : "xx", "4321" : "yy", "5555" : "hh", "2321" : "aa" };
Lets say that I want to delete every property from property name "5555" to
the end of the object(that means that I want to delete obj['5555'] and
delete obj['2321']). I am interested in smartest way, trough loop, to do
that.
In array I would use splice(2, arr.length) but I am confused.
I have some ides, but I don't think that they are smartest way to go, so I
ask you guys.
Thank You in Advance.
We have object type variable in Jquery:
var obj = {"1234" : "xx", "4321" : "yy", "5555" : "hh", "2321" : "aa" };
Lets say that I want to delete every property from property name "5555" to
the end of the object(that means that I want to delete obj['5555'] and
delete obj['2321']). I am interested in smartest way, trough loop, to do
that.
In array I would use splice(2, arr.length) but I am confused.
I have some ides, but I don't think that they are smartest way to go, so I
ask you guys.
Thank You in Advance.
Thursday, 22 August 2013
How to obtain some properties from a database using JDBC?
How to obtain some properties from a database using JDBC?
I'm trying to get some properties like the following:
databaseName
portNumber
serverName
driverType
readOnly
from DB2 database. How can I do that using java's JDBC?
I'm trying to get some properties like the following:
databaseName
portNumber
serverName
driverType
readOnly
from DB2 database. How can I do that using java's JDBC?
How do I cast type aclitem to text or varchar in psql?
How do I cast type aclitem to text or varchar in psql?
I am attempting to do a like/~ operation with an aclitem and am having
problems. I cannot cast this type to a text or varchar type, so I am
unable to use the like or ~ operators. I am having the same trouble with
the cstring type. My guess is that this is somehow enumerated, but I can't
seem to find the key. Any ideas?
This is the type of query I'd like to run:
select
case when relacl[1] ~ '%searchstring%' then 1 else 0 end as temp1,
case when relacl[1] like '%searchstring%' then 1 else 0 end as temp2,
case when aclitemout(relacl[1]) ~ '%searchstring%' then 1 else 0 end as
temp3,
case when aclitemout(relacl[1]) like '%searchstring%' then 1 else 0 end
as temp4,
relacl[1]::text as temp5,
relacl[1]::varchar as temp6,
aclitemout(relacl[1])::text as temp7,
aclitemout(relacl[1])::varchar as temp8
from
pg_class c
;
I am attempting to do a like/~ operation with an aclitem and am having
problems. I cannot cast this type to a text or varchar type, so I am
unable to use the like or ~ operators. I am having the same trouble with
the cstring type. My guess is that this is somehow enumerated, but I can't
seem to find the key. Any ideas?
This is the type of query I'd like to run:
select
case when relacl[1] ~ '%searchstring%' then 1 else 0 end as temp1,
case when relacl[1] like '%searchstring%' then 1 else 0 end as temp2,
case when aclitemout(relacl[1]) ~ '%searchstring%' then 1 else 0 end as
temp3,
case when aclitemout(relacl[1]) like '%searchstring%' then 1 else 0 end
as temp4,
relacl[1]::text as temp5,
relacl[1]::varchar as temp6,
aclitemout(relacl[1])::text as temp7,
aclitemout(relacl[1])::varchar as temp8
from
pg_class c
;
Android Studio : how to compile Google Play Services and GCM along with the project?
Android Studio : how to compile Google Play Services and GCM along with
the project?
I've been trying to compile my project using Google Play Services such as
Maps and GCM.
After following these instructions, my project now compiles successfully
and includes all the libs I need. Android Studio also has added
auto-completion for GCM and Maps functions. Build target is set to Google
APIs 18
But then, when I intent to start my app, it crashes when it hits
if(GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) !=
ConnectionResult.SUCCESS){
setContentView(R.layout.error_no_play);
return;
or when it hits the map fragment
<fragment
android:id="@+id/map"
android:layout_height="match_parent"
android:layout_width="match_parent"
tools:layout="@layout/fragment_gmap"
class="com.google.android.gms.maps.MapFragment"/>
The errors thrown are :
When checking if GooglePlayServices is available :
java.lang.NoClassDefFoundError:
com.google.android.gms.common.GooglePlayServicesUtil
For the fragment :
08-22 20:17:56.565 20356-20356/ E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity
ComponentInfo{/.MainActivity}: android.view.InflateException: Binary XML
file line #8: Error inflating class fragment at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2178)
at android.app.ActivityThread.access$700(ActivityThread.java:141) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271) at
android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:137) at
android.app.ActivityThread.main(ActivityThread.java:5118) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:511) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555) at
dalvik.system.NativeStart.main(Native Method) Caused by:
android.view.InflateException: Binary XML file line #8: Error inflating
class fragment at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at
android.view.LayoutInflater.rInflate(LayoutInflater.java:746) at
android.view.LayoutInflater.inflate(LayoutInflater.java:489) at
android.view.LayoutInflater.inflate(LayoutInflater.java:396) at
.SearchFragment.newTab(SearchFragment.java:71) at
.SearchFragment.setupTabs(SearchFragment.java:54) at
.SearchFragment.onCreateView(SearchFragment.java:28) at
android.support.v4.app.Fragment.performCreateView(Fragment.java:1460) at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) at
android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
at
android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
at
android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
at android.app.Activity.performStart(Activity.java:5068) at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2113)
... 11 more Caused by:
android.support.v4.app.Fragment$InstantiationException: Unable to
instantiate fragment com.google.android.gms.maps.MapFragment: make sure
class name exists, is public, and has an empty constructor that is public
at android.support.v4.app.Fragment.instantiate(Fragment.java:401) at
android.support.v4.app.Fragment.instantiate(Fragment.java:369) at
android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
... 26 more Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.google.android.gms.maps.MapFragment" on path: /data/app/-2.apk at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) at
java.lang.ClassLoader.loadClass(ClassLoader.java:501) at
java.lang.ClassLoader.loadClass(ClassLoader.java:461) at
android.support.v4.app.Fragment.instantiate(Fragment.java:391) ... 29 more
I've been dealing with this issue for 1 month now, and i still have no way
to deal with it. Is it a known issue of AndroidStudio ? Am i forgetting
something ? From what i'm reading from the error logs, it looks like the
libs are not compiled with the project.
the project?
I've been trying to compile my project using Google Play Services such as
Maps and GCM.
After following these instructions, my project now compiles successfully
and includes all the libs I need. Android Studio also has added
auto-completion for GCM and Maps functions. Build target is set to Google
APIs 18
But then, when I intent to start my app, it crashes when it hits
if(GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) !=
ConnectionResult.SUCCESS){
setContentView(R.layout.error_no_play);
return;
or when it hits the map fragment
<fragment
android:id="@+id/map"
android:layout_height="match_parent"
android:layout_width="match_parent"
tools:layout="@layout/fragment_gmap"
class="com.google.android.gms.maps.MapFragment"/>
The errors thrown are :
When checking if GooglePlayServices is available :
java.lang.NoClassDefFoundError:
com.google.android.gms.common.GooglePlayServicesUtil
For the fragment :
08-22 20:17:56.565 20356-20356/ E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity
ComponentInfo{/.MainActivity}: android.view.InflateException: Binary XML
file line #8: Error inflating class fragment at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2178)
at android.app.ActivityThread.access$700(ActivityThread.java:141) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271) at
android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:137) at
android.app.ActivityThread.main(ActivityThread.java:5118) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:511) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555) at
dalvik.system.NativeStart.main(Native Method) Caused by:
android.view.InflateException: Binary XML file line #8: Error inflating
class fragment at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at
android.view.LayoutInflater.rInflate(LayoutInflater.java:746) at
android.view.LayoutInflater.inflate(LayoutInflater.java:489) at
android.view.LayoutInflater.inflate(LayoutInflater.java:396) at
.SearchFragment.newTab(SearchFragment.java:71) at
.SearchFragment.setupTabs(SearchFragment.java:54) at
.SearchFragment.onCreateView(SearchFragment.java:28) at
android.support.v4.app.Fragment.performCreateView(Fragment.java:1460) at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) at
android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
at
android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
at
android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
at android.app.Activity.performStart(Activity.java:5068) at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2113)
... 11 more Caused by:
android.support.v4.app.Fragment$InstantiationException: Unable to
instantiate fragment com.google.android.gms.maps.MapFragment: make sure
class name exists, is public, and has an empty constructor that is public
at android.support.v4.app.Fragment.instantiate(Fragment.java:401) at
android.support.v4.app.Fragment.instantiate(Fragment.java:369) at
android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
... 26 more Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.google.android.gms.maps.MapFragment" on path: /data/app/-2.apk at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) at
java.lang.ClassLoader.loadClass(ClassLoader.java:501) at
java.lang.ClassLoader.loadClass(ClassLoader.java:461) at
android.support.v4.app.Fragment.instantiate(Fragment.java:391) ... 29 more
I've been dealing with this issue for 1 month now, and i still have no way
to deal with it. Is it a known issue of AndroidStudio ? Am i forgetting
something ? From what i'm reading from the error logs, it looks like the
libs are not compiled with the project.
How to load extensions into a watir driver browser?
How to load extensions into a watir driver browser?
I am using Watir driver and I am unable to load an extension into the
chrome executable. Can some one give me a valid working code? I did search
stackoverflow and found similar such questions but none of the solution
are working for me.
I am using Watir driver and I am unable to load an extension into the
chrome executable. Can some one give me a valid working code? I did search
stackoverflow and found similar such questions but none of the solution
are working for me.
Mikrotik IPSec VPN routing
Mikrotik IPSec VPN routing
I seem to be clueless at the routing with VPN. I am trying to setup an
IPSec VPN tunnel so as to secure communication between my private LAN and
a destination host. Any device within my private LAN should be able to
initiate connection to the destination host. However, if the destination
host wants to connect to my network (directed to my public IP address), I
want to forward that connection to just one particular server -
192.168.1.65.
My setup:
Private LAN : 192.168.1.1/24
Public IP : 50.X.X.X
Destination Host IP : 173.X.X.X (using CISCO ASA)
I got the basic setup working fine and my internal LAN is able to access
the internet. My attempt at the IPSec configuration is as follows:
/interface ipip
add comment="" disabled=no local-address=50.X.X.X mtu=1460 name=ipip1 \
remote-address=173.X.X.X
/ip address
add address=192.168.1.1/24 broadcast=192.168.1.255 comment="" disabled=no \
interface=ipip1 network=192.168.1.0
/ip ipsec peer
add address=173.X.X.X/32 auth-method=pre-shared-key comment="" \
dh-group=modp1024 disabled=no dpd-interval=disable-dpd \
enc-algorithm=3des exchange-mode=main generate-policy=no \
hash-algorithm=md5 lifebytes=0 lifetime=1d nat-traversal=no port=500 \
proposal-check=obey secret=SECRETKEY send-initial-contact=yes
/ip ipsec policy
add action=encrypt comment="" disabled=no dst-address=173.X.X.X/32
dst-port=any \
ipsec-protocols=esp level=require priority=0 proposal=ipsec
protocol=all \
sa-dst-address=173.X.X.X sa-src-address=50.X.X.X \
src-address=50.X.X.X/32:any tunnel=yes
/ip ipsec proposal
set default auth-algorithms=md5 comment="" disabled=no enc-algorithms=3des \
lifetime=60m name=ipsec pfs-group=none
What to do next? How to configure such that my devices can initiate
connection to the host and for the host to initiate connection to just one
particular server? Would it be ip firewall nat, masquerade or ip route?
Any help greatly appreciated.
I seem to be clueless at the routing with VPN. I am trying to setup an
IPSec VPN tunnel so as to secure communication between my private LAN and
a destination host. Any device within my private LAN should be able to
initiate connection to the destination host. However, if the destination
host wants to connect to my network (directed to my public IP address), I
want to forward that connection to just one particular server -
192.168.1.65.
My setup:
Private LAN : 192.168.1.1/24
Public IP : 50.X.X.X
Destination Host IP : 173.X.X.X (using CISCO ASA)
I got the basic setup working fine and my internal LAN is able to access
the internet. My attempt at the IPSec configuration is as follows:
/interface ipip
add comment="" disabled=no local-address=50.X.X.X mtu=1460 name=ipip1 \
remote-address=173.X.X.X
/ip address
add address=192.168.1.1/24 broadcast=192.168.1.255 comment="" disabled=no \
interface=ipip1 network=192.168.1.0
/ip ipsec peer
add address=173.X.X.X/32 auth-method=pre-shared-key comment="" \
dh-group=modp1024 disabled=no dpd-interval=disable-dpd \
enc-algorithm=3des exchange-mode=main generate-policy=no \
hash-algorithm=md5 lifebytes=0 lifetime=1d nat-traversal=no port=500 \
proposal-check=obey secret=SECRETKEY send-initial-contact=yes
/ip ipsec policy
add action=encrypt comment="" disabled=no dst-address=173.X.X.X/32
dst-port=any \
ipsec-protocols=esp level=require priority=0 proposal=ipsec
protocol=all \
sa-dst-address=173.X.X.X sa-src-address=50.X.X.X \
src-address=50.X.X.X/32:any tunnel=yes
/ip ipsec proposal
set default auth-algorithms=md5 comment="" disabled=no enc-algorithms=3des \
lifetime=60m name=ipsec pfs-group=none
What to do next? How to configure such that my devices can initiate
connection to the host and for the host to initiate connection to just one
particular server? Would it be ip firewall nat, masquerade or ip route?
Any help greatly appreciated.
Objective-C/UIAlertView - I can't find the button pressed in the alert view
Objective-C/UIAlertView - I can't find the button pressed in the alert view
For the program that i'm developing, i have created a class "Utilities"
that contains an alert view with a cancel button. I want create one NSLog
that advice me when the cancel button is pressed. The method that contains
the alert view is called in another class, that is the ViewController.m
file, but at the moment no log appear. Can you please help me to
understand what i'm doing wrong?
This is the Utilities.h file:
@interface Utilities : UIViewController <UIAlertViewDelegate>
-(Boolean) isOnline;
-(void) buttonPressed;
@end
This is the Utilities.m file:
-(Boolean) isOnline {
Boolean online = false;
Reachability *reachability = [Reachability
reachabilityForInternetConnection];
[reachability startNotifier];
NetworkStatus status = [reachability currentReachabilityStatus];
if(status == ReachableViaWiFi)
{
NSLog(@"WI FI");
online = true;
}
else
{
NSLog(@"NO WI FI");
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Warning"
message:@"You are
not connected to a
wireless network.
Please connect your
device."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];
}
return online;
}
- (void) buttonPressed:(UIAlertView *)alert
clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex==0) {
NSLog(@"Clicked the button Ok");
}
}
And here is where i call the method in the "ViewController" class:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//Add gradient background
CAGradientLayer *bgLayer = [BackgroundLayer blueGradient];
bgLayer.frame = self.view.bounds;
[self.view.layer insertSublayer:bgLayer atIndex:0];
[self initialize];
Utilities* utilities = [[Utilities alloc] init]; //create an istance of
the class Utilities for use their methods in this class
[utilities isOnline]; //call the method isOnline from the class Utilities
}
Thanks
For the program that i'm developing, i have created a class "Utilities"
that contains an alert view with a cancel button. I want create one NSLog
that advice me when the cancel button is pressed. The method that contains
the alert view is called in another class, that is the ViewController.m
file, but at the moment no log appear. Can you please help me to
understand what i'm doing wrong?
This is the Utilities.h file:
@interface Utilities : UIViewController <UIAlertViewDelegate>
-(Boolean) isOnline;
-(void) buttonPressed;
@end
This is the Utilities.m file:
-(Boolean) isOnline {
Boolean online = false;
Reachability *reachability = [Reachability
reachabilityForInternetConnection];
[reachability startNotifier];
NetworkStatus status = [reachability currentReachabilityStatus];
if(status == ReachableViaWiFi)
{
NSLog(@"WI FI");
online = true;
}
else
{
NSLog(@"NO WI FI");
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Warning"
message:@"You are
not connected to a
wireless network.
Please connect your
device."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];
}
return online;
}
- (void) buttonPressed:(UIAlertView *)alert
clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex==0) {
NSLog(@"Clicked the button Ok");
}
}
And here is where i call the method in the "ViewController" class:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//Add gradient background
CAGradientLayer *bgLayer = [BackgroundLayer blueGradient];
bgLayer.frame = self.view.bounds;
[self.view.layer insertSublayer:bgLayer atIndex:0];
[self initialize];
Utilities* utilities = [[Utilities alloc] init]; //create an istance of
the class Utilities for use their methods in this class
[utilities isOnline]; //call the method isOnline from the class Utilities
}
Thanks
Wednesday, 21 August 2013
Automatic Enrollment (SSO)
Automatic Enrollment (SSO)
I contract for a company that provides internet solutions to hotels and a
potential client wants us to manage their corporate network so we need to
make changes to our system to accommodate them.
One of those changes is to automatically enroll users (on our web portal
hosted on a linux box at the clients site) when they log into their
network using Active Directory.
We already have pages where a user can enter their AD details and we
interface to their AD server to verify those details. However, this means
that the user has to log into the network, then log into the web as well.
We'd like it to be a single step.
Cheers, Shawn
I contract for a company that provides internet solutions to hotels and a
potential client wants us to manage their corporate network so we need to
make changes to our system to accommodate them.
One of those changes is to automatically enroll users (on our web portal
hosted on a linux box at the clients site) when they log into their
network using Active Directory.
We already have pages where a user can enter their AD details and we
interface to their AD server to verify those details. However, this means
that the user has to log into the network, then log into the web as well.
We'd like it to be a single step.
Cheers, Shawn
IPC key chose 8 bits from st_dev and 16 bits from st_ino
IPC key chose 8 bits from st_dev and 16 bits from st_ino
This is a code copy from UNP Richard Stevens
#include "apue.h"
#include <sys/ipc.h>
int main(int argc,char * argv[])
{
struct stat stat_buf;
if(argc != 2)
err_quit("usage ftock <pathname>");
stat(argv[1],&stat_buf);
printf("st_dev :%08lx, st_info : %08lx ,key :%08x\n",(unsigned
long)stat_buf.st_dev,(unsigned
long)stat_buf.st_ino,ftok(argv[1],0x57));
}
Output:
st_dev :00000803, st_ino : 018e17c3 ,key :570317c3
So the key take 8 bit from id , 8 bit from st_dev and 16 bit from st_ino.
I use SUSE gcc .
I know the book is kind of old. new implement had its new method.
Can anyone tell me the principle of ftok works? And the reason choose more
bits from st_ino?
This is a code copy from UNP Richard Stevens
#include "apue.h"
#include <sys/ipc.h>
int main(int argc,char * argv[])
{
struct stat stat_buf;
if(argc != 2)
err_quit("usage ftock <pathname>");
stat(argv[1],&stat_buf);
printf("st_dev :%08lx, st_info : %08lx ,key :%08x\n",(unsigned
long)stat_buf.st_dev,(unsigned
long)stat_buf.st_ino,ftok(argv[1],0x57));
}
Output:
st_dev :00000803, st_ino : 018e17c3 ,key :570317c3
So the key take 8 bit from id , 8 bit from st_dev and 16 bit from st_ino.
I use SUSE gcc .
I know the book is kind of old. new implement had its new method.
Can anyone tell me the principle of ftok works? And the reason choose more
bits from st_ino?
Trigger an event on clicking "OK" on the messagebox in an access form
Trigger an event on clicking "OK" on the messagebox in an access form
I have an access form in which after the user performs few operations a
message box will appear. When the user clicks "OK" on the message box I
want to close the current form and open a new form. How can I do this?
I have an access form in which after the user performs few operations a
message box will appear. When the user clicks "OK" on the message box I
want to close the current form and open a new form. How can I do this?
Regex allowing for ascii codes 128-165?
Regex allowing for ascii codes 128-165?
How do you allow ASCII character codes from 128-165 to be included in
regular expressions? This includes letters that include tildes and
non-english keyboard characters?
Special characters are found at this link
How can this be implemented in python and/or javascript?
How do you allow ASCII character codes from 128-165 to be included in
regular expressions? This includes letters that include tildes and
non-english keyboard characters?
Special characters are found at this link
How can this be implemented in python and/or javascript?
Bib entry with urldate but no year uses the year of urldate as year
Bib entry with urldate but no year uses the year of urldate as year
Hi i have the following bibliographic entry:
@misc{Wikipedia,
author = {Wikipedia},
title = {{Software performance testing}},
url =
{http://en.wikipedia.org/wiki/Software\_performance\_testing\#Load\_testing},
urldate = {2013-07-10}
}
This entry gets rendered like the following in the bibliography:
if i add a year tag of 2012 to the entry, it becomes:
I think this is wrong, shouldn't i say something like (o.D. is a german
abbreviation for no date, "Besucht am" is "visited at")
Wikipedia o.D. Software Performance testing. Besucht am 10.Juli 2013
? How can i achieve this?
Hi i have the following bibliographic entry:
@misc{Wikipedia,
author = {Wikipedia},
title = {{Software performance testing}},
url =
{http://en.wikipedia.org/wiki/Software\_performance\_testing\#Load\_testing},
urldate = {2013-07-10}
}
This entry gets rendered like the following in the bibliography:
if i add a year tag of 2012 to the entry, it becomes:
I think this is wrong, shouldn't i say something like (o.D. is a german
abbreviation for no date, "Besucht am" is "visited at")
Wikipedia o.D. Software Performance testing. Besucht am 10.Juli 2013
? How can i achieve this?
Setting custom font to all TextViews
Setting custom font to all TextViews
Is there an easy way to make all textviews (and any other text elements in
my app) to use a custom font of my own (and not the built-in choices),
without having to manually set them via textview.setTypeface()?
I guess extending Textview would do the trick but then building interfaces
with the visual editor is kind of a pain. I was thinking of something like
styling but can't find how to set a custom font there.
Is there an easy way to make all textviews (and any other text elements in
my app) to use a custom font of my own (and not the built-in choices),
without having to manually set them via textview.setTypeface()?
I guess extending Textview would do the trick but then building interfaces
with the visual editor is kind of a pain. I was thinking of something like
styling but can't find how to set a custom font there.
Is Google Wallet API will allow multiple recipients during a single transaction
Is Google Wallet API will allow multiple recipients during a single
transaction
I am implementing Google Wallet API to complete the transaction with PHP
website. Seems there is no way to add multiple recipients during a single
transaction. please let me know if there is any way to do this.
transaction
I am implementing Google Wallet API to complete the transaction with PHP
website. Seems there is no way to add multiple recipients during a single
transaction. please let me know if there is any way to do this.
Tuesday, 20 August 2013
Starting activities on tab click
Starting activities on tab click
I have 3 tabs which show different content on click. I want them to open
certain activities on click. These activities are nothing but database
reports which just need to be displayed. I used web view and works fine on
emulator with API level 11 but gives an error saying "Web page not found"
on my device which is API level 10. Also, The tabs display data only after
clicking on other tabs and coming back to the first. Is there a way I can
start the activities directly instead of using web view?
Any help is appreciated.
Heres my code:
xml file:-
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabHost
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linearLayout1"
android:orientation="vertical"
>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" ></TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tabs1"
android:orientation="vertical"
>
<WebView
android:id="@+id/txtGetFuelInfo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Get info from Database" />
<TextView
android:id="@+id/txtGetFuel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tabs2"
android:orientation="vertical"
>
<WebView
android:id="@+id/txtMainGetInfo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Get info from Database"/>
<TextView
android:id="@+id/txtGetMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tabs3"
android:orientation="vertical"
>
<WebView
android:id="@+id/txtSpareGetInfo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Get info from Database"/>
<TextView
android:id="@+id/txtGetspare"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
CLass file :-
public class DetailsTabs extends Activity
{
TabSpec tspec;
FuelStoredInfo fuelInfo;
WebView fuelView,mainView,sparesView;
TextView tvFuel, tvMain, tvSpares;
WebSettings fuelSetting, mainSetting, spareSetting;
/* (non-Javadoc)
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.detailstabs);
fuelView = (WebView)findViewById(R.id.txtGetFuelInfo);
mainView = (WebView)findViewById(R.id.txtMainGetInfo);
sparesView = (WebView)findViewById(R.id.txtSpareGetInfo);
//tvFuel = (TextView)findViewById(R.id.totalFuelId);
//tvMain = (TextView)findViewById(R.id.totalmainId);
//tvSpares = (TextView)findViewById(R.id.totalspareId);
fuelInfo = new FuelStoredInfo(this);
fuelInfo.open();
TabHost th = (TabHost)findViewById(R.id.tabhost);
th.setup();
// Fuel Expense tab
tspec = th.newTabSpec("Tag 1");
tspec.setContent(R.id.tabs1);
tspec.setIndicator("Fuel"+"\n"+"Expense");
String Data = fuelInfo.getData();
double fuelTotal =fuelInfo.getTotalFuel();
fuelSetting = fuelView.getSettings();
fuelSetting.setDefaultFontSize(10);
//tvFuel.setText("Total fuel expense : Rs. "+
String.valueOf(fuelTotal));
fuelView.loadData(Data,"text/html",null);
th.addTab(tspec);
//Maintenance Expense tab
tspec = th.newTabSpec("Tag 2");
tspec.setContent(R.id.tabs2);
tspec.setIndicator("Maintenance"+"\n"+"Expense");
mainSetting = mainView.getSettings();
mainSetting.setDefaultFontSize(10);
String mainData = fuelInfo.getMainData();
double mainTotal =fuelInfo.getTotalMain();
tvMain.setText("Total maintenance expense : Rs. "+
String.valueOf(mainTotal));
mainView.loadData(mainData,"text/html",null);
th.addTab(tspec);
//Spares Expense tab
tspec = th.newTabSpec("Tag 3");
tspec.setContent(R.id.tabs3);
tspec.setIndicator("Spares"+"\n"+"Expense");
spareSetting = sparesView.getSettings();
spareSetting.setDefaultFontSize(10);
String sparesData= fuelInfo.getSpareData();
double spareTotal = fuelInfo.getTotalSpares();
tvSpares.setText("Total spares expense : Rs."+
String.valueOf(spareTotal));
sparesView.loadData(sparesData,"text/html",null);
th.addTab(tspec);
fuelInfo.close();
}
}
I have 3 tabs which show different content on click. I want them to open
certain activities on click. These activities are nothing but database
reports which just need to be displayed. I used web view and works fine on
emulator with API level 11 but gives an error saying "Web page not found"
on my device which is API level 10. Also, The tabs display data only after
clicking on other tabs and coming back to the first. Is there a way I can
start the activities directly instead of using web view?
Any help is appreciated.
Heres my code:
xml file:-
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabHost
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linearLayout1"
android:orientation="vertical"
>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" ></TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tabs1"
android:orientation="vertical"
>
<WebView
android:id="@+id/txtGetFuelInfo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Get info from Database" />
<TextView
android:id="@+id/txtGetFuel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tabs2"
android:orientation="vertical"
>
<WebView
android:id="@+id/txtMainGetInfo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Get info from Database"/>
<TextView
android:id="@+id/txtGetMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tabs3"
android:orientation="vertical"
>
<WebView
android:id="@+id/txtSpareGetInfo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Get info from Database"/>
<TextView
android:id="@+id/txtGetspare"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
CLass file :-
public class DetailsTabs extends Activity
{
TabSpec tspec;
FuelStoredInfo fuelInfo;
WebView fuelView,mainView,sparesView;
TextView tvFuel, tvMain, tvSpares;
WebSettings fuelSetting, mainSetting, spareSetting;
/* (non-Javadoc)
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.detailstabs);
fuelView = (WebView)findViewById(R.id.txtGetFuelInfo);
mainView = (WebView)findViewById(R.id.txtMainGetInfo);
sparesView = (WebView)findViewById(R.id.txtSpareGetInfo);
//tvFuel = (TextView)findViewById(R.id.totalFuelId);
//tvMain = (TextView)findViewById(R.id.totalmainId);
//tvSpares = (TextView)findViewById(R.id.totalspareId);
fuelInfo = new FuelStoredInfo(this);
fuelInfo.open();
TabHost th = (TabHost)findViewById(R.id.tabhost);
th.setup();
// Fuel Expense tab
tspec = th.newTabSpec("Tag 1");
tspec.setContent(R.id.tabs1);
tspec.setIndicator("Fuel"+"\n"+"Expense");
String Data = fuelInfo.getData();
double fuelTotal =fuelInfo.getTotalFuel();
fuelSetting = fuelView.getSettings();
fuelSetting.setDefaultFontSize(10);
//tvFuel.setText("Total fuel expense : Rs. "+
String.valueOf(fuelTotal));
fuelView.loadData(Data,"text/html",null);
th.addTab(tspec);
//Maintenance Expense tab
tspec = th.newTabSpec("Tag 2");
tspec.setContent(R.id.tabs2);
tspec.setIndicator("Maintenance"+"\n"+"Expense");
mainSetting = mainView.getSettings();
mainSetting.setDefaultFontSize(10);
String mainData = fuelInfo.getMainData();
double mainTotal =fuelInfo.getTotalMain();
tvMain.setText("Total maintenance expense : Rs. "+
String.valueOf(mainTotal));
mainView.loadData(mainData,"text/html",null);
th.addTab(tspec);
//Spares Expense tab
tspec = th.newTabSpec("Tag 3");
tspec.setContent(R.id.tabs3);
tspec.setIndicator("Spares"+"\n"+"Expense");
spareSetting = sparesView.getSettings();
spareSetting.setDefaultFontSize(10);
String sparesData= fuelInfo.getSpareData();
double spareTotal = fuelInfo.getTotalSpares();
tvSpares.setText("Total spares expense : Rs."+
String.valueOf(spareTotal));
sparesView.loadData(sparesData,"text/html",null);
th.addTab(tspec);
fuelInfo.close();
}
}
How to move images both clockwise and counter with swipes?
How to move images both clockwise and counter with swipes?
Hello and thanks for the help,
I have images in all four corners of my screen. Swipe right and all images
rotate clockwise one corner. Swipe left all images move one corner
counter-clockwise. Everthing works fine so long as I all objects start
from their original position...so you have to swipe 4 times to get back to
original position and then swipe left and all is well. However, I would
like the user to have the ability to swipe back whenever they like not
just from original position.
My question: what is the best way to go about this ?
hope that made sense. thanks for reading
Code for my Xvalues stored in an Array....same idea for my yVales also
called getNewYvalue(). Called by swipeRight()
public void getNewXvalue()
{
int BLTL_XValues[] =
{145,135,126,117,110,103,98,93,89,86,83,81,80,80,80,80,81,83,85,88,91,95,99,104,109,115,122,129,137,146,156};
int BRBL_XValues[] =
{643,627,610,594,577,560,543,526,509,492,475,458,441,424,407,390,373,356,339,323,306,289,272,255,238,221,204,187,170,153,136};
int TLTR_XValues[] =
{137,151,167,183,199,216,232,249,266,282,299,316,333,349,366,383,400,417,433,450,467,484,500,517,534,551,568,584,601,618,634};
int TRBR_XValues[] =
{634,644,651,657,661,665,668,670,672,673,674,674,674,674,673,672,671,670,668,666,663,660,657,653,649,645,640,634,628,621,613};
for (int i = 0; i < TRBR_XValues.length; i++)
{
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
goLeftX=BRBL_XValues[i];
goUpX=BLTL_XValues[i];
goDownX=TRBR_XValues[i];
goRightX=TLTR_XValues[i];
//
if(numOfSwipes==1)
{
droidSilverCell.setX(goUpX);
droidCards.setX(goLeftX);
droidCookies.setX(goDownX);
droidBlueCell.setX(goRightX);
}
else if(numOfSwipes==2)
{
droidSilverCell.setX(goRightX);
droidCards.setX(goUpX);
droidCookies.setX(goLeftX);
droidBlueCell.setX(goDownX);
}
else if(numOfSwipes==3)
{
droidSilverCell.setX(goDownX);
droidCards.setX(goRightX);
droidCookies.setX(goUpX);
droidBlueCell.setX(goLeftX);
}
else if(numOfSwipes==4)
{
droidSilverCell.setX(goLeftX);
droidCards.setX(goDownX);
droidCookies.setX(goRightX);
droidBlueCell.setX(goUpX);
}
else
{
}
if(numOfSwipes ==5)
{
numOfSwipes=1;
}
}
}
Hello and thanks for the help,
I have images in all four corners of my screen. Swipe right and all images
rotate clockwise one corner. Swipe left all images move one corner
counter-clockwise. Everthing works fine so long as I all objects start
from their original position...so you have to swipe 4 times to get back to
original position and then swipe left and all is well. However, I would
like the user to have the ability to swipe back whenever they like not
just from original position.
My question: what is the best way to go about this ?
hope that made sense. thanks for reading
Code for my Xvalues stored in an Array....same idea for my yVales also
called getNewYvalue(). Called by swipeRight()
public void getNewXvalue()
{
int BLTL_XValues[] =
{145,135,126,117,110,103,98,93,89,86,83,81,80,80,80,80,81,83,85,88,91,95,99,104,109,115,122,129,137,146,156};
int BRBL_XValues[] =
{643,627,610,594,577,560,543,526,509,492,475,458,441,424,407,390,373,356,339,323,306,289,272,255,238,221,204,187,170,153,136};
int TLTR_XValues[] =
{137,151,167,183,199,216,232,249,266,282,299,316,333,349,366,383,400,417,433,450,467,484,500,517,534,551,568,584,601,618,634};
int TRBR_XValues[] =
{634,644,651,657,661,665,668,670,672,673,674,674,674,674,673,672,671,670,668,666,663,660,657,653,649,645,640,634,628,621,613};
for (int i = 0; i < TRBR_XValues.length; i++)
{
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
goLeftX=BRBL_XValues[i];
goUpX=BLTL_XValues[i];
goDownX=TRBR_XValues[i];
goRightX=TLTR_XValues[i];
//
if(numOfSwipes==1)
{
droidSilverCell.setX(goUpX);
droidCards.setX(goLeftX);
droidCookies.setX(goDownX);
droidBlueCell.setX(goRightX);
}
else if(numOfSwipes==2)
{
droidSilverCell.setX(goRightX);
droidCards.setX(goUpX);
droidCookies.setX(goLeftX);
droidBlueCell.setX(goDownX);
}
else if(numOfSwipes==3)
{
droidSilverCell.setX(goDownX);
droidCards.setX(goRightX);
droidCookies.setX(goUpX);
droidBlueCell.setX(goLeftX);
}
else if(numOfSwipes==4)
{
droidSilverCell.setX(goLeftX);
droidCards.setX(goDownX);
droidCookies.setX(goRightX);
droidBlueCell.setX(goUpX);
}
else
{
}
if(numOfSwipes ==5)
{
numOfSwipes=1;
}
}
}
multiple functions in php and getting results after each one
multiple functions in php and getting results after each one
I am working on a script that builds a user in our system. I compile all
the data, and end up with a form POST array with all the data i need. What
i need to do is fire off a list of functions that will build the user out
in our system. After each function, i want to return the status to the
page so the user can see whats happening...something like this.
Building User, while its working, display spinner,done.
Building Email, while its working, display spinner,done.
Building Address, while its working, display spinner,done.
etc....
clearly php wont work, im guessing ajax? how would i begin? first i would
need to get the POST into jquery vars.... and then fire off ajax function
for user, get response, then fire off ajax function for email, and so
on....
I have no code because I don't even know where to start.
I am working on a script that builds a user in our system. I compile all
the data, and end up with a form POST array with all the data i need. What
i need to do is fire off a list of functions that will build the user out
in our system. After each function, i want to return the status to the
page so the user can see whats happening...something like this.
Building User, while its working, display spinner,done.
Building Email, while its working, display spinner,done.
Building Address, while its working, display spinner,done.
etc....
clearly php wont work, im guessing ajax? how would i begin? first i would
need to get the POST into jquery vars.... and then fire off ajax function
for user, get response, then fire off ajax function for email, and so
on....
I have no code because I don't even know where to start.
preg_split but ignore XML and HTML entities
preg_split but ignore XML and HTML entities
I using this php code to split a string roughly every 120 chars. IT splits
at the closest space. But it splits HTML and XML entities, so it sometimes
outputs things like: id="id">. how can i make it so it ignores xml and
html entities, but does not remove them.
function splitWords($string, $max = 1)
{
$words = preg_split( '/\s/', $string );
$lines = array();
$line = '';
foreach ( $words as $k => $word ) {
$newLine = $line . ' ' . $word;
$length = strlen( $newLine );
if ( $length <= $max ) {
$line .= ' ' . $word;
} else if ( $length > $max ) {
if ( !empty( $line ) ) {
$lines[] = trim( $line );
}
$line = $word;
} else {
$lines[] = trim( $line ) . ' ' . $word;
$line = '';
}
}
$lines[] = ( $line = trim( $line ) ) ? $line : $word;
return $lines;
}
thanks
Rob
I using this php code to split a string roughly every 120 chars. IT splits
at the closest space. But it splits HTML and XML entities, so it sometimes
outputs things like: id="id">. how can i make it so it ignores xml and
html entities, but does not remove them.
function splitWords($string, $max = 1)
{
$words = preg_split( '/\s/', $string );
$lines = array();
$line = '';
foreach ( $words as $k => $word ) {
$newLine = $line . ' ' . $word;
$length = strlen( $newLine );
if ( $length <= $max ) {
$line .= ' ' . $word;
} else if ( $length > $max ) {
if ( !empty( $line ) ) {
$lines[] = trim( $line );
}
$line = $word;
} else {
$lines[] = trim( $line ) . ' ' . $word;
$line = '';
}
}
$lines[] = ( $line = trim( $line ) ) ? $line : $word;
return $lines;
}
thanks
Rob
SQL Query vs Stored Procedures
SQL Query vs Stored Procedures
I am beginner in database. I have knowledge of SQL Queries and very basic
knowledge of Stored Procedures. I have learnt both SQL Queeries and Stored
Procedures but I dont know difference between them, I want to know that in
which condition I should choose one of them. Waiting for kind reply.
Thanks in advance.
PS :- If possible, suggest me some online content.
I am beginner in database. I have knowledge of SQL Queries and very basic
knowledge of Stored Procedures. I have learnt both SQL Queeries and Stored
Procedures but I dont know difference between them, I want to know that in
which condition I should choose one of them. Waiting for kind reply.
Thanks in advance.
PS :- If possible, suggest me some online content.
C# drag controls around a panel
C# drag controls around a panel
i am developing a system which allow user to drag objects around within a
same panel, i went through some research and founds that i should use
mouse events like mouse_up, mouse_down and mouse_move.
The the program will generate 3 picturebox and allow the user to drag
around the every picturebox within the panel, but the program i code did
not work perfectly as when i drag over a picturebox, the picturebox will
move, but not according to my mouse cursor location, it is somewhere else,
besides, when dragging, there is picturebox shadows in the panel, i've
tried those update(),refresh(), and invalidate() but it seems not useful
for me. Below are my codes, thanks for helping
public partial class Form1 : Form
{
List<PictureBox> pictureBoxList = new List<PictureBox>();
private bool isDragging = false;
public Form1()
{
InitializeComponent();
for (int i = 0; i < 3; i++)
{
PictureBox picture = new PictureBox
{
Name = "pictureBox" + i,
Size = new Size(20, 20),
Location = new Point(i * 40, i * 40),
BorderStyle = BorderStyle.FixedSingle,
SizeMode = PictureBoxSizeMode.Zoom,
ImageLocation = "A.jpg"
};
pictureBoxList.Add(picture);
foreach (PictureBox p in pictureBoxList)
{
p.MouseDown += new MouseEventHandler(c_MouseDown);
p.MouseMove += new MouseEventHandler(c_MouseMove);
p.MouseUp += new MouseEventHandler(c_MouseUp);
pnlDisplayImage.Controls.Add(p);
pnlDisplayImage.Refresh();
}
}
}
void c_MouseDown(object sender, MouseEventArgs e)
{
isDragging = true;
}
void c_MouseMove(object sender, MouseEventArgs e)
{
if (isDragging == true) {
Control c = sender as Control;
for (int i = 0; i < pictureBoxList.Count(); i++)
{
if (c.Equals(pictureBoxList[i]))
{
pictureBoxList[i].Location = new Point(e.X, e.Y);
}
}
}
}
void c_MouseUp(object sender, MouseEventArgs e)
{
PictureBox c = sender as PictureBox;
c.Location = pnlDisplayImage.PointToClient(new Point(e.X, e.Y));
pnlDisplayImage.Controls.Add(c);
isDragging = false;
for (int i = 0; i < pictureBoxList.Count(); i++) {
if (c.Equals(pictureBoxList[i])){
pictureBoxList[i].Location = new Point(e.X, e.Y);
}
}
}
private void pnlDisplayImage_Paint(object sender, PaintEventArgs e)
{
foreach (PictureBox p in pictureBoxList)
{
pnlDisplayImage.Controls.Add(p);
}
}
}
i am developing a system which allow user to drag objects around within a
same panel, i went through some research and founds that i should use
mouse events like mouse_up, mouse_down and mouse_move.
The the program will generate 3 picturebox and allow the user to drag
around the every picturebox within the panel, but the program i code did
not work perfectly as when i drag over a picturebox, the picturebox will
move, but not according to my mouse cursor location, it is somewhere else,
besides, when dragging, there is picturebox shadows in the panel, i've
tried those update(),refresh(), and invalidate() but it seems not useful
for me. Below are my codes, thanks for helping
public partial class Form1 : Form
{
List<PictureBox> pictureBoxList = new List<PictureBox>();
private bool isDragging = false;
public Form1()
{
InitializeComponent();
for (int i = 0; i < 3; i++)
{
PictureBox picture = new PictureBox
{
Name = "pictureBox" + i,
Size = new Size(20, 20),
Location = new Point(i * 40, i * 40),
BorderStyle = BorderStyle.FixedSingle,
SizeMode = PictureBoxSizeMode.Zoom,
ImageLocation = "A.jpg"
};
pictureBoxList.Add(picture);
foreach (PictureBox p in pictureBoxList)
{
p.MouseDown += new MouseEventHandler(c_MouseDown);
p.MouseMove += new MouseEventHandler(c_MouseMove);
p.MouseUp += new MouseEventHandler(c_MouseUp);
pnlDisplayImage.Controls.Add(p);
pnlDisplayImage.Refresh();
}
}
}
void c_MouseDown(object sender, MouseEventArgs e)
{
isDragging = true;
}
void c_MouseMove(object sender, MouseEventArgs e)
{
if (isDragging == true) {
Control c = sender as Control;
for (int i = 0; i < pictureBoxList.Count(); i++)
{
if (c.Equals(pictureBoxList[i]))
{
pictureBoxList[i].Location = new Point(e.X, e.Y);
}
}
}
}
void c_MouseUp(object sender, MouseEventArgs e)
{
PictureBox c = sender as PictureBox;
c.Location = pnlDisplayImage.PointToClient(new Point(e.X, e.Y));
pnlDisplayImage.Controls.Add(c);
isDragging = false;
for (int i = 0; i < pictureBoxList.Count(); i++) {
if (c.Equals(pictureBoxList[i])){
pictureBoxList[i].Location = new Point(e.X, e.Y);
}
}
}
private void pnlDisplayImage_Paint(object sender, PaintEventArgs e)
{
foreach (PictureBox p in pictureBoxList)
{
pnlDisplayImage.Controls.Add(p);
}
}
}
Monday, 19 August 2013
What happened to the jockey-gtk command?
What happened to the jockey-gtk command?
I installed the jockey-gtk package using the following command:
nathan@ubuntu:~$ sudo apt-get install jockey-gtk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
jockey-gtk
0 upgraded, 1 newly installed, 0 to remove and 176 not upgraded.
Need to get 3,228 B/3,228 B of archives.
After this operation, 53.2 kB of additional disk space will be used.
Selecting previously unselected package jockey-gtk.
(Reading database ... 153816 files and directories currently installed.)
Unpacking jockey-gtk (from .../jockey-gtk_0.9.7-0ubuntu13_all.deb) ...
Setting up jockey-gtk (0.9.7-0ubuntu13) ...
But when I attempt to actually run the command:
nathan@ubuntu:~$ jockey-gtk
The program 'jockey-gtk' is currently not installed. You can install it by
typing:
sudo apt-get install jockey-gtk
Why am I receiving this error message? I just installed the package!
This machine is running Ubuntu 13.04 64-bit - which I installed only
yesterday.
I installed the jockey-gtk package using the following command:
nathan@ubuntu:~$ sudo apt-get install jockey-gtk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
jockey-gtk
0 upgraded, 1 newly installed, 0 to remove and 176 not upgraded.
Need to get 3,228 B/3,228 B of archives.
After this operation, 53.2 kB of additional disk space will be used.
Selecting previously unselected package jockey-gtk.
(Reading database ... 153816 files and directories currently installed.)
Unpacking jockey-gtk (from .../jockey-gtk_0.9.7-0ubuntu13_all.deb) ...
Setting up jockey-gtk (0.9.7-0ubuntu13) ...
But when I attempt to actually run the command:
nathan@ubuntu:~$ jockey-gtk
The program 'jockey-gtk' is currently not installed. You can install it by
typing:
sudo apt-get install jockey-gtk
Why am I receiving this error message? I just installed the package!
This machine is running Ubuntu 13.04 64-bit - which I installed only
yesterday.
C++ Access private member of subclass from superclass
C++ Access private member of subclass from superclass
The title might be a bit misleading. I have the following problem: I have
a tree consisting of leaves and internal nodes. The user should be able to
store any information in the leaves and the tree has some methods which
get a set of user-defined values and need to access the corresponding
leaves in constant time (not amortized).
I came up with the following idea but it does not work because
unfortunately I cannot access private members of a subclass: The user
creates the tree and also for each leaf an instance of UserElement which
contains the user_defined value for the corresponding leaf. Once a method
like doSomethingWithTheTree(list>) is called and the tree is built, the
tree creates the corresponding leaves and saves it in the private field
leaf. Whenever the user wants to call a method with some of the leaves
corresponding to its user_defined values, he/she just has to call the
method by giving the corresponding UserElements and the tree can retrieve
the corresponding leaves in constant time.
class Tree {
public:
template <typename T>
class UserElement {
private:
T user_value;
tree_node* leaf; // this has to be private for
// everyone outside the class `Tree`
public:
T getInf() {
return user_value;
}
void setInf(T i) {
user_value = i;
}
};
void doSomethingWithTheTree(list<UserElement<T>> elements) {
...
// I want to be able to access elem.leaf for all elements
}
}
The title might be a bit misleading. I have the following problem: I have
a tree consisting of leaves and internal nodes. The user should be able to
store any information in the leaves and the tree has some methods which
get a set of user-defined values and need to access the corresponding
leaves in constant time (not amortized).
I came up with the following idea but it does not work because
unfortunately I cannot access private members of a subclass: The user
creates the tree and also for each leaf an instance of UserElement which
contains the user_defined value for the corresponding leaf. Once a method
like doSomethingWithTheTree(list>) is called and the tree is built, the
tree creates the corresponding leaves and saves it in the private field
leaf. Whenever the user wants to call a method with some of the leaves
corresponding to its user_defined values, he/she just has to call the
method by giving the corresponding UserElements and the tree can retrieve
the corresponding leaves in constant time.
class Tree {
public:
template <typename T>
class UserElement {
private:
T user_value;
tree_node* leaf; // this has to be private for
// everyone outside the class `Tree`
public:
T getInf() {
return user_value;
}
void setInf(T i) {
user_value = i;
}
};
void doSomethingWithTheTree(list<UserElement<T>> elements) {
...
// I want to be able to access elem.leaf for all elements
}
}
matlab curve fitting: restrictions on parameters
matlab curve fitting: restrictions on parameters
I have 5 non-parametric models all with 5 to 8 parameters. This models are
used to fit longitudinal data y(t) with t being time. Every datafile is
fitted by all 5 models for comparison. The model itself cannot be altered.
For fitting starting values are used and these are fitted into a
lsqcurvefit model using a levenberg-marquardt algortihm. So I've written a
script for several models and one function for curvefitting
if i perform the curve fitting a lot of the starting values are wandering
off to extreme values. This is the thing I want to avoid since these
parameters should stay in the proximity off it's starting values and
should only change between a well defined range or so that only curve fits
within a standard deviation are included.Important to note here is that
this restrictions should be imposed during the curve fitting (iterative
numerization techique) and not afterwards.
The function I've written to fit models into height:
% Fit a specific model for all valid persons
try
opts = optimoptions(@lsqcurvefit, 'Algorithm',
'levenberg-marquardt');
[personalParams,personalRes,personalResidual] =
lsqcurvefit(heightModel,initialValues,personalData(:,1),personalData(:,2),[],[],opts);
catch
x=1;
end
The function I've written for one of my models
elseif strcmpi(model,'jpss')
% y =
h_1(1-(1/(1+((t+0.75)^c_1/d_1)+((t+0.75)^c_2/d_2)+((t+0.75)^c_3/d_3)))
% heightModel = @(params,ages)
params(1).*(1-1./(1+((ages+0.75).^params(2))./params(3) +
((ages+0.75).^params(4))./params(5) +
((ages+0.75).^params(6))./params(7)));
heightModel = @(params,ages)
params(1).*(1-1./(1+(((ages+0.75)./params(3)).^params(2)) +
(((ages+0.75)./params(5)).^params(4)) +
((ages+0.75)./params(7)).^params(6))); % Adapted 25/07
modelStrings = {'h1','c1','d1','c2','d2','c3','d3'};
% Define initial values
if strcmpi('male',gender)
initialValues = [174.8 0.6109 2.9743 3.614 9.88 22.393 13.59];
else
initialValues = [162.7 0.6546 2.43 4.011 8.579 18.394 11.846];
end
What I would like to do:
Is it possible to place restrictions on every startingvalue @initial
values? Putting restrictions on lsqcurvefit wouldn't be a good idea I
think since there are different models with different starting values and
different ranges that are allowed.
I had 2 things in my mind: 1. using range and place this between the
initial values initialValues = [162.7 0.6546 2.43 4.011 8.579 18.394
11.846]` if range a1=[150,180]; range a2=[0.3,0.8] and so one
place lb and ub restrictions seperatly on all my initialvalues between
lsqcurvefit if Heightmodel='name model' initial value* 1.2 and lb =
initial value* 0.8
Can someone give me some hints or pointers because I can't make it work.
Thanks in advance
Lucy
Could somebody help me out
I have 5 non-parametric models all with 5 to 8 parameters. This models are
used to fit longitudinal data y(t) with t being time. Every datafile is
fitted by all 5 models for comparison. The model itself cannot be altered.
For fitting starting values are used and these are fitted into a
lsqcurvefit model using a levenberg-marquardt algortihm. So I've written a
script for several models and one function for curvefitting
if i perform the curve fitting a lot of the starting values are wandering
off to extreme values. This is the thing I want to avoid since these
parameters should stay in the proximity off it's starting values and
should only change between a well defined range or so that only curve fits
within a standard deviation are included.Important to note here is that
this restrictions should be imposed during the curve fitting (iterative
numerization techique) and not afterwards.
The function I've written to fit models into height:
% Fit a specific model for all valid persons
try
opts = optimoptions(@lsqcurvefit, 'Algorithm',
'levenberg-marquardt');
[personalParams,personalRes,personalResidual] =
lsqcurvefit(heightModel,initialValues,personalData(:,1),personalData(:,2),[],[],opts);
catch
x=1;
end
The function I've written for one of my models
elseif strcmpi(model,'jpss')
% y =
h_1(1-(1/(1+((t+0.75)^c_1/d_1)+((t+0.75)^c_2/d_2)+((t+0.75)^c_3/d_3)))
% heightModel = @(params,ages)
params(1).*(1-1./(1+((ages+0.75).^params(2))./params(3) +
((ages+0.75).^params(4))./params(5) +
((ages+0.75).^params(6))./params(7)));
heightModel = @(params,ages)
params(1).*(1-1./(1+(((ages+0.75)./params(3)).^params(2)) +
(((ages+0.75)./params(5)).^params(4)) +
((ages+0.75)./params(7)).^params(6))); % Adapted 25/07
modelStrings = {'h1','c1','d1','c2','d2','c3','d3'};
% Define initial values
if strcmpi('male',gender)
initialValues = [174.8 0.6109 2.9743 3.614 9.88 22.393 13.59];
else
initialValues = [162.7 0.6546 2.43 4.011 8.579 18.394 11.846];
end
What I would like to do:
Is it possible to place restrictions on every startingvalue @initial
values? Putting restrictions on lsqcurvefit wouldn't be a good idea I
think since there are different models with different starting values and
different ranges that are allowed.
I had 2 things in my mind: 1. using range and place this between the
initial values initialValues = [162.7 0.6546 2.43 4.011 8.579 18.394
11.846]` if range a1=[150,180]; range a2=[0.3,0.8] and so one
place lb and ub restrictions seperatly on all my initialvalues between
lsqcurvefit if Heightmodel='name model' initial value* 1.2 and lb =
initial value* 0.8
Can someone give me some hints or pointers because I can't make it work.
Thanks in advance
Lucy
Could somebody help me out
Sunday, 18 August 2013
how to Customize the c++ delete
how to Customize the c++ delete
i write a function 'myDelete' do someing like delete
template<typename T>
void myDelete(T* p)
{
dosoming...........
p->~T();
free(p);
}
but when the point 'p' is a point to a base class, is error when free
test code :
struct base0
{
int _;
virtual ~base0() {}
};
struct base1
{
int _;
virtual ~base1() {}
}
struct dev : public base0, public base1
{
int _;
virtual ~dev() {}
}
base1* p = new dev();
myDelete(p); // error, because p is adjust by base1
how to write the function meDelete?
i write a function 'myDelete' do someing like delete
template<typename T>
void myDelete(T* p)
{
dosoming...........
p->~T();
free(p);
}
but when the point 'p' is a point to a base class, is error when free
test code :
struct base0
{
int _;
virtual ~base0() {}
};
struct base1
{
int _;
virtual ~base1() {}
}
struct dev : public base0, public base1
{
int _;
virtual ~dev() {}
}
base1* p = new dev();
myDelete(p); // error, because p is adjust by base1
how to write the function meDelete?
What to get when signing an agreement
What to get when signing an agreement
I made a proposal/estimate system over the internet (PHP) and I need the
customer to agree terms and conditions and sign it online. Besides
personal information, IP address and date and time, what other information
should I store to avoid (legal) problems in the future?
I made a proposal/estimate system over the internet (PHP) and I need the
customer to agree terms and conditions and sign it online. Besides
personal information, IP address and date and time, what other information
should I store to avoid (legal) problems in the future?
proving boundedness of a linear functional
proving boundedness of a linear functional
Let $f$ be a linear functional on a normed vector space V and
$f^{-1}(\{0\})$ is closed. Prove that $f$ is bounded
Let $f$ be a linear functional on a normed vector space V and
$f^{-1}(\{0\})$ is closed. Prove that $f$ is bounded
iptables Applying firewall rules
iptables Applying firewall rules
I have two servers, when I restart iptables on the first server it does
"Applying firewall rules" but on the second does'nt. What's the problem
with the second server ?
First server:
[root@test ~]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
Second server:
[root@test ~]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: nat [ OK ]
iptables: Unloading modules: [ OK ]
Thank you.
I have two servers, when I restart iptables on the first server it does
"Applying firewall rules" but on the second does'nt. What's the problem
with the second server ?
First server:
[root@test ~]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
Second server:
[root@test ~]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: nat [ OK ]
iptables: Unloading modules: [ OK ]
Thank you.
Why entity framework uses set transaction isolation level read committed and what this means
Why entity framework uses "set transaction isolation level read committed"
and what this means
I am using enttiy framework, and I have tracked the sql server using sql
server profiler. And I found that when I query the database using EF , the
sql profiler will show the following :-
set transaction isolation level read committed.
So what does this means ?
and what this means
I am using enttiy framework, and I have tracked the sql server using sql
server profiler. And I found that when I query the database using EF , the
sql profiler will show the following :-
set transaction isolation level read committed.
So what does this means ?
What variable type to use for parameter LPVOID lpBuffer in C++ functions WriteFile and ReadFile
What variable type to use for parameter LPVOID lpBuffer in C++ functions
WriteFile and ReadFile
pWhat variable type should be used for stronglpBuffer/strong of C++
codeReadFile/code and codeWriteFile/code functions to communicate between
a Windows XP based PC and a micro-controller based system? The PC has
WinForm application in VS2010 C++/CLI. The micro-controller firmware is
ANSI C./p pMy PC is supposed to transmit command characters (say 'S', 'C'
etc) followed by command termination character code0xd/code (hex for
decimal 13). The micro-controller based system would respond with 5 to 10
bytes that would be mix of ASCII characters and hex numbers e.g. 'V'
followed by code0x41/code code0x72/code etc./p pstrongPC transmits and
micro-controller receives:/strong/p ol lipcodeTxMessage/code, codePP1/code
and codepTx/code declared as codechar/code and keeping
codenNumberOfBytesToWrite/code as 2, makes the micro-controller receive
code0x53/code for 'S' followed by code0xC3/code instead of
code0xd/code./p/li lipcodeTxMessage/code, codePP1/code and codepTx/code
declared as codewchar_t/code and keeping codenNumberOfBytesToWrite/code as
2, makes the micro-controller receive code0x53/code for 'S' only./p/li
lipcodeTxMessage/code, codePP1/code and codepTx/code declared as
codewchar_t/code and keeping codenNumberOfBytesToWrite/code as 4, makes
the micro-controller receive code0x53/code for 'S' followed by
code0xd/code correctly./p/li /ol pThe third scheme of transmit and receive
above meets my expected behavior of a solution. But the confusion is here:
Although the PC might be transmitting 4 bytes (for two codewchar/code
types), the micro-controller receives 2 bytes code0x53/code for 'S',
correctly followed by code0xD/code./p pstrongMicro-controller transmits
and PC receives:/strong/p pAssuming that codewchar_t/code is the right
choice for codelpBuffer/code, strongwhat should be my
codenNumberOfBytesToRead/code/strong for receiving 10 bytes from the
micro-controller? ReadFile would expect 20 bytes by virtue of
codewchar_t/code, whereas the micro-controller would transmit 10 bytes
only./p pAmazingly, irrespective of declaring (codeRxMessage/code,
codePP2/code and codepRx/code) as codewchar_t/code, codechar/code or
codeunsigned char/code, ReadFile receives 10 bytes from the
micro-controller (meets my expected behavior of a solution). But the issue
is that transmitting 'A' 10 times from the micro-controller, ReadFile on
the PC's end receives junk like 'S', code0x0/code, code0xd/code,
code0x54/code, code0x29/code./p precode/// Required designer variable.
HANDLE hCommPort; BOOL fSuccess; arraylt;wchar_tgt; ^ TxMessage;
arraylt;unsigned chargt; ^ RxMessage; TxMessage = gcnew arraylt;wchar_tgt;
(12); RxMessage = gcnew arraylt;unsigned chargt; (12); {
TxMessage[0]='S';//target cmd TxMessage[1]=0xd;//cmd termination character
DWORD dwhandled; if (hCommPort != INVALID_HANDLE_VALUE) {
pin_ptrlt;wchar_tgt; pp1 = amp;TxMessage[0]; wchar_t *pTx = pp1; fSuccess
= WriteFile(hCommPort, pTx, 4, amp;dwhandled, NULL); PurgeComm(hCommPort,
PURGE_RXABORT|PURGE_TXABORT|PURGE_RXCLEAR|PURGE_TXCLEAR);
pin_ptrlt;unsigned chargt; pp2 = amp;RxMessage[0]; unsigned char *pRx =
pp2; fSuccess = ReadFile(hCommPort, pRx, 10, amp;dwhandled, NULL); }//if
IsOpen else{ this-gt;toolStripStatusLabel4-gt;Text=Port Not Opened;} }
/code/pre
WriteFile and ReadFile
pWhat variable type should be used for stronglpBuffer/strong of C++
codeReadFile/code and codeWriteFile/code functions to communicate between
a Windows XP based PC and a micro-controller based system? The PC has
WinForm application in VS2010 C++/CLI. The micro-controller firmware is
ANSI C./p pMy PC is supposed to transmit command characters (say 'S', 'C'
etc) followed by command termination character code0xd/code (hex for
decimal 13). The micro-controller based system would respond with 5 to 10
bytes that would be mix of ASCII characters and hex numbers e.g. 'V'
followed by code0x41/code code0x72/code etc./p pstrongPC transmits and
micro-controller receives:/strong/p ol lipcodeTxMessage/code, codePP1/code
and codepTx/code declared as codechar/code and keeping
codenNumberOfBytesToWrite/code as 2, makes the micro-controller receive
code0x53/code for 'S' followed by code0xC3/code instead of
code0xd/code./p/li lipcodeTxMessage/code, codePP1/code and codepTx/code
declared as codewchar_t/code and keeping codenNumberOfBytesToWrite/code as
2, makes the micro-controller receive code0x53/code for 'S' only./p/li
lipcodeTxMessage/code, codePP1/code and codepTx/code declared as
codewchar_t/code and keeping codenNumberOfBytesToWrite/code as 4, makes
the micro-controller receive code0x53/code for 'S' followed by
code0xd/code correctly./p/li /ol pThe third scheme of transmit and receive
above meets my expected behavior of a solution. But the confusion is here:
Although the PC might be transmitting 4 bytes (for two codewchar/code
types), the micro-controller receives 2 bytes code0x53/code for 'S',
correctly followed by code0xD/code./p pstrongMicro-controller transmits
and PC receives:/strong/p pAssuming that codewchar_t/code is the right
choice for codelpBuffer/code, strongwhat should be my
codenNumberOfBytesToRead/code/strong for receiving 10 bytes from the
micro-controller? ReadFile would expect 20 bytes by virtue of
codewchar_t/code, whereas the micro-controller would transmit 10 bytes
only./p pAmazingly, irrespective of declaring (codeRxMessage/code,
codePP2/code and codepRx/code) as codewchar_t/code, codechar/code or
codeunsigned char/code, ReadFile receives 10 bytes from the
micro-controller (meets my expected behavior of a solution). But the issue
is that transmitting 'A' 10 times from the micro-controller, ReadFile on
the PC's end receives junk like 'S', code0x0/code, code0xd/code,
code0x54/code, code0x29/code./p precode/// Required designer variable.
HANDLE hCommPort; BOOL fSuccess; arraylt;wchar_tgt; ^ TxMessage;
arraylt;unsigned chargt; ^ RxMessage; TxMessage = gcnew arraylt;wchar_tgt;
(12); RxMessage = gcnew arraylt;unsigned chargt; (12); {
TxMessage[0]='S';//target cmd TxMessage[1]=0xd;//cmd termination character
DWORD dwhandled; if (hCommPort != INVALID_HANDLE_VALUE) {
pin_ptrlt;wchar_tgt; pp1 = amp;TxMessage[0]; wchar_t *pTx = pp1; fSuccess
= WriteFile(hCommPort, pTx, 4, amp;dwhandled, NULL); PurgeComm(hCommPort,
PURGE_RXABORT|PURGE_TXABORT|PURGE_RXCLEAR|PURGE_TXCLEAR);
pin_ptrlt;unsigned chargt; pp2 = amp;RxMessage[0]; unsigned char *pRx =
pp2; fSuccess = ReadFile(hCommPort, pRx, 10, amp;dwhandled, NULL); }//if
IsOpen else{ this-gt;toolStripStatusLabel4-gt;Text=Port Not Opened;} }
/code/pre
Subscribe to:
Comments (Atom)