Hugo: Static Site Generator written in Go

Hugo masthead from website

I like simplicity, and nothing says simple like a plain, old, static HTML website. Static websites have some real advantages: they are generally pretty secure, they play nice with whatever source control system you use, and they are fast. A static site generator gives you those advantages plus some niceties like templating and asset reuse.

One of the most interesting things about Hugo is that since it runs on the Go language runtime, you can drop the package on your system of choice and go.

From the website:

Hugo doesn’t depend on administrative privileges, databases, runtimes, interpreters or external libraries. Sites built with Hugo can be deployed
on S3, Github Pages, Dropbox or any web host.

Organize your content however you want with any URL structure. Declare your own content types. Define your own meta data in YAML, TOML or JSON.
Use indexes to group your content however you want.

The next time I build a static site, I’ll definitely give Hugo a look. I found out about this tool from Web Appers.

Hazelcast: Java Open Source In-Memory Data Grid

Hazelcast logo

At work, we’re currently using the open source version of ehcache in our apps. In our next software stack refresh we’ve talked about investigating a distributed caching framework. I think that Hazelcast might be a contender. I like that it allows you to store date in simple Lists, Sets, Maps, and Queues and handles the distributed part for you. The question we’ll need to answer at work is “how tunable is Hazelcast?”

From the website:

  • Distributed java.util.{Queue, Set, List, Map}
  • Distributed java.util.concurrency.locks.Lock
  • Distributed java.util.concurrent.ExecutorService
  • Distributed MultiMap for one to many mapping
  • Distributed Topic for publish/subscribe messaging
  • Distributed Indexing and Query support
  • Transaction support and J2EE container integration via JCA
  • Socket level encryption for secure clusters
  • Write-Through and Write-Behind persistence for maps
  • Java Client for accessing the cluster remotely
  • Dynamic HTTP session clustering
  • Support for cluster info and membership events
  • Dynamic discovery
  • Dynamic scaling
  • Dynamic partitioning with backups
  • Dynamic fail-over
  • Web-based cluster monitoring tool

Here are some code snippets from the website:

Map

import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;

import java.util.concurrent.ConcurrentMap;

public class DistributedMap {
    public static void main(String[] args) {
        Config config = new Config();
        HazelcastInstance h = Hazelcast.newHazelcastInstance(config);
        ConcurrentMap<String, String> map = h.getMap("my-distributed-map");
        map.put("key", "value");
        map.get("key");
        //Concurrent Map methods
        map.putIfAbsent("somekey", "somevalue");
        map.replace("key", "value", "newvalue");
    }
}

MultiMap

import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.MultiMap;

import java.util.Collection;

public class DistributedMultiMap {
    public static void main(String[] args) {
        Config config = new Config();
        HazelcastInstance h = Hazelcast.newHazelcastInstance(config);
        MultiMap<String, String> multiMap = h.getMultiMap("my-distributed-multimap");
        multiMap.put("key", "value1");
        multiMap.put("key", "value2");
        multiMap.put("key", "value3");

        Collection<String> values = multiMap.get("key");

        // remove specific key/value pair
        multiMap.remove("key", "value2");
    }
}

Queue

import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

public class DistributedQueue {
    public static void main(String[] args) throws InterruptedException {
        Config config = new Config();
        HazelcastInstance h = Hazelcast.newHazelcastInstance(config);
        BlockingQueue<String> queue = h.getQueue("my-distributed-queue");
        queue.offer("item");
        String item = queue.poll();

        //Timed blocking Operations
        queue.offer("anotheritem", 500, TimeUnit.MILLISECONDS);
        String anotherItem = queue.poll(5, TimeUnit.SECONDS);

        //Indefinitely blocking Operations
        queue.put("yetanotheritem");
        String yetanother = queue.take();
    }
}  

Topic

import com.hazelcast.config.Config;
import com.hazelcast.core.*;

public class DistributedTopic implements MessageListener<String> {
     public static void main(String[] args) {
         Config config = new Config();
         HazelcastInstance h = Hazelcast.newHazelcastInstance(config);
         ITopic<String> topic = h.getTopic("my-distributed-topic");
         topic.addMessageListener(new DistributedTopic());
         topic.publish("Hello to distributed world");
     }

     @Override
     public void onMessage(Message<String> message) {
         System.out.println("Got message " + message.getMessageObject());
     }
}

Lock

import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;

import java.util.concurrent.locks.Lock;

public class DistributedLock {

    public static void main(String[] args) {
        Config config = new Config();
        HazelcastInstance h = Hazelcast.newHazelcastInstance(config);
        Lock lock = h.getLock("my-distributed-lock");
        lock.lock();
        try {
            //do something here
        } finally {
            lock.unlock();
        }
    }
}

Executor Service

import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IExecutorService;
import com.hazelcast.core.Member;
import java.io.Serializable;

