Instantly share code, notes, and snippets.

View AppPushwooshNotifiable.js
import React from 'react';
import { Provider } from 'react-redux';
import { Router, AndroidBackButton } from 'react-router-native';
import { StyleProvider } from '@shoutem/theme';
/* Local components */
import StoredSession from 'src/components/connected/StoredSession';
import NotifiableDevice from 'src/components/connected/NotifiableDevice';
import Routes from 'src/routes';
View axios.js
import axios from 'axios';
import config from 'src/config';
export default axios.create({
baseURL: config.apiBaseUrl,
timeout: 3000,
headers: {
'content-type': 'application/json'
View ConnectedPrivateRoute.js
import { connect } from 'react-redux';
import HOCPrivateRoute from 'src/components/utility/PrivateRoute';
function mapStateToProps(state) {
return {
authenticated: state.auth.authenticated,
redirectTo: '/welcome'
View Loading.js
import React, { Component } from 'react';
import PropTypes from 'prop-types';
const Loading = (Wrapped, action) => class extends Component {
static propTypes = {
action: PropTypes.func
static defaultProps = {
action: false
View HistoryListener.js
import { Component } from 'react';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router-native';
const HistoryListener = class extends Component {
static propTypes = {
history: PropTypes.object.isRequired,
callback: PropTypes.func.isRequired,
delay: PropTypes.number
View calculations.rb
module Users
class Profile < ApplicationRecord
include ::Calculator::Profile # Let anything with this act as a profile?
module Trends
class Profile < ApplicationRecord
include ::Calculator::Profile # And if we need ad-hoc profiles,
# make classes for them
View entity_change_callbacks.rb
module EntityChangeCallbacks
extend ActiveSupport::Concern
# This concern allows us to treat lists of entity
# attributes as a unit, with their own create and update
# callbacks.
# create_change_callback name: :profile,
# attributes: [
View sitemap.rb
# Set the host name for URL creation
protocol = ENV['PROTOCOL'] || 'http'
SitemapGenerator::Sitemap.default_host = "#{protocol}://#{ENV['HOST']}"
SitemapGenerator::Sitemap.compress = false
SitemapGenerator::Sitemap.create do
View patch_for_jsonapi_authorization_relations.rb
module JSONAPI
module Authorization
class DefaultPunditAuthorizer
def create_resource(source_class, related_records)
::Pundit.authorize(user, source_class, 'create?')
related_records.each do |record|
user.define_singleton_method(:source_class) do
View airbrake.rb
Airbrake.configure do |c|
# You must set both project_id & project_key. To find your project_id and
# project_key navigate to your project's General Settings and copy the values
# from the right sidebar.
c.project_id = 'xxxx'
c.project_key = 'xxxxxxxxxxx'
c.root_directory = Rails.root
c.logger = Rails.logger