Thursday, 3 October 2013

Checkbox disabled not returning result from stored checkbox array

Checkbox disabled not returning result from stored checkbox array

I am storing all checkboxes what my div has in to a variable, later i am
finding disabled from the stored variable, but i am not get proper result,
instead if I find separately I am getting proper result..
what why i am not find the disabled from my stored variable?
here is my code:
var checkedBoxes = $(".locale-container .panel ul
li").find("input:checkbox"),
disabledBoxes = checkedBoxes.find("input:checkbox:disabled");
// not getting
But "disabledBoxes" not getting result from checkBoxes.
In case if I do like this:
var checkedBoxes = $(".locale-container .panel ul
li").find("input:checkbox"),
disabledBoxes = $(".locale-container .panel ul
li").find("input:checkbox:disabled"); // it works
so how can i filter or get the appropriate checkboxes from stored variable?
Thanks in advance

Wednesday, 2 October 2013

How does compiler resolves virtual functions accessing non-virtual data members C++

How does compiler resolves virtual functions accessing non-virtual data
members C++

I was reading about the C++ Objects when I got this doubt. Suppose there
are two classes
class X
{
virtual int def() { };
}
class Y
{
virtual int abc() { };
}
class Z : public X,public Y
{
virutal int abc() { return a };
int a;
}
Now what I understand is both Y and Z have the reference to Z::abc() in
their virtual tables which helps to resolve the correct function to call.
Consider
Y *y = new Z;
Z *z = new Z;
y->abc() // I understand this is done by reaching the vptr of y by this =
this + sizeof (X)
and z->abc() // z has its own vptr reachable
My understanding is that in both the cases the "this" pointer is passed
and after finding out the correct abc() to call, how does the programm
reach the int value "a"?
How does the compiler calculate the address of " int a" correctly based on
type of the object passed?

Access to an array element with PHP

Access to an array element with PHP

To avoid multiple mysql SELECT queries I try to take the SELECT out of the
foreach-loop.
The query is
SELECT o.orders_id,
o.date_purchased,
o.orders_status,
ot.text AS order_total,
os.orders_status_name
FROM " . TABLE_ORDERS . " o
JOIN " . TABLE_ORDERS_TOTAL . " ot ON (o.orders_id = ot.orders_id AND
ot.class = 'ot_total')
JOIN " . TABLE_ORDERS_STATUS . " os ON (o.orders_status =
os.orders_status_id AND os.language_id = " .
(int)$_SESSION['languages_id'] . ")
WHERE o.customers_id = " . (int)$_SESSION['customer_id'] . "
ORDER BY orders_id DESC
As the result I get the array called $history_result['RESULT'] and it
looks like
Array
(
[0] => Array
(
[orders_id] => 309
[date_purchased] => 2013-10-02 15:49:54
[orders_status] => 1
[order_total] => 9,00 €
[orders_status_name] => Offen
)
[1] => Array
(
[orders_id] => 308
[date_purchased] => 2013-10-02 15:39:54
[orders_status] => 1
[order_total] => 9,00 €
[orders_status_name] => Offen
)
[2] => Array
(
[orders_id] => 307
[date_purchased] => 2013-10-02 15:33:48
[orders_status] => 1
[order_total] => 9,00 €
[orders_status_name] => Offen
)
)
In the following foreach-loop is the next MySql-Query
foreach ($history_result['RESULT'] as $history) {
$trackings = $db->result("-- 03 account_history_info.php
SELECT o.ortra_parcel_id,
c.carrier_tracking_link,
c.carrier_name
FROM " . TABLE_ORDERS_TRACKING . " o
JOIN " . TABLE_CARRIERS . " c ON o.ortra_id = c.carrier_id
WHERE ortra_order_id = " . $history['orders_id']
);
}
How can I access directly to the array element 'orders_id' so that I could
create an SQL statement like
$trackings = $db->result("-- 03 account_history_info.php
SELECT o.ortra_parcel_id,
c.carrier_tracking_link,
c.carrier_name
FROM " . TABLE_ORDERS_TRACKING . " o
JOIN " . TABLE_CARRIERS . " c ON o.ortra_id = c.carrier_id
WHERE ortra_order_id IN = " . implode(',', $fooArray)
);

vorbis and vorbisenc libraries not found

vorbis and vorbisenc libraries not found

I need to retrieve vorbis and vorbisenc libraries to compile a C program.
I tried to download vorbis lib sources in http://xiph.org/downloads/ but
each time, there are problems for compiling this lib. Do you know where I
can download these lib (.h and .so ) ?
I work on MacOSX. Thanks

Tuesday, 1 October 2013

Why dont all my textviews update with 1 button clicks? Requires multiple clicks

Why dont all my textviews update with 1 button clicks? Requires multiple
clicks

I have a simple tablelayout with many textview. When the button is pressed
only a few are updated, but what happens is that, you need to press the
button mutiple times for all the textviews to get updated. Why dont they
all change on the first/only click?
public class Calculator extends Activity {
String[] measurement;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.calculator);
setTitle("");
getActionBar().setIcon(R.drawable.logo);
final Spinner spinner = (Spinner) findViewById(R.id.spinner);
final Button button = (Button) findViewById(R.id.trapulate);
final EditText value_user_amount =
(EditText)findViewById(R.id.user_amount);
final EditText value_gram_yp =
(EditText)findViewById(R.id.value_gram_yp);
final TextView value_gram_amt =
(TextView)findViewById(R.id.value_gram_amt);
final TextView value_gram_sale =
(TextView)findViewById(R.id.value_gram_sale);
final TextView value_gram_profit =
(TextView)findViewById(R.id.value_gram_profit);
final TextView value_eighth_amt =
(TextView)findViewById(R.id.value_eighth_amt);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.measurements_array, R.layout.spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
DecimalFormat numberFormat = new DecimalFormat("#.0");
String spinner_value = spinner.getSelectedItem().toString();
Double total_grams = 56.0;
Double total_price = 400.0;
String user_amount = value_user_amount.getText().toString();
Double user_amount_db = 20.0;
String user_price = value_user_amount.getText().toString();
Double user_price_num = 200.2;
String eighth_amt = value_eighth_amt.getText().toString();
Double eighth_amt_int = Double.parseDouble(eighth_amt);
String gram = value_gram_yp.getText().toString();
Double gram_int = Double.parseDouble(gram);
String gram_yp = value_gram_yp.getText().toString();
Double gram_yp_int = Double.parseDouble(gram_yp);
String gram_amt = value_gram_amt.getText().toString();
Double gram_amt_int = Double.parseDouble(gram_amt);
String gram_sale = value_gram_sale.getText().toString();
Double gram_sale_int = Double.parseDouble(gram_sale);
String gram_profit = value_gram_profit.getText().toString();
Double gram_profit_int = Double.parseDouble(gram_profit);
Double new_gram_amt = user_amount_db / 1;
Double new_gram_sale = gram_amt_int * gram_yp_int;
Double new_gram_profit = gram_sale_int - user_price_num;
if (spinner_value.equals("GRAMS"))
{
eighth_amt_int = user_amount_db / 3.5;
eighth_amt_int = Math.round(eighth_amt_int*1e2)/1e2;
value_eighth_amt.setText(Double.toString(eighth_amt_int));
value_gram_amt.setText(Double.toString(new_gram_amt));
value_gram_sale.setText(Double.toString(new_gram_sale));
value_gram_profit.setText(Double.toString(new_gram_profit));
}else
{
//Toast.makeText(getBaseContext(), "Not equal: "
+spinner_value,Toast.LENGTH_SHORT).show();
}
}
});
spinner.setOnItemSelectedListener(new OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3)
{
int index = arg0.getSelectedItemPosition();
// storing string resources into Array
measurement =
getResources().getStringArray(R.array.measurements_array);
//Toast.makeText(getBaseContext(), "You have selected : "
+measurement[index],Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
}
}

Why use typedef for iterators in template classes

Why use typedef for iterators in template classes

I read the following post: Why use typedef-typename in templates
I am reading up on some material which says you must have public typedef
for the following private nested class
template<typename T>
class list
{
private:
class my_private_it
{
public:
...
};
public:
typedef my_private_it iterator;
// should this be:
// typedef typename my_private_it iterator;
...
iterator begin(){return iterator(this)};
iterator end(){return iterator(NULL)};
};
Now from the aforementioned link, I understand, the typename is to help
the compiler deduce that it is infact working with types and not values
for certain dependent names. But why do people use the typedef? Is this
compiler requirement or standard requirement. Please note I understand the
typename part , but not the typedef part.

Where can I ask questions related to my my career options=?iso-8859-1?Q?=3F_=96_meta.stackoverflow.com?=

Where can I ask questions related to my my career options? –
meta.stackoverflow.com

Is there any branch of Stack Exchange where I can ask questions related to
my education and career?

what does uninstall-wubi.exe do?

what does uninstall-wubi.exe do?

What does uninstall-wubi.exe do? Does it uninstall just wubi or complete
Ubuntu? I installed Ubuntu 12.04 in Windows 7 and now have Windows 8 in
place of Windows 7 and I want a fresh copy of Ubuntu 12.04

Monday, 30 September 2013

Other answer is better than my answer; I am also the asker – meta.stackoverflow.com

Other answer is better than my answer; I am also the asker –
meta.stackoverflow.com

What is the proper way to handle when my answer on a question is (by far)
the leading vote getter, but someone else's answer is better? Improve my
answer by including parts of theirs? Give them credit …

Factorize $4a^2 - 9b^2 -2a - 3b$ – math.stackexchange.com

Factorize $4a^2 - 9b^2 -2a - 3b$ – math.stackexchange.com

I found this question in my textbook - $$4a^2 - 9b^2 -2a - 3b$$ I am in
ninth grade and we have been taught how to factorize using identities,
splitting the middle term and by using identities. I ...

