com.google.inject.internal.Sets
instead of com.google.common.collect.Sets
. Is it too much to ask for people to at least look at the code that is getting generated?
com.google.inject.internal.Sets
instead of com.google.common.collect.Sets
. Is it too much to ask for people to at least look at the code that is getting generated?
K=10 | K=50 | K=100 | |
---|---|---|---|
sort | 0.468977 | 0.466918 | 0.467177 |
fullheap | 0.099325 | 0.102839 | 0.106735 |
smallheap | 0.018063 | 0.028948 | 0.040435 |
#include <algorithm> #include <cstdlib> #include <ctime> #include <iostream> #include <numeric> #include <vector> using namespace std; typedef void (*topk_func)(vector<int> &, vector<int> &, int); bool greater_than(const int &v1, const int &v2) { return v1 > v2; } void topk_sort(vector<int> &data, vector<int> &top, int k) { sort(data.begin(), data.end()); vector<int>::iterator i = data.begin(); int j = 0; for (; j < k; ++i, ++j) { top.push_back(*i); } } void topk_fullheap(vector<int> &data, vector<int> &top, int k) { make_heap(data.begin(), data.end(), greater_than); for (int j = 0; j < k; ++j) { top.push_back(*data.begin()); pop_heap(data.begin(), data.end(), greater_than); data.pop_back(); } } void topk_smallheap(vector<int> &data, vector<int> &top, int k) { for (vector<int>::iterator i = data.begin(); i != data.end(); ++i) { if (top.size() < k) { top.push_back(*i); push_heap(top.begin(), top.end()); } else if (*i < *top.begin()) { pop_heap(top.begin(), top.end()); top.pop_back(); top.push_back(*i); push_heap(top.begin(), top.end()); } } sort_heap(top.begin(), top.end()); } void run_test(const string &name, topk_func f, int trials, int n, int k) { vector<double> times; for (int t = 0; t < trials; ++t) { vector<int> data; for (int i = 0; i < n; ++i) { data.push_back(rand()); } clock_t start = clock(); vector<int> top; f(data, top, k); clock_t end = clock(); times.push_back(1000.0 * (end - start) / CLOCKS_PER_SEC); } sort(times.begin(), times.end()); double sum = accumulate(times.begin(), times.end(), 0.0); double avg = sum / times.size(); double pct90 = times[static_cast<int>(trials * 0.90)]; double pct99 = times[static_cast<int>(trials * 0.99)]; cout << name << " " << k << " " << avg << " " << pct90 << " " << pct99 << endl; } int main(int argc, char **argv) { cout << "method k avg 90-%tile 99-%tile" << endl; int trials = 1000; int n = 10000; for (int k = 1; k <= 100; ++k) { run_test("sort", topk_sort, trials, n, k); run_test("fullheap", topk_fullheap, trials, n, k); run_test("smallheap", topk_smallheap, trials, n, k); } return 0; }
#!/usr/bin/env python import sys buffer = "" for i in range(100000): buffer += "%d\n" % i sys.stdout.write(buffer)
$ ./test.py | head -n1 0 ERROR:root:damn Traceback (most recent call last): File "./test.py", line 6, in <module> sys.stdout.write(buffer) IOError: [Errno 32] Broken pipe
#!/usr/bin/env python import errno import sys try: buffer = "" for i in range(100000): buffer += "%d\n" % i sys.stdout.write(buffer) except IOError, e: if e.errno != errno.EPIPE: raise e
null
. However, while using a regex with pattern matching I was surprised by a NullPointerException when trying to look at the result of an optional capture group. Consider the following example:scala> val Pattern = "(a)(b)?".r Pattern: scala.util.matching.Regex = (a)(b)? scala> "a" match { case Pattern(a, b) => printf("[%s][%s]%n", a, b) } [a][null] scala> "ab" match { case Pattern(a, b) => printf("[%s][%s]%n", a, b) } [a][b]
b
would be of type Option[String]
. There is probably a good reason for this travesty, my guess would be something about making it work with the type system, but after using scala for a while it just seems wrong to be getting a null
value.
#!/bin/bash function logFile { echo "$(date +%Y-%m-%d-%H-%M-%S).${1}.log" } function serveRequests { port=$1 remoteHost=$2 remotePort=$3 while true; do rm -f backpipe mkfifo backpipe cat backpipe | nc -l $port | tee -a $(logFile request) | nc $remoteHost $remotePort | tee -a $(logFile response) >backpipe done } port=${1:-12345} remoteHost=${2:-localhost} remotePort=${3:-80} serveRequests $port $remoteHost $remotePort
Subject: IMPORTANT: security violations found for cluster Security violations found for instances of cluster: foobar To see the full report go to: http://ids.mycompany.com/reports/cluster/<clustername>There are many things I think could be improved with this email, but the primary thing that annoyed me was the link to the full report. Why not insert the actual cluster name so I can just click on the link? The way it is I have to copy the prefix of the url and then type or copy in the cluster it is complaining about. Are functional links too much to ask for?
Global average sea level rose at an average rate of around 1.8 mm per year over 1961 to 2003 and at an average rate of about 3.1 mm per year from 1993 to 2003.That is a pretty accurate measurement. Go to the ocean and look at the waves and tides. How would you accurately measure the average sea level? Now consider less obvious sources of problems such as evaporation and how much water gets stuck on land vs returned to the oceans from year to year. These days we use measurements from satellites to help improve the accuracy, but what is the tried and true technique for measuring the sea level?
Money bagsOkay, so we are now well into August so why am I getting this crap touting how special July was? Well I have given up trying to explain to certain relatives that any mail with the phrase "send to everyone you know" is worthless garbage, but then again I'm enough of a loser to actually read through some of this tripe so I guess I can't complain too much. The first claim is about how special the so called "Money Bags" month is and that it only occurs every 823 years. This immediately strikes me as being wrong. A year is usually 365 days and 365 mod 7 is 1. So if we ignored leap years, then the first of July would return to the same day of week every 7 years. I was too lazy to do the math to see when this would occur and factor in the leap years, that is what computers are good for:
This year, July has 5 Fridays, 5 Saturdays and 5 Sundays. This happens once every 823 years. This is called money bags. So, forward this to your friends and money will arrive within 4 days. Based on Chinese Feng Shui. The one who does not forward.....will be without money.
Kind of interesting - read on!!!
This year we're going to experience four unusual dates.
1/1/11, 1/11/11, 11/1/11, 11/11/11 and that's not all...
Take the last two digits of the year in which you were born - now add the age you will be this year,
The results will be 111 for everyone in whole world. This is the year of the Money!!!
The proverb goes that if you send this to eight good friends, money will appear in next four days as it is explained in Chinese Feng Shui.
Those who don't continue the chain won't receive.
Its a mystery, but it’s worth a try. Good luck
$ gseq 2011 2025 | xargs -I'{}' cal 7 '{}' | grep -B2 -A5 '1 2$' July 2011 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 -- July 2016 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 -- July 2022 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
An untold number of people have tried to predict the Lord's return by using elaborate time tables. Most date setters do not realize mankind has not kept an unwavering record of time. Anyone wanting to chart for example 100 BC to 2000 AD would have contend with the fact 46 BC was 445 days long, there was no year 0 BC, and in 1582 we switched from Julian Years (360 days) to Gregorian (365 days). Because most prognosticators are not aware of all these errors, from the get go their math is already off by several years.The basic idea is correct, that is there have been many calendars over time and the nuances of those calendars makes it very difficult if not impossible to determine exactly when recorded events happened. So it is true that 46 BC was 445 days long because of accumulated errors in the Roman calendar. However, it fails to mention that 45 BC was the first year that the Julian calendar started getting used. It is also true that there is no 0 year in either the Julian or Gregorian calendars and that some Catholic countries adopted the Gregorian calendar in 1582, but adoption was a long process that took hundreds of years. For example, Greece did not adopt the Gregorian calendar until 1923.
/** * Example of using scaladoc wiki syntax. I use this example to make sure * [[https://wiki.scala-lang.org/display/SW/Syntax scaladoc syntax page]] * examples actually work. In particular, I could not get the wiki syntax lists * to work based on the documentation. * * This is another paragraph (note the empty line above) containing '''bold''', * ''italic'', `monospace`, __underline__, ^superscript^, and ,,subscript,, * words. This sentence uses the inline elements specified in the section * "Inline elements" on the syntax page that are sometimes different from the * example for _italic_, *bold*, +underline+, {{monspace}}, ^superscript^, and * ~subscript~. Why are there multiple ways of specifying the same format? * Apparently there aren't, the ones from the inline elements section do not * work. * * == Inline elements == * This section contains a correct listing of inline elements. It is also a * handy example of an unordered list as well as escaping. * * - '''Italic''': `''text''` becomes ''text''. * - '''Bold''': `'''text'''` becomes '''text'''. * - '''Underline''': `__text__` becomes __text__. * - '''Monospace''': use backticks, I couldn't figure out how to escape * other than sticking something in an inline monospace section, `text`. * - '''Superscript''': `^text^` becomes ^text^. * - '''Subscript''': `,,text,,` becomes ,,text,,. * - '''Entity links''': `[[scala.collection.Seq]]` becomes * [[scala.collection.Seq]]. As far as I know there is know way to link to * external scaladoc so this is useless except for linking to other classes * in the same build. * - '''External links''': `[[http://scala-lang.org Scala web site]]` becomes * [[http://scala-lang.org Scala web site]]. * * == Block elements == * Paragraphs should be obvious by now, just include a blank line. So lets move * to code blocks with a simple fibonacci example: * * {{{ * def fib(n: Int) = if (n < 2) n else fib(n - 1) + fib(n - 2) * }}} * * Headings are pretty straightforward, lets show some examples: * =h1= * Note that the default style for h1 makes it some white color with a drop * shadow that is difficult to see in the main body of the documentation. * ==h2== * ===h3=== * ====h4==== * =====h5===== * ======h6====== * * == Lists == * There is an example unordered list for the inline elements. This example will * be more gratuitous and try the various list types that are supported. I must * be an idiot because I couldn't figure out how to make unordered lists work * without looking at the scaladoc source code. Now it seems rather obvious * from the instructions. The problem I had was the "`$` is the left margin" * bit. I kept trying to include a `$` in the code to now avail. The other * problems is that the first whitespace after the `*` is ignored. However, * I still contend that with a simple example it would have been obvious right * away, so here are some list examples that have been tested and actually * generate a list: * * 1. item one * 1. item two * - sublist * - next item * 1. now for broken sub-numbered list, the leading item must be one of * `-`, `1.`, `I.`, `i.`, `A.`, or `a.`. And it must be followed by a space. * 1. one * 2. two * 3. three * 1. list types * I. one * i. one * i. two * I. two * A. one * A. two * I. three * a. one * a. two * * I didn't see it mentioned on the document but you can also add a horizontal * rule with 4 dashes. See hr below: * * ---- * * Ok now a brief look at supported javadoc tags. `@code` gets mapped to * inline monospace, e.g., {@code testing}. `@docRoot` and `@inheritDoc` are * mapped to empty strings. `@link`, `@linkplain`, and `@value` are also mapped * to inline monospace, e.g., {@link link}, {@linkplain linkplain}, * {@value value}. Note it seems linkplain is confused with link. `@literal` * just dumps the value in without modification, e.g., {@literal some value * '''in a literal''' that __will__ get wiki formatting}. * * @author subnormal numbers * @see scala.collection.Seq */ object Example { /** * Adds two integers. * @param v1 actual parameter * @param v2 actual second parameter * @param v3 garbage, but no warning :( * @return sum of two integers * @throws java.io.Exception also garbage, but no warning * @since 1.5 * @todo do something useful * @deprecated * @note a profound note * @example add(2, 2) */ def add(v1: Int, v2: Int): Int = v1 + v2 }
#!/usr/bin/env python import sys def printDiamond(width): ''' Print a diamond to the console. The diamond must have an odd width, if the width is even and error will be printed to stderr and the program will exit. ''' if width % 2 == 0: sys.stderr.write("ERROR: width must be odd\n") sys.exit(1) # Print top half of diamond numSpaces = width / 2 numAsterisks = 1 while numAsterisks <= width: sys.stdout.write(" " * numSpaces) sys.stdout.write("*" * numAsterisks) sys.stdout.write("\n") numSpaces -= 1 numAsterisks += 2 # Print bottom half of dimaond numSpaces = 1 numAsterisks = width - 2 while numAsterisks >= 1: sys.stdout.write(" " * numSpaces) sys.stdout.write("*" * numAsterisks) sys.stdout.write("\n") numSpaces += 1 numAsterisks -= 2 if len(sys.argv) < 2: print "Usage: %s <width>" % sys.argv[0] sys.exit(1) else: printDiamond(int(sys.argv[1]))
(i, j)
. At this point a lot of candidates just get bogged down trying to figure out the math and never step back to think about whether there is an easier way. I suppose the consistency is just that the basic trap is so easy to fall into for this question.
In conventional terms, when a one is written to disk the media records a one, and when a zero is written the media records a zero. However the actual effect is closer to obtaining a 0.95 when a zero is overwritten with a one, and a 1.05 when a one is overwritten with a one. Normal disk circuitry is set up so that both these values are read as ones, but using specialised circuitry it is possible to work out what previous "layers" contained. The recovery of at least one or two layers of overwritten data isn't too hard to perform by reading the signal from the analog head electronics with a high-quality digital sampling oscilloscope, downloading the sampled waveform to a PC, and analysing it in software to recover the previously recorded signal.Sometimes an oscilloscope may not be enough and you might need to use magnetic force microscopy or other techniques that require very expensive equipment. It should also be pointed out that the article was written 15 years ago, and hard drive densities have increased a lot in that time period. Microscopy techniques have no doubt improved as well, but it is still going to be much more difficult to recover data from modern drives. In the 2006 NIST Guidelines for Media Sanitization, they suggest that a single pass is enough to clear data:
For some media, clearing media would not suffice for purging. However, for ATA disk drives manufactured after 2001 (over 15 GB) the terms clearing and purging have converged. Studies have shown that most of today’s media can be effectively cleared and purged by one overwrite using current available sanitization technologies.In short, it appears to be cost prohibitive to recover data that has been wiped with a single pass. Lets face it, for most of the data on your computer it would probably cost more to recover than the attacker could ever get back by stealing that information, and most likely there are much faster and easier ways to steal your data.
Was your problem solved?I had to answer yes, however, my problem could have easily been solved if they would have just processed the web form in a reasonable way. I gave them all of the information they needed on the form, there was no reason to do the live chat.
- yes
- no
Would you use this service again?Well, for nice high speed internet in my area Comcast is really the only choice and there was no way to avoid the live chat on the website. So yes I would use it again.
- yes
- no
How helpful was the Comcast representative?The representative was as helpful as she could be given the whole service, especially for my issue, was a complete waste. The sales pitches were annoying, but I'm sure the representatives are required to nag the customers with that garbage.
- not helpful
- helpful
Was this service more or less work than you expected?I said way more than expected. In reality when I first saw the text on the form saying I would have to do the live chat to finish I was expecting a complete pain in the ass and waste of my time. So I suppose it was about what I expected. However, since there was no place on the survey for free text and the questions are not designed to get useful feedback, this last question seemed like the best option for ranking them poorly.
- less
- about what I expected
- a little more than I expected
- way more than I expected
#!/usr/bin/perl use strict; use warnings; use Data::UUID; use UUID::Tiny; sub v3_data_uuid { my $namespace = shift; my $name = shift; my $ug = shift; $ug = new Data::UUID unless defined $ug; return lc($ug->create_from_name_str($namespace, $name)); } sub v3_uuid_tiny { my $namespace = shift; my $name = shift; return UUID_to_string(create_UUID(UUID_V3, $namespace, $name)); } # Generate a v3 UUID using Data::UUID print "Data::UUID\n"; my $ug = new Data::UUID; print ' 1. ', lc($ug->create_from_name_str(UUID_NS_DNS, 'abc')), "\n"; print ' 2. ', lc($ug->create_from_name_str(UUID_NS_DNS, 'abc')), "\n"; print ' 3. ', v3_data_uuid(UUID_NS_DNS, 'abc'), "\n"; print ' 4. ', v3_data_uuid(UUID_NS_DNS, 'abc'), "\n"; print ' 5. ', v3_data_uuid(UUID_NS_DNS, 'abc', $ug), "\n"; # Generate a v3 UUID using UUID::Tiny print "UUID::Tiny\n"; print ' 1. ', UUID_to_string(create_UUID(UUID_V3, UUID_NS_DNS, 'abc')), "\n"; print ' 2. ', UUID_to_string(create_UUID(UUID_V3, UUID_NS_DNS, 'abc')), "\n"; print ' 3. ', v3_uuid_tiny(UUID_NS_DNS, 'abc'), "\n"; print ' 4. ', v3_uuid_tiny(UUID_NS_DNS, 'abc'), "\n"; # Generate a v3 UUID using Data::UUID with an invalid namespace print "Data::UUID - bad namespace\n"; my $namespace = 'namespace'; print ' 1. ', lc($ug->create_from_name_str($namespace, 'abc')), "\n"; print ' 2. ', lc($ug->create_from_name_str($namespace, 'abc')), "\n"; print ' 3. ', v3_data_uuid($namespace, 'abc'), "\n"; print ' 4. ', v3_data_uuid($namespace, 'abc'), "\n"; print ' 5. ', v3_data_uuid($namespace, 'abc', $ug), "\n"; # Generate a v3 UUID using UUID::Tiny with an invalid namespace print "UUID::Tiny - bad namespace\n"; print ' 1. ', UUID_to_string(create_UUID(UUID_V3, $namespace, 'abc')), "\n";
$ ./uuid.pl Data::UUID 1. 1fc38bb9-aae5-3dba-9894-38925088c9c0 2. 1fc38bb9-aae5-3dba-9894-38925088c9c0 3. 1fc38bb9-aae5-3dba-9894-38925088c9c0 4. 1fc38bb9-aae5-3dba-9894-38925088c9c0 5. 1fc38bb9-aae5-3dba-9894-38925088c9c0 UUID::Tiny 1. 5bd670ce-29c8-3369-a8a1-10ce44c7259e 2. 5bd670ce-29c8-3369-a8a1-10ce44c7259e 3. 5bd670ce-29c8-3369-a8a1-10ce44c7259e 4. 5bd670ce-29c8-3369-a8a1-10ce44c7259e Data::UUID - bad namespace 1. 15da4c6e-29ae-3f6c-a7ed-ec36373d4e5d 2. 15da4c6e-29ae-3f6c-a7ed-ec36373d4e5d 3. 8fa130be-2517-3e29-a087-c7d75545a62c 4. 8fa130be-2517-3e29-a087-c7d75545a62c 5. 8fa130be-2517-3e29-a087-c7d75545a62c UUID::Tiny - bad namespace UUID::Tiny::string_to_uuid(): 'namespace' is no UUID string! at ./uuid.pl line 50
namespace
, then I get different values depending on how/where/when it is called. UUID::Tiny on the other hand dies with a nice error message telling me exactly what is wrong.