Thursday, 3 October 2013

Remove all hyperlinks and tables from RTF using c#

Remove all hyperlinks and tables from RTF using c#

I have a Winform RichTextBox to which I am programatically loading RTF
documents. But I want to strip/remove all hyperlinks and tables from the
RTF before loading the RTF into the RichTextBox ( but needs to keep the
formatting). Same behavior I need for RTF texts copied from MS Word also.
How do I achive this? Are there any library to parse the RTF and strip
hyperlinks and tables (still keeping the formatting) ?

Wednesday, 2 October 2013

Overriding protected methods in Moq

Overriding protected methods in Moq

I have a class which implements an abstract class. The abstract class has
a protected virtual method as shown:
protected virtual void OnAction(string action, object result);
The class implementing the abstract class has a method which when
completed calls base.OnAction.
I am trying to override the behaviour of the implementation of OnAction in
my unit tests as I am trying to unit test only, not do integration tests.
My Moq call is setup as follows:
mock.Protected().Setup("OnAction", ItExpr.IsAny<string>,
ItExpr.IsAny<object>());
Breakpointing my base abstract classes OnAction method confirms it is
still being called.
I'm essentially wanting Moq to do the equivalent in it's emitted class:
public override OnAction(string action, object result) { // do nothing }

PHP/MySQL SELECT statement with 'variable' ' ' or 'variable' IS NOT NULL not working

PHP/MySQL SELECT statement with 'variable' ' ' or 'variable' IS NOT NULL
not working

I have a SQL routine written that compares a user's input with an existing
value in a table. If the value exists, a green check mark appears next to
the input. If it doesn't, then a red x appears. My SQL statement is as
follows:
$check = $con->prepare("SELECT count(*) FROM emaillist");
$check->execute();
$result = $check->fetchColumn(); //Get no. of columns
$check = $con->prepare("SELECT Username FROM emaillist WHERE Username =
'$Name' AND '$Name' <> '' ");
$check->execute();
$result = $check->fetchColumn(); //Get exact column
if(!$result) {
show red x } else { show green check }
This works fine as long as there is input. The red x appears when the
input doesn't match and the green check appears when it does; however, I
don't want anything to display if the field is left blank. Right now, the
red x appears if the field is empty or is null. Using IS NOT NULL didn't
work, either. What am I missing?

Microsoft Access -- Automation Error

Microsoft Access -- Automation Error

I'm running an ancient macro (circa 2002), and in the VBA code in
Microsoft Access, if I use the function "Excel.Application.NormSDist(mu)",
I get the error:
Automation Error The interface is unknown
Any ideas on how to fix this?

MSSQL server connect to kohana php framework

MSSQL server connect to kohana php framework

I'm new to kohana php framework. I tried to connect sql server 2005 to
it.somebody please help me. this is urgent situation.

Tuesday, 1 October 2013

CSS and html not rendering well on mobile

CSS and html not rendering well on mobile

I have a page i've created which works fine in a desktop but get's messed
up in a mobile browser.

This is the desktop version.

This is the mobile version. I have a header and a .container(the one with
gray background) set to width 100%. Inside .container i've a .wrapper set
to width: 900px; and margin: 0 auto;. Why is the blue background and the
gray background rendering till about half of the page witdh? What is the
best way I can approach the problem to create a page like the desktop
version on the mobile as well?
Codepen link http://codepen.io/tim-hoff/pen/ytGEw

Minimum value of numbers in char array

Minimum value of numbers in char array

I recently ran into this problem in an interview, and I was curious what
the best way to solve it would be. The question is given a char array that
has the ascii characters '0' to '9' make one swap such that the the set of
ascii values in the resultant array forms the lowest possible value. Both
the input array will not have preceding 0s and neither should the
resultant array.
So here is an example: char a[] = {'1','0', '9','7','6'}
The solution: char b[] = { '1','0', '6', '7', '9'}

Backup Server Solution in production environment

Backup Server Solution in production environment

I was looking at setting up a backup server running on a virtualbox with
Windows Server 2008r2 as the host (I have no say here). I was thinking
about using FreeNAS with ZFS, however, I am finding out that some have had
problems with this due to S.M.A.R.T. and windows paging when running
FreeNAS on a virtual Machine.
This Backup Server will be responsible for backing up our whole
infrastructure in increments of a week (already have an on site full
backup solution).
Does Windows have any backup server-client applications that would both be
VM friendly and have the performance to backup TeraBytes of data?
hardware specs are not a problem here.
Thank you in advance!

EC2 backup strategy, 2 EBS volumes

EC2 backup strategy, 2 EBS volumes

i've currently set up a Windows EC2 instance with MySQL installed on the
root/C: drive, with the database files, logs, etc on another volume.
Is it safe to use snapshots to back up the instance? My thinking is that
it would be impossible to take a snapshot of each volume at the exact same
time, so you don't have a consistent snapshot of the entire instance.
If there is such an issue, what other backup options are there? Back up
using AMIs instead?
tia

Monday, 30 September 2013

rsync flock not deleting flocktmp.lock file?

rsync flock not deleting flocktmp.lock file?

Recently, I changed my rsync flock command, and now it has stopped
deleting the flock file when the sync is done.
Can anyone see the error in my command? That would really help me out!
flock -xn /tmp/flocktmp.lock -c "/usr/bin/rsync -avz --perms --chmod=a+rwx
--delete \
'user@some.site.com:~/www/user.some.site.com/public_html/links/rtorrent_data/iRL\
REMUX/
' \
/media/HDD01/shares/SB/iRL\ REMUX"

AWS Load Balancing Same Server Different Port

AWS Load Balancing Same Server Different Port

I am just curios and probably the answer in no. But I was wondering if it
is possible have a load balancing that listen on 1 server instead 2 or
more and redirect the traffic on different ports?

How to use adapter class inside button onClick listener?

How to use adapter class inside button onClick listener?

I am new to android development.
I have problem with Popup Window.
Now i am required popup menu when i click the grideview Button than open
the popup to show the data from the arrayList store.
Thank you in advance
package com.example.skpl;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;
public class DashBoardActivity extends Activity {
JSONObject json;
SoapPrimitive responce = null;
private static final String NAMESPACE="SKPLWebService";
private static final String METHOD_NAME = "GetDeshBoard";
private static final String SOAP_ACTION = "SKPLWebService/GetDeshBoard";
private static final String URL =
"http://192.168.1.13/SKPLWS/Service1.asmx";
private String TAG = "PGGURU";
public static ArrayList<String> table = new ArrayList<String>();
TextView tv ;
GridView gd;
Button b;
LinearLayout mainlayout;
LinearLayout layout;
LayoutParams params;
MyAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.dashboard);
tv = (TextView) findViewById(R.id.text1);
gd = (GridView) findViewById(R.id.gridView1);
mainlayout = new LinearLayout(this);
layout = new LinearLayout(this);
adapter = new MyAdapter(this,
android.R.layout.simple_list_item_1, table);
Call tast = new Call();
tast.execute();
}
private class Call extends AsyncTask<String, Void, Void>
{
@Override
protected Void doInBackground(String... params) {
// TODO Auto-generated method stub
deshboard();
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
Log.i(TAG, "onPostExecute");
gd.setAdapter(adapter);
}
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
Log.i(TAG, "onPreExecute");
tv.setText("Loading Data...");
}
@Override
protected void onProgressUpdate(Void... values) {
// TODO Auto-generated method stub
Log.i(TAG, "onProgressUpdate");
}
}
private class MyAdapter extends ArrayAdapter<String>
{
private Context context;
private int layoutResourceId;
private ArrayList<String> data = new ArrayList<String>();
public MyAdapter(Context context, int layoutResourceId,
ArrayList<String> data) {
super(context, layoutResourceId, data);
this.context = context;
this.data = data;
this.layoutResourceId = layoutResourceId;
}
@Override
public View getView(final int position, View row, ViewGroup parent) {
// TODO Auto-generated method stub
LayoutInflater inflater = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View row1 = inflater.inflate(R.layout.item_list,
parent,false);
b = (Button)row1.findViewById(R.id.Button);
b.setText(data.get(position));
b.setGravity(100);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
ArrayList<String> tabledata = new ArrayList<String>();
try {
String tablename = "Table"+position;
if(tablename.equals("Table0"))
{
tablename = "Table";
json=new JSONObject(responce.toString());
JSONArray jsonarray =
json.getJSONArray(tablename);
for(int i=0;i<jsonarray.length();i++)
{
JSONObject
jsonnew=jsonarray.getJSONObject(i);
String
str_data=jsonnew.getString("DisplayVoucherNumber");
String
str_data1=jsonnew.getString("ActualDate");
String str_data2=jsonnew.getString("Pcs");
String str_data3=jsonnew.getString("Weight");
tabledata.add(str_data);
tabledata.add(str_data1);
tabledata.add(str_data2);
tabledata.add(str_data3);
}
Log.d("Table", tabledata.toString());
}
else if(tablename.equals("Table1"))
{
json=new JSONObject(responce.toString());
JSONArray jsonarray =
json.getJSONArray(tablename);
for(int i=0;i<jsonarray.length();i++)
{
JSONObject
jsonnew=jsonarray.getJSONObject(i);
String
str_data=jsonnew.getString("DisplayVoucherNumber");
String
str_data1=jsonnew.getString("ActualDate");
String
str_data2=jsonnew.getString("Difference");
tabledata.add(str_data);
tabledata.add(str_data1);
tabledata.add(str_data2);
}
Log.d("Table1", tabledata.toString());
}
else if(tablename.equals("Table2"))
{
json=new JSONObject(responce.toString());
JSONArray jsonarray =
json.getJSONArray(tablename);
for(int i=0;i<jsonarray.length();i++)
{
JSONObject
jsonnew=jsonarray.getJSONObject(i);
String str_data=jsonnew.getString("Weight");
String
str_data1=jsonnew.getString("CatName");
tabledata.add(str_data);
tabledata.add(str_data1);
}
Log.d("Table2", tabledata.toString());
}
else if(tablename.equals("Table3"))
{
json=new JSONObject(responce.toString());
JSONArray jsonarray =
json.getJSONArray(tablename);
for(int i=0;i<jsonarray.length();i++)
{
JSONObject
jsonnew=jsonarray.getJSONObject(i);
String
str_data=jsonnew.getString("DisplayVoucherNumber");
String
str_data1=jsonnew.getString("ActualDate");
String
str_data2=jsonnew.getString("NetWeight");
String
str_data3=jsonnew.getString("CatName");
tabledata.add(str_data);
tabledata.add(str_data1);
tabledata.add(str_data2);
tabledata.add(str_data3);
}
Log.d("Table3", tabledata.toString());
}
else if(tablename.equals("Table4"))
{
json=new JSONObject(responce.toString());
JSONArray jsonarray =
json.getJSONArray(tablename);
for(int i=0;i<jsonarray.length();i++)
{
JSONObject
jsonnew=jsonarray.getJSONObject(i);
String
str_data=jsonnew.getString("DisplayVoucherNumber");
String
str_data1=jsonnew.getString("ActualDate");
String
str_data2=jsonnew.getString("TagStatus");
String
str_data3=jsonnew.getString("NetWeight");
tabledata.add(str_data);
tabledata.add(str_data1);
tabledata.add(str_data2);
tabledata.add(str_data3);
}
Log.d("Table4", tabledata.toString());
}
else if(tablename.equals("Table5"))
{
json=new JSONObject(responce.toString());
JSONArray jsonarray =
json.getJSONArray(tablename);
for(int i=0;i<jsonarray.length();i++)
{
JSONObject
jsonnew=jsonarray.getJSONObject(i);
String
str_data=jsonnew.getString("VoucherNo");
String
str_data1=jsonnew.getString("PacketNo");
String
str_data2=jsonnew.getString("CatName");
tabledata.add(str_data);
tabledata.add(str_data1);
tabledata.add(str_data2);
}
Log.d("Table5", tabledata.toString());
}
else if(tablename.equals("Table6"))
{
json=new JSONObject(responce.toString());
JSONArray jsonarray =
json.getJSONArray(tablename);
for(int i=0;i<jsonarray.length();i++)
{
JSONObject
jsonnew=jsonarray.getJSONObject(i);
String
str_data=jsonnew.getString("VoucherNo");
String
str_data1=jsonnew.getString("PacketNo");
String
str_data2=jsonnew.getString("CatName");
tabledata.add(str_data);
tabledata.add(str_data1);
tabledata.add(str_data2);
}
Log.d("Table6", tabledata.toString());
}
else if(tablename.equals("Table7"))
{
json=new JSONObject(responce.toString());
JSONArray jsonarray =
json.getJSONArray(tablename);
for(int i=0;i<jsonarray.length();i++)
{
JSONObject
jsonnew=jsonarray.getJSONObject(i);
String
str_data=jsonnew.getString("OrderVNO");
String
str_data1=jsonnew.getString("DifferenceWgt");
String
str_data2=jsonnew.getString("Justification");
tabledata.add(str_data);
tabledata.add(str_data1);
tabledata.add(str_data2);
}
Log.d("Table7", tabledata.toString());
}
else if(tablename.equals("Table8"))
{
json=new JSONObject(responce.toString());
JSONArray jsonarray =
json.getJSONArray(tablename);
for(int i=0;i<jsonarray.length();i++)
{
JSONObject
jsonnew=jsonarray.getJSONObject(i);
String str_data=jsonnew.getString("Weight");
String
str_data1=jsonnew.getString("CatName");
tabledata.add(str_data);
tabledata.add(str_data1);
}
Log.d("Table8", tabledata.toString());
}
else if(tablename.equals("Table9"))
{
json=new JSONObject(responce.toString());
JSONArray jsonarray =
json.getJSONArray(tablename);
for(int i=0;i<jsonarray.length();i++)
{
JSONObject
jsonnew=jsonarray.getJSONObject(i);
String
str_data=jsonnew.getString("DisplayVoucherNo");
String
str_data1=jsonnew.getString("ActualDate");
String
str_data2=jsonnew.getString("FromDeptName");
String
str_data3=jsonnew.getString("ToDeptName");
String
str_data4=jsonnew.getString("CatName");
tabledata.add(str_data);
tabledata.add(str_data1);
tabledata.add(str_data2);
tabledata.add(str_data3);
tabledata.add(str_data4);
}
Log.d("Table9", tabledata.toString());
}
else
{
Log.e("Error", "No Data Found");
}
if(tabledata.size() !=0)
{
//Here require to popup window with tabledata
}
else
{
Toast.makeText(getApplicationContext(), "Sorry
No data Available !!!",
Toast.LENGTH_LONG).show();
}
}
catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
return row1;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return data.size();
}
}
private class MyAdapter1 extends ArrayAdapter<String>
{
private Context context;
private int layoutResourceId;
private ArrayList<String> data = new ArrayList<String>();
TextView tv;
public MyAdapter1(Context context, int layoutResourceId,
ArrayList<String> data) {
super(context, layoutResourceId, data);
this.context = context;
this.data = data;
this.layoutResourceId = layoutResourceId;
}
@Override
public View getView(final int position, View row, ViewGroup parent) {
// TODO Auto-generated method stub
LayoutInflater inflater = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row1 = inflater.inflate(R.layout.popup_item, parent,false);
tv = (TextView) row1.findViewById(R.id.gd1);
tv.setText(data.get(position));
return row1;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return data.size();
}
}
public void deshboard()
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE aht = new HttpTransportSE(URL);
aht.debug = true;
try
{
aht.call(SOAP_ACTION, envelope);
responce = (SoapPrimitive) envelope.getResponse();
Log.e("Responce", responce.toString());
}
catch(Exception ex)
{
String err = (ex.getMessage()==null)?"ExceptionError Means No
Value Return":ex.getMessage();
Log.e("ExceptionError:",err);
}
try{
json=new JSONObject(responce.toString());
JSONArray jsonarray = json.getJSONArray("Table10");
for(int i=0;i<jsonarray.length();i++)
{
JSONObject jsonnew=jsonarray.getJSONObject(i);
String str_data=jsonnew.getString("TableName");
String str_data1=jsonnew.getString("Notification");


table.add(str_data+"\\n["+str_data1+"]");
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}

accordionPanel - multiline header in tab

accordionPanel - multiline header in tab

I would like to make accordion component with tab that has multiline headers.
Is it possible to make tab header multiline in accordion component?
I am using newest Primefaces 4.0-rc1.
Thank you

Sunday, 29 September 2013

Python SQLite recordset with field names

Python SQLite recordset with field names

I have googled and searched here, but can't seem to find an answer.
It appears that SQLite under Python only returns the values of a query but
not the column names, i.e. a dictionary:
def dbRows(sql):
con = dbapi.connect('/usr/share/mydb.sqlite')
cur = con.cursor()
cur.execute(sql)
return cur.fetchall()
> [(20, 1380506536631, '19:5d:ee3da0', 3, 'xxxx', 26.625, 30.0, 'true',
1379301655061, 0, 60, '10-0008017f31d3', 4, 0)]
How can I return the data as a dictionary type record set i.e ?
[(xx:20, xxx:1380506536631, xxxx:'19:5d:ee3da0', yy:3, yyy:'xxxx',
yyyy:26.625, zz:30.0, zzz:'true', zzzz:1379301655061, aa:0, aaa:60,
aaaa:'10-0008017f31d3', bb:4, bbb:0)]

Android Buttons wont activate

Android Buttons wont activate

I know this has been asked a million times but none have led me to solving
my problem. The onclicklistener will not activate the code for any of the
buttons. Here are the different sections that apply to the five buttons.
Button btnGuysMax;
Button btnGuysMedium;
Button btnEven;
Button btnGirlsMedium;
Button btnGirlsMax;
....
private void init()
{
datasource = new BarsDataSource(this);
datasource.open();
Intent intent = getIntent();
long id = intent.getLongExtra("bar_id",0);
bar = datasource.getBarById(id);
title = (TextView)findViewById(R.id.title);
btnGuysMax = (Button)findViewById(R.id.btnGuysMax);
btnGuysMedium = (Button)findViewById(R.id.btnGuysMedium);
btnEven = (Button)findViewById(R.id.btnEven);
btnGirlsMedium = (Button)findViewById(R.id.btnGirlsMedium);
btnGirlsMax = (Button)findViewById(R.id.btnGirlsMax);
......
btnGuysMax.setOnClickListener(this);
btnGuysMedium.setOnClickListener(this);
btnEven.setOnClickListener(this);
btnGirlsMedium.setOnClickListener(this);
btnGirlsMax.setOnClickListener(this);
.....
@Override
public void onClick(View view)
{
//resetButtons();
switch (view.getId()) {
case R.id.btnGuysMax:
//bar.setSexRatio(-2);
//btnGuysMax.setBackgroundColor(guysMaxColor);
Toast.makeText(this,"Max clicked!",Toast.LENGTH_LONG);
break;
case R.id.btnGuysMedium:
bar.setSexRatio(-1);
Toast.makeText(this,"Medium clicked!",Toast.LENGTH_LONG);
//btnGuysMedium.setBackgroundColor(guysMediumColor);
break;
case R.id.btnEven:
bar.setSexRatio(0);
//Toast.makeText(this,"Medium clicked!",Toast.LENGTH_LONG);
break;
case R.id.btnGirlsMedium:
bar.setSexRatio(1);
//btnGirlsMedium.setBackgroundColor(girlsMediumColor);
break;
case R.id.btnGirlsMax:
bar.setSexRatio(2);
break;
.....

Inner class & Outer class- Stacic blocks and methods

Inner class & Outer class- Stacic blocks and methods

Suppose there are static blocks in inner class and its outer class. Are
all the static blocks called first?? or just the static blocks of outer
class be called only?? And what about static methods in both the classes??

Fscanf inside while keeps crashing?

Fscanf inside while keeps crashing?

I have the following text:
ASDCASDSA255878 Jack Jhon 1988 12
ASDCASDSA255878 Bill Smith 1977 12
And i have the following code:
inputFile = fopen(fileName,"r");
char id[50];
char fname[50];
char lname[50];
char year[50];
char month[50];
while(fscanf(inputFile, "%s %s %s %s %s\n",id,fname,lname,year,month) == 5)
{
}
fclose(inputFile);
The file gets opened and if i put a printf statment inside the while loop
i could see it and after that it crashes.
I tried changing the ==5 to !=EOF but same problem.

Saturday, 28 September 2013

LatLng constructor changing latitude value to -90.0

LatLng constructor changing latitude value to -90.0

For some reason the constructor for LatLng is changing the latitude value
to -90.0 but the longitue value is fine.
for (DealMarker m : markers.getMarkers()) {
Log.d("map " , "pre - lat " + m.getmLatitude() + " " +
m.getmLongitude());
LatLng latlng = new LatLng(m.getmLatitude(), m.getmLongitude());
Log.d("map " , "post lat " + latlng.latitude + " " +
latlng.longitude);
Marker deallocation = mMap.addMarker(new
MarkerOptions().position(latlng).title(m.getTitle()).snippet(m.getSnippett()));
}
This produces a log file like: 09-28 19:26:50.212: D/map(17784): pre - lat
-121.6176785 39.1417939 09-28 19:26:50.212: D/map(17784): post lat -90.0
39.1417939
for each marker.. I am at a loss been working on this for hours. Thank you
all.

Can the free_function be a static class method?

Can the free_function be a static class method?

This is a follow-up question to How to write void pointer typedefs in vapi
files?
I know have four almost identical compact classes that represent handles
allocated with unixODBCs SQLAllocHandle function.
The first one (for the ENV type handle) looks like this:
[CCode (cname = "void", free_function = "EnvironmentHandle.free")]
[Compact]
public class EnvironmentHandle {
[CCode (cname = "SQLAllocHandle")]
private static Return allocate_internal (HandleType type, void*
nothing, out EnvironmentHandle output_handle);
public static Return allocate (out EnvironmentHandle output_handle) {
return allocate_internal (HandleType.ENV, null, out output_handle);
}
[CCode (cname = "SQLFreeHandle")]
private static Return free_internal (HandleType type,
EnvironmentHandle handle);
public static Return free (EnvironmentHandle handle) {
return free_internal (HandleType.ENV, handle);
}
}
This doesn't compile.
Is it possible to use a static class method as the free_function?
If not, is there at least a way to write a custom free_function in the
vapi file?
I need a custom function because the SQLFreeHandle function takes the
handle type and the handle as an argument.

Assign attributes with C++ to an arbitrary R object?

Assign attributes with C++ to an arbitrary R object?

I have started with Rcpp and I am working through Hadley's book / page
here. I guess these basics are more than enough for me, still though I
missed, some aspect or feel that this might be less basic:
How can I assign attributes to an arbitrary R Object using C++?
E.g.:
// [[Rcpp::export]]
NumericVector attribs(CharacterVector x,NumericVector y) {
NumericVector out = y;
out.attr("my-attr") = x;
return out;
}
I understand I have to specify the type in C++, but still I wonder whether
there's a way to assign an attribute to ANY R object that I pass... I have
seen that settatr in the data.table works with C++, but seems to work only
with elements of class data.table. Is there any way but writing an extra
function for every R mode / class?

Proximity Alert giving no notifications

Proximity Alert giving no notifications

I want notification when user enters particular area , but it is not
working and no error here ! I am stuck here since a week , kindly
cooperate with me!
public class MainActivity extends FragmentActivity{
protected GoogleMap gMap;
private LocationManager locationManager;
TextView txt;
double clat,clong;
private static final String PROX_ALERT_INTENT
="com.example.map.ProximityAlert";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gMap = ((SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
if (gMap == null) {
Toast.makeText(this, "Google Maps not available",
Toast.LENGTH_LONG).show();}
txt=(TextView) findViewById(R.id.text1);
locate();
gMap.setMyLocationEnabled(true);
}
private void locate() {
locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
clat=location.getLatitude();
clong=location.getLongitude();
}
public void onStatusChanged(String provider, int status, Bundle
extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
10000, 10, locationListener);
addProximityAlert(clat,clong);
}
private void addProximityAlert(double latitude, double longitude) {
Intent intent = new Intent(PROX_ALERT_INTENT);
PendingIntent proximityIntent =
PendingIntent.getBroadcast(this, 0,
intent,PendingIntent.FLAG_CANCEL_CURRENT);
float POINT_RADIUS=10000;
long PROX_ALERT_EXPIRATION=10000;
locationManager.addProximityAlert(
latitude, // the latitude of the central point of
the alert region
longitude, // the longitude of the central point of
the alert region
POINT_RADIUS, // the radius of the central point of
the alert region, in meters
PROX_ALERT_EXPIRATION, // time for this proximity
alert, in milliseconds, or -1 to indicate no
expiration
proximityIntent // will be used to generate an
Intent to fire when entry to or exit from the alert
region is detected
);
IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT);
registerReceiver(new ProximityIntentReceiver(), filter);
}
}
Here is the Proximity receiver class ,
public class ProximityIntentReceiver extends BroadcastReceiver {
private static final int NOTIFICATION_ID = 1;
@SuppressWarnings("deprecation")
public void onReceive(Context context, Intent intent) {
String key = LocationManager.KEY_PROXIMITY_ENTERING;
Boolean entering = intent.getBooleanExtra(key, false);
if (entering) {
Log.d(getClass().getSimpleName(), "entering");
}
else {
Log.d(getClass().getSimpleName(), "exiting");
}
NotificationManager notificationManager =
(NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent pendingIntent = PendingIntent.getActivity(context,
0, null, 0);
Notification notification = createNotification();
notification.setLatestEventInfo(context,"Proximity Alert!", "You
are near your point of interest.", pendingIntent);
notificationManager.notify(NOTIFICATION_ID, notification);
}
private Notification createNotification() {
Notification notification = new Notification();
//notification.icon = R.drawable.image_1.jpg;
notification.when = System.currentTimeMillis();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notification.ledARGB = Color.WHITE;
notification.ledOnMS = 1500;
notification.ledOffMS = 1500;
return notification;
}
}
Manifest File,
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.map"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission
android:name="com.example.map.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.map.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"
/>
<!--
The following two permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.map.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.map.Locate"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.Locate" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name="ProximityIntentReceiver" >
<intent-filter>
<action android:name="com.example.map" />
</intent-filter>
</receiver>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBeJoGKnhxYps-youI1xfMZn6S2G05l0PM" />
</application>
</manifest>

Friday, 27 September 2013

How does Q_PROPERTY() RESET clause work?

How does Q_PROPERTY() RESET clause work?

When using the Q_PROPERTY macro to define a property to Qt's property
system, one of the available clauses is RESET. I know what the reset
function is for, and how to create one, but I can't figure out when it
would be triggered from QML. I notice that examples of reset function
declarations I've looked at in the BlackBerry Cascades header files are
not specified as Q_INVOKABLE, so you can't just call the function, but
they are always defined as a slot. This makes me wonder if the property
system has a hidden reset signal that is connected to the reset function
slot when you use the RESET clause with Q_PROPERTY. This way it would get
automatically triggered when some event happened from your QML. What this
event might be is what I just can't figure out.
I've been through the Cascades and Qt documentation upside-down and
sideways, and I can find lots of stuff about using the RESET clause and
how the reset function must be declared, but nothing on what makes it
trigger.
Does anyone have any insight on this?

Subdomain as a filter (Google Analytics API)

Subdomain as a filter (Google Analytics API)

We are new to Google Analytics (GA), and we are trying to figure out if we
should use it for our use case, which is:
Suppose that we have a domain, say example.com
And we have hundreds of users.
And each user should get his/her own 'website' which actually is a
subdomain of our site
(e.g. steve.example.com)

We would like to -
-----------------------
1. not require each user create a separate GA account (& code).
2. show each user's web-analytics stats in his/her own site

To get the above, will the following work ?
------------------------------------------------
1. we will create 1 GA account/tracking-code for example.com
2. we will use Google Analytics API to get data
3. to retrieve data only for 1 subdomain (user), we will specify the
respective subdomain as a filter
Is 3 possible ? i.e. Will we be able to send queries to Google Analytics
API that include subdomain as one of the filters (alongwith Metrics &
Dimensions like PageViews & Location) ?
Research/Reading that I have done:
---------------------------------------------
1. Most solutions are pointing towards creating separate Profiles for
different SubDomains, but this is not an option for us, since there are so
many of them, and also 50 seems to be a limit on the number of Profiles
that each Domain can have (from
https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts
)
2. Google Analytics does not allow tracking codes/profiles to be created
via API

Execute Javascript Function from From

Execute Javascript Function from From

Sorry for this simple question but I can't find the answer anywhere...I'm
also a Javascript newbie with 0 experience so I'm really stuck.
Anyways, I have a function that is used with a simple button click:
<input type="button" value="Add Item" onclick="addToCartt('MODELNUMBER');">
I need to change that from the current setup where you can click and hit a
button and run the function with the ModelNumber argument into a form
where you enter the ModelNumber manually and hit return via an html form
and run the function addToCartt with the ModelNumber as the argument.
Thanks for any help

How get parametr array?

How get parametr array?

Code:
var photo2 ='[{
"photo":"c8375afbbd:x",
"sizes":[["s","9458927","1d20","RfIuuZB51yM",75,64],["m","9458927","1d21","HALC4aM1hyM",130,111],["x","9458927","1d22","-e8mBA0nmOU",420,360],["o","9458927","1d23","GFqFFIuRFOE",130,111],["p","9458927","1d24","9twLTScmx5c",200,171],["q","9458927","1d25","XikD8ZmYFRs",320,274],["r","9458927","1d26","qAUIuroqtYE",420,360]],
"kid":"7bf1820e725a4a9baea4db56472d76b4"}]
';
When i do:
alert(photo2[0].photo);
i get undefened.
Why i get error and how aright get argument photo in array photo ?

Run javascript function after another is successful

Run javascript function after another is successful

I call a validate form function in the following way:
$(document).ready(function () {
$('#MainContent_btnRegisterClient').click(function (e) {
return validateForm('.registerClient',
'#MainContent_lblRegStatus', '#MainContent_txtClientEmail', e);
});
});
Which calls my validateForm and then validateEmail:
//textbox validation
function validateForm(className, message, email, e) {
var isValid = true;
//empty validation
$(className).each(function () {
if ($.trim($(this).val()) == '') {
isValid = false;
$(message).text(errAllfields);
$(message).fadeIn();
$(this).css({
"border": "1px solid #036447",
"background": "#B5E0D2"
});
}
else {
$(this).css({
"border": "",
"background": ""
});
}
//prevent form submission
if (isValid == false)
e.preventDefault();
});
//if all fields complete
if (isValid == true) {
//if email field entered then validate
if (email != null) {
if (!validateEmail(email, message)) {
return false;
}
}
}
}
However I then want to add another function (password and password confirm
compare function) to be run after these ones are successful. What is the
best way to accomplish this? Can I call it straight from my aspx page?
Thanks

Thursday, 26 September 2013

UITextField issue in iOS 7

UITextField issue in iOS 7

UIAlertView with UITextField not working in iOS 7. How to fix ?
Here is ScreenShot:
Here is my code:
How can I get UITextFeield in UIAlertView in iOS7 ?
-(void)takeUserName
{
mChangePlayerAlert = [[UIAlertView alloc] init];
mChangePlayerAlert.title = title;
mChangePlayerAlert.message = @"\n";
mChangePlayerAlert.delegate = self;
[mChangePlayerAlert addButtonWithTitle:@"Save"];
[mChangePlayerAlert addButtonWithTitle:@"Cancel"];
CGRect frame;
frame = CGRectMake(20, 45, 245, 27);//(200, 500, 400, 120);
mTextFeild = [[UITextField alloc] initWithFrame:frame];
mTextFeild.textColor = [UIColor blueColor];
mTextFeild.borderStyle = UITextBorderStyleRoundedRect;
mTextFeild.keyboardType = inType;//;
mTextFeild.returnKeyType = UIReturnKeyDone;
mTextFeild.autocorrectionType = UITextAutocorrectionTypeNo;
mTextFeild.autocapitalizationType = UITextAutocapitalizationTypeNone;
mTextFeild.delegate = self;
[mChangePlayerAlert addSubview:mTextFeild];
mTextFeild.delegate = self;
[mTextFeild becomeFirstResponder];
[mChangePlayerAlert show];
}

Wednesday, 25 September 2013

In Jenkins, can I trigger a downstream job once a day

In Jenkins, can I trigger a downstream job once a day

We've got a Jenkins setup where we do incremental builds on SCM change,
validate and then if this works do a full build (from scratch). This
basically works but we waste time doing full builds during the day that we
don't normally use.
I know we could trigger full builds every night, but many of our branches
won't change for a few days - and then we might get a rush of changes.
Thus building every branch every night is wasteful too.
What I really want is some mechanism where we only do the full builds once
(say at night) if there has been an SCM change and the incremental build
and validate worked - there is no point auto-triggering full builds where
the incremental build and validate failed. Actually just "the incremental
build and validate worked" should suffice - as these normally just run on
SCM change.
Any suggestions? Is there some Jenkins extension that would help with this?

Thursday, 19 September 2013

Data from Google Spreadsheet to Javascript Object

Data from Google Spreadsheet to Javascript Object

trying to create a set of of html form option/select fields that are
driven by a google spreadsheet, to steer users to specific choices. think
a hat that is available in red, blue or black, a tshirt that is available
in blue, green or red. the source data has the same value in col 1 for
many rows, and unique values in col 2. the colors are specific to each
product. (the spreadsheet structure can not be changed.)
i'm trying to group the rows by product, so i can populate a product
dropdown, then a colors dropdown that is keyed to that product. that's
where i'm stuck.
i have the data loading ok and can do the form displays stuff, just need
some insight into how to end how to structure an array like this: var
productsAndColors = []; productsAndColors[0] = new Array("hat", ["pink",
"red", "blue"]);
just quoting the iffy bit here:
for (i = 0; i < json.feed.entry.length; i++) {
var entry = json.feed.entry[i];
product = entry.gsx$product.$t;
productsAndColors[i] = ['', []];
if (productCheck != product) {
productsAndColors[i][0] = product;
thisShape = product;
}
color = entry.gsx$color.$t;
productsAndColors[i][1].push(color);
}
this creates an array per row, just can't seem to figure out a way to
group the rows. i realize this is cavemanish.
thanks for your thoughts.
http://jsfiddle.net/hartogsmith/SqNNk/
https://docs.google.com/spreadsheet/ccc?key=0AkT3oKFSug31dGhva1lpWkhDOGxKaVJsNnpkZVpNbUE#gid=0

Want to populate the end date of the month in php

Want to populate the end date of the month in php

I have a two datefield textbox. In one field, i populate it by getDate()
which returns the current date . But in another table i want to populate
the exact the last date of that month.
For example Current date : 9/20/2012 in one text Now next date must be
9/30/2012
Similarly Current date : 01/14/2012 in one text Now next date must be
01/31/2012

Creating Word Documents - Win XP and WIn8

Creating Word Documents - Win XP and WIn8

I build a function that creates a loooong word document (700pages++) then
I Export it to .pdf.
This WinXP is a VirtualMachine
It works fine when I'm debbugin/running in WinXP. Also it's really FAST,
like 3minuts.
But When I try the same code with Win8, the Formatation get a little
messed up, also the time... IT gets more than 15minuts to accomplish the
operation.
Why does it have this different with the same source code but only
different SO ?

What Service Needs to be on to translate UserSID

What Service Needs to be on to translate UserSID

I have a script which accepts following input
"sender-ip=10.10.10.10"
It is supposed to return the last user logged on.
First, it will attempt to detect Operating System
Second, it will attempt to detect User Profile
Finally, it will attempt to translate Security Identifier into a user
account, i.e. DOMAIN\username
Here is relevant part of code
$Sender_IP = $my_hash.Get_Item("sender-ip")
try
{
<#Gather information on the computer corresponding to $Sender_IP#>
$Win32OS = Get-WmiObject -Class Win32_OperatingSystem -ComputerName
$Sender_IP -ErrorAction Stop
}
catch [Exception]
{
$userId = "Unknown/CannotDetectOS "
return $output = "userId=" + $userId
}
try
{
$Win32User = Get-WmiObject -Class Win32_UserProfile -ComputerName
$Sender_IP -ErrorAction Stop
}
catch [Exception]
{
$userId = "Unknown/CannotDetectUserProfile "
return $output+= "userId=" + $userId
}
$Win32User = $Win32User | Sort-Object -Property LastUseTime -Descending
$LastUser = $Win32User | Select-Object -First 1
try
{
$UserSID = New-Object
System.Security.Principal.SecurityIdentifier($LastUser.SID)
$userId = $UserSID.Translate([System.Security.Principal.NTAccount])
}
catch [Exception]
{
$userId = "Unknown/CannotDetectUserSID "
return $output = "userId=" + $userId
}
$userId = $userId.Value
if ($userId -ne $NULL){
$output = "userId=" + $userId
}
elseif ($userID -eq $NULL)
{
$userId = "Unknown/UserID"
$output = "userId=" + $userId
}
$output.replace("\","/")
From what I understand, WMI service needs to be turned on in order to
detect Windows Operating system, i.e.
$Win32OS = Get-WmiObject -Class Win32_OperatingSystem -ComputerName
$Sender_IP -ErrorAction Stop
and Windows User Profile, i.e.
$Win32User = Get-WmiObject -Class Win32_UserProfile -ComputerName
$Sender_IP -ErrorAction Stop
But what service needs to be turned on to properly translate Security
Identifier, i.e.
$Win32User = $Win32User | Sort-Object -Property LastUseTime -Descending
$LastUser = $Win32User | Select-Object -First 1
try
{
$UserSID = New-Object
System.Security.Principal.SecurityIdentifier($LastUser.SID)
$userId = $UserSID.Translate([System.Security.Principal.NTAccount])
}
catch [Exception]
{
$userId = "Unknown/CannotDetectUserSID "
return $output = "userId=" + $userId
}
One week I will run the script with "sender-ip=10.10.10.10" and get the
actual user, and the next week script throws "CannotDetectUserProfile",
and next week script throws "CannotDetectOS", etc
What service needs to be turned on, and can I do this remotely through
powershell?

Is there a name for this creation pattern?

Is there a name for this creation pattern?

What should I be calling the "BFactory" below. Its not really a Factory
since there is no selection of a concrete class happening, and its not
necessarily creating an object each time. Its kind of a Pool but the users
do not return the Bs they get to the pool after they are done with them.
It could be called a Cache but performance is not the primary intention.
The intention is that everyone who is using the same BFactory will get the
same B when they pass the same A which starts to sound kind of like a
singleton-ish.
public class A
{
public int MyProperty { get; set; }
}
public class B
{
public B(A wrapped)
{
Wrapped = wrapped;
}
public A Wrapped { get; set; }
}
public class BFactory
{
private Dictionary<A,B> _created = new Dictionary<A,B>();
public B GetB(A a)
{
if (_created.ContainsKey(a) == false)
{
_created[a] = new B(a);
}
return _created[a];
}
}

what's wrong with this program

what's wrong with this program

I've a code snippet:
class WhileTest
{
public static void main(String s[])
{
int x=12;
while(x<13)
{
x--;
}
System.out.println(x);
}
}
The output of the above program is: 2147483647
Why so?
Code on ideone

table search data can be shown... search function ok... display error

table search data can be shown... search function ok... display error

<in form.html>
<title>Live Search!</title>
<header>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript" src="EditDeletePage.js"></script>
<style type="text/css">
body{
width: 1000px;
margin: 0 auto;
padding: 0;
font-family:Arial, Helvetica, sans-serif
}
#loading{
width: 100%;
position: absolute;
top: 200px;
left: 200px;
margin-top:200px;
}
#container .pagination ul li.inactive,
#container .pagination ul li.inactive:hover{
background-color:#ededed;
color:#bababa;
border:1px solid #bababa;
cursor: default;
}
#container .data ul li{
list-style: none;
font-family: verdana;
margin: 10px 0 100px 0;
color: #000;
font-size: 11px;
}
#container .pagination{
width: 1000px;
height: 25px;
}
#container .pagination ul li{
list-style: none;
float: left;
border: 1px solid #006699;
padding: 2px 6px 2px 6px;
margin: 0 3px 0 3px;
font-family: arial;
font-size: 14px;
color: #006699;
font-weight: bold;
background-color: #f2f2f2;
}
#container .pagination ul li:hover{
color: #fff;
background-color: #006699;
cursor: pointer;
}
.go_button
{
background-color:#f2f2f2;border:1px solid
#006699;color:#cc0000;padding:2px 6px 2px
6px;cursor:pointer;position:absolute;margin-top:-1px;
}
.total
{
float:right;font-family:arial;color:#999;
}
.editbox
{
display:none;
}
td, th
{
width:25%;
text-align:left;;
padding:5px;
}
.editbox
{
padding:4px;
}
</style>
</header>
Keyword Search:
<form id="searchform" method="post" onsubmit="return false;">
<input autocomplete="off" id="searchbox" name="searchq"
onkeyup="sendRequest()" type="textbox">
</form><table border = '1'>
<tr><th>Student
Name</th><th>Password</th><th>email</th><th>student
Id</th><th>Edit</th></tr>
</table>
<div id="show_results"></div><script src="prototype.js"
type="text/javascript">
</script>
<script>
function sendRequest() {
new Ajax.Updater('show_results', 'search.php', { method:
'post', parameters: $('searchform').serialize() });
}
</script>
<in search.php>
<?php require_once("../includes/session.php"); ?>
<?php require_once("../includes/connection.php") ?>
<?php require_once("../includes/functions.php") ?>
<?php
$searchq = $_POST['searchq'];
$tablehead="<tr><th>Product
Name</th><th>Category</th><th>Price</th><th>Discount</th><th>Edit</th></tr>";
$tabledata = "";
if(empty($searchq)) {
echo "";
} else {
//If there is text in the search field, this code is executed every
time the input changes.
echo "<div id='results'-->"; //this div is used to contain the
results. Mostly used for styling.
//This query searches the name field for whatever the input is.
$sql = "SELECT * FROM `tblstudent` WHERE `student_id` LIKE
'%$searchq%' or `name` LIKE '%$searchq%' or `email` LIKE
'%$searchq%'";
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result)) {
$id = $row['id'];
$student_id=htmlentities($row['student_id']);
$hashed_password=htmlentities($row['hashed_password']);
$name=htmlentities($row['name']);
$email=htmlentities($row['email']);
$tabledata.="<tr id='$id' class='edit_tr'><td class='edit_td' >
<span id='one_$id' class='text'>$student_id</span>
<input type='text' value='$student_id' class='editbox' id='one_input_$id' />
</td>
<td class='edit_td' >
<span id='two_$id' class='text'>$hashed_password</span>
<input type='text' value='$hashed_password' class='editbox'
id='two_input_$id'/>
</td>
<td class='edit_td' >
<span id='three_$id' class='text'>$name $</span>
<input type='text' value='$name' class='editbox' id='three_input_$id'/>
</td>
<td class='edit_td' >
<span id='four_$id' class='text'>$email $</span>
<input type='text' value='$email' class='editbox' id='four_input_$id'/>
</td>
<td><a href='#' class='delete' id='$id'> X </a></td>
</tr>";
}
$finaldata = "<table width='100%'>". $tablehead . $tabledata . "</table>";
// Content for Data
}
echo "</div>";
?>
this is the js query plug in.
<EditDeletePage.js>
$(document).ready(function()
{
$(".delete").live('click',function()
{
var id = $(this).attr('id');
var b=$(this).parent().parent();
var dataString = 'id='+ id;
if(confirm("Sure you want to delete this update? There is NO undo!"))
{
$.ajax({
type: "POST",
url: "delete_ajax.php",
data: dataString,
cache: false,
success: function(e)
{
b.hide();
e.stopImmediatePropagation();
}
});
return false;
}
});
$(".edit_tr").live('click',function()
{
var ID=$(this).attr('id');
$("#one_"+ID).hide();
$("#two_"+ID).hide();
$("#three_"+ID).hide();
$("#four_"+ID).hide();
$("#one_input_"+ID).show();
$("#two_input_"+ID).show();
$("#three_input_"+ID).show();
$("#four_input_"+ID).show();
}).live('change',function(e)
{
var ID=$(this).attr('id');
var one_val=$("#one_input_"+ID).val();
var two_val=$("#two_input_"+ID).val();
var three_val=$("#three_input_"+ID).val();
var four_val=$("#four_input_"+ID).val();
var dataString = 'id='+ ID
+'&name='+one_val+'&category='+two_val+'&price='+three_val+'&discount='+four_val;
if(one_val.length>0&& two_val.length>0 && three_val.length>0 &&
four_val.length>0)
{
$.ajax({
type: "POST",
url: "live_edit_ajax.php",
data: dataString,
cache: false,
success: function(e)
{
$("#one_"+ID).html(one_val);
$("#two_"+ID).html(two_val);
$("#three_"+ID).html(three_val);
$("#four_"+ID).html(four_val);
e.stopImmediatePropagation();
}
});
}
else
{
alert('Enter something.');
}
});
// Edit input box click action
$(".editbox").live("mouseup",function(e)
{
e.stopImmediatePropagation();
});
// Outside click action
$(document).mouseup(function()
{
$(".editbox").hide();
$(".text").show();
});
//Pagination
function loading_show(){
$('#loading').html("<img src='images/loading.gif'/>").fadeIn('fast');
}
function loading_hide(){
$('#loading').fadeOut('fast');
}
function loadData(page){
loading_show();
$.ajax
({
type: "POST",
url: "load_data.php",
data: "page="+page,
success: function(msg)
{
$("#container").ajaxComplete(function(event, request, settings)
{
loading_hide();
$("#container").html(msg);
});
}
});
}
loadData(1); // For first time page load default results
$('#container .pagination li.active').live('click',function(){
var page = $(this).attr('p');
loadData(page);
});
$('#go_btn').live('click',function(){
var page = parseInt($('.goto').val());
var no_of_pages = parseInt($('.total').attr('a'));
if(page != 0 && page <= no_of_pages){
loadData(page);
}else{
alert('Enter a PAGE between 1 and '+no_of_pages);
$('.goto').val("").focus();
return false;
}
});
});
I edit from the
http://palavas.biz/forum/viewtopic.php?f=51&t=4143&sid=9241f1f287fc672cc32f91a06b93f4c3#.UjqVx9Jmim4
but not work... i try to change the function that already have a table
display to a search function only display out. but unfortunately I can't
display out the data which list inside the table when type words in the
search keyword textbox.

