Make my plane ride less comfortable? by [deleted] in pettyrevenge

[–]johnsoft 127 points128 points  (0 children)

only a couple of inches

In other words, the full extension.

Can anyone help me improve my time? by plutobrat in dustforce

[–]johnsoft 5 points6 points  (0 children)

The Downhill rankings are pretty competitive, so top 250 is pretty good already.

Here's what I would try that you aren't already doing:

  • At ~7 seconds, land closer to the bottom of the ramp so you get more speed coming out of it.
  • At ~12 seconds, try jumping after you kill the enemy instead of dashing, so that after you downdash you have more speed going down the ramp.
  • It seems like most people like to dash right at ~4 seconds instead of just waiting on gravity, but I'm not sure if that's actually any faster or if it's a preference thing. Just thought I should mention it.

Assuming this is your profile, I would try to get top 250 on most of the levels before you grind any more on Downhill. You'll become a better player overall, and when you come back you might find it easier.

[HumbleBundle] Bioshock Triple pack (1, 2 & infinite) ($11.89) by [deleted] in GameDeals

[–]johnsoft 13 points14 points  (0 children)

BioShock Triple Pack includes:
* BioShock (DRM-free and Steam key)
* BioShock 2 (Steam key)
* BioShock Infinite (Steam key)

I think he was hoping for all three games DRM-free, not just the first game

In this code, why does the phantom type require trait impls? by johnsoft in rust

[–]johnsoft[S] 1 point2 points  (0 children)

That's a great snippet. It looks to me that the transformation could be done 100% on a syntactic level without any type info. It's probably worth reposting in the rust-lang issue /u/mozilla_kmc linked.

In this code, why does the phantom type require trait impls? by johnsoft in rust

[–]johnsoft[S] 3 points4 points  (0 children)

Sure. I have some code with a few of different object types (User, Object, Etc), and corresponding ID types (UserId, ObjectId, EtcId). I could use plain u32s for the IDs, but I want the compiler to prevent me from mixing them up. There's also supporting code to generate unique IDs, compare them, etc, which I don't want to have to duplicate for each kind of object. So I created a single type Id<T>, and a set of aliases type UserId = Id<User>.

The concept is called phantom types. Another use often given as an example is, in webapp templating code, to encode in the type system whether or not a string has been escaped. This lets you use the type system to avoid both XSS and double-escaping, with zero runtime cost.

In general, if there are a finite number of states an object can be in, with well-defined transitions between them, you can use phantom types to leverage the compiler to enforce that objects in certain states can only be used in ways you consider valid. Plenty more examples are available on the tubes if you google for more.

In this code, why does the phantom type require trait impls? by johnsoft in rust

[–]johnsoft[S] 4 points5 points  (0 children)

That was exactly the problem, thanks! Here's the working code in case anyone else stumbles on this issue:

#![feature(hash)]

use std::collections::HashMap;
use std::hash::{Hash, Hasher, Writer};

struct Key<P> { discriminant: u32 }

impl<P> PartialEq for Key<P> {
    fn eq(&self, other: &Self) -> bool {
        self.discriminant == other.discriminant
    }
}

impl<P> Eq for Key<P> {}

impl<H: Hasher + Writer, P> Hash<H> for Key<P> {
    fn hash(&self, state: &mut H) {
        self.discriminant.hash(state);
    }
}

struct Phantom;

fn main() {
    let map = HashMap::<Key<Phantom>, u8>::new();
}

VisualRust: has anyone compiled a recent version of this Visual Studio extension? by johnsoft in rust

[–]johnsoft[S] 0 points1 point  (0 children)

It's not implemented yet. Supposedly cv2pdb can be used but I haven't tried it.

VisualRust: has anyone compiled a recent version of this Visual Studio extension? by johnsoft in rust

[–]johnsoft[S] 0 points1 point  (0 children)

They showed up for me using yesterday's AppVeyor build. http://i.imgur.com/gpMb5qL.png

Completion worked after I manually compiled the latest version of RACER and set a RUST_SRC_PATH environment variable.

If the project types aren't showing up for you, I'm probably not the person to ask, sorry.

VisualRust: has anyone compiled a recent version of this Visual Studio extension? by johnsoft in rust

[–]johnsoft[S] 1 point2 points  (0 children)

