Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.
I've tried to make it as lean and unobtrusive as possible.
errors/AppError.js
| import React, {PropTypes} from 'react'; | |
| export const Tab = (props) => { | |
| return ( | |
| <li className="tab"> | |
| <a className={`tab-link ${props.linkClassName} ${props.isActive ? 'active' : ''}`} | |
| onClick={(event) => { | |
| event.preventDefault(); | |
| props.onClick(props.tabIndex); | |
| }}> |
| # Scopes that make use of the index | |
| def self.within_distance_of(lat:, lng:, meters:) | |
| where(%{ | |
| ST_DWithin( | |
| ST_GeographyFromText( | |
| 'SRID=4326;POINT(' || #{table_name}.longitude || ' ' || #{table_name}.latitude || ')' | |
| ), | |
| ST_GeographyFromText('SRID=4326;POINT(%f %f)'), | |
| %d | |
| ) |
| class MyJob < ActiveJob::Base | |
| queue_as :urgent | |
| rescue_from(NoResultsError) do | |
| retry_job wait: 5.minutes, queue: :default | |
| end | |
| def perform(*args) | |
| MyService.call(*args) | |
| end |
| --color | |
| --require spec_helper | |
| --require ./spec/support/lifx | |
| -f LIFXFormatter |
| // These are my base breakpoints when working on projects that | |
| // utilize Bourbon (http://bourbon.io/) & Neat (http://neat.bourbon.io/) | |
| $desktop-wide : new-breakpoint(min-width 1370px); | |
| $desktop : new-breakpoint(min-width 1001px); | |
| $desktop-narrow : new-breakpoint(max-width 1000px); | |
| $desktop-narrow-only : new-breakpoint(min-width 769px max-width 1000px); | |
| $tablet : new-breakpoint(max-width 768px); | |
| $tablet-only : new-breakpoint(min-width 640px max-width 768px); | |
| $phone-wide : new-breakpoint(max-width 669px); |
Add the utf8_sanitizer.rb to your Rails 3.2 project in app/middleware. Instead of removing the invalid request characters and continuing the request (as some gems do) it returns a 400 error.
Add the following line to your config/application.rb:
config.middleware.use 'Utf8Sanitizer'
If you only need it in production add to config/environments/production.rb. This can be without quotes:
config.middleware.use Utf8Sanitizer
| # A Rake tasks to facilitate importing data from your models into a common Elasticsearch index. | |
| # | |
| # All models should declare a common index_name, and a document_type: | |
| # | |
| # class Article | |
| # include Elasticsearch::Model | |
| # | |
| # index_name 'app_scoped_index' | |
| # document_type 'articles' | |
| # |
| # config/routes.rb | |
| resources :documents do | |
| scope module: 'documents' do | |
| resources :versions do | |
| post :restore, on: :member | |
| end | |
| resource :lock | |
| end | |
| end |