Saturday 31 August 2013

how to retrieve the orderID from custom list view in Android

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": "" } ] }

Is there a Maven plugin to fetch an rpm

Is there a Maven plugin to fetch an rpm

Folks,
As part of my current procedure,I have to do a Linux package fetch,
followed by a Maven build.
Is there a Maven plugin to fetch a Linux package ( rpm -i xxx or apt-get
install xxx )
maven-exec-plugin enables this. but is there a more specialized plugin
that wraps data on top?
Note : - maven-rpm-plugin and maven-apt-plugin seem to allow you to create
rpm packages, not to fetch them
Thanks, - Ranjan

Can mysql import a csv or other txt file into one column?

Can mysql import a csv or other txt file into one column?

In mysql we can import data files -
load data infile 'file.txt'
into table `text`
fields terminated ' '
lines terminated '\n'
My question is can we import a file with unknown columns all into one
column? Or possibly can we create columns that we need on the fly?

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)

CYGWIN INSTALLATION of packages for windows

CYGWIN INSTALLATION of packages for windows

I am using windows and all the Cygwin mirror sites are downloading tar.bz2
files for the required packages. Will it run that way or should I select
another mirror site which has .zip files?? Thanks in Advance

Using a rails scope query in a controller

Using a rails scope query in a controller

I'm working on my first rails project, and I'm having trouble getting my
query to work correctly. My overall goal is to setup a collection of
scopes to create some long queries with multiple options. However, to
start with, I'm just trying to set up a single scope, to query a single
column from a single model. Here is my model:
class Drawing < ActiveRecord::Base
has_many :revisions
scope :by_description, lambda { |description| where(description:
description) unless description.nil? }
end
Here is the index action of my controller:
def index
@drawings = Drawing.by_description(params[:description]).all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @drawings }
end
end
And the view is the default index view for rails.
When I enter an input into the search field, for example "Case", the
submit button works and directs me to the index view, but all of the
"Drawings" are listed, instead of just the ones that have "Case" as their
description. Thanks so much for your help.

PHP Issue in Twitter API Caching Script

PHP Issue in Twitter API Caching Script

I admit I am a level below functional retardation when it comes to code
development of any sort. I'm trying to create a script that calls the
Twitter API and caches responses. I can call the API and get data without
issue, I can write it to a file too, and I can call the file to display
the info.
However, every time this piece of code is called, it results in a hit to
Twitter's API gateway. I can tell by reading the responses from a shell
window; this is on a busy site and I see the number of available
transactions decrease quickly when the script is made live.
Why isn't it delivering just info from the file, and running $tweets
everytime?
<?php
session_start();
require_once('/home/user/public_html/twitter_api/twitteroauth.php');
//Path to twitteroauth library
$twitteruser = "username";
$notweets = 3;
$consumerkey = "xyz";
$consumersecret = "xyz";
$accesstoken = "xyz";
$accesstokensecret = "xyz";
function getConnectionWithAccessToken($cons_key, $cons_secret,
$oauth_token, $oauth_token_secret) {
$connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token,
$oauth_token_secret);
return $connection;
}
$connection = getConnectionWithAccessToken($consumerkey, $consumersecret,
$accesstoken, $accesstokensecret);
$tweets =
$connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser."&count=".$notweets);
$file = '/home/user/public_html/twitter_api/twitter_cache.data';
$cache_life = '900';
$filemtime = @filemtime($file);
if (!$filemtime or (time() - $filemtime >= $cache_life)){
$fh = fopen($file, 'w') or die("can't open file");
fwrite($fh, serialize($tweets));
fclose($fh);
}
else
{
$twitter_result =
unserialize(file_get_contents('/home/user/public_html/twitter_api/twitter_cache.data'));
foreach ($twitter_result as $item) {
echo '<a href="http://twitter.com/username" target="_blank"
style="font-size:12px;">'.$item->text.'</a><br /><br />';
}
echo '<h5><a href="http://twitter.com/username" target="_blank"
class="tw">Follow On Twitter</a></h5>';
}
?>

Golang/App Engine - securely hashing a user's password

Golang/App Engine - securely hashing a user's password

I have typically used the bcrypt library to do password hashing, but am
unable to do so because of the libraries use of "syscall." I have also
tried scrypt. What other ways are secure, and which would be the best way?

Friday 30 August 2013

java regex what the heck? am I misreading the regex docs completey?

java regex what the heck? am I misreading the regex docs completey?

System.out.println("a".matches("^[A-Za-z]+"));
System.out.println("a ".matches("^[A-Za-z]+"));
This gives me:
true
false
What the heck is up? As far as I am reading it, "[A-Za-z]" includes "a",
and "+" means one or more, so this seems like it would work, at least in
this universe....
Details are:
Mac OS X 10.8.4
$ java -version
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)
Maybe I have been writing perl too long and java's regex system is kind of
like it but not? No idea.

I'm in a video image smoke detection

I'm in a video image smoke detection

This code must detect smoke in the video, will activate the warning
system, but the problem is that all the videos warns, even those who do
not smoke. Can someone help me to fix it?
vid=uigetfile;
vid=mmreader(vid);
numFrames = vid.NumberOfFrames;
n=numFrames;
for i =1:n
frames = read(vid,i);
imwrite(frames,[int2str(i) '.jpg']);
end
frm1=rgb2gray(imread('1.jpg'));
for j=1:n
frm2=([num2str(j),'.jpg']);
p1=(imread(frm2,'jpg'));
p2=(rgb2gray(p1));
res=abs(double(p2)-double(frm1));
astn=get(handles.edt,'string');
astn=str2num(astn);
ast=res<astn;
bw=bwareaopen(ast,500);
R=p1(:,:,1);
G=p1(:,:,2);
B=p1(:,:,3);
xr=R(bw);
r=mean(xr);
xg=G(bw);
g=mean(xg);
xb=B(bw);
b=mean(xb);
avg=(r+b+g);
S=(abs(r-avg)+abs(b-avg)+abs(g-avg))/3;
if (S>200)
set(handles.text1,'visible','on');
beep
subplot(211)
h1 = image;
axis ij
imshow(p1,h1);
pause(0.5);
set(handles.text1,'visible','off');
pause(0.5);
end;
end

Thursday 29 August 2013

Comparing strings to a dictionary in groups of multiples of 3

Comparing strings to a dictionary in groups of multiples of 3

I am writing a program which reads in a number of DNA characters (which is
always divisible by 3) and checks if they correspond to the same amino
acid. For example AAT and AAC both correspond to N so my program should
print "It's the same". It does this fine but i just don't know how to
compare 6/9/12/any multiple of 3 and see if the definitions are the same.
For example:
AAAAACAAG
AAAAACAAA
Should return me It's the same as they are both KNK.
This is my code:
sequence = {}
d = 0
for line in open('codon_amino.txt'):
pattern, character = line.split()
sequence[pattern] = character
a = input('Enter original DNA: ')
b = input('Enter patient DNA: ')
for i in range(len(a)):
if sequence[a] == sequence[b]:
d = d + 0
else:
d = d + 1
if d == 0:
print('It\'s the same')
else:
print('Mutated!')
And the structure of my codon_amino.txt is structured like:
AAA K
AAC N
AAG K
AAT N
ACA T
ACC T
ACG T
ACT T
How do i compare the DNA structures in patters of 3? I have it working for
strings which are 3 letters long but it returns an error for anything
more.
EDIT:
If i knew how to split a and b into a list which was in intervals of three
that might help so like:
a2 = a.split(SPLITINTOINTERVALSOFTHREE)
then i could easily use a for loop to iterate through them, but how do i
split them in the first place?

