View 0-media-query-snippets.md

Media query snippets

Type b4+ then press TAB. It expands to

@media (min-width: $screen-xs-min) { // > 480px

Snippets

View family-tree.md

family-tree

Writing a family tree

Let's start with families. Every family can have parents and children.

+families:
+  - parents: [Marge, Homer]
+    children: [Bart, Lisa, Maggie]
View vim powerlevelling.md

Text objects

vip - select IN paragraph
vap - select AROUND paragraph

also: ( [ ' " t

% - go to opening/closing ( or [ or <tag>
View µredux.js
var INIT = '@redux/INIT'
function createStore (reducer, state, enhancer) {
if (enhancer) return enhancer(createStore)(reducer, state)
var subscribers = []
dispatch({ type: INIT })
return {
View bundle-js.md

bundle-js

Batteries-included, minimal-configuration JS bundler

A hypothetical JavaScript bundler. bundle-js aims to be your one-stop-shop for everything in the JS frontend. Goals:

  • Batteries-included: you should be able to use bundle-js without any plugins or any fancy configuration.
  • Convention over configuration: there should be little need to configure bundle-js.
  • One dependency: no more dealing with webpack, loaders, babel, babel presets, babel plugins, and so on!
  • Extensible: it should still be possible to extend functionality if necessary.
View slug_generator.ex
defmodule SlugGenerator do
@moduledoc """
Generates random slugs.
def changeset(model, params \\ %{}) do
model
|> cast(params, @fields)
|> SlugGenerator.generate_slug(Article, :slug, to_slug(changeset))
end
View debugger.eex
primary = "#EB532D"
logo_uri = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJEAAABjCAYAAACbguIxAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAHThJREFUeAHtPWlgVOW197vbLNkTFoFQlixAwpIVQZ8ooE+tRaBWdoK4VF5tfe2r1tb2ta611r6n9b1Xd4GETRGxIuJSoKACAlkIkD0hsiRoIHtmues7J3LpOJ2Z3Jm5yUxi5s+991vOOd+5Z777fWf7CGXA79Ct46ZGmyPnshw9WaX5qTSlJBCKjqU51aoohKVUivaIRqUUmlactEK3iCp1gablTztsnZ9kbK16w2P7wcKw5AAJhKqiBWlzIyIjVrKsnKtQ7HiiqiaGZQOC5Qm/JAkiUekqSha2X7/x2JP1FOXw1G6wLDw4oPvFl94+ZVmkib9HJnQuy7MRfUW+qoqSLMtHWi60PzB9Z+2BvsI7iEc/B3wK0d8Wjk8dHRX7B5hjbqBZU6R+sMa3VBWFUiSxqLmhdc303XVHjMcwCDFQDngUosO3JF0VPzz2eSKRLJrjPLbxhVARYYXDUCKlKAJFMV00yw731d6fOlWVKadT/mjSxsIb/ek32Lb3OPANAdl/c3La8CExmziGnUYYz2thd1JwhpBk5RDDyBccTuWgKNpqWxzCsdk76iuwbdXiyd/nIqO2ufcL9lmVBZvgcP5k4pYTrwcLa7B/cBy4LESVeVlvsxS9wN+ZR1Jkioi2B5M3nPiTJ1LqVuXaCcuaPdUZUSbJjg9T1hXfZASsQRiBcYDULJ/2OM1zDxOa0zf1eMFDROmcQ5Jeam7peE+iKOfQ+IjFHM//gqF7T4A0UhD3dflHkusHd3EaS/r0SupWZO+lCHWFwislio2Kpi30cKKQZEKYGEL7L1e4ZqFkRSWs/2upYEauSpKjpblldvaOmkPBwBns6z8HLn/O3Lsenjs+N2pU7G94hr6JpjnevT4cn0
View sum via stream and enum.ex
defmodule Summer do
def sum_of_threes_and_fives(n) do
0..n
|> Stream.filter(&multiple_of_3_or_5?/1)
|> Enum.reduce(&Kernel.+/2)
end
def multiple_of_3_or_5?(n) do
rem(n, 5) == 0 || rem(n, 3) == 0
end
View sum via recursion.ex
defmodule Summer do
def sum_of_threes_and_fives(n) when n <= 0 do
0
end
def sum_of_threes_and_fives(n) when rem(n, 5) == 0 or rem(n, 3) == 0 do
n + sum_of_threes_and_fives(n - 1)
end
def sum_of_threes_and_fives(n) do
View _example.js
getArticles()
.then(condition({
if: (data) => data.length > 10,
then: p => p
.then(paginateArticles),
else: p => p
.then(sortArticles)
})