how to retrieve the orderID from custom list view in Android
Can any one help me in retrieving the order id from custom list view with
check box. I need to get the order id, which are checked, when the show
button is clicked, i need to get the order id which is added to the
mopenOrders array list . the checked/selected order id's from the custom
list view i must retrieve, below is the image and my code
My main activity:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
ListView mListView;
Button btnShowCheckedItems;
ArrayList<Product> mProducts;
ArrayList<OpenOrders> mOpenOrders;
MultiSelectionAdapter<OpenOrders> mAdapter;
public String serverStatus =null;
private InputStream is;
private AssetManager assetManager;
ArrayList<String> order_Item_Values =new
ArrayList<String>();
int mMAX_ORDERS_TOBEPICKED; //Parameter passed from
server for the selection of max order
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
assetManager=getAssets();
bindComponents();
init();
addListeners();
}
private void bindComponents() {
// TODO Auto-generated method stub
mListView = (ListView) findViewById(android.R.id.list);
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
btnShowCheckedItems = (Button)
findViewById(R.id.btnShowCheckedItems);
}
private void init() {
// TODO Auto-generated method stub
try {
is = assetManager.open("open_order_item_details.txt");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String jString = getStringFromInputStream(is);
String fileContent=jString;
JSONObject jobj = null;
JSONObject jobj1 = null;
JSONObject ItemObj=null;
try {
jobj = new JSONObject(fileContent);
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
System.out.println("READ/PARSING JSON");
serverStatus = jobj.getString("SERVER_STATUS");
System.out.println("serverStatusObj: "+serverStatus);
JSONArray serverResponseArray2=jobj.getJSONArray("SERVER_RESPONSE");
for (int m = 0; m < serverResponseArray2.length(); m++) {
String SERVER_RESPONSE = serverResponseArray2.getString(m);
JSONObject Open_Orders_obj = new JSONObject(SERVER_RESPONSE);
mMAX_ORDERS_TOBEPICKED =
Open_Orders_obj.getInt("MAX_ORDERS_TOBEPICKED");
JSONArray ja =
Open_Orders_obj.getJSONArray("ORDER_ITEM_DETAILS");
order_Item_Values.clear();
mOpenOrders = new ArrayList<OpenOrders>();
for(int i=0; i<ja.length(); i++){
String ORDER_ITEM_DETAILS = ja.getString(i);
// System.out.println(ORDER_ITEM_DETAILS);
jobj1 = new JSONObject(ORDER_ITEM_DETAILS);
String ORDERNAME = jobj1.getString("ORDERNAME");
String ORDERID = jobj1.getString("ORDERID");
mOpenOrders.add(new OpenOrders(ORDERID,ORDERNAME));
}
}
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
mAdapter = new MultiSelectionAdapter<OpenOrders>(this, mOpenOrders);
mListView.setAdapter(mAdapter);
}
private void addListeners() {
// TODO Auto-generated method stub
btnShowCheckedItems.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(mAdapter != null) {
SparseBooleanArray checked = mListView.getCheckedItemPositions();
for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) {
int pos = checked.keyAt(i);
Object o = mListView.getAdapter().getItem(pos);
// do something with your item. print it, cast it, add
it to a list, whatever..
Log.d(MainActivity.class.getSimpleName(), "cheked Items: " +
o.toString());
Toast.makeText(getApplicationContext(), "chked Items:: "
+o.toString(), Toast.LENGTH_LONG).show();
}
}
ArrayList<OpenOrders> mArrayProducts = mAdapter.getCheckedItems();
Log.d(MainActivity.class.getSimpleName(), "Selected Items: " +
mArrayProducts.toString());
}
}
private static String getStringFromInputStream(InputStream is) {
BufferedReader br = null;
StringBuilder sb = new StringBuilder();
String line;
try {
br = new BufferedReader(new InputStreamReader(is));
while ((line = br.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return sb.toString();
}
}
MultiSelectionAdapter.java
import java.util.ArrayList;
import android.content.Context;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
public class MultiSelectionAdapter<T> extends BaseAdapter{
Context mContext;
LayoutInflater mInflater;
ArrayList<T> mList;
SparseBooleanArray mSparseBooleanArray;
public MultiSelectionAdapter(Context context, ArrayList<T> list) {
// TODO Auto-generated constructor stub
this.mContext = context;
mInflater = LayoutInflater.from(mContext);
mSparseBooleanArray = new SparseBooleanArray();
mList = new ArrayList<T>();
this.mList = list;
}
public ArrayList<T> getCheckedItems() {
ArrayList<T> mTempArry = new ArrayList<T>();
for(int i=0;i<mList.size();i++) {
if(mSparseBooleanArray.get(i)) {
mTempArry.add(mList.get(i));
}
}
return mTempArry;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return mList.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return mList.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup
parent) {
// TODO Auto-generated method stub
if(convertView == null) {
convertView = mInflater.inflate(R.layout.row, null);
}
TextView tvTitle = (TextView) convertView.findViewById(R.id.tvTitle);
tvTitle.setText(mList.get(position).toString());
CheckBox mCheckBox = (CheckBox)
convertView.findViewById(R.id.chkEnable);
mCheckBox.setTag(position);
///mCheckBox.setTag(mList.get(position).toString());
mCheckBox.setChecked(mSparseBooleanArray.get(position));
mCheckBox.setOnCheckedChangeListener(mCheckedChangeListener);
return convertView;
}
OnCheckedChangeListener mCheckedChangeListener = new
OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean
isChecked) {
// TODO Auto-generated method stub
mSparseBooleanArray.put((Integer) buttonView.getTag(), isChecked);
}
};
}
OpenOrders.java
public class OpenOrders {
private String orderID;
private String orderName;
private String itemID;
private String itemName;
public OpenOrders(String orderID, String orderName) {
super();
this.orderID = orderID;
this.orderName = orderName;
}
public String getOrderID() {
return orderID;
}
public void setOrderID(String orderID) {
this.orderID = orderID;
}
public String getOrderName() {
return orderName;
}
public void setOrderName(String orderName) {
this.orderName = orderName;
}
@Override
public String toString() {
return this.orderName;
}
public void OpenOrderItems(String itemID, String itemName) {
this.itemID = itemID;
this.itemName = itemName;
}
public String getItemID() {
return itemID;
}
public void setItemID(String itemID) {
this.itemID = itemID;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
}
My json: { "SERVER_STATUS": "1", "SERVER_RESPONSE": [ {
"MAX_ORDERS_TOBEPICKED":3, "ORDER_ITEM_DETAILS": [ { "ORDERNAME":
"ORDER1", "ORDERID": "1", "ITEMS": [ { "ITEMNUMBER": 1, "ITEMNAME":
"APPLE-LAPTOP", "CATEGORY":"ELECTRONICS", "ORDERQUANTITY": "5",
"PICKEDQUANTITY": "", "PRICE": "4500 DHMS", "SHOPNAME": "Indico Icon Kits
403", "ITEMIMAGEURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg",
"ITEMIMAGEFULLVIEWURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg" }, {
"ITEMNUMBER": 2, "ITEMNAME": "DEL-LAPTOP", "CATEGORY":"ELECTRONICS",
"ORDERQUANTITY": "5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS",
"SHOPNAME": "Indico Icon Kits 403", "ITEMIMAGEURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731094558Victorinox%20Aug%204.JPG",
"ITEMIMAGEFULLVIEWURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731094558Victorinox%20Aug%204.JPG"
}, { "ITEMNUMBER": 3, "ITEMNAME": "FUJI-LAPTOP", "CATEGORY":"ELECTRONICS",
"ORDERQUANTITY": "5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS",
"SHOPNAME": "Indico Icon Kits 403", "ITEMIMAGEURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731122832COLLECTOR-ENSEMBLE-RVB%204.JPG",
"ITEMIMAGEFULLVIEWURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731122832COLLECTOR-ENSEMBLE-RVB%204.JPG"
} ] }, { "ORDERNAME": "ORDER2", "ORDERID": "2", "ITEMS": [ { "ITEMNUMBER":
4, "ITEMNAME": "APPLE-LAPTOP", "CATEGORY":"ELECTRONICS", "ORDERQUANTITY":
"5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS", "SHOPNAME": "Indico Icon
Kits 403", "ITEMIMAGEURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731122312DG_INTENSE_EDP_100ML_conv%204.jpg",
"ITEMIMAGEFULLVIEWURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731122312DG_INTENSE_EDP_100ML_conv%204.jpg"
}, { "ITEMNUMBER": 5, "ITEMNAME": "DEL-LAPTOP", "CATEGORY":"ELECTRONICS",
"ORDERQUANTITY": "5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS",
"SHOPNAME": "Indico Icon Kits 403", "ITEMIMAGEURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731125233Boss%204.JPG",
"ITEMIMAGEFULLVIEWURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731125233Boss%204.JPG"
}, { "ITEMNUMBER": 6, "ITEMNAME": "FUJI-LAPTOP", "CATEGORY":"ELECTRONICS",
"ORDERQUANTITY": "5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS",
"SHOPNAME": "Indico Icon Kits 403", "ITEMIMAGEURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731122312DG_INTENSE_EDP_100ML_conv%204.jpg",
"ITEMIMAGEFULLVIEWURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731122312DG_INTENSE_EDP_100ML_conv%204.jpg"
} ] }, { "ORDERNAME": "ORDER3", "ORDERID": "3", "ITEMS": [ { "ITEMNUMBER":
7, "ITEMNAME": "APPLE-LAPTOP", "CATEGORY":"ELECTRONICS", "ORDERQUANTITY":
"5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS", "SHOPNAME": "Indico Icon
Kits 403", "ITEMIMAGEURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731122312DG_INTENSE_EDP_100ML_conv%204.jpg",
"ITEMIMAGEFULLVIEWURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731122312DG_INTENSE_EDP_100ML_conv%204.jpg"
}, { "ITEMNUMBER": 8, "ITEMNAME": "DEL-LAPTOP", "CATEGORY":"ELECTRONICS",
"ORDERQUANTITY": "5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS",
"SHOPNAME": "Indico Icon Kits 403", "ITEMIMAGEURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731122312DG_INTENSE_EDP_100ML_conv%204.jpg",
"ITEMIMAGEFULLVIEWURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731122312DG_INTENSE_EDP_100ML_conv%204.jpg"
}, { "ITEMNUMBER": 9, "ITEMNAME": "FUJI-LAPTOP", "CATEGORY":"ELECTRONICS",
"ORDERQUANTITY": "5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS",
"SHOPNAME": "Indico Icon Kits 403", "ITEMIMAGEURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg",
"ITEMIMAGEFULLVIEWURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg" } ] }, {
"ORDERNAME": "ORDER4", "ORDERID": "4", "ITEMS": [ { "ITEMNUMBER": 10,
"ITEMNAME": "AsusE-LAPTOP", "CATEGORY":"ELECTRONICS", "ORDERQUANTITY":
"5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS", "SHOPNAME": "Indico Icon
Kits 403", "ITEMIMAGEURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731122312DG_INTENSE_EDP_100ML_conv%204.jpg",
"ITEMIMAGEFULLVIEWURL":
"http://www.dubaidutyfree.com/Content/upload/products/20130731122312DG_INTENSE_EDP_100ML_conv%204.jpg"
}, { "ITEMNUMBER": 11, "ITEMNAME": "hp-LAPTOP", "CATEGORY":"ELECTRONICS",
"ORDERQUANTITY": "5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS",
"SHOPNAME": "Indico Icon Kits 403", "ITEMIMAGEURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg",
"ITEMIMAGEFULLVIEWURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg" }, {
"ITEMNUMBER": 12, "ITEMNAME": "FUJI-LAPTOP", "CATEGORY":"ELECTRONICS",
"ORDERQUANTITY": "5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS",
"SHOPNAME": "Indico Icon Kits 403", "ITEMIMAGEURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg",
"ITEMIMAGEFULLVIEWURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg" } ] }, {
"ORDERNAME": "ORDER5", "ORDERID": "5", "ITEMS": [ { "ITEMNUMBER": 13,
"ITEMNAME": "Asus-k-LAPTOP", "CATEGORY":"ELECTRONICS", "ORDERQUANTITY":
"5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS", "SHOPNAME": "Indico Icon
Kits 403", "ITEMIMAGEURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg",
"ITEMIMAGEFULLVIEWURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg" }, {
"ITEMNUMBER": 14, "ITEMNAME": "wio-LAPTOP", "CATEGORY":"ELECTRONICS",
"ORDERQUANTITY": "5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS",
"SHOPNAME": "Indico Icon Kits 403", "ITEMIMAGEURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg",
"ITEMIMAGEFULLVIEWURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg" }, {
"ITEMNUMBER": 15, "ITEMNAME": "Accer-LAPTOP", "CATEGORY":"ELECTRONICS",
"ORDERQUANTITY": "5", "PICKEDQUANTITY": "", "PRICE": "4500 DHMS",
"ITEMIMAGEURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg",
"ITEMIMAGEFULLVIEWURL":
"http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg" } ] } ] } ],
"ERROR_STATUS": "0", "ERROR_RESPONSE": [ { "ERROR_MESSAGE": "" } ] }
Saturday, 31 August 2013
Algorithm to determine status of a TicTacToe game?
Algorithm to determine status of a TicTacToe game?
I have a program that allows 2 players to play TicTacToe. After each
player makes a move, it should display the board at that point and return
an enumaration called Status that show whether the players should
continue, if a player won, or if it's a draw. However, the algorithm
either return a StackOverflowError, or continues input. Here is the
algorithm I used.
//Checks for winner by rows
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 1; j++) {
if (board[i][j] == 'X') {
if (board[i][j] == board[i][0 + 1] && board[i][j] ==
board[i][0 + 2]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
} else if (board[i][j] == 'O') {
if (board[i][j] == board[i][0 + 1] && board[i][j] ==
board[i][0 + 2]) {
printStatus(2);
return Status.WIN;
} else {
return Status.CONTINUE;
}
}
}
}
//Checks for winner by columns
for (int i = 0; i < 1; i++) {
for (int j = 0; j < 3; j++) {
if (board[i][j] == 'X') {
if (board[i][j] == board[0 + 1][j] && board[i][j] ==
board[0 + 2][j]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
} else if (board[i][j] == 'O') {
if (board[i][j] == board[0 + 1][j] && board[i][j] ==
board[0 + 2][j]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
}
}
}
//This group of if statements boards for winner diagnolly
if (board[0][0] == 'X') {
if (board[0][0] == board[1][1] && board[0][0] == board[2][2]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
}else if (board[0][0] == '0') {
if (board[0][0] == board[1][1] && board[0][0] == board[2][2]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
}
if (board[0][2] == 'O') {
if (board[0][2] == board[1][1] && board[0][2] == board[2][0]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
}else if (board[0][2] == 'X') {
if (board[0][2] == board[1][1] && board[0][2] == board[2][0]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
}
I have a program that allows 2 players to play TicTacToe. After each
player makes a move, it should display the board at that point and return
an enumaration called Status that show whether the players should
continue, if a player won, or if it's a draw. However, the algorithm
either return a StackOverflowError, or continues input. Here is the
algorithm I used.
//Checks for winner by rows
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 1; j++) {
if (board[i][j] == 'X') {
if (board[i][j] == board[i][0 + 1] && board[i][j] ==
board[i][0 + 2]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
} else if (board[i][j] == 'O') {
if (board[i][j] == board[i][0 + 1] && board[i][j] ==
board[i][0 + 2]) {
printStatus(2);
return Status.WIN;
} else {
return Status.CONTINUE;
}
}
}
}
//Checks for winner by columns
for (int i = 0; i < 1; i++) {
for (int j = 0; j < 3; j++) {
if (board[i][j] == 'X') {
if (board[i][j] == board[0 + 1][j] && board[i][j] ==
board[0 + 2][j]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
} else if (board[i][j] == 'O') {
if (board[i][j] == board[0 + 1][j] && board[i][j] ==
board[0 + 2][j]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
}
}
}
//This group of if statements boards for winner diagnolly
if (board[0][0] == 'X') {
if (board[0][0] == board[1][1] && board[0][0] == board[2][2]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
}else if (board[0][0] == '0') {
if (board[0][0] == board[1][1] && board[0][0] == board[2][2]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
}
if (board[0][2] == 'O') {
if (board[0][2] == board[1][1] && board[0][2] == board[2][0]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
}else if (board[0][2] == 'X') {
if (board[0][2] == board[1][1] && board[0][2] == board[2][0]) {
printStatus(1);
return Status.WIN;
} else {
return Status.CONTINUE;
}
}
Is it possible to sort items in FSO with classic asp?
Is it possible to sort items in FSO with classic asp?
Im using the following code on an old IIS machine to generate XML for a
mobile app I have built for android and ios devices... it works, but I am
now wanting to figure out how I would go about SORTING by date last
modified so the list has the NEWEST files at top... my question is, based
on how I have my code structured below,
is this possible with my existing code ( sorting 'x' somehow? )?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Response.ContentType = "text/xml"%>
<%Response.AddHeader "Content-Type","text/xml"%>
<songlist>
<%
dim fs,fo,x
dim i
set fs=Server.CreateObject("Scripting.FileSystemObject")
'point to a specific folder on the server to get files listing from...
set fo=fs.GetFolder(Server.MapPath("./songs"))
i = -1
for each x in fo.files
'loop through all the files found, use var 'i' as a counter for each...
i = i + 1
'only get files where the extension is 'mp3' -- we only want the mp3 files
to show in list...
if right(x,3) = "mp3" then
%>
<song>
<songid><%=i%></songid>
<name><%= replace(replace(x.Name, "-", " "), ".mp3", "")%></name>
<filename><%=x.Name%></filename>
<datemodified><%=x.DateLastModified%></datemodified>
</song>
<%
end if
next
set fo=nothing
set fs=nothing
%>
</songlist>
Im using the following code on an old IIS machine to generate XML for a
mobile app I have built for android and ios devices... it works, but I am
now wanting to figure out how I would go about SORTING by date last
modified so the list has the NEWEST files at top... my question is, based
on how I have my code structured below,
is this possible with my existing code ( sorting 'x' somehow? )?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Response.ContentType = "text/xml"%>
<%Response.AddHeader "Content-Type","text/xml"%>
<songlist>
<%
dim fs,fo,x
dim i
set fs=Server.CreateObject("Scripting.FileSystemObject")
'point to a specific folder on the server to get files listing from...
set fo=fs.GetFolder(Server.MapPath("./songs"))
i = -1
for each x in fo.files
'loop through all the files found, use var 'i' as a counter for each...
i = i + 1
'only get files where the extension is 'mp3' -- we only want the mp3 files
to show in list...
if right(x,3) = "mp3" then
%>
<song>
<songid><%=i%></songid>
<name><%= replace(replace(x.Name, "-", " "), ".mp3", "")%></name>
<filename><%=x.Name%></filename>
<datemodified><%=x.DateLastModified%></datemodified>
</song>
<%
end if
next
set fo=nothing
set fs=nothing
%>
</songlist>
Spring + Hibernate Not able to address issue
Spring + Hibernate Not able to address issue
i am using spring 3.2.4 (latest stable version) with hibernate i have
added all the dependencies but still i am getting the error which is below
java.lang.NoClassDefFoundError:
org/springframework/transaction/interceptor/TransactionInterceptor
if i use maven then i get too many errors like Failed to Autowired (in
both service and DAO),
org.springframework.beans.factory.BeanCreationException:
java.lang.ClassNotFoundException: org.hibernate.cache.CacheProvider
please help me to solve problem for one of above. i want to create an
application (spring + Hibernate) any of way (with maven or without maven)
i am using spring 3.2.4 (latest stable version) with hibernate i have
added all the dependencies but still i am getting the error which is below
java.lang.NoClassDefFoundError:
org/springframework/transaction/interceptor/TransactionInterceptor
if i use maven then i get too many errors like Failed to Autowired (in
both service and DAO),
org.springframework.beans.factory.BeanCreationException:
java.lang.ClassNotFoundException: org.hibernate.cache.CacheProvider
please help me to solve problem for one of above. i want to create an
application (spring + Hibernate) any of way (with maven or without maven)
Declaring array as static won't crash program
Declaring array as static won't crash program
When I initialise array of 1,000,000 integers, program crashes, but when I
put keyword static in front everything works perfectly, why?
int a[1000000] <- crash
static int a[1000000] <- runs correctly
When I initialise array of 1,000,000 integers, program crashes, but when I
put keyword static in front everything works perfectly, why?
int a[1000000] <- crash
static int a[1000000] <- runs correctly
XPath testing dates
XPath testing dates
I've hunted high and low and found some very interesting functionality
with XPATH but, I haven't found a way to test DATES.
I have a Date attribute that I want to use to fetch a collection of nodes.
<History>
<item>
<Name>string</Name>
<Location>string</Location>
<VisitDate>01/08/2013</VisitDate>
<Description>string</Description>
</item>
</History>
The XPath code happily finds an equals, but I need to perform a => test.
Dim doc As New Xml.XmlDocument
doc.Load(filename)
Dim d As Date = DateAdd(DateInterval.Day, -7, Today)
s = "//History/item[VisitDate=>'" & d.ToString("dd/MM/yyyy") & "']"
Dim nodes As Xml.XmlNodeList = doc.SelectNodes(s)
Now this doesn't work. It errors out at the SelectNodes(s), so it
obviously doesn't like the ">" bit.
Are there any "Date" functions in XPath, I've found boolean(); concat();
true(); not true(); translate(); substring() etc, and I'm presuming that
I'm going to eventually have to use a combination of these, and maybe
others, but I can't figure out how to do "greater than"....
Is there anyone out there with an understanding of XPath in this area?
I've hunted high and low and found some very interesting functionality
with XPATH but, I haven't found a way to test DATES.
I have a Date attribute that I want to use to fetch a collection of nodes.
<History>
<item>
<Name>string</Name>
<Location>string</Location>
<VisitDate>01/08/2013</VisitDate>
<Description>string</Description>
</item>
</History>
The XPath code happily finds an equals, but I need to perform a => test.
Dim doc As New Xml.XmlDocument
doc.Load(filename)
Dim d As Date = DateAdd(DateInterval.Day, -7, Today)
s = "//History/item[VisitDate=>'" & d.ToString("dd/MM/yyyy") & "']"
Dim nodes As Xml.XmlNodeList = doc.SelectNodes(s)
Now this doesn't work. It errors out at the SelectNodes(s), so it
obviously doesn't like the ">" bit.
Are there any "Date" functions in XPath, I've found boolean(); concat();
true(); not true(); translate(); substring() etc, and I'm presuming that
I'm going to eventually have to use a combination of these, and maybe
others, but I can't figure out how to do "greater than"....
Is there anyone out there with an understanding of XPath in this area?
What does s.equals("") mean in Java? [on hold]
What does s.equals("") mean in Java? [on hold]
Here is the full code I saw and I am trying to wrap my head around it:
for (i = 0; i < s.length - 1; i++) {
if (s.charAt(i - 1) == b && s.charAt(i) != a) {
return false;
}
}
return !s.endsWith(String.valueOf(b));
Could anyone explain?
Here is the full code I saw and I am trying to wrap my head around it:
for (i = 0; i < s.length - 1; i++) {
if (s.charAt(i - 1) == b && s.charAt(i) != a) {
return false;
}
}
return !s.endsWith(String.valueOf(b));
Could anyone explain?
Mozilla Add-on: Google Translator returns null
Mozilla Add-on: Google Translator returns null
I just started to build Mozilla add-ons, and I am trying to run the
example (Google Translate & replace the selected text) shown in the
official introduction video. But it is failing with "TypeError:
response.json.responseData is null". Can anyone help me to fix the
"Translator" code. I tried the code in both Add-on SDK and Add-on Builder.
Link to the tutorial video:
https://addons.mozilla.org/en-US/developers/builder
Regards, Mohan
I just started to build Mozilla add-ons, and I am trying to run the
example (Google Translate & replace the selected text) shown in the
official introduction video. But it is failing with "TypeError:
response.json.responseData is null". Can anyone help me to fix the
"Translator" code. I tried the code in both Add-on SDK and Add-on Builder.
Link to the tutorial video:
https://addons.mozilla.org/en-US/developers/builder
Regards, Mohan
Friday, 30 August 2013
li element not rendering 10 times
li element not rendering 10 times
I have declared an li element as global and tried to push the same in
array. Later I appended the same in ul but only once li item got displayed
instead of displaying it 10 times.
var items = [], ele = $("<li>brad</li>");
for(var i=0; i<10; i++) {
items.push(ele);
}
$("#myId").append(items);
But if the li element is declared within loop as below:
for(var i=0; i<10; i++) {
ele = $("<li>brad</li>")
items.push(ele);
}
It displayed li 10 times. I couldn't figure out the reason for that. Why?
I have declared an li element as global and tried to push the same in
array. Later I appended the same in ul but only once li item got displayed
instead of displaying it 10 times.
var items = [], ele = $("<li>brad</li>");
for(var i=0; i<10; i++) {
items.push(ele);
}
$("#myId").append(items);
But if the li element is declared within loop as below:
for(var i=0; i<10; i++) {
ele = $("<li>brad</li>")
items.push(ele);
}
It displayed li 10 times. I couldn't figure out the reason for that. Why?
Thursday, 29 August 2013
xslt merge multiple nodes with same name
xslt merge multiple nodes with same name
I can see many answers to similar questions, but I can't seem to get them
work for me. I have some xml files with some sibling element nodes having
same tag name. I want to merge these nodes using XSLT. Any help would be
deeply appreciated.
Input:
<?xml version="1.0"?>
<Screen>
<Shapes>
<Triangle id="tri1">
<color>red</color>
<size>large</size>
</Triangle>
</Shapes>
<Shapes>
<Rectangle id="rec1">
<color>blue</color>
<size>medium</size>
</Rectangle>
</Shapes>
<Shapes>
<Circle id="cir1">
<color>green</color>
<size>small</size>
</Circle>
</Shapes>
<Shapes>
<Square id="sqr1">
<color>yellow</color>
<size>large</size>
</Square>
</Shapes>
<Device>
<Name>peg</Name>
<type>X11</type>
</Device>
<Utilities>
<Software>QT</Software>
<Platform>Linux</Platform>
</Utilities>
</Screen>
I want to merge all "Shapes" nodes. Required Output
<?xml version="1.0"?>
<Screen>
<Shapes>
<Triangle id="tri1">
<color>red</color>
<size>large</size>
</Triangle>
<Rectangle id="rec1">
<color>blue</color>
<size>medium</size>
</Rectangle>
<Circle id="cir1">
<color>green</color>
<size>small</size>
</Circle>
<Square id="sqr1">
<color>yellow</color>
<size>large</size>
</Square>
</Shapes>
<Device>
<Name>peg</Name>
<type>X11</type>
</Device>
<Utilities>
<Software>QT</Software>
<Platform>Linux</Platform>
</Utilities>
</Screen>
XSLT I tried was:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes" />
<xsl:template match="Shapes">
<xsl:if test="not(preceding-sibling::*[local-name() = 'Shapes'])">
<Shapes>
<xsl:apply-templates select="node() | @*" />
<xsl:apply-templates select="following-sibling::*[local-name() =
'Shapes']" />
</Shapes>
</xsl:if>
<xsl:if test="preceding-sibling::*[local-name() = 'Shapes']">
<xsl:apply-templates select="node() | @*" />
</xsl:if>
</xsl:template>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
But the output I got was ( :( )
<Screen>
<Shapes>
<Triangle id="tri1">
<color>red</color>
<size>large</size>
</Triangle>
<Rectangle id="rec1">
<color>blue</color>
<size>medium</size>
</Rectangle>
<Circle id="cir1">
<color>green</color>
<size>small</size>
</Circle>
<Square id="sqr1">
<color>yellow</color>
<size>large</size>
</Square>
</Shapes>
<Rectangle id="rec1">
<color>blue</color>
<size>medium</size>
</Rectangle>
<Circle id="cir1">
<color>green</color>
<size>small</size>
</Circle>
<Square id="sqr1">
<color>yellow</color>
<size>large</size>
</Square>
<Device>
<Name>peg</Name>
<type>X11</type>
</Device>
<Utilities>
<Software>QT</Software>
<Platform>Linux</Platform>
</Utilities>
</Screen>
Is there a simple XSLT code I can use, or is there any modification in my
xslt I can apply to get the output?
I can see many answers to similar questions, but I can't seem to get them
work for me. I have some xml files with some sibling element nodes having
same tag name. I want to merge these nodes using XSLT. Any help would be
deeply appreciated.
Input:
<?xml version="1.0"?>
<Screen>
<Shapes>
<Triangle id="tri1">
<color>red</color>
<size>large</size>
</Triangle>
</Shapes>
<Shapes>
<Rectangle id="rec1">
<color>blue</color>
<size>medium</size>
</Rectangle>
</Shapes>
<Shapes>
<Circle id="cir1">
<color>green</color>
<size>small</size>
</Circle>
</Shapes>
<Shapes>
<Square id="sqr1">
<color>yellow</color>
<size>large</size>
</Square>
</Shapes>
<Device>
<Name>peg</Name>
<type>X11</type>
</Device>
<Utilities>
<Software>QT</Software>
<Platform>Linux</Platform>
</Utilities>
</Screen>
I want to merge all "Shapes" nodes. Required Output
<?xml version="1.0"?>
<Screen>
<Shapes>
<Triangle id="tri1">
<color>red</color>
<size>large</size>
</Triangle>
<Rectangle id="rec1">
<color>blue</color>
<size>medium</size>
</Rectangle>
<Circle id="cir1">
<color>green</color>
<size>small</size>
</Circle>
<Square id="sqr1">
<color>yellow</color>
<size>large</size>
</Square>
</Shapes>
<Device>
<Name>peg</Name>
<type>X11</type>
</Device>
<Utilities>
<Software>QT</Software>
<Platform>Linux</Platform>
</Utilities>
</Screen>
XSLT I tried was:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes" />
<xsl:template match="Shapes">
<xsl:if test="not(preceding-sibling::*[local-name() = 'Shapes'])">
<Shapes>
<xsl:apply-templates select="node() | @*" />
<xsl:apply-templates select="following-sibling::*[local-name() =
'Shapes']" />
</Shapes>
</xsl:if>
<xsl:if test="preceding-sibling::*[local-name() = 'Shapes']">
<xsl:apply-templates select="node() | @*" />
</xsl:if>
</xsl:template>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
But the output I got was ( :( )
<Screen>
<Shapes>
<Triangle id="tri1">
<color>red</color>
<size>large</size>
</Triangle>
<Rectangle id="rec1">
<color>blue</color>
<size>medium</size>
</Rectangle>
<Circle id="cir1">
<color>green</color>
<size>small</size>
</Circle>
<Square id="sqr1">
<color>yellow</color>
<size>large</size>
</Square>
</Shapes>
<Rectangle id="rec1">
<color>blue</color>
<size>medium</size>
</Rectangle>
<Circle id="cir1">
<color>green</color>
<size>small</size>
</Circle>
<Square id="sqr1">
<color>yellow</color>
<size>large</size>
</Square>
<Device>
<Name>peg</Name>
<type>X11</type>
</Device>
<Utilities>
<Software>QT</Software>
<Platform>Linux</Platform>
</Utilities>
</Screen>
Is there a simple XSLT code I can use, or is there any modification in my
xslt I can apply to get the output?
Row inside bootstrap collapse
Row inside bootstrap collapse
I'm using Bootstrap 2.3.2 for a website which contains an accordion
element with one row within it. Accordion is span6 and I expected that the
row will be able to contain two span3 elements but it can't. Here is my
code simplified:
<div class="span6">
<div class="accordion" id="accordion2">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse"
data-parent="#accordion2" href="#collapseOne">
<p><h3>Some text here</h3></p>
</a>
</div>
<div id="collapseOne" class="accordion-body collapse">
<div class="accordion-inner">
<div class="row">
<br />
<div class="span3 offer">
<div class="offer-wrap">
This one should be on the left
</div>
</div>
<div class="span3 offer">
<div class="offer-wrap">
This one should be on the right, but is BELOW
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I was able to make them appear next to each other, but only with some
nasty CSS fiddling, which only works on my screen size.
If I put that row outside of accordion element everything looks perfect.
I'm using Bootstrap 2.3.2 for a website which contains an accordion
element with one row within it. Accordion is span6 and I expected that the
row will be able to contain two span3 elements but it can't. Here is my
code simplified:
<div class="span6">
<div class="accordion" id="accordion2">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse"
data-parent="#accordion2" href="#collapseOne">
<p><h3>Some text here</h3></p>
</a>
</div>
<div id="collapseOne" class="accordion-body collapse">
<div class="accordion-inner">
<div class="row">
<br />
<div class="span3 offer">
<div class="offer-wrap">
This one should be on the left
</div>
</div>
<div class="span3 offer">
<div class="offer-wrap">
This one should be on the right, but is BELOW
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I was able to make them appear next to each other, but only with some
nasty CSS fiddling, which only works on my screen size.
If I put that row outside of accordion element everything looks perfect.
Wednesday, 28 August 2013
Search in a .txt file, compare output and retrieve answer in collor botton and text
Search in a .txt file, compare output and retrieve answer in collor botton
and text
Good afternoon,
I am trying to write and application to, using a txt file as data base,
compare results from the database to the ones inserted by the user
as an example.
The content of the text file would be:
Name Number Version Comment
Test1 001 1 Hello
Test1 001 2 Hello To all
Test2 002 1 Hi
Introducing the 001 and 1 on the program, it should pop you a red screen
with a small comment like "incorrect". introducing the 001 2 it should pop
a green screen, with a comment like OK.
Any idea in how to do it? Thanks in advance
and text
Good afternoon,
I am trying to write and application to, using a txt file as data base,
compare results from the database to the ones inserted by the user
as an example.
The content of the text file would be:
Name Number Version Comment
Test1 001 1 Hello
Test1 001 2 Hello To all
Test2 002 1 Hi
Introducing the 001 and 1 on the program, it should pop you a red screen
with a small comment like "incorrect". introducing the 001 2 it should pop
a green screen, with a comment like OK.
Any idea in how to do it? Thanks in advance
Correct approach event counting
Correct approach event counting
I want to list users which have a particular event count but I'm confused
on which approach to take.
This is the database table:
CREATE TABLE `event` (
`event_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`visitor_id` int(11) DEFAULT NULL,
`key` varchar(200) DEFAULT NULL,
`value` text,
`label` varchar(200) DEFAULT '',
`datetime` datetime DEFAULT NULL,
PRIMARY KEY (`event_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
INSERT INTO `event` (`event_id`, `visitor_id`, `key`, `value`, `label`,
`datetime`)
VALUES
(1, 1, 'LOGIN', NULL, '', NULL),
(2, 2, 'LOGIN', NULL, '', NULL),
(3, 1, 'VIEW_PAGE', 'HOTEL', '', NULL),
(4, 2, 'VIEW_PAGE', 'HOTEL', '', NULL),
(5, 1, 'PURCHASE_HOTEL', NULL, '', NULL);
CREATE TABLE `visitor` (
`visitor_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`datetime` datetime DEFAULT NULL,
PRIMARY KEY (`visitor_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
INSERT INTO `visitor` (`visitor_id`, `datetime`)
VALUES
(1, NULL),
(2, NULL);
and this is my approach:
SELECT DISTINCT
t1.`visitor_id`
FROM
`visitor` t1
JOIN `event` t2 on t1.visitor_id = t2.visitor_id AND t2.`key` = 'LOGIN'
JOIN `event` t3 on t1.visitor_id = t3.visitor_id AND t3.`key` =
'VIEW_PAGE' AND t3.`value` = 'HOTEL'
WHERE ( SELECT COUNT(*) FROM `event` WHERE `event`.`key` =
'PURCHASE_HOTEL' ) > 0
this should only list visitor 1 but it does actually list visitor 2 too
which does not have the PURCHASE_HOTEL event.
As you can imagine, there will be more "rules" like all the JOIN events
for each particular case. Can we correct and improve this somehow?
BONUS: What is the name of this approach?
I want to list users which have a particular event count but I'm confused
on which approach to take.
This is the database table:
CREATE TABLE `event` (
`event_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`visitor_id` int(11) DEFAULT NULL,
`key` varchar(200) DEFAULT NULL,
`value` text,
`label` varchar(200) DEFAULT '',
`datetime` datetime DEFAULT NULL,
PRIMARY KEY (`event_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
INSERT INTO `event` (`event_id`, `visitor_id`, `key`, `value`, `label`,
`datetime`)
VALUES
(1, 1, 'LOGIN', NULL, '', NULL),
(2, 2, 'LOGIN', NULL, '', NULL),
(3, 1, 'VIEW_PAGE', 'HOTEL', '', NULL),
(4, 2, 'VIEW_PAGE', 'HOTEL', '', NULL),
(5, 1, 'PURCHASE_HOTEL', NULL, '', NULL);
CREATE TABLE `visitor` (
`visitor_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`datetime` datetime DEFAULT NULL,
PRIMARY KEY (`visitor_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
INSERT INTO `visitor` (`visitor_id`, `datetime`)
VALUES
(1, NULL),
(2, NULL);
and this is my approach:
SELECT DISTINCT
t1.`visitor_id`
FROM
`visitor` t1
JOIN `event` t2 on t1.visitor_id = t2.visitor_id AND t2.`key` = 'LOGIN'
JOIN `event` t3 on t1.visitor_id = t3.visitor_id AND t3.`key` =
'VIEW_PAGE' AND t3.`value` = 'HOTEL'
WHERE ( SELECT COUNT(*) FROM `event` WHERE `event`.`key` =
'PURCHASE_HOTEL' ) > 0
this should only list visitor 1 but it does actually list visitor 2 too
which does not have the PURCHASE_HOTEL event.
As you can imagine, there will be more "rules" like all the JOIN events
for each particular case. Can we correct and improve this somehow?
BONUS: What is the name of this approach?
Windows 7 : Stop showing tooltip when hovering oppened applications on taskbar and instantly show thumbnails preview
Windows 7 : Stop showing tooltip when hovering oppened applications on
taskbar and instantly show thumbnails preview
I'm having a hard time figuring out somethihng on windows 7. I would like
to disable the useless tooltip from showing on my taskbar application
icons once i hover my mouse on them and instead i would like to instantly
show thumbnail previews.
I have set the registery key for MouseHoverDelay to 0 (for instant
thumbnail) already but it only shows the thumbnail preview instantly after
showing the useless tooltip popup. My guess is that the tooltip is
blocking the thumbnail preview from showing up as fast as i want. Also the
tooltip takes about 2 seconds to show up and that's pretty frustrating.
Either disable the tooltip from the taskbar or the tooltip not preventing
the thumbnails preview would be perfect.
Many thanks.
EDIT : Been a while now. Anybody knows any clue?
taskbar and instantly show thumbnails preview
I'm having a hard time figuring out somethihng on windows 7. I would like
to disable the useless tooltip from showing on my taskbar application
icons once i hover my mouse on them and instead i would like to instantly
show thumbnail previews.
I have set the registery key for MouseHoverDelay to 0 (for instant
thumbnail) already but it only shows the thumbnail preview instantly after
showing the useless tooltip popup. My guess is that the tooltip is
blocking the thumbnail preview from showing up as fast as i want. Also the
tooltip takes about 2 seconds to show up and that's pretty frustrating.
Either disable the tooltip from the taskbar or the tooltip not preventing
the thumbnails preview would be perfect.
Many thanks.
EDIT : Been a while now. Anybody knows any clue?
Tuesday, 27 August 2013
conversion between list of objects and Gson string
conversion between list of objects and Gson string
I'm converting a list of objects to json string and then back to list of
objects as below:
List<Work> list = new ArrayList<Work>();
Work w1 = new Work();
Work w2 = new Work();
list.add(w1);
list.add(w2);
String str = GsonUtils.getJsonString(list);
Type listType = new TypeToken<ArrayList<Work>>() {
}.getType();
List<Work> list1 = new Gson().fromJson(str, listType);
this works completely fine and returns the list List<Work>.
Now I'm doing same by extracting a method as below:
List<Work> list = new ArrayList<Work>();
Work w1 = new Work();
Work w2 = new Work();
list.add(w1);
list.add(w2);
String str = GsonUtils.getJsonString(list);
Type listType = new TypeToken<ArrayList<Work>>() {
}.getType();
List<Work> list1 = getListFromJSON(str, Work.class);
where method is defined as below:
public <T> List<T> getListFromJSON(String str, Class<T> type) {
Type listType = new TypeToken<ArrayList<T>>() {
}.getType();
List<T> list = new Gson().fromJson(str, listType);
return list;
}
this time it's resulting into an error:
Exception in thread "main" java.lang.ClassCastException:
com.google.gson.internal.StringMap cannot be cast to
com.restfb.types.User$Work
at expt.ExptGsonList.main(ExptGsonList.java:45)
Please help me to know where am I going wrong and how can I get this
working using method?
I'm converting a list of objects to json string and then back to list of
objects as below:
List<Work> list = new ArrayList<Work>();
Work w1 = new Work();
Work w2 = new Work();
list.add(w1);
list.add(w2);
String str = GsonUtils.getJsonString(list);
Type listType = new TypeToken<ArrayList<Work>>() {
}.getType();
List<Work> list1 = new Gson().fromJson(str, listType);
this works completely fine and returns the list List<Work>.
Now I'm doing same by extracting a method as below:
List<Work> list = new ArrayList<Work>();
Work w1 = new Work();
Work w2 = new Work();
list.add(w1);
list.add(w2);
String str = GsonUtils.getJsonString(list);
Type listType = new TypeToken<ArrayList<Work>>() {
}.getType();
List<Work> list1 = getListFromJSON(str, Work.class);
where method is defined as below:
public <T> List<T> getListFromJSON(String str, Class<T> type) {
Type listType = new TypeToken<ArrayList<T>>() {
}.getType();
List<T> list = new Gson().fromJson(str, listType);
return list;
}
this time it's resulting into an error:
Exception in thread "main" java.lang.ClassCastException:
com.google.gson.internal.StringMap cannot be cast to
com.restfb.types.User$Work
at expt.ExptGsonList.main(ExptGsonList.java:45)
Please help me to know where am I going wrong and how can I get this
working using method?
T-SQL TRY-CATCH not working in DDL trigger
T-SQL TRY-CATCH not working in DDL trigger
I have a DDL trigger to audit any changes to DDL events that occur on the
server.
The code in the trigger reads the eventdata and writes it to a table.
I want to wrap that operation in a TSQL try-catch so if it fails for any
reason then I would log the fault to the SQL log but let the operation go
through, but it doesn't seem to work. I am already using if exists to make
sure the table I need to write to still exists, but I want to trap any
unforseen errors and make the trigger as robust as possible.
DDL triggers seem to work differently than normal T-SQL and doesn't seem
to honour the TRY-CATCH block.
The following code works fine if it is in an SP but it doesn't work if it
is in a DDL trigger.
BEGIN TRY
-- Simulate an error
RAISERROR ('Just a test!', 14, 1);
END TRY
BEGIN CATCH
DECLARE @errorNumber int = ERROR_NUMBER()
DECLARE @errorMessage NVARCHAR(2048) = ERROR_MESSAGE() + '(' +
CAST(ERROR_NUMBER() AS NVARCHAR) + ')'
-- Log the error to the SQL server event log
EXEC master..xp_logevent 50005, @errorMessage, WARNING
END CATCH;
Any ideas?
I have a DDL trigger to audit any changes to DDL events that occur on the
server.
The code in the trigger reads the eventdata and writes it to a table.
I want to wrap that operation in a TSQL try-catch so if it fails for any
reason then I would log the fault to the SQL log but let the operation go
through, but it doesn't seem to work. I am already using if exists to make
sure the table I need to write to still exists, but I want to trap any
unforseen errors and make the trigger as robust as possible.
DDL triggers seem to work differently than normal T-SQL and doesn't seem
to honour the TRY-CATCH block.
The following code works fine if it is in an SP but it doesn't work if it
is in a DDL trigger.
BEGIN TRY
-- Simulate an error
RAISERROR ('Just a test!', 14, 1);
END TRY
BEGIN CATCH
DECLARE @errorNumber int = ERROR_NUMBER()
DECLARE @errorMessage NVARCHAR(2048) = ERROR_MESSAGE() + '(' +
CAST(ERROR_NUMBER() AS NVARCHAR) + ')'
-- Log the error to the SQL server event log
EXEC master..xp_logevent 50005, @errorMessage, WARNING
END CATCH;
Any ideas?
High performing Bitmap Drawing solution in c#
High performing Bitmap Drawing solution in c#
I have a use case where I need to render a collage of bitmaps as a
preview. The application is implemented as a MVC based REST service, and I
have a fairly vanilla implementation:
using (var bitmap = new Bitmap((int)maxWidth, (int)maxHeight))
{
using (var graphic = Graphics.FromImage(bitmap))
{
graphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
// now again for each mod
foreach (var mod in mods)
{
var frame = frames.First(f => f.Index == mod.FrameIndex);
var fileInfo = GetFileInfo(mod);
using (var modImage = Image.FromFile(fileInfo.FullName))
{
graphic.DrawImage(modImage, (int)frame.Left, (int)frame.Top);
}
}
bitmap.Save(previewFileName);
}
}
While this code works fine, it performs very poorly (especially with
larger images). I am open to using third party libraries as well, I just
need a faster performing solution.
Any help would be mostly appreciated.
I have a use case where I need to render a collage of bitmaps as a
preview. The application is implemented as a MVC based REST service, and I
have a fairly vanilla implementation:
using (var bitmap = new Bitmap((int)maxWidth, (int)maxHeight))
{
using (var graphic = Graphics.FromImage(bitmap))
{
graphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
// now again for each mod
foreach (var mod in mods)
{
var frame = frames.First(f => f.Index == mod.FrameIndex);
var fileInfo = GetFileInfo(mod);
using (var modImage = Image.FromFile(fileInfo.FullName))
{
graphic.DrawImage(modImage, (int)frame.Left, (int)frame.Top);
}
}
bitmap.Save(previewFileName);
}
}
While this code works fine, it performs very poorly (especially with
larger images). I am open to using third party libraries as well, I just
need a faster performing solution.
Any help would be mostly appreciated.
AFNetworking AFHTTPClient AFJSONRequestOperation not using JSON Operation
AFNetworking AFHTTPClient AFJSONRequestOperation not using JSON Operation
I followed this Screencast... http://nsscreencast.com/episodes/6-afnetworking
My singleton AFHTTPClient code is...
+ (MyClient *)sharedInstance
{
static dispatch_once_t once;
static MyClient *myClient;
dispatch_once(&once, ^ { myClient = [[MyClient alloc]
initWithBaseURL:[NSURL URLWithString:MyBaseURL]];});
return myClient;
}
- (id)initWithBaseURL:(NSURL *)url
{
self = [super initWithBaseURL:url];
if (self) {
// these are not actual values but I am setting default headers.
[self setDefaultHeader:@"sdfg" value:@"4"];
[self setDefaultHeader:@"std" value:@"3"];
[self setDefaultHeader:@"reg" value:@"5"];
[self setDefaultHeader:@"yu" value:@"1"];
[self setDefaultHeader:@"xv" value:@"3"];
[self setDefaultHeader:@"hmm" value:@"5"];
[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
}
return self;
}
Then I'm executing it like...
[[MyClient sharedInstance] getPath:@"blah.php" parameters:parameters
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSMutableArray *stats = [NSMutableArray array];
// it crashes on the next line because responseObject is NSData
for (NSDictionary *dictionary in responseObject) {
CCStatistic *stat = [[CCStatistic alloc]
initWithDictionary:dictionary];
[stats addObject:stat];
}
self.stats = stats;
[self.tableView reloadData];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error retrieving!");
NSLog(@"%@", error);
}];
It all works fine. I've intercepted it with Charles and it is sending the
correct request and receiving the correct JSON except the operation is not
a JSON operation.
So the responseObject is NSData not the JSON object that I was expecting.
An I missing any config to use the JSON operation?
I followed this Screencast... http://nsscreencast.com/episodes/6-afnetworking
My singleton AFHTTPClient code is...
+ (MyClient *)sharedInstance
{
static dispatch_once_t once;
static MyClient *myClient;
dispatch_once(&once, ^ { myClient = [[MyClient alloc]
initWithBaseURL:[NSURL URLWithString:MyBaseURL]];});
return myClient;
}
- (id)initWithBaseURL:(NSURL *)url
{
self = [super initWithBaseURL:url];
if (self) {
// these are not actual values but I am setting default headers.
[self setDefaultHeader:@"sdfg" value:@"4"];
[self setDefaultHeader:@"std" value:@"3"];
[self setDefaultHeader:@"reg" value:@"5"];
[self setDefaultHeader:@"yu" value:@"1"];
[self setDefaultHeader:@"xv" value:@"3"];
[self setDefaultHeader:@"hmm" value:@"5"];
[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
}
return self;
}
Then I'm executing it like...
[[MyClient sharedInstance] getPath:@"blah.php" parameters:parameters
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSMutableArray *stats = [NSMutableArray array];
// it crashes on the next line because responseObject is NSData
for (NSDictionary *dictionary in responseObject) {
CCStatistic *stat = [[CCStatistic alloc]
initWithDictionary:dictionary];
[stats addObject:stat];
}
self.stats = stats;
[self.tableView reloadData];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error retrieving!");
NSLog(@"%@", error);
}];
It all works fine. I've intercepted it with Charles and it is sending the
correct request and receiving the correct JSON except the operation is not
a JSON operation.
So the responseObject is NSData not the JSON object that I was expecting.
An I missing any config to use the JSON operation?
Cleaning up a text file with a variety of CR and LF line breaks
Cleaning up a text file with a variety of CR and LF line breaks
I'm trying to import into mySQL a text file containing memos. I don't know
how they managed to do this, but while the memo field is consistently
terminated by CR LF, parts of the text itself contains a mixture of CR,
LF, and CR LF line breaks as well.
Naturally this breaks my ability to import it, as there is no clear
indication of what constitutes a line break. Roughly half the data is lost
during import, and 25% of what made the cut ends up truncated.
Is there any feasible way of sorting this mess out? It was originally
exported from Access.
Thanks!
I'm trying to import into mySQL a text file containing memos. I don't know
how they managed to do this, but while the memo field is consistently
terminated by CR LF, parts of the text itself contains a mixture of CR,
LF, and CR LF line breaks as well.
Naturally this breaks my ability to import it, as there is no clear
indication of what constitutes a line break. Roughly half the data is lost
during import, and 25% of what made the cut ends up truncated.
Is there any feasible way of sorting this mess out? It was originally
exported from Access.
Thanks!
Android Mobile - Jelly Bean 4 will not show the drop-down boxes arrow icon
Android Mobile - Jelly Bean 4 will not show the drop-down boxes arrow icon
I have tested three different Android Devices running the OS Jelly Bean 4.
Two of the devices had 4.3 and the other had 4.1.
When looking at a drop-down-box on any website through these devices the
drop down arrow icon is not displayed. The box looks like an ordinary
input box with no indication the user can select options from it.
Androids older OS Ginger Bread shows the drop-down-menu as intended.
Does anybody know why Jelly Bean has this problem and if there a fix?
Thanks :)
I have tested three different Android Devices running the OS Jelly Bean 4.
Two of the devices had 4.3 and the other had 4.1.
When looking at a drop-down-box on any website through these devices the
drop down arrow icon is not displayed. The box looks like an ordinary
input box with no indication the user can select options from it.
Androids older OS Ginger Bread shows the drop-down-menu as intended.
Does anybody know why Jelly Bean has this problem and if there a fix?
Thanks :)
Monday, 26 August 2013
How can I toggle the Windows 8 Surface Pro's trackpad?
How can I toggle the Windows 8 Surface Pro's trackpad?
Earlier this year, anyone wishing to disable or toggle the Trackpad on the
Surface's keyboard could download the Trackpad Settings app. However, it
seems that this app is no longer available on the Windows Store (even
though that store page is still quite visible). My search for a
replacement has been fruitless, and even the Surface help docs still refer
to this app.
So... given this situation, how can I toggle my Surface's trackpad?
Just to show it really appears to be gone...
Some search results
... and the store page for that one result.
Earlier this year, anyone wishing to disable or toggle the Trackpad on the
Surface's keyboard could download the Trackpad Settings app. However, it
seems that this app is no longer available on the Windows Store (even
though that store page is still quite visible). My search for a
replacement has been fruitless, and even the Surface help docs still refer
to this app.
So... given this situation, how can I toggle my Surface's trackpad?
Just to show it really appears to be gone...
Some search results
... and the store page for that one result.
Strange sound issues with Asus Xonar Essence One
Strange sound issues with Asus Xonar Essence One
I am running Ubuntu 13.04 and I am using Asus Xonar Essence One as my
sound card. Alsamixer sees the card, but can not control volume - doesn't
recognise any outputs. PulseAudio driver worked out of the box, but
behaves in a most strange way.
First of all, PulseAudio sees two outputs for some reason: "Analog Output"
and "Digital Output (S/PDIF)". It makes no difference which one I choose -
both work, but are behaving strangely.
Now the main problem starts here: sound usually works fine as I start
Ubuntu, but then if I start a video (youtube and other web players,vlc) or
start a skype/mumble call, or start any program at all, there is a random
chance of sound slowing down or speeding up (so the sound becomes way too
deep or way too high pitched, with occasional stutter). This happens
especially often in vlc as I watch 720p/1080p videos. Even pausing and
then resuming can often cause the sound to speed up or slow down. I would
also like to add that system volume always resets to 100% every time I
start Ubuntu.
I am wondering if anyone can help me as I have googled and have not found
a single person with a similar problem.
I am running Ubuntu 13.04 and I am using Asus Xonar Essence One as my
sound card. Alsamixer sees the card, but can not control volume - doesn't
recognise any outputs. PulseAudio driver worked out of the box, but
behaves in a most strange way.
First of all, PulseAudio sees two outputs for some reason: "Analog Output"
and "Digital Output (S/PDIF)". It makes no difference which one I choose -
both work, but are behaving strangely.
Now the main problem starts here: sound usually works fine as I start
Ubuntu, but then if I start a video (youtube and other web players,vlc) or
start a skype/mumble call, or start any program at all, there is a random
chance of sound slowing down or speeding up (so the sound becomes way too
deep or way too high pitched, with occasional stutter). This happens
especially often in vlc as I watch 720p/1080p videos. Even pausing and
then resuming can often cause the sound to speed up or slow down. I would
also like to add that system volume always resets to 100% every time I
start Ubuntu.
I am wondering if anyone can help me as I have googled and have not found
a single person with a similar problem.
IBM gxt4500p with CentOS
IBM gxt4500p with CentOS
I have the following card installed in a DELL Poweredge server, is it
possible to make it work with linux?
I am using CEntOS 6.
The card is an IBM gxt4500p originally made for AIX, but I see the driver
should be inside the kernel.
lspci sees it.
Do I have to configure Xorg? I need it only for the DVI connection. Thanks
I have the following card installed in a DELL Poweredge server, is it
possible to make it work with linux?
I am using CEntOS 6.
The card is an IBM gxt4500p originally made for AIX, but I see the driver
should be inside the kernel.
lspci sees it.
Do I have to configure Xorg? I need it only for the DVI connection. Thanks
Form submit event is not capturing OnSelectedIndexChanged?
Form submit event is not capturing OnSelectedIndexChanged?
I have a button and a dropdownlst
And I have this script :
$("form").submit(function (e)
{
$('#divOverlay').show();
});
My Goal :
When a form submits , I need to show a "loading div" :
Question :
When I press the button it does show me the div (the gray div which blinks
for a second):
But when I change index on the dropdownlist :
<asp:DropDownList runat="server"
OnSelectedIndexChanged="OnSelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Value="a"> a</asp:ListItem>
<asp:ListItem Value="b">b</asp:ListItem>
</asp:DropDownList>
It does submit bUt I dont see the div :
Why does the $("form").submit(function (e) does not capture this postback
which occurs after selected index change ? ?
NB :
Fiddler shows both events (pressing the button && changing index) as a
POST command
I have a button and a dropdownlst
And I have this script :
$("form").submit(function (e)
{
$('#divOverlay').show();
});
My Goal :
When a form submits , I need to show a "loading div" :
Question :
When I press the button it does show me the div (the gray div which blinks
for a second):
But when I change index on the dropdownlist :
<asp:DropDownList runat="server"
OnSelectedIndexChanged="OnSelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Value="a"> a</asp:ListItem>
<asp:ListItem Value="b">b</asp:ListItem>
</asp:DropDownList>
It does submit bUt I dont see the div :
Why does the $("form").submit(function (e) does not capture this postback
which occurs after selected index change ? ?
NB :
Fiddler shows both events (pressing the button && changing index) as a
POST command
Are there any databases of Android services/applications & their respective descriptions?
Are there any databases of Android services/applications & their
respective descriptions?
When I'm attempting to clean up my phone's unused files and applications,
I run into a lot of cryptic items that I have no idea what their purpose
is.
For example, on my Samsung Stellar running Android version 4.1.2, there
are some items in the Application Manager that say:
ChocoEUKor
CSC
Hely Neue S
QoSSig
TwDVFSApp
I can't find any good databases, websites, or any other resources that
provide information about these "applications/services" that allow people
to search for data relevant to each item for their specific phone model.
I find it hard to believe that this information isn't already out there,
but maybe I'm not looking hard enough or have been looking in all the
wrong places.
Does anyone know if and where this information exists?
Thanks
respective descriptions?
When I'm attempting to clean up my phone's unused files and applications,
I run into a lot of cryptic items that I have no idea what their purpose
is.
For example, on my Samsung Stellar running Android version 4.1.2, there
are some items in the Application Manager that say:
ChocoEUKor
CSC
Hely Neue S
QoSSig
TwDVFSApp
I can't find any good databases, websites, or any other resources that
provide information about these "applications/services" that allow people
to search for data relevant to each item for their specific phone model.
I find it hard to believe that this information isn't already out there,
but maybe I'm not looking hard enough or have been looking in all the
wrong places.
Does anyone know if and where this information exists?
Thanks
Sunday, 25 August 2013
Redirect user if record doenst exist in database
Redirect user if record doenst exist in database
I'm working on a small php script which call records from databse. I'm
using this code : ` mysql_query("select * from kalimat where cat=$id order
by id");
` I want to redirect user to 404 error page if the cat id doesnt exist in
the database !
I'm working on a small php script which call records from databse. I'm
using this code : ` mysql_query("select * from kalimat where cat=$id order
by id");
` I want to redirect user to 404 error page if the cat id doesnt exist in
the database !
how to read XML id's with value and update it by PHP
how to read XML id's with value and update it by PHP
My XML:
<WorkingTime>
<FromTime>08:00</FromTime>
<ToTime>11:00</ToTime>
<Name>Izpit</Name>
<Owner>Marko</Owner>
<Category>
<School Professor="111" Room="1" Subject="882" />
</Category>
</WorkingTime>
<Professors>
<Professor email="xxx" id="111" code="String">Name 1</Professor>
<Professor email="xxx" id="222" code="String">Name 2</Professor>
<Professor email="xxx" id="333" code="String">Name 3</Professor>
</Professors>
<Rooms>
<Room id="1">IA-301</Room>
<Room id="2">A-302</Room>
<Room id="3">A-303</Room>
<Room id="4">A-304</Room>
<Room id="5">A-305</Room>
<Room id="6">A-306</Room>
</Rooms>
<Subjects>
<Subject id="881">Vaje</Subject>
<Subject id="882">Kolokvij</Subject>
<Subject id="883">Predmet</Subject>
<Subject id="884">Izpit</Subject>
</Subjects>
How can I in php now print Professor.
I can get id like:
$professor = $workingTime->Category->School->attributes()->Professor;
$room = $workingTime->Category->School->attributes()->Room;
$subject = $workingTime->Category->School->attributes()->Subject;
but how to now get value:
I try this but is empty:
echo $xml->Professors->Professor[$professor];
And how can I update values.
I want to save:
I am using dom_import_simplexml and simplexml_load_file
My XML:
<WorkingTime>
<FromTime>08:00</FromTime>
<ToTime>11:00</ToTime>
<Name>Izpit</Name>
<Owner>Marko</Owner>
<Category>
<School Professor="111" Room="1" Subject="882" />
</Category>
</WorkingTime>
<Professors>
<Professor email="xxx" id="111" code="String">Name 1</Professor>
<Professor email="xxx" id="222" code="String">Name 2</Professor>
<Professor email="xxx" id="333" code="String">Name 3</Professor>
</Professors>
<Rooms>
<Room id="1">IA-301</Room>
<Room id="2">A-302</Room>
<Room id="3">A-303</Room>
<Room id="4">A-304</Room>
<Room id="5">A-305</Room>
<Room id="6">A-306</Room>
</Rooms>
<Subjects>
<Subject id="881">Vaje</Subject>
<Subject id="882">Kolokvij</Subject>
<Subject id="883">Predmet</Subject>
<Subject id="884">Izpit</Subject>
</Subjects>
How can I in php now print Professor.
I can get id like:
$professor = $workingTime->Category->School->attributes()->Professor;
$room = $workingTime->Category->School->attributes()->Room;
$subject = $workingTime->Category->School->attributes()->Subject;
but how to now get value:
I try this but is empty:
echo $xml->Professors->Professor[$professor];
And how can I update values.
I want to save:
I am using dom_import_simplexml and simplexml_load_file
Saturday, 24 August 2013
Uncaught TypeError: Object has no method 'setAttribute'
Uncaught TypeError: Object has no method 'setAttribute'
I am having some trouble with my nested for loop. I am trying to determine
the value of checked checkboxes in my form. I was told that the whole
thing should formatted like so:
for(checkboxes loop){
for(item.appointmentType[1] loop){
if(statement conditional){
set checks code
}
}
}
But I just can not seem to get it written correctly because I have
received an error saying, Uncaught TypeError: Object has no method
'setAttribute'
Below is the code that I am working with. Can someone help me correct it
that may know what I am talking about?
var checkboxes = document.forms[0].appointmentType;
for(var i=0; i<checkboxes.length; i++){
for(var j=0; j<item.appointmentType[1].length; j++){
if(checkboxes[i].value === item.appointmentType[1][j]){
item.appointmentType[1][j].setAttribute("checked", "checked");
}
}
}
Thanks.
I am having some trouble with my nested for loop. I am trying to determine
the value of checked checkboxes in my form. I was told that the whole
thing should formatted like so:
for(checkboxes loop){
for(item.appointmentType[1] loop){
if(statement conditional){
set checks code
}
}
}
But I just can not seem to get it written correctly because I have
received an error saying, Uncaught TypeError: Object has no method
'setAttribute'
Below is the code that I am working with. Can someone help me correct it
that may know what I am talking about?
var checkboxes = document.forms[0].appointmentType;
for(var i=0; i<checkboxes.length; i++){
for(var j=0; j<item.appointmentType[1].length; j++){
if(checkboxes[i].value === item.appointmentType[1][j]){
item.appointmentType[1][j].setAttribute("checked", "checked");
}
}
}
Thanks.
Rails Devise - current_user is nil
Rails Devise - current_user is nil
For some reason, current_user returns nil in my model-less controller
(Subscriptions). I have found nothing on the Internet to justify this
behavior...
class SubscriptionsController < ApplicationController
def new
...
end
def create
current_user # returns nil
end
end
I can provide more code, but I'm not sure what would be useful.
For some reason, current_user returns nil in my model-less controller
(Subscriptions). I have found nothing on the Internet to justify this
behavior...
class SubscriptionsController < ApplicationController
def new
...
end
def create
current_user # returns nil
end
end
I can provide more code, but I'm not sure what would be useful.
How to modify jstree to display name of node when seleted
How to modify jstree to display name of node when seleted
In this fiddle : http://jsfiddle.net/ak4Ed/ when a node is selected and
the key 'c' is pressed the selected node id is displayed as popup.
How can I modify the code so that when a node is selected the popup is
displayed instead of relying on the user pressing the 'c' hotkey ?
Reading the jstree documentation this does not seem to be explained ? :
http://www.jstree.com/documentation/core
Here is the jsfiddle code :
<div id="demo1" style="height:100px;">
<ul>
<li id="node_1_id">
<a>Root node 1</a>
<ul>
<li id="child_node_1_id">
<a>Child node 1</a>
</li>
<li id="child_node_2_id">
<a>Child node 2</a>
</li>
</ul>
</li>
</ul>
<ul>
<li><a>Team A's Projects</a>
<ul>
<li><a>Iteration 1</a>
<ul>
<li><a>Story A</a></li>
<li><a>Story B</a></li>
<li><a>Story C</a></li>
</ul>
</li>
<li><a>Iteration 2</a>
<ul>
<li><a>Story D</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
$(function() {
$("#demo1").jstree({
"hotkeys": {
"c" : function(event) {
var node = this._get_node();
if(!node) {
alert("no node selected");
}
else {
alert("selected node: "+node.attr("id"));
}
},
"d": function(event) {
var node = this._get_node(this.data.ui.hovered);
if(!node) {
alert("no node hovered");
}
else {
alert("hovered node: "+node.attr("id"));
}
}
},
"plugins": ["ui", "html_data", "themes", "hotkeys"]
});
});
In this fiddle : http://jsfiddle.net/ak4Ed/ when a node is selected and
the key 'c' is pressed the selected node id is displayed as popup.
How can I modify the code so that when a node is selected the popup is
displayed instead of relying on the user pressing the 'c' hotkey ?
Reading the jstree documentation this does not seem to be explained ? :
http://www.jstree.com/documentation/core
Here is the jsfiddle code :
<div id="demo1" style="height:100px;">
<ul>
<li id="node_1_id">
<a>Root node 1</a>
<ul>
<li id="child_node_1_id">
<a>Child node 1</a>
</li>
<li id="child_node_2_id">
<a>Child node 2</a>
</li>
</ul>
</li>
</ul>
<ul>
<li><a>Team A's Projects</a>
<ul>
<li><a>Iteration 1</a>
<ul>
<li><a>Story A</a></li>
<li><a>Story B</a></li>
<li><a>Story C</a></li>
</ul>
</li>
<li><a>Iteration 2</a>
<ul>
<li><a>Story D</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
$(function() {
$("#demo1").jstree({
"hotkeys": {
"c" : function(event) {
var node = this._get_node();
if(!node) {
alert("no node selected");
}
else {
alert("selected node: "+node.attr("id"));
}
},
"d": function(event) {
var node = this._get_node(this.data.ui.hovered);
if(!node) {
alert("no node hovered");
}
else {
alert("hovered node: "+node.attr("id"));
}
}
},
"plugins": ["ui", "html_data", "themes", "hotkeys"]
});
});
Possible to integrate existing Java class with Actor?
Possible to integrate existing Java class with Actor?
I am on Scala 2.10.2, Akka 2.2.0 and trying to determine if it is
meaningful to integrate an existing Java class with an Actor. The Java
class I have in mind is the Apache Commons FileUpload streaming API.
This is what I got working without using an Actor
class HelloWorld extends HttpServlet {
override def doGet(req: HttpServletRequest, resp: HttpServletResponse) = {
resp.getWriter().print("Hello World!")
}
override def doPost(req: HttpServletRequest, resp: HttpServletResponse )
= {
if (ServletFileUpload.isMultipartContent(req)) {
val upload = new ServletFileUpload()
// Parse the request
val iter = upload.getItemIterator(req)
while (iter.hasNext()) {
val item = iter.next()
val name = item.getFieldName()
val stream = item.openStream()
if (item.isFormField()) {
println("Form field " + name + " with value " +
Streams.asString(stream) + " detected.")
} else {
println("File field " + name + " with file name " +
item.getName() + " detected.")
saveAttachment(item.getName(), stream)
}
}
resp.getWriter().print("\nFile uploads success!\n")
} else
resp.getWriter().print("\nNo file upload found!\n")
}
private def saveAttachment(...) {...}
}
Typically an actor handles all its messages within the receive method but
in this case the class already has predefined methods. For lack of a
better term, is there a way to actorfy this?
I am on Scala 2.10.2, Akka 2.2.0 and trying to determine if it is
meaningful to integrate an existing Java class with an Actor. The Java
class I have in mind is the Apache Commons FileUpload streaming API.
This is what I got working without using an Actor
class HelloWorld extends HttpServlet {
override def doGet(req: HttpServletRequest, resp: HttpServletResponse) = {
resp.getWriter().print("Hello World!")
}
override def doPost(req: HttpServletRequest, resp: HttpServletResponse )
= {
if (ServletFileUpload.isMultipartContent(req)) {
val upload = new ServletFileUpload()
// Parse the request
val iter = upload.getItemIterator(req)
while (iter.hasNext()) {
val item = iter.next()
val name = item.getFieldName()
val stream = item.openStream()
if (item.isFormField()) {
println("Form field " + name + " with value " +
Streams.asString(stream) + " detected.")
} else {
println("File field " + name + " with file name " +
item.getName() + " detected.")
saveAttachment(item.getName(), stream)
}
}
resp.getWriter().print("\nFile uploads success!\n")
} else
resp.getWriter().print("\nNo file upload found!\n")
}
private def saveAttachment(...) {...}
}
Typically an actor handles all its messages within the receive method but
in this case the class already has predefined methods. For lack of a
better term, is there a way to actorfy this?
Separated, grainy ganache (Dark and Stormies from Grewelings's book)
Separated, grainy ganache (Dark and Stormies from Grewelings's book)
I tried making "Dark and Stormies" out of Greweling's book (Chocolate and
Confections). The center is a white chocolate ganache infused with vanilla
and ginger and with rum. Both times I tried it, the ganache came out
grainy or almost spongy in appearance.
I've never had this problem with ganache (although I'm aware that it is
very common). I've also never used Greweling's technique for ganache. It
has two primary differences:
The chocolate has to be tempered prior to using it for the ganache.
The chocolate is melted at 86 F (for white chocolate) before the cream is
added.
Normally, I would use chopped up unmelted chocolate and pour hot cream
over it. I wanted to try Geweling's method, though.
Attempt 1:
I know the chocolate was over heated (probably to around 130-140) during
tempering, but the chocolate didn't show any signs of burning.
Attempt 2:
This time the chocolate was kept at the right temperature. I also stirred
the ganache slightly less. The result seems to be better, but still
separated.
Thanks!
I tried making "Dark and Stormies" out of Greweling's book (Chocolate and
Confections). The center is a white chocolate ganache infused with vanilla
and ginger and with rum. Both times I tried it, the ganache came out
grainy or almost spongy in appearance.
I've never had this problem with ganache (although I'm aware that it is
very common). I've also never used Greweling's technique for ganache. It
has two primary differences:
The chocolate has to be tempered prior to using it for the ganache.
The chocolate is melted at 86 F (for white chocolate) before the cream is
added.
Normally, I would use chopped up unmelted chocolate and pour hot cream
over it. I wanted to try Geweling's method, though.
Attempt 1:
I know the chocolate was over heated (probably to around 130-140) during
tempering, but the chocolate didn't show any signs of burning.
Attempt 2:
This time the chocolate was kept at the right temperature. I also stirred
the ganache slightly less. The result seems to be better, but still
separated.
Thanks!
in c# getting Error cannot access a disposed object object name='System.Net.Socket.Socket'
in c# getting Error cannot access a disposed object object
name='System.Net.Socket.Socket'
I want a chat application in C# Client and in Java Server
I go through C# Client but I got some Error when I response to Java Server
I get the error@
cannot access a disposed object object name='System.Net.Socket.Socket'
class Program
{
static void Main(string[] args)
{
byte[] bytes = new byte[1024];// data buffer for incoming data
// connect to a Remote device
try
{
// Establish the remote end point for the socket
IPHostEntry ipHost = Dns.Resolve("localhost");
IPAddress ipAddr = ipHost.AddressList[0];
IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 95);
Socket Socketsender = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
// Connect the socket to the remote endpoint
Socketsender.Connect(ipEndPoint);
Console.WriteLine("\n\n___________________Client Server Chat
Application__________________________");
Console.WriteLine("___________________________________________________________________________");
Console.WriteLine("\nSocket Connecting To Java Server...." +
Socketsender.RemoteEndPoint.ToString());
// Console.ReadLine();
string data = null;
while (true)
{
//Recieved from Java Server Message
int bytesRec = Socketsender.Receive(bytes);
Console.WriteLine("\nJava Server:: {0}",
Encoding.ASCII.GetString(bytes, 0, bytesRec));
// Console.ReadLine();
Console.Write("C# Client ::"); // Prompt
string line = Console.ReadLine();
byte[] sendToServer = Encoding.ASCII.GetBytes(line);
// Send the data through the socket
int intByteSend = Socketsender.Send(sendToServer);
// Socketsender.Shutdown(SocketShutdown.Both);
Socketsender.Close();
Console.WriteLine("____________________________________________________________________________");
Console.WriteLine("_________________________End
Chat___________________________________________");
// Socketsender.Shutdown(SocketShutdown.Both);
Socketsender.Close();
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.ReadLine();
}
}
name='System.Net.Socket.Socket'
I want a chat application in C# Client and in Java Server
I go through C# Client but I got some Error when I response to Java Server
I get the error@
cannot access a disposed object object name='System.Net.Socket.Socket'
class Program
{
static void Main(string[] args)
{
byte[] bytes = new byte[1024];// data buffer for incoming data
// connect to a Remote device
try
{
// Establish the remote end point for the socket
IPHostEntry ipHost = Dns.Resolve("localhost");
IPAddress ipAddr = ipHost.AddressList[0];
IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 95);
Socket Socketsender = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
// Connect the socket to the remote endpoint
Socketsender.Connect(ipEndPoint);
Console.WriteLine("\n\n___________________Client Server Chat
Application__________________________");
Console.WriteLine("___________________________________________________________________________");
Console.WriteLine("\nSocket Connecting To Java Server...." +
Socketsender.RemoteEndPoint.ToString());
// Console.ReadLine();
string data = null;
while (true)
{
//Recieved from Java Server Message
int bytesRec = Socketsender.Receive(bytes);
Console.WriteLine("\nJava Server:: {0}",
Encoding.ASCII.GetString(bytes, 0, bytesRec));
// Console.ReadLine();
Console.Write("C# Client ::"); // Prompt
string line = Console.ReadLine();
byte[] sendToServer = Encoding.ASCII.GetBytes(line);
// Send the data through the socket
int intByteSend = Socketsender.Send(sendToServer);
// Socketsender.Shutdown(SocketShutdown.Both);
Socketsender.Close();
Console.WriteLine("____________________________________________________________________________");
Console.WriteLine("_________________________End
Chat___________________________________________");
// Socketsender.Shutdown(SocketShutdown.Both);
Socketsender.Close();
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.ReadLine();
}
}
Can I earn money with PYTHON/RUBY programming language?
Can I earn money with PYTHON/RUBY programming language?
My desktop is dead(No signal to monitor). Now I'm using my brother's
laptop. I need at least $200 to buy a medium desktop. Don't tell me that
you will send me one for free. I want to earn legit-fair money NOW!!!
My desktop is dead(No signal to monitor). Now I'm using my brother's
laptop. I need at least $200 to buy a medium desktop. Don't tell me that
you will send me one for free. I want to earn legit-fair money NOW!!!
Friday, 23 August 2013
A Question Related to Fubini's Theorem
A Question Related to Fubini's Theorem
I was wondering if there is a integrable function $f: A \times B \to
\mathbb{R}$ (where $A, B \subset \mathbb{R}^n$ are rectangles) such that
$$ \int\limits_{A \times B} f = \int\limits_{A}\int\limits_{B} f(x, y) \,
dy \, dx $$ but $$ \int\limits_{B}\int\limits_{A} f(x, y) \, dx \, dy $$
does not exist.
I was wondering if there is a integrable function $f: A \times B \to
\mathbb{R}$ (where $A, B \subset \mathbb{R}^n$ are rectangles) such that
$$ \int\limits_{A \times B} f = \int\limits_{A}\int\limits_{B} f(x, y) \,
dy \, dx $$ but $$ \int\limits_{B}\int\limits_{A} f(x, y) \, dx \, dy $$
does not exist.
How do I do user inputs
How do I do user inputs
What I wish to do is ask a question to the user (user inputs) (Answers:
Yes, No) if they say yes, something happens, if they say no, something
else happens.
I.E: I ask the user if they want to have a race in how fast they can type
compared to the computer. If they say yes, we have a race, if they say no,
i can continue with something else.
What I wish to do is ask a question to the user (user inputs) (Answers:
Yes, No) if they say yes, something happens, if they say no, something
else happens.
I.E: I ask the user if they want to have a race in how fast they can type
compared to the computer. If they say yes, we have a race, if they say no,
i can continue with something else.
js: Unexpected call to method or property access - appendChild()
js: Unexpected call to method or property access - appendChild()
I have created a bookmarklet that executes the below code, adding css
styling to the page. It works on all tried sites in Chrome and Firefox,
but fails for some sites on IE. It's always the same sites that fail.
The fourth line fails with "Unexpected call to method or property access"
for SOME sites, only on IE.
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
style.appendChild(document.createTextNode(""));
head.appendChild(style);
Two sites that fail on IE 10:
http://www.momswhothink.com/cake-recipes/banana-cake-recipe.html
http://www.bakerella.com/
I have created a bookmarklet that executes the below code, adding css
styling to the page. It works on all tried sites in Chrome and Firefox,
but fails for some sites on IE. It's always the same sites that fail.
The fourth line fails with "Unexpected call to method or property access"
for SOME sites, only on IE.
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
style.appendChild(document.createTextNode(""));
head.appendChild(style);
Two sites that fail on IE 10:
http://www.momswhothink.com/cake-recipes/banana-cake-recipe.html
http://www.bakerella.com/
Dynamic Formview from Datatable
Dynamic Formview from Datatable
I am trying to create a dynamic formview and bind a datatable to it, it
seems to create the formview but when i try to bind the datatable to it,
it doesn't display anything. Below is the code that i have:
test3.aspx.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class test3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataTable table = GetTable();
Response.Write("Back - " + table.Rows.Count);
FormView frm = new FormView();
frm.ID = "FormView1";
frm.DataSource = table;
frm.DataBind();
DynamicControlsHolder1.Controls.Add(frm);
}
static DataTable GetTable()
{
//
// Here we create a DataTable with four columns.
//
DataTable table = new DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Columns.Add("Drug", typeof(string));
table.Columns.Add("Patient", typeof(string));
table.Columns.Add("Date", typeof(DateTime));
//
// Here we add five DataRows.
//
table.Rows.Add(25, "Indocin", "David", DateTime.Now);
table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
return table;
}
}
test3.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test3.aspx.cs"
Inherits="test3" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:PlaceHolder ID="DynamicControlsHolder1"
runat="server"></asp:PlaceHolder>
</div>
</form>
</body>
</html>
I am trying to create a dynamic formview and bind a datatable to it, it
seems to create the formview but when i try to bind the datatable to it,
it doesn't display anything. Below is the code that i have:
test3.aspx.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class test3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataTable table = GetTable();
Response.Write("Back - " + table.Rows.Count);
FormView frm = new FormView();
frm.ID = "FormView1";
frm.DataSource = table;
frm.DataBind();
DynamicControlsHolder1.Controls.Add(frm);
}
static DataTable GetTable()
{
//
// Here we create a DataTable with four columns.
//
DataTable table = new DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Columns.Add("Drug", typeof(string));
table.Columns.Add("Patient", typeof(string));
table.Columns.Add("Date", typeof(DateTime));
//
// Here we add five DataRows.
//
table.Rows.Add(25, "Indocin", "David", DateTime.Now);
table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
return table;
}
}
test3.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test3.aspx.cs"
Inherits="test3" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:PlaceHolder ID="DynamicControlsHolder1"
runat="server"></asp:PlaceHolder>
</div>
</form>
</body>
</html>
Running a macro automatically in one sheet when workbook is opened
Running a macro automatically in one sheet when workbook is opened
I'm trying to run a macro automatically when a workbook is opened. I was
using the privatesub command in ThisWorkbook tab. However it seems when I
shut the Excel file and open it again, the macro has run on another sheet
as well resulting in a circular references error. How do I solve this so
it only runs on one sheet ("Cover Sheet"). Would placing the macro in he
actual sheet module work?
Private Sub Workbook_Open()
With Sheets("Cover Sheet")
With Range("B21")
.Formula = "=COUNTIFS('Design Risk Scoring Sheet'!$AN$12:$AN$" &
Sheets("Design Risk Scoring Sheet").Cells(Rows.count,
"AN").End(xlUp).Row & ",""<""&B20, 'Design Risk Scoring
Sheet'!$B$12:$B$" & Sheets("Design Risk Scoring
Sheet").Cells(Rows.count, "AN").End(xlUp).Row & ", """" )"
.AutoFill Destination:=Range("B21:AF21"), Type:=xlFillDefault
End With
With Range("B22")
.Formula = "=COUNTIFS('Design Risk Scoring Sheet'!$BF$12:$BF$" &
Sheets("Design Risk Scoring Sheet").Cells(Rows.count,
"AN").End(xlUp).Row & ",""<""&B20, 'Design Risk Scoring
Sheet'!$B$12:$B$" & Sheets("Design Risk Scoring
Sheet").Cells(Rows.count, "AN").End(xlUp).Row & ", """" )"
.AutoFill Destination:=Range("B22:AF22"), Type:=xlFillDefault
End With
End With
I'm trying to run a macro automatically when a workbook is opened. I was
using the privatesub command in ThisWorkbook tab. However it seems when I
shut the Excel file and open it again, the macro has run on another sheet
as well resulting in a circular references error. How do I solve this so
it only runs on one sheet ("Cover Sheet"). Would placing the macro in he
actual sheet module work?
Private Sub Workbook_Open()
With Sheets("Cover Sheet")
With Range("B21")
.Formula = "=COUNTIFS('Design Risk Scoring Sheet'!$AN$12:$AN$" &
Sheets("Design Risk Scoring Sheet").Cells(Rows.count,
"AN").End(xlUp).Row & ",""<""&B20, 'Design Risk Scoring
Sheet'!$B$12:$B$" & Sheets("Design Risk Scoring
Sheet").Cells(Rows.count, "AN").End(xlUp).Row & ", """" )"
.AutoFill Destination:=Range("B21:AF21"), Type:=xlFillDefault
End With
With Range("B22")
.Formula = "=COUNTIFS('Design Risk Scoring Sheet'!$BF$12:$BF$" &
Sheets("Design Risk Scoring Sheet").Cells(Rows.count,
"AN").End(xlUp).Row & ",""<""&B20, 'Design Risk Scoring
Sheet'!$B$12:$B$" & Sheets("Design Risk Scoring
Sheet").Cells(Rows.count, "AN").End(xlUp).Row & ", """" )"
.AutoFill Destination:=Range("B22:AF22"), Type:=xlFillDefault
End With
End With
How do I automate the process of sending the full text of my saved feedly items to Evernote?
How do I automate the process of sending the full text of my saved feedly
items to Evernote?
I use feedly as a newsreader, but prefer to do my actual reading in
Evernote, so I can quickly save and label articles I want to save. I end
up spending a lot of time using Evernote web clipper to export the
articles one at a time.
I've tried using IFTTT to automate the process, but it only sends the
summary text of saved articles.
I'd like to try and build a tool to do all this myself. I have limited
programming experience (I took C in college), but I really don't even know
where to start on building something like this.
How do I write a program that gets the url from the title of the feedly
item, then imports the full text of that url's page to Evernote?
items to Evernote?
I use feedly as a newsreader, but prefer to do my actual reading in
Evernote, so I can quickly save and label articles I want to save. I end
up spending a lot of time using Evernote web clipper to export the
articles one at a time.
I've tried using IFTTT to automate the process, but it only sends the
summary text of saved articles.
I'd like to try and build a tool to do all this myself. I have limited
programming experience (I took C in college), but I really don't even know
where to start on building something like this.
How do I write a program that gets the url from the title of the feedly
item, then imports the full text of that url's page to Evernote?
Thursday, 22 August 2013
Which control caused postback in apsx page when postback is triggered from JavaScript
Which control caused postback in apsx page when postback is triggered from
JavaScript
I have a aspx page which contains few controls along with a Button.
<asp:Button ID="savebtn" runat="server" OnClick="savebtn_Click"
Style="display: none" />
I use this button to trigger post pack using the click event of this button.
//For post back
$(document).ready(function () {
var id = document.getElementById('<%= savebtn.ClientID %>');
//causes post back
id.Text = "postback";
id.click();
});
Now at the page load I want to know which control caused the post back.
I have used below code to find out which control caused the postpack but
its returning null. May be because I am triggered the post pack from
JavaScript.
private Control GetControlThatCausedPostBack(Page page)
{
//initialize a control and set it to null
Control ctrl = null;
//get the event target name and find the control
string ctrlName = Page.Request.Params.Get("__EVENTTARGET");
if (!String.IsNullOrEmpty(ctrlName))
ctrl = page.FindControl(ctrlName);
//return the control to the calling method
return ctrl;
}
Please help
JavaScript
I have a aspx page which contains few controls along with a Button.
<asp:Button ID="savebtn" runat="server" OnClick="savebtn_Click"
Style="display: none" />
I use this button to trigger post pack using the click event of this button.
//For post back
$(document).ready(function () {
var id = document.getElementById('<%= savebtn.ClientID %>');
//causes post back
id.Text = "postback";
id.click();
});
Now at the page load I want to know which control caused the post back.
I have used below code to find out which control caused the postpack but
its returning null. May be because I am triggered the post pack from
JavaScript.
private Control GetControlThatCausedPostBack(Page page)
{
//initialize a control and set it to null
Control ctrl = null;
//get the event target name and find the control
string ctrlName = Page.Request.Params.Get("__EVENTTARGET");
if (!String.IsNullOrEmpty(ctrlName))
ctrl = page.FindControl(ctrlName);
//return the control to the calling method
return ctrl;
}
Please help
Calculating seconds to millisecond NSTimer
Calculating seconds to millisecond NSTimer
Trying to work out where I have screwed up with trying to create a count
down timer which displays seconds and milliseconds. The idea is the timer
displays the count down time to an NSString which updates a UILable.
The code I currently have is
-(void)timerRun {
if (self.timerPageView.startCountdown) {
NSLog(@"%i",self.timerPageView.xtime);
self.timerPageView.sec = self.timerPageView.sec - 1;
seconds = (self.timerPageView.sec % 60) % 60 ;
milliseconds = (self.timerPageView.sec % 60) % 1000;
NSString *timerOutput = [NSString stringWithFormat:@"%i:%i", seconds,
milliseconds];
self.timerPageView.timerText.text = timerOutput;
if (self.timerPageView.resetTimer == YES) {
[self setTimer];
}
}
else {
}
}
-(void)setTimer{
if (self.timerPageView.xtime == 0) {
self.timerPageView.xtime = 60000;
}
self.timerPageView.sec = self.timerPageView.xtime;
self.timerPageView.countdownTimer = [NSTimer
scheduledTimerWithTimeInterval:0.01 target:self
selector:@selector(timerRun) userInfo:Nil repeats:YES];
self.timerPageView.resetTimer = NO;
}
Anyone got any ideas what I am doing wrong?
Trying to work out where I have screwed up with trying to create a count
down timer which displays seconds and milliseconds. The idea is the timer
displays the count down time to an NSString which updates a UILable.
The code I currently have is
-(void)timerRun {
if (self.timerPageView.startCountdown) {
NSLog(@"%i",self.timerPageView.xtime);
self.timerPageView.sec = self.timerPageView.sec - 1;
seconds = (self.timerPageView.sec % 60) % 60 ;
milliseconds = (self.timerPageView.sec % 60) % 1000;
NSString *timerOutput = [NSString stringWithFormat:@"%i:%i", seconds,
milliseconds];
self.timerPageView.timerText.text = timerOutput;
if (self.timerPageView.resetTimer == YES) {
[self setTimer];
}
}
else {
}
}
-(void)setTimer{
if (self.timerPageView.xtime == 0) {
self.timerPageView.xtime = 60000;
}
self.timerPageView.sec = self.timerPageView.xtime;
self.timerPageView.countdownTimer = [NSTimer
scheduledTimerWithTimeInterval:0.01 target:self
selector:@selector(timerRun) userInfo:Nil repeats:YES];
self.timerPageView.resetTimer = NO;
}
Anyone got any ideas what I am doing wrong?
Jquery radar control with gradient line
Jquery radar control with gradient line
Have question about jquery control - do you know where i can find (for
free if it`s possible) radar jquery control that will have opportunity
setup gradient for line?
It should looks like on picture here
Thanks a lot.
Have question about jquery control - do you know where i can find (for
free if it`s possible) radar jquery control that will have opportunity
setup gradient for line?
It should looks like on picture here
Thanks a lot.
Can I access system file icons for certain file types in my Mac app?
Can I access system file icons for certain file types in my Mac app?
I have a path to a file that is of the type plist. Isn't there a way to
take that file extension, and hand it to some library and have it return
the plist icon image that Mac OS uses?
I swear I have seen this done before, but I can't find any information on it.
Thanks!
I have a path to a file that is of the type plist. Isn't there a way to
take that file extension, and hand it to some library and have it return
the plist icon image that Mac OS uses?
I swear I have seen this done before, but I can't find any information on it.
Thanks!
Determine which textview should be cut off
Determine which textview should be cut off
In a relativelayout I am using the code below. If the total width is too
high tvProgress should be cut off. The problem is that I don't know how to
determine which view should be cut off. The current code lets
list_lib_episodes_watched_total cut off. How can I determine that
tvProgress is cut off instead?
...
<TextView
android:id="@+id/tvProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/list_lib_et_episodes_watched"
android:layout_toRightOf="@+id/list_lib_cover"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:lines="1"
android:singleLine="true"
android:text="Progress:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/list_lib_et_episodes_watched"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/list_lib_status_spinner"
android:layout_toRightOf="@+id/tvProgress"
android:hint="0"
android:imeOptions="actionSend"
android:inputType="number"
android:maxEms="4"
android:maxLength="4"
android:text="0" />
<TextView
android:id="@+id/list_lib_episodes_watched_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/list_lib_et_episodes_watched"
android:layout_toLeftOf="@+id/list_lib_episodes_watched_increase"
android:layout_toRightOf="@+id/list_lib_et_episodes_watched"
android:lines="1"
android:singleLine="true"
android:text="/0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#707070" />
<ImageButton
android:id="@+id/list_lib_episodes_watched_increase"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/list_lib_et_episodes_watched"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/list_lib_et_episodes_watched"
android:layout_marginLeft="6dp"
android:layout_marginRight="8dp"
android:adjustViewBounds="true"
android:background="@drawable/btn_transparant"
android:contentDescription="Increase by 1"
android:minWidth="60dp"
android:scaleType="centerInside"
android:src="@drawable/ic_increase" />
...
In a relativelayout I am using the code below. If the total width is too
high tvProgress should be cut off. The problem is that I don't know how to
determine which view should be cut off. The current code lets
list_lib_episodes_watched_total cut off. How can I determine that
tvProgress is cut off instead?
...
<TextView
android:id="@+id/tvProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/list_lib_et_episodes_watched"
android:layout_toRightOf="@+id/list_lib_cover"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:lines="1"
android:singleLine="true"
android:text="Progress:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/list_lib_et_episodes_watched"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/list_lib_status_spinner"
android:layout_toRightOf="@+id/tvProgress"
android:hint="0"
android:imeOptions="actionSend"
android:inputType="number"
android:maxEms="4"
android:maxLength="4"
android:text="0" />
<TextView
android:id="@+id/list_lib_episodes_watched_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/list_lib_et_episodes_watched"
android:layout_toLeftOf="@+id/list_lib_episodes_watched_increase"
android:layout_toRightOf="@+id/list_lib_et_episodes_watched"
android:lines="1"
android:singleLine="true"
android:text="/0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#707070" />
<ImageButton
android:id="@+id/list_lib_episodes_watched_increase"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/list_lib_et_episodes_watched"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/list_lib_et_episodes_watched"
android:layout_marginLeft="6dp"
android:layout_marginRight="8dp"
android:adjustViewBounds="true"
android:background="@drawable/btn_transparant"
android:contentDescription="Increase by 1"
android:minWidth="60dp"
android:scaleType="centerInside"
android:src="@drawable/ic_increase" />
...
Wednesday, 21 August 2013
Struts2 Localization with struts dojo autocompleter
Struts2 Localization with struts dojo autocompleter
I have implemented autocomplete function using struts2 dojo autocompleter
and I used localization for three languages. I have got some data from
property files and the some data which I have got from backend to front
end like list for drop down list, is not getting from other languages
properties files when I change the language. It is always getting en_us
(global.properties) file. Other data in Jsp file , which I have got from
property file is coming properly. Please help.
I have implemented autocomplete function using struts2 dojo autocompleter
and I used localization for three languages. I have got some data from
property files and the some data which I have got from backend to front
end like list for drop down list, is not getting from other languages
properties files when I change the language. It is always getting en_us
(global.properties) file. Other data in Jsp file , which I have got from
property file is coming properly. Please help.
Is there a way to explicitly state what the ticks on a TikZ/pgfplots picture should say (ie 10.000 rather than 10)?
Is there a way to explicitly state what the ticks on a TikZ/pgfplots
picture should say (ie 10.000 rather than 10)?
I'm trying to show that my graph has 5 significant figures on the y-axis.
But I can't seem to get TikZ/pgfplots to show the trailing zeros though. I
tried to get TikZ/pgfplots to show the extra zeros by using the ytick
option, but it doesn't seem to work.
\documentclass[letterpaper,12pt]{article}
\usepackage{pgfplots}
\usepackage[margin=1in]{geometry}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xticklabel={\pgfmathprintnumber\tick\%},
xmin = 0, xmax = 20,
ymin = 10, ymax = 10.3,
xlabel = Concentration,
axis x line = bottom,
ylabel = Mass (g),
axis y line = left,
xtick = {0,5,10,15,20},
ytick = {10.000,10.100,10.200,10.300}, % My attempt thus far
grid = major,
width = \textwidth - 1in,
tick align = outside
]
\addplot coordinates{
(5,10.012)
(10,10.180)
(15,10.230)
};
\end{axis}
\end{tikzpicture}
\end{document}
And here's what the document currently looks like:
picture should say (ie 10.000 rather than 10)?
I'm trying to show that my graph has 5 significant figures on the y-axis.
But I can't seem to get TikZ/pgfplots to show the trailing zeros though. I
tried to get TikZ/pgfplots to show the extra zeros by using the ytick
option, but it doesn't seem to work.
\documentclass[letterpaper,12pt]{article}
\usepackage{pgfplots}
\usepackage[margin=1in]{geometry}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xticklabel={\pgfmathprintnumber\tick\%},
xmin = 0, xmax = 20,
ymin = 10, ymax = 10.3,
xlabel = Concentration,
axis x line = bottom,
ylabel = Mass (g),
axis y line = left,
xtick = {0,5,10,15,20},
ytick = {10.000,10.100,10.200,10.300}, % My attempt thus far
grid = major,
width = \textwidth - 1in,
tick align = outside
]
\addplot coordinates{
(5,10.012)
(10,10.180)
(15,10.230)
};
\end{axis}
\end{tikzpicture}
\end{document}
And here's what the document currently looks like:
Network Admin switched computers, now I can't access my Access files
Network Admin switched computers, now I can't access my Access files
I created an Access file for users several years ago. Since then, a new
network administrator installed a new computer for me. I tried to open the
Access file to modify some of its characteristics and I am denied editing
because I do not have sufficiently high permissions. I assume this has to
do with the workstation, user ID, and workgroup settings on the new
computer.
Any suggestions on how to work around this?
I created an Access file for users several years ago. Since then, a new
network administrator installed a new computer for me. I tried to open the
Access file to modify some of its characteristics and I am denied editing
because I do not have sufficiently high permissions. I assume this has to
do with the workstation, user ID, and workgroup settings on the new
computer.
Any suggestions on how to work around this?
Storyboards VS xib's use concept
Storyboards VS xib's use concept
I have a custom UIViewController class that I want to show when a
UITableViewCell is pressed, so I get a callback when a particular cell has
been pressed.
My project is a navigation based application and i have created the
ViewController that I want to present in the StoryBoard but it have no
segue connected to it because it should be called from a dynamic
UITableViewCell.
The ViewController also set as the class that Subclassing it.
So now I am trying to do something like :
[self.navigationController pushViewController:[[AddAccountsViewController
alloc]init] animated:YES];
It does push but all I see is black screen. with an XIB I could just
create it separately but then I lose the 4 inch screen auto fit behavior
which I dont want.
How can I mange this?
I have a custom UIViewController class that I want to show when a
UITableViewCell is pressed, so I get a callback when a particular cell has
been pressed.
My project is a navigation based application and i have created the
ViewController that I want to present in the StoryBoard but it have no
segue connected to it because it should be called from a dynamic
UITableViewCell.
The ViewController also set as the class that Subclassing it.
So now I am trying to do something like :
[self.navigationController pushViewController:[[AddAccountsViewController
alloc]init] animated:YES];
It does push but all I see is black screen. with an XIB I could just
create it separately but then I lose the 4 inch screen auto fit behavior
which I dont want.
How can I mange this?
Common JavaScript Closure issue on jQuery elements in an Array
Common JavaScript Closure issue on jQuery elements in an Array
I am working at building a widget that calls a particular plugin on each
jQuery DOM element inside an array.
MyApp.forms is an array of Objects. Each Object has a jQuery wrapped DOM
element.
I am doing the following:
$(MyApp.forms).each(function(i){
var individualForm = this;
/*
individualForm is an Object {
prop: 'value,
$el: somejQueryElement,
...
}
*/
individualForm.$el.on('something', function() {
individualForm; // refers to the last object in MyApp.forms
this; // refers to the last
$(this); // same problem
}).on('somethingElse', function() {
// same problem as above here.
});
});
The events something and somethingElse get attached to all
individualForm's $el. But when they fire, I always get the last element.
I feel this is a common JavaScript Closure problem.
I tried using a for loop and creating an IIFE inside but it doesn't work,
as the function executes when the event fires. And though both events fire
on all elements, I only get the handler attached to last element executed.
I am working at building a widget that calls a particular plugin on each
jQuery DOM element inside an array.
MyApp.forms is an array of Objects. Each Object has a jQuery wrapped DOM
element.
I am doing the following:
$(MyApp.forms).each(function(i){
var individualForm = this;
/*
individualForm is an Object {
prop: 'value,
$el: somejQueryElement,
...
}
*/
individualForm.$el.on('something', function() {
individualForm; // refers to the last object in MyApp.forms
this; // refers to the last
$(this); // same problem
}).on('somethingElse', function() {
// same problem as above here.
});
});
The events something and somethingElse get attached to all
individualForm's $el. But when they fire, I always get the last element.
I feel this is a common JavaScript Closure problem.
I tried using a for loop and creating an IIFE inside but it doesn't work,
as the function executes when the event fires. And though both events fire
on all elements, I only get the handler attached to last element executed.
Tuesday, 20 August 2013
C++ type of issue
C++ type of issue
Tour and GuidedTour. GuideTour extends Tour. I create a list of these
items and add them to a vector.
list = new vector<Tour>();
list->push_back(Tour("FP001", "Fun Park 3 Day Pass", 110.00));
list->push_back(Tour("BG002", "Botanical Gardens Entry Pass", 30.00));
list->push_back(GuidedTour("SK003", "Learn to Ski Adventure Tour",
240.00, "28/07/2008", "Zail S", 25));
list->push_back(Tour("OZ004", "Open Range Zoo Entry Pass", 45.00));
list->push_back(GuidedTour("AB005", "Abseiling for Beginners Tour",
120.00, "15/07/2008", "Rex P", 35));
list->push_back(GuidedTour("RA006", "White Water Rafting Tour", 200.00,
"22/06/2008", "Clint R", 16));
Then I want to go thorugh this array and check the type of these Objects
void TourManager::callDisplayOnEach() {
for (vector<Tour>::iterator it = list->begin(); it != list->end();
++it) {
if (typeid(*it) == typeid(GuidedTour)) {
cout << "Guided Tour" << "\n";
}
else {
cout << "NOT Guided Tour : " << typeid(*it).name() << "\n";
}
//(*it).display();
}
}
However it always returns NOT a Guided Tour option.
Tour and GuidedTour. GuideTour extends Tour. I create a list of these
items and add them to a vector.
list = new vector<Tour>();
list->push_back(Tour("FP001", "Fun Park 3 Day Pass", 110.00));
list->push_back(Tour("BG002", "Botanical Gardens Entry Pass", 30.00));
list->push_back(GuidedTour("SK003", "Learn to Ski Adventure Tour",
240.00, "28/07/2008", "Zail S", 25));
list->push_back(Tour("OZ004", "Open Range Zoo Entry Pass", 45.00));
list->push_back(GuidedTour("AB005", "Abseiling for Beginners Tour",
120.00, "15/07/2008", "Rex P", 35));
list->push_back(GuidedTour("RA006", "White Water Rafting Tour", 200.00,
"22/06/2008", "Clint R", 16));
Then I want to go thorugh this array and check the type of these Objects
void TourManager::callDisplayOnEach() {
for (vector<Tour>::iterator it = list->begin(); it != list->end();
++it) {
if (typeid(*it) == typeid(GuidedTour)) {
cout << "Guided Tour" << "\n";
}
else {
cout << "NOT Guided Tour : " << typeid(*it).name() << "\n";
}
//(*it).display();
}
}
However it always returns NOT a Guided Tour option.
Admob ad code location [on hold]
Admob ad code location [on hold]
I am an android developer. I used to use admob but now I have moved on.
Recently I opened my app to see admob ads, so I went to the admob homepage
and clicked delete account, thinking that would fix my problem. About a
week later I went back to my app, only to see admob ads! My account is
still gone so I cannot log in.
Can sombody tell me where the ad code is placed, so I can manually remove
the ads. My sincerest thanks to the people who answer.
I am an android developer. I used to use admob but now I have moved on.
Recently I opened my app to see admob ads, so I went to the admob homepage
and clicked delete account, thinking that would fix my problem. About a
week later I went back to my app, only to see admob ads! My account is
still gone so I cannot log in.
Can sombody tell me where the ad code is placed, so I can manually remove
the ads. My sincerest thanks to the people who answer.
Lost VBA when downgrading from excel 2013 to excel 2010
Lost VBA when downgrading from excel 2013 to excel 2010
I am on windows 7. In the past I waas using excel 2003. I installed office
2013 and found that my office 2003 was in tact and I could run both
versions. I made updates to some worksheets using excel 2013 and VBA code.
I was informed that I needed to use office 2010 (I won't go into the
reasons) so I uninstalled office 2013 and installed office 2010 (Corporate
licenses). When I open the spreadsheets that I modified using excel 2013
in 2010 I get a microsoft visual basic for applications message "Class not
registered. Lokking for object iwht
CLSID:(AC9F2F90-E877-11DE-9F68-00AA00574A4F). When I hit ok, I get the
excel message "Excel found unreadable content in "name of
spreadsheet".xls. Do you want to recover the content of this workbook?" If
I select yes then I get a message that reads "Excel was able to open the
file by repairing or removing the unreadable content. Lost Visual Basic
project. Reparis were made to PivotTable report, ONe or more invalid
conditional formats were removed from the workbook and Lost ActiveX
controls.
Now the VBA code is not found. The workbook opens and looks normal but
buttons running VBA don't work and when opening VBA (alt F11) I don't see
any of the modules.
I tried running the FM20.dll using regsrv32.exe and I get a message which
says "The module fm20.dll failed to load. Make sure the binary is stored
at the spedified path or debug it to check for problems with the binary or
dependent .DLL files. The spedified mdoule could not be found". But I ran
regsrv32 from the subdirectory the FM20.dll was in.
I presume my problems have to do with losing the visual basic project and
or ActiveX controls.
What do I need to do to be able to find the vba code that was there before
removing excel 2013 and installing excel 2010?
THank you for helping me.
I am on windows 7. In the past I waas using excel 2003. I installed office
2013 and found that my office 2003 was in tact and I could run both
versions. I made updates to some worksheets using excel 2013 and VBA code.
I was informed that I needed to use office 2010 (I won't go into the
reasons) so I uninstalled office 2013 and installed office 2010 (Corporate
licenses). When I open the spreadsheets that I modified using excel 2013
in 2010 I get a microsoft visual basic for applications message "Class not
registered. Lokking for object iwht
CLSID:(AC9F2F90-E877-11DE-9F68-00AA00574A4F). When I hit ok, I get the
excel message "Excel found unreadable content in "name of
spreadsheet".xls. Do you want to recover the content of this workbook?" If
I select yes then I get a message that reads "Excel was able to open the
file by repairing or removing the unreadable content. Lost Visual Basic
project. Reparis were made to PivotTable report, ONe or more invalid
conditional formats were removed from the workbook and Lost ActiveX
controls.
Now the VBA code is not found. The workbook opens and looks normal but
buttons running VBA don't work and when opening VBA (alt F11) I don't see
any of the modules.
I tried running the FM20.dll using regsrv32.exe and I get a message which
says "The module fm20.dll failed to load. Make sure the binary is stored
at the spedified path or debug it to check for problems with the binary or
dependent .DLL files. The spedified mdoule could not be found". But I ran
regsrv32 from the subdirectory the FM20.dll was in.
I presume my problems have to do with losing the visual basic project and
or ActiveX controls.
What do I need to do to be able to find the vba code that was there before
removing excel 2013 and installing excel 2010?
THank you for helping me.
jQuery unobtrusive Validation don't working
jQuery unobtrusive Validation don't working
I have form in mvc 4 that don't make validation on client side.
The validation happen only only on the server side.
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Phone)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Phone)
@Html.ValidationMessageFor(model => model.Phone)
</div>
<p>
<input type="submit" value="Send" />
</p>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
the bundle code is:
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
I also checked the web.config settings:
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
The model I using is:
public class ContactUs
{
[Required]
public string Name { get; set; }
[Required]
public string Phone { get; set; }
}
The page is inside the _Layout file. Scripts version: jquery 2.0.3s and
jQuery Validation Plugin 1.11.1
All the scripts is working and exist on the source code of the page.
What can be the problem?
I have form in mvc 4 that don't make validation on client side.
The validation happen only only on the server side.
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Phone)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Phone)
@Html.ValidationMessageFor(model => model.Phone)
</div>
<p>
<input type="submit" value="Send" />
</p>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
the bundle code is:
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
I also checked the web.config settings:
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
The model I using is:
public class ContactUs
{
[Required]
public string Name { get; set; }
[Required]
public string Phone { get; set; }
}
The page is inside the _Layout file. Scripts version: jquery 2.0.3s and
jQuery Validation Plugin 1.11.1
All the scripts is working and exist on the source code of the page.
What can be the problem?
Whats my IP and subnet from Azure website?
Whats my IP and subnet from Azure website?
Im building out an Azure hosted website, but it needs to reach into our
home office to connect to some internally hosted web services. Our
firewall is setup to only allow traffic over certain IP's, so we're
looking to determine what IP range we need to allow access to.
Currently I'm still using the MSDN "Free" Azure subscription, so I don't
know what options may be limited, but is there a way I can determine what
source IP, subnet, whatever my Azure hosted site will attempt to call my
web services from?
Thanks!
Im building out an Azure hosted website, but it needs to reach into our
home office to connect to some internally hosted web services. Our
firewall is setup to only allow traffic over certain IP's, so we're
looking to determine what IP range we need to allow access to.
Currently I'm still using the MSDN "Free" Azure subscription, so I don't
know what options may be limited, but is there a way I can determine what
source IP, subnet, whatever my Azure hosted site will attempt to call my
web services from?
Thanks!
how to make search tool through MySQL db for received string from user?
how to make search tool through MySQL db for received string from user?
there is a database item with fields "name","surname","biography" can
someone suggest me so how can i look for and retrieve matched(SQL script)
? if someone has attend for example the "ComputerScience" class which is
somewhere in biography field so if user types "com" on search bar and hits
enter the string should be looked for through whole db and bring out only
matched db parts, in this case the name,surname,biography of matched
item..
there is a database item with fields "name","surname","biography" can
someone suggest me so how can i look for and retrieve matched(SQL script)
? if someone has attend for example the "ComputerScience" class which is
somewhere in biography field so if user types "com" on search bar and hits
enter the string should be looked for through whole db and bring out only
matched db parts, in this case the name,surname,biography of matched
item..
Link color in Firefox
Link color in Firefox
I'm changing the color of the link in a web page. The css: a:link,
a:visited, a:active { color:#009900 !important; text-decoration:none; }
a:hover {
background-color:#009900;
color:#ffffff !important;
text-decoration:none;
}
.lemmas a:link, a:visited, a:active {
color:#014e68 !important;
text-decoration:none;
}
.lemmas a:hover {
background-color:#014e68;
color:#ffffff !important;
text-decoration:none;
}
.feel a:link, a:visited, a:active {
color:#ff3300;
text-decoration:none;
}
.feel a:hover {
background-color:#ff3300;
color:#ffffff !important;
text-decoration:none;
}
The link are colored only with the last color the one assigned to the
class feel in firefox. In explorer the colors are shown perfectly. Do you
know where is the problem? Thanks
I'm changing the color of the link in a web page. The css: a:link,
a:visited, a:active { color:#009900 !important; text-decoration:none; }
a:hover {
background-color:#009900;
color:#ffffff !important;
text-decoration:none;
}
.lemmas a:link, a:visited, a:active {
color:#014e68 !important;
text-decoration:none;
}
.lemmas a:hover {
background-color:#014e68;
color:#ffffff !important;
text-decoration:none;
}
.feel a:link, a:visited, a:active {
color:#ff3300;
text-decoration:none;
}
.feel a:hover {
background-color:#ff3300;
color:#ffffff !important;
text-decoration:none;
}
The link are colored only with the last color the one assigned to the
class feel in firefox. In explorer the colors are shown perfectly. Do you
know where is the problem? Thanks
Monday, 19 August 2013
How to implement offline mode on android
How to implement offline mode on android
We load lots of data as JSON objects to some arrays in our application and
this is handled while online. but now we would like to move to some kind
of caching, how can we implement off line mode with Android?, is there an
external storage I can write to?, there could be thousands of records.
We load lots of data as JSON objects to some arrays in our application and
this is handled while online. but now we would like to move to some kind
of caching, how can we implement off line mode with Android?, is there an
external storage I can write to?, there could be thousands of records.
Insight Into System CPU Usage
Insight Into System CPU Usage
We've noticed that top doesn't give much insight into sys CPU usage. It
only appears to give CPU percentages for user.
Are there any tools out there that give more insight into System CPU usage?
We've noticed that top doesn't give much insight into sys CPU usage. It
only appears to give CPU percentages for user.
Are there any tools out there that give more insight into System CPU usage?
Hiding and revealing form field submission output
Hiding and revealing form field submission output
I'm a first time asker, and I'm still unclear on a lot of the language on
all sides of programming, so please excuse the simple minded nature of my
question:
I have a form with three fields:
<form method="get">
<div class="bday_forms">
<label for="first_name">What is your first name?</label>
<input id="first_name" name="first">
<br/>
<label for="last_name">What is your last name?</label>
<input id="last_name" name="last">
<br/>
<label for="your_bday">When is your birthday?</label>
<input id="your_bday" name="bday">
</div>
<div class="bday_button">
<button class="btn btn-default" type="submit">Gimme</button>
</div>
</form>
Simple enough. Following is the following "output div", which prints out
the above form fields after submission:
<div>
<%= params["first"]%> <%= params["last"]%> was born on <%=
params["bday"]%>.
</div>
What I want to do now is hide the whole "output div" above if the fields
have not been filled and submitted, and to reveal it once they have.
I think this mean I need to use an if/else/end command and boolean
true/false values. Help, please! Thanks
I'm a first time asker, and I'm still unclear on a lot of the language on
all sides of programming, so please excuse the simple minded nature of my
question:
I have a form with three fields:
<form method="get">
<div class="bday_forms">
<label for="first_name">What is your first name?</label>
<input id="first_name" name="first">
<br/>
<label for="last_name">What is your last name?</label>
<input id="last_name" name="last">
<br/>
<label for="your_bday">When is your birthday?</label>
<input id="your_bday" name="bday">
</div>
<div class="bday_button">
<button class="btn btn-default" type="submit">Gimme</button>
</div>
</form>
Simple enough. Following is the following "output div", which prints out
the above form fields after submission:
<div>
<%= params["first"]%> <%= params["last"]%> was born on <%=
params["bday"]%>.
</div>
What I want to do now is hide the whole "output div" above if the fields
have not been filled and submitted, and to reveal it once they have.
I think this mean I need to use an if/else/end command and boolean
true/false values. Help, please! Thanks
How to remove the extra column while freezing in jxl api?
How to remove the extra column while freezing in jxl api?
Using jxl, I'm trying to do both horizontal and vertical freeze
sheet.getSettings().setVerticalFreeze(7);
sheet.getSettings().setHorizontalFreeze(1);
The horizontal one is fine, but the vertical one adds an extra column
(narrow column). Not only that - if I open up the excel file, unfreeze all
columns, and try to freeze again manually, it adds the extra column again
!! Something gets messed up, while the file is generated.
Any idea how to fix this?
I'm on Mac, and using MS office on mac
Using jxl, I'm trying to do both horizontal and vertical freeze
sheet.getSettings().setVerticalFreeze(7);
sheet.getSettings().setHorizontalFreeze(1);
The horizontal one is fine, but the vertical one adds an extra column
(narrow column). Not only that - if I open up the excel file, unfreeze all
columns, and try to freeze again manually, it adds the extra column again
!! Something gets messed up, while the file is generated.
Any idea how to fix this?
I'm on Mac, and using MS office on mac
Sunday, 18 August 2013
Invoking Secure windows service i.e. .asmx webservice from Java
Invoking Secure windows service i.e. .asmx webservice from Java
I have a webservice whose url is something like this:
http://pc212323/AdminService/HelloWorldService.asmx?wsdl
Now when i hit this service from soapUI it asks for Username, Password in
a saperate popup window. This is done before soapUI loads the request
structure. Again then i have to pass Username and password in the Request
Properties present on the left of SoapUI tool. Then it gives me the
output.
Now i want to hit this asmx sevice through java but am unable to figure
out how to invoke this service by passing username and password.
In short i want to replicate this behaviour of soapUI through java code
Looking forward to your answers. Thanks in advance.
I am invoking the above service with this code of mine:
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
public class HelloWorldSecurity {
public static void main(String[] args) {
HelloWorldSecurity helloWorldSecurity =
new HelloWorldSecurity ();
helloWorldSecurity.service_code();
}
public ServiceClient configuration()
{
System.out.println("configuration");
ServiceClient stClient = null;
try{
org.apache.axis2.context.ConfigurationContext
configurationContext =
org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,null);
MultiThreadedHttpConnectionManager
multiThreadedHttpConnectionManager
= new
MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams
params = new
HttpConnectionManagerParams();
params.setDefaultMaxConnectionsPerHost(2);
multiThreadedHttpConnectionManager.setParams(params);
HttpClient httpClient =
new
HttpClient(multiThreadedHttpConnectionManager);
configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT,httpClient);
stClient = new
ServiceClient(configurationContext
, null);
Options options = new
Options();
EndpointReference
targetEPR = new
EndpointReference("http://pc212323/AdminService/HelloWorldService.asmx");
options.setTo(targetEPR);
options.setAction("http://tempuri.org/HelloWorld");
options.setUserName("kevin");
options.setPassword("password-1");
stClient.setOptions(options);
}
catch(Exception e)
{
e.printStackTrace();
}
return stClient;
}
public void service_code(){
OMFactory fac =
OMAbstractFactory.getOMFactory();
OMNamespace ns =
fac.createOMNamespace("http://tempuri.org",
"ns1");
OMElement result = null;
OMElement PayloadElement =
fac.createOMElement("HelloWorld", ns);
ServiceClient client = configuration();
try {
result =
client.sendReceive(PayloadElement);
} catch (AxisFault e) {
e.printStackTrace();
}
}
}
But i am getting error as:
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at
org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:310)
at
org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:194)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at
org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:555)
at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:531)
at HelloWorldSecurity.service_code(HelloWorldSecurity.java:63)
at HelloWorldSecurity.main(HelloWorldSecurity.java:22)
I have a webservice whose url is something like this:
http://pc212323/AdminService/HelloWorldService.asmx?wsdl
Now when i hit this service from soapUI it asks for Username, Password in
a saperate popup window. This is done before soapUI loads the request
structure. Again then i have to pass Username and password in the Request
Properties present on the left of SoapUI tool. Then it gives me the
output.
Now i want to hit this asmx sevice through java but am unable to figure
out how to invoke this service by passing username and password.
In short i want to replicate this behaviour of soapUI through java code
Looking forward to your answers. Thanks in advance.
I am invoking the above service with this code of mine:
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
public class HelloWorldSecurity {
public static void main(String[] args) {
HelloWorldSecurity helloWorldSecurity =
new HelloWorldSecurity ();
helloWorldSecurity.service_code();
}
public ServiceClient configuration()
{
System.out.println("configuration");
ServiceClient stClient = null;
try{
org.apache.axis2.context.ConfigurationContext
configurationContext =
org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,null);
MultiThreadedHttpConnectionManager
multiThreadedHttpConnectionManager
= new
MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams
params = new
HttpConnectionManagerParams();
params.setDefaultMaxConnectionsPerHost(2);
multiThreadedHttpConnectionManager.setParams(params);
HttpClient httpClient =
new
HttpClient(multiThreadedHttpConnectionManager);
configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT,httpClient);
stClient = new
ServiceClient(configurationContext
, null);
Options options = new
Options();
EndpointReference
targetEPR = new
EndpointReference("http://pc212323/AdminService/HelloWorldService.asmx");
options.setTo(targetEPR);
options.setAction("http://tempuri.org/HelloWorld");
options.setUserName("kevin");
options.setPassword("password-1");
stClient.setOptions(options);
}
catch(Exception e)
{
e.printStackTrace();
}
return stClient;
}
public void service_code(){
OMFactory fac =
OMAbstractFactory.getOMFactory();
OMNamespace ns =
fac.createOMNamespace("http://tempuri.org",
"ns1");
OMElement result = null;
OMElement PayloadElement =
fac.createOMElement("HelloWorld", ns);
ServiceClient client = configuration();
try {
result =
client.sendReceive(PayloadElement);
} catch (AxisFault e) {
e.printStackTrace();
}
}
}
But i am getting error as:
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at
org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:310)
at
org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:194)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at
org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:555)
at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:531)
at HelloWorldSecurity.service_code(HelloWorldSecurity.java:63)
at HelloWorldSecurity.main(HelloWorldSecurity.java:22)
Subscribe to:
Comments (Atom)