Ember.Handlebars.registerBoundHelper('markdown', function (content) { | |
return new Handlebars.SafeString(markdown.toHTML(content)); | |
}); |
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)) |
Solution to https://twitter.com/nolanlawson/status/578948854411878400.
doSomething().then(function () {
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.
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
'use strict'; | |
var request = require('supertest'); | |
var jsdom = require('jsdom'); | |
var app = require('../../app'); | |
describe('account middleware', () => { | |
var server; |
// Add a 401 response interceptor | |
window.axios.interceptors.response.use(function (response) { | |
return response; | |
}, function (error) { | |
if (401 === error.response.status) { | |
swal({ | |
title: "Session Expired", | |
text: "Your session has expired. Would you like to be redirected to the login page?", | |
type: "warning", | |
showCancelButton: true, |