How to get a free share of stock from Robinhood

When I joined I didn’t get a free share because I used a referral link that wasn’t in the program. But I just recently got my own referral link that does give free stocks to people who join through it:

If you use this link it should say “There’s A Free Stock Waiting For You”

Robinhood is a brokerage that doesn’t charge a fee for buying or selling stocks.


How to get StarCraft 1.18+ running on Wine

Blizzard hotfixes the latest version and it works in Wine again


Install the latest Wine Staging

The current staging has patches in it to make running StarCraft possible. You can install the latest staging from:

Run the installer inside of a new Wine prefix like $HOME/sc-prefix and install the game there. Do not start the game after the installer is done. Hit x to close the installer when it’s finished.

Before you run it, run wineconfig on your StarCraft prefix.

env WINEPREFIX="$HOME/sc-prefix" wine winecfg

You can use the the system version of wineconfig if you’d like. Select Windows 2003 version. This makes StarCraft run, Windows XP and Windows 10 don’t seem to work on my machine.

As of staging 3.7, I no longer need that work-around, both 32 and 64 bit prefixes work without it.

Then make sure you have the correct dependencies. On Ubuntu 32 bit prefix I needed to install:

$ sudo dpkg --add-architecture i386

$ sudo apt-get update

$ sudo apt-get install libgl1-mesa-glx:i386 libasound2:i386 libasound2-plugins:i386 libc6:i386 libncurses5:i386 libstdc++6:i386 libxtst6:i386 libldap-2.4-2:i386 libfreetype6:i386

An Arch user reported he needed lib32-mpg123. You might possibly need other packages as well.

You can create a shortcut like:

env WINEPREFIX="$HOME/sc-prefix" wine StarCraft.exe

that runs inside the StarCraft folder. That way you can run using a shortcut instead of having to manually open a terminal every time.

If you don’t want the launcher to launch modify the shortcut to

env WINEPREFIX="$HOME/sc-prefix" wine StarCraft.exe -launch


If you encounter issues with StarCraft, there are two entries in Wine DB for the latest versions:

SD Remastered

You can check each issue for workarounds. I list some of them here.

Blizzard launcher

If Blizzard launcher has buttons you can’t click or see, change the version of the launcher to Windows 2003. It’s the executable inside of Blizzard App folder (not inside the StarCraft folder itself). This will give you a message that your Windows version is not supported, so you can change it back if you don’t need it.

Difficulties logging in, 6:3 Error

If you can’t log in to the app, on the log-in screen you will see styled boxes on top. Those do not work. Use the white boxes below them. You won’t be able to see what you’re typing, but you will be able to log in if you type into them and hit the Enter key. If you are logged in, you won’t get 6:3 Error.

Slow Menus

When running Ubuntu 17.04 I encountered an issue with menus being slow. I downgraded to 16.04 and the issue mostly disappeared. Sometimes I have to restart the game to fix it again, but that’s not as bad as having to wait for more than 30 seconds for each menu.

Game Stuck Under Overlay

I’ve had the game stuck in a dark overlay when I pressed F10 to bring up the menu. I was able to get out of it by pressing Alt+Q during a game. This brings up the quit game modal, so I could select cancel. Selecting cancel brought me back to the game.

Performance in StarCraft: Remastered

My computer only could do 106 FPS in Remastered and 300 in SD. When I loaded up OBS, I could only hold barely above 60 FPS. OBS itself could only hold a pitiful 24 FPS.

What I did was downgrade to kernel version 4.04 and for some reason I can get 300+ FPS in Remastered and stream at 1440p in OBS at 60 FPS (although that requires too much bitrate for Twitch). Your mileage may vary. I’m not even using AMDGPU Pro drivers (I downgraded to install them and found out I didn’t need to).

Lag in ladder games

Make sure to forward port 6112 on UDP.

Ctrl+5 doesn’t work

Ctrl+5 is a shortcut in fcitx for Reload configuration in Global Config (check Advance Option). Not a StarCraft bug per se, but international users keep running into it.

Real Time Lighting

Currently StarCraft doesn’t detect that I have more than 2.2GB of VRAM, so this feature can’t be enabled from inside the game.

Appendix: How to Install from source

Use so you don’t have to apply staging patches manually.

$ git clone

and then follow this guide to compile it

Note that you don’t need to run the `clean` command on a freshly created folder.

After you finish building the 32 bit Wine you don’t need to install it system-wide, just make the shortcut point to the correct version of Wine.

How to fix Google play services has stopped problem

I recently flashed my tablet with a newer Android version that wasn’t available over the air. I kept getting an error “Google play services has stopped” every few seconds. I tried clearing cache and data, but it wouldn’t go away.

What actually did work for me is going to Settings -> Apps -> Show system apps -> Google play services and giving it all the permissions. Apparently it was freaking out because it was lacking some permission.

FizzBuzz in Rust

The FizzBuzz Test is sometimes given at interviews to filter out candidates who don’t program. The test is as follows:

Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

If you wanted to show that you can program, you’d write something like

fn main () {
    for n in 1..101 {
        if n % 15 == 0 {
        } else if n % 3 == 0 {
        } else if n % 5 == 0 {
        } else {
            println!("{}", n);

This would be sufficient to get to the actual part of the interview where the interviewer can assume you can write a for loop. I’ll admit that half of the time I mess up if I’m not paying attention. This time I forgot to write the % 15 case first so I had to go back and fix it.

But let’s say you had to write this at your job for some reason. This solution is fine, until your boss comes back and says “OK, do the same thing, but now can you make it write Bazz instead of Buzz?”

It would be tempting to just make the substitution in place. But you have new knowledge that requirements may change frequently, so you decide to refactor the program before you change it.

fn main() {
    let first = "Fizz";
    let second = "Buzz";

    for n in 1..101 {
        println!("{}", fizzbuzz(first, second, n));

fn fizzbuzz(first: &str, second: &str, n: i32) -> String {
    if n % 3 == 0 {
    } else if n % 5 == 0 {
    } else if n % 15 == 0 {
        first.to_string() + second
    } else {

You can now freely change the string that’s being concatenated, it doesn’t matter if it’s Buzz or Bazz. You can even write a nice test for it:

mod tests {
    use super::fizzbuzz;

    fn it_works() {
        assert!(fizzbuzz("Fizz", "Buzz", 3) == "Fizz".to_string());
        assert!(fizzbuzz("Fizz", "Buzz", 5) == "Buzz".to_string());
        assert!(fizzbuzz("Fizz", "Buzz", 15) == "FizzBuzz".to_string());
        assert!(fizzbuzz("Fizz", "Buzz", 4) == 4.to_string());

But now our boss comes back and says “What I meant is that you’re supposed to do Fizz, Buzz, Bazz for 3, 5, 7”. Suddenly, our solution is bad. Before we had four cases where we duplicate some code in one of them. Now we have nine cases, and if our boss comes back to ask for more features, possibly sixteen. We try this solution:

fn main() {
    let first = "Fizz";
    let second = "Buzz";

    for n in 1..101 {
        println!("{}", fizzbuzz(&[(first, 3), (second, 5)], n));

pub fn fizzbuzz(tuples: &[(&str, i32)], n: i32) -> String {
    let mut output = String::from("");
    for &tuple in tuples {
        let (s, factor) = tuple;
        if n % factor == 0 {
             output = output + s;
    if output == "" {
    } else {

It’s a clever hack, exploiting the fact that the empty string is an identity element in string concatenation. Unfortunately, it doesn’t pass our new test suite:

mod tests {
    use super::fizzbuzz;

    fn it_works() {
        assert!(fizzbuzz(&[("Fizz", 3), ("Buzz", 5)], 3) == "Fizz".to_string());
        assert!(fizzbuzz(&[("Fizz", 3), ("Buzz", 5)], 5) == "Buzz".to_string());
        assert!(fizzbuzz(&[("Fizz", 3), ("Buzz", 5)], 15) == "FizzBuzz".to_string());
        assert!(fizzbuzz(&[("Fizz", 3), ("Buzz", 5)], 4) == 4.to_string());
        assert!(fizzbuzz(&[("", 3), ("Buzz", 5)], 3) == "".to_string());

Because we used arbitrary strings, our function doesn’t work for empty strings! I don’t know about you, but I feel uneasy writing a function that fails on some valid inputs. Even if we think (read: hope) that those inputs won’t be fed into our function, we can do better. Rust helpfully has the Option type to actually mark absence of something. We can mark the absence of a match as None, and the presence of a match as Some(String).

pub fn fizzbuzz(tuples: &[(&str, i32)], n: i32) -> String {
    let default = || n.to_string();
    accumulate(tuples, n).unwrap_or_else(default)

Now we’ll write the accumulate function. There is actually a library called itertools that has a function called fold1 that does a fold starting with None and returns Some if there are things to fold.

fn accumulate(tuples: &[(&str, i32)], n: i32) -> Option<String> {
        .filter(|&x|n % x.1 == 0)

fn first<A, B>(&(ref first, _): &(A, B)) -> &A {

The function first is not really necessary, but it feels clearer to me. We also have to unfortunately write a trait for things that can be concatenated.

pub trait Concatenable {
    fn concat(self, other: Self) -> Self;

impl Concatenable for String {
    fn concat(mut self, other: String) -> String {

But we’ll ignore that and hope Add is implemented on String + String in the future so we can easily call fold1 on it. But notice that our FizzBuzz program no longer has a single if statement or even a match. This is because the logic of excluding non-factors is inside the filter and the logic for writing the original number is in unwrap_or_else. The benefit of this is there is only one path through the program. The whole program is now in a declarative style.

The final result (with some dependencies inlined) is here:

I also wrote the same thing using Cow<'a, str> and each condition being a closure in my repository:


How to make foobar2000 look like Google Play Music


I liked the Google Play Music UI because I could remember albums by their covers. So I figured out how to style foobar2000 to do the same thing.

I needed the EsPlaylist component from

After installing it, I had to add it to the UI in Quick Edit mode. After that I could right click and select Browse -> Browse Library. That lets me view my library using the EsPlaylist component. I also used the Biography View component from the same website to download the cover art for the albums.



How to update the PATH variable on windows without logging off or rebooting

When you go to Computer->Properties->Advanced System Settings->Environment Variables you can change the PATH variable. But the general advice is that you have to log off or reboot to actually see the change.

I actually found a work-around:

  1. Change the PATH variable.
  2. Add a new variable, call it something random. Maybe something like CHANGE_TO_UPDATE and put a random value like x in it.
  3. Remember to restart cmd.exe or whatever program that needs to see the new path variable.

Voila! It should now work. When I didn’t do step 2, it did not work for me no matter which other solutions I tried.

Implementing FizzBuzz with monoids in Rust

I was very impressed with the Haskell solution to FizzBuzz. The blog is now down, but here’s the Internet Archive of the page:

I asked /r/rust about implementing monoids in the Rust programming language and got help with porting the Haskell version.

Here’s the repository:

It’s mostly written by Reddit and IRC with me piecing it together until it type checked and did the same thing the Haskell program did.

Brag: it’s actually possible to write this in Rust because Monoids don’t require higher kinds.
Beat: I have to nest .op(.op()) to do several ops because of C-style syntax
Variance: I spent lots of time trying to figure out why [_, n,] didn’t type check, until [_, n, ..] just worked