Susan Potter

Snippets

snippets

JavaScript Performance: Node CLI flags

These are some notes on performance engineering related to generating insights into Node.js (v8) performance. All material here is specific to the v8 engine found in Node.js, Chrome, and Opera. Generally useful things to learn to tune JavaScript (for the v8 engine) is natives …

snippets

Socket Statistics on Linux with ss

An excellent tool when you need to troubleshoot distributed systems is ss, which provides visibility into TCP states of your live connections. Even if you know netstat this is a command you should get acquainted with because of its more powerful interface which requires fewer …

snippets

Profunctor exploration in less than 100 lines of Haskell

A snippet showing the space around profunctors in Haskell (e.g. Strong, Choice, Cartesian).

snippets

Decoding lens operators

Notation conventions The following table provides a quick overview of conventions used in symbolic operators in the lens library. Symbol Concept Denotes ^ getter gets value from structure ~ setter sets values in structure % over apply transformation over selected …

snippets

Ruby 2.4 changes overview

Unified Fixnum and Bignum into Integer It’s backward compatible too. $ irb irb(main):001:0> RUBY_VERSION => "2.3.1" irb(main):002:0> (2**100).class => Bignum irb(main):003:0> 2.class => Fixnum irb(main):004:0> Fixnum => Fixnum …

snippets

Nix in your home directory

Prerequisites wget is installed tar is installed Purpose If you really don't want to install Nix under /nix (or you can't) then you can install Nix in your home directory like in the homedir_install.sh script included in this Gist. Now whenever you want to run …

snippets

Scala WTFs

Small sample of Scala WTFs circa 2014 (many taken from Paul Phillips talks on the Scala Collections library): scala> List("a", "b", "c").toSet // the only reasonable line of code in here res1: scala.collection.immutable.Set[String] = Set(a, b, c) …

snippets

OSX Lion (10.7.4) work laptop setup

Homebrew Install after the command-line tools for Xcode. tmux erlang haskell-platform zsh git figlet scala sbt rbenv ruby-build s3cmd pit brew install tmux erlang haskell-platform zsh \ git figlet scala sbt rbenv ruby-build s3cmd pit RubyGems …

snippets

Erlang OTP Glossary

I am hoping this will serve as a reference for coworkers and others new to Erlang and OTP to be able to figure out the terminology easier than I had to. I learned the hard way, so you don't have to!:) Erlang/OTP - The set of libraries and conventions that are used as part …

snippets

Erlang Meck API notes

Notes on using Meck API (a mocking library in Erlang) which are not well documented. % Will create a fully mocked version of existing_module until caller crashes meck:new(ExistingModule). % Will create a fully mocked version of existing_module even after caller crashes …

snippets

Custom Security Handler Nitrogen

An example of a custom security handler implementation for Nitrogen 2.x. customer_security_handler.erl %%% HEADER %%% @author Susan Potter <me@susanpotter.net> %%% @date 2011-02-16T17:08 %%% @license BSD %%% @doc Example of a security_handler behavior implementation …

snippets

Predicate Algebra in Python

Updated for Python3 recently: class Predicate: """ Define predicate algebra. >>> isEven=Predicate(lambda x: x % 2 == 0) >>> isOdd=Predicate(lambda x: x % 2 == 1) >>> isEven(6) True >>> isOdd(6) False >>> …

snippets

My .gitconfig & .tigrc files

[user] name = Susan Potter # make sure you change this email = me@susanpotter.net # make sure you change this [color] diff = auto status = auto branch = auto [diff] rename = copy color = auto [apply] whitespace = strip [pager] color = true [status] color = auto [branch] …

snippets

Ruby Idioms, Part 7

This idiom I have seen a little more in Rails than I have seen in Ruby, but I am putting it in this Ruby Idioms series anyway. First off, most of you will know by know that you can "transparently" provide a method in Ruby a Hash. What do I mean by …

snippets

Ruby Idioms, Part 6

Tonight I remembered couple more idioms in Ruby and felt compelled to share. In Javafied Ruby code (below) we often see something like the following: if something for role in user.roles return true if @@roles.include? role end end Now when I first started writing Ruby code …

snippets

Ruby Idioms, Part 5

Some of you may say this isn't strictly an idiom, but it is dependent on Ruby's core API and classes, so I have included it. Ranges are a very nice low-level abstraction and can save Ruby developers a lot of time for certain coding needs. In a previous idiom example on …

snippets

Ruby Idioms, Part 4

To splat or not to splat, that is the question. In Java to unpack an array's values into separate variables you would need to do something like the following: burgers = [:hamburger, :bocaburger, :gardenburger, :turkeyburger] t = burgers[0] u = burgers[1] v = burgers[2] w = …

snippets

Ruby Idioms, Part 3

Now, probably the biggest difference after the syntax, and the non-static nature of Ruby for Java heads to get used to is that Ruby is an "expressionist" language. Meaning almost all statements in Ruby evaluates to a value, i.e. everything that reasonably can be is an …

snippets

Ruby Idioms, Part 2

Now the "idiom" we will use is not specific to Ruby, since I am pretty sure Perl has one of the constructs we will use to solve the stated problem, but it is still idiomatic, since the majority of popular OO languages (static, dynamic or otherwise) do not have it (as far …

snippets

Ruby Idioms, Part 1

With more people moving to Ruby everyday from languages like Java, I wanted to create blog entries on the most common Ruby idioms (especially ones frequently found in Rails core or Rails application code) and briefly explain how to convert your Java mindset to Ruby (over time). …

snippets

Rubyisms: reopening classes

Ever wished you could write code in a very expressive way like the following examples? expiration_date = 3.years.from_now birth_date = 32.years.ago Now you can, in Ruby at least. Two years ago I was a very happy Python developer that thought no other language could compete …

snippets

Rubyisms: naming conventions

Today I wanted to show the implicit and explicit naming conventions in Ruby for newbies. It isn't particularly consistent with another language's conventions, so could cause confusion when reading the Ruby Standard Library (RSL). Where appropriate I also discuss how some …

snippets

Rubyisms: forwardables

Recently some Java friends of mine have decided to taste the juicier fruits in Ruby-land with my assistance. So below are some excerpts from an email conversation I had with one about Ruby's standard library forwardable features: Suppose we have the following model classes …