Tuesday, 10 September 2013

How do I list the files having particular strings from group of directories in bash?

How do I list the files having particular strings from group of
directories in bash?

I want to list files having strings like "hello", "how" and "todo" from a
directory (which is having multiple directories). Also I want to list only
c(.c) and cpp (.cpp) files only. I have tried with grep -R but not
satisfied. Please suggest me an alternate way. Thanks in advance.

Monday, 9 September 2013

Div appear on mouse coordinates

Div appear on mouse coordinates

I've created a simple list. I'd like to make the div img appear when one
of the li is hovered. I would like to make that img div appear at the
current mouse coordinates.
I can make it all work, but not at the coordinates:
http://jsfiddle.net/tmyie/fwgRE/2/

MySQL query based on time range, group users, and sum values over a sliding window

MySQL query based on time range, group users, and sum values over a
sliding window

I want to create a new Table B based on the information from another
existing Table A. I'm wondering if MySQL has the functionality to take
into account a range of time and group column A values then only sum up
the values in a column B based on those groups in column A.
Table A stores logs of events like a journal for users. There can be
multiple events from a single user in a single day. Say hypothetically I'm
keeping track of when my users eat fruit and I want to know how many fruit
they eat in a week (7days) and also how many apples they eat.
So in Table B I want to count for each entry in Table A, the previous 7
day total # of fruit and apples.
EDIT:
I'm sorry I over simplified my given information and didn't thoroughly
think my example.
I'm initially have only Table A. I'm trying to create Table B from a query.
Assume:
User/id can log an entry multiple times in a day.
sum counts should be for id between date and date - 7 days
fruit column stands for the total # of fruit during the 7 day interval (
apples and bananas are both fruit)
The data doesn't only start at 2013-9-5. It can date back 2000 and I want
to use the 7 day sliding window over all the dates between 2000 to 2013.
The sum count is over a sliding window of 7 days
Here's an example:
Table A:
| id | date-time | apples | banana |
---------------------------------------------
| 1 | 2013-9-5 08:00:00 | 1 | 1 |
| 2 | 2013-9-5 09:00:00 | 1 | 0 |
| 1 | 2013-9-5 16:00:00 | 1 | 0 |
| 1 | 2013-9-6 08:00:00 | 0 | 1 |
| 2 | 2013-9-9 08:00:00 | 1 | 1 |
| 1 | 2013-9-11 08:00:00 | 0 | 1 |
| 1 | 2013-9-12 08:00:00 | 0 | 1 |
| 2 | 2013-9-13 08:00:00 | 1 | 1 |
note: user 1 logged 2 entries on 2013-9-5
The result after the query should be Table B.
Table B
| id | date-time | apples | fruit |
--------------------------------------------
| 1 | 2013-9-5 08:00:00 | 1 | 2 |
| 2 | 2013-9-5 09:00:00 | 1 | 1 |
| 1 | 2013-9-5 16:00:00 | 2 | 3 |
| 1 | 2013-9-6 08:00:00 | 2 | 4 |
| 2 | 2013-9-9 08:00:00 | 2 | 3 |
| 1 | 2013-9-11 08:00:00 | 2 | 5 |
| 1 | 2013-9-12 08:00:00 | 0 | 3 |
| 2 | 2013-9-13 08:00:00 | 2 | 4 |
At 2013-9-12 the sliding window moves and only includes 9-6 to 9-12.
That's why id 1 goes from a sum of 2 apples to 0 apples.

Javascript Split String at First Numeric

Javascript Split String at First Numeric

I am trying to split a UK postcode string to only include the initial
letters. For example, 'AA1 2BB' would become 'AA.'
I was thinking something like the below.
var postcode = 'AA1 2BB';
var postcodePrefix = postcode.split([0-9])[0];
This does not actually work, but can someone help me out with the syntax?
Thanks for any help.

String.format not completely working?

String.format not completely working?

TMP = String.format("%-25s %25s", STRING1, STRING2);
Whenever I print TMP, it doesn't seem to properly print the table the way
I'm looking for
For example:
STRING1 = Test1 & Test12 STRING2 = Hello
Print:
Test1 Hello
Test12 Hello
Why is that happening?

Unexpected behavior when extracting minima using turnpoints (Pastecs package in R)

Unexpected behavior when extracting minima using turnpoints (Pastecs
package in R)

So I have some data, height.
> print(height)
V3 V4 V5 V6 V7
V8 V9 V10 V11 V12
V13 V14 V15
0.0000000 -3.1486232 39.1502937 -2.8437808 -24.7633269
-35.4022061 -36.2401943 46.4133021 -19.1868097 0.4067331
22.6768200 -38.8550971 -41.3161054
V16 V17 V18 V19 V20
33.0446273 41.4934899 19.9558741 3.3477473 0.3611974
I then apply turnpoints(), and use extract() to get what looks like a
logical vector indicating the positions of the minima.
tp = turnpoints(height)
pitpositions = extract(tp, peak = FALSE, pit = TRUE)
print(pitpositions) # [1] 0 1 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0
I would expect that height[pitpositions] would give the values of the
minima, and that height[!pitpositions] would give the values of the
non-minima.
The latter works as expected:
> height[!pitpositions]
V3 V5 V6 V7 V8
V10 V12 V13 V14 V16
V17 V18 V19
0.0000000 39.1502937 -2.8437808 -24.7633269 -35.4022061
46.4133021 0.4067331 22.6768200 -38.8550971 33.0446273
41.4934899 19.9558741 3.3477473
V20
0.3611974
But the former doesn't, and I don't know how to interpret the results:
> height[pitpositions]
V3 V3 V3 V3
0 0 0 0
So my questions are:
Why is this happening?
How can I get the result that I'm looking for (basically the opposite of
height[!pitpositions]?
Thanks!
--Davis
Edit:
To answer question number 2, I can get what I'm looking for using
height[tp$pits]. tp$pits seems to have the same information as
pitpositions, but when I print out pitpositoins I get a series of TRUE
FALSE, whereas when I print out tp$pits I get a series of 0 1. I would
have thought these were equivalent, as 0 == FALSE and 1 == TRUE.

Rendering Problems - Can't manage certificates/identifiers in apple developer center

Rendering Problems - Can't manage certificates/identifiers in apple
developer center

since a couple of days I can't manage my certificates/identifiers/.. in
the developer center. Steps to reproduce: 1. Log on to developer.apple.com
2. navigate to "Member Center" 3. click on "Manage your certificates, App
IDs, devices, and provisioning profiles"
screenshot of my browser showing "manage your certificates.."
https://discussions.apple.com/servlet/JiveServlet/showImage/2-22930732-294327/appleDevCenterIdentifiersRenderingError.jpg
This appreas in different browsers: Latest Safari, Chrome, Firefox.
I am not behind an proxy server which might block some content. Any idea
what I can do?
Thanks