Skip to content

Instantly share code, notes, and snippets.

View horaciosystem's full-sized avatar
🏠
Working from home

Horacio Alexandre Fernandes horaciosystem

🏠
Working from home
View GitHub Profile

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

@nolanlawson
nolanlawson / promises_answer_sheet.md
Last active July 26, 2022 08:02
Promises puzzle cheat sheet
defmodule Stuff do
def inlist([search_item|_tail], search_item), do: true
def inlist([_head|tail], search_item) , do: inlist(tail, search_item)
def inlist([], _), do: false
end
IO.inspect(Stuff.inlist([1,2,3],1))
@pbojinov
pbojinov / README.md
Last active June 27, 2025 05:25
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@kevin-smets
kevin-smets / iterm2-solarized.md
Last active August 17, 2025 14:25
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@gyllstromk
gyllstromk / ember_handlebars_markdown_helper.js
Last active April 13, 2023 19:33
Render markdown as HTML in Ember via `registerBoundHelper`. This example uses https://github.com/evilstreak/markdown-js.
Ember.Handlebars.registerBoundHelper('markdown', function (content) {
return new Handlebars.SafeString(markdown.toHTML(content));
});