Skip to content

Instantly share code, notes, and snippets.

View feargswalsh92's full-sized avatar

Feargal Walsh feargswalsh92

View GitHub Profile
@feargswalsh92
feargswalsh92 / EventEmitter.js
Created January 17, 2020 00:54
Implementation of node.js Event Emitter class for Pramp Interview question
class EventEmitter {
constructor(event) {
this._events = {};
}
on = (event, listener) => {
if (typeof listener === "function") {
this._events[event] = [];
this._events[event].push(listener);
} else {

10 Scala One Liners to Impress Your Friends

Here are 10 one-liners which show the power of scala programming, impress your friends and woo women; ok, maybe not. However, these one liners are a good set of examples using functional programming and scala syntax you may not be familiar with. I feel there is no better way to learn than to see real examples.

Updated: June 17, 2011 - I'm amazed at the popularity of this post, glad everyone enjoyed it and to see it duplicated across so many languages. I've included some of the suggestions to shorten up some of my scala examples. Some I intentionally left longer as a way for explaining / understanding what the functions were doing, not necessarily to produce the shortest possible code; so I'll include both.

1. Multiple Each Item in a List by 2

The map function takes each element in the list and applies it to the corresponding function. In this example, we take each element and multiply it by 2. This will return a list of equivalent size, compare to o

@k0emt
k0emt / Experiment.py
Last active June 11, 2023 15:41
Basic Hello world in Python with corresponding unittest
__author__ = 'k0emt'
class Greeter:
def __init__(self):
self.message = 'Hello world'
# print self.message