public class DistributedExecutorService {
    public static void main(String[] args) {
        Config config = new Config();
        HazelcastInstance h = Hazelcast.newHazelcastInstance(config);
        IExecutorService ex = h.getExecutorService("my-distributed-executor");
        ex.submit(new MessagePrinter("message to any node"));
        Member firstMember = h.getCluster().getMembers().iterator().next();
        ex.executeOnMember(new MessagePrinter("message to very first member of the cluster"), firstMember);
        ex.executeOnAllMembers(new MessagePrinter("message to all members in the cluster"));
        ex.executeOnKeyOwner(new MessagePrinter("message to the member that owns the following key"), "key");
    }

    static class MessagePrinter implements Runnable, Serializable {
        final String message;

        MessagePrinter(String message) {
            this.message = message;
        }

        @Override
        public void run() {
            System.out.println(message);
        }
    }
}

ØMQ (AKA zeromq): Open-source async socket/messaging library & concurrency framework with support for 40+ languages & most OSes

zeromq logo

I found out about this project while listening to a FLOSS Weekly episode on SaltStack.

From the website:

  • The socket library that acts as a concurrency framework.
  • Carries messages across inproc, IPC, TCP, and multicast.
  • Connect N-to-N via fanout, pubsub, pipeline, request-reply.
  • Asynch I/O for scalable multicore message-passing apps.
  • Large and active open source community.
  • 40+ languages including C, C++, Java, .NET, Python.
  • Most OSes including Linux, Windows, OS X.
  • Free software with full commercial support.

Check out the Learn the Basics page. There’s some good stuff there.

SQLAlchemy: Python SQL Toolkit and Object Relational Mapper

SQLAlchemy masthead from site

SQLAlchemy looks cool enough to make me go hunting for a Java equivalent for use on projects at work.

Take a look at the features page. I’m particularly interested in the Unit Of Work

The Unit Of Work system, a central part of SQLAlchemy’s Object Relational Mapper (ORM), organizes pending insert/update/delete operations into
queues and flushes them all in one batch. To accomplish this it performs a topological “dependency sort” of all modified items in the queue so as
to honor inter-row dependencies, and groups redundant statements together where they can sometimes be batched even further. This produces the
maximum efficiency and transaction safety, and minimizes chances of deadlocks. Modeled after Fowler’s “Unit of Work” pattern as well as
Hibernate, Java’s leading object-relational mapper.

…and Raw SQL statement mapping

SQLA’s object relational query facilities can accommodate raw SQL statements as well as plain result sets, and object instances can be generated
from these results in the same manner as any other ORM operation. Any hyper-optimized query that you or your DBA can cook up, you can run in
SQLAlchemy, and as long as it returns the expected columns within a rowset, you can get your objects from it. Statements which represent multiple
kinds of objects can be used as well, with results received as named-tuples, or with dependent objects routed into collections on parent objects.

SQLAlchemy supports…

…dialects for SQLite, Postgresql, MySQL, Oracle, MS-SQL, Firebird, Sybase and others, most of which support multiple DBAPIs. Other dialects are
published as external projects. The corresponding DB-API 2.0 implementation (or sometimes one of several available) is required to use each
particular database. View Current DBAPI Support.

Bruce Eckel is a Java guy I respect. He wrote Thinking in Java and he said this about SQLAlchemy:

SQLAlchemy is a pretty amazing design…In SQLAlchemy, you need to explicitly start a session. What’s amazing is that all the changes you make
during that session are kept in some kind of parse tree, and then when the session ends SQL is created on-the-fly to produce a single, optimal
SQL statement for that particular sequence of changes. I found this idea pretty mind-blowing.

That sounds pretty sexy to me.

tmux: Open Source terminal multiplexer

From the tmux website:

tmux lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a
different terminal.

tmux is intended to be a simple, modern, BSD-licensed alternative to programs such as GNU screen.

This release runs on OpenBSD, FreeBSD, NetBSD, Linux and OS X and may still
run on Solaris and AIX (although they haven’t been tested in a while).

Ack: grep-like tool written in Perl for searching source code from the command line

Ack logo

I use this all the time at work. I get people asking me all the time, “How do you get your grep results to look like that?”

