Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
from datetime import datetime as dt
from datetime import timedelta as td
from calendar import monthrange
import calendar
def make_bar(r):
return (int(round(r/10))*"*").ljust(10,'O')

What's this?

I wanted a reference which covered a small piece of rust to help people get over one piece of the learning curve! What was that piece? How to call functions and return stuff. I know it sounds a little absurd to have to write a tutorial on how to call and return, but rust makes it a little more challenging than other languages in order to be as neato-keen as it is.

This tutorial assumes that you've probably already learned another programming language and can guess at the functionality of some of these snippets (or that you've looked at some other, more complete rust tutorials).

Calling functions

Can't touch this

By default, variables are immutable in rust. So the following is an error (run it):

fn main() {
@jconwell
jconwell / akkaTestPatterns.md
Last active September 22, 2016 17:13
Unit and functional test patterns for Akka actors in Java

AKKA Test Patterns for Java

NOTE: These patterns assume you have a working understanding of Akka's JavaTestKit

Testing Actors In Complete Isolation

AKKA is all about building hierarchies of actors to represent a system. I've found this is a great way to decompose, design, and if needed distribute a system. This means your system becomes a hierarchy of actors, where parent actors create and manage their child actors, and child actors either carry out some unit of work, and/or themselves become parent actors.

But this can be a bit of a pain when it comes to writing tests for your actors. For example, say we have an actor, actorA, who in turn creates one or more child actors. I could have actorA create its child actor(s) as part of its instantiation. This is attractive especially if I know the exact child actors its going to create.