Wednesday, 18 September 2013

Double splitview

Double splitview

In my application i want to add multiple splitviews as like in the image,
i have gone through so man Split1,Split2,Split3.

But no one supports nested splitviews.Can one please help me with some
refrence.

rooted android stop wi-fi, when not needed

rooted android stop wi-fi, when not needed

Samsung Galaxy Note 10.1 N8000 has 1 feature, which I like it. Doesn't
drain the battery f the screen off and I went to sleep and forgot to turn
off the wi-fi. Once I got even with 30% battery after 2 weeks when I came
back from vacation. It has inserted a 3G SIM too ( works only with 3G) I
am wondering how can I make an app on my rooted Android phone to copy this
functionality.
Here is how to turn off WI-FI Here is how to turn off 3G
But if I put they into an app, than my app need to be launched at boot-up
and stay in foreground? -or make a Service without Activity?

Sound is not working in backtrack5r3

Sound is not working in backtrack5r3

How to update or install the sound driver in backtrack5r3 is the same way
we do in ubuntu like to install some thing we write sudo-apt get insatall
or the syntax is change anybody please help me out

Ruby - how to group data in object?

Ruby - how to group data in object?

I am receiving data in this format:
{2013-09-13 22:55:56 UTC=>1, 2013-09-15 13:14:19 UTC=>1, 2013-09-16
13:05:39 UTC=>1, 2013-09-16 19:12:44 UTC=>1}
I would need to group them according to day, to this shape:
{2013-09-13=>1, 2013-09-15=>1, 2013-09-16=>2}
How to do this in Ruby?
Thanks