Centering items using CSS

Centering items using CSS

I'm having trouble centering things, I've tried table cell and the line
height trick but can't get things to work.
Here's my HTML
<li class="image-item gallery-image-item">
<i class="icon-remove"></i>
<i class="btn-comment icon-comment"></i>
<i class="btn-youtube icon-youtube-play"></i>
</li>
I'm trying to get icon-remove to sit top right in the li.
btn-comment and btn-youtube should be centered in the li, vertically and
horizontally.
The problem I am having is that the icon-remove icon is causing the
centering of the other two items to shift.

if list returns empty display message

if list returns empty display message

Using MVC I am passing a list 'Projects' to the view
@if (Model.Projects != null && Model.Projects.Count > 0)
{
<fieldset>
<table class="items" summary="@T("This is a table of the delivery Runs
in your application")">
<colgroup>
}
else
{
//no data available
}
Model.Projects.Count > 0 is saying operator > cant be applied to opeards
of type 'method group' and 'int'

Sunday, 29 September 2013

Why does the following CSS not work?

Why does the following CSS not work?

I must admit, I expect this to work. In my mind I see my CSS class as
selecting,"all child h2 elements of an element containing
class="jumbotron-features"
jsFiddle: http://jsfiddle.net/sKAhn/
.jumbotron-features
h2
{
color: #797979;
font-style: oblique;
}
<div class="jumbotron jumbtron-features">
<div class="container">
<div class="content">
<div class="row">
<div class="col-lg-4 text-left">
<div class="feature-box feature-box-vertical-middle">
<h2>Seriously powerful, incredibly intuitive,
and designed by real estate experts!</h2>
</div>
</div>
</div>
</div>
</div>
</div>

Clone closest row from a href

Clone closest row from a href

I have a code that is supposed to duplicate the row that I specify. My
table is made dynamically so I am not able to define an id. I want to be
able to click a button on the specified row and find the closest tr to
duplicate.
The code that is supposed to duplicate is:
function cloneRow()
{
var row = $(this).closest('tr'); // find row to copy
var table = document.getElementById("ScannedItems");
var clone = row.cloneNode(true); // copy children too
clone.id = "newID";
table.appendChild(clone);
}
I am needing to change var row = $(this).closest('tr'); to something else
but I don't know what to change it to so I can get the closest tr from the
a href that is clicked.
Or just duplicate the same row that the a is clicked on.
The a href looks like this
<a onclick='cloneRow();'><span class='glyphicon glyphicon-plus'
style='padding-right:15px;'>

Pandas dataframe column multiplication

Pandas dataframe column multiplication

What if , you hae 2 df's to multiply using selected columns , and store
the result in a new column for example df1 AAPL IBM GOOG XOM
transaction_amount 2011-01-10 16:00:00 1500 0 0 0
df2 [[ 340.99 143.41 614.21 72.02] [ 340.18 143.06 616.01 72.56]
i want to multiply , aapl in df1 with 340.99 in df2 , and store the result
in transaction_amount.

Getting facebook profile while signup with facebook in liferay

Getting facebook profile while signup with facebook in liferay

I am trying to use the liferay inbuild facebook signin feature. By default
facebook connect only stores first name,lastname,email and gender. I want
to get the profile picture of user from facebook and store in the database
as userpotrait of a user when he sign up with facebook. How can do it in
liferay?

Saturday, 28 September 2013

Single thread per request asp.net

Single thread per request asp.net

Is anyone aware of any setting in IIS 7 that will force it to use a single
thread per request, and not allow it to switch threads during a request?
Or go back to a legacy thread model?
Our problem is the entire request, beginning to end uses multiple
connections to different databases and we want to guarantee data integrity
by using TransactionScope (which starts as a light weight transaction,
then is promoted to a distributed transaction, once a second connection is
established).
The reason we need a single thread per request, is when you attempt to
dispose a transaction on a thread different than the thread that started
it, it throws an exception stating it must be disposed on the same thread
that started it. Then the transaction leaks, and nothing gets committed,
and it slowly brings the machine to a grinding halt.

Returning value

Returning value

I have some difficulties with understanding what is really done behind
returning values in C++.
Let's have following code:
class MyClass {
public:
int id;
MyClass(int id) {
this->id = id;
cout << "[" << id << "] MyClass::ctor\n";
}
MyClass(const MyClass& other) {
cout << "[" << id << "] MyClass::ctor&\n";
}
~MyClass() {
cout << "[" << id << "] MyClass::dtor\n";
}
MyClass& operator=(const MyClass& r) {
cout << "[" << id << "] MyClass::operator=\n";
return *this;
}
};
MyClass foo() {
MyClass c(111);
return c;
}
MyClass& bar() {
MyClass c(222);
return c;
}
MyClass* baz() {
MyClass* c = new MyClass(333);
return c;
}
I use gcc 4.7.3.
Case 1
When I call:
MyClass c1 = foo();
cout << c1.id << endl;
The output is:
[111] MyClass::ctor
111
[111] MyClass::dtor
My understanding is that in foo object is created on the stack and then
destroyed upon return statement because it's end of a scope. Returning is
done by object copying (copy constructor) which is later assigned to c1 in
main (assignment operator). If I'm right why there is no output from copy
constructor nor assignment operator? Is this because of RVO?
Case 2
When I call:
MyClass c2 = bar();
cout << c2.id << endl;
The output is:
[222] MyClass::ctor
[222] MyClass::dtor
[4197488] MyClass::ctor&
4197488
[4197488] MyClass::dtor
What is going on here? I create variable then return it and variable is
destroyed because it is end of a scope. Compiler is trying copy that
variable by copy constructor but It is already destroyed and that's why I
have random value? So what is actually in c2 in main?
Case 3
When I call:
MyClass* c3 = baz();
cout << c3->id << endl;
The output is:
[333] MyClass::ctor
333
This is the simplest case? I return a dynamically created pointer which
lies on heap, so memmory is allocated and not automatically freed. This is
the case when destructor isn't called and I have memory leak. Am I right?

getting unfortunately stopped error when i define onItemSelectedListener

getting unfortunately stopped error when i define onItemSelectedListener

I really can't understand what is the problem.
This running very well.
super.onCreate(savedInstanceState);
setContentView(R.layout.select);
Resources r = getResources();
values = r.getStringArray(R.array.values);
sSelect = (Spinner) findViewById(R.id.sSelect);
tvSelect = (TextView) findViewById(R.id.tvSelect);
But this isn't working.
super.onCreate(savedInstanceState);
setContentView(R.layout.select);
Resources r = getResources();
values = r.getStringArray(R.array.values);
sSelect = (Spinner) findViewById(R.id.sSelect);
tvSelect = (TextView) findViewById(R.id.tvSelect);
sSelect.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long
arg3) {
// TODO Auto-generated method stub
}
});
I really want to know what is the problem. Also how can i know what is the
problem? There is no error reporting in android programming?
EDIT: setOnItemClickListener cannot be used with a spinner Which listener
can i use with spinner? I don't want to use onItemSelectedListener because
It run when app start.

xlib programming - how to find if the line is outside a given polygon

xlib programming - how to find if the line is outside a given polygon

I have a polygon .
How can i find out through xlib programming whether the black color line
lies outside the polygon or inside the polygon .

Friday, 27 September 2013

I need something to add line in xml

I need something to add line in xml

i need big help in xml file. I need to know how to add a new line in all
my <Invoice> </ Invoice>. for example:
<Invoice>
<InvoiceNo>FR 2013A/5391</InvoiceNo>
**<DocumentStatus>**
<InvoiceStatus>N</InvoiceStatus>
<InvoiceStatusDate>2013-07-01T09:00:25</InvoiceStatusDate>
<SourceID>Admin</SourceID>
<SourceBilling>P</SourceBilling>
**</DocumentStatus>**
</Invoice>
so i need to know how can i add <DocumentStatus> after
<InvoiceNO></InvoiceNO>, and </DocumentStatus> after
<SourceBilling></SourceBilling> ? The values inside off
<InvoiceNO></InvoiceNO> and <SourceBilling></SourceBilling> comes from DB,
so in other <Invoice></Invoice> that values comes diferente. Thats my big
problem. I need file to do this operation, can anyone help me?

Cannot Change TextView Value Inside Fragment From FragmentActivity

Cannot Change TextView Value Inside Fragment From FragmentActivity

I'm developing a simple app based on viewPager. I'm trying to change the
text in a textView inside a fragment from the mainActivity. I tried to
call textV.setText(String) right after the init() method(where the
fragment is instantiated), but the OnCreateView is executed much later, so
the reference to textV is null in that moment. The textV textView is
placed in tab0layout.xml, and become != null when the layout file is
inflated, and it is referenced inside OnCreateView method of Fragment0.
How can I get a valid reference of textV inside my MainActivity? Setting
the text from within the OnCreateView works fine, but I need it available
in the mainActivity.
Here is the whole java file:
public class MainActivity extends FragmentActivity implements
ActionBar.TabListener {
SectionsPagerAdapter mSectionsPagerAdapter;
ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();//fragment is instantiated
Fragment0.textV.setText("new text");//doesn't work, now textV is null!!
}
private void init() {
List<Fragment> fragments = new Vector<Fragment>();
fragments.add(Fragment.instantiate(this, Fragment0.class.getName()));
this.mSectionsPagerAdapter = new
SectionsPagerAdapter(super.getSupportFragmentManager(), fragments);
mViewPager = (ViewPager)super.findViewById(R.id.pager);
mViewPager.setAdapter(this.mSectionsPagerAdapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction
fragmentTransaction) {
// When the given tab is selected, switch to the corresponding page in
// the ViewPager.
mViewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction
fragmentTransaction) {
}
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction
fragmentTransaction) {
}
public class SectionsPagerAdapter extends FragmentPagerAdapter {
private List<Fragment> fragments;
public SectionsPagerAdapter(FragmentManager fm, List<Fragment>
fragments) {
super(fm);
this.fragments = fragments;
}
@Override
public Fragment getItem(int position) {
return this.fragments.get(position);
}
/* (non-Javadoc)
* @see android.support.v4.view.PagerAdapter#getCount()
*/
@Override
public int getCount() {
return this.fragments.size();
}
}
public static class Fragment0 extends Fragment {
static TextView textV;
public Fragment0() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.tab0_layout, container,
false);
textV = (TextView)rootView.findViewById(R.id.text);
return rootView;
}
}
}
}

