Skip to content

Instantly share code, notes, and snippets.

defmodule EctoSlugs.Repo.Migrations.CreateEctoSlugs.Blog.Article do
use Ecto.Migration
def change do
alter table(:blog_articles) do
add :slug, :string
end
create unique_index(:blog_articles, [:slug]) # should be unique
end
defmodule EctoSlugs.Blog.Article.TitleSlug do
use EctoAutoslugField.Slug, from: :title, to: :slug
end
defmodule EctoSlugs.Blog.Article.TitleSlug do
use EctoAutoslugField.Slug, to: :slug
import Ecto.Changeset
def get_sources(changeset, _opts) do
# This function is used to get sources to build slug from:
base_fields = [:title]
if get_change(changeset, :breaking, false) do
defmodule EctoSlugs.Blog.Article.TitleSlug do
use EctoAutoslugField.Slug, from: :title, to: :slug
def build_slug(sources, _changeset) do
sources
|> super()
|> String.replace("-", "+")
end
end
@sobolevn
sobolevn / Pipfile
Created November 11, 2017 09:23
mimesis-factory
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
mimesis = "*"
(pipenv-tests) ~/Desktop/pipenv master ✗
» pipenv run pytest -n 8 tests
Loading .env environment variables…
============================= test session starts ==============================
platform darwin -- Python 3.6.4, pytest-3.4.0, py-1.5.2, pluggy-0.6.0
rootdir: /Users/sobolev/Desktop/pipenv, inifile:
plugins: xdist-1.22.0, forked-0.2
gw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 ok / gw5 ok / gw6 ok / gw7 ogw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 ok / gw6 ok / gwgw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 [111] / gw6 ok /gw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 [111] / gw6 ok /gw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 [111] / gw6 [111] / gw7 [111]
scheduling tests via LoadScheduling
FFFFFF..s........s..s......F..................F......................... [ 64%]
#!/usr/bin/env bash
# Running: `bash create_merge_conflict.sh`
set -e
PROJECT_NAME="pipenv-merge-conflicts"
# Creating project structure:
rm -rf "$PROJECT_NAME"
# -*- coding: utf-8 -*-
import json
import toml
def read_pipenv_lock():
with open('Pipfile.lock') as lock:
return json.loads(lock.read())
A002: "dict" is used as an argument and thus shadows a python builtin, consider renaming the argument
1 manimlib/utils/config_ops.py
Total: 1
B001: Do not use bare `except:`, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer `except Exception:`. If you're sure what you're doing, be explicit and write `except BaseException:`.
1 manimlib/mobject/svg/drawings.py
4 manimlib/mobject/svg/svg_mobject.py
1 manimlib/utils/color.py
1 manimlib/utils/sounds.py
Total: 7
{
"env": {
"node": true,
"browser": true,
"es6": true
},
"globals": {
"document": false,
"navigator": false,
"window": false