Centered icons with float:left

Centered icons with float:left

I have a problem with the centering icon
CSS:
.icons .overview {
position: relative;
float: left;
width: 16.6666666667%;
text-align: center;
overflow: visible;
}
.icon {
display: inline-block;
width: 64px;
height: 64px;
cursor: help;
margin-bottom: 20px;
}
Website: http://www.plus-seo.pl/ category "Oferta" Any ideas?

Uncaught reference error: xy not defined but working

Uncaught reference error: xy not defined but working

I have something like this in which the value gets updated
($('#'+name+userid).val(value);), but the userid variable cannot be found.
If I define a new userid variable as a.attr('userid'), the value does not
get updated. Why is this working then?
$.ajax({
url: '../modify_users_admin.inc.php',
type: 'POST',
data: {
value: a.attr('value'),
name: a.attr('name'),
userid: a.attr('userid')
},
success: function(data) {
$('#'+name+userid).val(value);
if (data) {
console.log('s');
alert(data);
}
else {
$('#notice').text('Updated');
$('#notice').fadeOut().fadeIn();
}
}
});

Preventing JSF commandButton from reloading the page

Preventing JSF commandButton from reloading the page

I have a page with 2 forms on it.
Initially, one of them is hidden while the other is visible. When the
first one is filled in and the submit/continue button is clicked, the
first one should be hidden and the second one should be display.
When I click the button, it hides the first form and displays the second,
but after a moment the page reloads and I'm staring at the first form
again. Does anyone know what I can do to prevent this from happening?
Here is the button I use:
<h:commandButton immediate="true" value="Continue" styleClass="btn
btn-warning btn-large btn-block" onclick="formClick('adult',
#{adult.index})"></h:commandButton>

Tuesday, 17 September 2013

when click on aspbuttone slide div class right to left Jquery

when click on aspbuttone slide div class right to left Jquery

When I am clicking on asp button div slide from right to left but when I
click on a button which is inside the div then jquery stops working
Following is my code
<script type="text/javascript">
$(function () {
var myDivWidth = $(".boxno1").width();
$('[id$=reqbtn]').click(function (e) {
if ($("div.boxno1").width() == 0) {
$("div.boxno1").animate({ width: myDivWidth },
'slow');
$("div.boxno1").toggle("slow");
//$("td#panel").show();
return false;
} else {
$("div.boxno1").animate({ width: 0 }, 'slow');
$("div.boxno1").toggle("slow");
//$("td#panel").hide();
return false;
}
});
</script>

Enable RequiredFieldValidator if TextBox is not empty

Enable RequiredFieldValidator if TextBox is not empty

can you help me with this simple problem of mine in asp.net,
I have 3 textboxes; Txt1 Txt2 txt3
If txt1 is not empty, txt2 and txt3 requiredvalidator should be enabled.
if txt1 is empty, txt2 and txt3 requiredvalidator should not be enabled,
Here's the requirement, once txt1 has a value, txt2 and txt3 should be a
required field.
can someone help me with this??
Thank you so much.

How can I re-install ADT?

How can I re-install ADT?

I have Eclipse and ADT. My copy of Eclipse crashed. In this topic (Eclipse
crashes when it's starting) I was advised to re-install ADT. I read that I
can install ADT from Eclipse. But my Eclipse doesn't start. Do I have to
re-install Eclipse too?

how to run apache's vysper xmpp server

how to run apache's vysper xmpp server

I'm having issue running vysper.
1) Download/Extract Files
http://mina.apache.org/vysper-project/downloads.html Apache Vysper 0.7
Release 2) Modified the spring-config.xml to have additional
users/passwords
Just updated this section:
<bean id="addUsers" class="org.apache.vysper.spring.AddUserHelper">
<constructor-arg index="0">
<map>
<entry key="admin@vysper.org" value="Password" />
<entry key="darewreck@test" value="Password" />
<!--<entry key="user2@vysper.org" value="CHOOSE A SECURE
PASSWORD" />-->
<!--<entry key="user3@vysper.org" value="CHOOSE A SECURE
PASSWORD" />-->
</map>
</constructor-arg>
<property name="storageProviderRegistry" ref="storageRegistry" />
</bean>
3) executed /bin/run.bat
16:16:22,415 | INFO |
org.springframework.context.support.ClassPathXmlApplicationContext |
Refreshing
org.springframework.context.support.ClassPathXmlApplicationContext@625e068:
startup date [Mon Sep
16 16:16:22 PDT 2013]; root of context hierarchy
16:16:22,457 | INFO |
org.springframework.beans.factory.xml.XmlBeanDefinitionReader | Loading
XML bean definitions from class path resource [spring-config.xml]
16:16:22,514 | INFO |
org.springframework.beans.factory.support.DefaultListableBeanFactory |
Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@19f9e
414: defining beans
[inmemoryStorageRegistry,jcrStorageRegistry,addUsers,tcpEndpoint,server];
root of factory hierarchy
16:16:22,762 | INFO |
org.apache.vysper.xmpp.server.DefaultServerRuntimeContext | replacing the
storage provider registry with
org.apache.vysper.storage.inmemory.MemoryStorageProviderRegistry
16:16:22,821 | INFO |
org.apache.vysper.xmpp.server.DefaultServerRuntimeContext | adding
module... servicediscovery (1.0beta)
16:16:22,825 | INFO |
org.apache.vysper.xmpp.server.DefaultServerRuntimeContext | adding
module... roster (1.0beta)
16:16:22,877 | INFO |
org.apache.vysper.xmpp.server.DefaultServerRuntimeContext | adding
module... XEP-0092 Software Version (1.0)
16:16:22,881 | INFO |
org.apache.vysper.xmpp.server.DefaultServerRuntimeContext | adding
module... XEP-0202 Entity Time (1.0)
16:16:22,883 | INFO |
org.apache.vysper.xmpp.server.DefaultServerRuntimeContext | adding
module... XEP-0054 Vcard-temp (1.0)
16:16:22,883 | ERROR |
org.apache.vysper.xmpp.modules.extension.xep0054_vcardtemp.VcardTempModule
| no VcardTempPersistenceManager found
16:16:22,883 | INFO |
org.apache.vysper.xmpp.server.DefaultServerRuntimeContext | adding
module... XEP-0199 XMPP Ping (2.0)
16:16:22,883 | INFO |
org.apache.vysper.xmpp.server.DefaultServerRuntimeContext | adding
module... XEP-0049 Private Data (1.2)
16:16:22,884 | ERROR |
org.apache.vysper.xmpp.modules.extension.xep0049_privatedata.PrivateDataModule
| no PrivateDataPersistenceManager found
16:16:22,884 | INFO |
org.apache.vysper.xmpp.server.DefaultServerRuntimeContext | adding
module... XEP-0050 Ad-hoc Commands (1.2)
16:16:22,885 | INFO |
org.apache.vysper.xmpp.server.DefaultServerRuntimeContext | adding
module... XEP-0133 Service Administration (1.1)
16:16:22,885 | INFO |
org.apache.vysper.xmpp.server.DefaultServerRuntimeContext | adding
module... XEP-0045 Multi-user chat (1.24)
16:16:22,891 | WARN |
org.apache.vysper.xmpp.modules.extension.xep0045_muc.MUCModule | No room
storage provider found, using the default (in memory)
16:16:22,891 | WARN |
org.apache.vysper.xmpp.modules.extension.xep0045_muc.MUCModule | No
occupant storage provider found, using the default (in memory)
4) Opened an XMPP client (Swift) (Any XMPP client should work)
User: darewreck@test Password: Password
However, Swift Client receives an encryption error. I'm not really sure
what I'm doing wrong.
The server prints out:
16:18:49,571 | DEBUG | org.apache.vysper.xmpp.protocol.SessionStateHolder
| session state changed to = INITIATED
16:18:56,582 | DEBUG | org.apache.vysper.xml.decoder.XMPPContentHandler |
Decoder writing stanza: <stream:stream
xmlns:stream="http://etherx.jabber.org/streams" to="test"
version="1.0"></stream:stream
>
16:18:56,584 | INFO | stanza.client | stream
16:18:56,585 | DEBUG | org.apache.vysper.xmpp.protocol.SessionStateHolder
| session state changed to = STARTED
16:18:56,588 | INFO | stanza.server | stream.starttls[required]
16:18:56,590 | DEBUG | org.apache.vysper.xml.decoder.XMPPContentHandler |
Decoder writing stanza: <starttls
xmlns="urn:ietf:params:xml:ns:xmpp-tls"></starttls>
16:18:56,591 | INFO | stanza.client | starttls
16:18:56,592 | DEBUG | org.apache.vysper.xmpp.protocol.SessionStateHolder
| session state changed to = ENCRYPTION_STARTED
16:18:56,604 | DEBUG | org.apache.vysper.xmpp.protocol.SessionStateHolder
| session state changed to = CLOSED
Is there something i'm not configuring correctly with the
authentication/password provided in the spring-config.xml file?
Thanks, Any Advice appreciated, D

