Play nice, node-formidable and express.bodyParser
I used to do app.use(express.bodyParser()); to allow me to get POST bodies
in my ordinary (non-file) routes.
I then had to implement multi-file uploads, so I introduced
node-formidable. For the the only single route for which I need
node-formidable's functionality, I instantiate it explicitly and use it
from there:
var form = new formidable.IncomingForm({ uploadDir:__dirname +
'/public/uploads' });
What I now need is to get back to being able to parse textual POST data
without having formidable interfere with that. Sadly, as soon as I
reintroduce app.use(express.bodyParser()); into my script, then attempts
to parse images using node-formidable as described above, will fail.
Is there any easy way to get around this? Can I not use node-formidable's
bodyParser to deal with everything? If so, how would I do that?
Tuesday, 10 September 2013
Why not working to write into a txt file with PHP
Why not working to write into a txt file with PHP
I am trying to write some simple text into a text file but writing is not
working, Below is the code I am using: what is the wrong with the code
please??
<?php
// create short variable names
$tireqty = 24;
$oilqty = 34;
$sparkqty = 12;
echo "<p>Your order is as follows: </p>";
echo $tireqty." tires<br />";
echo $oilqty." bottles of oil<br />";
echo $sparkqty." spark plugs<br />";
@ $fp=fopen("/order.txt","w");
if(!$fp){
echo "The file is not exists";
exit;
}
$outputstring = $date.'\t'.$tireqty.' tires \t'.$oilqty.' oil\t'
.$sparkqty.' spark plugs\t\$'.$totalamount.'\t'. $address.'\n';
fwrite($fp, $outputstring);
fclose($fp);
echo "Order have written into order.txt";
I am trying to write some simple text into a text file but writing is not
working, Below is the code I am using: what is the wrong with the code
please??
<?php
// create short variable names
$tireqty = 24;
$oilqty = 34;
$sparkqty = 12;
echo "<p>Your order is as follows: </p>";
echo $tireqty." tires<br />";
echo $oilqty." bottles of oil<br />";
echo $sparkqty." spark plugs<br />";
@ $fp=fopen("/order.txt","w");
if(!$fp){
echo "The file is not exists";
exit;
}
$outputstring = $date.'\t'.$tireqty.' tires \t'.$oilqty.' oil\t'
.$sparkqty.' spark plugs\t\$'.$totalamount.'\t'. $address.'\n';
fwrite($fp, $outputstring);
fclose($fp);
echo "Order have written into order.txt";
refreshing the action bar spinner after database changes
refreshing the action bar spinner after database changes
I have an action bar spinner in one activity that gets populated using
data from a database. I have a second activity that modifies the database
(including data for the action bar spinner that is used in the first
activity). How do I refresh the spinner once database changes ? I tried
notifyDataSetChanged();, doesn't work. Also when I restart the app after
doing the changes, they are reflected in the spinner so I can see
modifying works, but only when I run the app again, not as the changes are
being made
// this is inside the onCreate()
// return a List<String> used to populate action bar spinner
listUniqueCat = mDbHelper.getUniqueCategories();
// create an array adapter to popluate dropdown list
adapter = new ArrayAdapter<String>(
getBaseContext(),
android.R.layout.simple_spinner_dropdown_item, listUniqueCat);
// enable dropdown list naaavigation in action bar
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
// defining navigation listiner
ActionBar.OnNavigationListener navigationListener = new
OnNavigationListener() {
@Override
public boolean onNavigationItemSelected(int itemPosition,
long itemId) {
selectedPos = getActionBar().getSelectedNavigationIndex();
selectedSpinnerItem = listUniqueCat.get(selectedPos);
Toast.makeText(getBaseContext(),
"you selected " + selectedSpinnerItem,
Toast.LENGTH_LONG).show();
return false;
}
};
// setting dropdown items and item navigation listener for action bar
getActionBar().setListNavigationCallbacks(adapter, navigationListener);
I have an action bar spinner in one activity that gets populated using
data from a database. I have a second activity that modifies the database
(including data for the action bar spinner that is used in the first
activity). How do I refresh the spinner once database changes ? I tried
notifyDataSetChanged();, doesn't work. Also when I restart the app after
doing the changes, they are reflected in the spinner so I can see
modifying works, but only when I run the app again, not as the changes are
being made
// this is inside the onCreate()
// return a List<String> used to populate action bar spinner
listUniqueCat = mDbHelper.getUniqueCategories();
// create an array adapter to popluate dropdown list
adapter = new ArrayAdapter<String>(
getBaseContext(),
android.R.layout.simple_spinner_dropdown_item, listUniqueCat);
// enable dropdown list naaavigation in action bar
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
// defining navigation listiner
ActionBar.OnNavigationListener navigationListener = new
OnNavigationListener() {
@Override
public boolean onNavigationItemSelected(int itemPosition,
long itemId) {
selectedPos = getActionBar().getSelectedNavigationIndex();
selectedSpinnerItem = listUniqueCat.get(selectedPos);
Toast.makeText(getBaseContext(),
"you selected " + selectedSpinnerItem,
Toast.LENGTH_LONG).show();
return false;
}
};
// setting dropdown items and item navigation listener for action bar
getActionBar().setListNavigationCallbacks(adapter, navigationListener);
Monday, 9 September 2013
how do i insert a huge amount of data rows from a CSV to MYSQL?
how do i insert a huge amount of data rows from a CSV to MYSQL?
I have an Excel document (15KB) extracted as .CSV from a monitoring
platform that uses 1 column ip address but contains 1048576 Rows.
how do i insert all this data on my MYSQL database?
also, i have 10 of these excel documents each document maximizes the excel
total rows. so i have a total of 10485760 rows to use.
does MYSQL the appropriate database to use?
i needed to check these data from time to time, but im not sure where to
store them and look/search for a specific row easily when i needed to.
p.s: i dont work for the NSA
I have an Excel document (15KB) extracted as .CSV from a monitoring
platform that uses 1 column ip address but contains 1048576 Rows.
how do i insert all this data on my MYSQL database?
also, i have 10 of these excel documents each document maximizes the excel
total rows. so i have a total of 10485760 rows to use.
does MYSQL the appropriate database to use?
i needed to check these data from time to time, but im not sure where to
store them and look/search for a specific row easily when i needed to.
p.s: i dont work for the NSA
DiscoverMeteor: Commit 2-2
DiscoverMeteor: Commit 2-2
Right after adding bootstrap (after commit 2-1), the font of the main page
changed, even though microscope.css is still empty. I could not find any
other stylesheets in the microscope directory. How was the style applied?
Right after adding bootstrap (after commit 2-1), the font of the main page
changed, even though microscope.css is still empty. I could not find any
other stylesheets in the microscope directory. How was the style applied?
Urgent help required
Urgent help required
I'm trying to do the following but it is not working properly:
In my project I have several forms. In some forms I have a lookup button.
What I'm trying to do is- when the lookup button is clicked, another form
with a datagrid is openned and some records are displayed on the grid
(from SQL Server). Up to this point there is no problem. The next what I
want is- when a record on the grid is clicked, the relevant record will be
displayed in a text box in the from. This only works inone form. It does
not work in any other form. Here is the code I'm using-
Private Sub dtGrid_Click(sender As Object, e As EventArgs) Handles
dtGrid.Click Dim i As Integer
i = dtGrid.CurrentRow.Index
Try
frmServicing.txtRego.Text = dtGrid.Item(0, i).Value
frmVehicle.txtcCode.Text = dtGrid.Item(0, i).Value
frmVehicle.txtAllocation.Text = dtGrid.Item(1, i).Value
Catch ex As Exception
End Try
It only works for frmVehicle. I tried all possible ways but no luck. Any
idea?
End Sub
I'm trying to do the following but it is not working properly:
In my project I have several forms. In some forms I have a lookup button.
What I'm trying to do is- when the lookup button is clicked, another form
with a datagrid is openned and some records are displayed on the grid
(from SQL Server). Up to this point there is no problem. The next what I
want is- when a record on the grid is clicked, the relevant record will be
displayed in a text box in the from. This only works inone form. It does
not work in any other form. Here is the code I'm using-
Private Sub dtGrid_Click(sender As Object, e As EventArgs) Handles
dtGrid.Click Dim i As Integer
i = dtGrid.CurrentRow.Index
Try
frmServicing.txtRego.Text = dtGrid.Item(0, i).Value
frmVehicle.txtcCode.Text = dtGrid.Item(0, i).Value
frmVehicle.txtAllocation.Text = dtGrid.Item(1, i).Value
Catch ex As Exception
End Try
It only works for frmVehicle. I tried all possible ways but no luck. Any
idea?
End Sub
Java Scanner do-while Lack of Recognition Issue
Java Scanner do-while Lack of Recognition Issue
I have created a do-loop to continue iterating until the user enters a
word starting with Y or N, originally using a primitive check on a char
and now using the methods outlined below to check strings for equality.
With both comparison media, I found that even with 'y' or 'n' entered, the
loop would not exit. I cannot explain why, and hope that you can:
The following is the code:
do{
System.out.println("Please Enter a Valid y/n Reply:");
eraseOr_no = histScanner.next();
if(histScanner.hasNext()){
(eraseOr_no.replaceAll("\\s+", "")).toLowerCase();
character = Character.toString(eraseOr_no.charAt(0));
//DEBUGGING
System.out.println("CHECKPOINT 5" + "----" + character);
//DEBUGGING
}
}while(!(character.equals("n")) || !(character.equals("y")));
As is clear I have used a simply system to inform me of the value of the
String character, and as you may be able to see it is successfully
displaying the 'y' or 'n' meaning that my first-letter-retrieval code is
functioning, though the entire do structure is not.
Continue
Answer:
CHECKPOINT 4.0.
PLACEHOLDER
Please Enter a Valid y/n Reply:
y
y
CHECKPOINT 5----y
Please Enter a Valid y/n Reply:
y
CHECKPOINT 5----y
Please Enter a Valid y/n Reply:
n
CHECKPOINT 5----y
Please Enter a Valid y/n Reply:
y
CHECKPOINT 5----n
Please Enter a Valid y/n Reply:
Should I try to remove all whitespace? Am I missing something more
fundamental?
I have created a do-loop to continue iterating until the user enters a
word starting with Y or N, originally using a primitive check on a char
and now using the methods outlined below to check strings for equality.
With both comparison media, I found that even with 'y' or 'n' entered, the
loop would not exit. I cannot explain why, and hope that you can:
The following is the code:
do{
System.out.println("Please Enter a Valid y/n Reply:");
eraseOr_no = histScanner.next();
if(histScanner.hasNext()){
(eraseOr_no.replaceAll("\\s+", "")).toLowerCase();
character = Character.toString(eraseOr_no.charAt(0));
//DEBUGGING
System.out.println("CHECKPOINT 5" + "----" + character);
//DEBUGGING
}
}while(!(character.equals("n")) || !(character.equals("y")));
As is clear I have used a simply system to inform me of the value of the
String character, and as you may be able to see it is successfully
displaying the 'y' or 'n' meaning that my first-letter-retrieval code is
functioning, though the entire do structure is not.
Continue
Answer:
CHECKPOINT 4.0.
PLACEHOLDER
Please Enter a Valid y/n Reply:
y
y
CHECKPOINT 5----y
Please Enter a Valid y/n Reply:
y
CHECKPOINT 5----y
Please Enter a Valid y/n Reply:
n
CHECKPOINT 5----y
Please Enter a Valid y/n Reply:
y
CHECKPOINT 5----n
Please Enter a Valid y/n Reply:
Should I try to remove all whitespace? Am I missing something more
fundamental?
Subscribe to:
Posts (Atom)