Thursday, 19 September 2013

Media queries catch tablet portrait

Media queries catch tablet portrait

I have the following rules:
@media only screen and (min-device-width : 320px) and (max-device-width :
480px)
@media only screen and (min-width : 321px) /* Smartphones (landscape) */
@media only screen and (max-width : 320px) /* Smartphones (portrait) */
@media only screen and (min-width: 768px) /* tablets and desktops */
How to catch tablet portrait without affect the other rules?

Changing service reference endpoint at runtime, sometimes the wrong endpoint is used

Changing service reference endpoint at runtime, sometimes the wrong
endpoint is used

I have a WCF service that in turn has a service reference to some other
SOAP endpoint. This endpoint has an identical copy at another address with
the same metadata but different data. When a request comes in to my
service, it specifies which of the two identical endpoints that I consume
it wants data from. So, I have something like this:
using (var client = new ServiceClient())
{
client.Endpoint.Address = new System.ServiceModel.EndpointAddress(url);
//do some work, pull some data, bake some muffins
}
This sometimes doesn't work when I have two requests coming in very close
together with different urls. The second request ends up going out to the
same endpoint as the first one. I understand that once the channel is open
I can't change the endpoint, but I thought the client would only be used
once and then disposed. Is there some optimization going on where the same
proxy is being re-used for multiple requests? What's a good approach to
problems like this?

rails 3 multiple language for any user

rails 3 multiple language for any user

I want my app has multiple languages. To do this, I read railscasts #138
But there, the writer put a language column to User model and thus users
can see pages only in their language as I understand right. But I want my
website can be seen in any language by any user just like usual.
How can this be done?

Python iterate over two nested 2D lists where list2 has list1's row numbers

Python iterate over two nested 2D lists where list2 has list1's row numbers

I'm new to Python. So I want to get this done with loops without using
some fancy stuff like generators. I have two 2D arrays, one interger array
and the other string array like this:
I) Integer 2D list:
Here, dataset2d[0][0] is number of rows in the table, dataset[0][1] is
number of columns. So the below 2D list has 6 rows and 4 columns
dataset2d[][]:
6 4
0 0 0 1
1 0 2 0
2 2 0 1
1 1 1 0
0 0 1 1
1 0 2 1
II) String 2D list:
partition2d[][]
A 1 2 4
B 3 5
C 6
partition[*][0] i.e first column is a label. For group A, 1,2 and 4 are
the row numbers that I need to pick up from dataset2d and apply a formula.
So it means I will read 1, go to row 1 in dataset2d and read the first
column value i.e dataset2d[1][0], then I will read 2 from partition2d, go
to row 2 of dataset 2d and read the first column i.e dataset2d[2][0].
Similarly next one I'll read dataset2d[4][0].
Then I will do some calculations, get a value and store it in a 2D list,
then go to the next column in dataset2d for those rows. So in this
example, next column values read would be dataset2d[1][1],
dataset2d[2][1], dataset2d[4][1]. And again do some calculation and get
one value for that column, store it. I'll do this until I reach the last
column of dataset2d.
The next row in partition2d is B, 3, 5. So I'll start with
dataset2d[3][0], dataset2d[5][0]. Get a value for that column be a
formula. Then real dataset2d [3][1], dataset2d[5][1] stc. until I reach
last column. I do this until all rows in partition2d are read.
What I tried:
for partitionRow in partition2d:
for partitionCol in partitionRow:
for colDataset in dataset2d:
print dataset2d[partitionCol][colDataset]
What problem I'm facing:
partition2d is a string array where I need to skip the first column which
has characters like A,B,C.
I want to iterate in dataset2d column wise only over the row numbers given
in partition2d. So the colDataset should increment only after I'm done
with that column.

Wednesday, 18 September 2013

css hover creating border but pushing content

css hover creating border but pushing content

Situation
I'm currently building a site and desire to have some elements create a
border/outline upon hovering the mouse over them. This is simple enough to
make work. For reference, please see the staging site at Stagin area link.
I'm using the grid part of the latest bootstrap and the box-sizing model.
Issue
I find that upon hovering, the content below that which is being hovered
gets "pushed" far down below the next element. Using the stagin area as
reference, I can change the behaviour through CSS to fix this on the left
hand side or the right hand side but, not both at the same time.
Code
Here is a snippet of the CSS I use to make the effect:
.hover-border:hover {
border: 3px solid #3A3A3A;
display: block;
}
Using this method, anything but the first element behaves as expected. If
I try this next snippet, the first element works but, then the others
break:
.hover-border:hover {
border: 3px solid #3A3A3A;
display: block;
margin-top: -6px;
}
For the sake of clarification with regard to properties inherited, I have
set the margin/padding on the elements in question to '0 !important' for
standard behaviour until hover
Problem
How can I stop the element below from being pushed?

Receiving Intent EXTRA_MESSAGE from Another Application

Receiving Intent EXTRA_MESSAGE from Another Application

In my Eclipse workspace I have my main application: A and I have another
fully functional application: B
I have configured appliction A to open up application B upon the click of
a button by using an Intent and it works.
Here is the issue:
In application B I need to receive the EXTRA_MESSAGE. However, I am unable
to access the info because application B does not recognize application A:
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE_DESC);
states that "MainActivity" cannot be resolved to a variable.
*addendum: I am working on the actual code of application B, as opening
the class reference in application A gives me a uneditable display.
It seems that I would need to alter the manifest of application B, and add
application A in the build path of B... this seems messy and not
reusablely friendly.
Thank you for any help

Can't get one click on the mouse using jquery?

Can't get one click on the mouse using jquery?

When I attempt to click on any one selection on of the buttons, sometimes
I get one click (as expected) and sometimes I get more than one click
fired (not what I want) using the code below given by someone on
Stackoverflow...
var $document = $(document);
var clickCount = 0;
var treeLogic = function (event) {
// unbind the element from the event handler
$document.off("click", "#file", treeLogic);
clickCount = clickCount + 1;
// for testing the number of clicks on each click of a button.
// sometimes it shows one click and sometimes it shows more than one
click
// (not what I want).
// bind the element back to the event handler
$document.on("click", "#file", treeLogic);
};
$document.on("click", "#file", treeLogic);
Could be my mouse is bad? Or the logic above is bad, and if so, can
someone show me how to fix it?