Order_by in sqlalchemy with outer join

Order_by in sqlalchemy with outer join

I have the following sqlalchemy queries:
score = Scores.query.group_by(Scores.email).order_by(Scores.date).subquery()
students = db.session.query(Students,
score.c.id).filter_by(archive=0).order_by(Students.exam_date).outerjoin(score,
Students.email == score.c.email)
And then I render the things with:
return render_template('students.html', students=students.all())
Now, the issue is that I want the last score for a student to be
displayed, as there are many of them corresponding to each user. But the
first one seems to be returned. I tried some sortings and order_by on the
first query, score, but without success.
How can I affect and pick only one latest result from the "score" to be
paired with the corresponding row in "students"?
Thanks!

Valgrind - Error

Valgrind - Error

Below is the message I get when I run my code on Valgrind
1) Uninitialised value was created by a stack allocation ==16808== at
0x400EC1: init() (Hite.cpp:90)
2) Invalid read of size 8
How do we over come these errors from arising

Tagging System - Get position of element in an array an replace it

Tagging System - Get position of element in an array an replace it

first of all I am new in jQuery and my English is not the best.
I try to create a Tagging-System like Stackoverflow and I already found
some useful code. For better understanding here is the current system.
HTML:
<div class="holder">
<span class="test targetLeft" style="background: red;"></span>
<input class="test taggingSystem" type="text" />
<span class="test targetRight"></span>
</div>
jQuery:
$(document).ready(function() {
tags = [];
$(".taggingSystem").keyup(function (e) {
if ($(".taggingSystem").val().substring(0, 1) == " ") {
$('.taggingSystem').val('');
return false;
}
// GET THE VALUE OF THE INPUT FIELD
var value = $('.taggingSystem').val().replace(/\s/g,"");
// IF USER IS HITTING THE BACKSPACE KEY
if (e.which === 8 && value === "") {
var text = $('.targetLeft .tagHolder:last-child
.tagValue').text();
$('.targetLeft .tagHolder:last-child').remove();
$(this).val(text);
}
// IF USER IS HITTING THE SPACE KEY
if (e.which === 32 && value != "") {
$(".targetLeft").append('<span class="test tagHolder"><span
class="test tagValue">' + value + '</span><span class="test
cross">X</span></span>');
tags.push(this.value);
this.value = "";
}
});
$(document).on('click','.targetLeft .tagHolder',function() {
var clickedValue =
$(this).prev('.tagHolder').find('.tagValue').text();
tags.splice(clickedValue, 1);
var value = $('.taggingSystem').val();
if ($(".taggingSystem").val().substring(0, 1) != "") {
$(".targetRight").prepend('<span class="test tagHolder"><span
class="test tagValue">' + value + '</span><span class="test
cross">X</span></span>');
}
var text = $(this).find('.tagValue').text();
var following = $(this).nextAll();
following.remove();
$(".targetRight").prepend(following);
$(this).remove();
$('.taggingSystem').val(text);
});
$(document).on('click','.targetRight .tagHolder',function() {
var value = $('.taggingSystem').val();
if ($(".taggingSystem").val().substring(0, 1) != "") {
$(".targetLeft").append('<span class="test tagHolder"><span
class="test tagValue">' + value + '</span><span class="test
cross">X</span></span>');
}
var text = $(this).find('.tagValue').text();
var following = Array.prototype.reverse.call($(this).prevAll());
following.remove();
$(".targetLeft").append(following);
$(this).remove();
$('.taggingSystem').val(text);
});
$(".holder").click(function (e) {
if(!$(e.target).is('.test')) {
var value = $('.taggingSystem').val();
if ($(".taggingSystem").val().substring(0, 1) != "") {
$(".targetLeft").append('<span class="test
tagHolder"><span class="test tagValue">' + value +
'</span><span class="test cross">X</span></span>');
}
$('.taggingSystem').val('');
var following = $('.targetRight').find('.tagHolder');
$(".targetLeft").append(following);
}
});
});
The problem is that if I click on a tag to write some other text in it,
the data appear at the end of the array. But I want that the data will be
replaced at the same position in the array. As you can see I also tried to
work with splice(). But I don't know how to push the new data at the
position where the deleted text was living. Have you any idea for that?
http://jsfiddle.net/Wky2Z/12/

mod-wsgi processes are never terminated

mod-wsgi processes are never terminated

I have configured my Apache with mod_wsgi to serve web.py application.
Apache configuration,
(PWPYTHON)ubuntu@PWVM2:~$ apache2 -V
Server version: Apache/2.2.22 (Ubuntu)
Server built: Jul 12 2013 13:37:10
Server's Module Magic Number: 20051115:30
Server loaded: APR 1.4.6, APR-Util 1.3.12
Compiled using: APR 1.4.6, APR-Util 1.3.12
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/apache2"
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="mime.types"
-D SERVER_CONFIG_FILE="apache2.conf"
Now, sample vhost file is,
Listen 20109
<VirtualHost *:20109>
DocumentRoot /
WSGIScriptAlias / /server.py
WSGIDaemonProcess egauge user=ubuntu group=ubuntu processes=3 threads=3
home=/ maximum-requests=1000 shutdown-timeout=10 display-name=rs-egauge
WSGIProcessGroup egauge
WSGIApplicationGroup %{GLOBAL}
AddType text/html .py
<Directory />
Order deny,allow
Allow from all
</Directory>
ErrorLog "|/usr/sbin/rotatelogs
/var/log/apache2/rs_egauge_error.log.%Y.%m.%d 86400"
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel info
CustomLog "|/usr/sbin/rotatelogs
/var/log/apache2/rs_egauge_access.log.%Y.%m.%d 86400" pw_rs_combined
</VirtualHost>
As you can see i've mentioned 3 processes and 3 threads in daemon mode.
Now, when i send 1000's of request after serving some set of requests,
apache should kill the interpreter and reinitiate a new one. Apache tries
to do this, however the killed processes stays back in the memory as
subprocesses of init(PID-1). Thus occupying memory. Eventually number of
processes increases and system crashes due to lack of memory.
So, what can be done to avoid this ? Am i doing anything wrong in
application itself ?
Please help me out.

Thursday, 26 September 2013

KineticJS layer.get() finds non existent shapes

KineticJS layer.get() finds non existent shapes

I'm experiencing some troubles with KinectJS when I try to get a rectangle
using its id. Take a look at my code here:
var obj = null;
obj = myLayer.get("#asd");
if (obj != null) {
console.log(obj);
}
There are no shapes with #asd - but obj still isn't null. When I log it in
the console i get:
[each: function, toArray: function, on: function, off: function, remove:
function…]
What I want is to check if it found the shape with id #asd. How can I do
that?

Wednesday, 25 September 2013

Unload a device

Unload a device

I made a device driver. But my system crashed at the moment when it was
deleting the device object. I think the symbolic link was deleted and it
crashed after it was trying to delete the device as I can't see the
symbolic link in the Global. How do I delete this device now. It also
gives me a error popup(system cannot find the file specified
Device\Mydriver) when I try to open the listed Mydriver under devices from
Winobj.
I tried starting the driver's service again. I do get a handle back when
opening the service. But it wont start now. giving the error value of
Cannot find the file specified. I was working fine, i mean starting the
driver before this crash.
I am a beginner with drivers and doing this to learn, please guide.

Thursday, 19 September 2013

Chrome extension: Slide out menu from the left of Chrome window

Chrome extension: Slide out menu from the left of Chrome window

Is it possible add a functionality in the extension that when you mouse
over the left edge of Chrome window a menu with some options (what options
is not important now) will slide out?

Setting input value with javascript nullifies PHP post

Setting input value with javascript nullifies PHP post

I have PHP form where I collect a bunch of values from text inputs, but
for one input I have the input filled in via javascript (user selects a
date from a calendar, that date then populates a text input). The way the
form basically works (radically simplified) is this:
<?php
$email = $_POST['email'];
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" id="email" name="email" value="<?php echo
$_POST['email']; ?>" />
</form>
And then in jQuery or pure JS I do one of these:
$('#email').val('newValue');
or
document.getElementById('newValue').value = 'newValue';
Both of the above seem to work. They populate the input with the value I
want. But when I submit the form, the PHP variable that's supposed to
collect that value is null. Every other input in the form works, and if I
remove the javascript and manually enter the exact same text that I had
set with JavaScript into the input it works as well.
Any idea what's going on here? I've spent hours puzzling over this to no
avail.

Call an override method in an abstract class

Call an override method in an abstract class

i have a problem. I try to start the override Host method from Program.cs
in the abstract class AbstractGenericClass.
public abstract class AbstractGenericClass<T>
{
protected abstract void Host();
public static void Start()
{
//add additional logic for all classes that use this
try
{
((AbstractGenericClass<T>)
Activator.CreateInstance(typeof(T))).Host();
Console.WriteLine("Works!");
}
catch (Exception ex)
{
Console.WriteLine("Don't Works!");
}
}
}
class AnotherClass
{
public void DoSomething()
{
//NOP
}
}
class Program
: AbstractGenericClass<AnotherClass>
{
static void Main(string[] args)
{
Program.Start();
Console.ReadLine();
}
protected override void Host()
{
Console.WriteLine("Host running...");
}
}
I add here all sample classes i create for showing what i mean. The line
with ((AbstractGenericClass) Activator.CreateInstance(typeof(T))).Host();
crash the program because of InvalidCastException. It must be possible to
call the Host method but i have no idea how i could this, if this dont
operates.
Have you any other idea how this could operate? Or is this totally wrong
what i try?

Mondrian setup error. Ubuntu server, MySQL, tomcat6

Mondrian setup error. Ubuntu server, MySQL, tomcat6

I need to fix my Mondrian installation. I have created a mondrian.xml
schema with Schema WorkBench. This Schema was created poiting to a MySQL
Database.
Now when I try to browse this data from jpivot, I get this error:
The Mondrian XML: java.lang.NullPointerException
This are the changes I've made:
copied mysql-connector-java-5.0.8-bin.jar to /mondrian/WEB-INF/lib Not
sure if this is the correct way to setup the driver.
My servlet section in web.xml. I changed the DynamicDatasourceXmlaServlet,
don't know which I need actually
<servlet>
<servlet-name>MondrianXmlaServlet</servlet-name>
<servlet-class>mondrian.xmla.impl.MondrianXmlaServlet</servlet-class>
<init-param>
<param-name>DataSourcesConfig</param-name>
<param-value>/var/lib/tomcat6/webapps/mondrian/WEB-INF/datasources.xml</param-value>
</init-param>
</servlet>
My datasources.xml
<DataSources>
<DataSource>
<DataSourceName>Provider=Mondrian;DataSource=ocupacion;</DataSourceName>
<DataSourceDescription>datasource
ocupacion</DataSourceDescription>
<URL>http://localhost:8081/mondrian/xmla</URL>
<DataSourceInfo>Provider=mondrian;Jdbc=jdbc:mysql://172.26.0.120:3306/my_db;JdbcUser=root;JdbcPassword=mypass;JdbcDrivers=com.mysql.jdbc.Driver
<ProviderName>Mondrian</ProviderName>
<ProviderType>MDP</ProviderType>
<AuthenticationMode>Unauthenticated</AuthenticationMode>
<Catalogs>
<Catalog name="OCUPACION">
<Definition>/WEB-INF/queries/OCUPACION.xml</Definition>
</Catalog>
</Catalogs>
</DataSource>
I don't know if I need to do something else.
Thanks for helping! :)

sqlite or mysql for symfony2 CMF

sqlite or mysql for symfony2 CMF

I was installing the symfony2 CMF using composer and I noticed that the
default PDO handler for it is set to sqlite. I'm just curious if there's
any reason behind it that related to performance or the symfony team just
don't feel like using mysql for CMF.

Switch Statement Inside a For LOOP

Switch Statement Inside a For LOOP

Here is my code :
public class For_Loop {
public static void main(String[] args) {
for (int x = 10; x <= 20; x++){
switch (x) {
case 10:
System.out.println ("Ten");
break;
case 20:
System.out.println ("Twenty");
break;
default:
System.out.println ("None");
break;
}
}
}
}
What's wrong with this???

Replace result from awk

Replace result from awk

Basically, what I want to do is replacing a result parsed from awk with
something else. I have the following awk command :
awk '$1~/^DocumentRoot/{print $2}' /etc/apache2/sites-available/default
Which returns :
/var/www/
What I want to do is replace the /var/www/ (of course, it can be anything
and not /var/www/ in particular) in the file. I tried to pipe a sed
command, but I can't figure out how to do it...
Anyone can help ?

Wednesday, 18 September 2013

inner join-where-order by-limit in mysql

inner join-where-order by-limit in mysql

When I am executing mysql query with limit 0,50 . I am getting 50 rows.
SELECT md.*,cl.country_name FROM master_detail md
INNER JOIN country_list cl on cl.country_value=md.Partner_value
where md.for_country_value='577' order by md.id LIMIT 0,50
But When I am executing mysql query with limit 50,100 . I am getting 100
rows.
SELECT md.*,cl.country_name FROM master_detail md
INNER JOIN country_list cl on cl.country_value=md.Partner_value
where md.for_country_value='577' order by md.id LIMIT 50,100
It might be problem due to inner join? Actually I want data on the basis
of limit but how I dont know?

Python , vairiable doesnt accumlate over time?

Python , vairiable doesnt accumlate over time?

Okay well i'm new to python, and im taking a class in school for this, and
im a bit confused this. We are writing a program/script to calculate
transactions from buying and selling shares. and for some reason i cant
get the "balance" variable to accumulate over time and be subtracted from
and added to from buying and selling the shares. Here's the code, any
input would be amazing ^.^
def main():
#Below is the variables used in the context
balance = float(input("Starting cash amount? "))
numtrades = int(input("Number of trades for today?"))
print('You do not own any shares, but have', balance, 'in cash')
buy = 0
sell = 0
price_per_share = 0
transaction_amount = 0
transaction_amount_buy = 0
transaction_amount_sell = 0
#Below is the prompt for the first transaction, which requires a buy
num_shares = int(input('Number of shares to buy?'))
price_per_share = float(input('Price per share?'))
print(num_shares, "shares for $",price_per_share, "per share cost
$",price_per_share * num_shares)
buy = buy + num_shares
transaction_amount_buy = transaction_amount_buy + (num_shares *
price_per_share)
print("Currently holding", buy, "and have $", balance -
transaction_amount_buy , "in cash")
if balance < transaction_amount :
print('You do not have sufficient funds to purchase', num_shares,
'for $', price_per_share, 'per share.')
print('Your current balance is', balance, ', but', num_shares,' x
', price_per_share,' = ', num_shares * price_per_share)
print("Currently holding", buy, "and have $", balance -
transaction_amount , "in cash")
#Below is the loop counter for each trade, along with if statements for
buy/sell
for i in range(numtrades):
print('Trade number', (i + 2), end = "")
action = input(' (buy/sell)?')
if action == 'buy':
num_shares = int(input('Number of shares to buy?'))
if action == 'sell':
num_shares = int(input('Number of shares to sell?'))
price_per_share = float(input('Price per share?'))
print('Transaction', (i+2))
print('Transaction type is', action)
if action == 'buy':
print(num_shares, "shares for $",price_per_share, "per share cost
$",price_per_share * num_shares)
buy = buy + num_shares
transaction_amount_buy = transaction_amount_buy + (num_shares *
price_per_share)
if action == 'sell':
print(num_shares, 'shares for $',price_per_share, 'per share worth
$',price_per_share * num_shares)
sell = sell + num_shares
transaction_amount_sell = transaction_amount_sell + (num_shares *
price_per_share)
transaction_amount = transaction_amount_buy - transaction_amount_sell
if balance < transaction_amount :
print('You do not have sufficient funds to purchase', num_shares,
'for $', price_per_share, 'per share.')
print('Your current balance is', balance - transaction_amount, ',
but', num_shares,' x ', price_per_share,' = ', num_shares *
price_per_share)
print("Currently holding", buy, "and have $", balance -
transaction_amount , "in cash")
if balance > transaction_amount :
print("Currently holding", buy, "and have $", balance -
transaction_amount , "in cash")
main()

Opening a custom page upon click on google chrome extension icon

Opening a custom page upon click on google chrome extension icon

I want to open a new custom page like "p.html" (that I load with the
maps_app to the browser) when I click the google extension icon. It
shouldn't be a new tab as other questions answer, but replace the current
tab. To open in the present tab, to say the least.

C++, How do get this function to delete the string stored in the array?

C++, How do get this function to delete the string stored in the array?

I have a delete function that is supposed to delete a string in an array
by writing over it with the previous strings. The look function see's that
Overide matches and should be deleted. But the code i wrote for the loop
in Delete is not removing that first spot in the array that Overide has
taken up, and the output remains unchanged. Also each phrase after + is
being added into the array so four spots are taken in the array, and sorry
i could not make that part look better the formatting screwed it up.
int AR::Look(const std::string & word)
{
int result = -1;
for(int i=0; i<counter; ++i)
{
if( con[i].find(word) != std::string::npos)
result = i;
}
return result;
}
void AR::Delete(const string & word)
{
int loc = Look(word);
if (loc == -1)
{
cout<<"word not found\n";
}
else
{
for(int i=0; i<counter-1,i++;)
{
con[i]= con[i+1];
}
}
}
AR their
Ar(1);
theirAr + "Overload the +" + " operator as a member function " +
"with chaining to add a string " + "to an Arrary object.";
cout<<theirAr<<endl<<endl;
cout<<"testing Delete and Look. <<endl;
theirAr.Delete("XXXXXX");
theirAr.Delete("Overload");
cout<<"Output after Delete and Look called\n";
cout<<theirArray<<endl<<endl;

repeat do while loop if switch statement reaches default

repeat do while loop if switch statement reaches default

I have a do while loop asking for user input. Inside this do while loop I
have a switch statement. How can I make it so that if the default value is
met repeat the loop asking for the users gender again?
do
{
cout << "What is your weight?" << endl;
cin >> weight;
cout << "What is your height?" << endl;
cin >> height;
cout << "What is your age?" << endl;
cin >> age;
cout << "What is your gender?" << endl;
cin >> gender;
switch (gender)
{
case 'M':
case 'm':
cout << endl << Male(weight, height, age);
break;
case 'F':
case 'f':
cout << endl << Female(weight, height, age);
break;
default:
cout << "What is your gender?";
}
cout << "Do you want to continue? (Y/N)" << endl;
cin >> stopApp;
} while(toupper(stopApp) == 'Y');

There a somebody best way treat an error on generator of Yeoman?

There a somebody best way treat an error on generator of Yeoman?

There a somebody best way treat an error on generator of Yeoman? Because
sometimes occurs errors, but don't display where occurred specifically.

openstack error with ec2 api tools

openstack error with ec2 api tools

I have downloaded ec2rc.sh file on my computer and sourced it. When I try
to use ec2 commands such as: ec2-describe-images I get an error:
Unexpected error: org.codehaus.xfire.fault.XFireFault: Server returned
error code = 400 for URI : http://mycloud.org:8773/services/Cloud . Check
server logs for details at
org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89) at
org.codehaus.xfire.client.Invocation.invoke(Invocation.java:83) at
org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114) at
org.codehaus.xfire.client.Client.invoke(Client.java:336) at
org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77) at
org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57) at
com.sun.proxy.$Proxy12.describeImages(Unknown Source) at
com.amazon.aes.webservices.client.Jec2Impl.describeImages(Jec2Impl.java:534)
at
com.amazon.aes.webservices.client.cmd.DescribeImages.invokeOnline(DescribeImages.java:158)
at com.amazon.aes.webservices.client.cmd.BaseCmd.invoke(BaseCmd.java:1061)
at
com.amazon.aes.webservices.client.cmd.DescribeImages.main(DescribeImages.java:182)
Caused by: org.codehaus.xfire.XFireRuntimeException: Server returned error
code = 400 for URI : http://mycloud.org:8773/services/Cloud . Check server
logs for details at
org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:130)
at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
at
org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79) ... 9
more
On the controller node, there is nothing to report in keystone.log. I get
the following message in nova.log
2013-09-18 13:20:45.389 4958 INFO nova.ec2.wsgi.server [-] (4958) accepted
('130.237.221.115', 65154)
2013-09-18 13:20:45.400 4958 ERROR nova.api.ec2 [-] Unauthorized:
Signature not provided 2013-09-18 13:20:45.401 4958 INFO nova.api.ec2 [-]
0.1073s myhost POST /services/Cloud None:None 400 [ec2-api-tools 1.6.10.0]
text/xml text/xml 2013-09-18 13:20:45.402 4958 INFO nova.ec2.wsgi.server
[-] myhost "POST /services/Cloud HTTP/1.1" status: 400 len: 314 time:
0.0022440
What am I missing here?
Thanks

Can google datastore manage lots of continous write operations?

Can google datastore manage lots of continous write operations?

I'm using google app engine to read data from a google cloud sql database
and write some of its data and some derived data in google datastore, the
database right now doesn't have lots of entries per day, but it's
estimated to have around 200-300 entries per day on the future. I'm
testing to write all the data from the whole databse that now has a number
aproximately equal to these entries in it doesn't work properly, first of
all not all entries are being taken and derived data is sometimes properly
written and other times not, the result changes everytime I do a reading
from the database, so I guess that at least partially google datastore has
something that is related to the problem.
Don't know if google datastore could fall into race conditions or
something like that, although it would be sort of strange, but I'd like to
know if someone has had problems similar to mine and if how he was able to
solve it if he could.
Thanks.

Tuesday, 17 September 2013

concatenating 2 django query result into one

concatenating 2 django query result into one

res= table.objects.values('lat','lng')
res1 = table1.objects.values('lat','lng')
res1=[{'lat': u'22.216021036729217', 'lng': u'84.83377508819103'}]
res=[{'lat': u'15.898394035175443', 'lng': u'73.82306920364499'}]
I want to add result of res and res1 into poi:
poi = [{'lat': u'15.898394035175443', 'lng': u'73.82306920364499'},{'lat':
u'22.216021036729217', 'lng': u'84.83377508819103'} ]
I have tried poi=list(res)+list(res1) but got the following error:
list referenced before assignment

Fetch user plotted latitude and longitude on Google Maps

Fetch user plotted latitude and longitude on Google Maps

I've a map displayed to the user, and he/she has the ability to plot on
the map his/her location and the google map marker appears, now how do I
fetch programatically the location plotted by the user on the google map.
I will be using this data and storing it in my database, which I can
handle on my own, but I'm unsure of how to fetch the data plotted by the
user.
Someone has already implemented it or has a link or tutorials to it,
please share.
Thanks

MySQL Order By alternate values

MySQL Order By alternate values

Im having trouble in MySQL query Order By.
First I have a table(tbl_records) that contains 10000+ records. This table
has a primary key called rec_id and a foreign key rec_f_id.
rec_f_id has only two kinds of value (555, 666).
Now my problem is how can I gather the records on the table that orders in
alternate value of rec_f_id.
Eg
SELECT * FROM tbl_records ORDER BY FIELD(rec_f_id, 555, 666) LIMIT 100;
The above query only returns record with rec_f_id = 555. What I want to
have is
| rec_id | rec_f_id |
|1 |555 |
|2 |666 |
|3 |555 |
|4 |666 |
|5 |555 |
|6 |666 |
|7 |555 |
|8 |666 |
|9 |555 |
...
Thanks!

How to resolve this? "unfortunately has stopped"

How to resolve this? "unfortunately has stopped"

I can't figure out, the loop and randoms i cant see, the program will
close directly.. and pop up "unfortunately has stopped"?
package com.main.project.spotddifference;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener {
private long startTime = 0L;
private Handler customHandler = new Handler();
long timeInMilliseconds = 0L;
long timeSwapBuff = 0L;
long updatedTime = 0L;
Context context;
ImageView display,all;
TextView timer;
int anss,triesCount;
Random random = new Random( System.currentTimeMillis() );
int next = random.nextInt( 23 ) + 1;
int[] imageViews = {R.id.A,R.id.B,R.id.C,R.id.D };
int[] img = new int[]
{R.drawable.img1,R.drawable.img2,R.drawable.img3,R.drawable.img4,
R.drawable.img5,R.drawable.img6,R.drawable.img7,R.drawable.img8,
R.drawable.img9,R.drawable.img10,R.drawable.img11,R.drawable.img12,
R.drawable.img13,R.drawable.img14,R.drawable.img15,R.drawable.img16,
R.drawable.img17,R.drawable.img18,R.drawable.img19,R.drawable.img20,
R.drawable.img21,R.drawable.img22,R.drawable.img23,R.drawable.img24};
int [] ansLET = new int[]
{R.drawable.alpha,R.drawable.charlie,R.drawable.alpha,R.drawable.delta,
R.drawable.delta,R.drawable.alpha,R.drawable.beta,R.drawable.alpha,
R.drawable.alpha,R.drawable.beta,R.drawable.delta,R.drawable.delta,
R.drawable.charlie,R.drawable.alpha,R.drawable.charlie,R.drawable.alpha,
R.drawable.beta,R.drawable.delta,R.drawable.charlie,R.drawable.alpha,
R.drawable.beta,R.drawable.alpha,R.drawable.charlie,R.drawable.delta};
int [] ansImg = new
int[]{R.drawable.aimg1,R.drawable.aimg2,R.drawable.aimg3,R.drawable.aimg4,
R.drawable.aimg5,R.drawable.aimg6,R.drawable.aimg7,R.drawable.aimg8,
R.drawable.aimg9,R.drawable.aimg10,R.drawable.aimg11,R.drawable.aimg12,
R.drawable.aimg13,R.drawable.aimg14,R.drawable.aimg15,R.drawable.aimg16,
R.drawable.aimg17,R.drawable.aimg18,R.drawable.aimg19,R.drawable.aimg20,
R.drawable.aimg21,R.drawable.aimg22,R.drawable.aimg23,R.drawable.aimg24};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
display = (ImageView)findViewById(R.id.imageView1);
timer = (TextView)findViewById(R.id.textView1);
context = this;
allImage();
allButton();
}
private void allButton() {
Button choose = (Button)findViewById(R.id.choice);
Button quit = (Button)findViewById(R.id.back);
choose.setOnClickListener(this);
quit.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.splash, menu);
return true;
}
private void allImage() {
ImageView a= (ImageView)findViewById(R.id.A);
ImageView b= (ImageView)findViewById(R.id.B);
ImageView c= (ImageView)findViewById(R.id.C);
ImageView d= (ImageView)findViewById(R.id.D);
a.setOnClickListener(this);
b.setOnClickListener(this);
c.setOnClickListener(this);
d.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
switch(arg0.getId()){
case R.id.A:
display.setImageResource(R.drawable.alpha);
break;
case R.id.B:
display.setImageResource(R.drawable.beta);
break;
case R.id.C:
display.setImageResource(R.drawable.charlie);
break;
case R.id.D:
display.setImageResource(R.drawable.delta);
break;
case R.id.choice:
checkAns();
break;
case R.id.quit:
Intent intent2 = new Intent (this,MenuActivity.class);
startActivity(intent2);
break;
}
}
public void randomImage(){
List<Integer> generated = new ArrayList<Integer>();
for (int i = 0; i < imageViews.length; i++) {
int v = imageViews[i]-1;
int vs = imageViews[i]-3;
if ( generated.contains( next ) ) {
generated.add( next );
ImageView iv = (ImageView) findViewById( v );
ImageView ivs = (ImageView) findViewById( vs );
iv.setImageResource( img[next] );
ivs.setImageResource(ansImg[next]);
checkAns();
}
}
}
@SuppressWarnings("unchecked")
public void checkAns(){
for(int a = 1 ; a <= 2 ; a++){
for(int s = 1 ; s <= 5; s++ ){
if(((List<Integer>) display).contains(ansLET[next])){
randomImage();
}
else{
Intent in = new Intent
(getApplicationContext(),AgainActivity.class);
in.putExtra("result", "Congratulation!.You got the right
answer!.");
startActivity(in);
break;
}
}
Intent go = new Intent
(getApplicationContext(),CongratsActivity.class);
startActivity(go);
}
}
public void startTime(){
startTime = SystemClock.uptimeMillis();
customHandler.postDelayed(updateTimerThread, 0);
}
public void pauseTime(){
timeSwapBuff += timeInMilliseconds;
customHandler.removeCallbacks(updateTimerThread);
}
private Runnable updateTimerThread = new Runnable() {
public void run() {
timeInMilliseconds = SystemClock.uptimeMillis() - startTime;
updatedTime = timeSwapBuff + timeInMilliseconds;
int secs = (int) (updatedTime / 1000);
int mins = secs / 60;
secs = secs % 60;
int milliseconds = (int) (updatedTime % 1000);
timer.setText("" + String.format("%02",mins) + ":"
+ String.format("%02d", secs) + ":"
+ String.format("%02d", milliseconds));
customHandler.postDelayed(this, 0);
}
};
}
my XML file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="350dp"
android:layout_height="350dp"
android:layout_centerVertical="true" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/A"
android:layout_width="270dp"
android:layout_height="270dp"
android:layout_marginBottom="25dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="25dp"
android:contentDescription="@string/pics"
/>
<ImageView
android:id="@+id/B"
android:layout_width="270dp"
android:layout_height="270dp"
android:layout_marginBottom="25dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="25dp"
android:contentDescription="@string/pics"
/>
<ImageView
android:id="@+id/C"
android:layout_width="270dp"
android:layout_height="270dp"
android:layout_marginBottom="25dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="25dp"
android:contentDescription="@string/pics"
/>
<ImageView
android:id="@+id/D"
android:layout_width="270dp"
android:layout_height="270dp"
android:layout_marginBottom="25dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="25dp"
android:contentDescription="@string/pics"
/>
</LinearLayout>
</HorizontalScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/horizontalScrollView1"
android:layout_marginBottom="15dp"
android:layout_alignParentBottom="true" >
<Button
android:id="@+id/choice"
android:layout_width="150dp"
android:layout_height="70dp"
android:background="@drawable/button_custom3"
android:text="@string/btn_in_choose"
android:textStyle="bold" />
<ImageView
android:id="@+id/answer"
android:layout_width="110dp"
android:layout_height="80dp"
android:layout_marginRight="20dp"
android:contentDescription="@string/pics"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/horizontalScrollView1"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:weightSum="200" >
<Button
android:layout_weight="20"
android:id="@+id/back"
android:layout_width="50dp"
android:layout_height="80dp"
android:background="@drawable/button_custom3"
android:text="@string/btn_mainmenu"
android:textStyle="bold" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="160"
android:text="@string/heading_timer"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:layout_weight="20"
android:id="@+id/hm"
android:layout_width="50dp"
android:layout_height="80dp"
android:background="@drawable/button_custom3"
android:text="@string/btn_in_hint"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
Logcat File:
09-17 22:45:22.828: D/dalvikvm(935): GC_FOR_ALLOC freed 38K, 7% free
2402K/2580K, paused 51ms, total 54ms
09-17 22:45:22.848: I/dalvikvm-heap(935): Grow heap (frag case) to 3.944MB
for 1536016-byte allocation
09-17 22:45:22.918: D/dalvikvm(935): GC_FOR_ALLOC freed <1K, 5% free
3901K/4084K, paused 66ms, total 66ms
09-17 22:45:23.008: D/dalvikvm(935): GC_CONCURRENT freed <1K, 5% free
3901K/4084K, paused 9ms+6ms, total 89ms
09-17 22:45:23.398: D/dalvikvm(935): GC_FOR_ALLOC freed <1K, 5% free
3901K/4084K, paused 37ms, total 37ms
09-17 22:45:23.409: I/dalvikvm-heap(935): Grow heap (frag case) to 4.766MB
for 864016-byte allocation
09-17 22:45:23.558: D/dalvikvm(935): GC_CONCURRENT freed 0K, 4% free
4745K/4928K, paused 89ms+5ms, total 147ms
09-17 22:45:23.558: D/dalvikvm(935): WAIT_FOR_CONCURRENT_GC blocked 8ms
09-17 22:45:23.888: D/dalvikvm(935): GC_CONCURRENT freed 1500K, 30% free
3946K/5628K, paused 6ms+57ms, total 171ms
09-17 22:45:24.108: D/dalvikvm(935): GC_FOR_ALLOC freed 697K, 36% free
3643K/5628K, paused 38ms, total 43ms
09-17 22:45:24.128: I/dalvikvm-heap(935): Grow heap (frag case) to 5.155MB
for 1536016-byte allocation
09-17 22:45:24.288: D/dalvikvm(935): GC_FOR_ALLOC freed <1K, 28% free
5142K/7132K, paused 154ms, total 155ms
09-17 22:45:24.428: D/dalvikvm(935): GC_CONCURRENT freed <1K, 28% free
5142K/7132K, paused 9ms+6ms, total 140ms
09-17 22:45:25.068: D/dalvikvm(935): GC_CONCURRENT freed <1K, 17% free
5986K/7132K, paused 73ms+89ms, total 267ms
09-17 22:45:25.158: D/dalvikvm(935): GC_FOR_ALLOC freed 1500K, 9% free
4487K/4924K, paused 62ms, total 63ms
09-17 22:45:25.188: I/dalvikvm-heap(935): Grow heap (frag case) to 5.979MB
for 1536016-byte allocation
09-17 22:45:25.398: D/dalvikvm(935): GC_CONCURRENT freed <1K, 7% free
5987K/6428K, paused 74ms+46ms, total 211ms
09-17 22:45:25.908: D/dalvikvm(935): GC_FOR_ALLOC freed 1500K, 27% free
5331K/7272K, paused 51ms, total 52ms
09-17 22:45:25.908: I/dalvikvm-heap(935): Grow heap (frag case) to 6.804MB
for 1536016-byte allocation
09-17 22:45:26.128: D/dalvikvm(935): GC_CONCURRENT freed <1K, 7% free
6831K/7272K, paused 72ms+6ms, total 201ms
09-17 22:45:26.688: D/dalvikvm(935): GC_FOR_ALLOC freed 1500K, 24% free
6175K/8116K, paused 62ms, total 62ms
09-17 22:45:26.688: I/dalvikvm-heap(935): Grow heap (frag case) to 7.628MB
for 1536016-byte allocation
09-17 22:45:26.898: D/dalvikvm(935): GC_CONCURRENT freed <1K, 6% free
7675K/8116K, paused 75ms+28ms, total 202ms
09-17 22:45:27.439: D/dalvikvm(935): GC_FOR_ALLOC freed 1500K, 22% free
7020K/8960K, paused 50ms, total 51ms
09-17 22:45:27.639: D/dalvikvm(935): GC_CONCURRENT freed <1K, 5% free
8520K/8960K, paused 71ms+22ms, total 185ms
09-17 22:45:28.129: D/dalvikvm(935): GC_FOR_ALLOC freed 1500K, 20% free
7864K/9804K, paused 46ms, total 46ms
09-17 22:45:28.609: D/dalvikvm(935): GC_FOR_ALLOC freed <1K, 5% free
9364K/9804K, paused 43ms, total 44ms
09-17 22:45:28.738: D/dalvikvm(935): GC_FOR_ALLOC freed 1500K, 19% free
8708K/10648K, paused 47ms, total 47ms
09-17 22:45:29.198: D/dalvikvm(935): GC_FOR_ALLOC freed <1K, 5% free
10208K/10648K, paused 45ms, total 46ms
09-17 22:45:29.318: D/dalvikvm(935): GC_FOR_ALLOC freed 1500K, 17% free
9553K/11492K, paused 40ms, total 46ms
09-17 22:45:29.808: D/dalvikvm(935): GC_FOR_ALLOC freed <1K, 4% free
11053K/11492K, paused 66ms, total 66ms
09-17 22:45:29.948: D/dalvikvm(935): GC_FOR_ALLOC freed 1500K, 16% free
10397K/12336K, paused 52ms, total 53ms
09-17 22:45:30.398: D/dalvikvm(935): GC_FOR_ALLOC freed <1K, 4% free
11897K/12336K, paused 56ms, total 57ms
09-17 22:45:30.518: D/dalvikvm(935): GC_FOR_ALLOC freed 1500K, 15% free
11241K/13180K, paused 48ms, total 49ms
09-17 22:45:30.958: D/dalvikvm(935): GC_FOR_ALLOC freed <1K, 4% free
12741K/13180K, paused 51ms, total 52ms
09-17 22:45:31.268: I/Choreographer(935): Skipped 72 frames! The
application may be doing too much work on its main thread.
09-17 22:45:31.298: D/gralloc_goldfish(935): Emulator without GPU
emulation detected.
09-17 22:45:36.348: I/Choreographer(935): Skipped 79 frames! The
application may be doing too much work on its main thread.
09-17 22:45:36.458: I/Choreographer(935): Skipped 78 frames! The
application may be doing too much work on its main thread.
09-17 22:45:36.588: I/Choreographer(935): Skipped 83 frames! The
application may be doing too much work on its main thread.
09-17 22:45:36.808: I/Choreographer(935): Skipped 83 frames! The
application may be doing too much work on its main thread.
09-17 22:45:38.178: D/dalvikvm(935): GC_FOR_ALLOC freed 1507K, 14% free
12737K/14644K, paused 158ms, total 187ms
09-17 22:45:39.329: I/Choreographer(935): Skipped 2407 frames! The
application may be doing too much work on its main thread.
09-17 22:45:39.988: I/Choreographer(935): Skipped 620 frames! The
application may be doing too much work on its main thread.
09-17 22:45:40.748: I/Choreographer(935): Skipped 703 frames! The
application may be doing too much work on its main thread.
09-17 22:45:41.048: I/Choreographer(935): Skipped 285 frames! The
application may be doing too much work on its main thread.
09-17 22:45:43.338: I/Choreographer(935): Skipped 77 frames! The
application may be doing too much work on its main thread.
09-17 22:45:43.908: I/Choreographer(935): Skipped 40 frames! The
application may be doing too much work on its main thread.
09-17 22:45:44.338: I/Choreographer(935): Skipped 132 frames! The
application may be doing too much work on its main thread.
09-17 22:45:48.948: D/AndroidRuntime(935): Shutting down VM
09-17 22:45:48.948: W/dalvikvm(935): threadid=1: thread exiting with
uncaught exception (group=0x40a71930)
09-17 22:45:49.108: E/AndroidRuntime(935): FATAL EXCEPTION: main
09-17 22:45:49.108: E/AndroidRuntime(935):
java.util.UnknownFormatConversionException: Conversion: 02
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.util.Formatter$FormatSpecifierParser.unknownFormatConversionException(Formatter.java:2304)
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.util.Formatter$FormatSpecifierParser.advance(Formatter.java:2298)
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.util.Formatter$FormatSpecifierParser.parseConversionType(Formatter.java:2377)
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.util.Formatter$FormatSpecifierParser.parseWidth(Formatter.java:2360)
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.util.Formatter$FormatSpecifierParser.parseArgumentIndexAndFlags(Formatter.java:2344)
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.util.Formatter$FormatSpecifierParser.parseFormatToken(Formatter.java:2281)
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.util.Formatter.doFormat(Formatter.java:1069)
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.util.Formatter.format(Formatter.java:1040)
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.util.Formatter.format(Formatter.java:1009)
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.lang.String.format(String.java:1988)
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.lang.String.format(String.java:1962)
09-17 22:45:49.108: E/AndroidRuntime(935): at
com.main.project.spotddifference.MainActivity$1.run(MainActivity.java:196)
09-17 22:45:49.108: E/AndroidRuntime(935): at
android.os.Handler.handleCallback(Handler.java:725)
09-17 22:45:49.108: E/AndroidRuntime(935): at
android.os.Handler.dispatchMessage(Handler.java:92)
09-17 22:45:49.108: E/AndroidRuntime(935): at
android.os.Looper.loop(Looper.java:137)
09-17 22:45:49.108: E/AndroidRuntime(935): at
android.app.ActivityThread.main(ActivityThread.java:5041)
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.lang.reflect.Method.invokeNative(Native Method)
09-17 22:45:49.108: E/AndroidRuntime(935): at
java.lang.reflect.Method.invoke(Method.java:511)
09-17 22:45:49.108: E/AndroidRuntime(935): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-17 22:45:49.108: E/AndroidRuntime(935): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-17 22:45:49.108: E/AndroidRuntime(935): at
dalvik.system.NativeStart.main(Native Method)
09-17 22:45:52.828: I/Process(935): Sending signal. PID: 935 SIG: 9
09-17 22:45:53.808: E/Trace(972): error opening trace file: No such file
or directory (2)
09-17 22:45:54.478: D/dalvikvm(972): GC_FOR_ALLOC freed 41K, 8% free
2402K/2584K, paused 139ms, total 176ms
09-17 22:45:54.578: I/dalvikvm-heap(972): Grow heap (frag case) to 3.944MB
for 1536016-byte allocation
09-17 22:45:54.748: D/dalvikvm(972): GC_FOR_ALLOC freed <1K, 5% free
3901K/4088K, paused 169ms, total 169ms
09-17 22:45:54.948: D/dalvikvm(972): GC_CONCURRENT freed <1K, 5% free
3901K/4088K, paused 15ms+26ms, total 199ms
09-17 22:45:56.298: D/dalvikvm(972): GC_FOR_ALLOC freed <1K, 5% free
3901K/4088K, paused 238ms, total 238ms
09-17 22:45:56.358: I/dalvikvm-heap(972): Grow heap (frag case) to 4.766MB
for 864016-byte allocation
09-17 22:45:56.618: D/dalvikvm(972): GC_CONCURRENT freed 0K, 4% free
4745K/4932K, paused 74ms+35ms, total 258ms
09-17 22:45:57.848: D/dalvikvm(972): GC_FOR_ALLOC freed 1500K, 31% free
3872K/5560K, paused 140ms, total 170ms
09-17 22:45:58.218: D/dalvikvm(972): GC_CONCURRENT freed 625K, 34% free
3704K/5560K, paused 6ms+6ms, total 228ms
09-17 22:45:58.588: D/dalvikvm(972): GC_CONCURRENT freed 291K, 32% free
3805K/5560K, paused 77ms+33ms, total 174ms
09-17 22:45:58.868: I/Choreographer(972): Skipped 46 frames! The
application may be doing too much work on its main thread.
09-17 22:45:58.899: D/gralloc_goldfish(972): Emulator without GPU
emulation detected.
09-17 22:46:13.848: I/Choreographer(972): Skipped 88 frames! The
application may be doing too much work on its main thread.
09-17 22:46:14.098: D/AndroidRuntime(972): Shutting down VM
09-17 22:46:14.118: W/dalvikvm(972): threadid=1: thread exiting with
uncaught exception (group=0x40a71930)
09-17 22:46:14.368: E/AndroidRuntime(972): FATAL EXCEPTION: main
09-17 22:46:14.368: E/AndroidRuntime(972): java.lang.RuntimeException:
Unable to start activity ComponentInfo
{com.main.project.spotddifference/com.main.project.spotddifference.HelpActivity}:
android.content.res.Resources$NotFoundException: Resource ID
#0x7f090014 type #0x12 is not valid
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.app.ActivityThread.access$600(ActivityThread.java:141)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.os.Looper.loop(Looper.java:137)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.app.ActivityThread.main(ActivityThread.java:5041)
09-17 22:46:14.368: E/AndroidRuntime(972): at
java.lang.reflect.Method.invokeNative(Native Method)
09-17 22:46:14.368: E/AndroidRuntime(972): at
java.lang.reflect.Method.invoke(Method.java:511)
09-17 22:46:14.368: E/AndroidRuntime(972): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-17 22:46:14.368: E/AndroidRuntime(972): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-17 22:46:14.368: E/AndroidRuntime(972): at
dalvik.system.NativeStart.main(Native Method)
09-17 22:46:14.368: E/AndroidRuntime(972): Caused by:
android.content.res.Resources$NotFoundException: Resource ID #0x7f090014
type #0x12 is not valid
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.content.res.Resources.loadXmlResourceParser(Resources.java:2144)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.content.res.Resources.getLayout(Resources.java:853)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.view.LayoutInflater.inflate(LayoutInflater.java:394)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
09-17 22:46:14.368: E/AndroidRuntime(972): at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.app.Activity.setContentView(Activity.java:1881)
09-17 22:46:14.368: E/AndroidRuntime(972): at
com.main.project.spotddifference.HelpActivity.onCreate(HelpActivity.java:17)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.app.Activity.performCreate(Activity.java:5104)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
09-17 22:46:14.368: E/AndroidRuntime(972): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
09-17 22:46:14.368: E/AndroidRuntime(972): ... 11 more
09-17 22:46:16.808: I/Process(972): Sending signal. PID: 972 SIG: 9
this is my codes , please help me out off this problem.

