If you’re viewing files from your local computer in a web browser, their URL will appear with a "file:///" prefix instead of the usual "https://" that you might normally see.

Sometimes browsers give different privileges and treatment to files if they’re local or on a web server. If you need to test a local file out as if it were on a web server.

You can set up a local testing server by following the instructions in these Mozilla docs.

The short version of that is:

  1. open up the terminal or command prompt
  2. navigate to the directory where the files live
  3. run a local python server by running:

    python3 -m http.server 1234

  4. Go to http://localhost:1234/ in your browser and navigate to or type into the address bar the file you’re trying to open

If you run into issues, the Mozilla reference is more comprehensive and should sort things out.

21 March 2018

Space Creatures

Since January, I have been at Recurse Center. I like to refer to it as a self-directed coding retreat. I’m really loving it. As is seen on this blog, I really enjoy jumping into side projects and building fun things. This space is great for it as it gives me a wonderful environment to work in, and also the added benefit of being around interesting people who are also working on interesting things. It feels part academic, part co-working space, part art studio, and part social experiment.

I can talk more on RC, but I figured today I would share the project I built when I applied. There were many prompts to choose from, and I chose one that asked to implement your own version of Space Invaders. I called it Space Creatures!

After going through the initial application and sharing it, I worked on it for an extra day, because I was having fun piecing it together. I built it from scratch, using no libraries (as the prompt requested limiting usage of other libraries). My favorite parts were the sounds and explosion animations. In trying to get the right easing on my animations, To point out one random part, I had fun resorting to high school math and plotting ideas on the built-in Grapher tool on my Mac:

 _fade_out_exp(frac) {
  // frac - float - 0 to 1
  // exponential fade-out: y = (2 - 2^(1 - 6x)) / 2
  return (2 - Math.pow(2, 1 - 6 * frac)) / 2;

Space creatures easing function graph

This was the first project on which I used Prettier. I also went on a fun tangent reading about Symbols and realizing that my initial intuition on how I wanted to use them as enums isn’t exactly what they’re really meant for.

Space Creatures links:

Space Creatures game

A simple one-liner with ffmpeg to convert a Quicktime MOV file to MP4. read full post…
Various of examples of how errors and rejects bubble up (or not) with JavaScript Promises. read full post…

21 December 2017

An abacus in a pile of toys

I recently chanced across an abacus and finally learned how they work. It turns out it’s a really cool tool and I think it’s useful for all math students to learn! read full post…

Peter Coles

Peter Coles

is a software engineer who lives in NYC, works at Ringly, and blogs here.
More about Peter »

github · soundcloud · @lethys · rss

It’s time to get big money out of politics. Join the kick-started campaign to put government back in the hands of the people. Pledge mayday.us now