Wednesday 28 August 2013

Is it possible to group Plone portlet fields into fieldsets?

Is it possible to group Plone portlet fields into fieldsets?

I have a very long portlet edit screen so I'd like to group its fields
using fieldsets (and then probably layouting those into native form tabs,
like those used in content's edit view).
Is this possible with zope.formlib?

Embedded YouTube videos without hidden controls until clicking on the video

Embedded YouTube videos without hidden controls until clicking on the video

I'd like to display embedded YouTube videos with the controls hidden by
default, and when the user clicks on the video, controls appear. Just as
the videos on this page.
In Google documentation pages I found how to hide controls altogether, but
not in this way. And using Firebug while visiting this page I can't see
any options used in the iframe code that relates to controls.
So how to do that?

Can't loading CSS images in JSF

Can't loading CSS images in JSF

Description : In my JSF application, i am setting the menu background
images through CSS property.
i configured the file structure as follows
This is my CSS code
Style.css
#menu
{
height:35px;
width:950px;
background:url(images/default.gif);
/*background:url(#{resource['images:default.gif']});
background:url(#{resource['images/default.gif']});
*/
}
and this CSS file is under /resources/css directory, and i am importing
the css file in xhtml page using
<h:head>
<h:outputStylesheet library="css" name="style.css"></h:outputStylesheet>
</h:head>
There is no problem in importing CSS file
Problem description
I mapped the FacesServlet on *.xhtml:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
If i run the home page , the menu images which is configured in css is not
loading
When i remove the FacesServlet mapped configuration on *.xhtml the images
are is loading perfectly
i have tried
I have tried the following methods in css file to load an image
background:url(images/default.gif);
background:url(#{resource['images:default.gif']});
background:url(#{resource['images/default.gif']});
Added Resource handler in faces-config.xml
<application>
<resource-handler>org.omnifaces.resourcehandler.UnmappedResourceHandler</resource-handler>
But i couldn't find the solution yet...!!!

Tuesday 27 August 2013

Asynctask vs Thread in android

Asynctask vs Thread in android

In UI I want to do some background work.For that i use separate thread.But
i suggested by other do it in asynctask.What is the main difference
between Asynctask and Thread,in which scenario i've to use Thread and
Asynctask?.

Increase load test over time

Increase load test over time

I would like to test the load of my App Engine App.
From the load test google recommendation. Query per second should increase
gradually.

So I would like to add 1 connection every second to my load test. How can
I do that? I search for AB (Apache Benchmark) and JMeter without success.
Maybe my question is very basic, but as I'm not use to load testing I
don't google it properly.
Thanks.

Heroku RoR 3.2 ignoring http put request

Heroku RoR 3.2 ignoring http put request

Hello all I built a website with RoR 3.2 and hosted it for free on heroku
:)! This website receives http put request from client side applications
that update the database every 60 seconds. I am seeing an issue where the
first few(2-10) http put request come through to heroku just fine but then
they randomly stop. I have checked my client app and it is still sending
the http put requests but I no longer see them in the heroku logs of the
application. I was wondering if maybe heroku has doesn't like me sending
put request so frequently and is blocking me? Thanks for the help!

Size of scaled image in iOS

Size of scaled image in iOS

How can I get a size(either width or height) of an scaled image in
objective-C? Provide with a sample code. Also, I have tried the following
but its not working,
Width : self.object.position.x * scaleFactor;

gets.chomp method excercise in learn to program book

gets.chomp method excercise in learn to program book

I'm new to programming/Ruby. I am doing excercise 5.6 out of "Learn to
Program" for a class. I have the following:
puts 'What\'s your first name?'
first = gets.chomp
puts 'What\'s your middle name?'
middle = gets.chomp
puts 'What\'s your last name?'
last = gets.chomp
puts 'Hello, Nice to meet you first middle last'
And I have tried the following:
puts 'What is your first name?'
first = gets.chomp
puts 'What is your middle name?'
middle = gets.chomp
puts 'What is your last name?'
last = gets.chomp
puts 'Hello, Nice to meet you #{first} #{middle} #{last}'
When I get the last "puts" it won't get the first, middle and last name
that I wrote in. It says, "Hello, nice to meet you first, middle,
last....Instead of Joe John Smith for example. What am I doing wrong?
Thank you so much for your help! I really appreciate it!

javascript how to document.evaluate() with @contains one value and not @contains 2nd value

javascript how to document.evaluate() with @contains one value and not
@contains 2nd value

I need to use evaluate() to get containing "images/" in src and at the
same time not containing window.location.hostname in the src, I know
evaluate supports "and" & "or" operators, but "not" does not seem to be
supported, how can this be done?
'.//img[contains(@src,"images/") and not
contains(@src,window.location.hostname)]'

Monday 26 August 2013

htaccess URL redirection - Want to remove a word from URL

htaccess URL redirection - Want to remove a word from URL

I want to redirect some URLs to different URL. For instance
http://www.mydomain.com/some-text-2-rss/
http://www.mydomain.com/another-text-rss
http://www.mydomain.com/sample-rss/
http://www.mydomain.com/dummy-content-rss
http://www.mydomain.com/some-folder-1/my-text-rss
http://www.mydomain.com/another-folder/some-text-rss/
TO
http://www.mydomain.com/some-text-2/
http://www.mydomain.com/another-text
http://www.mydomain.com/sample/
http://www.mydomain.com/dummy-content
http://www.mydomain.com/some-folder-1/my-text
http://www.mydomain.com/another-folder/some-text/
i.e if any URL's ending is '-rss' or '-rss/', i want to remove '-rss' from
the URL.
Thanks in Advance.

Boot-repair doesn't work

Boot-repair doesn't work

I am a new user, and I may have completely screwed up my computer trying
to install Ubuntu 13.04. I'm working from a liveUSB, and I'm pretty sure I
accidentally uninstalled Windows 8 (which is what my computer came with -
now the computer doesn't recognize any boot device without the USB
inserted), and now the computer simply won't boot. When I start the
computer with the liveUSB inserted, I am taken to a page headed "GNU GRUB
version 2.00-13ubuntu3", which allows me to select "Try Ubuntu without
installing" or "Install Ubuntu," and I've already installed it - if I try
to install again, it gives me the option of installing alongside Ubuntu
13.04 or replacing it, so I am pretty sure it installed the first time but
it just won't boot. I then used Try Ubuntu and followed the instructions
under 2nd Option on this page:
https://help.ubuntu.com/community/Boot-Repair
I tried rebooting, and it didn't work - I just went back to the "GNU GRUB
version 2.00-13ubuntu3" menu once again. The url from my boot-repair
attempt is http://paste.ubuntu.com/6030961
I know this is very chaotic, and I am in way over my head, so any
help/advice would be much appreciated!

Future of Android [on hold]

Future of Android [on hold]

What is the future of Android, and the opportunities for developers and
challenges in the near future? What is the advantage it holds upon the
other formats available in the market now.

How to include php-generated javascript?

How to include php-generated javascript?

I've looked around and have found no great solution so far: I would like
to add customized javascript from a widget using wp_enqueue_script, but
Wordpress seems to be limiting scope to the javascript file I load in, as
my javascript file says:
Uncaught TypeError: Object [object Object] has no method 'photogallery'
Here is the output I would like to load in, as if it were its own script
via wp_enqueue_script:
<script type = "text/javascript">
(function ($) {
"use strict";
$(function () {
var $gallery = $("#gallery").photogallery(
"a",
{
thumbs: <?php echo
setBool($instance["hasThumbs"]); ?>,
history: <?php echo
setBool($instance["historyEnabled"]); ?>,
time: <?php echo
($instance["transitionTime"] * 1000); ?>,
autoplay: <?php echo
setBool($instance["autoplayEnabled"]); ?>,
loop: <?php echo
setBool($instance["isLooped"]); ?>,
counter: <?php echo
setBool($instance["hasCounter"]); ?>,
zoomable: <?php echo
setBool($instance["zoomable"]); ?>,
hideFlash: <?php echo
setBool($instance["hideFlash"]); ?>
}
);
});
}(jQuery));
</script>
I know that manually coding the default values in to another js file, and
using enqueue_script will work fine, but how do I do this properly, with
custom widget values, and not load the required js file twice? I am not
interested in complex ajax requests unless it is my only option, as
mentioned here.
Thanks in advance.

What exactly defines a Main Loop and a Secondary Loop?

What exactly defines a Main Loop and a Secondary Loop?

My assumption is that the main loop is always the first loop and you're
always supposed to use query_post? Is this correct? Then whenever you you
need to feed in some arguments to get a different set or order of posts
you use WP_Query or get_posts. These would both be secondary loops? I just
feel I'm hardly interacting with the Main Loop at all so I have this
feeling, whilst everything works, I'm just not doing things properly.

Turbo C++: Why does printf print expected values=?iso-8859-1?Q?=2C_when_no_variables_are_passed_to_it=3F_=96_stackoverflo?=w.com

Turbo C++: Why does printf print expected values, when no variables are
passed to it? – stackoverflow.com

A question was asked in a multiple choice test: What will be the output of
the following program: #include <stdio.h> int main(void) { int a = 10, b =
5, c = 2; printf("%d %d %d\n"); …

JAVASCRIPT: OK button proceed to another .php form

JAVASCRIPT: OK button proceed to another .php form

I have a basic javascript code for my saving entry.
Scenario:
I have two forms, the first form,[view_netbldg.php], is for my data entry
then when the user click the "ADD" button it will proceed to the next form
[save_netbldg.php]. So in my save_netbldg.php form there is a if else
condition where the code will know first if the variable of $bldgName or
$netName are empty. Everything is okay, but my concern is this when the
code detect either of the two variables are empty the code below I'm using
will be executed.
Here's my code:
if($bldgName == "" || $netName == "")
{
echo "<script type='text/javascript'>\n";
echo "alert('Please complete the fields for Building Name or Network
Name');\n";
echo "</script>";
header("location:view_netbdlg.php");
}
*The result of the program is, its not displaying the alert instead it
will jump to the header
The correct way is, if the $bldgName == "" || $netName == "" == true** an
alert will display and when the user click the ok button it will proceed
to the next form which is "view_netbdlg.php". I don't need a confirmation
message here because its only an error message something like that.
Advance thank you.

Sunday 25 August 2013

ncurses' printw() doesn't work

ncurses' printw() doesn't work

i filled a matrix with strings from a file, that printf() see correctly,
but printw() doesn't seem to agree with the rest of the code. it works
with normal strings, but with strings from that matrix, it doesn't work.
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ncurses.h>
int main (int argc, char const *argv[])
{
char** matrice = malloc(sizeof(char*)*51);
size_t nbytes;
int i = 0, j = 0;
FILE* lab = fopen(argv[1], "r");
while((getline(&matrice[i], &nbytes, lab) != -1))
{
i++;
}
printf("%s", matrice[0]);
getchar();
initscr(); /* Start curses mode */
cbreak(); /* Line buffering disabled */
keypad(stdscr, TRUE); /* We get F1, F2 etc.. */
noecho(); /* Don't echo() while we do getch */
printw(matrice[0]);
printw("dummy line"\n);
refresh();
getch();
endwin();
return EXIT_SUCCESS;
}

Remove second row caused by WITH ROLLUP

Remove second row caused by WITH ROLLUP

I need to remove the 2nd row of results which contain a duplicate of the
total record from the 1st row. My result set is as follows
1 | 1025
1 | NULL --- I need to remove this row
My query is as follows:
SELECT SUM( mdl_quiz.fcpd ) AS cpdtotal, mdl_user.id AS userid
FROM mdl_grade_grades
INNER JOIN mdl_user ON mdl_grade_grades.userid = mdl_user.id
INNER JOIN mdl_grade_items ON mdl_grade_grades.itemid = mdl_grade_items.id
INNER JOIN mdl_quiz ON mdl_grade_items.itemname = mdl_quiz.name
INNER JOIN mdl_course ON mdl_grade_items.courseid = mdl_course.id
INNER JOIN mdl_user_info_data ON mdl_user.id = mdl_user_info_data.userid
WHERE mdl_user_info_data.fieldid =1
AND mdl_grade_items.itemname IS NOT NULL
AND mdl_user.annualCPDReportActive = 'Y'
AND (
mdl_course.category =27
)
AND mdl_user.id =1025
AND YEAR( FROM_UNIXTIME( mdl_grade_grades.timemodified ) ) =2013
GROUP BY mdl_user.id
WITH ROLLUP

what's the best library to display 3d stuff in C#?

what's the best library to display 3d stuff in C#?

Say I have an array of point coordinates in a 3d space, like
point1 x=5, y=10, z=15
point2 x=1, y=25, z=3
... and so on.
And I need to show them in a sort of a 3d environment, where the user
would be able to zoom in, pan and rotate, in a winform.
I haven't done 3d in c# before, so I wanted to ask what's the
method/library of choice for that?
Thanks

Saturday 24 August 2013

Headers disappear when stuck in StickyListHeadersListView

Headers disappear when stuck in StickyListHeadersListView

The headers in my StickyListHeadersListView disappear (it seems to become
transparent) when stuck at the top of the list on my Samsung Galaxy with
2.3.3. They're displayed correctly on Nexus 4 with 4.3.
Anybody can help?
No scroll:

After scrolling, the stuck header becomes transparent (or black):

A simple way to "bundle" .htm files containing x-jquery-tmpl templates?

A simple way to "bundle" .htm files containing x-jquery-tmpl templates?

My application performs a $.get of a half-dozen .htm files containing
x-jquery-tmpl templates. I organized those .htm files based on areas of
responsibility, which saved me from any scrolling-induced carpal tunnel
during development.
I'm wondering if there's a way to "bundle" these .htm files at compile
time, similar to the script/CSS bundling in MVC, such that it's only one
HTTP request at runtime but still convenient for me to manage them?

Full Width - Normal Height BG Img

Full Width - Normal Height BG Img

So I have been over and over all the pages on google looking for some code
that will help me fix my stretch width background image. I'm looking to
make my background image fit all browser resolutions width, the height
must remain the height it is on the image.
So far my code has given me a full width background but didn't stretch the
image so its full width but the image didn't budge.
body{
background-color:#575c70;
background: url('http://i.imgur.com/1MS4u4y.jpg');
height: auto;
width: 100%;
left: 0;
background-repeat: no-repeat;
position: absolute;
}

Why does frozen spinach have so much less iron than fresh spinach?

Why does frozen spinach have so much less iron than fresh spinach?

I have been trying to increase my iron intake and was dismayed to learn
that my frozen spinach only has 2% of my daily iron needs while fresh
cooked spinach has about 20%. I have been under the impression that
freezing vegetables preserves their nutrients from the moment they are
picked/frozen and that transporting fresh vegetables across the country
depletes the nutrients.
There was a whole about this some time ago either on TV or the internet or
someplace.
So when I read the back of my frozen spinach container I was really
surprised to find that it only has 2% of what I need.
Why is this? Is there a difference between the kinds of spinach that are
grown for canning/fresh/frozen? Does freezing break something in the case
of spinach? Does this happen with all fresh green leafy vegetables?
Thank you for your time.

Multidimensional Array structure to PHP HTML output?

Multidimensional Array structure to PHP HTML output?

I have repeated sections in my web site.
I'm trying to decrease them,
My approach is one time i will create a html schema (predefined as array),
via this schema my function undestranding that what kind of output user
needs and outputs results according to my variables..
My problem is I could not find a way to complete situation..
Input variables might be (infinitive)
$vals = array('Country Name' => 'USA', 'Country Name' => 'Canada',
'Country Name' => 'Mexico');
$vals = array('Country Name' => 'USA', 'Country Name' => 'Canada');
$vals = array('Country Name' => 'USA');
Expected outputs are in order
<div class="lines">
<div><span>Country Name</span>USA</div>
<div><span>Country Name</span>Canada</div>
<div><span>Country Name</span>Mexico</div>
</div>
<div class="lines">
<div><span>Country Name</span>USA</div>
<div><span>Country Name</span>Canada</div>
</div>
<div class="lines">
<div><span>Country Name</span>USA</div>
</div>
Schema is the variables that is totally suitable with html
$schema = array(
array(
'tag' => 'div',
'class' => 'lines',
array(
'tag' => 'div',
array(
'tag' => 'span',
'key' => '$key'
),
'key' => '$key'
),
)
);
My function creates outputs from this schema. (Schema might be expand
accordings to user need.)
function get_output($schema, $vals, $t = -1){
$t++;
$tag = "";
$atts = array();
$keys = array();
$code = array();
foreach($schema as $k => $v){
if(is_array($v)){
$keys[] = get_output($v, $vals, $t);
} else {
switch($k){
case "tag": $tag = $v; break;
case "key": break;
case "type": break;
default: $atts[$k] = $v; break;
}
}
}
//echo $t;
//$code[] = str_repeat("\t", $t);
if($tag){
$code[] = "<$tag"; foreach($atts as $k=>$v){ $code[] = '
'.$k.'="'.urlencode($v).'"'; } $code[] = ">";
$code = array(implode('', $code));
}
foreach($keys as $k){ $code[] = $k; }
if($tag){
//$code[] = "\n".str_repeat("\t", $t);
$code[] = '</'.$tag.'>';
}
//print_r($code);
return implode("", $code);
}
After all this process I will just call my function with the variables.,
Schema predefined once.
$vals = array('Country Name' => 'USA', 'Country Name' => 'Canada',
'Country Name' => 'Mexico');
echo get_output($schema, $vals, -1);

How to manage pair- programming code check in user identification?

How to manage pair- programming code check in user identification?

How do you identify users when a programming pair checks in code? I heard
a complaint that, often a junior dev will be at the keyboard, using
his/her account, but is not going to be the best person to ask questions
about the code being checked in (the more senior dev is likely to have the
best answer).
Is this really a problem? Seems like a programming team could think of
some way to identify pairs and get the necessary information in their
version control software.
I also think they're not benefiting from this process if both programmers
don't know what their code does.

Friday 23 August 2013

(Russia) Diophantine equation involving prime numbers

(Russia) Diophantine equation involving prime numbers

Find all pairs of prime nummbers $p,q$ such that $p^3 - q^5 = (p+q)^2$.
It's obvious that $p>q$ and $q=2$ doesn't work, then both $p,q$ are odd.
Assuming $p = q + 2k$ we conclude, by the equation, that $k|q^3 - q - 4$
because $\gcd(k,q)=1$ (else $p$ is not prime) and $k=1$ has no solution.
I also tried to use some modules, but I couldn't.

Removing even elements from a list

Removing even elements from a list

How can we remove even elements from a list of integers?
List dropEven(List l, int n) {
List to_return = nil();
while(true) {
if(l.isEmpty()) return to_return;
if(n==0) l.remove(n);
Integer i = (Integer)(hd(l));
to_return=append1(to_return,hd(l));
n= n-1;
l=tl(l);

Autofill with variable number of rows

Autofill with variable number of rows

I am trying to automate a monthly report where the final autofill is based
on variable number of rows that change monthly with the change in # of
clients. For example: if this month I have 25 clients, I could easily
hardcode that I want to create 25 rows of my report. But in the next month
when I have 30 clients, my code still would say 25 and therefore would
miss five clients.
If anyone has any insight that would be very helpful as I feel like there
should be a way to accomplish this that I am just completely missing on my
own.
Thanks.

Best Package for Sparse Matrix Multiplication

Best Package for Sparse Matrix Multiplication

I am looking for the best package for sparse matrix multiplication on
single core solution. I am not looking for CUDA, MPI or OpenMP solutions.
My preference for languages in decreasing order : Matlab, Python, C/C++.
Matlab has its own matrix multiplication function which can be used for
sparse matrix multiplication. But are there any better package(s)
available ?

Shortcut for if else

Shortcut for if else

What is the shortest way to express the folowing decission rule
df<-data.frame(a=LETTERS[1:5],b=1:5)
index<-df[,"a"]=="F"
if(any(index)){
df$new<-"A"
}else{
df$new<-"B"
}

Keyboard randomly turns off

Keyboard randomly turns off

Sometimes my keyboard stops working, all key presses are ignored and
indicator LEDs turn off as well. After ~10-20 seconds it resumes working.
How can I check what is the reason - software, keyboard, motherboard,
anything else?

Thursday 22 August 2013

((((((((((((( __ READ __ BEFORE ___ DELETED ___ BY ___ MODS ___ ))))))))))))))

((((((((((((( __ READ __ BEFORE ___ DELETED ___ BY ___ MODS ___
))))))))))))))

You are about to be provided with information to
start your own Google.
Some people posted comments and said this can not
be done because google has 1 million servers and we do not.
The truth is, google has those many servers for trolling
purposes (e.g. google +, google finance, youtube the bandwidth consuming
no-profit making web site, etc ).
all for trolling purposes.
if you wanted to start your own search engine...
you need to know few things.
1 : you need to know how beautiful mysql is.
2: you need to not listen to people that tell you to use a framework
with python, and simply use mod-wsgi.
3: you need to cache popular searches when your search engine is running.
3: you need to connect numbers to words. maybe even something like..
numbers to numbers to words.
in other words let's say in the past 24 hours people searched for
some phrases over and over again.. you cache those and assign numbers
to them, this way you are matching numbers with numbers in mysql.
not words with words.
in other words let's say google uses 1/2 their servers for trolling
and 1/2 for search engine.
we need technology and ideas so that you can run a search engine
on 1 or 2 dedicated servers that cost no more than $100/month each.
once you make money, you can begin buying more and more servers.
after you make lots of money.. you probably gonna turn into a troll
too like google inc.
because god is brutal.
god is void-state
it keeps singing you songs when you are sleeping and says
"nothing matters, there is simply no meaning"
but of course to start this search engine, you need a jump start.
if you notice google constantly links to other web sites with a
trackable way when people click on search results.
this means google knows which web sites are becoming popular
are popular, etc. they can see what is rising before it rises.
it's like being able to see the future.
the computer tells them " you better get in touch with this guy
before he becomes rich and becomes un-stopable "
sometimes they send cops onto people. etc.
AMAZON INC however..

will provide you with the top 1 million web sites in the world.
updated daily in a cvs file.
downloadable at alexa.com
simply click on 'top sites' and then you will see the downloadable
file on the right side.
everyday they update it. and it is being given away for free.
google would never do this.
amazon does this.
this list you can use to ensure you show the top sites first in your
search engine .
this makes your search engine look 'credible'
in other words as you start making money, you first display things
in a "Generic" way but at the same time not in a "questionable" way
by displaying them based on "rank"
of course amazon only gives you URLS of the web sites.
you need to grab the title and etc from the web sites.
the truth is, to get started you do not need everything from web sites.
a title and some tags is all you need.
simple.
basic.
functional
will get peoples attention.
i always ask questions on SO but most questions get deleted. here's
something that did not get deleted..
How do I ensure that re.findall() stops at the right place?
use python, skrew php, php is no good.
do not use python frameworks, it's all lies and b.s. use mod-wsgi
use memcache to cache the templates and thus no need for a template engine.

always look at russian dedicated servers, and so on.
do not put your trust in america.
it has all turned into a mafia.

google can file a report, fbi can send cops onto you, and next thing you know
they frame you as a criminal, thug, mentally ill, bipolar, peadophile, and
so on.
all you can do is bleed to death behind bars.
do not give into the lies of AMERICA.
find russian dedicated servers.
i tried signing up with pw-service.com but i couldn't do it due to
restrictions with their russian payment systems and so on..
again, amazon's web site alexa.com provides you with downloadable
top 1 mil web sites in the form of a cvs file.
use it.
again, do not give into python programmers suggesting frameworks for python.
it's all b.s. use mod_wsgi with memcache.
again, american corporations can ruin you with lies and all you can do is
bleed to death behind bars
again, a basic search engine needs : url, title, tags, and popular searches
can be "cached" and words can be connected to "numbers" within the mysql.
mysql has capabilities to cache things as well.
cache once, cache twice, and you will not need 1 million servers in order
to troll.
if you need some xdotool commands to deal with people calling you a troll
here it is;
xdotool key ctrl+c
xdotool key Tab Tab Tab Return
xdotool type '@'
xdotool key ctrl+v
xdotool type --clearmodifiers ', there can not be such thing as a `troll`
unless compared to a stationary point, if you are complaining, you are not
stationary. which means you are the one that is trolling.'
xdotool key Tab Return
create an application launcher on your gnome-panel, and then select the
username in the comments section that called you a 'troll' and click the
shortcut on the gnome-panel.
it will copy the selected username to the clipboard and then hit TAB TAB
TAB RETURN
which opens the comment typing box. and then it will type @ + username +
comma, and then the rest.
...............................................................................................................

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?

MAC crashed - Installing Ubuntu as single boot

MAC crashed - Installing Ubuntu as single boot

My new mac book pro crashed. Yes, I have the warranty & apple guys will
replace the hdd but I do not want this crappy apple now. I am rather
considering setting up ubuntu on this hardware.
I've taken out mac book's original hdd (that crashed) and got a new
external disk. I intend to use this new hdd with ubuntu install in my Mac.
There is no working copy of mac os in the original mac disk now.
I've seen several posts suggesting I can install ubuntu on the disk & I
have already done the install on my new ext disk.
The problem I am facing at the moment is once I take out the Ubuntu
install CD and try to boot the MAC with the new hdd (ubuntu), it doesn't
start up. This new hdd is connected as external disk only (via a usb
connector).
Should I put it inside the MAC instead.?
Are there any issues using Ubuntu as single boot on MAC?
What about MAC firmware updates?
Any points / inputs will be helpful.

CSS/SCSS only works as an inline style in the div, and does not work if I use a class or an id

CSS/SCSS only works as an inline style in the div, and does not work if I
use a class or an id

I have many imported SCSS files for third party plugins which could be the
problem, but essentially if I directly use the style attribute (inline
style) in the div the intended behavior works. But, if I create a class or
even an ID it does not apply to it.
Any suggestions on what to look into or immediate corrections would be
greatly appreciated.
<div class="box" style="margin-left: 50px; margin-right: 50px">
<div class="padded" >
<%= @step.description %>
</div>
</div>
However, when I change the above code to below, and add class to
custom.css.scss - it does not work:
<div class="box description">
<div class="padded" >
<%= @step.description %>
</div>
</div>
.description {
margin-left: 50px;
margin-right: 50px
}

Chaining jQuery promises/deferreds

Chaining jQuery promises/deferreds

I have a process where I have to send an ajax request to the server, but
need to stop a scheduler before the ajax request begins, then restart the
scheduler when the request is done.
I have got this working using the following code:
scheduler.stop()
.done(function () {
setQuestionStatus().done(scheduler.start);
});
But it seems that there should be a simpler way to write this, such as:
scheduler.stop().then(setQuestionStatus).then(scheduler.start);
My problem is that when written this way, setQuestionStatus and
scheduler.start are both called as soon as scheduler.stop has resolved,
rather than after each item in the chain has resolved.
Can anyone tell me what I'm doing wrong in the second example?



For your information, both scheduler.stop and setQuestionStatus return a
promise using the pattern:
var setQuestionStatus = function(){
return $.Deferred(function (def) {
// Do stuff
def.resolve();
}).promise();
}

Wednesday 21 August 2013

tortoiseSVN: got error message when commit file

tortoiseSVN: got error message when commit file

I am using TortoiseSVN to commit a file. But I got bellow error message:
Error post-commit hook failed (exit code 25) with output:
Error An unexpected error has occured. The process at spawn ID exp5 has
produced the following output:
Error yes
Error
Error Failed to add the host to the list of known hosts
(/var/www/.ssh/known_hosts).
Error Password:
what does this mean? and how to fix it?

Automatically create a new row each day, on top of older rows

Automatically create a new row each day, on top of older rows

I am looking for a way to automatically create a new row on top of older
rows each day.
Inside of this row should be the current date.

Failed Running Visual Studio: Cannot find Visual Studio 2012 or later

Failed Running Visual Studio: Cannot find Visual Studio 2012 or later

windows 8 environment folder -> run as -> visual studio project
-everything is built successfully, then these 2 last lines in console:
Application 'app' deployed successfully with environment 'windows8'
Failed Running Visual Studio: Cannot find Visual Studio 2012 or later.
this happens on windows 8 pro, with visual studio for mobile phone
installed...
also there is a .jsproj file in 'windows8/native' folder, shouldn't it be
.csproj ??

How to disable language autodetection in Word style?

How to disable language autodetection in Word style?

I want to make style to type programming code in Word.
Unfortunately, Word tries to guess (human) language and do some other
wrong things.
How to disable? There is an option, but it is dimmed:

How do I change inner HTML of a DIV to the output of a PHP file using jQuery

How do I change inner HTML of a DIV to the output of a PHP file using jQuery

I am learning PHP and jQuery. I have a PHP file called renderPicture.php
that returns a dynamically created image in an HTML IMG tag. I want to
change that image after a click event on my webpage -- without reloading
the page. I know that I need a jQuery Ajax call to renderPicture. And I
know that I need to set the inner HTML of my div to the result of that
jQuery Ajax call. I learned how to set inner HTML here How to replace
innerHTML of a div using jQuery? But I am not quite sure how to do this
with the AJAX call.
How to I set the inner HTML of a DIV to the output of a PHP file using
jQuery?
Here is the jQuery and some of the HTML:
<script>
$(document).ready(function(){
$("#myDIV").click(function(){
//var resultOfAjaxCall = $.ajax({ url: './renderPicture.php',});
$("#myDIV").html(resultOfAjaxCall); //This is roughly what I want
to do
});
});
</script>
</head>
<div id='myDIV'>
<?php
$cryptinstall="./renderPicture.php";
include $cryptinstall;
?>
</div>
</html>
Here is renderpicture.php
<?php
$cryptinstall="./cryptographp.fct.php";
include $cryptinstall;
if(session_id() == "") session_start();
$_SESSION['cryptdir']= dirname($cryptinstall);
$cfg=0;
echo "<img id='cryptogram'
src='".$_SESSION['cryptdir']."/cryptographp.php?cfg=".$cfg."&".SID."'>";
ren
?>

Printing File by using C#

Printing File by using C#

I am developing C# application. In this C# program, i want to add print
button so users may print any document they want by using this button. I
managed to print a txt file by reading it. But if i choose a pdf file
instead, program prints some error codes in result.
private void printButton_Click(object sender, EventArgs e)
{
try
{
streamToPrint = new StreamReader("C:\\test.txt");
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
pd.Print();
}
finally
{
streamToPrint.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
string line = null;
linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics);
while (count < linesPerPage && ((line = streamToPrint.ReadLine()) !=
null))
{
yPos = topMargin + (count *
printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString(line, printFont, Brushes.Black,
leftMargin, yPos, new StringFormat());
count++;
}
if (line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
}
Besides these, is there any way to open ctrl-p menu on the
document(printing options)? Then user may choose any printer he/she
desires.
I would appreciate your helps.
My regards...

Tuesday 20 August 2013

Using Math Symbols Stored in an Array as a String

Using Math Symbols Stored in an Array as a String

I'm very new to Ruby and I'm trying to use math symbols that are stored in
an array as strings to perform math. This is for a Reverse Polish Notation
calculator I'm working on. For example:
var = ['1','2','+']
I've puzzled through enough regular expressions to figure out how to
differentiate numbers from non-numbers in an if statement, but I'm trying
to figure out how I could make the following work to produce -1.
var[0] var[2] var[1] #=> 1 - 2
Does anyone know how to change the string '-' back into the math symbol?

TXC not reading in project file

TXC not reading in project file

I have been working on my thesis report and use TXC as my editor.
Everything was fine until there was a BSOD on my computer for unknown
reason. After restarting the computer I realised that the TXC is no longer
able to read my project file. Here is the screenshot of the error.

Is there any reason why this happens and how can I possibly fix this issue ?

Retrieving results from IPython parallel hub database

Retrieving results from IPython parallel hub database

I've been running parallel jobs on a SGE cluster using IPython parallel. I
submit my jobs and retrieve the results from the hub database (SQlite) at
a later time when all the jobs have finished, using the jobs message ID.
This worked fine till my controller crashed; on restarting the controller,
I couldn't retrieve the jobs submitted to the old controller. I got this
error:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/IPython/parallel/controller/hub.py",
line 1281, in get_results
raise KeyError('No such message: '+msg_id)
KeyError: u'No such message: 7f1996c0-deb0-4d7c-8782-619c86d2d064'
The database file (tasks.db) still exists and has the same size as before
the hub crashed. So, I'm sure the results are in the database. Can I
retrieve them using the new controller? Also, if I use the bd_query
command:
rc.db_query({'msg_id' : '7f1996c0-deb0-4d7c-8782-619c86d2d064'})
I get an empty result.

How to inlucde external javascipt libraries in Codeigniter

How to inlucde external javascipt libraries in Codeigniter

I have a web page which needs to include external javascript libraries. I
have downloaded them and include in the php->libraries folder. My
application is hosted in openshift cloud. I want to include those
javascript files in my php file. I have used this code
<script
src="../../libraries/dhtmlxCalendar/dhtmlxCalendar/codebase/dhtmlxcalendar.js"></script>
But it is not working
Then I tried
<script type="text/javascript" src="<?php echo base_url();?>js/jquery.js"
></script>
The base url gives me the url but it is also not working.
What is the correct way for this ? I am a beginner for codeigniter. Could
you help me

rm -rf does not delete folder contents but instead creates another empty one

rm -rf does not delete folder contents but instead creates another empty one

I'm currently writing a start script for a minecraft game server. In this
script I included a backup script.
This backup script works almost perfect but instead of deleting a folders
contents it just creates another one (similarilly named) and does not do
anything with the targeted folder.
I'm using this command: rm -rf "$MINECRAFT_PATH/server.log backups/*"
This command is executed in a bash script.
The variable $MINECRAFT_PATH does contain the correct path. The folder
created has this name: server.log.backups (Note the dot between log and
backups). But the targeted folder has this name: server.log backups. This
folder does exist and this is not the problem.

scikit-learn install failure / numpy not found

scikit-learn install failure / numpy not found

When i try to install scikit-learn on a Suse (openSuse 12.2 x86_64) server
via:
pip install -U scikit-learn
i get the following error:
(....)
compile options: '-I/usr/lib64/python2.7/site-packages/numpy/core/include
-Isklearn/svm/src/libsvm
-I/usr/lib64/python2.7/site-packages/numpy/core/include
-I/usr/include/python2.7 -c'
gcc: sklearn/svm/libsvm.c
sklearn/svm/libsvm.c:303:31: fatal error: numpy/arrayobject.h: No such
file or directory
compilation terminated.
sklearn/svm/libsvm.c:303:31: fatal error: numpy/arrayobject.h: No such
file or directory
compilation terminated.
I already tried:
-installing gcc to the latest version
-installing scikit from a downloaded zip, over easy_install (to avoid old
repos) -uninstalling and reinstalling numpy (over pip)
When i try to install scipy (which is a requirement of numpy) i get a
similar Error:
adding 'build/src.linux-x86_64-2.7/fortranobject.c' to sources.
adding 'build/src.linux-x86_64-2.7' to include_dirs.
error: file
'/usr/lib64/python2.7/site-packages/numpy/f2py/src/fortranobject.c' does
not exist
Could be a version conflict but i cant find anythin related on the Web.
Python-dev

ng-repeat a single element over nested objects

ng-repeat a single element over nested objects

Say I have an object with keys corresponding to products and values
corresponding to objects which in turn have keys corresponding to price
points at which those products have sold, and values corresponding to
amount sold.
For example, if I sold 10 widgets at $1 and 5 widgets at $2, I'd have the
data structure:
{ 'widget': {'1': 10, '2': 5} }
I'd like to loop over this structure and generate rows in a table such as
this one:
thing price amount
---------------------
widget $1 10
widget $2 5
In Python it's possible to nest list comprehensions to traverse lists data
structures like this. Would such a thing be possible using ng-repeat?

Monday 19 August 2013

Java Netty Client Channel Closing

Java Netty Client Channel Closing

I'm building a server and client to support multiple connections from
different people. I have done the decoders and encoders. I use ByteBuffer
and convert that into ChannelBuffer to send data. During a session, if
correct session credentials are met, then client opens up the Login
JFrame. After the JFrame is opened, the channel connected to server is
closed automatically. I'm assuming it was because the client isnt
receiving or sending any data or has nothing to do. So how can I make the
client keep checking for incoming data while during the JFrame stage?

A local repository to update games?

A local repository to update games?

I have a computer cafe. Updating and maintaining files (particularly
games) has been a hassle for me and my employees. In addition, I am not
willing to pay for something like G-Cafe Management Program. I am familiar
with programming languages like C, PHP, JAVA, but I am neither aware of
what logic and algorithm I would use for my objective nor familiar with
networking
My friend suggested I use a local repository, so I researched topics
regarding the same matter. But it turns out that I have a question that
was not answered by discussions I've read.
This is how I view how my update was going to work:
I plan on updating games through this flow: [(Internet -> Server) ->
(Server -> Client]. If there are game updates, the local server will
download it through the internet; then, the client will copy or download
these files from the local server.
Seeing that games have autoupdaters, I plan on placing all of the games
inside the repository (in the server) and the client stations will connect
to that repository. But then again, SVN works with revisions, am I right?
Are there any suggestions or ideas whether how will I be able to update
client games through SVN / Git (of course from the server)? Or if there
are any other ways?
I was playing too dumb.. :(

Generating non-random data according to an already existing dataset and applying it to another dataset

Generating non-random data according to an already existing dataset and
applying it to another dataset

I am looking for a package in R or a tool that could help me generate data.
I have 1 dataset that has only one element and then I have a second
dataset that has approx. 450 elements. I obviously can't perform a T-test
with what I have, therefore I have to generate "artificial" data in my
first dataset in accordance with the elements from my second dataset.
Background: The first dataset with the one element corresponds to the
expression of a mutated gene for one patient and the second dataset
corresponds to the expression of the same gene that has not been mutated
for several patients.
I tried searching for solutions but I only found options for resampling
already existing data or creating new random data, which I do not want to
do.
Thank you for your help!

Titanium: Check if application installed on the device (android)

Titanium: Check if application installed on the device (android)

How i can check if application installed on android device (for e.g. by
application id - com.foo.bar) ? Or, how i can get list of all android
application installed on the device? Im use titanium mobile. Thanks!

Sunday 18 August 2013

Android monitor won't recognize my Android (Galaxy S2) on Windows 8

Android monitor won't recognize my Android (Galaxy S2) on Windows 8

I'm trying to build and run a cordova project on my Galaxy S2. I'm having
trouble getting my windows 8 HP Pavilion intel core i5 laptop to recognize
the phone. Here's the two things that have worked for me:
A. I've gone through the whole process easily on my windows 7 desktop, so
it isn't my phone's settings
B. I can transfer files from my phone on the windows 8 machine (ie its
icon appears in My Computer), so its not a simple connection issue
I've followed these instructions, which look pretty identical to the
official windows 7 instruction for some reason. The result was that my
computer told me "Windows was unable to install your SAMSUNG_Android".
Going to the android monitor never shows my phone when i plug it in. I
also tried installing directly from
sdk/extras/google/usb_driver/android_winusb.inf (it tells me "The
operation completed successfully"), then restarted the computer. No Dice.
So what gives? How do I do this? Help!

Is it ok to send login details over GET request using SSL

Is it ok to send login details over GET request using SSL

I'm restricted to using JSONP for API requests from a javascript app.
The entire javascript app will be hosted over SSL.
As we are limited to GET requests when using JSONP is it ok to send login
credentials (username/password) to the API using a GET request?
I presume it wouldn't be if we weren't using SSL but it is ok because we
are. Correct?
Thanks!

Convert a string from Java to C++

Convert a string from Java to C++

I have this string in Java:
String op="text1 "+z+" text2"+j+" text3"+i+" "+Arrays.toString(vol);
where "z", "j" and "i" are int variables; "toString()" is a function
belongs to a class.
calss Nod
{
private:
char *op;
public:
char Nod::toString()
{
return *op;
}
}
and "vol" is a vector of int variables.
and I want to convert it in C++ language.
Can you help me please?

C# Connection String

C# Connection String

I am using the following connection string within the node. But somehow,
it seems that it is not saving. Everytime I use
System.Configuration.ConfigurationManager.ConnectionStrings["myDB"].ConnectionString
it has a null value, and when I check the index "0" it points to
.\SQLEXPRESS.
`
<connectionStrings>
<clear/>
<add name="myDB"
providerName="System.Data.SqlClient"
connectionString="Server=Server\Instance;Database=anydb;User
Id=***; Password=***;" />
</connectionStrings>
`
The projects is an ASP.NET MVC 2 project. I really need this to work,
since I am learning the CodeFirst Entity manager Framework. Is there any
sugesion?

start index of word in RichTextBox using C# [on hold]

start index of word in RichTextBox using C# [on hold]

I have a RichTextBox in a Winform application. I need to get the start
index of the last entered word in the RTB. Say the sentence user types is
' quick brown fox,. now it's easy to get the start index of the word 'fox'
using the following code
int startindex = rtb.Text.TrimEnd().LastIndexOf(' ');
But now if the user types 'brown' in the middle (say after 'quick') the
how do we get the start index of the word 'brown' ?

Doctrine 2 base entities like those in doctrine 1?

Doctrine 2 base entities like those in doctrine 1?

I'm starting a new project with Symfony2/Doctrine2 and I generated my
entities from the DB with the mapping:convert and mapping:import commands.
My entities are fine, but I only have the generated entities. Back in
Doctrine1/Symfony1, you had your entities generated twice : once in the
doctrine folder, an almost empty class just extending the second one in
doctrine/base folder where all the doctrine internals were
(getters/setters, fields...) This way, you could add your own methods in
the first file where they remained untouched even if you generated again
the entities (only the doctrine/base files were modified by the
generator).
Am I missing something ?

Add Rows/Columns to a Grid dynamically

Add Rows/Columns to a Grid dynamically

I have a child userControl comprising of multiple textboxes, labels. I
need to populate these controls in Parent User control which has a Grid.
Number of child user controls that need to be populated in the parent user
control are determined at run time and can change. Basically the number
depends on the search result. So it can be from 0 to n. How can I populate
my child user control in parent control?
Is there a better alternate to using a GRID? Any help will be much
appreciated. Thanks

Saturday 17 August 2013

Maximum related to Nonnegative Matrix

Maximum related to Nonnegative Matrix

Suppose $A$ is a fixed nonnegative $n\times n$ matrix (i.e. $A_{ij}\geq0$
for all $i,j$). Then for any arbitrary $n$ positive numbers
$x_1,\ldots,x_n$, we denote:
$$F(x_1,\ldots,x_n)=\min_i\frac{1}{x_i}\sum_{j=1}^n x_jA_{ij}$$ Frobenius
Theorem tells us that there's always an inequality
$$F(x_1,\ldots,x_n)\leq\rho(A)$$ where $\rho(A)$ is the spectral radius of
$A$.
Here my question is, what is the maximum of $F(x_1,\ldots,x_n)$ ? Is it
just $\rho(A)$ ? Or there's no maximum but a supremum? Thanks a lot for
your help.

mod_rewrite cookie based on query string

mod_rewrite cookie based on query string

If a query string is detected, I want to update/set a cookie so a
particular dir is used for that browser session or until the query string
is explicitly set again.
This is what I have so far but it doesn't work as expected. Pretty sure
I'm writing the logic wrong, but not sure where.
RewriteCond %{QUERY_STRING} splittest=(A|B)
RewriteRule splittest=(A|B) [CO=splittest:$1:%{HTTP_HOST}:0:/,L]
RewriteCond %{QUERY_STRING} splittest=A [OR]
RewriteCond %{HTTP_COOKIE} splittest=A
# Split test A
RewriteRule ^(.*)$ A/$1 [L]
# Split test B
RewriteRule ^(.*)$ B/$1 [L]

Image seperator in splitted unordered list css

Image seperator in splitted unordered list css

I have an unordered list. Something like
<ul class="dynamic"><br>
<li class="dynamic">"something1"</li><br>
<li class="dynamic">"something2"</li><br>
<li class="dynamic">"something3"</li><br>
<li class="dynamic">"something4"</li><br>
<li class="dynamic">"something5"</li><br>
<li class="dynamic">"something6"</li><br>
</ul>
I have split the list in two columns using css. Now I want to place an
image separator between these two columns.

Subviews of UITableView?

Subviews of UITableView?

I have an UITableView with five costum UITableViewCells. If the TableView
scrolls all Cells should perform the same method.
Here is the code:
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if(self.newsViewTable == scrollView) {
for(int i = 1; i < [self.newsViewTable.subviews count]; i++) {
[[self.newsViewTable.subviews objectAtIndex:i]
hideSocialMediaBar];
}
}
}
But if I scoll there comes an error!
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[UIImageView hideSocialMediaBar]:
unrecognized selector sent to instance 0x8a9ea90'
I don't now why the error deals with an UIImageView? There is just one
direct subview of the UITableView and this is the Cell! What is wrong? Why
it is an UIImageView?

I have a file which is larger than memory size, how to handle such file?

I have a file which is larger than memory size, how to handle such file?

I am asking how to handle the file whose size is larger than memory size?

online Leeds vs Sheff Wed Live tv stream

online Leeds vs Sheff Wed Live tv stream

Watch Live Streaming Link
Football Live Tv
We also have Streams in Justin, Sopcast, Ustream, Vshare, Livevdo,
Freedocast, Veemi, YYcast – all you need is Adobe Flashplayer. We Always
try our best to get you the best possible HD Streams to watch Live Sports
Online. You will never have to pay for any service just enjoy streaming
live Television, Videos and Sports.
Watch Live Streaming Link

Combine text boxes into one string

Combine text boxes into one string

If you have two text box fields, how would you go about combing them into
one string with text in the middle.
For example
You have textbox1 and textbox2 and want to have a - in hte middle
so if the input was andy(1) maxel(2) it would come out andy-maxel
I have tried this
$daters = $_POST['11']." ". $_POST['22']." ". $_POST['33'];
$dater = $_POST['11']." - ". $_POST['22']." - ". $_POST['33'];

Friday 16 August 2013

Please recommend open source project to get involved in

Please recommend open source project to get involved in

I want to improve my programming skill and build my technology database.
Reading good quality codes of some open source project and get involved in
developing are the best methods. However, there are too many projects that
I have no idea which ones should I focus on.
So I list my objectives below, please recommend your best experienced
projects that cover these items. The more the better. Thanks in advance!
1: Database(Oracle, PostgreSql)
2: Linux kernel(Memory management, File system, IPC, device driver)
3: Networking, socket programming
4: Multi-threading/processing, parallel computing
5: large scale data mining/learning
6: Language: Java/C++/Python/
7: New c++ library such as LR1, LR2 or BOOST.
Appreciate!!

Saturday 10 August 2013

Cassandra: choosing a Partition Key

Cassandra: choosing a Partition Key

I'm undecided whether it's better, performance-wise, to use a very
commonly shared column value (like Country) as partition key for a
compound primary key or a rather unique column value (like Last_Name).
Looking at Cassandra 1.2's documentation about indexes I get this:
"When to use an index Cassandra's built-in indexes are best on a table
having many rows that contain the indexed value. The more unique values
that exist in a particular column, the more overhead you will have, on
average, to query and maintain the index. For example, suppose you had a
user table with a billion users and wanted to look up users by the state
they lived in. Many users will share the same column value for state (such
as CA, NY, TX, etc.). This would be a good candidate for an index."
"When not to use an index
Do not use an index to query a huge volume of records for a small number
of results. For example, if you create an index on a column that has many
distinct values, a query between the fields will incur many seeks for very
few results. In the table with a billion users, looking up users by their
email address (a value that is typically unique for each user) instead of
by their state, is likely to be very inefficient. It would probably be
more efficient to manually maintain the table as a form of an index
instead of using the Cassandra built-in index. For columns containing
unique data, it is sometimes fine performance-wise to use an index for
convenience, as long as the query volume to the table having an indexed
column is moderate and not under constant load."
Looking at the examples from CQL's SELECT for
"Querying compound primary keys and sorting results", I see something like
a UUID being used as partition key... which would indicate that it's
preferable to use something rather unique?

If $\cos^4 \theta −\sin^4 \theta = x$. Find $\cos^6 \theta − \sin^6 \theta $ in terms of $x$.

If $\cos^4 \theta &#8722;\sin^4 \theta = x$. Find $\cos^6 \theta &#8722;
\sin^6 \theta $ in terms of $x$.

Given $\cos^4 \theta &#8722;\sin^4 \theta = x$ , I've to find the value of
$\cos^6 \theta &#8722; \sin^6 \theta $ .
Here is what I did: $\cos^4 \theta &#8722;\sin^4 \theta = x$.
($\cos^2 \theta &#8722;\sin^2 \theta)(\cos^2 \theta +\sin^2 \theta) = x$
Thus ($\cos^2 \theta &#8722;\sin^2 \theta)=x$ , so $\cos 2\theta=x$ .
Now $x^3=(\cos^2 \theta &#8722;\sin^2 \theta)^3=\cos^6 \theta-\sin^6
\theta +3 \sin^4 \theta \cos^2 \theta -3 \sin^2 \theta \cos^4 \theta $
So if I can find the value of $3 \sin^4 \theta \cos^2 \theta -3 \sin^2
\theta \cos^4 \theta $ in terms of $x$ , the question is solved. But how
to do that ?

Android billing - purchase subscription code does not do anythnig

Android billing - purchase subscription code does not do anythnig

I have this code that executes when the user presses a button to buy a
subscription
Button support_us = (Button)findViewById(R.id.support_us);
support_us.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
// GETS THIS FAR
ArrayList skuList = new ArrayList();
skuList.add("basicsubscription");
Bundle querySkus = new Bundle();
querySkus.putStringArrayList("basicsubscription", skuList);
try
{
Bundle skuDetails = mService.getSkuDetails(3,
getPackageName(), "subs", querySkus);
int response = skuDetails.getInt("RESPONSE_CODE");
if (response == 0)
{
ArrayList<String> responseList
= skuDetails.getStringArrayList("DETAILS_LIST");
for (String thisResponse : responseList)
{
JSONObject object = new JSONObject(thisResponse);
String sku = object.getString("basicsubscription");
String price = object.getString("price");
if (sku.equals("premiumUpgrade"))
{
//mPremiumUpgradePrice = price;
}
else
if (sku.equals("gas"))
{
//mGasPrice = price;
}
}
}
else
{
}
Bundle buyIntentBundle = mService.getBuyIntent(3,
getPackageName(),
"basicsubscription", "subs",
"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
PendingIntent pendingIntent =
buyIntentBundle.getParcelable("BUY_INTENT");
startIntentSenderForResult(pendingIntent.getIntentSender(),
1001, new Intent(), Integer.valueOf(0),
Integer.valueOf(0),
Integer.valueOf(0));
}
catch ( Exception e )
{
}
}
});
But it doesn't seem to do anything. Would anyone know what may be wrong
with it?
Thanks!