Skip to content

Instantly share code, notes, and snippets.

@jean182
jean182 / _errors.html.erb
Last active Nov 22, 2018
Bootstrap alert partial for form validation haml and erb
View _errors.html.erb
<% if object.errors.any? %>
<div class="alert alert-danger alert-dismissible fade show" id="error_explanation" role="alert">
<h4>
<%= pluralize(object.errors.count, "error") %>
prohibited
this object from being saved:
</h4>
<ul>
<% object.errors.full_messages.each do |msg| %>
<li>
@jean182
jean182 / bitbucket-pipelines.yml
Created Dec 18, 2018
Bitbucket Pipelines example
View bitbucket-pipelines.yml
image: starefossen/ruby-node:2-5
pipelines:
branches:
master:
- step:
script:
- export HEROKU_APP_NAME=ci-conceptual
- chmod +x deploy-scripts/package_and_deploy.sh deploy-scripts/migrate.sh deploy-scripts/restart.sh
- deploy-scripts/package_and_deploy.sh
View Select.jsx
import React, { Component } from "react";
import { connect } from "react-redux";
import PropTypes from "prop-types";
import { isEmpty, isUndefined } from "lodash-es";
import { makeCurrentLevel } from "redux-modules/location/hierarchy";
const LevelOption = props => {
const { level } = props;
if (!isEmpty(level)) {
const { id, attributes } = level;
View react-tips.md

Ideas

  1. Prefer the usage of native methods, don't rely too much on lodash. Examples:
    1. We tend to over use isEmpty and there're many native ways to do it:
     import { isEmpty } from "lodash-es";
    
     /* When an array is present or does not have values */