How can I get Oracle to have a better execution plan for this query?

How can I get Oracle to have a better execution plan for this query?

We have some tables which keep track of processed transactions. These
tables have millions of rows. Often times I want to look at the most
recent X transactions, so I have a query like this to pull the info I want
from a few tables:
select a.id, b.field_one, c.field_two
from trans a, table_two b, table_three c
where a.id = b.id
and a.id = c.id
and a.id in
(select id from trans where id > (select max(id) from trans) - 100);
Right now the query is very slow. The explain plan shows a full table scan
on B and C. Now, if I evaluate the nested query separately and replace it
with a list of comma separated IDs, the query is very fast. This seems
obvious to me - it will only have 100 rows to join together so of course
it will be faster than if it answered the query by first joining A and B
together.
Conceptually I understand the query optimizer is trying to find a good
execution plan but in this case it seems like it is doing a terrible job.
Is there any way to force the DBMS to execute the nested query first?
Possibly by using a Hint?
Thanks

Sunday, 15 September 2013

Select Case Function asking for Return Value

Select Case Function asking for Return Value

I am trying to write to Select Case functions, one for two excel
worksheets and one for a range of cells. The functions are used to index
the sheets and ranges for a sorting procedure. However, the Functions are
asking me for a return value, and I am not sure what value to return. I
can't return my parameter. Basically, I want my sort sub to loop through
both sheets and both ranges and sort the sheets in the select ranges in
the function.
If there is a better approach, I am also open to suggestions.
Here is my code:
Dim xlWB As Excel.Workbook =
CType(Globals.ThisWorkbook.Application.ActiveWorkbook, Excel.Workbook)
Dim xlWSEmployee As Excel.Worksheet =
CType(CType(xlWB.Sheets("byEmployee"), Excel.Worksheet), Excel.Worksheet)
Dim xlWSPosition As Excel.Worksheet =
CType(CType(xlWB.Sheets("byPosition"), Excel.Worksheet), Excel.Worksheet)
Public Function SheetsToSort(Index As Long) As Excel.Worksheet
Select Case Index
Case 1 : SheetsToSort = xlWSEmployee
Case 2 : SheetsToSort = xlWSPosition
End Select
***Return (?)***
End Function
Public Function GetRange(index As Long) As Excel.Range
Select Case index
Case 1 : GetRange = xlWSEmployee.Range("A1")
Case 2 : GetRange = xlWSPosition.Range("W1")
End Select
***Return (?)***
End Function
Sub Sort_Sheets()
Dim refSheets As Excel.Worksheet
Dim sortRange As Excel.Range
Dim x As Long
'This is Step 6 when the frmDataImportSplash is activated.
'The key formulas only work if the data is sorted properly.
The procedure
'below sorts each sheet by the required field. Look at the
public_Declarations module
'for the pass byRef.
For x = 1 To 2 Step 1
refSheets = SheetsToSort(x)
sortRange = GetRange(x)
With refSheets
.Sort.SortFields.Clear()
.Sort.SortFields.Add(Key:=(refSheets.sortRange),
SortOn:=XlSortOn.xlSortOnValues,
Order:=Excel.XlSortOrder.xlAscending,
DataOption:=XlsortDataoption.xlSortNormal)
With .Sort
.Header = XlYesNoGuess.xlYes
.MatchCase = False
.Orientation = Excel.XlSortOrientation.xlSortColumns
.SortMethod = Excel.XlSortMethod.xlPinYin
.Apply()
End With
End With
Next x
End Sub

