Instantly share code, notes, and snippets.

View paper_trail.rb
module PaperTrail
class RecordTrail
def record_create
return unless enabled?
@in_after_callback = true
@record.class.paper_trail.version_class.after_transaction do
VersionJob.perform_async(@record.class.paper_trail.version_class, data_for_create)
end
ensure
View webpack.config.js
const path = require("path");
const WebpackNodeExternals = require('webpack-node-externals')
const commonConfiguration = {
mode: process.env.NODE_ENV || "development",
}
const moduleBabel = {
test: /index\.js$/,
exclude: /node_modules/,
use: {
View webpack.config.js
const path = require("path");
const WebpackNodeExternals = require('webpack-node-externals')
module.exports = [
{
mode: process.env.NODE_ENV || "development",
entry: "./source/server/index.js",
target: "node",
externals: [
WebpackNodeExternals()
View gist:c96bcb3684403fa208a96869ce7e104f
krainboltgreene@lovelace.lan at ~/Code/unctionjs/_tempLate on ± core 𝑓 rm -rf node_modules package-lock.json
krainboltgreene@lovelace.lan at ~/Code/unctionjs/_tempLate on ± core 𝑓 npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN Invalid name: "@unction/{{FQNAME}}"
npm WARN _tempLate No description
npm WARN _tempLate No repository field.
npm WARN _tempLate No README data
npm WARN _tempLate No license field.
up to date in 0.76s
View gist:8b55c096ef3f90479dcb9f400fc33509
krainboltgreene@lovelace.lan at ~/Code/unctionjs/_tempLate on ± core 𝑓 1 npm audit fix
npm ERR! code ELOCKVERIFY
npm ERR! Errors were found in your package-lock.json, run npm install to fix them.
npm ERR! Missing: babel-plugin-transform-object-rest-spread@6.26.0
npm ERR! Missing: babel-preset-flow@6.23.0
npm ERR! Missing: chokidar-cli@1.2.0
npm ERR! Missing: eslint@4.7.2
npm ERR! Missing: eslint-plugin-babel@4.1.2
npm ERR! Missing: eslint-plugin-immutable@1.0.0
npm ERR! Missing: flow@0.2.3
View patchtree-1.js
// KeyChain:: Array<mixed>
// Before:: mixed
// After:: Mixed
// Replacements:: Map<Before, After>
// patchTree:: (Map<KeyChain, Replacements>) => Object => Object
View .hyper.js
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// Choose either "stable" for receiving highly polished,
// or "canary" for less polished but more frequent updates
updateChannel: 'stable',
View gist:eb5cf8331abb76371469e7c0d29234d2
[1] pry(main)> module Behavior
[1] pry(main)* extend ActiveSupport::Concern
[1] pry(main)*
[1] pry(main)* included do
[1] pry(main)* add(1)
[1] pry(main)* end
[1] pry(main)*
[1] pry(main)* class_methods do
[1] pry(main)* def add(value)
[1] pry(main)* @value = value
View add_to_cart_operation.rb
# NOTE: Each task is a map function wrapped in a HOC for handling the return data.
# The annotation of each task is `state -> mixed | state | exception` and the HOC is
# `state -> (state -> mixed | exception) -> state`. `error` is like a task, but instead:
# `exception -> mixed` wrapped in a HOC that matches `exception -> (exception -> mixed) -> exception`.
class AddToCartOperation < ApplicationOperation
task :check_for_missing_product
task :carbon_copy_cart_item
task :lock
task :persist
View challenge.rb
require "set"
require "rspec/autorun"
GRAPH = Hash.new { |accumulated, key| accumulated[key] = Set.new}
LIBRARIES = Set.new
def depend(subject, *dependencies)
GRAPH[subject].merge(dependencies)
dependencies.each(&GRAPH.method(:[]))
end