Monday, 30 September 2013

Not able to wget to ftp server

Not able to wget to ftp server

I am trying to wget a ftp server from a remote machine. The command is not
getting past 'Logging in as anonymous'. This is what i am getting.
wget ftp://hgdownload.cse.ucsc.edu/goldenPath/hg19/chromosomes/chr1.fa.gz
--2013-09-29
22:07:53--
ftp://hgdownload.cse.ucsc.edu/goldenPath/hg19/chromosomes/chr1.fa.gz
=> 'chr1.fa.gz'
Resolving proxy.x.y.z... *.*.*.*
Connecting to proxy.x.y.z|*.*.*.*|:3128... connected.
Logging in as anonymous ...
When i try accessing the site by firefox from the remote machine, it works
fine. I have set my ftp proxy like this
export ftp_proxy="ftp://a.user:password@proxy:3128
Can anyone help me fix this problem?
Thanks

CDF of Euclidean distance between two points.

CDF of Euclidean distance between two points.

2-D plane, a circle $\text{C}_0$ of radius $R$ centered at $A(0,0)$, $N$
random points $D_i(x_i,y_i),i=1\dots N$ are independently uniformly
distributed in $\text{C}_0$.
Choose the point $D_s$ from $D_i$ which has the smallest Euclidean
distance to point $A$, i.e., $$s = \mathop{\arg\min}_{i=1\dots
N}\sqrt{x_i^2+y_i^2},\\ d_s=\min_{i=1\dots N}\sqrt{x_i^2+y_i^2}. $$
I know that the CDF of $d_s$ is
$$F_{d_s}(r)=1-\left(1-\frac{r^2}{R^2}\right)^N,0\leq r\leq R.$$
If there is another point $P(a,0),a>R$, the Euclidean distance from $D_s$
to $P$ is $$d_{sp}=\sqrt{(x_s-a)^2+y_s^2}.$$
How can I find the CDF or PDF of $d_{sp}$ ?
Thanks a lot!

How to compress/decompress strings in a userscript?

How to compress/decompress strings in a userscript?

I've been trying to figure out why a userscript I'm working on is slow in
Firefox yet blazing in Chrome and Safari. One reason I've identified
(though maybe not the only reason) is that the large file size of the
userscript is having a big effect. The script has ten book length strings
in it, for a file size of 3.8 MB. If I remove the strings the script gets
fast again---basically everything in the browser grinds to a halt while
the file loads (right at the time for a typical user input interaction).
So I was thinking it might help to precompress the strings, then
uncompress as needed during the run. Anyone have a strategy for doing this
within a userscript?

MDX Get last non empty value for EACH month

MDX Get last non empty value for EACH month

I need to get the last non empty value of Total Cost for EACH month.
M,P,R are parcel types, B is also a parcel type which i don't want to see.
I tried all kinds of codes, here is what i have now:
SELECT { [Measures].[Total Cost Price] } ON COLUMNS,
NON EMPTY {TAIL(NonEmptyCrossJoin([TimeDim].[Date].AllMembers,1),1) *
[Parcel Type].[Parcel Type ID].[Parcel Type ID].ALLMEMBERS ) } ON ROWS
FROM ( SELECT (-{ [Parcel Type].[Parcel Type ID].&[B] } ) ON COLUMNS
FROM [SomeDB])
It gives the following result:

Which is exactly what i need for September, 22/9/2013 is the last date in
September which holds data and the value is correct. But i need this for
each month, August etc.
Can anyone please suggest a solution? I use sql 2008

Sunday, 29 September 2013

When to use mutable vs immutable classes in Scala

When to use mutable vs immutable classes in Scala

Much is written about the advantages of immutable state, but are there
common cases in Scala where it makes sense to prefer mutable classes?
(This is a Scala newbie question from someone with a background in
"classic" OOP design using mutable classes.)
For something trivial like a 3-dimensional Point class, I get the
advantages of immutability. But what about something like a Motor class,
which exposes a variety of control variables and/or sensor readings? Would
a seasoned Scala developer typically write such a class to be immutable?
In that case, would 'speed' be represented internally as a 'val' instead
of a 'var', and the 'setSpeed' method return a new instance of the class?
Similarly, would every new reading from a sensor describing the motor's
internal state cause a new instance of Motor to be instantiated?
The "old way" of doing OOP in Java or C# using classes to encapsulate
mutable state seems to fit the Motor example very well. So I'm curious to
know if once you gain experience using the immutable-state paradigm, you
would even design a class like Motor to be immutable.

sql order by hardcoded values

sql order by hardcoded values

I have the following query:
select 'junior' as type, value
from mytable
union
select 'intermediate' as type, value
from mytable
union
select 'senior' as type, value
from mytable
Which returns the following data:
type value
Intermediate 10
Junior 5
Senior 1
I just need to reorder it so it looks like this
Junior 5
Intermediate 10
Senior 1
I can't figure out which order by clause to use to achieve ordering by
custom specific values, how would I achieve this?

Find a file Age In php

Find a file Age In php

I need to find the age of a file using php
for eg : i have abc.txt. I need to find how many days old.
ans: abc.txt is 20 day's old...
i have tried below code but i need only day's output
function humanTiming ($time)
{
// to get the time since that moment
$time = time() - $time;
// time unit constants
$timeUnits = array (
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
// iterate over time contants to build a human
$humanTiming;
foreach ($timeUnits as $unit => $text)
{
if ($time < $unit)
continue;
$numberOfUnits = floor($time / $unit);
var_dump($humanTiming);
// human readable token for current time unit
$humanTiming = $humanTiming.' '.$numberOfUnits.'
'.$text.(($numberOfUnits>1)?'s':'');
// compute remaining time for next loop iteration
$time -= $unit*$numberOfUnits;
}
return $humanTiming;
}
$filename = 'H:\xampp\htdocs\doc\index.php';
if (file_exists($filename))
{
$time = strtotime('2010-04-28 17:25:43');
$time = filemtime($filename);
echo '<br/>File age is '.humanTiming($time).'.';
$elapsedTime = time()-filemtime($filename);
}