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.
How To Grouping And Then Sorting Query SQL Server 2000 From Different Database Using PHP
How To Grouping And Then Sorting Query SQL Server 2000 From Different
Database Using PHP
I had a case like this. there are several branches database. I already can
create a report using PHP that show name product, total sales, then grand
total for all name product.
Now i want create a report for all branches database. How to do it? I want
create a report like this, The report must be group by each name product
from all branches. And then for each name product, display its, total
sales on the right side. Finally at the bottom of report, display grand
total for all name product group.
The method i have research and try to do this (but i still fail get a report)
First i create query to display top 20 name product from all branches
database. for example i have 10 branches database. By doing this i get
20*10 = 200 name product that already group by name product. Sorted DESC
by its total sales.
I created temp database to save this result temporary to group it again
and sorting DESC to get 20 name product. The problem is, i fail to create
temp database, if this method right, please guide me to create temp
database using php on sql server 2000.
OR
First i create query to display top 20 name product from all branches
database. for example i have 10 branches database. By doing this i get
20*10 = 200 name product that already group by name product. Sorted DESC
by its total sales.
I created an single array to save this result temporary to group it again
and sorting DESC to get 20 name product. The problem is, how to create
array and then grouping its value and sorting it? Please guide me, if this
method is the best way to create a report for my case.
Lastly, Please forgive me if my english bad. I'll appreciate to hear a
suggestion from all of you out there.
Thanks and best regards.
Database Using PHP
I had a case like this. there are several branches database. I already can
create a report using PHP that show name product, total sales, then grand
total for all name product.
Now i want create a report for all branches database. How to do it? I want
create a report like this, The report must be group by each name product
from all branches. And then for each name product, display its, total
sales on the right side. Finally at the bottom of report, display grand
total for all name product group.
The method i have research and try to do this (but i still fail get a report)
First i create query to display top 20 name product from all branches
database. for example i have 10 branches database. By doing this i get
20*10 = 200 name product that already group by name product. Sorted DESC
by its total sales.
I created temp database to save this result temporary to group it again
and sorting DESC to get 20 name product. The problem is, i fail to create
temp database, if this method right, please guide me to create temp
database using php on sql server 2000.
OR
First i create query to display top 20 name product from all branches
database. for example i have 10 branches database. By doing this i get
20*10 = 200 name product that already group by name product. Sorted DESC
by its total sales.
I created an single array to save this result temporary to group it again
and sorting DESC to get 20 name product. The problem is, how to create
array and then grouping its value and sorting it? Please guide me, if this
method is the best way to create a report for my case.
Lastly, Please forgive me if my english bad. I'll appreciate to hear a
suggestion from all of you out there.
Thanks and best regards.
Friday, 27 September 2013
I have a blank page after submitting a php mysqli update form,
I have a blank page after submitting a php mysqli update form,
Hi I am trying to complete this update and It keeps sending me a blank
page with no errors and not submitting the info into the DataBase.
Everything works up to the point of the prepared statement as far as i can
tell, it draws the id and the other variables no problem from the database
and the previous search queries but wont let me go any further. Can anyone
see where I have gone wrong, I just cant see it???
<html>
<head>
<title>
<?php if ($id != '') { echo "Edit Record";
} else { echo "New Record"; } ?>
</title>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8"/>
</head>
<body>
<h1><?php if ($id != '') { echo "Edit Record";
} else { echo "New Record"; } ?></h1>
<?php if ($error != '') {
echo "<div style='padding:4px;
border:1px solid red; color:red'>" .
$error
. "</div>";
} ?>
<form action="" method="post">
<div>
<?php if ($id != '') { ?>
<input type="hidden" name="id"
value="<?php echo $id; ?>" />
<p>ID: <?php echo $id; ?></p>
<?php } ?>
<br><strong>Item Type: *
</strong><input name="item_type"
value="<?php echo $item_type; ?>"
type="text"><br>
<br><strong>Location: *
</strong><input name="location"
value="<?php echo $location; ?>"
type="text"><br>
<br><strong>Date Last Test: *
</strong><input name="date_last_test"
value="<?php echo $date_last_test; ?>"
type="date"><br>
<br><strong>Serial Number:
*</strong><input name="serial_number"
value="<?php echo $serial_number; ?>"
type="text"><br>
<br><strong>Date Next Test:
*</strong><input name="date_next_test"
value="<?php echo $date_next_test; ?>"
type="date"><br>
<br><strong>Comments: *</strong><input
name="comments" value="<?php echo
$comments; ?>" type="text"><br>
<p style="text-align: left;">*
required</p>
<input name="submit" value="Submit"
type="submit"><div style="text-align:
left;">
</div></div><div style="text-align: left;">
</body>
</html>
/*
EDIT RECORD
*/
// if the 'id' variable is set in the URL, we know that we need to
edit a record
if (isset($_GET['id']))
{
// if the form's submit button is clicked, we need to process
the form
if (isset($_POST['submit']))
{
// make sure the 'id' in the URL is valid
if (is_numeric($_POST['id']))
{
// get variables from the URL/form
$id = $_POST['id'];
$item_type = htmlentities($_POST['item_type'],
ENT_QUOTES);
$location = htmlentities($_POST['location'],
ENT_QUOTES);
$date_last_test =
htmlentities($_POST['date_last_test'],
ENT_QUOTES);
$serial_number =
htmlentities($_POST['serial_number'],
ENT_QUOTES);
$date_next_test =
htmlentities($_POST['date_next_test'],
ENT_QUOTES);
$comments = htmlentities($_POST['comments'],
ENT_QUOTES);
// check that firstname and lastname are both
not empty
if ($item_type == '' || $location == ''||
$date_last_test == ''|| $serial_number == ''||
$date_next_test == ''|| $comments == '' )
{
// if they are empty, show an error
message and display the form
$error = 'ERROR: Please fill in all
required fields!';
renderForm($item_type, $location,
$date_last_test, $serial_number,
$date_next_test, $comments, $error,
$id);
}
else
{
// if everything is fine, update the
record in the database
if ($stmt =
$mysqli->prepare("UPDATE
`Calibration_and_Inspection_Register`
SET `item_type` = ?,
`location` = ?,
`date_last_test` = ?,
`serial_number` = ?,
`date_next_test` = ?,
`comments` = ?
WHERE `id`=?"))
{
$stmt->bind_param("issdsds",`$id`,
`$item_type`, `$location`,
`$date_last_test`,
`$serial_number`,
`$date_next_test`,
`$comments`);
$stmt->execute();
$stmt->close();
}
// show an error message if the query
has an error
else
{
echo "ERROR: could not prepare
SQL statement.";
}
// redirect the user once the form is
updated
//header("Location: View Calibration
and Inspection records.php");
}
}
// if the 'id' variable is not valid, show an error
message
else
{
echo "Error with ID !";
}
}
// if the form hasn't been submitted yet, get the info from
the database and show the form
else
{
// make sure the 'id' value is valid
if (is_numeric($_GET['id']) && $_GET['id'] > 0)
{
// get 'id' from URL
$id = $_GET['id'];
// get the recod from the database
if($stmt = $mysqli->prepare("SELECT
`item_type`,`location`,`date_last_test`,`serial_number`,`date_next_test`,`comments`,`id`
FROM `Calibration_and_Inspection_Register`
WHERE id=?"))
{
$stmt->bind_param("i", $id);
$stmt->execute();
$stmt->bind_result($item_type,
$location, $date_last_test,
$serial_number, $date_next_test,
$comments, $id);
$stmt->fetch();
// show the form
renderForm($item_type, $location,
$date_last_test, $serial_number,
$date_next_test, $comments, $id);
$stmt->close();
}
// show an error if the query has an error
else
{
echo "Error: could not prepare SQL
statement";
}
}
// if the 'id' value is not valid, redirect the user back
to the view.php page
else
{
header("Location: View All Calibration and
Inspection Records.php");
}
}
}
Hi I am trying to complete this update and It keeps sending me a blank
page with no errors and not submitting the info into the DataBase.
Everything works up to the point of the prepared statement as far as i can
tell, it draws the id and the other variables no problem from the database
and the previous search queries but wont let me go any further. Can anyone
see where I have gone wrong, I just cant see it???
<html>
<head>
<title>
<?php if ($id != '') { echo "Edit Record";
} else { echo "New Record"; } ?>
</title>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8"/>
</head>
<body>
<h1><?php if ($id != '') { echo "Edit Record";
} else { echo "New Record"; } ?></h1>
<?php if ($error != '') {
echo "<div style='padding:4px;
border:1px solid red; color:red'>" .
$error
. "</div>";
} ?>
<form action="" method="post">
<div>
<?php if ($id != '') { ?>
<input type="hidden" name="id"
value="<?php echo $id; ?>" />
<p>ID: <?php echo $id; ?></p>
<?php } ?>
<br><strong>Item Type: *
</strong><input name="item_type"
value="<?php echo $item_type; ?>"
type="text"><br>
<br><strong>Location: *
</strong><input name="location"
value="<?php echo $location; ?>"
type="text"><br>
<br><strong>Date Last Test: *
</strong><input name="date_last_test"
value="<?php echo $date_last_test; ?>"
type="date"><br>
<br><strong>Serial Number:
*</strong><input name="serial_number"
value="<?php echo $serial_number; ?>"
type="text"><br>
<br><strong>Date Next Test:
*</strong><input name="date_next_test"
value="<?php echo $date_next_test; ?>"
type="date"><br>
<br><strong>Comments: *</strong><input
name="comments" value="<?php echo
$comments; ?>" type="text"><br>
<p style="text-align: left;">*
required</p>
<input name="submit" value="Submit"
type="submit"><div style="text-align:
left;">
</div></div><div style="text-align: left;">
</body>
</html>
/*
EDIT RECORD
*/
// if the 'id' variable is set in the URL, we know that we need to
edit a record
if (isset($_GET['id']))
{
// if the form's submit button is clicked, we need to process
the form
if (isset($_POST['submit']))
{
// make sure the 'id' in the URL is valid
if (is_numeric($_POST['id']))
{
// get variables from the URL/form
$id = $_POST['id'];
$item_type = htmlentities($_POST['item_type'],
ENT_QUOTES);
$location = htmlentities($_POST['location'],
ENT_QUOTES);
$date_last_test =
htmlentities($_POST['date_last_test'],
ENT_QUOTES);
$serial_number =
htmlentities($_POST['serial_number'],
ENT_QUOTES);
$date_next_test =
htmlentities($_POST['date_next_test'],
ENT_QUOTES);
$comments = htmlentities($_POST['comments'],
ENT_QUOTES);
// check that firstname and lastname are both
not empty
if ($item_type == '' || $location == ''||
$date_last_test == ''|| $serial_number == ''||
$date_next_test == ''|| $comments == '' )
{
// if they are empty, show an error
message and display the form
$error = 'ERROR: Please fill in all
required fields!';
renderForm($item_type, $location,
$date_last_test, $serial_number,
$date_next_test, $comments, $error,
$id);
}
else
{
// if everything is fine, update the
record in the database
if ($stmt =
$mysqli->prepare("UPDATE
`Calibration_and_Inspection_Register`
SET `item_type` = ?,
`location` = ?,
`date_last_test` = ?,
`serial_number` = ?,
`date_next_test` = ?,
`comments` = ?
WHERE `id`=?"))
{
$stmt->bind_param("issdsds",`$id`,
`$item_type`, `$location`,
`$date_last_test`,
`$serial_number`,
`$date_next_test`,
`$comments`);
$stmt->execute();
$stmt->close();
}
// show an error message if the query
has an error
else
{
echo "ERROR: could not prepare
SQL statement.";
}
// redirect the user once the form is
updated
//header("Location: View Calibration
and Inspection records.php");
}
}
// if the 'id' variable is not valid, show an error
message
else
{
echo "Error with ID !";
}
}
// if the form hasn't been submitted yet, get the info from
the database and show the form
else
{
// make sure the 'id' value is valid
if (is_numeric($_GET['id']) && $_GET['id'] > 0)
{
// get 'id' from URL
$id = $_GET['id'];
// get the recod from the database
if($stmt = $mysqli->prepare("SELECT
`item_type`,`location`,`date_last_test`,`serial_number`,`date_next_test`,`comments`,`id`
FROM `Calibration_and_Inspection_Register`
WHERE id=?"))
{
$stmt->bind_param("i", $id);
$stmt->execute();
$stmt->bind_result($item_type,
$location, $date_last_test,
$serial_number, $date_next_test,
$comments, $id);
$stmt->fetch();
// show the form
renderForm($item_type, $location,
$date_last_test, $serial_number,
$date_next_test, $comments, $id);
$stmt->close();
}
// show an error if the query has an error
else
{
echo "Error: could not prepare SQL
statement";
}
}
// if the 'id' value is not valid, redirect the user back
to the view.php page
else
{
header("Location: View All Calibration and
Inspection Records.php");
}
}
}
Bash script to find apache servers
Bash script to find apache servers
I apologize if I haven't properly searched every possible post on this but
all seem a little different and I'm starting to get crossed eyed looking
at this.
The following bash code is what I have so far.
for server in cat serverlist2.txt; do ssh -q $server if ! ps -ef | grep -q
http ; then echo $server fi done
I'm new to bash scripting and I have to find all the hosts listed in the
file serverlist2.txt that run apache (http) and then print the hostnames
where http is found. Any help would be greatly appreciated.
I apologize if I haven't properly searched every possible post on this but
all seem a little different and I'm starting to get crossed eyed looking
at this.
The following bash code is what I have so far.
for server in cat serverlist2.txt; do ssh -q $server if ! ps -ef | grep -q
http ; then echo $server fi done
I'm new to bash scripting and I have to find all the hosts listed in the
file serverlist2.txt that run apache (http) and then print the hostnames
where http is found. Any help would be greatly appreciated.
Google Places API -- Java Version
Google Places API -- Java Version
I am very much interested about Google API'S. Today I saw one new API
(PLACES API). With this we can search places. But I tried to found out the
JAVA version of API but I was unable to find out the JAVA version sample
code. I found the JavaScript version. But I don't the JavaScript. Can any
one point me to the Java Version of "Google Place API"...?
Thanq, Amar.
I am very much interested about Google API'S. Today I saw one new API
(PLACES API). With this we can search places. But I tried to found out the
JAVA version of API but I was unable to find out the JAVA version sample
code. I found the JavaScript version. But I don't the JavaScript. Can any
one point me to the Java Version of "Google Place API"...?
Thanq, Amar.
Selenium. How to swith to a window that contains a partial substring?
Selenium. How to swith to a window that contains a partial substring?
I have three windows open as a result of Selenium manipulations. I need to
switch the the window who's URL contains a substring "Servlet"
driver.switchTo().window("*Servlet*");
How can I code it correctly?
I have three windows open as a result of Selenium manipulations. I need to
switch the the window who's URL contains a substring "Servlet"
driver.switchTo().window("*Servlet*");
How can I code it correctly?
enable the button to be clicked only to once exception?
enable the button to be clicked only to once exception?
I use a dialog to get the user input, but I found the user may click
double click the button and added the content twice, the cause is the
dialog fadeout too slow or the user clicked twice on the mouse.. I don't
want to adjust the fadeout speed, instead, how to enable the button only
can be clicked once?
I use a dialog to get the user input, but I found the user may click
double click the button and added the content twice, the cause is the
dialog fadeout too slow or the user clicked twice on the mouse.. I don't
want to adjust the fadeout speed, instead, how to enable the button only
can be clicked once?
finding length of wma in java
finding length of wma in java
I am a bit confused about all of the various sound apis available in java.
All I need is something to determine the length of a wma file. I don't
need to play it or convert it or anything else. I understand that the
native java api doesn't support wma. Can anyone recommend a good
library/method that can easily get the length of a wma? (I found JAVE from
searching here, but it seems like overkill in terms of setting up for just
determining the length.) It will run on a Windows computer if that's
relevant.
I am a bit confused about all of the various sound apis available in java.
All I need is something to determine the length of a wma file. I don't
need to play it or convert it or anything else. I understand that the
native java api doesn't support wma. Can anyone recommend a good
library/method that can easily get the length of a wma? (I found JAVE from
searching here, but it seems like overkill in terms of setting up for just
determining the length.) It will run on a Windows computer if that's
relevant.
Maximum size of MYSQL data base
Maximum size of MYSQL data base
I am using VPS with Centos 5 , RAM - 2GB and my server storage space is
10GB what is the maximum size of database , Will it take more than 1
second for execution ?
I am using VPS with Centos 5 , RAM - 2GB and my server storage space is
10GB what is the maximum size of database , Will it take more than 1
second for execution ?
Thursday, 26 September 2013
Why am I getting "Call to undefined function findOne()" here?
Why am I getting "Call to undefined function findOne()" here?
I've got a little PHP script that has the following code in it:
$m = new MongoClient(Settings::$db);
$db = $m->db;
// get the 'customers' collection
$customers = $db->customers;
// determine if this customer already exists
$c = $customers.findOne(array('email' => $email)); <--- throws
if (is_null($c)) {
$customers.insert(array(
'email' => $email,
'firstname' => $firstName,
'lastname' => $lastName
));
}
// get the 'payments' collection
$payments = $db->payments;
// add a record
$payments->insert(array(
'email' => $email,
'firstname' => $firstName,
'lastname' => $lastName,
'amount' => $price,
'token' => $token
));
but it's throwing the error:
PHP Fatal error: Call to undefined function findOne() in ...
Now, I've downloaded and copied into the ext directory the php_mongo.dll
file. Further, I've added this line to the php.ini:
extension=php_mongo.dll
and I've since rebooted the server numerous times.
It really feels to me like this findOne method isn't available because the
php_mongo extension isn't loaded. But on the other hand, it's not throwing
when creating the MongoClient, nor is it throwing when grabbing the
database and the collection.
What's going on here?
I've got a little PHP script that has the following code in it:
$m = new MongoClient(Settings::$db);
$db = $m->db;
// get the 'customers' collection
$customers = $db->customers;
// determine if this customer already exists
$c = $customers.findOne(array('email' => $email)); <--- throws
if (is_null($c)) {
$customers.insert(array(
'email' => $email,
'firstname' => $firstName,
'lastname' => $lastName
));
}
// get the 'payments' collection
$payments = $db->payments;
// add a record
$payments->insert(array(
'email' => $email,
'firstname' => $firstName,
'lastname' => $lastName,
'amount' => $price,
'token' => $token
));
but it's throwing the error:
PHP Fatal error: Call to undefined function findOne() in ...
Now, I've downloaded and copied into the ext directory the php_mongo.dll
file. Further, I've added this line to the php.ini:
extension=php_mongo.dll
and I've since rebooted the server numerous times.
It really feels to me like this findOne method isn't available because the
php_mongo extension isn't loaded. But on the other hand, it's not throwing
when creating the MongoClient, nor is it throwing when grabbing the
database and the collection.
What's going on here?
Wednesday, 25 September 2013
how to convert human date to unix by strotime
how to convert human date to unix by strotime
Can anyone help , i want to to make simple script as anyone insert human
date like 2013 - 9 - 25 19:10:00 P.M to milliseconds Unix .
is it possible using strtotime.
I want anyone to show me how to make the whole human date (2013 - 9 - 25
19:10:00 P.M ) be in one variable so i can convert it then echo it
Can anyone help , i want to to make simple script as anyone insert human
date like 2013 - 9 - 25 19:10:00 P.M to milliseconds Unix .
is it possible using strtotime.
I want anyone to show me how to make the whole human date (2013 - 9 - 25
19:10:00 P.M ) be in one variable so i can convert it then echo it
Thursday, 19 September 2013
Detecting Numbers in a String Variable (In Java)
Detecting Numbers in a String Variable (In Java)
So, normally for detecting user input, I use int and double variable types.
Example:
Scanner in = new Scanner(System.in);
int selection;
System.out.println("Welcome to RPG! (prototype name)\nIn this game,
you do stuff.\nChoose a class:\n1. Soldier\n2. Knight\n3. Paladin\n4.
Heavy");
selection = in.nextInt();
if(selection == 1){
System.out.print("you are a soldier");
}
else{
System.out.print(selection);
}
}
This technique usually works fine for me, but I noticed that if the user
inputs a letter into the int variable, the game will crash because
integers can't store letters. (right?) So I tried using a String variable
in its place, like this:
Scanner in = new Scanner(System.in);
String selection;
System.out.println("Welcome to RPG! (prototype name)\nIn this game,
you do stuff. Level up, yo!\nChoose a class:\n1. Soldier\n2.
Knight\n3. Paladin\n4. Heavy");
selection = in.next();
if(selection == "1"){
System.out.print("you are a soldier");
}
else{
System.out.print(selection);
}
}
This seemed to work at first, but as you can see, I have it set so that if
the variable "selection" is equal to 1, that it will print "you are a
soldier", yet this did not work, instead it printed out the collection
variables value (1). Did I do something wrong or should I use a different
type of variable?
So, normally for detecting user input, I use int and double variable types.
Example:
Scanner in = new Scanner(System.in);
int selection;
System.out.println("Welcome to RPG! (prototype name)\nIn this game,
you do stuff.\nChoose a class:\n1. Soldier\n2. Knight\n3. Paladin\n4.
Heavy");
selection = in.nextInt();
if(selection == 1){
System.out.print("you are a soldier");
}
else{
System.out.print(selection);
}
}
This technique usually works fine for me, but I noticed that if the user
inputs a letter into the int variable, the game will crash because
integers can't store letters. (right?) So I tried using a String variable
in its place, like this:
Scanner in = new Scanner(System.in);
String selection;
System.out.println("Welcome to RPG! (prototype name)\nIn this game,
you do stuff. Level up, yo!\nChoose a class:\n1. Soldier\n2.
Knight\n3. Paladin\n4. Heavy");
selection = in.next();
if(selection == "1"){
System.out.print("you are a soldier");
}
else{
System.out.print(selection);
}
}
This seemed to work at first, but as you can see, I have it set so that if
the variable "selection" is equal to 1, that it will print "you are a
soldier", yet this did not work, instead it printed out the collection
variables value (1). Did I do something wrong or should I use a different
type of variable?
iOS - Load UIViewController in Specific Orientation
iOS - Load UIViewController in Specific Orientation
What i'm trying to do - is simply force start my ViewController in
Portrait mode regardless of its orientation:
after its initiated, it could just continue to follow the AutoRotate
functionality
This is probably along the answer I'm looking for : but the answer
contains a broken link
---- if interested, the reason i need this is:
i'm creating a PDF Reader in a UIView
in Portrait mode it can use the screen dimensions to load the PDF
proportionately
the UIView is set to UIViewAutoReSizingNone and UIViewContentModeLeft
this presents the PDF perfectly when the device Orientation changes to
landscape (of course I'm handling panning / zooming / positioning of the
PDF separately for a better presentation)
But when I launch the VC in landscape I have problems . . . .
What i'm trying to do - is simply force start my ViewController in
Portrait mode regardless of its orientation:
after its initiated, it could just continue to follow the AutoRotate
functionality
This is probably along the answer I'm looking for : but the answer
contains a broken link
---- if interested, the reason i need this is:
i'm creating a PDF Reader in a UIView
in Portrait mode it can use the screen dimensions to load the PDF
proportionately
the UIView is set to UIViewAutoReSizingNone and UIViewContentModeLeft
this presents the PDF perfectly when the device Orientation changes to
landscape (of course I'm handling panning / zooming / positioning of the
PDF separately for a better presentation)
But when I launch the VC in landscape I have problems . . . .
PHP: use a variable to reference a defined variable, w/o eval
PHP: use a variable to reference a defined variable, w/o eval
That title probably doesn't help much. I'm trying to figure out if there's
a way to get the value of a variable that has been set using define(...),
but using a 2nd variable to build the defined var's name. Example will be
clearer:
define('I_LOVE_YOU', 'xoxox');
$n = 'LOVE';
// how to get 'xoxox', using $n? This won't work:
$defd = 'I_'.$n.'_YOU';
echo $defd; // obviously echos 'I_LOVE_YOU', not 'xoxox'
// this will, but is awful
eval('echo I_'.$defd.'_YOU;'); // echos 'xoxox'
Is there any other way to do this, w/o resorting to eval?
That title probably doesn't help much. I'm trying to figure out if there's
a way to get the value of a variable that has been set using define(...),
but using a 2nd variable to build the defined var's name. Example will be
clearer:
define('I_LOVE_YOU', 'xoxox');
$n = 'LOVE';
// how to get 'xoxox', using $n? This won't work:
$defd = 'I_'.$n.'_YOU';
echo $defd; // obviously echos 'I_LOVE_YOU', not 'xoxox'
// this will, but is awful
eval('echo I_'.$defd.'_YOU;'); // echos 'xoxox'
Is there any other way to do this, w/o resorting to eval?
Remove all border on all panelgrids
Remove all border on all panelgrids
I need to hide all borders of all panelgrids using primefaces. I have
tried he following without effects:
table {
border: none;
}
table tr, table td {
border: none;
}
What can I do?
I need to hide all borders of all panelgrids using primefaces. I have
tried he following without effects:
table {
border: none;
}
table tr, table td {
border: none;
}
What can I do?
abt naudio input and output devices
abt naudio input and output devices
I am pretty new to Naudio, trying to understand it, I require the
following to be done in my application
I have couple of devices connected to my system say 1) head set - with a
mic 2) inbuilt system mic and speakers
I require to do the following the audio from the two input devices(headset
mic and system mic) should be mixed and a byte array needs to be
constructed. how can this be done using naudio
Also, the system speakers and headset would receive a stream that needs to
played on both any concept ? or classes that i can use ?
I am pretty new to Naudio, trying to understand it, I require the
following to be done in my application
I have couple of devices connected to my system say 1) head set - with a
mic 2) inbuilt system mic and speakers
I require to do the following the audio from the two input devices(headset
mic and system mic) should be mixed and a byte array needs to be
constructed. how can this be done using naudio
Also, the system speakers and headset would receive a stream that needs to
played on both any concept ? or classes that i can use ?
Translate cancel and save buttons in [weekCalendar jquery plugin]
Translate cancel and save buttons in [weekCalendar jquery plugin]
I'd like to translate buttons - "save" and "cancel" in weekCalendar jquery
plugin, I'd tried to search in files for I couldnt find in files
translatable "save" or "cancel" text, any one have ever tried doing that
or any suggestions how to achieve using jquery ?
Link to plugin
I'd like to translate buttons - "save" and "cancel" in weekCalendar jquery
plugin, I'd tried to search in files for I couldnt find in files
translatable "save" or "cancel" text, any one have ever tried doing that
or any suggestions how to achieve using jquery ?
Link to plugin
MQ Queue with multiple consumers but only one active
MQ Queue with multiple consumers but only one active
We have one MQ Queue which receives messages from an external system out
of our control. Our system processing the incoming messages is a critical
one and needs to be up and running 27x7 no matter what.
The order in which the incoming messages are processed is also not
negotiable which means we need to process them in exactly the order they
arrived.
To make sure our system is 100% available we deployed our system to a
bunch of physical machines able to process those messages.
Once the messages reached our system we put in place a mechanism to make
sure the messages processing does not go out of order while also getting
some performance gain as a result of the parallel processing. For us the
performance gain is a good to have, however it is rather a side effect as
our main goal is the high availability while assuring the right processing
order.
My thoughts were to have on every single machine an MDB able to process
the incoming messages but only have one active consumer at a time.
We are using Webshere MQ as a JMS provider and Webshere Application Server
8.5 to deploy our application.
The problem with multiple consumers listening to the same queue does not
seem to be a workable solution as when messages arrive in bulk they would
be round-robin passed to all consumers and there is no way to control how
this is going to happen and the messages easily go out of sequence.
When I manually stopped all the listeners but one obviously the messages
got processed in order. But manually shutting down and starting up such
listeners is definitely not a HA solution.
We could put in place monitoring processes to check for health of the
system and shut things down or start them up as required but this still
looks too weak to me. What we want in fact is to have all listeners up and
running but only one receiving the messages. If that one goes down for
whatever reasons then another one sitting there will become active and
start processing messages.
Initially we considered using a topic rather than a queue but this comes
with other issues like below:
we cannot control the source of our messages
the high volume of messages we have would put us in in trouble with our
going down subscribers that have to be durable and such when coming up
back will have to deal with lots of pending messages
the input queues are already part of a cluster and changing all the
infrastructure would require a lot of work
Anyway in my view it has to be an existing pattern to accommodate
situations like this. Any help, suggestion would be greatly appreciated.
The solution does not have to be a specific MQ one, any idea is welcome.
Thanks in advance
We have one MQ Queue which receives messages from an external system out
of our control. Our system processing the incoming messages is a critical
one and needs to be up and running 27x7 no matter what.
The order in which the incoming messages are processed is also not
negotiable which means we need to process them in exactly the order they
arrived.
To make sure our system is 100% available we deployed our system to a
bunch of physical machines able to process those messages.
Once the messages reached our system we put in place a mechanism to make
sure the messages processing does not go out of order while also getting
some performance gain as a result of the parallel processing. For us the
performance gain is a good to have, however it is rather a side effect as
our main goal is the high availability while assuring the right processing
order.
My thoughts were to have on every single machine an MDB able to process
the incoming messages but only have one active consumer at a time.
We are using Webshere MQ as a JMS provider and Webshere Application Server
8.5 to deploy our application.
The problem with multiple consumers listening to the same queue does not
seem to be a workable solution as when messages arrive in bulk they would
be round-robin passed to all consumers and there is no way to control how
this is going to happen and the messages easily go out of sequence.
When I manually stopped all the listeners but one obviously the messages
got processed in order. But manually shutting down and starting up such
listeners is definitely not a HA solution.
We could put in place monitoring processes to check for health of the
system and shut things down or start them up as required but this still
looks too weak to me. What we want in fact is to have all listeners up and
running but only one receiving the messages. If that one goes down for
whatever reasons then another one sitting there will become active and
start processing messages.
Initially we considered using a topic rather than a queue but this comes
with other issues like below:
we cannot control the source of our messages
the high volume of messages we have would put us in in trouble with our
going down subscribers that have to be durable and such when coming up
back will have to deal with lots of pending messages
the input queues are already part of a cluster and changing all the
infrastructure would require a lot of work
Anyway in my view it has to be an existing pattern to accommodate
situations like this. Any help, suggestion would be greatly appreciated.
The solution does not have to be a specific MQ one, any idea is welcome.
Thanks in advance
Wednesday, 18 September 2013
Should I make sure to destroy SDL 2.0 objects (renderer, window, textures, etc.) before exiting the program?
Should I make sure to destroy SDL 2.0 objects (renderer, window, textures,
etc.) before exiting the program?
This tutorial on SDL 2.0 uses code that returns from main without first
destroying any of the resource pointers:
int main(int argc, char** argv){
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
std::cout << SDL_GetError() << std::endl;
return 1;
}
window = SDL_CreateWindow("Lesson 2", SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_SHOWN);
if (window == nullptr){
std::cout << SDL_GetError() << std::endl;
return 2; //this
}
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED
| SDL_RENDERER_PRESENTVSYNC);
if (renderer == nullptr){
std::cout << SDL_GetError() << std::endl;
return 3; //and this too
}
Should I tell my terminate function to DestroyRenderer, DestroyWindow,
DestroyTexture, etc. before exiting?
etc.) before exiting the program?
This tutorial on SDL 2.0 uses code that returns from main without first
destroying any of the resource pointers:
int main(int argc, char** argv){
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
std::cout << SDL_GetError() << std::endl;
return 1;
}
window = SDL_CreateWindow("Lesson 2", SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_SHOWN);
if (window == nullptr){
std::cout << SDL_GetError() << std::endl;
return 2; //this
}
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED
| SDL_RENDERER_PRESENTVSYNC);
if (renderer == nullptr){
std::cout << SDL_GetError() << std::endl;
return 3; //and this too
}
Should I tell my terminate function to DestroyRenderer, DestroyWindow,
DestroyTexture, etc. before exiting?
I want to read a file line by line and split the strings to be used as attributes for a new object
I want to read a file line by line and split the strings to be used as
attributes for a new object
I'm trying to read from a txt file that has the following format:
Matthew:1000
Mark:100
Luke:10
John:0
Actually, there is no extra space between the lines, I just couldn't get
it to look like that.
I have a Score object that stores the player's name and score (int). This
is the class for Score:
public class Score {
String playerName;
int playerScore;
public String toString(){
StringBuilder builder = new StringBuilder();
builder.append(playerName + ":" + playerScore);
return builder.toString();
}
public void setName(String name){
this.playerName = name;
}
public void setScore(int score){
this.playerScore = score;
}
}
I would like to read from the file in such a way that I could get the
player's name (Matthew) and their score (1000, stored as an integer), and
make a new Score object. This is the code I've tried so far:
public ArrayList getLoadFile(String filename) {
ArrayList<Score> scores = new ArrayList<Score>();
BufferedReader bufferedReader = null;
try{
bufferedReader = new BufferedReader(new FileReader(filename));
String fileLine;
while((fileLine = bufferedReader.readLine()) != null){
Score newScore = new Score();
newScore.playerName = fileLine.split(":", 0)[0];
newScore.playerScore = Integer.parseInt(fileLine.split(":",
0)[1]);
scores.add(newScore);
}
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
return scores;
}
This function is supposed to load string representations of saved scores
and make an ArrayList of scores, then return them to a test function. When
I run it, it returns: java.lang.ArrayIndexOutOfBoundsException: 1
Any help would be greatly appreciated.
attributes for a new object
I'm trying to read from a txt file that has the following format:
Matthew:1000
Mark:100
Luke:10
John:0
Actually, there is no extra space between the lines, I just couldn't get
it to look like that.
I have a Score object that stores the player's name and score (int). This
is the class for Score:
public class Score {
String playerName;
int playerScore;
public String toString(){
StringBuilder builder = new StringBuilder();
builder.append(playerName + ":" + playerScore);
return builder.toString();
}
public void setName(String name){
this.playerName = name;
}
public void setScore(int score){
this.playerScore = score;
}
}
I would like to read from the file in such a way that I could get the
player's name (Matthew) and their score (1000, stored as an integer), and
make a new Score object. This is the code I've tried so far:
public ArrayList getLoadFile(String filename) {
ArrayList<Score> scores = new ArrayList<Score>();
BufferedReader bufferedReader = null;
try{
bufferedReader = new BufferedReader(new FileReader(filename));
String fileLine;
while((fileLine = bufferedReader.readLine()) != null){
Score newScore = new Score();
newScore.playerName = fileLine.split(":", 0)[0];
newScore.playerScore = Integer.parseInt(fileLine.split(":",
0)[1]);
scores.add(newScore);
}
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
return scores;
}
This function is supposed to load string representations of saved scores
and make an ArrayList of scores, then return them to a test function. When
I run it, it returns: java.lang.ArrayIndexOutOfBoundsException: 1
Any help would be greatly appreciated.
Xsl count based on Filtered node
Xsl count based on Filtered node
I have the following xml:
<Activity>
<item>
<task>XXX</task>
<assignto>User1</assignto>
</item>
<item>
<task>YYY</task>
<assignto>User2</assignto>
</item>
<item>
<task>ZZZ</task>
<assignto>User1</assignto>
</item>
<team>
<member>User1</member>
<member>User2</member>
<team>
</Activity>
I want to generate using XSL a count of task per member in the team.
User- Count
user1- 2
user2- 1
so far I have the following XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table>
<tr>
<th>User</th>
<th>Task Count</th>
</tr>
<xsl:for-each select="Activity/team/member">
<tr>
<td><xsl:value-of select="node()" /></td>
<td><xsl:value-of
select="count(/Activity/item[assignto='user1'])" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
so far I hardcoded 'user1', I would like to filter based on the current
member in the for each loop.
Can someone help, please?
Thanks,
I have the following xml:
<Activity>
<item>
<task>XXX</task>
<assignto>User1</assignto>
</item>
<item>
<task>YYY</task>
<assignto>User2</assignto>
</item>
<item>
<task>ZZZ</task>
<assignto>User1</assignto>
</item>
<team>
<member>User1</member>
<member>User2</member>
<team>
</Activity>
I want to generate using XSL a count of task per member in the team.
User- Count
user1- 2
user2- 1
so far I have the following XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table>
<tr>
<th>User</th>
<th>Task Count</th>
</tr>
<xsl:for-each select="Activity/team/member">
<tr>
<td><xsl:value-of select="node()" /></td>
<td><xsl:value-of
select="count(/Activity/item[assignto='user1'])" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
so far I hardcoded 'user1', I would like to filter based on the current
member in the for each loop.
Can someone help, please?
Thanks,
Deploy no Windows Phone 8 rodando dentro do virtualbox
Deploy no Windows Phone 8 rodando dentro do virtualbox
Estou usando linux opensuse como hospedeiro, com sua vm aberta uma com o
windows 8.1 pro e outra com Windows phone 8, usando o virtual box, alguém
sabe como fazer deploy da minha aplicação para o windows phone?
Estou usando linux opensuse como hospedeiro, com sua vm aberta uma com o
windows 8.1 pro e outra com Windows phone 8, usando o virtual box, alguém
sabe como fazer deploy da minha aplicação para o windows phone?
DB4o update vs insert
DB4o update vs insert
Assuming you are using DB4O with the standard configuration and
out-of-the-box - meaning, you are using DB4O's standard internal id
scheme, as per below*.
First, as an assumption, when updating or inserting an object into the
database, the programmer only has one option, to call
"objectContainer.store(object)".
Now, how does DB4O know whether to update an existing object in the DB, or
to insert an entirely new one? My guess is that DB4O looks to see if the
internal id of the object is not null.
However, I could also see the possibility that the burden is on the
programmer to first pull the object from the DB, then update it. So my
question is, how can we reliably update an object in a DB4O database
without first pulling it into Java memory?
*This is very informative:
http://community.versant.com/documentation/Reference/db4o-8.1/java/reference/Content/platform_specific_issues/disconnected_objects/comparison_of_ids.htm
Assuming you are using DB4O with the standard configuration and
out-of-the-box - meaning, you are using DB4O's standard internal id
scheme, as per below*.
First, as an assumption, when updating or inserting an object into the
database, the programmer only has one option, to call
"objectContainer.store(object)".
Now, how does DB4O know whether to update an existing object in the DB, or
to insert an entirely new one? My guess is that DB4O looks to see if the
internal id of the object is not null.
However, I could also see the possibility that the burden is on the
programmer to first pull the object from the DB, then update it. So my
question is, how can we reliably update an object in a DB4O database
without first pulling it into Java memory?
*This is very informative:
http://community.versant.com/documentation/Reference/db4o-8.1/java/reference/Content/platform_specific_issues/disconnected_objects/comparison_of_ids.htm
Character Pointers and Case Sensitive when checking if a string is a palindrome in C
Character Pointers and Case Sensitive when checking if a string is a
palindrome in C
my code here checks a string to see if it is a palindrome. However, it
doesn't check for uppercase letters and it also doesn't use character
pointers which I am supposed to use in this program. Can someone give me
some tips?
#include <stdio.h>
#include <string.h>
int main(){
char string1[20];
int i, length;
int flag = 0;
printf("Enter a string: ");
scanf("%s", string1);
length = strlen(string1);
for(i=0;i < length ;i++){
if((string1[i]) != (string1[length-i-1])){
flag = 1;
break;
}
}
if (flag)
printf("%s is not a palindrome \n\n", string1);
else
printf("%s is a palindrome \n", string1);
return 0;
}
palindrome in C
my code here checks a string to see if it is a palindrome. However, it
doesn't check for uppercase letters and it also doesn't use character
pointers which I am supposed to use in this program. Can someone give me
some tips?
#include <stdio.h>
#include <string.h>
int main(){
char string1[20];
int i, length;
int flag = 0;
printf("Enter a string: ");
scanf("%s", string1);
length = strlen(string1);
for(i=0;i < length ;i++){
if((string1[i]) != (string1[length-i-1])){
flag = 1;
break;
}
}
if (flag)
printf("%s is not a palindrome \n\n", string1);
else
printf("%s is a palindrome \n", string1);
return 0;
}
I want to finish the activity from an other activity on pressing the back button
I want to finish the activity from an other activity on pressing the back
button
I have an activity named QRCodeReader it has a back button on it. It scans
the qr code and pass the id to MetaioCloudARViewTestActivity to start the
channel. Its working fine. But when i press the back button of the
qrCodeReader it finishes the current activity but it loads the blank arel
camera web view of MetaioCloudARViewTestActivity. So i want to finish that
the web view also. If i use the finish in onResume of
MetaioCloudARViewTestActivity it works fine for back button of
QRCodeReader. But i need that activity when i have to scan the code. I
just want to finish it on pressing the back button in QRCodeReader.
button
I have an activity named QRCodeReader it has a back button on it. It scans
the qr code and pass the id to MetaioCloudARViewTestActivity to start the
channel. Its working fine. But when i press the back button of the
qrCodeReader it finishes the current activity but it loads the blank arel
camera web view of MetaioCloudARViewTestActivity. So i want to finish that
the web view also. If i use the finish in onResume of
MetaioCloudARViewTestActivity it works fine for back button of
QRCodeReader. But i need that activity when i have to scan the code. I
just want to finish it on pressing the back button in QRCodeReader.
How to post long text to facebook wall thru javascript
How to post long text to facebook wall thru javascript
I try to post custom text to facebook wall. I found good example:
http://www.fbrell.com/fb.ui/feed And this is work, but not exactly what i
expected
If text that I send more then ~300 characters, facebook cut it without
"see more" button And not way to see full text, and this is a problem
I tried play with parameters, but seems that this is not right way Tried
to find other component, but seems that dialog-feed more suitable for my
purpose
Thanks
I try to post custom text to facebook wall. I found good example:
http://www.fbrell.com/fb.ui/feed And this is work, but not exactly what i
expected
If text that I send more then ~300 characters, facebook cut it without
"see more" button And not way to see full text, and this is a problem
I tried play with parameters, but seems that this is not right way Tried
to find other component, but seems that dialog-feed more suitable for my
purpose
Thanks
Tuesday, 17 September 2013
Web services consumption and calling
Web services consumption and calling
I want to ask how can I add web service into my already existing MVC 4.0
project? I have searched on Internet, in all the links they are saying to
create a new application/solution but I want to add a web service and how
It will be available to call from other web sites. Can somebody please
tell me the steps for it. I will be thankful to you. I just have basic
knowledge of .Net.
2)Suppose I have to call a web service from another site so how will I
able to call that service if I do not have my own?
I have searched following links:
http://www.aspdotnet-suresh.com/2011/05/aspnet-web-service-or-creating-and.html
http://www.codeproject.com/Articles/337535/Understanding-the-Basics-of-Web-Service-in-ASP-NET
I want to ask how can I add web service into my already existing MVC 4.0
project? I have searched on Internet, in all the links they are saying to
create a new application/solution but I want to add a web service and how
It will be available to call from other web sites. Can somebody please
tell me the steps for it. I will be thankful to you. I just have basic
knowledge of .Net.
2)Suppose I have to call a web service from another site so how will I
able to call that service if I do not have my own?
I have searched following links:
http://www.aspdotnet-suresh.com/2011/05/aspnet-web-service-or-creating-and.html
http://www.codeproject.com/Articles/337535/Understanding-the-Basics-of-Web-Service-in-ASP-NET
(Reading CSV file) scanf skip to next line of input after pattern mismatch
(Reading CSV file) scanf skip to next line of input after pattern mismatch
I want to give an error message if scanf encounters a mismatch and then
continue reading the rest of the inputs. My current code goes into an
infinite loop if one of the inputs isn't formatted correctly.
Expected input:
101,Betty,Hay,123 Main St.,23
234,Sheila,Benn,937 Ash Ave.,46
384,Ron,Jewell,3991 Cedar Ave.,30
291,Bill,Read,83 Crescent St.,19
103,Alexander,Ott,100 2nd St.,21
115,Tricia,Munson,585 Oxen Ave.,28
118,Sam,Munson,585 Oxen Ave.,35
110,Valerie,Parker,1513 Copper Rd.,37
Code:
#include <stdio.h>
int main()
{
int sum = 0;
int count = 0;
while (1)
{
int id;
char first[80], last[80], addr[80];
int age;
scanf("%d,%80[^,],%80[^,],%80[^,],%d", &id, first, last, addr, &age);
if (feof(stdin)) break;
printf("id=%d first=%s last=%s addr=%s age=%d\n",
id, first, last, addr, age);
sum += age;
count++;
}
printf("Average age is %f\n", (float)sum / count);
return 0;
}
I tried to fix this by putting scanf inside an if statement comparing it
to the expected number of reads, this worked for displaying the error
message but doesn't help reading the rest of the input. Is there a way to
skip to the next line of input?
I want to give an error message if scanf encounters a mismatch and then
continue reading the rest of the inputs. My current code goes into an
infinite loop if one of the inputs isn't formatted correctly.
Expected input:
101,Betty,Hay,123 Main St.,23
234,Sheila,Benn,937 Ash Ave.,46
384,Ron,Jewell,3991 Cedar Ave.,30
291,Bill,Read,83 Crescent St.,19
103,Alexander,Ott,100 2nd St.,21
115,Tricia,Munson,585 Oxen Ave.,28
118,Sam,Munson,585 Oxen Ave.,35
110,Valerie,Parker,1513 Copper Rd.,37
Code:
#include <stdio.h>
int main()
{
int sum = 0;
int count = 0;
while (1)
{
int id;
char first[80], last[80], addr[80];
int age;
scanf("%d,%80[^,],%80[^,],%80[^,],%d", &id, first, last, addr, &age);
if (feof(stdin)) break;
printf("id=%d first=%s last=%s addr=%s age=%d\n",
id, first, last, addr, age);
sum += age;
count++;
}
printf("Average age is %f\n", (float)sum / count);
return 0;
}
I tried to fix this by putting scanf inside an if statement comparing it
to the expected number of reads, this worked for displaying the error
message but doesn't help reading the rest of the input. Is there a way to
skip to the next line of input?
decompress GIF with multiple data-blocks
decompress GIF with multiple data-blocks
I wrote python script that takes GIF data like this :
['8c', '2d', '99', '87', '2a', '1c', 'dc']
and turn it to this:
[1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
first I get all the data in all the blocks and turn it to a stream of bits
>> I am not sure about this step .I don't know if I have to decompress all
the blocks at once as one stream or decompress them Individually
for byte in data:
bit=bin(int(m,16))[2:]
while len(bit)<8:
bit='0'+bit
c.append(bit[::-1] )
stream= ''.join(c)
decompress(stream)
here is the decompress function
def decompress(s,InitialCodeSize):
index=[]
table=Initialize(InitialCodeSize)
codesize = InitialCodeSize + 1
ClearCode=int(math.pow(2, InitialCodeSize))
L=int(math.pow(2, codesize))
code = int(s[:codesize][::-1],2)
s=s[codesize:]
c = table[code]
old = c
for i in c:
index.append(i)
while s !='':
code = int(s[:codesize][::-1],2)
s=s[codesize:]
if code == ClearCode:
table=Initialize(InitialCodeSize)
codesize = InitialCodeSize + 1
if code in list(xrange(len(table ))):
c=table[code]
table.append(old + [c[0]])
else:
table.append(old + [old[0]])
c= old + [old[0]]
for i in c:
index.append(i)
old=c
if len(table) == L and codesize< 12:
codesize=codesize+1
L=int(math.pow(2, codesize))
return index
everything work just fine when the image has few blocks but when it has
more blocks it always return smaller number of pixels
for example if the image 522*200 =104400 pixels it give me only 61806
pixels I though maybe the GIF format uses RLE encoding
I wrote python script that takes GIF data like this :
['8c', '2d', '99', '87', '2a', '1c', 'dc']
and turn it to this:
[1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
first I get all the data in all the blocks and turn it to a stream of bits
>> I am not sure about this step .I don't know if I have to decompress all
the blocks at once as one stream or decompress them Individually
for byte in data:
bit=bin(int(m,16))[2:]
while len(bit)<8:
bit='0'+bit
c.append(bit[::-1] )
stream= ''.join(c)
decompress(stream)
here is the decompress function
def decompress(s,InitialCodeSize):
index=[]
table=Initialize(InitialCodeSize)
codesize = InitialCodeSize + 1
ClearCode=int(math.pow(2, InitialCodeSize))
L=int(math.pow(2, codesize))
code = int(s[:codesize][::-1],2)
s=s[codesize:]
c = table[code]
old = c
for i in c:
index.append(i)
while s !='':
code = int(s[:codesize][::-1],2)
s=s[codesize:]
if code == ClearCode:
table=Initialize(InitialCodeSize)
codesize = InitialCodeSize + 1
if code in list(xrange(len(table ))):
c=table[code]
table.append(old + [c[0]])
else:
table.append(old + [old[0]])
c= old + [old[0]]
for i in c:
index.append(i)
old=c
if len(table) == L and codesize< 12:
codesize=codesize+1
L=int(math.pow(2, codesize))
return index
everything work just fine when the image has few blocks but when it has
more blocks it always return smaller number of pixels
for example if the image 522*200 =104400 pixels it give me only 61806
pixels I though maybe the GIF format uses RLE encoding
how do I properly incorporate arrays into for loops in jquery/javascript?
how do I properly incorporate arrays into for loops in jquery/javascript?
I am working on a custom gallery right now, but I cannot seem to get the
array of variables to apply during the loop. What am I missing?
Here is the relevant code:
var racerImage = ['$("img.ryanthumb")', '$("img.pierthumb")',
'$("img.jeremythumb")',
'$("img.mattthumb")', '$("img.andrewthumb")', '$("img.alanthumb")',
'$("img.kevinthumb")', '$("img.mikethumb")', '$("img.dougthumb")'];
var showMe= ['showRacer("ryan")\;', 'showRacer("pier")\;',
'showRacer("jeremy")\;', 'showRacer("matt")\;',
'showRacer("andrew")\;',
'showRacer("alan")\;', 'showRacer("kevin")\;', 'showRacer("mike")\;',
'showRacer("doug")\;'];
for (var i = 0; i < racerImage.length; i++)
{
racerImage[i].click(function(){
switch (i)
{
case 0:
showMe[i];
break;
case 1:
showMe[i];
break;
case 2:
showMe[i];
break;
case 3:
showMe[i];
break;
case 4:
showMe[i];
break;
case 5:
showMe[i];
break;
case 6:
showMe[i];
break;
case 7:
showMe[i];
break;
case 8:
showMe[i];
break;
}
});
}
Basically I am trying to use a for loop to apply the jquery multiple times
instead of writing it over and over again. I don't know if I am going
about this the right way, but any insights would be great. Thanks again!
I am working on a custom gallery right now, but I cannot seem to get the
array of variables to apply during the loop. What am I missing?
Here is the relevant code:
var racerImage = ['$("img.ryanthumb")', '$("img.pierthumb")',
'$("img.jeremythumb")',
'$("img.mattthumb")', '$("img.andrewthumb")', '$("img.alanthumb")',
'$("img.kevinthumb")', '$("img.mikethumb")', '$("img.dougthumb")'];
var showMe= ['showRacer("ryan")\;', 'showRacer("pier")\;',
'showRacer("jeremy")\;', 'showRacer("matt")\;',
'showRacer("andrew")\;',
'showRacer("alan")\;', 'showRacer("kevin")\;', 'showRacer("mike")\;',
'showRacer("doug")\;'];
for (var i = 0; i < racerImage.length; i++)
{
racerImage[i].click(function(){
switch (i)
{
case 0:
showMe[i];
break;
case 1:
showMe[i];
break;
case 2:
showMe[i];
break;
case 3:
showMe[i];
break;
case 4:
showMe[i];
break;
case 5:
showMe[i];
break;
case 6:
showMe[i];
break;
case 7:
showMe[i];
break;
case 8:
showMe[i];
break;
}
});
}
Basically I am trying to use a for loop to apply the jquery multiple times
instead of writing it over and over again. I don't know if I am going
about this the right way, but any insights would be great. Thanks again!
Delay function in jquery
Delay function in jquery
I'm pretty new to jquery and I couldn't make .delay work. Can you please
check this fiddle? (note: I don't want to use .queue or .settimeout or any
other method, I want to learn how to use .delay)
http://jsfiddle.net/YMmD7/1/
$(document).ready(function(){
$(".box").click(function(){
$(".box").hide().delay(1000).show();
});
});
I'm pretty new to jquery and I couldn't make .delay work. Can you please
check this fiddle? (note: I don't want to use .queue or .settimeout or any
other method, I want to learn how to use .delay)
http://jsfiddle.net/YMmD7/1/
$(document).ready(function(){
$(".box").click(function(){
$(".box").hide().delay(1000).show();
});
});
Worklight 6.0 fixpack 1 install error
Worklight 6.0 fixpack 1 install error
Getting error on install of 6.0 Worklight server to Fix pack 1:
WASX7017E: Exception received while running file "D:\Program
Files\IBM\Worklight1\WorklightServer\uninstall\was-install.py"; exception
information: com.ibm.websphere.wim.exception.WIMApplicationException:
com.ibm.websphere.wim.exception.WIMApplicationException: CWWIM5505E To
manage users and groups, either federated repositories must be the current
realm definition or the current realm definition configuration must match
the federated repositories configuration. If you use Lightweight Directory
Access Protocol (LDAP), configure both the federated repositories and
standalone LDAP registry configurations to use the same LDAP server.
Security is LDAP (Active Directory), but, looking at script
(was-install.py), it is hard-coded looking for a user called
"appcenteradmin", which, which we do not use (we've allowed admin access
to another user). Is this user "appcenteradmin" now required?
The was-install.py has this comment:
If the custom panels have told the user that an account 'appcenteradmin' will
be created, do so now.
But, there is no panel indicating this in the IBM Installation Manager
screens.
Getting error on install of 6.0 Worklight server to Fix pack 1:
WASX7017E: Exception received while running file "D:\Program
Files\IBM\Worklight1\WorklightServer\uninstall\was-install.py"; exception
information: com.ibm.websphere.wim.exception.WIMApplicationException:
com.ibm.websphere.wim.exception.WIMApplicationException: CWWIM5505E To
manage users and groups, either federated repositories must be the current
realm definition or the current realm definition configuration must match
the federated repositories configuration. If you use Lightweight Directory
Access Protocol (LDAP), configure both the federated repositories and
standalone LDAP registry configurations to use the same LDAP server.
Security is LDAP (Active Directory), but, looking at script
(was-install.py), it is hard-coded looking for a user called
"appcenteradmin", which, which we do not use (we've allowed admin access
to another user). Is this user "appcenteradmin" now required?
The was-install.py has this comment:
If the custom panels have told the user that an account 'appcenteradmin' will
be created, do so now.
But, there is no panel indicating this in the IBM Installation Manager
screens.
Sunday, 15 September 2013
How does --data option work in curl
How does --data option work in curl
curl --data "<xml>" --header "Content-Type: text/xml" --request PROPFIND
url.com
By reading the curl man page I could not understand how the above
commandline is using --data option.
Question:
What does above commandline do ?
Why doesn't man page describe this usage? If it does then what did I not
understand after reading the man page?
curl --data "<xml>" --header "Content-Type: text/xml" --request PROPFIND
url.com
By reading the curl man page I could not understand how the above
commandline is using --data option.
Question:
What does above commandline do ?
Why doesn't man page describe this usage? If it does then what did I not
understand after reading the man page?
Android - Stopping Little Fluffy Location Service
Android - Stopping Little Fluffy Location Service
I am testing out the really nice Little Fluffy Location Service
(https://code.google.com/p/little-fluffy-location-library/), but I can't
figure out how to stop the service. It seems to continue forever.
How can this service be stopped, and also started later?
I am testing out the really nice Little Fluffy Location Service
(https://code.google.com/p/little-fluffy-location-library/), but I can't
figure out how to stop the service. It seems to continue forever.
How can this service be stopped, and also started later?
Android ListView showing images results in out of memory
Android ListView showing images results in out of memory
Okay,
I have what I think is an odd problem.
I load photos into a list view as the user scroll (meaning if picked up
from disk or online, it takes a little time and they "pop in")
1)
I ensure that I only fetch one image online + resize to 1/3 width at a
time (a lock) -- this is to ensure not e.g. 5 threads each are converting
a .jpg to bitmap at the same time. (Imagine a user scrolling very fast, it
would then be conceivable this could happen.)
2)
All images on disk are only 1/3 width
3)
While the bitmaps are scaled up to fit device width, I call recycle and
set bitmaps to null when used in the getView. (I am converting bitmaps to
a BitmapDrawable object which the listitem imageview uses in a
setImageDrawable call)
I am testing on a Samsung Galaxy II. Do you guys have any ideas on what
more I could try? Since I only max need to show 10 items, I would think it
should be possible...
Okay,
I have what I think is an odd problem.
I load photos into a list view as the user scroll (meaning if picked up
from disk or online, it takes a little time and they "pop in")
1)
I ensure that I only fetch one image online + resize to 1/3 width at a
time (a lock) -- this is to ensure not e.g. 5 threads each are converting
a .jpg to bitmap at the same time. (Imagine a user scrolling very fast, it
would then be conceivable this could happen.)
2)
All images on disk are only 1/3 width
3)
While the bitmaps are scaled up to fit device width, I call recycle and
set bitmaps to null when used in the getView. (I am converting bitmaps to
a BitmapDrawable object which the listitem imageview uses in a
setImageDrawable call)
I am testing on a Samsung Galaxy II. Do you guys have any ideas on what
more I could try? Since I only max need to show 10 items, I would think it
should be possible...
Adding KeyListeners to JPanel not working
Adding KeyListeners to JPanel not working
I've just completed an online tutorial on making a networked game. The
game it's self is just a small circle that follows the mouse when on the
screen.
I've been modifying the code to use keys to move the circle instead of the
mouse. However whilst I've done this before I've never used "JPanel" and
I'm struggling to get the keys to move the circle around.
The game's 'client' side only consists of two files, Client.java and
DataPackage.java, the problem (to my knowledge) appears to be in
Client.java.
I wont paste the whole code as it is quite big (i will if you think it is
necessary), but here is the bit that makes the ball follow the mouse
public Client()
{
this.addMouseMotionListener(new MouseMotionListener()
{
@Override
public void mouseDragged(MouseEvent e)
{
x = e.getX();
y = e.getY();
}
@Override
public void mouseMoved(MouseEvent e) {}
});
}
now I've tried just changing
this.addMouseMotionListener(new MouseMotionListener()
{
@Override
public void mouseDragged(MouseEvent e)
{
x = e.getX();
y = e.getY();
}
@Override
public void mouseMoved(MouseEvent e) {}
});
to
this.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) { System.out.println(
"tester"); }
public void keyReleased(KeyEvent e) {
System.out.println("2test2"); }
public void keyTyped(KeyEvent e) {
System.out.println("3test3"); }
});
but this didn't appear to work, then i tried changing the location of the
keying code by putting it outside of the
public Client() { }
Then I thought it could be the 'implements' tags at the top of the file.
so I added
implements KeyListener
to the end of
public class Client extends JComponent
but again, this did not work then I did some more research and it seems
that I need to set the panel to be focused by using
panel.setFocusable(true);
but the source of this information, failed to say where to put it and
everywhere I put it throws an error
Can someone shed some light on this for me please?
I've just completed an online tutorial on making a networked game. The
game it's self is just a small circle that follows the mouse when on the
screen.
I've been modifying the code to use keys to move the circle instead of the
mouse. However whilst I've done this before I've never used "JPanel" and
I'm struggling to get the keys to move the circle around.
The game's 'client' side only consists of two files, Client.java and
DataPackage.java, the problem (to my knowledge) appears to be in
Client.java.
I wont paste the whole code as it is quite big (i will if you think it is
necessary), but here is the bit that makes the ball follow the mouse
public Client()
{
this.addMouseMotionListener(new MouseMotionListener()
{
@Override
public void mouseDragged(MouseEvent e)
{
x = e.getX();
y = e.getY();
}
@Override
public void mouseMoved(MouseEvent e) {}
});
}
now I've tried just changing
this.addMouseMotionListener(new MouseMotionListener()
{
@Override
public void mouseDragged(MouseEvent e)
{
x = e.getX();
y = e.getY();
}
@Override
public void mouseMoved(MouseEvent e) {}
});
to
this.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) { System.out.println(
"tester"); }
public void keyReleased(KeyEvent e) {
System.out.println("2test2"); }
public void keyTyped(KeyEvent e) {
System.out.println("3test3"); }
});
but this didn't appear to work, then i tried changing the location of the
keying code by putting it outside of the
public Client() { }
Then I thought it could be the 'implements' tags at the top of the file.
so I added
implements KeyListener
to the end of
public class Client extends JComponent
but again, this did not work then I did some more research and it seems
that I need to set the panel to be focused by using
panel.setFocusable(true);
but the source of this information, failed to say where to put it and
everywhere I put it throws an error
Can someone shed some light on this for me please?
Scanners and multiple if statements
Scanners and multiple if statements
I am trying to get a Scanner to read through each line of data and only
print out the lines that contain the word "model" followed by a year
within the boundaries I set. I am not sure if there is a more efficient
way to do this, but I made one Scanner for the whole set of data and then
within that I declared another one that reads each line. I then tried to
set it to look for a String comprised of the word "model" plus the year if
the line contains the right year. Since tokens in Scanners are divided by
spaces, I thought the correct way to do it would to declare a different
String, tokenToken, that combines the first token with a space and the
year, if such a combination exists.
Currently when I run it, it just runs forever, not compiling, so I don't
know what's wrong with it. I think it may have to do with the innermost if
statement but I'm not sure. I'm new to this.
public static void main(String[] args) {
Scanner inStream = new Scanner(System.in);
while (inStream.hasNext()) {
String line = inStream.nextLine();
Scanner lineStream = new Scanner(line);
while (lineStream.hasNext()) {
String token = lineStream.next();
if (token.matches("model") && lineStream.hasNextInt()) {
int year= lineStream.nextInt();
if ((year>= 1976) && (year <= 2013)) {
String tokenToken = (token + " " + year);
if (lineStream.hasNext(tokenToken)) {
System.out.println(line);
} else {
}
}
}
}
lineStream.close();
}
inStream.close();
}
I am trying to get a Scanner to read through each line of data and only
print out the lines that contain the word "model" followed by a year
within the boundaries I set. I am not sure if there is a more efficient
way to do this, but I made one Scanner for the whole set of data and then
within that I declared another one that reads each line. I then tried to
set it to look for a String comprised of the word "model" plus the year if
the line contains the right year. Since tokens in Scanners are divided by
spaces, I thought the correct way to do it would to declare a different
String, tokenToken, that combines the first token with a space and the
year, if such a combination exists.
Currently when I run it, it just runs forever, not compiling, so I don't
know what's wrong with it. I think it may have to do with the innermost if
statement but I'm not sure. I'm new to this.
public static void main(String[] args) {
Scanner inStream = new Scanner(System.in);
while (inStream.hasNext()) {
String line = inStream.nextLine();
Scanner lineStream = new Scanner(line);
while (lineStream.hasNext()) {
String token = lineStream.next();
if (token.matches("model") && lineStream.hasNextInt()) {
int year= lineStream.nextInt();
if ((year>= 1976) && (year <= 2013)) {
String tokenToken = (token + " " + year);
if (lineStream.hasNext(tokenToken)) {
System.out.println(line);
} else {
}
}
}
}
lineStream.close();
}
inStream.close();
}
spring mongodb: getting sorted and paginated list of inner document
spring mongodb: getting sorted and paginated list of inner document
I have two document. User and Activities. Activities is a inner document.
@Document(collection="users")
public class User {
@Id
private String id;
private String usertoken;
private String firstname;
private List<Activity> activities;
}
@Document
public class Activity {
private Date date;
private String text;
}
I am using spring mongo layer in my project. I wanted to query and get a
paginated list of activities (in descending order of date) for a given
user using query annotations. How could I achieve this?
@Query()
List<Activities> getActivities(usertoken, Pageable);
I am fine with getting User document with inner document activities if the
above is not possible.
I have two document. User and Activities. Activities is a inner document.
@Document(collection="users")
public class User {
@Id
private String id;
private String usertoken;
private String firstname;
private List<Activity> activities;
}
@Document
public class Activity {
private Date date;
private String text;
}
I am using spring mongo layer in my project. I wanted to query and get a
paginated list of activities (in descending order of date) for a given
user using query annotations. How could I achieve this?
@Query()
List<Activities> getActivities(usertoken, Pageable);
I am fine with getting User document with inner document activities if the
above is not possible.
Update numpy array row by condition
Update numpy array row by condition
I need help) I have NumPy array:
False False False False
False True True False
True True True True
False True True False
False False False False
How can I get this (take first and last rows, that contains True, and set
all of them elements to False)?
False False False False
False False False False
True True True True
False False False False
False False False False
I need help) I have NumPy array:
False False False False
False True True False
True True True True
False True True False
False False False False
How can I get this (take first and last rows, that contains True, and set
all of them elements to False)?
False False False False
False False False False
True True True True
False False False False
False False False False
Saturday, 14 September 2013
Starting my app on boot in android in xamarin (c#)
Starting my app on boot in android in xamarin (c#)
I am a c# developer and i using from xamarin for developmen my android
app. now i want to start my app automaticly on android boot or start a
service, but my app show error after restarting phone and wont open.
For start on boot i use from this articles:
How to Start an Application on Startup?
And
http://morewally.com/cs/blogs/wallym/archive/2011/07/28/start-an-application-on-boot-with-mono-for-android-android-monodroid.aspx
And handle that codes for my application but my app boot start doset work
and show a force close. Please help me.
I am a c# developer and i using from xamarin for developmen my android
app. now i want to start my app automaticly on android boot or start a
service, but my app show error after restarting phone and wont open.
For start on boot i use from this articles:
How to Start an Application on Startup?
And
http://morewally.com/cs/blogs/wallym/archive/2011/07/28/start-an-application-on-boot-with-mono-for-android-android-monodroid.aspx
And handle that codes for my application but my app boot start doset work
and show a force close. Please help me.
Creating a mobile layout that looks like the landscape version while in portrait
Creating a mobile layout that looks like the landscape version while in
portrait
I'm working on a website for job listings that needs to integrate a widget
from SmartRecruiters and have run into an issue with the mobile layout.
I'm using the viewport tag as <meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1" /> which
works really well for a landscape orientation. The issue is that the
SmartRecruiters table that lists the job openings does not shrink to be
narrow enough when in portrait mode and requires the user to scroll
horizontally.
How can I make the portrait layout zoom out to the same width as the
landscape layout that works really well?
Thank you in advance.
portrait
I'm working on a website for job listings that needs to integrate a widget
from SmartRecruiters and have run into an issue with the mobile layout.
I'm using the viewport tag as <meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1" /> which
works really well for a landscape orientation. The issue is that the
SmartRecruiters table that lists the job openings does not shrink to be
narrow enough when in portrait mode and requires the user to scroll
horizontally.
How can I make the portrait layout zoom out to the same width as the
landscape layout that works really well?
Thank you in advance.
jquery onclick function braking after addClass next click
jquery onclick function braking after addClass next click
Click on the element adds the class play the css can handle it well. With
the next click I would like to remove the class play and that just doesn't
wants to happen.
What am I doing wrong? Also how could I do better ?
Thank YOU
<span class="icon small-player-icons pause" style="display: inline;">click
here</span>
$('.small-player-icons.pause').on('click',function(){
$(this).addClass('play');
});
$('.small-player-icons.pause.play').on('click', function(){
alert("clicked");
$(this).removeClass('play');
});
span.small-player-icons.pause {
background-color:green;
padding:10px;
}
span.small-player-icons.play {
background-color:orange;
}
Here is the fiddle
Click on the element adds the class play the css can handle it well. With
the next click I would like to remove the class play and that just doesn't
wants to happen.
What am I doing wrong? Also how could I do better ?
Thank YOU
<span class="icon small-player-icons pause" style="display: inline;">click
here</span>
$('.small-player-icons.pause').on('click',function(){
$(this).addClass('play');
});
$('.small-player-icons.pause.play').on('click', function(){
alert("clicked");
$(this).removeClass('play');
});
span.small-player-icons.pause {
background-color:green;
padding:10px;
}
span.small-player-icons.play {
background-color:orange;
}
Here is the fiddle
How to check if the user logged in or out with PHP?
How to check if the user logged in or out with PHP?
how to check if the user logged in with php if the user logged in with
javascript SDK? and why i do need appId if i use login plugin for m site?
how to check if the user logged in with php if the user logged in with
javascript SDK? and why i do need appId if i use login plugin for m site?
Display content of a html page in a div
Display content of a html page in a div
I have an index.html page:
<body>
<ul>
<li><a id="page" href="#">About</a></li>
</ul>
<div id="show">
</div>
</body>
a jQuery:
<script type="text/javascript">
$(document).ready(function(){
$("#page").click(function(){
$('#show').load('test.html');
});
});
</script>
What I need is to display content from test.html in #show div, but above
code doesn't work.
So my question is: what did I do wrong?
PS: I'm using jQuery 1.9.1 library from link <script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
type="text/javascript"></script> and it works with other jQuery scripts.
I have an index.html page:
<body>
<ul>
<li><a id="page" href="#">About</a></li>
</ul>
<div id="show">
</div>
</body>
a jQuery:
<script type="text/javascript">
$(document).ready(function(){
$("#page").click(function(){
$('#show').load('test.html');
});
});
</script>
What I need is to display content from test.html in #show div, but above
code doesn't work.
So my question is: what did I do wrong?
PS: I'm using jQuery 1.9.1 library from link <script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
type="text/javascript"></script> and it works with other jQuery scripts.
Global AJAX event listeners in Can.JS?
Global AJAX event listeners in Can.JS?
Is it possible to bind listeners to when an AJAX request is started in
Can.JS? I want to integrate a little loading indicator in my Can.JS
project so that users can see when data is being loaded from my server.
Using the jQuery $.ajaxStart and $.ajaxSend events didn't work, however
the $.ajaxComplete event did fire correctly.
Is it possible to bind listeners to when an AJAX request is started in
Can.JS? I want to integrate a little loading indicator in my Can.JS
project so that users can see when data is being loaded from my server.
Using the jQuery $.ajaxStart and $.ajaxSend events didn't work, however
the $.ajaxComplete event did fire correctly.
VBA excel read file text in folder
VBA excel read file text in folder
I'm new in VBA, I wonder if someone can help me out, I want to read a few
text file in one folder and put it on excel sheet using VBA code. let say
I have about 100 - 200 of single line text file that contain like below
(just example) file= james.txt, contain = Mr.James phone number is
789101112, ID card:123456789 live at California file= Andy.txt contain =
Mr.Andy phone number is 789456123, ID card:45678978622331 live at Los
angeles file = and so on.. I need to get the contain file at put in excel
to became like below A B C D 1 James Mr.James 789101112 123456789 2 Andy
Mr.Andy 789456123 45678978622331 3 and so on... Can anyone help me
please...
I'm new in VBA, I wonder if someone can help me out, I want to read a few
text file in one folder and put it on excel sheet using VBA code. let say
I have about 100 - 200 of single line text file that contain like below
(just example) file= james.txt, contain = Mr.James phone number is
789101112, ID card:123456789 live at California file= Andy.txt contain =
Mr.Andy phone number is 789456123, ID card:45678978622331 live at Los
angeles file = and so on.. I need to get the contain file at put in excel
to became like below A B C D 1 James Mr.James 789101112 123456789 2 Andy
Mr.Andy 789456123 45678978622331 3 and so on... Can anyone help me
please...
Not able to install requests on cygwin
Not able to install requests on cygwin
I know this question has been asked already. But nothing seems to work for
me. When I tried the following command
pip install requests
I am getting the following error
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 343, in
load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2307, in
load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2013, in
load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File
"/usr/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip/__init__.py",
line 10, in <module>
from pip.util import get_installed_distributions, get_prog
File "/usr/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip/util.py",
line 8, in <module>
import zipfile
File "/usr/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/usr/lib/python2.7/io.py", line 60, in <module>
import _io
ImportError: No module named _io
I know this question has been asked already. But nothing seems to work for
me. When I tried the following command
pip install requests
I am getting the following error
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 343, in
load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2307, in
load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2013, in
load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File
"/usr/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip/__init__.py",
line 10, in <module>
from pip.util import get_installed_distributions, get_prog
File "/usr/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip/util.py",
line 8, in <module>
import zipfile
File "/usr/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/usr/lib/python2.7/io.py", line 60, in <module>
import _io
ImportError: No module named _io
Friday, 13 September 2013
Why does the TDBGrid take up more space at run-time?
Why does the TDBGrid take up more space at run-time?
I have bumped into a pretty confusing problem.
At design time, I clearly indicate the size of columns (width and Max
width) for the TDBGrid.
Here's the problem... As you see, the design time and run-time grids are
different in size. And also note that the form is the same size.
Please ignore the rest of the screen. My only concern is the window with
the grid :)
Is there any way I can fix this?
BTW, I'm working on Ubuntu with Lazarus but the software may be on Ubuntu
or Windows.
I'd really appreciate nay inputs on this. Thanks!
I have bumped into a pretty confusing problem.
At design time, I clearly indicate the size of columns (width and Max
width) for the TDBGrid.
Here's the problem... As you see, the design time and run-time grids are
different in size. And also note that the form is the same size.
Please ignore the rest of the screen. My only concern is the window with
the grid :)
Is there any way I can fix this?
BTW, I'm working on Ubuntu with Lazarus but the software may be on Ubuntu
or Windows.
I'd really appreciate nay inputs on this. Thanks!
PHP - sum values except one in foreach
PHP - sum values except one in foreach
Ok I have this code
$var[0] = array('my_value=500,other_values,..');
$var[1] = array('my_value=700,other_values,..');
$sumValues = 0;
foreach ($vars as $key=>$var) {
$trek = $var->my_value;
if ( $key = 0 ) {
$sumValues = $some_external_value;
} else {
$sumValues = $sumValues + $trek[$key-1];
}
}
Expected returned values
$var[0] - $sumValues = 0
$var[1] - $sumValues = 500
$var[2] - $sumValues = 700
I want to sum up the values of $trek to be used for each $var as a value
only determined by the sum of the previous $var elements and not itself.
As always, thanks for any reply :)
Ok I have this code
$var[0] = array('my_value=500,other_values,..');
$var[1] = array('my_value=700,other_values,..');
$sumValues = 0;
foreach ($vars as $key=>$var) {
$trek = $var->my_value;
if ( $key = 0 ) {
$sumValues = $some_external_value;
} else {
$sumValues = $sumValues + $trek[$key-1];
}
}
Expected returned values
$var[0] - $sumValues = 0
$var[1] - $sumValues = 500
$var[2] - $sumValues = 700
I want to sum up the values of $trek to be used for each $var as a value
only determined by the sum of the previous $var elements and not itself.
As always, thanks for any reply :)
In C#, how can I get the name of the calling project from within a referenced project?
In C#, how can I get the name of the calling project from within a
referenced project?
I have three projects: My.Business, My.WebSite and My.WebService
I need my logging class to be able to identify when a request is made from
the website versus the web service. I used to have the web service running
as a separate application underneath the web site, so I'd just use
different config files, which worked fine. But I want the web service now
to run under the same application.
If I could figure out if the request was coming from My.WebSite or
My.WebService, I'd be set, but I'm not sure how to do this.
Assembly.GetExecutingAssembly() returns back My.Business
Assembly.GetEntryAssembly() is null
I could check the StackTrace, but that seems sloppy and how for back would
I have to go? Especially because the logging may be triggered by code in
My.Business that was originally invoked from one of the other projects.
Since the web service requests end in ".asmx", the following concept
works, but it just doesn't feel right.
return HttpContext.Current.Request.Path.IndexOf(".asmx") >= 0 ?
"My.WebService" : "My.WebSite";
Thanks!
referenced project?
I have three projects: My.Business, My.WebSite and My.WebService
I need my logging class to be able to identify when a request is made from
the website versus the web service. I used to have the web service running
as a separate application underneath the web site, so I'd just use
different config files, which worked fine. But I want the web service now
to run under the same application.
If I could figure out if the request was coming from My.WebSite or
My.WebService, I'd be set, but I'm not sure how to do this.
Assembly.GetExecutingAssembly() returns back My.Business
Assembly.GetEntryAssembly() is null
I could check the StackTrace, but that seems sloppy and how for back would
I have to go? Especially because the logging may be triggered by code in
My.Business that was originally invoked from one of the other projects.
Since the web service requests end in ".asmx", the following concept
works, but it just doesn't feel right.
return HttpContext.Current.Request.Path.IndexOf(".asmx") >= 0 ?
"My.WebService" : "My.WebSite";
Thanks!
How to Echo a Distinct Count in PHP?
How to Echo a Distinct Count in PHP?
I have a Mysql that returns a count of items we have in stock
select count(distinct style) from bottles
I want to echo that value out to my website. I tried.
<?php
#///////////////////////////////////
#// Show Amount of Bottles
#///////////////////////////////////
$distinct = mysql_query("select count(distinct style) from bottles", $con);
$num_rows = count($distinct);
echo "$num_rows Bottles In Stock";
?> as of <?php print date('l F jS, Y', time()-86400);
But its only showing me the value of 1? Can someone point me in the right
direction?
Also if I would like to have one statement echo multiple rows how can i do
this?
Item Name | Style | Location
So I would like to echo on our site:
As of today we have 400 bottles of beer in stock X different styles from Y
locations?
Thanks in advance for any help. I just started teaching myself php and
mysql about a month ago.
Ryan
I have a Mysql that returns a count of items we have in stock
select count(distinct style) from bottles
I want to echo that value out to my website. I tried.
<?php
#///////////////////////////////////
#// Show Amount of Bottles
#///////////////////////////////////
$distinct = mysql_query("select count(distinct style) from bottles", $con);
$num_rows = count($distinct);
echo "$num_rows Bottles In Stock";
?> as of <?php print date('l F jS, Y', time()-86400);
But its only showing me the value of 1? Can someone point me in the right
direction?
Also if I would like to have one statement echo multiple rows how can i do
this?
Item Name | Style | Location
So I would like to echo on our site:
As of today we have 400 bottles of beer in stock X different styles from Y
locations?
Thanks in advance for any help. I just started teaching myself php and
mysql about a month ago.
Ryan
calendarview stops scrolling when nested in scrolview in android
calendarview stops scrolling when nested in scrolview in android
I have nested calendarview in ScrollView . My problem begins when height
of view increases. I can scroll calendar months vertically but wen
scrollview scrollbar comes it does not let scroll calendar. Instead of
scrolling calendar the whole view scrol up or down.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout android:orientation="vertical" android:id="@+id/ReminderLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/TaskName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:singleLine="true"
android:textSize="26.0sp" />
<View
android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip" />
<TextView
android:id="@+id/lblNotes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Notes" />
<EditText
android:id="@+id/TaskNotes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:textSize="26.0sp" />
<View
android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip" />
<TextView
android:id="@+id/lblReminder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Reminder" />
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">"
<CalendarView
android:id="@+id/calendarReminder"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:scrollbars="vertical"
android:isScrollContainer="true" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TimePicker
android:id="@+id/timePickerReminder"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="center" />
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<View android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<TextView android:id="@+id/ReminderTime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="On Time" android:paddingLeft="20dip"/>
<View android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<TextView android:id="@+id/Recurring"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Only Once" android:paddingLeft="20dip"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
I have nested calendarview in ScrollView . My problem begins when height
of view increases. I can scroll calendar months vertically but wen
scrollview scrollbar comes it does not let scroll calendar. Instead of
scrolling calendar the whole view scrol up or down.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout android:orientation="vertical" android:id="@+id/ReminderLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/TaskName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:singleLine="true"
android:textSize="26.0sp" />
<View
android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip" />
<TextView
android:id="@+id/lblNotes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Notes" />
<EditText
android:id="@+id/TaskNotes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:textSize="26.0sp" />
<View
android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip" />
<TextView
android:id="@+id/lblReminder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Reminder" />
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">"
<CalendarView
android:id="@+id/calendarReminder"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:scrollbars="vertical"
android:isScrollContainer="true" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TimePicker
android:id="@+id/timePickerReminder"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="center" />
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<View android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<TextView android:id="@+id/ReminderTime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="On Time" android:paddingLeft="20dip"/>
<View android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<TextView android:id="@+id/Recurring"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Only Once" android:paddingLeft="20dip"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
Thursday, 12 September 2013
How to do Animation like BooK front cover?
How to do Animation like BooK front cover?
I want the Page flip animation for Photo Allbum Book cover even though i
have added animation for pages(Used UIpageViewController) but need to have
main page animation as well. Please see this link exactly like this I want
see this
1: Please help.
I want the Page flip animation for Photo Allbum Book cover even though i
have added animation for pages(Used UIpageViewController) but need to have
main page animation as well. Please see this link exactly like this I want
see this
1: Please help.
Issue referencing images in JQuery code
Issue referencing images in JQuery code
Probably a silly question but I'm having quite a bit of trouble trying to
figure out how to reference an image from my folder in JQuery code.
I want to turn images to greyscale, that revert to colour on mouse
rollover. However, my image referencing isn't working. I've tried the
usual ('folderofimages/myimage') but that isn't working. I've tried the
suggested way ('.myimage folderofimages') and that's not working either.
This is the website that supplied the code,
http://webdesignerwall.com/tutorials/html5-grayscale-image-hover/comment-page-4#comments
Any help is greatly appreciated!
Here is my code,
// On window load. This waits until images have loaded which is essential
$(window).load(function(){
// Fade in imagimages/homeannual.jpeges so there isn't a color "pop"
document load and then on window load
$("images.homeannual").fadeIn(500);
// clone image
$('images.homeannual').each(function(){
var el = $(this);
el.css({"position":"absolute"}).wrap("<div class='img_wrapper'
style='display:
inline-block'>").clone().addClass('img_grayscale').css({"position":"absolute","z-index":"998","opacity":"0"}).insertBefore(el).queue(function(){
var el = $(this);
el.parent().css({"width":this.width,"height":this.height});
el.dequeue();
});
this.src = grayscale(this.src);
});
// Fade image
$('images.homeannual').mouseover(function(){
$(this).parent().find('img:first').stop().animate({opacity:1}, 1000);
})
$('.img_grayscale').mouseout(function(){
$(this).stop().animate({opacity:0}, 1000);
});
});
// Grayscale w canvas method
function grayscale(src){
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
var imgObj = new Image();
imgObj.src = src;
canvas.width = imgObj.width;
canvas.height = imgObj.height;
ctx.drawImage(imgObj, 0, 0);
var imgPixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
for(var y = 0; y < imgPixels.height; y++){
for(var x = 0; x < imgPixels.width; x++){
var i = (y * 4) * imgPixels.width + x * 4;
var avg = (imgPixels.data[i] + imgPixels.data[i + 1] +
imgPixels.data[i + 2]) / 3;
imgPixels.data[i] = avg;
imgPixels.data[i + 1] = avg;
imgPixels.data[i + 2] = avg;
}
}
ctx.putImageData(imgPixels, 0, 0, 0, 0, imgPixels.width,
imgPixels.height);
return canvas.toDataURL();
}
Probably a silly question but I'm having quite a bit of trouble trying to
figure out how to reference an image from my folder in JQuery code.
I want to turn images to greyscale, that revert to colour on mouse
rollover. However, my image referencing isn't working. I've tried the
usual ('folderofimages/myimage') but that isn't working. I've tried the
suggested way ('.myimage folderofimages') and that's not working either.
This is the website that supplied the code,
http://webdesignerwall.com/tutorials/html5-grayscale-image-hover/comment-page-4#comments
Any help is greatly appreciated!
Here is my code,
// On window load. This waits until images have loaded which is essential
$(window).load(function(){
// Fade in imagimages/homeannual.jpeges so there isn't a color "pop"
document load and then on window load
$("images.homeannual").fadeIn(500);
// clone image
$('images.homeannual').each(function(){
var el = $(this);
el.css({"position":"absolute"}).wrap("<div class='img_wrapper'
style='display:
inline-block'>").clone().addClass('img_grayscale').css({"position":"absolute","z-index":"998","opacity":"0"}).insertBefore(el).queue(function(){
var el = $(this);
el.parent().css({"width":this.width,"height":this.height});
el.dequeue();
});
this.src = grayscale(this.src);
});
// Fade image
$('images.homeannual').mouseover(function(){
$(this).parent().find('img:first').stop().animate({opacity:1}, 1000);
})
$('.img_grayscale').mouseout(function(){
$(this).stop().animate({opacity:0}, 1000);
});
});
// Grayscale w canvas method
function grayscale(src){
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
var imgObj = new Image();
imgObj.src = src;
canvas.width = imgObj.width;
canvas.height = imgObj.height;
ctx.drawImage(imgObj, 0, 0);
var imgPixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
for(var y = 0; y < imgPixels.height; y++){
for(var x = 0; x < imgPixels.width; x++){
var i = (y * 4) * imgPixels.width + x * 4;
var avg = (imgPixels.data[i] + imgPixels.data[i + 1] +
imgPixels.data[i + 2]) / 3;
imgPixels.data[i] = avg;
imgPixels.data[i + 1] = avg;
imgPixels.data[i + 2] = avg;
}
}
ctx.putImageData(imgPixels, 0, 0, 0, 0, imgPixels.width,
imgPixels.height);
return canvas.toDataURL();
}
Backbone Marionette get region view
Backbone Marionette get region view
I have a marionette layout that has a region with a view inside. How can I
get a reference to that view?
For example:
var layoutView = Backbone.Marionette.Layout.extend({
regions: {
myRegion: '.some-element'
},
initialize: function(){
this.render();
this.myView.show(new someView());
},
test: function(){
var view = this.myRegion.get() // or something to retrieve the view?
}
});
I mean, I can save the view instance into "this", but surely marionette
must have a way of retrieving it...right?
I have a marionette layout that has a region with a view inside. How can I
get a reference to that view?
For example:
var layoutView = Backbone.Marionette.Layout.extend({
regions: {
myRegion: '.some-element'
},
initialize: function(){
this.render();
this.myView.show(new someView());
},
test: function(){
var view = this.myRegion.get() // or something to retrieve the view?
}
});
I mean, I can save the view instance into "this", but surely marionette
must have a way of retrieving it...right?
Url binding on web.config location element
Url binding on web.config location element
I have one site containing several bindings, in example
www.page.com
private.page.com
The www.page.com does have a gallery, ie www.page.com/gallery and so does
the private subsite, private.page.com/gallery
Since I've implemented a .net membership system I like to use the built in
location elements to restrain access, the example below does the trick
just fine
<location path="gallery">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
But I'd like to have it affecting the private.page.com site only. Is there
a way to handle this in web.config?
Thanks
I have one site containing several bindings, in example
www.page.com
private.page.com
The www.page.com does have a gallery, ie www.page.com/gallery and so does
the private subsite, private.page.com/gallery
Since I've implemented a .net membership system I like to use the built in
location elements to restrain access, the example below does the trick
just fine
<location path="gallery">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
But I'd like to have it affecting the private.page.com site only. Is there
a way to handle this in web.config?
Thanks
Subscribe to:
Comments (Atom)