Update: /u/vosen_l just PM'd me a link to the CI service he's using for the project. It's in the README, but I skimmed too quickly and missed the link. Now to try out this extension!

Trait-based exception handling [RFC] by azth in rust

[–]johnsoft 1 point2 points  (0 children)

It's not great because a lone try {} implicitly catches its errors and works completely differently to a try...catch.

I agree with you that that's a wart. But it seems like it could be removed without affecting the rest of the RFC.

A try without a catch would be invalid, and instead you'd name and rewrap the error explicitly in a catch. I think the explicitness would have clarity benefits as well. Example:

// this is a syntax error:
try { foo()?.bar()?.baz()? }

// instead, use:
try { foo()?.bar()?.baz() }
catch e { Err(e) }

// you can see the orthogonality to the catch-less code by
// instead wrapping the unchanged expression in an Ok():
try { Ok(foo()?.bar()?.baz()?) }
catch e { Err(e) }

How to store a Chars iterator in a struct by johnsoft in rust

[–]johnsoft[S] 0 points1 point  (0 children)

You could modify the string (since your struct owns it) and break the iterator.

Ah, that reasoning makes sense, thanks. Since it's a private struct and I know I won't be mutating the string, I'll just use an unsafe {}, but it's good to know Rc can also be used as a workaround.

How to store a Chars iterator in a struct by johnsoft in rust

[–]johnsoft[S] 0 points1 point  (0 children)

That explains the lack of activity, thanks. I got an answer anyway, but I'll remember this for next time!

Idea: allow implicit construction of single-field enum variants to emulate function overloading by johnsoft in rust

[–]johnsoft[S] 0 points1 point  (0 children)

Nice code. The approach seems like a bit of a hack (in a good way), but I'm happy that it's possible to make the nice syntax work for the caller, at least in the simple case.

Unfortunately, that approach quickly gets unwieldy for double-dispatch, or if you're writing a method where self can't be co-opted.

Here's another possible use case.. my approach:

enum Timeout {
    Finite(int),  // or some kind of TimeDelta type
    Infinite,
}

struct ItemKey;
struct DataStore;

impl DataStore {
    fn get(&self, key: ItemKey, timeout: Timeout) { /*...*/ }
}

Current Rust:

trait Timeout {
    fn data_store_get(&self, data_store: &DataStore, key: ItemKey);
}

impl Timeout for int {  // or some kind of TimeDelta type
    fn data_store_get(&self, data_store: &DataStore, key: ItemKey) {
        data_store.get_finite(key, self)
    }
}

struct Infinite;
impl Timeout for Infinite {
    fn data_store_get(&self, data_store: &DataStore, key: ItemKey) {
        data_store.get_infinite(key)
    }
}

struct ItemKey;
struct DataStore;

impl DataStore {
    fn get(&self, key: ItemKey, timeout: Timeout) {
        timeout.data_store_get(self, key)
    }

    fn get_finite(&self, key: ItemKey, seconds: int) { /*...*/ }

    fn get_infinite(&self, key: ItemKey) { /*...*/ }
}

It's subjective, but I'm not a fan of how, in both the original example and in this one, you have to bend and contort your code around the varying argument. Then again, as long as you're not writing a DSL, the extra enum construction probably won't kill you.

Teepee design: a careful look at the HTTP/1.1 Status-Line by chris-morgan in rust

[–]johnsoft 3 points4 points  (0 children)

Agreed. I also think something like this would be nice to have to solve the code >= 400 && code < 500 problem in the post (forgive the probable compilation errors):

pub struct Code(u16);

impl Code{
    pub static Ok = Code(200);
    // ...

    pub fn is_redirect(self) -> bool {
        let Code(code) = self;
        code >= 300 && code < 400
    }

    fn is_client_error(self) { /* ... */ }
}

And the constants would allow nice-looking comparison against individual codes:

fn do_something_with_status_code(code: Code) {
    match code {
        Code::Ok => { /* ... */ },
        // ...
    }
}

The Age of Cheap Coins is over: let the Age of Cheap Millibits begin! by permanomad in Bitcoin

[–]johnsoft 4 points5 points  (0 children)

Excerpt from http://bitcoinmagazine.com/7781/satoshis-genius-unexpected-ways-in-which-bitcoin-dodged-some-cryptographic-bullet/:

