Recent submissions

Comment · 14 years ago
FWIW iSSH on iOS has good X support.
Comment · 14 years ago
This is part of your /etc/shadow file:

    root:censored
We can still read /etc/ssh/ssh_host_rsa_key, etc.

Edit: removed hash, sorry

Comment · 14 years ago
clang uses the same ABI as gcc and if you find that something is binary incompatible then it is a bug.
Comment · 14 years ago
> approximately 60Gb of storage

Is that Gb or GB?

Comment · 15 years ago
I use clang complete for vim. For me it is more precise than Visual Studio 2010 Intellisense (they use edg for code completion).
Comment · 15 years ago
It uses heap only as a fallback if maximum recursion depth is reached. The key difference between __introselect and the posted article is that __introselect uses pivoting to (ideally) "throw" away half of the array during each step.
Comment · 15 years ago
The original article uses heap to get top K numbers. It's runtime complexity is O(N*log(K)) and nth_element is O(N), so the algorithms are not similar at all.
Comment · 15 years ago
Here is a solution in C++. It reads K and then N numbers from stdin and then prints K largest.

The complexity of nth_element is O(N).

    #include <algorithm>
    #include <vector>
    #include <iostream>
    #include <iterator>

    using namespace std;

    int main() {
        int K;
        cin >> K;
        vector<int> numbers((istream_iterator<int>(cin)),
                            istream_iterator<int>());
        nth_element(numbers.begin(), numbers.begin() + K, numbers.end(),
                    greater<int>());
        for (int i = 0; i < K; ++i) {
            cout << numbers[i] << ' ';
        }
        cout << '\n';
    }

Input:

    5
    1 9 1 3 7 8 2 11 2 5 5 9 1 7
Output:

    7 9 9 11 8
Note: the output is not sorted.
Comment · 15 years ago
If you compile recent clang, it supports range based for loops.

Using https://github.com/Rip-Rip/clang_complete you can use smart context-aware completion with vim/emacs.

For example if you had this code:

vector<string> vec; for (auto &x : vec) { x

and then if you typed period (.), it would show members from std::string. I'd say it works better than Intellisense (it's very precise and you use the same parser for code completion and final compilation).

Comment · 15 years ago
Even better:

for (auto &x : vec) { }

Comment · 15 years ago
I managed to compile the program using shedskin, but it throws a runtime error after it finds the first solution:

    ==== solution 1 =====
    (0, 2, 5, 7, 9, 4, 8, 1, 3, 6)
    terminate called after throwing an instance of '__shedskin__::TypeError*'
    Aborted
Comment · 15 years ago
140x speedup was compared to optimized python version. I've tried it vs. pypy now (version 1.5) - it is 20x faster.
Comment · 15 years ago
next_permutation is in standard library (header algorithm).
Comment · 15 years ago
I think this is an example where C++ really shines. The code is not much longer (44 vs 33 lines, although the output in python version is much nicer) than the python code and on my computer it is about 140x faster than python 2.7.1.
Comment · 15 years ago
Wow, that is amazing. I honestly never tried that and assumed (because of short circuiting) that it can't be overloaded.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton