Blog

  • Cloudron

    Cloudron is fascinating piece of software I found out a few days ago. It makes it super easy to self-host a bunch of applications like Nextcloud, GitLab, Wallabag, etc.

    They all have one-click installers and SSO with your Cloudron user accounts. Also, it supports encrypted backup to various cloud providers like Amazon S3, DigitalOcean Spaces, Google Cloud, etc.

    The only two downsides I’ve found are that it costs $30/mo and isn’t FOSS.

    I think I’m going to give it a try on a Linode server.

  • Pamac > Pacman

    I must say that I much prefer the Pamac CLI package manager to Pacman. It’s much more intuitive and I’m glad that Manjaro includes it by default.

  • Arduino Pong

    This is a simple pong game I created for fun for the CICS 290M Makerboard running Arduino software. The board is part of the CS Make course at UMass Amherst.

    Below is the source code, it’s also available on GitHub.

    // Imports
    #include <Adafruit_SSD1306.h>
    
    // Globals
    #define UP_BUTTON 34
    #define DOWN_BUTTON 0
    #define RESET_BUTTON 35
    #define BUZZER 17
    
    // Game State
    int score = 0;
    
    // Paddle
    int paddle_pos = 32;
    int paddle_velocity = 1;
    int paddle_height = 16;
    int paddle_width = 4;
    
    // Ball
    volatile int ball_x = random(10, 80);
    volatile int ball_y = random(16, 48);
    volatile int ball_radius = 3;
    volatile int ball_velocity_x = random(1, 3);
    volatile int ball_velocity_y = random(1, 3);
    
    
    Adafruit_SSD1306 lcd(128, 64); // create display object
    
    // Callbacks
    void IRAM_ATTR moveUp() {
      if (paddle_pos >= 0) {
        paddle_pos -= 1;
      }
    }
    
    void IRAM_ATTR moveDown() {
      if (paddle_pos + paddle_height <= 64) {
        paddle_pos += 1;
      }
    }
    
    void IRAM_ATTR restart() {
      if (gameOver()) {
        score = 0;
        ball_x = random(10, 80);
        ball_y = random(16, 48);
        ball_velocity_x = random(1, 3);
        ball_velocity_y = random(1, 3);
      }
    }
    void setup() {
      Serial.begin(9600);
      pinMode(BUZZER, OUTPUT);
      pinMode(UP_BUTTON, INPUT);
      pinMode(DOWN_BUTTON, INPUT);
      pinMode(RESET_BUTTON, INPUT);
      lcd.begin(SSD1306_SWITCHCAPVCC, 0x3C); // init
      lcd.setTextColor(WHITE);
      lcd.clearDisplay(); // clear software buffer
      lcd.display();
      attachInterrupt(RESET_BUTTON, restart, FALLING);
    }
    
    // Test if coordinates are out of bounds
    boolean yIsOutOfBounds(int y) {return y > 63 || y < 0;}
    boolean xIsOutOfBounds(int x) {return x > 127 || x < 0;}
    boolean outOfBounds(int x, int y) {return xIsOutOfBounds(x) || yIsOutOfBounds(y);}
    boolean gameOver() {return ball_x + ball_radius >= 127;}
    boolean ballPaddleCollision(int x, int y) {
      return (x > 128 - paddle_width) && (y < paddle_pos + paddle_height && y > paddle_pos);
    }
    
    void drawPaddle(int x, int y, int width, int height) {
      lcd.fillRect(x, y, width, height, WHITE);
    }
    
    void ding() {
      ledcSetup(0, 5000, 8);
      ledcAttachPin(BUZZER, 0);
      ledcWriteTone(0, 500);
      delay(50); // 500Hz for 0.05 second
      ledcWriteTone(0, 0); // buzzer off
    }
    
    void drawBall() {
      lcd.fillCircle(ball_x, ball_y, ball_radius, BLACK);
      if (xIsOutOfBounds(ball_x + ball_radius) || xIsOutOfBounds(ball_x - ball_radius)) {
        ball_velocity_x *= -1;
        ding();
      }
      if (yIsOutOfBounds(ball_y + ball_radius) || yIsOutOfBounds(ball_y - ball_radius)) {ball_velocity_y *= -1;}
      if (ballPaddleCollision(ball_x + ball_radius, ball_y) || ballPaddleCollision(ball_x - ball_radius, ball_y)) {
        ball_velocity_x *= -1;
        ding();
        score++;
      }
      ball_x += ball_velocity_x;
      ball_y += ball_velocity_y;
      lcd.fillCircle(ball_x, ball_y, ball_radius, WHITE);
    }
    
    void loop() {
      // Check if Game is over
      if (gameOver()) {
        lcd.clearDisplay();
        lcd.setCursor(0,0);
        lcd.print("Score: " + String(score) + "\nPress bottom button \nto restart.");
        lcd.display();
        return;
      }
      // Check for button presses
      if (!digitalRead(UP_BUTTON)) {
        moveUp();
      }
      if (!digitalRead(DOWN_BUTTON)) {
        moveDown();
      }
      lcd.clearDisplay();
      drawPaddle(0, ball_y - (paddle_height / 2), paddle_width, paddle_height);
      drawPaddle(127 - paddle_width, paddle_pos + paddle_velocity, paddle_width, paddle_height); 
      drawBall();
      lcd.display();
    }
  • Signal Foundation Donation

    I’ve decided to set up a monthly donation to the Signal Foundation. I’m not the biggest fan of Signal and I’ve been critical of the fact that it relies on central servers that can be shut off at any time.

    But none of the peer-to-peer apps I’ve tried (such as Tox) seem competitive in this space. I need something I can give a non-technical friend and not have them feel like its a downgrade from WhatsApp.

    For now I’m going to stick with Signal but I’ll keep an eye on some other promising projects like Matrix.

  • Switching to Krita from GIMP

    I’ve been using GIMP for the last couple of years, but since I’m on KDE Plasma I decided to give Krita a try.

    It’s actually very capable and I’m going to try using it in lieu of GIMP for a little while.

  • 2020 Recession

    There seems to have been lots of talk of an impending stock market crash recently. Some people seem to be absolutely certain of it for reasons such as the inverted yield curve, high PE multiples, and the trade war with China. I’ve even heard people talk about the “2020 recession” as if it has already happened.

    Personally, I’m skeptical. I don’t think there is any greater risk of a market downturn today then there was 5 years ago. Everyone knows that the yield curve has inverted and that inversions have historically preceded recessions in the United States. But the expectation of an upcoming recession is already priced into the market.

    Similarly, the risks associated with the Chinese trade war have also been priced in.

    Now I’m not saying that there won’t be a market crash, but I am saying that if there is one the cause will be something that is not currently priced into the market (in other words, something that isn’t receiving 24/7 news coverage).

  • Charlie Munger interview

    I always appreciate Charlie Munger’s bluntness in his interviews. It’s quite the contrast to Warren.

  • Bitcoin is still bad

    So it’s been a while since I last purchased something using Bitcoin and I wanted to see if the process had become any less painful today. I decided that I was going to purchase a $10 item at a shop that accepted Bitcoin.

    I head on over to my Coinbase account and purchase $10 of Bitcoin. Due to fees the amount I actually got was only worth $8. Okay, I buy some more to make it $10, then I try to send the money to the address I was given by the shop. Turns out that Coinbase doesn’t actually let you send Bitcoin to non-Coinbase users anymore unless you wait 12 days after you purchase it. Even if I could send the money, the estimated fee was over $3 (30% of the transaction).

    I ended up paying with PayPal and have asked Coinbase for a refund on my Bitcoin purchases.

  • How to Fix OnePlus 3 Camera Focus

    A few weeks ago my OnePlus 3 camera stopped focusing properly meaning I could no longer take photos of text or scan QR codes. After doing a bit of research on the OnePlus community forums I found that this was likely an issue with the hardware stablization of the camera getting stuck.

    If your stabilizer is stuck you may be able to fix it by just giving your phone a good shake. However, the solution for me was to take a refrigerator magnet and move it over the external camera module several times (you should hear the camera moving back and forth inside).

    If the magnet solution does not work it seems like some people have had success opening their phone and placing a metal object like paperclip or staple next to the camera module. Below is a video I found on YouTube of someone doing so. That said, I believe that opening your phone will void your warranty so if you are near a OnePlus service center I would recommend you give them a visit to see if they can fix your problem first.