Linq == null vs IsNullOrEmpty -- Different or Same?

Linq == null vs IsNullOrEmpty -- Different or Same?

In Linq or Linq to Sql to be more accurate: is there a difference between
the == null and the IsNullOrEmpty in the below queries?
From a in context.SomeTable
where a.SomeId.Equals(SomeOtherId)
&& a.SomeOtherColumn == null
Select new .....
&
From a in context.SomeTable
where a.SomeId.Equals(SomeOtherId)
&& string.IsNullOrEmpty(a.SomeOtherColumn)
Select new .....

Rails NoMethodError (undefined method `employee' for nil:NilClass)

Rails NoMethodError (undefined method `employee' for nil:NilClass)

I got the following in the Rails log:
NoMethodError (undefined method `employee' for nil:NilClass):
app/datatables/workorders4_datatable.rb:16:in `as_json'
app/controllers/workorders_controller.rb:92:in `block (2 levels) in index8'
app/controllers/workorders_controller.rb:90:in `index8'
This is the workorders4_datatable code:
class Workorders4Datatable
delegate :params, :h, :link_to, :number_to_currency, to: :@view
def initialize(view)
@view = view
end
def mygroupsopenwos(employee)
workorders.select("workorders.*").joins("left outer join empgroups ON
empgroups.workgroup_id=workorders.workgroup_id").where("empgroups.employee_id
= ?", employee).where("wostatus_id NOT IN (?)", [231, 230, 9263, 9264,
232] )
end
def as_json(options = {})
{
sEcho: params[:sEcho].to_i,
iTotalRecords: mygroupsopenwos(User.current.employee.id).count,
iTotalDisplayRecords:
mygroupsopenwos(User.current.employee.id).total_entries,
aaData: data
}
end
private
def data
mygroupsopenwos(User.current.employee.id).map do |workorder|
[
link_to(workorder.wonum, workorder),
h(workorder.parent.try(:wonum)),
h(workorder.workgroup.try(:group_name)),
h(workorder.employee.try(:last_name)),
h(workorder.description),
h(workorder.type.try(:typecode)),
h(workorder.location.try(:name)),
h(workorder.woasset.try(:assetnum)),
h(workorder.wostatus.try(:statuscode)),
h(workorder.priority)
]
end
end
def workorders
@workorders ||= fetch_workorders
end
def fetch_workorders
workorders = Workorder.order("#{sort_column} #{sort_direction}")
workorders = workorders.page(page).per_page(per_page)
if params[:sSearch].present?
workorders =
workorders.includes(:wostatus,:employee,:client,:type,:location).where("wonum
ILIKE :search or workorders.description ILIKE :search or
wostatuses.statuscode ILIKE :search or employees.last_name ILIKE
:search or employees.first_name ILIKE :search or clients.client_name
ILIKE :search or types.typecode ILIKE :search or locations.name
ILIKE :search", search: "%#{params[:sSearch]}%")
end
workorders
end
def page
params[:iDisplayStart].to_i/per_page + 1
end
def per_page
params[:iDisplayLength].to_i > 0 ? params[:iDisplayLength].to_i : 10
end
def sort_column
columns = %w[workorders.wonum workorders.parent_id
workorders.workgroup_id workorders.employee_id workorders.description
workorders.type_id workorders.location_id workorders.woasset_id
workorders.wostatus_id workorders.priority]
columns[params[:iSortCol_0].to_i]
end
def sort_direction
params[:sSortDir_0] == "desc" ? "desc" : "asc"
end
end
This line of code tries to get the employee:
h(workorder.employee.try(:last_name)),
I'm using TRY - so why would I get an error?
Thanks for your help!!

Lines Shift on report

Lines Shift on report

I'm having an issue with my reports, I built the report with vb.net in
visual studio, the problem is when I'm sending to the printer, just the
first prints are ok , the other pages shifts the lines, I already changed
the printer and I its the same result.
Any Ideas
thanks

Sunday, 15 September 2013

How to perfectly combine Scrum and Kanban

How to perfectly combine Scrum and Kanban

I understand the philosophies of both Scrum and Kanban. I've seen some
articles saying they can be combined together to achieve better efficiency
than using only one of them. Can someone share some experience of running
a scrum team by combining Scrum and Kanban together? Any thoughts are
appreciated.

Implementing dropzone.js in java

Implementing dropzone.js in java

im using http://www.dropzonejs.com/ in a java web project. The problem is
that i cant find out how to handle the file in the server side. There are
some examples but they are in php and other languajes. Here is one of the
examples:
http://www.startutorial.com/articles/view/how-to-build-a-file-upload-form-using-dropzonejs-and-php
Thank you!

NimbusLookAndFeel cannot be resolved to a variable

NimbusLookAndFeel cannot be resolved to a variable

I am trying to learn the basic GUI using swing. When I tried to
activate/set nimbus, the following error is shown
"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel cannot be resolved to a
variable". The error is shown in the
com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel line in setLookAndFeel()
method. I am using java build 1.7.0
import java.awt.FlowLayout;
import javax.swing.UIManager.LookAndFeelInfo; import javax.swing.*;
public class swing1 extends JFrame {
public swing1(){
super("Title: Swing Project 1");
//setLookAndFeel();
setSize(225,80);
setLookAndFeel();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
FlowLayout flo = new FlowLayout();
JButton adds = new JButton ("Add");
JButton minus = new JButton("Substract");
JButton mult = new JButton ("Multiply");
add(adds);
add(minus);
add(mult);
setVisible(true);
}
private void setLookAndFeel() {
// TODO Auto-generated method stub
try {
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"
);
}
catch (Exception exc) {
//ignore
}
} public static void main (String args []){
swing1 startSwing = new swing1();
}
}

JButton and jgraphx wont show up at the same time

JButton and jgraphx wont show up at the same time

I have tried several ways, but still havent found the solution. I have a
jgraph in a frame and I want to add a Jbutton in that frame also in a
specific location. However I only get one of them when i run the program,
because they expand to the whole window. Any ideas how to fix this?
Thanks in advance.
public class GUIquery extends JFrame {
JFrame frame ;
static JGraph jgraph ;
final mxGraph graph = new mxGraph() ;
final mxGraphComponent graphComponent = new mxGraphComponent(graph);
public GUIquery() {
super("Test");
GraphD() ;
imgbtn();
}
public void GraphD() {
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
try
{ ..... }
finally
{
graph.getModel().endUpdate();
}
getContentPane().add(graphComponent);
public void imgbtn() {
JPanel jpanel = new JPanel() ;
jpanel.setSize(100, 100) ;
jpanel.setLocation(1200,60) ;
JButton imgbtn = new JButton("Export as Image") ;
imgbtn.setSize(100, 100) ;
imgbtn.setLocation(1200,60) ;
jpanel.add(imgbtn);
add(jpanel);
}
}
public static void main(String[] args)
{
GUIquery frame = new GUIquery();
frame.setLayout(null);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 320);
frame.setVisible(true);
}
}

