(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
# Ways to execute a shell script in Ruby | |
# Example Script - Joseph Pecoraro | |
cmd = "echo 'hi'" # Sample string that can be used | |
# 1. Kernel#` - commonly called backticks - `cmd` | |
# This is like many other languages, including bash, PHP, and Perl | |
# Synchronous (blocking) | |
# Returns the output of the shell command | |
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 |
# Dealing with namespaces in Nokogiri. | |
# | |
# First thing you must do is abandon what you're used to with Builder, | |
# namespaces aren't just attributes on an element, they uniquely identify | |
# what sort of element you are building and, as such, you are better off | |
# specifying them manually. | |
# | |
# The key here is accessing the Nokogiri::XML::Element being built with | |
# b.parent, then you can set the namespace (distinguished by an element | |
# with a prefix such as "soap12:Envelope") or add a default namespace |
gem 'kaminari' | |
gem 'ransack' |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
import { Component } from "React"; | |
export var Enhance = ComposedComponent => class extends Component { | |
constructor() { | |
this.state = { data: null }; | |
} | |
componentDidMount() { | |
this.setState({ data: 'Hello' }); | |
} | |
render() { |
React now supports the use of ES6 classes as an alternative to React.createClass()
.
React's concept of Mixins, however, doesn't have a corollary when using ES6 classes. This left the community without an established pattern for code that both handles cross-cutting concerns and requires access to Component Life Cycle Methods.
In this gist, @sebmarkbage proposed an alternative pattern to React mixins: decorate components with a wrapping "higher order" component that handles whatever lifecycle methods it needs to and then invokes the wrapped component in its render()
method, passing through props
.
While a viable solution, this has a few drawbacks:
To install a composer package globally, you run the usual require command, but with the addition of the global modifier. So to install PHPUnit, you would run:
$ composer global require phpunit/phpunit
$ composer global require phpunit/dbunit
$ composer global require phing/phing
$ composer global require phpdocumentor/phpdocumentor
$ composer global require sebastian/phpcpd
# frozen_string_literal: true | |
class AssociationLoader < GraphQL::Batch::Loader | |
attr_reader :klass, :association | |
def initialize(klass, association) | |
raise ArgumentError, "association to load must be a symbol (got #{association.inspect})" unless association.is_a?(Symbol) | |
raise ArgumentError, "cannot load associations for class #{klass.name}" unless klass < ActiveRecord::Base | |
raise TypeError, "association #{association} does not exist on #{klass.name}" unless klass.reflect_on_association(association) | |
@klass = klass |
const webpack = require('webpack') | |
const { environment } = require('@rails/webpacker') | |
// Don't use commons chunk for server_side_render chunk | |
const entries = environment.toWebpackConfig().entry | |
const commonsChunkEligible = Object.keys(entries).filter(name => name !== 'server_side_render') | |
environment.plugins.set('CommonsChunkVendor', new webpack.optimize.CommonsChunkPlugin({ | |
name: 'vendor', | |
minChunks: (module, count) => { |
I got to here after spending hours trying to deploy to an Elastic Beanstalk instance via CircleCi 2.0 so I thought I'd write up what worked for me to hopefully help others. Shout out to RobertoSchneiders who's steps for getting it to work with CircleCi 1.0 were my starting point.
For the record, I'm not the most server-savvy of developers so there may be a better way of doing this.