I don't know how to use a fuction of the Scanner classs
so I have to do a Flask Machine assignment and I have a small problem with
the scanner class. I created a method in which I want to add the bottle
types(A B or C) to an arraylist. So I don't really know how many bottles I
will enter. The thing is I want my scanning to stop once I encounter a
,,0". I know I have to use a while loop but using it like this doesn't
work because by the time I want to add the bottle to the list, it jumps to
the next scanned bottle.
While(input.next()!="0"){
list.add(input.next());
count++;
}
Thursday, 3 October 2013
Wednesday, 2 October 2013
Activity com.example.mediastore.LoginActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView
Activity com.example.mediastore.LoginActivity has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView
I have a loginActivity that will redirect me to userViewActivity, but I
got these errors:
10-03 00:50:11.628: E/WindowManager(1820): Activity
com.example.mediastore.LoginActivity has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView{b558aee8 V.E.....
R.....ID 0,0-456,144} that was originally added here
10-03 00:50:11.628: E/WindowManager(1820): android.view.WindowLeaked:
Activity com.example.mediastore.LoginActivity has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView{b558aee8 V.E.....
R.....ID 0,0-456,144} that was originally added here
10-03 00:50:11.628: E/WindowManager(1820): at
android.view.ViewRootImpl.<init>(ViewRootImpl.java:354)
10-03 00:50:11.628: E/WindowManager(1820): at
android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:216)
10-03 00:50:11.628: E/WindowManager(1820): at
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
10-03 00:50:11.628: E/WindowManager(1820): at
android.app.Dialog.show(Dialog.java:281)
10-03 00:50:11.628: E/WindowManager(1820): at
com.example.mediastore.LoginActivity$userLogin.onPreExecute(LoginActivity.java:80)
10-03 00:50:11.628: E/WindowManager(1820): at
android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
10-03 00:50:11.628: E/WindowManager(1820): at
android.os.AsyncTask.execute(AsyncTask.java:534)
10-03 00:50:11.628: E/WindowManager(1820): at
com.example.mediastore.LoginActivity$1.onClick(LoginActivity.java:63)
10-03 00:50:11.628: E/WindowManager(1820): at
android.view.View.performClick(View.java:4202)
10-03 00:50:11.628: E/WindowManager(1820): at
android.view.View$PerformClick.run(View.java:17340)
10-03 00:50:11.628: E/WindowManager(1820): at
android.os.Handler.handleCallback(Handler.java:725)
10-03 00:50:11.628: E/WindowManager(1820): at
android.os.Handler.dispatchMessage(Handler.java:92)
10-03 00:50:11.628: E/WindowManager(1820): at
android.os.Looper.loop(Looper.java:137)
10-03 00:50:11.628: E/WindowManager(1820): at
android.app.ActivityThread.main(ActivityThread.java:5039)
10-03 00:50:11.628: E/WindowManager(1820): at
java.lang.reflect.Method.invokeNative(Native Method)
10-03 00:50:11.628: E/WindowManager(1820): at
java.lang.reflect.Method.invoke(Method.java:511)
10-03 00:50:11.628: E/WindowManager(1820): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-03 00:50:11.628: E/WindowManager(1820): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-03 00:50:11.628: E/WindowManager(1820): at
dalvik.system.NativeStart.main(Native Method)
and here is the loginActivity:
package com.example.mediastore;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;
import com.example.mediastore.JSONParser;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.InputFilter.LengthFilter;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class LoginActivity extends Activity {
Button login;
EditText inputusername;
EditText inputpassword;
private static String url_users =
"http://10.0.2.2/mediastore/android/usersLogin.php";
private ProgressDialog pDialog;
JSONParser jsonParser = new JSONParser();
private static final String TAG_SUCCESS = "success";
@Override
public void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
login = (Button) findViewById(R.id.loginbtn);
inputusername = (EditText) findViewById(R.id.username);
inputpassword = (EditText) findViewById(R.id.password);
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(v == login) {
login.setBackgroundDrawable(getResources().getDrawable(R.drawable.button2));
}
String u = inputusername.getText().toString();
String p = inputpassword.getText().toString();
if(u.equals("")||p.equals(""))
Toast.makeText(getApplicationContext(), "Please fill
these two fields", Toast.LENGTH_SHORT).show();
else
new userLogin().execute();
}
});
}
class userLogin extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(LoginActivity.this);
pDialog.setMessage("Logging user..");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Creating product
* */
@SuppressLint("ShowToast")
protected String doInBackground(String... args) {
String username = inputusername.getText().toString();
String password = inputpassword.getText().toString();
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("username", username));
params.add(new BasicNameValuePair("password", password));
// getting JSON Object
// Note that create product url accepts POST method
JSONObject json = jsonParser.makeHttpRequest(url_users,
"POST", params);
// check log cat fro response
Log.d("Login Response", json.toString());
// check for success tag
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// successfully created product
Intent i = new Intent(getApplicationContext(),
UserViewActivity.class);
startActivity(i);
// closing this screen
finish();
} else {
// failed to create product
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog once done
pDialog.dismiss();
}
}
}
I'am not familiar too much with android, can you help me to find a
solution for this problem please?
com.android.internal.policy.impl.PhoneWindow$DecorView
I have a loginActivity that will redirect me to userViewActivity, but I
got these errors:
10-03 00:50:11.628: E/WindowManager(1820): Activity
com.example.mediastore.LoginActivity has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView{b558aee8 V.E.....
R.....ID 0,0-456,144} that was originally added here
10-03 00:50:11.628: E/WindowManager(1820): android.view.WindowLeaked:
Activity com.example.mediastore.LoginActivity has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView{b558aee8 V.E.....
R.....ID 0,0-456,144} that was originally added here
10-03 00:50:11.628: E/WindowManager(1820): at
android.view.ViewRootImpl.<init>(ViewRootImpl.java:354)
10-03 00:50:11.628: E/WindowManager(1820): at
android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:216)
10-03 00:50:11.628: E/WindowManager(1820): at
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
10-03 00:50:11.628: E/WindowManager(1820): at
android.app.Dialog.show(Dialog.java:281)
10-03 00:50:11.628: E/WindowManager(1820): at
com.example.mediastore.LoginActivity$userLogin.onPreExecute(LoginActivity.java:80)
10-03 00:50:11.628: E/WindowManager(1820): at
android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
10-03 00:50:11.628: E/WindowManager(1820): at
android.os.AsyncTask.execute(AsyncTask.java:534)
10-03 00:50:11.628: E/WindowManager(1820): at
com.example.mediastore.LoginActivity$1.onClick(LoginActivity.java:63)
10-03 00:50:11.628: E/WindowManager(1820): at
android.view.View.performClick(View.java:4202)
10-03 00:50:11.628: E/WindowManager(1820): at
android.view.View$PerformClick.run(View.java:17340)
10-03 00:50:11.628: E/WindowManager(1820): at
android.os.Handler.handleCallback(Handler.java:725)
10-03 00:50:11.628: E/WindowManager(1820): at
android.os.Handler.dispatchMessage(Handler.java:92)
10-03 00:50:11.628: E/WindowManager(1820): at
android.os.Looper.loop(Looper.java:137)
10-03 00:50:11.628: E/WindowManager(1820): at
android.app.ActivityThread.main(ActivityThread.java:5039)
10-03 00:50:11.628: E/WindowManager(1820): at
java.lang.reflect.Method.invokeNative(Native Method)
10-03 00:50:11.628: E/WindowManager(1820): at
java.lang.reflect.Method.invoke(Method.java:511)
10-03 00:50:11.628: E/WindowManager(1820): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-03 00:50:11.628: E/WindowManager(1820): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-03 00:50:11.628: E/WindowManager(1820): at
dalvik.system.NativeStart.main(Native Method)
and here is the loginActivity:
package com.example.mediastore;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;
import com.example.mediastore.JSONParser;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.InputFilter.LengthFilter;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class LoginActivity extends Activity {
Button login;
EditText inputusername;
EditText inputpassword;
private static String url_users =
"http://10.0.2.2/mediastore/android/usersLogin.php";
private ProgressDialog pDialog;
JSONParser jsonParser = new JSONParser();
private static final String TAG_SUCCESS = "success";
@Override
public void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
login = (Button) findViewById(R.id.loginbtn);
inputusername = (EditText) findViewById(R.id.username);
inputpassword = (EditText) findViewById(R.id.password);
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(v == login) {
login.setBackgroundDrawable(getResources().getDrawable(R.drawable.button2));
}
String u = inputusername.getText().toString();
String p = inputpassword.getText().toString();
if(u.equals("")||p.equals(""))
Toast.makeText(getApplicationContext(), "Please fill
these two fields", Toast.LENGTH_SHORT).show();
else
new userLogin().execute();
}
});
}
class userLogin extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(LoginActivity.this);
pDialog.setMessage("Logging user..");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Creating product
* */
@SuppressLint("ShowToast")
protected String doInBackground(String... args) {
String username = inputusername.getText().toString();
String password = inputpassword.getText().toString();
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("username", username));
params.add(new BasicNameValuePair("password", password));
// getting JSON Object
// Note that create product url accepts POST method
JSONObject json = jsonParser.makeHttpRequest(url_users,
"POST", params);
// check log cat fro response
Log.d("Login Response", json.toString());
// check for success tag
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// successfully created product
Intent i = new Intent(getApplicationContext(),
UserViewActivity.class);
startActivity(i);
// closing this screen
finish();
} else {
// failed to create product
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog once done
pDialog.dismiss();
}
}
}
I'am not familiar too much with android, can you help me to find a
solution for this problem please?
C# - Gradient over picture in picturebox
C# - Gradient over picture in picturebox
I have developed an application in VB.NET that I'm now moving over to C#.
Everything is going smooth so far, but I'm facing one problem.
I have a pictureBox that has a picture in it. Over this picture box I want
a gradient to be that goes from transparent at top down to the color
"control" to blend in with the forms background color. I have allready
done this in VB.net which works, but when im trying to do this in C# the
gradient seems to be drawn, but behind the picture.
Here is what i have tried:
private void PictureBox1_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
Color top = Color.Transparent;
Color bottom = Color.FromKnownColor(KnownColor.Control);
GradientPictureBox(top, bottom, ref PictureBox1, e);
}
public void GradientPictureBox(Color topColor, Color bottomColor, ref
PictureBox PictureBox1, System.Windows.Forms.PaintEventArgs e)
{
LinearGradientMode direction = LinearGradientMode.Vertical;
LinearGradientBrush brush = new
LinearGradientBrush(PictureBox1.DisplayRectangle, topColor,
bottomColor, direction);
e.Graphics.FillRectangle(brush, PictureBox1.DisplayRectangle);
brush.Dispose();
}
However this does in fact seem to work, but again it paints the gradient
behind the picture. In VB.net it painted it on top of the picture without
any extra code..
Do i need to add anything extra?
If it matters im coding in C# 2010 express.
I have developed an application in VB.NET that I'm now moving over to C#.
Everything is going smooth so far, but I'm facing one problem.
I have a pictureBox that has a picture in it. Over this picture box I want
a gradient to be that goes from transparent at top down to the color
"control" to blend in with the forms background color. I have allready
done this in VB.net which works, but when im trying to do this in C# the
gradient seems to be drawn, but behind the picture.
Here is what i have tried:
private void PictureBox1_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
Color top = Color.Transparent;
Color bottom = Color.FromKnownColor(KnownColor.Control);
GradientPictureBox(top, bottom, ref PictureBox1, e);
}
public void GradientPictureBox(Color topColor, Color bottomColor, ref
PictureBox PictureBox1, System.Windows.Forms.PaintEventArgs e)
{
LinearGradientMode direction = LinearGradientMode.Vertical;
LinearGradientBrush brush = new
LinearGradientBrush(PictureBox1.DisplayRectangle, topColor,
bottomColor, direction);
e.Graphics.FillRectangle(brush, PictureBox1.DisplayRectangle);
brush.Dispose();
}
However this does in fact seem to work, but again it paints the gradient
behind the picture. In VB.net it painted it on top of the picture without
any extra code..
Do i need to add anything extra?
If it matters im coding in C# 2010 express.
How to implement smooth seeking in video with AVPlayer?
How to implement smooth seeking in video with AVPlayer?
When I seek to time with AVPlayer and a slider I get choppy results.
Seeking backwards stutters and lags a lot but seeking forwards is smooth.
[player seekToTime:CMTimeMakeWithSeconds(targetSeekTime, NSEC_PER_SEC)
toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];
Built-in camera app has much smoother seeking. Maybe there is a setting?
When I seek to time with AVPlayer and a slider I get choppy results.
Seeking backwards stutters and lags a lot but seeking forwards is smooth.
[player seekToTime:CMTimeMakeWithSeconds(targetSeekTime, NSEC_PER_SEC)
toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];
Built-in camera app has much smoother seeking. Maybe there is a setting?
legend placement issue in D3 Bar chart
legend placement issue in D3 Bar chart
I have a stacked bar chart. I want to place the legend, just above the
chart area ends and in centre like this
I have created a Fiddle HereLegend Fiddle
But I am facing issue in locating the legend at correct dimension. I know
some issue in
.attr("transform", function(d, i) { return "translate(-180," + i * 20 +
")"; });
Could you please help in placing legend at right location. Thanks Gunjan
I have a stacked bar chart. I want to place the legend, just above the
chart area ends and in centre like this
I have created a Fiddle HereLegend Fiddle
But I am facing issue in locating the legend at correct dimension. I know
some issue in
.attr("transform", function(d, i) { return "translate(-180," + i * 20 +
")"; });
Could you please help in placing legend at right location. Thanks Gunjan
Tuesday, 1 October 2013
A little confusion about compactness and connectedness
A little confusion about compactness and connectedness
This question may be a bit simple or even naive for some people but it
indeed confuses me for a long time. Thank you all if you provide any
explanation.
I know concepts: compactness means any open cover have finite subcover,
which is equivalent to bounded close; connectedness means there's no
disjoint decomposition by two nonempty open sets. However, I have no idea
how they play roles in particular cases. I read many theorems that require
compact and connected topology but there's no any mention in their proofs.
The situation occurs frequently, as far as I concern, in differential
geometry and multivariable calculus (vector fields). Could anyone explain
to me how they involve in mathematics? A few examples are better welcomed.
This question may be a bit simple or even naive for some people but it
indeed confuses me for a long time. Thank you all if you provide any
explanation.
I know concepts: compactness means any open cover have finite subcover,
which is equivalent to bounded close; connectedness means there's no
disjoint decomposition by two nonempty open sets. However, I have no idea
how they play roles in particular cases. I read many theorems that require
compact and connected topology but there's no any mention in their proofs.
The situation occurs frequently, as far as I concern, in differential
geometry and multivariable calculus (vector fields). Could anyone explain
to me how they involve in mathematics? A few examples are better welcomed.
wpf mvvm datagrid loses sort when context recreated
wpf mvvm datagrid loses sort when context recreated
I have a wpf application built with MVVM light that uses entity framework
as the model.
Background:
My view model has a context that I use to populate a datagrid in the view.
I have a "navigation service" I built that changes what view/viewmodels
are displayed. As part of this navigation service I trigger an event that
the viewmodel uses to refresh the record of the datagrid in the viewmodel
before the requested view is displayed to the user.
Problem:
If the user has sorted the datagrid by clicking on a column heading, that
sorting is lost when I refresh the records. I want to maintain the
datagrid sroting when I drop and recreate the context.
Example:
here is the stripped down version of my refresh records function in the
view model:
Context = Nothing
Context = _ModelService.NewContext
InStockCollection = Await
_TrackingService.GetTracking_Stock_AllAsync(Context)
InStockCollectionViewSource.Source = InStockCollection
here is the declaration of the datagird in the paired view:
<DataGrid x:Name="StockDataGrid"
Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="3"
ItemsSource="{Binding
InStockCollectionViewSource.View,
IsAsync=True}"
CanUserAddRows="False"
CanUserDeleteRows="False"
SelectionMode="Single"
SelectedItem="{Binding SelectedInStock,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
VirtualizingStackPanel.IsVirtualizing="True"
RowHeight="49">
QUESTION:
How can I capture the current sorted value of the datagird in the view
model (i am confortable adding sorting descriptioins to the
collectionviewsource in the code, I just cant figure out how to tell what
sort is currently applied)
OR
Or how can I maintain the sort of the datagrid when the context of the
collectionviewsource is dropped and recreated.
thanks in advance
I have a wpf application built with MVVM light that uses entity framework
as the model.
Background:
My view model has a context that I use to populate a datagrid in the view.
I have a "navigation service" I built that changes what view/viewmodels
are displayed. As part of this navigation service I trigger an event that
the viewmodel uses to refresh the record of the datagrid in the viewmodel
before the requested view is displayed to the user.
Problem:
If the user has sorted the datagrid by clicking on a column heading, that
sorting is lost when I refresh the records. I want to maintain the
datagrid sroting when I drop and recreate the context.
Example:
here is the stripped down version of my refresh records function in the
view model:
Context = Nothing
Context = _ModelService.NewContext
InStockCollection = Await
_TrackingService.GetTracking_Stock_AllAsync(Context)
InStockCollectionViewSource.Source = InStockCollection
here is the declaration of the datagird in the paired view:
<DataGrid x:Name="StockDataGrid"
Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="3"
ItemsSource="{Binding
InStockCollectionViewSource.View,
IsAsync=True}"
CanUserAddRows="False"
CanUserDeleteRows="False"
SelectionMode="Single"
SelectedItem="{Binding SelectedInStock,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
VirtualizingStackPanel.IsVirtualizing="True"
RowHeight="49">
QUESTION:
How can I capture the current sorted value of the datagird in the view
model (i am confortable adding sorting descriptioins to the
collectionviewsource in the code, I just cant figure out how to tell what
sort is currently applied)
OR
Or how can I maintain the sort of the datagrid when the context of the
collectionviewsource is dropped and recreated.
thanks in advance
VPS apache config - Invalid command 'PassengerDefaultRuby' after adding latest passenger gem
VPS apache config - Invalid command 'PassengerDefaultRuby' after adding
latest passenger gem
used to have this list of rubies in my vps:
ruby-1.9.2-p320 [ i686 ]
=* ruby-1.9.3-p194 [ i686 ]
ruby-1.9.3-p374 [ i686 ]
ruby-1.9.3-p392 [ i686 ]
today I installed a new app on this vps on ruby 2.0, so I added 2.0 to rvm:
ruby-1.9.2-p320 [ i686 ]
ruby-1.9.3-p194 [ i686 ]
ruby-1.9.3-p374 [ i686 ]
ruby-1.9.3-p392 [ i686 ]
=* ruby-2.0.0-p247 [ i686 ]
installed passenger and passenger-apache-module, instructions says to add
these lines:
LoadModule passenger_module
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p247/ruby
to /etc/apache2/apache2.conf and restart apache, after restart I got this
error:
Syntax error on line 242 of /etc/apache2/apache2.conf:
Invalid command 'PassengerDefaultRuby', perhaps misspelled or defined by a
module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
...fail!
and one more problem, when I open my app at http://nccm.md I got:
Could not find rake-10.1.0 in any of the sources (Bundler::GemNotFound)
from gem list command I can see this gem is installed in ruby 2.0
environment, but the app looks for it in
usr/local/rvm/gems/ruby-1.9.3-p194@global and not in
ruby-2.0.0-p247@global. Why is that? Thank you for any help.
latest passenger gem
used to have this list of rubies in my vps:
ruby-1.9.2-p320 [ i686 ]
=* ruby-1.9.3-p194 [ i686 ]
ruby-1.9.3-p374 [ i686 ]
ruby-1.9.3-p392 [ i686 ]
today I installed a new app on this vps on ruby 2.0, so I added 2.0 to rvm:
ruby-1.9.2-p320 [ i686 ]
ruby-1.9.3-p194 [ i686 ]
ruby-1.9.3-p374 [ i686 ]
ruby-1.9.3-p392 [ i686 ]
=* ruby-2.0.0-p247 [ i686 ]
installed passenger and passenger-apache-module, instructions says to add
these lines:
LoadModule passenger_module
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p247/ruby
to /etc/apache2/apache2.conf and restart apache, after restart I got this
error:
Syntax error on line 242 of /etc/apache2/apache2.conf:
Invalid command 'PassengerDefaultRuby', perhaps misspelled or defined by a
module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
...fail!
and one more problem, when I open my app at http://nccm.md I got:
Could not find rake-10.1.0 in any of the sources (Bundler::GemNotFound)
from gem list command I can see this gem is installed in ruby 2.0
environment, but the app looks for it in
usr/local/rvm/gems/ruby-1.9.3-p194@global and not in
ruby-2.0.0-p247@global. Why is that? Thank you for any help.
How can I add a cultural game mechanic to Pathfinder=?iso-8859-1?Q?=3F_=96_rpg.stackexchange.com?=
How can I add a cultural game mechanic to Pathfinder? – rpg.stackexchange.com
I was reading this article on how most people play all races exactly the
same. The author hinted at replacing races in Pathfinder with a culture
mechanic, but didn't really go into the details. I …
I was reading this article on how most people play all races exactly the
same. The author hinted at replacing races in Pathfinder with a culture
mechanic, but didn't really go into the details. I …
Monday, 30 September 2013
Why is the Atomic Blimp not showing up=?iso-8859-1?Q?=3F_=96_gaming.stackexchange.com?=
Why is the Atomic Blimp not showing up? – gaming.stackexchange.com
When you download the Atomic Blimp DLC, a blimp icon appears at the
Vinewood Racetrack and a new contact is added to your phone, "Blimp". I
know I can get to the Blimp by simply accessing the ...
When you download the Atomic Blimp DLC, a blimp icon appears at the
Vinewood Racetrack and a new contact is added to your phone, "Blimp". I
know I can get to the Blimp by simply accessing the ...
Webapps on Chrome - not Chromium - with Ubuntu 13.04
Webapps on Chrome - not Chromium - with Ubuntu 13.04
I've been trying to find some info on this, but I only got very confusing
or old pages. I simply would like to know if I can use the webapps on my
Chrome (version 29.0.1547.76) with Ubuntu 13.04
I've been trying to find some info on this, but I only got very confusing
or old pages. I simply would like to know if I can use the webapps on my
Chrome (version 29.0.1547.76) with Ubuntu 13.04
Strange issue with HTML / CSS causing extra space
Strange issue with HTML / CSS causing extra space
I have a problem with some unexplained space at the bottom of a page that
I am working on. I have tried to fix the issue but I can't figure out what
is causing it...
A screenshot of the problem is here: http://bit.ly/18FQ9Ca
A link to the real page is here: http://bit.ly/18FR1qA
I think it might be something to do with the id="CivilService" div layer,
as the problem goes away when I remove the div. But there doesn't seem to
be anything contained which could cause the problem.
Many thanks for any help that you can give...
I have a problem with some unexplained space at the bottom of a page that
I am working on. I have tried to fix the issue but I can't figure out what
is causing it...
A screenshot of the problem is here: http://bit.ly/18FQ9Ca
A link to the real page is here: http://bit.ly/18FR1qA
I think it might be something to do with the id="CivilService" div layer,
as the problem goes away when I remove the div. But there doesn't seem to
be anything contained which could cause the problem.
Many thanks for any help that you can give...
PHP include a fallback to variable value
PHP include a fallback to variable value
In my PHP file I have a variable called mynumber as shown below.
$mynumber = "SELECT id FROM myTbl WHERE date >= CURDATE() LIMIT 1";
This works fine as mynumber unless I have no date field that is >= than
the curdate. I want to do something like
$mynumber = "SELECT ..." || 1
Currently I am doing.
$mynumberSelect = "SELECT id FROM myTbl WHERE matchdate >= CURDATE()
LIMIT 1";
if(empty($mynumberSelect)) {
$mynumber = "SELECT id FROM myTbl WHERE matchdate >= CURDATE() LIMIT 1";
}
else {
$mynumber = "SELECT id FROM myTbl ORDER BY id DESC LIMIT 1";
}
Which is working, but I thought there might be a better way to acheive this?
In my PHP file I have a variable called mynumber as shown below.
$mynumber = "SELECT id FROM myTbl WHERE date >= CURDATE() LIMIT 1";
This works fine as mynumber unless I have no date field that is >= than
the curdate. I want to do something like
$mynumber = "SELECT ..." || 1
Currently I am doing.
$mynumberSelect = "SELECT id FROM myTbl WHERE matchdate >= CURDATE()
LIMIT 1";
if(empty($mynumberSelect)) {
$mynumber = "SELECT id FROM myTbl WHERE matchdate >= CURDATE() LIMIT 1";
}
else {
$mynumber = "SELECT id FROM myTbl ORDER BY id DESC LIMIT 1";
}
Which is working, but I thought there might be a better way to acheive this?
Sunday, 29 September 2013
how to work on JList
how to work on JList
I want to add files in JList and when user selects the file and clicks
open then he should be able to open that selected.
I am trying to code this, will I be able to only display the path of the
file in the list? So that when user clicks then we get that path where
user clicked and open the file.
If so then, is it possible to list only the filename and not its paths so
that even then when user clicks on that file name he should be able to
open it.
If its possible just tell me how to do it na.. I don't want coding i just
need a practical idea on this..i am coding all this using java..
I want to add files in JList and when user selects the file and clicks
open then he should be able to open that selected.
I am trying to code this, will I be able to only display the path of the
file in the list? So that when user clicks then we get that path where
user clicked and open the file.
If so then, is it possible to list only the filename and not its paths so
that even then when user clicks on that file name he should be able to
open it.
If its possible just tell me how to do it na.. I don't want coding i just
need a practical idea on this..i am coding all this using java..
sorting using vectors c++
sorting using vectors c++
Hello everyone i'm writing a program of a stock market where i read from a
file and sort with symbols and percent gain/loss. I have completed sorting
with symbols but having trouble establishing the percent gain loss. First
i designed and implemented the stock object. call the class stockType.
main components of a stock are the stock symbol, stock price and number of
shares. Second we have to create a list of stock objects. call the class
to implement a list of stock objects stockListType. To store the list of
stocks, i declared a vector and called the component type of this vector
stockType.
Because the company requires me to produce the list ordered by percent
gain/loss, i need to sort the stock list by this component. However, i'm
not to physically sort the list by component percent gain/loss; instead i
should provide a logic ordering with respect to this component. To do so i
added a data member, a vector to hold the indices of the stock list
ordered by the component percent gain/loss and i called this array
indexByGain. I am going to use the array indexByGain to print the list.
The elements of the array indexByGain will tell which component of the
stock list to print next. I have trouble going about how to implement the
function sortStockGain(). i need assistance and this would be of great
help as i don't know how to start. below is my entire code and the txt
file. I have sort symbols working but dont know how to implement the sort
by gain if one could assist me this would be of great help. By the way
this is my first programming class.
Below is my entire code:
#ifndef STOCKTYPE_H
#define STOCKTYPE_H
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
class stockType
{
public:
stockType(string symbol="", double openPrice=0.0, double closePrice=0.0,
double highPrice=0.0,
double lowPrevPrice=0.0, double closePrevPrice=0.0, int shares=0);
friend istream& operator>>(istream& ins, stockType& stock);
friend ostream& operator<<(ostream& outs, const stockType& stock);
//sets the variables
void setStockInfo(string syms, double open, double close, double high,
double lowPrev, double closePrev, int no_of_shares);
//calculates the gain
void calculateGain(double closeP, double prevP);
bool operator==(const stockType& stock1) const;
bool operator!=(const stockType& stock1) const;
bool operator<=(const stockType& stock1) const;
bool operator<(const stockType& stock1) const;
bool operator>=(const stockType& stock1) const;
bool operator>(const stockType& stock1) const;
//member functions
string getSymbols()const {return symbols;}
double getOpenPrice()const {return open_price;}
double getClosePrice()const {return close_price;}
double getHighPrice()const {return high_price;}
double getLowPrevPrice()const {return low_prev_price;}
double getClosePrevPrice()const {return close_prev_price;}
double getShares()const {return no_shares;}
double getGain()const {return gain;}
private:
string symbols;
double open_price, close_price, high_price, low_prev_price,
close_prev_price, gain;
int no_shares;
};
#include "stockType.h"
stockType::stockType(string symbol, double openPrice, double
closePrice, double highPrice,
double lowPrevPrice, double closePrevPrice, int shares)
{
setStockInfo(symbol, openPrice, closePrice, highPrice, lowPrevPrice,
closePrevPrice, shares);
}
void stockType::setStockInfo(string syms, double open, double close,
double high,
double lowPrev, double closePrev, int no_of_shares)
{
symbols = syms;
open_price = open;
close_price = close;
high_price = high;
low_prev_price = lowPrev;
close_prev_price = closePrev;
no_shares = no_of_shares;
}
istream& operator>>(istream& ins, stockType& stock)
{
ins>>stock.symbols;
ins>>stock.open_price;
ins>>stock.close_price;
ins>>stock.high_price;
ins>>stock.low_prev_price;
ins>>stock.close_prev_price;
ins>>stock.no_shares;
stock.calculateGain(stock.close_price, stock.close_prev_price);
return ins;
}
ostream& operator<<(ostream& outs, const stockType& stock)
{
outs<<stock.getSymbols()
<<fixed<<showpoint<<setprecision(2)
<<setw(10)<<stock.getOpenPrice()<<setw(10)
<<stock.getClosePrice()<<setw(10)
<<stock.getHighPrice()<<setw(10)
<<stock.getLowPrevPrice()<<setw(11)
<<stock.getClosePrevPrice()
<<setw(10)<<stock.getGain()<<"%"<<setw(13)
<<stock.getShares()<<endl<<endl;
return outs;
}
void stockType::calculateGain(double closeP, double prevP)
{
gain = ((closeP - prevP)/(prevP)*100);
}
bool stockType::operator==(const stockType& stock1) const
{
return (symbols==stock1.symbols);
}
bool stockType::operator!=(const stockType& stock1) const
{
return (symbols!=stock1.symbols);
}
bool stockType::operator>=(const stockType& stock1) const
{
return (symbols>=stock1.symbols);
}
bool stockType::operator>(const stockType& stock1) const
{
return (symbols>stock1.symbols);
}
bool stockType::operator<=(const stockType& stock1) const
{
return (symbols<=stock1.symbols);
}
bool stockType::operator<(const stockType& stock1) const
{
return (symbols<stock1.symbols);
}
#ifndef stockListType_H
#define stockListType_H
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include "stockType.h"
using namespace std;
class stockListType
{
public:
stockListType()
{
}
void insert(const stockType& item);
void sortStockSymbols();
void sortStockGain();
void printStockSymbols();
void printStockGain();
private:
vector<int> indexByGain;
vector<stockType> list;
};
Hello everyone i'm writing a program of a stock market where i read from a
file and sort with symbols and percent gain/loss. I have completed sorting
with symbols but having trouble establishing the percent gain loss. First
i designed and implemented the stock object. call the class stockType.
main components of a stock are the stock symbol, stock price and number of
shares. Second we have to create a list of stock objects. call the class
to implement a list of stock objects stockListType. To store the list of
stocks, i declared a vector and called the component type of this vector
stockType.
Because the company requires me to produce the list ordered by percent
gain/loss, i need to sort the stock list by this component. However, i'm
not to physically sort the list by component percent gain/loss; instead i
should provide a logic ordering with respect to this component. To do so i
added a data member, a vector to hold the indices of the stock list
ordered by the component percent gain/loss and i called this array
indexByGain. I am going to use the array indexByGain to print the list.
The elements of the array indexByGain will tell which component of the
stock list to print next. I have trouble going about how to implement the
function sortStockGain(). i need assistance and this would be of great
help as i don't know how to start. below is my entire code and the txt
file. I have sort symbols working but dont know how to implement the sort
by gain if one could assist me this would be of great help. By the way
this is my first programming class.
Below is my entire code:
#ifndef STOCKTYPE_H
#define STOCKTYPE_H
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
class stockType
{
public:
stockType(string symbol="", double openPrice=0.0, double closePrice=0.0,
double highPrice=0.0,
double lowPrevPrice=0.0, double closePrevPrice=0.0, int shares=0);
friend istream& operator>>(istream& ins, stockType& stock);
friend ostream& operator<<(ostream& outs, const stockType& stock);
//sets the variables
void setStockInfo(string syms, double open, double close, double high,
double lowPrev, double closePrev, int no_of_shares);
//calculates the gain
void calculateGain(double closeP, double prevP);
bool operator==(const stockType& stock1) const;
bool operator!=(const stockType& stock1) const;
bool operator<=(const stockType& stock1) const;
bool operator<(const stockType& stock1) const;
bool operator>=(const stockType& stock1) const;
bool operator>(const stockType& stock1) const;
//member functions
string getSymbols()const {return symbols;}
double getOpenPrice()const {return open_price;}
double getClosePrice()const {return close_price;}
double getHighPrice()const {return high_price;}
double getLowPrevPrice()const {return low_prev_price;}
double getClosePrevPrice()const {return close_prev_price;}
double getShares()const {return no_shares;}
double getGain()const {return gain;}
private:
string symbols;
double open_price, close_price, high_price, low_prev_price,
close_prev_price, gain;
int no_shares;
};
#include "stockType.h"
stockType::stockType(string symbol, double openPrice, double
closePrice, double highPrice,
double lowPrevPrice, double closePrevPrice, int shares)
{
setStockInfo(symbol, openPrice, closePrice, highPrice, lowPrevPrice,
closePrevPrice, shares);
}
void stockType::setStockInfo(string syms, double open, double close,
double high,
double lowPrev, double closePrev, int no_of_shares)
{
symbols = syms;
open_price = open;
close_price = close;
high_price = high;
low_prev_price = lowPrev;
close_prev_price = closePrev;
no_shares = no_of_shares;
}
istream& operator>>(istream& ins, stockType& stock)
{
ins>>stock.symbols;
ins>>stock.open_price;
ins>>stock.close_price;
ins>>stock.high_price;
ins>>stock.low_prev_price;
ins>>stock.close_prev_price;
ins>>stock.no_shares;
stock.calculateGain(stock.close_price, stock.close_prev_price);
return ins;
}
ostream& operator<<(ostream& outs, const stockType& stock)
{
outs<<stock.getSymbols()
<<fixed<<showpoint<<setprecision(2)
<<setw(10)<<stock.getOpenPrice()<<setw(10)
<<stock.getClosePrice()<<setw(10)
<<stock.getHighPrice()<<setw(10)
<<stock.getLowPrevPrice()<<setw(11)
<<stock.getClosePrevPrice()
<<setw(10)<<stock.getGain()<<"%"<<setw(13)
<<stock.getShares()<<endl<<endl;
return outs;
}
void stockType::calculateGain(double closeP, double prevP)
{
gain = ((closeP - prevP)/(prevP)*100);
}
bool stockType::operator==(const stockType& stock1) const
{
return (symbols==stock1.symbols);
}
bool stockType::operator!=(const stockType& stock1) const
{
return (symbols!=stock1.symbols);
}
bool stockType::operator>=(const stockType& stock1) const
{
return (symbols>=stock1.symbols);
}
bool stockType::operator>(const stockType& stock1) const
{
return (symbols>stock1.symbols);
}
bool stockType::operator<=(const stockType& stock1) const
{
return (symbols<=stock1.symbols);
}
bool stockType::operator<(const stockType& stock1) const
{
return (symbols<stock1.symbols);
}
#ifndef stockListType_H
#define stockListType_H
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include "stockType.h"
using namespace std;
class stockListType
{
public:
stockListType()
{
}
void insert(const stockType& item);
void sortStockSymbols();
void sortStockGain();
void printStockSymbols();
void printStockGain();
private:
vector<int> indexByGain;
vector<stockType> list;
};
How can I have multiple condition in 1 if statement
How can I have multiple condition in 1 if statement
I'm trying to hide a button until both select boxes have an item select.
<select id="comType">
<option>-- Select --</option>
<option>Call</option>
<option>Fax</option>
<option>Email</option>
</select>
<select id="comDirection">
<option>-- Select --</option>
<option>Incoming</option>
<option>Outgoing</option>
</select>
<a href="#"
id="button_that_displays_only_when_both_selects_have_input">Next</a>
What I'm currently using, but I know is not right.
<script>
$(document).ajaxSuccess(function () {
if ($("#comType").change()) || ($("#comDirection").change()))
{ $("#button_that_displays_only_when_both_selects_have_input").show()}
});
</script>
It would be an added bonus if this could ensure actual selection, as in,
not allow the first select option to count as they are just
placeholders....
Thanks, Mark
I'm trying to hide a button until both select boxes have an item select.
<select id="comType">
<option>-- Select --</option>
<option>Call</option>
<option>Fax</option>
<option>Email</option>
</select>
<select id="comDirection">
<option>-- Select --</option>
<option>Incoming</option>
<option>Outgoing</option>
</select>
<a href="#"
id="button_that_displays_only_when_both_selects_have_input">Next</a>
What I'm currently using, but I know is not right.
<script>
$(document).ajaxSuccess(function () {
if ($("#comType").change()) || ($("#comDirection").change()))
{ $("#button_that_displays_only_when_both_selects_have_input").show()}
});
</script>
It would be an added bonus if this could ensure actual selection, as in,
not allow the first select option to count as they are just
placeholders....
Thanks, Mark
How to prevent the cursor to go back while pressing backspace key in javascript?
How to prevent the cursor to go back while pressing backspace key in
javascript?
Please consider the following html.
<div id="container" contenteditable="true">
<p>This is a paragraph <span class="test">'this text is inside the
span'</span>
This is another paragraph afer the span tag inside this p tag
</p> </div>
As you see, the p and the span tag are editable in the browser.It means we
can write in it in browser. Now my question is about the span inside the p
tag. So can anyone explain If the cursor (while typing in this span in
browser) is just after the span tag i.e after the closing span tag,the
backspace key should not work.
More simple,once the cursor goes outside the span,the backspace key should
not move it again to go to the span. Please help with a simple example in
javascript.
Thanks to all.
javascript?
Please consider the following html.
<div id="container" contenteditable="true">
<p>This is a paragraph <span class="test">'this text is inside the
span'</span>
This is another paragraph afer the span tag inside this p tag
</p> </div>
As you see, the p and the span tag are editable in the browser.It means we
can write in it in browser. Now my question is about the span inside the p
tag. So can anyone explain If the cursor (while typing in this span in
browser) is just after the span tag i.e after the closing span tag,the
backspace key should not work.
More simple,once the cursor goes outside the span,the backspace key should
not move it again to go to the span. Please help with a simple example in
javascript.
Thanks to all.
Saturday, 28 September 2013
concat pdo not dieing, but still not updating the database
concat pdo not dieing, but still not updating the database
my code is as follows
SQL = 'UPDATE cb_contact_tickets SET ticket_status = :status' .
($_POST['status']=="declined"?', declined=CONCAT(declined, :captain_id),
captain_id=NULL':'') .
' WHERE captain_id = :captain_id AND user_id = :user_id';
$stmt = $dbh->prepare($SQL);
$stmt->bindParam(':user_id', $_POST['user_id']);
$stmt->bindParam(':status', $_POST['status']);
$stmt->bindParam(':captain_id', $capatinID);
if (!$stmt->execute()) {
die(print_r($stmt->errorInfo()));
}
I checked the responses and i consistently get success ( a json encoded
response at the end) but my database doesnt change. The code doesnt die,
and im pulling hair out trying to figure out why. Please help.
my code is as follows
SQL = 'UPDATE cb_contact_tickets SET ticket_status = :status' .
($_POST['status']=="declined"?', declined=CONCAT(declined, :captain_id),
captain_id=NULL':'') .
' WHERE captain_id = :captain_id AND user_id = :user_id';
$stmt = $dbh->prepare($SQL);
$stmt->bindParam(':user_id', $_POST['user_id']);
$stmt->bindParam(':status', $_POST['status']);
$stmt->bindParam(':captain_id', $capatinID);
if (!$stmt->execute()) {
die(print_r($stmt->errorInfo()));
}
I checked the responses and i consistently get success ( a json encoded
response at the end) but my database doesnt change. The code doesnt die,
and im pulling hair out trying to figure out why. Please help.
Reach nested array item using recursion - javascript
Reach nested array item using recursion - javascript
I'm trying to reach the center of a nested array using recursion. This is
part of a larger problem I'm trying to solve. I'm sure the solution is
somewhat elementary. I've been learning JS/web dev and am stumped.
Here's my code:
var j = [[[["hey!"]]]];
function getNested(obj) {
for (var i = 0; i < obj.length; i++) {
if (Array.isArray(obj[i])) {
obj = obj[i];
getNested(obj);
}
return obj[i];
}
}
The function is supposed to return the 'hey!' string, but I can't seem to
get it right.
I'm trying to reach the center of a nested array using recursion. This is
part of a larger problem I'm trying to solve. I'm sure the solution is
somewhat elementary. I've been learning JS/web dev and am stumped.
Here's my code:
var j = [[[["hey!"]]]];
function getNested(obj) {
for (var i = 0; i < obj.length; i++) {
if (Array.isArray(obj[i])) {
obj = obj[i];
getNested(obj);
}
return obj[i];
}
}
The function is supposed to return the 'hey!' string, but I can't seem to
get it right.
Developing android apps
Developing android apps
I want to develop an android app which will be help a shop owner can input
his daily sales expense, employee history, product setting and it show day
to day or monthly profit. when he use this app no need to connect internet
connectivity. data all are store in sd card but if he want in internet
connectivity state he can save data in dropbox. So as like a financial app
when I build this which program I need to know like java, xml ?? there are
need any database program ??? I am a new Apps Developer.
I want to develop an android app which will be help a shop owner can input
his daily sales expense, employee history, product setting and it show day
to day or monthly profit. when he use this app no need to connect internet
connectivity. data all are store in sd card but if he want in internet
connectivity state he can save data in dropbox. So as like a financial app
when I build this which program I need to know like java, xml ?? there are
need any database program ??? I am a new Apps Developer.
Subscribe to:
Posts (Atom)