Make hidden div appear then fade away?

Make hidden div appear then fade away?

What is the simplest way to make a div appear then fade a way for a few
second?
.fade_div {
visibility: none;
position: fixed;
background-color: yellow;
border: 1px solid black;
top: 300px;
left: 300px
}
<input type="button" value="Add Item" id="mybutton">
<div class="fade_div">Successfully Added!</div>
$('mybutton').click(function(){
$('.fade_div').....
}

String replacement not working in powershell script at runtime

String replacement not working in powershell script at runtime

I have powershell file in which i have line of variable decalration as below
[string] $global:myExePath = "\\myshare\code\scripts";
I want to replace \\myshare\code\scripts with \\mynewshare\code1\psscript
at runtime by executing a powershell script.
I am using
Get-Content $originalfile | ForEach-Object { $_ -replace
"\\myshare\code\scripts", $mynewcodelocation.FullName } | Set-Content
($originalfile)
If am execuing { $_ -replace "scripts", $mynewcodelocation.FullName } it
is working fine, but it is not working for { $_ -replace
"\\myshare\code\scripts", $mynewcodelocation.FullName }
What is wrong here ?

How to pass JavaScript variable to in php

How to pass JavaScript variable to in php

I want to pass javascript variable as a path to <img src="path"> in php
my code is
javascript code

`
function showSmallImage(path)
{
document.getElementById("small_image").value = path;
}
`i am getting path and i have to pass it to
php code

echo "<img id='small_image' src='".$path."'>";but i am not getting any way
to solve it please suggest me any way to solve this issue.
Thanks in advanced!!!

Saturday, 14 September 2013

stop R process without closing console?

stop R process without closing console?

I've accidentally initiated a long process in R without saving what I need
from the workspace I'm using in the R console. I would like to stop the
current process without closing the console. But, what always happens in
an intensive process is that the R Console will not respond. I will then
either have to wait or exit out of the console. I am running 64 bit R
2.15.0 and my OS is Windows & 64-bit. Is there some way to kill R
processes outside the R environment and not close the console?

dot42/xamarin Android programming and applying AlertDialog's SetOnCancelListener method

dot42/xamarin Android programming and applying AlertDialog's
SetOnCancelListener method

I try to 'develop' an Android application with C# (VS2010 + dot42/mono)
which shows lots od messages, gets users' input, and creates AlertDialogs.
The questions are: 1. Do you know how to catch OnCancel Event returned
from Android AlertDialog(s)? 2. How to detect which exactly AlertDialog
sent it?
To be more clear, I am trying to get the AlertDialog.Builder
SetOnCancelListener(IDialogInterface_IOnCancelListener onCancelListener)
to work.
I have created a method which displays a simple message box, and I try to
catch somehow (but it is all wrong so far) the onCancel event. Please see
below. Can you help me?
private void button2_OnClick(object sender, EventArgs eventArgs)
{
AlertDialog.Builder a_builder = new AlertDialog.Builder(this);
a_builder.SetMessage("Is this all?");
a_builder.SetTitle("Question");
a_builder.SetPositiveButton("Yes", OnMsgClick_Result2 );
a_builder.SetNegativeButton("Not yet" OnMsgClick_Result2);
a_builder.SetCancelable(true);
a_builder.SetOnCancelListener(
new IDialogInterface_IOnCancelListener(
new IDialogInterface_IOnClickListener(IDialogInterface
dialog) {
switch (dialog.which) //<--------- ???
{
case _dialogA:
text1.settext("DialogA was canceled");
break;
case _dialogB:
text1.settext("DialogB was canceled");
break;
default:
text1.settext("Nothing has been canceled");
break;
}
})
); //<--- ??? ERROR HERE of course
a_builder.Create().Show();
}

Comparing Multiple Items

Comparing Multiple Items

I apologize for my ignorance, but I've gone through stackoverflow array
element comparison topics, but none of them really have what I need.
I'm programming in java.
My problem is that I need to compare multiple items in an ArrayList,
however I can't seem to figure out how to draw images where the ArrayItem
is.
Like I have an Item in arraylist with an x and y, and in my main activity
class, I try to do
g.getImage(picturename, ArrayItem.x, ArrayItem.y, this);
It asks me to change the items x and y to static.
If someone could point me in the correct way, thanks.

Does tiOPF support on XE3 or XE4

Does tiOPF support on XE3 or XE4

Does tiOPF http://tiopf.sourceforge.net/ is support for XE3 or XE4 ?

How to get total possible result set from a pagination type query?

How to get total possible result set from a pagination type query?

I'm using SQLLite in AS3 AIR, and am paginating like in the following
example query (100 results per page):
SELECT * FROM table1 WHERE col1 LIKE "%my keywords here%" LIMIT 100 OFFSET 0
It works fine - I change the offset when the user hits a next or previous
button. So the next button's subsequent query is:
SELECT * FROM table1 WHERE col1 LIKE "%my keywords here%" LIMIT 100 OFFSET
100
Just wondering if it's possible to get the total number of possible
results, so I can dsiplay 'page 3 of 12' etc? Or do I have to do two
queries - the first a count(*) without the LIMIT and OFFSET so I get the
result total, and then the above query to get the actual page result?
Thanks for your time and help.

Iterating an array

Iterating an array

I have framed an array like below
iArray = [true, true, false, false, false, false, false, false, true,
true, true, false,
true, false, false, false, false, true]
Condtional check: If anyone of the value in this array is false I will be
showing an error message else if everything is true I will be showing
success message.
var boolIteration = iArray.split(',');
var i;
for (i = 0; i < boolIteration.length; ++i) {
//conditional check
}
I'm struggling to iterate the array using the above condition.
Can anyone point me in the right direction with an efficient solution.