Zurb foundation grid calculations not working correctly

Zurb foundation grid calculations not working correctly

I've setup the grid in _settings.scss and it isn't going quite as wide as
it should. I want a 980px width grid and it's only spanning 960px. I'm
wondering what I'm doing wrong. Here are the default settings I have:
$base-font-size: 14px !default;
$em-base: $base-font-size !default;
$row-width: 980px;
$column-gutter: 14px;
$total-columns: 12;
Can anyone see why my columns aren't spanning their expected width? A
single column should be 81.66px but it's currently only showing as 81.33px
Thanks for any help

#1054 - Unknown column 'node.id' in 'on clause'

#1054 - Unknown column 'node.id' in 'on clause'

Trying to work with a nested set model. Retrieving a Single Path, starting
at 'Pakken', the parent of it is 'Heren', but since this is hierarchical
data, 'Heren' could have an unlimited amount of parents to himself.
I'm stuck on the join, giving me this error
#1054 - Unknown column 'node.id' in 'on clause'
From this query where I try to join the product where his
products.category_id must be equal to the selected id of the objects
(node).
SELECT *
FROM `categories` AS `node`,
`categories` AS `parent`
INNER JOIN `products` ON `node`.`id` = `products`.`category_id`
WHERE `node`.`lft` BETWEEN `parent`.`lft` AND `parent`.`rght`
AND `parent`.`id` = '1'
ORDER BY `node`.`lft`;
Code works fine without the INNER JOIN to it.
Thanks :)

