James Larisch

CS PhD student, learning by writing

Page 2

The Serial Intern

I worked at HubSpot for 7 months and have currently been working at Gem for almost 6 months. I have yet to graduate.

I, like almost every student at Northeastern University, am a serial intern.

Northeastern, like other co-op schools, sends students to work for 2-3 periods of 6 months within their 5 year stints as a ‘student’. Software engineering work and computer science study blend to perfect synergy. Looking past the mind-numbingly high price-tag of NEU, this medley of experience has been spectacular.

I think everyone should embrace the intern mentality - it’s learning at its purest.


Often the first few months at a job are the most stressful. But they also tend to be absolute catapult-periods in terms of knowledge and skill-acquisition.

You’ll almost certainly be

  • Learning a new style of project-management and process
  • Learning new technologies, languages, and

Continue reading →

Real Life™ + UI programming = FRP (or why Elm is awesome)


A piece of software that requires and reacts to user interaction is akin to a car. I’m no car guy - but when I press on the accelerator, my car’s velocity increases. When I hit the brakes, the brakepad hit my tires and the car begins to slow down.

I imagine slamming the brakes in a car is direct, short trip for the electrical system. When brakes are in ‘slammed’ state, the brakepad are hitting the tires. This makes sense & there’s no mental hurdle to jump to understand it.

In simple terms of input: I as the user am inputting ‘brake’. I get a car that is slowing down. In other words - whenever the brakes are down, the car is slowing down. Whenever the steering wheel is turned to the left, the wheels are turned to the left. It’s tempting to say that my input determines the state of the car, but I don’t think that’s ambitious enough.

The input is the state of the car. They

Continue reading →

Understanding Bitcoin mining & difficulty for fun and no profit

This post is for understanding the particulars of mining a block from the Bitcoin network. It assumes you have read Ken Shirrif’s post on the subject and have a vague understanding of it. If some of the details behind the Python mining simulator seemed a bit rushed, that’s what this post will attempt to ramify.

I will also attempt to make some of the details in the difficulty wiki article a bit more clear, so it’s worth giving that a skim.

Ken posted a small Python program to simulate how mining works here. He doesn’t really go into the details, so I did, and I’d like to share.

I will go through the code line by line, explaining what it does. After that I plan to convert the code to Ruby, using (I think) better naming conventions and function abstraction.

import hashlib, struct

ver = 2
prev_block = "000000000000000117c80378b8da0e33559b5997f2ad55e2f7d18ec1975b9717"
mrkl_root =

Continue reading →

Fix: Including modules on singleton objects in Ruby

Two weeks ago I posted this.

The idea behind adding methods to a single object still hold, but I made a rather egregious error.

I am pulling a row out of the database, (abstracted by ActiveRecord) and then extending that Ruby object with a module to add methods to it.

I was operating under the false assumption that that object, let’s call it x, will persist those methods after dying.

x is pulled out of the database. Methods a and b are added to that object (row). Then, the code moves on, or the user logs out. The data represented by x still exists in the database, but x itself does not. So, those methods get thrown away.

In my example, whenever a Membership was saved, it was extended. But again, that extends becomes useless after that particular object is no longer referenced.

A solution to this, the one I’m taking, is to extend that module whenever the Coinbase membership is

Continue reading →

Including modules on singleton objects in Ruby

Zenchi‘s relational model has the following relationship:

User has_many memberships

A membership is say, a Coinbase account. This model contains the email associated with this account, among other things of that nature.

Separately, we have a Coinbase module, which has a static method refresh_transactions(user) that updates a User’s Coinbase transactions.

This means a user has to have a Coinbase membership and utilize the Coinbase module. When more services like Coinbase come into the picture, we will add a membership and module for each. Could be better.

My thinking - 'why can’t each membership have the same set of methods, defined differently?’

Solution: dynamically include modules based on the type of membership. This way, Coinbase memberships and Bitstamp memberships will have a different set of methods.

Like so -

class Membership < ActiveRecord::Base


Continue reading →


#include stdio.h
char *copy_string(char *source, char *destination) {
  int *start = destination;
  while (*source != '\0') {
    *destination++ = *source++;
  *destination = '\0';
  return start;

int main() {
  char a[9] = "hello";
  char b[9];
  char *pA = a;
  char *pB = b;
  copy_string(a, b);
  return 0;

Pointers. int x = 12; allocates a block of memory (4 bytes for 32, 8 bytes for 64 bit OSes) and then 12 is placed into that block of memory. If you then do int y = x;, you have taken the value of x, which is 12, and then placed that value also in the allocation for y.

However — I don’t know if this is only because integers are constants - I don’t think this would be the same for objects.

&x is the memory address that the x block exists under. Addresses are stored in “pointer types”. I thought that all things storing addresses should be integers, but that doesn’t seem

Continue reading →