HNHacker News
TopNewBestAskShowJobs

dzorz

174 karma · joined August 24, 2007

submissionscomments
dzorz··on Android X server
FWIW iSSH on iOS has good X support.
dzorz··on Show HN: Online C/C++ to assembly visualizer [Weekend Project]
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

dzorz··on Why artificially limit your code to C?
clang uses the same ABI as gcc and if you find that something is binary incompatible then it is a bug.
dzorz··on 500px Terms of Service
> approximately 60Gb of storage

Is that Gb or GB?

dzorz··on Your problem with Vim is that you don't grok vi
I use clang complete for vim. For me it is more precise than Visual Studio 2010 Intellisense (they use edg for code completion).
dzorz··on Finding the top K items in a list efficiently
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.
dzorz··on Finding the top K items in a list efficiently
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.
dzorz··on Finding the top K items in a list efficiently
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.
dzorz··on Google paper comparing performance of C++, Java, Scala, and Go [PDF]
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).

dzorz··on Google paper comparing performance of C++, Java, Scala, and Go [PDF]
Even better:

for (auto &x : vec) { }

dzorz··on N-Queen Problem: Python 2.6.5 vs PyPy 1.5.0
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
dzorz··on N-Queen Problem: Python 2.6.5 vs PyPy 1.5.0
140x speedup was compared to optimized python version. I've tried it vs. pypy now (version 1.5) - it is 20x faster.
dzorz··on N-Queen Problem: Python 2.6.5 vs PyPy 1.5.0
next_permutation is in standard library (header algorithm).
dzorz··on N-Queen Problem: Python 2.6.5 vs PyPy 1.5.0
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.
dzorz··on The Dark Side of C++ (2007)
Wow, that is amazing. I honestly never tried that and assumed (because of short circuiting) that it can't be overloaded.
dzorz··on The Dark Side of C++ (2007)
Actually you can't overload && although you can overload &.
dzorz··on Fired employee wipes out whole season of TV show
April 1st?
dzorz··on Foursquare 3.0 Has Arrived: Here's What's New
What does LBS mean?
dzorz··on C++ in Coders at Work
C++0x solves that issue by introducing rvalues.
dzorz··on ACM considered harmful
IEEE is much more expensive.
dzorz··on List Processing in C
> it's because expressions separated by a comma can be evaluated in any order (I believe).

Expressions separated by the comma operator are always evaluated left to right. On the other hand function arguments (which are separated by comma) can be evaluated in any order.

dzorz··on Quicksort is the new Hello World
Although this version is very simple, concatenating and creating lists at runtime ruins performance (and it takes extra memory). Please make it a good example by doing a version of Quicksort with in-place partition.
dzorz··on Ways to get screwed by C
> Still not convinced? Try this one (suggested by Mark Scarbrough ):

     #define DEVICE_COUNT 4 
    uint8 *szDevNames[DEVICE_COUNT] = {
            "SelectSet 5000",
            "SelectSet 7000"}; /* table has two entries of junk     
    */
Actually, the remaining two entries are 0, they are not junk.
dzorz··on A Graphical Web Browser for Linux Command Line
I think uzbl is much more promising. It is built on WebKit and with little tweaks you can install it without X: http://lug.rose-hulman.edu/wiki/DirectFB
dzorz··on How Fake Money Saved Brazil
80% per month sounds crazy, but it is not even close to top 6: http://en.wikipedia.org/wiki/Hyperinflation#Worst_Hyperinfla...
dzorz··on Zed Shaw on C++
You can make a string class that interns strings. Language can express it, but std::string doesn't do it.
dzorz··on Protocol Buffers by Google
You could've used fixed32 instead of int32 (varint)... Just sayin' :-)
dzorz··on Large-scale design in Haskell?
I understand that Xmonad probably is engineered like a large project, but I don't think it really qualifies as a large project. I'd say it is mid-size at best.
dzorz··on The 10:10 Code
Ditto for X, Y, W.
dzorz··on The Real Cost of Owning a Car
> How much would I have after three years? Assuming a modest 10% return per year

Is 10% really a modest return?

Page 1 of 3Next →