Mediastore scan does not notice mp3 album artwork tagging

Mediastore scan does not notice mp3 album artwork tagging

my code changes the artwork of a single mp3 file. By opening the mp3 file
on my pc the artwork got changed but by opening the mp3 file on the
android device nothing happend. The shown artwork is still the old one.
I guess that this has sth. to do with the mediastore therefore I tried this:
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
File f = new File(song_path);
Uri contentUri = Uri.fromFile(f);
mediaScanIntent.setData(contentUri);
FindCoverActivity.this.sendBroadcast(mediaScanIntent);
but nothing happend.
I tried another thing: By changing the artwork AND the name of the album
the mediastore immediatly noticed what was going on and by opening the mp3
file on the android phone again, the artwork gets displayed correctly with
the new artwork. But it is not my goal to change important mp3 tags like
the album name. Could this be a bug or has anyone suggestions?
Thanks!

error while parsing rss feed for stackoverflow.com

error while parsing rss feed for stackoverflow.com

i am trying to create rss feeds app that parses all the websites
supporting feed. i used Jsoup for this purpose. and parsed for different
type of rss in this way
org.jsoup.select.Elements links =
doc.select("link[type=application/rss+xml]"); org.jsoup.select.Elements
links = doc.select("link[type=application/atom+xml]");
it parses various websites like engadget.com, ndtv.com etc but when i
tried to pase websites like stackoverflow.com or 1up.com i got the
following error.
thread exiting with uncaught exception (group=0x40efe378)
and
Caused by: java.lang.IllegalStateException: Target host must not be null,
or set in parameters. scheme=null, host=null, path=/rss
searching for error #1 didnt yield even 1 results. searching for eroror #2
had many. all stated to use http:// before any websites url like
http://1up.com
but then too the error persists. and i had already implemented this before
since all other websites rss are parsed. this is my logcat for 1up.com rss
feed.
D/URL Length(4097): 14 D/url name(4097): http://1up.com D/No of RSS links
found(4097): 1 W/dalvikvm(4097): threadid=12: thread exiting with uncaught
exception (group=0x40efe378) E/AndroidRuntime(4097): FATAL EXCEPTION:
AsyncTask #1 E/AndroidRuntime(4097): java.lang.RuntimeException: An error
occured while executing doInBackground() E/AndroidRuntime(4097): at
android.os.AsyncTask$3.done(AsyncTask.java:299) E/AndroidRuntime(4097): at
java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
E/AndroidRuntime(4097): at
java.util.concurrent.FutureTask.setException(FutureTask.java:124)
E/AndroidRuntime(4097): at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
E/AndroidRuntime(4097): at
java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/AndroidRuntime(4097): at
android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
E/AndroidRuntime(4097): at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
E/AndroidRuntime(4097): at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
E/AndroidRuntime(4097): at java.lang.Thread.run(Thread.java:856)
E/AndroidRuntime(4097): Caused by: java.lang.IllegalStateException: Target
host must not be null, or set in parameters. scheme=null, host=null,
path=/rss E/AndroidRuntime(4097): at
org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:591)
E/AndroidRuntime(4097): at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:293)
E/AndroidRuntime(4097): at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
E/AndroidRuntime(4097): at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
E/AndroidRuntime(4097): at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
E/AndroidRuntime(4097): at
com.maulik.rss.RssParser.getXmlFromUrl(RssParser.java:214)
E/AndroidRuntime(4097): at
com.maulik.rss.RssParser.getRSSFeed(RssParser.java:69)
E/AndroidRuntime(4097): at
com.maulik.rss.RSS_AddNewSiteActivity$loadRSSFeed.doInBackground(RSS_AddNewSiteActivity.java:97)
E/AndroidRuntime(4097): at
com.maulik.rss.RSS_AddNewSiteActivity$loadRSSFeed.doInBackground(RSS_AddNewSiteActivity.java:1)
E/AndroidRuntime(4097): at android.os.AsyncTask$2.call(AsyncTask.java:287)
E/AndroidRuntime(4097): at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/AndroidRuntime(4097): ... 5 more