From the ack website (via http://kkovacs.eu/):

  • Blazing fast: It’s fast because it only searches the stuff it makes sense
    to search.
  • Better search: Searches entire trees by default while ignoring Subversion,
    Git and other VCS directories and other files that aren’t your source code.
  • Designed for code search: Where grep is a general text search tool, ack
    is especially for the programmer searching source code. Common tasks take
    fewer keystrokes.
  • Highly portable: ack is pure Perl, so it easily runs on a Windows
    installation Perl (like Strawberry Perl) without modifications.
  • Free and open: Ack costs nothing. It’s 100% free and open source under
    Artistic License v2.0.

Ack screenshot

Dart: Google-backed programming language built to address issues in JavaScript

Dart Logo

I have to admit that this project pushes all of the right buttons for me. It looks like a fully structured language. It allows the use of types which opens the door for good tool support. It compiles down to JavaScript, so it will run in any browser. It can run on the server. Inheritance, generitc, isolates, annotations… I’m looking forward to building something in Dart.

From Wikipedia:

Dart is an open-source Web programming language developed by Google.

The goal of Dart is “ultimately to replace JavaScript as the lingua franca of web development on the open web platform”, but Dart currently relies
exclusively on its cross-compilation to JavaScript feature in order to run in mainstream browsers. Dart is intended to address issues with
JavaScript that Google engineers felt could not be solved by evolving the language, while offering better performance. Google works on Dart to help
it build more complex, full-featured client-side Web applications.
Dart is a class-based, single inheritance, object-oriented language with C-style syntax. It supports interfaces, abstract classes, reified
generics, and optional typing. Static type annotations do not affect the runtime semantics of the code. Instead, the type annotations can provide
documentation for tools like static checkers and dynamic run time checks.

From the Dart: Up and Running book on the Dart website:

Dart is easy to learn. A wide range of developers can learn Dart quickly. It’s an object-oriented language with classes, single inheritance,
lexical scope, top-level functions, and a familiar syntax. Most developers are up and running with Dart in just a few hours.

Dart compiles to JavaScript. Dart has been designed from the start to compile to JavaScript, so that Dart apps can run across the entire
modern web. Every feature considered for the language must somehow be translated to performant and logical JavaScript before it is added. Dart
draws a line in the sand and doesn’t support older, legacy browsers.

Dart runs in the client and on the server. The Dart virtual machine (VM) can be integrated into a web browser, but it can also run standalone
on the command line. With built-in library support for files, directories, sockets, and even web servers, you can use Dart for full end-to-end
apps.

Dart comes with a lightweight editor. You can use Dart Editor to write, launch, and debug Dart apps. The editor can help you with code
completion, detecting potential bugs, debugging both command-line and web apps, and even refactoring. Dart Editor isn’t required for writing
Dart; it’s just a tool that can help you write better code faster.

Dart supports types, without requiring them. You can omit types when you want to move very quickly, aren’t sure what structure to take, or
simply want to express something you can’t with the type system. You can add types as your program matures, the structure becomes more evident,
and more developers join the project. Dart’s optional types are static type annotations that act as documentation, clearly expressing your
intent. Using types means that fewer comments are required to document the code, and tools can give better warnings and error messages.

Dart scales from small scripts to large, complex apps. Web development is very much an iterative process. With the reload button acting as
your compiler, building the seed of a web app is often a fun experience of writing a few functions just to experiment. As the idea grows, you can
add more code and structure. Thanks to Dart’s support for top-level functions, optional types, classes, and libraries, your Dart programs can
start small and grow over time. Tools such as Dart Editor help you refactor and navigate your code as it evolves.

Dart has a wide array of built-in libraries. The core library supports built-in types and other fundamental features such as collections,
dates, and regular expressions. Web apps can use the HTML library—think DOM programming, but optimized for Dart. Command-line apps can use the
I/O library to work with files, directories, sockets, and servers. Other libraries include URI, UTF, Crypto, Math, and Unit test.

Dart supports safe, simple concurrency with isolates. Traditional shared-memory threads are difficult to debug and can lead to deadlocks.
Dart’s isolates, inspired by Erlang, provide an easier to understand model for running isolated, but concurrent, portions of your code. Spawning
new isolates is cheap and fast, and no state is shared.

Dart supports code sharing. Traditional web programming workflows can’t integrate third-party libraries from arbitrary sources or frameworks.
With the Dart package manager (pub) and language features such as libraries, you can easily discover, install, and integrate code from across the
web and enterprise.

Dart is open source. Dart was born for the web, and it’s available under a BSD-style license. You can find the project’s issue tracker and
source repository online. Maybe you’ll submit the next patch?

Web Appers: One of my go to sites for web development resources

Weappers screenshot

Web Appers is one of the sites I visit regularly to learn about new web development tools and resources.

The website says:

WebAppers is a blog dedicated to share top quality open source resources for web developer and web designer daily. As a web designer, you’ll find
some of the best free icons, stock photos, brushes, fonts and design inspirations. As a web developer, you’ll also find some of the best Javascript
and Ajax components like modal windows, menus, galleries, tooltips, charts, calendars plugins and a lot more …

Elixir: functional language built on the Erlang VM

Elixir logo

From the Elixir website (via Tim Bray’s blog) :

Elixir is a functional, meta-programming aware language built on top of the
Erlang VM. It is a dynamic language with flexible syntax and macro support that
leverages Erlang’s abilities to build concurrent, distributed and fault-tolerant
applications with hot code upgrades.

Elixir also provides first-class support for pattern matching, polymorphism via
protocols (similar to Clojure’s), aliases and associative data structures
(usually known as dicts or hashes in other programming languages).

Finally, Elixir and Erlang share the same bytecode and data types. This means
you can invoke Erlang code from Elixir (and vice-versa) without any conversion
or performance hit. This allows a developer to mix the expressiveness of Elixir
with the robustness and performance of Erlang.