
collection.forEach(System.out::println);is of course very cute to use, and is (wow) 10 characters shorter than:
for (Object o : collection) System.out.println(o);but this is not functional programming because it has side effects.
Stream<Pair> allFactorials = Stream.iterate(
new Pair(BigInteger.ONE, BigInteger.ONE),
x -> new Pair(
x.num.add(BigInteger.ONE),
x.value.multiply(x.num.add(BigInteger.ONE))));
return allFactorials.filter(
(x) -> x.num.equals(num)).findAny().get().value;
When you are fresh out of the functional programming class, this may seem
like a good idea to you... (and in contrast to the examples mentioned above,
this is really a functional program).
BigInteger cur = BigInteger.ONE, acc = BigInteger.ONE;
while(cur.compareTo(num) <= 0) {
cur = cur.add(BigInteger.ONE); // Unfortunately, BigInteger is immutable!
acc = acc.multiply(cur);
}
return acc;
BigInteger acc = BigInteger.ONE;
for(long i = 2; i <=x; i++) {
acc = acc.multiply(BigInteger.valueOf(i));
}
return acc;
functional 1000 100 avgt 20 9748276,035 ± 222981,283 ns/op biginteger 1000 100 avgt 20 7920254,491 ± 247454,534 ns/op traditional 1000 100 avgt 20 6360620,309 ± 135236,735 ns/opAs you can see, this "functional" approach above is about 50% slower than the classic for-loop. This will be mostly due to the Pair and additional BigInteger objects created and garbage collected.
for(Iterator<Something>> it = collection.iterator(); it.hasNext(); ) {
Something s = it.next();
if (someTest(s)) continue; // Skip
if (otherTest(s)) it.remove(); // Remove
if (thirdTest(s)) process(s); // Call-out to a complex function
if (fourthTest(s)) break; // Stop early
}
In many cases, this code is preferrable to the lambda hacks we see pop up
everywhere these days. Above code is efficient, and readable.Unity, that is the Ubuntu user interface, that nobody else uses.
Since it is a Ubuntu-only thing, few applications have native support for its OSX-style hipster "global" menus.
For Java, someone once wrote a hack called java-swing-ayatana, or "jayatana", that is preloaded into the JVM via the environment variable JAVA_TOOL_OPTIONS. The hacks seems to be unmaintained now.
Unfortunately, this hack seems to be broken now (Google has thousands of problem reports), and causes a NullPointerException or similar crashes in many applications; likely due to a change in OpenJDK 8.
Now all Java Swing applications appear to be broken for Ubuntu users, if they have the jayatana package installed. Congratulations!
And of couse, you see bug reports everywhere. Matlab seems to no longer work for some, NetBeans appears to have issues, and I got a number of bug reports on ELKI because of Ubuntu. Thank you, not.
[INFO] +- org.apache.hadoop:hadoop-hdfs:jar:2.6.0:compile [INFO] | +- com.google.guava:guava:jar:11.0.2:compile [INFO] | +- org.mortbay.jetty:jetty:jar:6.1.26:compile [INFO] | +- org.mortbay.jetty:jetty-util:jar:6.1.26:compile [INFO] | +- com.sun.jersey:jersey-core:jar:1.9:compile [INFO] | +- com.sun.jersey:jersey-server:jar:1.9:compile [INFO] | | \- asm:asm:jar:3.1:compile [INFO] | +- commons-cli:commons-cli:jar:1.2:compile [INFO] | +- commons-codec:commons-codec:jar:1.4:compile [INFO] | +- commons-io:commons-io:jar:2.4:compile [INFO] | +- commons-lang:commons-lang:jar:2.6:compile [INFO] | +- commons-logging:commons-logging:jar:1.1.3:compile [INFO] | +- commons-daemon:commons-daemon:jar:1.0.13:compile [INFO] | +- javax.servlet.jsp:jsp-api:jar:2.1:compile [INFO] | +- log4j:log4j:jar:1.2.17:compile [INFO] | +- com.google.protobuf:protobuf-java:jar:2.5.0:compile [INFO] | +- javax.servlet:servlet-api:jar:2.5:compile [INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile [INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile [INFO] | +- tomcat:jasper-runtime:jar:5.5.23:compile [INFO] | +- xmlenc:xmlenc:jar:0.52:compile [INFO] | +- io.netty:netty:jar:3.6.2.Final:compile [INFO] | +- xerces:xercesImpl:jar:2.9.1:compile [INFO] | | \- xml-apis:xml-apis:jar:1.3.04:compile [INFO] | \- org.htrace:htrace-core:jar:3.0.4:compile [INFO] +- org.apache.hadoop:hadoop-auth:jar:2.6.0:compile [INFO] | +- org.slf4j:slf4j-api:jar:1.7.5:compile [INFO] | +- org.apache.httpcomponents:httpclient:jar:4.2.5:compile [INFO] | | \- org.apache.httpcomponents:httpcore:jar:4.2.4:compile [INFO] | +- org.apache.directory.server:apacheds-kerberos-codec:jar:2.0.0-M15:compile [INFO] | | +- org.apache.directory.server:apacheds-i18n:jar:2.0.0-M15:compile [INFO] | | +- org.apache.directory.api:api-asn1-api:jar:1.0.0-M20:compile [INFO] | | \- org.apache.directory.api:api-util:jar:1.0.0-M20:compile [INFO] | +- org.apache.zookeeper:zookeeper:jar:3.4.6:compile [INFO] | | +- org.slf4j:slf4j-log4j12:jar:1.7.5:compile [INFO] | | \- jline:jline:jar:0.9.94:compile [INFO] | \- org.apache.curator:curator-framework:jar:2.6.0:compile [INFO] +- org.apache.hadoop:hadoop-common:jar:2.6.0:compile [INFO] | +- org.apache.hadoop:hadoop-annotations:jar:2.6.0:compile [INFO] | | \- jdk.tools:jdk.tools:jar:1.6:system [INFO] | +- org.apache.commons:commons-math3:jar:3.1.1:compile [INFO] | +- commons-httpclient:commons-httpclient:jar:3.1:compile [INFO] | +- commons-net:commons-net:jar:3.1:compile [INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile [INFO] | +- com.sun.jersey:jersey-json:jar:1.9:compile [INFO] | | +- org.codehaus.jettison:jettison:jar:1.1:compile [INFO] | | +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile [INFO] | | | \- javax.xml.bind:jaxb-api:jar:2.2.2:compile [INFO] | | | +- javax.xml.stream:stax-api:jar:1.0-2:compile [INFO] | | | \- javax.activation:activation:jar:1.1:compile [INFO] | | +- org.codehaus.jackson:jackson-jaxrs:jar:1.8.3:compile [INFO] | | \- org.codehaus.jackson:jackson-xc:jar:1.8.3:compile [INFO] | +- net.java.dev.jets3t:jets3t:jar:0.9.0:compile [INFO] | | \- com.jamesmurty.utils:java-xmlbuilder:jar:0.4:compile [INFO] | +- commons-configuration:commons-configuration:jar:1.6:compile [INFO] | | +- commons-digester:commons-digester:jar:1.8:compile [INFO] | | | \- commons-beanutils:commons-beanutils:jar:1.7.0:compile [INFO] | | \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile [INFO] | +- org.apache.avro:avro:jar:1.7.4:compile [INFO] | | +- com.thoughtworks.paranamer:paranamer:jar:2.3:compile [INFO] | | \- org.xerial.snappy:snappy-java:jar:1.0.4.1:compile [INFO] | +- com.google.code.gson:gson:jar:2.2.4:compile [INFO] | +- com.jcraft:jsch:jar:0.1.42:compile [INFO] | +- org.apache.curator:curator-client:jar:2.6.0:compile [INFO] | +- org.apache.curator:curator-recipes:jar:2.6.0:compile [INFO] | +- com.google.code.findbugs:jsr305:jar:1.3.9:compile [INFO] | \- org.apache.commons:commons-compress:jar:1.4.1:compile [INFO] | \- org.tukaani:xz:jar:1.0:compile [INFO] +- org.apache.hadoop:hadoop-core:jar:1.2.1:compile [INFO] | +- org.apache.commons:commons-math:jar:2.1:compile [INFO] | +- tomcat:jasper-compiler:jar:5.5.23:compile [INFO] | +- org.mortbay.jetty:jsp-api-2.1:jar:6.1.14:compile [INFO] | | \- org.mortbay.jetty:servlet-api-2.5:jar:6.1.14:compile [INFO] | +- org.mortbay.jetty:jsp-2.1:jar:6.1.14:compile [INFO] | | \- ant:ant:jar:1.6.5:compile [INFO] | +- commons-el:commons-el:jar:1.0:compile [INFO] | +- hsqldb:hsqldb:jar:1.8.0.10:compile [INFO] | +- oro:oro:jar:2.0.8:compile [INFO] | \- org.eclipse.jdt:core:jar:3.1.1:compile
Example: command1 = as_sudo(["cat,"/etc/passwd"]) + " | grep user"(from the Ambari python documentation)
/bin/bash -c "wget http://www.scala-lang.org/files/archive/scala-2.10.3.deb ; dpkg -x ./scala-2.10.3.deb /"Note that it doesn't even install the package properly, but extracts it to your root directory. The download does not check any signature, not even SSL certificates. (Source: Bigtop puppet manifests)
double[].adapterFor 1000000 thrpt 50 836,898 ± 13,223 ops/s adapterForL 1000000 thrpt 50 842,464 ± 11,008 ops/s adapterForR 1000000 thrpt 50 810,343 ± 9,961 ops/s adapterWhile 1000000 thrpt 50 839,369 ± 11,705 ops/s adapterWhileL 1000000 thrpt 50 842,531 ± 9,276 ops/s boxedFor 1000000 thrpt 50 848,081 ± 7,562 ops/s boxedForL 1000000 thrpt 50 840,156 ± 12,985 ops/s boxedForR 1000000 thrpt 50 817,666 ± 9,706 ops/s boxedWhile 1000000 thrpt 50 845,379 ± 12,761 ops/s boxedWhileL 1000000 thrpt 50 851,212 ± 7,645 ops/s forSum 1000000 thrpt 50 845,140 ± 12,500 ops/s forSumL 1000000 thrpt 50 847,134 ± 9,479 ops/s forSumL2 1000000 thrpt 50 846,306 ± 13,654 ops/s forSumR 1000000 thrpt 50 831,139 ± 13,519 ops/s foreachSum 1000000 thrpt 50 843,023 ± 13,397 ops/s whileSum 1000000 thrpt 50 848,666 ± 10,723 ops/s whileSumL 1000000 thrpt 50 847,756 ± 11,191 ops/sThe postfix is the iteration type: sum using for loops, with local variable for the length (L), or in reverse order (R); while loops (again with local variable for the length). The prefix is the data layout: the primitive array, the array using a static adapter (which is the approach I have been using in many implementations in cervidae) and using a "boxed" wrapper class around the array (roughly the approach that Daniel Lemire has been investigating. On the primitive array, I also included the foreach loop approach (for(double v:array){).

preseed/late_command="in-target apt-get install -y sysvinit-core"or by using a preseeding file (which is a really nice feature I used for installing my Hadoop nodes) to do the same:
d-i preseed/late_command string in-target apt-get install -y sysvinit-coreIf you are a sysadmin, using preseeding can save you a lot of typing. Put all your desired configuration into preseeding files, put them on a webserver (best with a short name resolvable by local DNS). Let's assume you have set up the DNS name d-i.example.com, and your DHCP is configured such that example.com is on the DNS search list. You can also add a vendor extension to DHCP to serve a full URL. Manually enabling preseeding then means adding
auto url=d-ito the installer boot command line (d-i is the hostname I suggested to set up in your DNS before, and the full URL would then be http://d-i.example.com/d-i/jessie/./preseed.cfg. Preseeding is well documented in Appendix B of the installer manual, but nevertheless will require a number of iterations to get everything work as desired for a fully automatic install like I used for my Hadoop nodes.
# /etc/pyroman/02_icmpv6.py:82 -A rfc4890f -p icmpv6 --icmpv6-type 255 -j DROPindicates that this particular line was produced due to line 82 in file /etc/pyroman/02_icmpv6.py. This makes debugging easier. In particular it allows pyroman to produce a meaningful error message if the rules are rejected by the kernel: it will tell you which line caused the rule that was rejected.

-dbc.in coords.tsv.gz -db.index tree.spatial.rstarvariants.rstar.RStarTreeFactory -pagefile.pagesize 500 -spatial.bulkstrategy SortTileRecursiveBulkSplit -time -algorithm clustering.optics.OPTICSXi -opticsxi.xi 0.01 -algorithm.distancefunction geo.LngLatDistanceFunction -optics.epsilon 5000.0 -optics.minpts 1000 -resulthandler KMLOutputHandler -out /tmp/out.kmzand the total runtime for 23 million points on a single core was about 29 hours. The indexes helped a lot: less than 10000 distances were computed per point, instead of 23 million - the expected speedup over a non-indexed approach is 2400.
sudo dpkg --force-depends -i google-earth-stable_current_i386.deb
SigniTrend: Scalable Detection of Emerging Topics in Textual Streams by Hashed Significance Thresholds
Erich Schubert, Michael Weiler, Hans-Peter Kriegel
20th ACM SIGKDD Conference on Knowledge Discovery and Data Mining
@5SOS @Luke5SOS @Ashton5SOS @Michael5SOS @Calum5SOS
♥
CAN YOU FOLLOW MЕ?
♥
It would mean the world to me!
♥
Make my dream come true!🙏
x804
— ♕ Chantal ♕ (@Chantal_San22) 25. August 2014
Now if you look at this tweet, there is this odd "x804" at the end. This is
to defeat a simple spam filter by Twitter. Because this user did not tweet this
just once: instead it is common amongst teenie to spam their idols with
follow requests by the dozen. Probably using some JavaScript hack, or third
party Twitter client. Occassionally, you see hundreds of such tweets, each sent
within a few seconds of the previous one. If you get a 1% sample of these, you
still get a few then...
Google Summer of Code 2014 is currently open for mentoring organizations to register.
I've decided to not apply for GSoC with my data mining open source project ELKI anymore.
It has been all over the place. The Debian CTTE has chosen systemd over upstart as default init system by chairman call. This decision was overdue, as it was pretty clear that the tie will not change, and thus it will be up to chairman. There were no new positions presented, and nobody was being convinced of a different preference. The whole discussion had been escalating, and had started to harm Debian.
Some people may not want to hear this, but another 10 ballots and options would not have changed this outcome. Repating essentially the same decision (systemd, upstart, or "other things nobody prefers") will do no good, but turn out the same result, a tie. Every vote counting I saw happen would turn out this tie. Half of the CTTE members prefer systemd, the other half upstart.
The main problems, however, are these:
So please, everybody get back to work now. If there ever is enough reason to overturn this decision, there are formal ways to do this, and there are people in the CTTE (half of the CTTE, actually) that will take care of this.
Until then, live with the result of a 0.1 votes lead for systemd. Instead of pursuing a destructive hate campaign, why not improve your favorite init system instead.
Oh, and don't forget about the need to spell out a policy for init system support requirements of packages.
How to reduce your usage of debian-multimedia packages:
As you might be aware, the "deb-multimedia" packages have seen their share of chaos.
Originally, they were named "debian-multimedia", but it was then decided that they should better be called "deb-multimedia" as they are not an official part of Debian. The old domain was then grabbed by cybersquatters when it expired.
While a number of packages remain indistributable for Debian due to legal issues - such as decrypting DVDs - and thus "DMO" remains useful to many desktop users, please note that for many of the packages, a reasonable version exists within Debian "main".
So here is a way to prevent automatically upgrading to DMO versions of packages that also exist in Debian main:
We will use a configuration option known as apt pinning. We will modify the priority of DMO package to below 100, which means they will not be automatically upgraded to; but they can be installed when e.g. no version of this package exists within Debian main. I.e. the packages can be easily installed, but it will prefer using the official versions.
For this we need to create a file I named /etc/apt/preferences.d/unprefer-dmo with the contents:
Package: * Pin: release o=Unofficial Multimedia Packages Pin-Priority: 123
As long as the DMO archive doesn't rename itself, this pin will work; it will continue to work if you use a mirror of the archive, as it is not tied to the URL.
It will not downgrade packages for you. If you want to downgrade, this will be a trickier process. You can use aptitude for this, and start with a filter (l key, as in "limit") of ?narrow(~i,~Vdmo). This will only show packages installed where the version number contains dmo. You can now patrol this list, enter the detail view of each package, and check the version list at the end for a non-dmo version.
I cannot claim this will be an easy process. You'll probably have a lot of conflicts to clear up, due to different libavcodec* API versions. If I recall correctly, I opted to uninstall some dmo packages such as ffmpeg that I do not really need. In other cases, the naming is slightly different: Debian main has handbrake, while dmo has handbrake-gtk.
A simple approach is to consider uninstalling all of these packages. Then reinstall as needed; since installing Debian packages is trivial, it does not hurt to deinstall something, does it? When reinstalling, Debian packages will be preferred over DMO packages.
I prefer to use DFSG-free software wherever possible. And as long as I can watch my favorite series (Tatort, started in 1970 and airing episode 900 this month) and the occasional DVD movie, I have all I need.
An even more powerful aptitude filter to review installed non-Debian software is ?narrow(~i,!~ODebian), or equivalently ?narrow(?installed,?not(?origin(Debian))). This will list all package versions, which cannot be installed from Debian sources. In particular, this includes versions that are no longer available (they may have been removed because of security issues!), software that has been installed manually from .deb files, or any other non-Debian source such as Google or DMO. (You should check the output of aptitude policy that no source claims to be o=Debian that isn't Debian though).
This filter is a good health check for your system. Debian packages receive a good amount of attention with respect to packaging quality, maintainability, security and all of these aspects. Third party packages usually failed the Debian quality check in at least one respect. For example, Sage isn't in Debian yet; mostly because it has so many dependencies, that making a reliable and upgradeable installation is a pain. Similarly, there is no Hadoop in Debian yet. If you look at Hadoop packaging efforts such as Apache Bigtop, they do not live up to Debian quality yet. In particular, the packages have high redundancy, and re-include various .jar copies instead of sharing access to an independently packaged dependency. If a security issue arises with any of these jars, all the Hadoop packages will need to be rebuilt.
As you can see, it is usually not because of Debian being too strict or too conservative about free software when software is not packaged. More often than not, it's because the software in question itself currently does not live up to Debian packaging quality requirements. And of course sometimes because there is too little community backing the software in question, that would improve the packaging. If you want your software to be included in Debian, try to make it packaging friendly. Don't force-include copies of other software, for example. Allow the use of system-installed libraries where possible, and provide upgrade paths and backwards compatibility. Make dependencies optional, so that your software can be pacakged even if a dependency is not yet available - and does not have to be removed if the dependency becomes a security risk. Maybe learn how to package yourself, too. This will make it easier for you to push new features and bug fixes to your userbase: instead of requiring your users to manually upgrade, make your software packaging friendly. Then your users will be auto-upgraded by their operating system to the latest version.
Update: If you are using APT::Default-Release or other pins, these may override above pin. You may need to use apt-cache policy to find out if the pins are in effect, and rewrite your default-release pin into e.g.
Package: * Pin: release a=testing,o=Debian Pin-Priority: 912for debugging, use a different priority for each pin, so you can see which one is in effect. Notice the o=Debian in this pin, which makes it apply only to Debian repositories.
Data science has been called "the sexiest job" so often, this has recently led to an integer overflow.
for (int i = 0; i < size; i++) {
for (int j = i + 1; j < size; j++) {
matrix[i][j] = computeDistance(data[i], data[j]);
}
}
In C, if you want to be able to choose computeDistance at
runtime, you would likely make it a function pointer, or in C++ use
e.g. boost::function or a virtual method.
In Java, you would use an interface method instead, i.e. distanceFunction.distance().> a = array(range(-1000000,1000001)) * 0.000001 > min(a), max(a), numpy.sum(a), math.fsum(a) (-1.0, 1.0, -2.3807511517759394e-11, 0.0)
> b = a + 1e15 > numpy.var(a), numpy.var(b) (0.33333366666666647, 0.33594164452917774) > mean(a**2)-mean(a)**2, mean(b**2)-mean(b)**2 (0.33333366666666647, -21532835718365184.0)(as you can see, numpy.var does not use the naive single-pass formula; probably they use the classic straight forward two-pass approach)
> import timeit > for f in ["sum(a)", "math.fsum(a)"]: > print timeit.timeit(f, setup="import math; a=range(0,1000)") 30.6121790409 202.994441986So unless we need that extra precision (e.g. because we have messy data with outliers of large magnitude) we might prefer the simpler approach which is roughly 3-6x faster (at least as long as pure CPU performance is concerned. Once I/O gets into play, the difference might just disappear altogether). Which is probably why all but the fsum function show the same inaccuracy: performance. In particular, as in 99% of situations the problems won't arise.