Instantly share code, notes, and snippets.

View each.js
function Each(obj, fn) {
if (obj.length) for (var i = 0, ol = obj.length, v = obj[0]; i < ol && fn(v, i) !== false; v = obj[++i]);
else for (var p in obj) if (fn(obj[p], p) === false) break;
}
View elixir_logger.ex
require Logger
Logger.info "path: " <> inspect(conn.params["paths"])
View make_fake.exs
SampleElixirEctoSelect.Repo.start_link
alias SampleElixirEctoSelect.RssFeed
Enum.map 0..99,
fn _ ->
params = %{
feed_url: Faker.Internet.url,
title: Faker.Commerce.product_name,
subtitle: Faker.Company.bs,
View js_log.js
console.debug("%O", obj)
View ecto_gen_migration.ex
mix ecto.gen.migration add_posts_table
View phoenix auth model
mix phoenix.gen.json UserAuth user_auths email:string encrypted_password:string password:string type:string
View elixir_google_place.ex
defmodule GooglePlaces do
@moduledoc false
# https://developers.google.com/places/web-service/?hl=ja
use HTTPoison.Base
#require Logger
@text_search "/textsearch/json?key=<api key>"
View actions.js
mport {createAction} from 'redux-actions'
import {METHOD_GET, METHOD_POST, METHOD_PUT, createApiMeta} from '../../../common/js/actions/helpers/api';
export const aaaGet = createAction('AAA_GET',
() => ( null ),
(id) => createApiMeta(`/api/company_branches/${id}`, null, METHOD_GET));
View rails g
# model
rails g model Company --no-migration -t rspec
# controller (page)
rails g controller Rules -t rspec
# scaffold
rails generate scaffold Plan -t rspec