Why will byte not take 0xff in java?

Why will byte not take 0xff in java?

Why will java compiler not let me put 0xff into a byte, 0xff is 8 bits
long which is just the size of byte datatype.

Can someone explain why 1 works and why 2 does not ?
class a
{
public static void main(String[] args)
{
// 1
byte a = 0xff; //results in error
System.out.printf("%x\n",a);
//2
byte a = (int)0xff // works fine
System.out.printf("%x\n",a);
}
}

cocos2d python can't show UI in mac

cocos2d python can't show UI in mac

when I run cocos2d(python)hello example in mac pro, I use sudo ,but no UI
show , what I missed?

jQuery XML Parse - check if Element has attribute

jQuery XML Parse - check if Element has attribute

Would you please help with an issue i have with some XML documents.
When parsing through the documents I am getting to a point where i need to
only acquire the pertinent data.
Here is an example of a set of child elements that I am looping:
<element type="forecast_icon_code">3</element>
<text type="precis">Partly cloudy.</text>
<text type="probability_of_precipitation">10%</text>
$(locationInfo).children().each(function(){
alert($(this).attr("forecast_icon_code"));
});
The returned value is "undefined"

Saturday, 14 September 2013

Out Of Bounds Expeption location (JAVA)

Out Of Bounds Expeption location (JAVA)

