Some of the most important advancements in programming came from adding restrictions to the way we program.
Famous article by Edsger Dijkstra Go To Statement Considered Harmful
shows how introducing one statement into programming language breaks many nice properties of that language.
goto gives us freedom and solves couple of simple problems like breaking from nested loops easily,
but it can make programs very hard to understand.
This happens, because we cannot look at two pieces of code in separation.
The execution can jump to some other place in code or even worse: it can jump from other piece of code to here and We need to keep that in mind.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .windows { | |
| /* looking good: Roboto */ | |
| font-family: "Work Sans" !important; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; -*- mode: emacs-lisp; lexical-binding: t -*- | |
| ;; This file is loaded by Spacemacs at startup. | |
| ;; It must be stored in your home directory. | |
| (defun dotspacemacs/layers () | |
| "Layer configuration: | |
| This function should only modify configuration layer settings." | |
| (setq-default | |
| ;; Base distribution to use. This is a layer contained in the directory | |
| ;; `+distribution'. For now available distributions are `spacemacs-base' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule App.Implementations do | |
| def of(key) do | |
| with impls when is_list(impls) <- Application.get_env(:app, :impls), | |
| {:ok, module} <- Keyword.fetch(impls, key) do | |
| module | |
| else | |
| :error -> | |
| raise KeyError, | |
| message: """ | |
| :#{key} key is not defined in the implementations for application :app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Project.ActiveUsers do | |
| @behaviour Project.UseCase | |
| def run(params, deps) do | |
| deps[:repo].fetch_users(params) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Event do | |
| @type t() :: %__MODULE__{date: Date.t(), title: String.t(), content: String.t()} | |
| defstruct :date, :title, :content | |
| def group(events) do | |
| events | |
| |> Enum.group_by(fn event -> envent.date) | |
| |> Map.to_list() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const path = require('path'); | |
| const glob = require('glob'); | |
| const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | |
| const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); | |
| const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); | |
| const CopyWebpackPlugin = require('copy-webpack-plugin'); | |
| const paths = { | |
| static: path.join(__dirname, "../priv/static"), | |
| build: path.join(__dirname, "../priv/static"), | |
| node_modules: path.join(__dirname, "./node_modules"), |
- Create file on
.templatesfolder at user home:mkdir ~/.templates/elixir && touch ~/.templates/elixir/module - Contents:
defmodule {{mod}} do
endUsage: bob -tpl elixir/module -d ./person.ex -v mod=Person
Templates are based on handlebars rendered by aymerick/raymond
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | |
| const devMode = process.env.NODE_ENV !== 'production' | |
| module.exports = { | |
| entry: './src/main/resources/assets/js/index.js', | |
| output: { | |
| filename: './js/index.js', | |
| path: __dirname + '/src/main/resources/static/' | |
| }, | |
| module: { |