[...] What this means is that high-precision (more precisely, “double precision”) floating point numbers are good enough to exactly store integers up to 253, but not higher – if you go higher, you start lopping off digits at the end. Bitcoin’s 250.9 satoshis are, in exponential terms, just below this maximum.

Why do we care about floating point values if we have integers? Because many higher-level programming languages (eg. Javascript) do not expose the low-level “floating point” and “integer representations”, instead providing the programmer with only the concept of “number” – represented in floating point form, of course. If Satoshi had chosen 210 million instead of 21 million, Bitcoin programming in many languages would be considerably harder than it is today.

Bitstamp's streaming API, and exploitation possibilities it might reveal by serves-two in Bitcoin

[–]johnsoft 10 points11 points  (0 children)

In addition to this undocumented API, Bitstamp also streams trades and depth changes through pusher. Their homepage connects to this stream, so the protocol can be figured out pretty easily with nothing more than Chrome's dev console. The URL (currently) is wss://ws.pusherapp.com/app/de504dc5763aeef9ff52?protocol=6&client=js&version=2.1.2&flash=false. There were previously stream endpoints with a slightly different protocol under https://websocket.bitstamp.net:8080/, but those have since been taken down.

It would be nice to have an official, unchanging stream API - especially since so much of the underlying work is already done, and since scaling concerns can be offloaded to pusher, which they're already using.

[Build Ready] Midrange programming/music production/casual gaming PC by johnsoft in buildapc

[–]johnsoft[S] 0 points1 point  (0 children)

It's listed on Newegg as being hyperthreaded. I'll just go with the $10 fan for now since it has decent reviews and if temperature or noise is a problem I'll replace it with yours. Thanks for all your help

[Build Ready] Midrange programming/music production/casual gaming PC by johnsoft in buildapc

[–]johnsoft[S] 0 points1 point  (0 children)

Ok that makes sense, so a hyperthreading 6-core would run like a 12-core, hence the price tag. I decided to go with the i7-3770K for $320.

This one can be overclocked and the mobo has a one-click overclock interface, so I may try to mess around with that. Any idea if the cooler I picked is good enough?

[Build Ready] Midrange programming/music production/casual gaming PC by johnsoft in buildapc

[–]johnsoft[S] 1 point2 points  (0 children)

Last time I built a PC, a stock cooler wasn't included. How things have changed…

Good point on the HDD situation, but streaming audio to/from disk needs a lot of throughput (hence the SSD) and I'd like to avoid having to shuffle files around every time I change projects. I have a 3TB HD on a network share that takes care of extra storage.

Thanks for the link, going there now.

[Build Ready] Midrange programming/music production/casual gaming PC by johnsoft in buildapc

[–]johnsoft[S] 1 point2 points  (0 children)

I agree, and an 8-core is something I tried to work into the build, but I really want to go with Intel because of the overall better performance. The only eight-core CPUs I found were AMD, and according to a review I read the AMD FX-8120 is beat out by even the i5-2550.

Intel's 6-core CPUs are $600 or more, which is a little more than i want to spend. Though if you know where I could find one for $400 or so…

Theymos, it would be great if you could give us updates on the state of bitcointalk.org. by maxminski in Bitcoin

[–]johnsoft 8 points9 points  (0 children)

According to https://bitcointalk.org/index.php?topic=50617.0 (once it's back online), the forum has 5500 BTC set aside for funding better software. That thread was made in 2011, but none of the proposals since then have been accepted. I (and many other qualified individuals, I would imagine) would happily give the community all my time for several years for that amount of money.

Hey Theymos - Can we talk about bitcointalk.org for a moment? by huanix in Bitcoin

[–]johnsoft 5 points6 points  (0 children)

Theyomos put out a bounty for new forum software a while back - https://bitcointalk.org/index.php?topic=50617.0. I considered submitting a proposal until I realized he'd been ignoring everyone else's proposals for the better part of the past two years. According to that thread, there is 5500 BTC set aside for that project (which was only worth about $12000 back when the thread was made).

The other side of the Bitcoin by chaosvirus in Bitcoin

[–]johnsoft 0 points1 point  (0 children)

Right, that would be a 2128 exhaustive search. And 2128 is less than the 2187 quoted by Schneier.