Can someone help me understand where the out of bounds exeption is
happening. The compiler said its here if(content[i] == delSub[j]) and out
of bounds by 5. is that really where its happening and if so why?
char[] content = new char []{'A','B','C','D','E','F','G'};
//SubString = BCDEF
public int deleteSubString(String delSubString)
{
int count = 0;
char[] delSub = new char[delSubString.length()];
String temp = "";
for(int i = 0; i < content.length;i++)
{
for (int j = 0; i < delSub.length;j++)
{
if(content[i] == delSub[j])
{
temp = temp + content[i];
}
}
}
return 0;
//TODO configure return statement conditions
}

How to set the master page dynamically using http handler?

How to set the master page dynamically using http handler?

I knew we can set the master page dynamically using PreInit method of each
page... but if i want to set the master page dynamically for more than 10
pages, changing the code in each page is not good idea....Did anyone tried
using Http Handler?

main arguments and functions in c

main arguments and functions in c

int multiply(int n){
doenstwork = n * 2
return doesntwork;
int main(int argc, char *argv[]){
int n;
n = atoi(argv[1]);
return multiply(n);
}
I have been sitting for hours and trying to figure out how c handles
argument and how functions work. I wrote this code and don´t have any idea
why it doesn´t work.
I really want to make friends with c but it seems not to like me or maybe
I'm not trying hard enough;) Please make me think the right way.

How to print data that I will show in datagridviewer?

How to print data that I will show in datagridviewer?

I have 3 buttons and 1 datagridview. 1st button is to show the
borrowedbooks 2nd is to show returned books and 3rd is to show penalty in
datagridview. What I need to do is to print the data that I will show in
datagridview. Can someone help me with this.

How to display text from a text file in labels which are created dynamically depending on number of lines in the text file using vb.net

How to display text from a text file in labels which are created
dynamically depending on number of lines in the text file using vb.net

Below is my code. I have a text file "D:\1.txt" which contains some text
in lines. i want to display each line as a label in a Tabcontrol Tabpage.
But using this code I am only able to create the first line as a label.
The other lines are not displayed.THIS code is triggered during a form
load.
Dim FILE_NAME As String = "D:\1.txt"
For Each line As String In System.IO.File.ReadAllLines(FILE_NAME)
Dim label1 As New Label
label1.Text = line
TabPage2.Controls.Add(label1)
Next
Can anyone help me?

Track Friend Location android like GPS Tracking Pro

Track Friend Location android like GPS Tracking Pro

I want to make and application which tracks the location of my
friends,relatives etc.Basically In my application when the user enters his
friend phone number,I want to track friend location from friend phone GPS
or wifi or cell tower.I want the similar functionality like GPS Tracking
Pro
"https://play.google.com/store/apps/details?id=com.fsp.android.c&hl=en"
I got one solution but for that my friend should also installed this
application and should continuously update its location,But I don't want
my friend to install this application to update its location and should
update any location updates.Can anyone please help me that how can I
achieve this...?

calling a web method from clientside using jquery ajax method - not calling method rather going into pageload

calling a web method from clientside using jquery ajax method - not
calling method rather going into pageload

I click my edit button,it enters button click function in javascript.When
ajax() is executed the control goes to page load of WebForm rather than
directly calling update() of webform which I'm mentioning as [ url:
"WebForm1.aspx/update",] in ajax().Why not my update function is invoked
?? I'm having master page for my webform and the button is an asp:control
my aspx page looks like this
This is my javascript
$(document).ready(function () {
$("input[id*='edit']").click(function () {
var userdata = {};
userdata["Name"]="Saran";
var DTO = { 'userdata' : userdata};
$.ajax({
type: "POST",
contenttype: "application/json; charset=utf-8",
url: "WebForm1.aspx/update",
data: JSON.stringify(DTO),
datatype: "json",
success: function (result) {
//do something
alert("SUCCESS = " + result);
console.log(result);
},
error: function (xmlhttprequest, textstatus, errorthrown) {
alert(" conection to the server failed ");
console.log("error: " + errorthrown);
}
});//end of $.ajax()
return false;
});//eof button click
});
and my webform looks like this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using Payoda.Assignments.BusinessLayer;
namespace Payoda.Assignments.LoginApplication
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string update(string userdata)
{
return "success";
}
}
}
<%@ Page Title="" Language="C#" MasterPageFile="~/MyMasterPage.Master"
AutoEventWireup="true" CodeBehind="TrialPage.aspx.cs"
Inherits="Application.TrialPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script src="Scripts/jquery-1.10.2.js"></script>
<script src="Scripts/TrialScript.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Contents" runat="server">
<asp:Button ID="editLink" runat="server" Text="MY BUTTON" />
</asp:Content>