Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Hiring!

Justin Gordon justin808

💭
Hiring!
View GitHub Profile
View justin-shell-tips.md
gpf='git push --force-with-lease'
gca='git commit -v -a'
gpthis='git push origin HEAD:$(git_current_branch) && git branch -u origin/$(git_current_branch) $(git_current_branch) && echo "pushed current branch and set upstream to origin"'
gco='git checkout'
g='grep -i --color=auto'
hb='hub browse'
@justin808
justin808 / run-commands-async.sh
Created Jun 4, 2018
Simple bash script to run multiple tasks concurrently
View run-commands-async.sh
#!/usr/bin/env bash
# Edit the list of commands.
# YOU MUST USE SINGLE QUOTES HERE.
commands=(
'yarn run build:client-bundles:prod'
'yarn run build:server-bundle:prod'
'yarn run build:global-styles:prod'
)
View gist:bd75f4aba6bb775e45f26f56ef9cf826
########################################################################################################################
########################################################################################################################
# run-prod-locally.sh
########################################################################################################################
echo "Only run this once to set your production setup after changing JS assets."
echo "You can run foreman start -f Procfile.local-prod to restart the server without recompiling"
echo "You may want to have your /application.yml and /config/database.yml reflect your development settings for production"
# Run the rake tasks as production
RAILS_ENV=production rake assets:clobber
View react_on_rails-simple-redux.js
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
// app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx
import { HELLO_WORLD_NAME_UPDATE } from '../constants/helloWorldConstants';
export const updateName = (text) => ({
type: HELLO_WORLD_NAME_UPDATE,
text,
});
View redux-thunk-example.js
// multiple entities returned gets normalized
// https://github.com/shakacode/react-webpack-rails-tutorial/blob/08081f07c7d2686facf2e98d956d50dfbef83678/mobile/ReactNativeTutorial/app/api/index.js
export const fetchComments = async () => {
const response = await getRequest('comments.json');
const camelizedResponse = _.mapKeys(_.camelCase, response);
const { entities } = normalize(camelizedResponse, { comments: commentsSchema });
return entities;
};
View poltergeist.rb
# See in use here:
# https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/spec/support/poltergeist.rb
# This file supports 2 strategies:
# 1. switch_to_selenium: switch drivers
# 2. restart_poltergeist
RESTART_PHANTOMJS = ENV["RESTART_PHANTOMJS"] &&
%w(TRUE YES).include?(ENV["RESTART_PHANTOMJS"].upcase)
puts "RESTART_PHANTOMJS = #{RESTART_PHANTOMJS}"
View ShakacodeReactStyle.md

Redux

  1. Use Immutable.js for non primitives, such as lists, objects, maps, etc.
  2. Store keys of Immutable.js values should be named with prefix $$ Store should be of the shape:
export type StoreType = {
  $$commentsStore: $$Map<string, any>,
  $$profileStore: $$Map<string, any>,
@justin808
justin808 / errors-for-tutorial-different-drivers
Last active Mar 6, 2016
Errors when running non-selenium drivers (anybody know how to fix this?) for the https://github.com/shakacode/react-webpack-rails-tutorial/
View errors-for-tutorial-different-drivers
➜ ~/shakacode/react-webpack-rails-tutorial (fix-comments-json-format) DRIVER=selenium_chrome rspec [12:06:38]
Running via Spring preloader in process 39408
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's 'rails' settings.
Capybara using driver: selenium_chrome
Add new comment
from main page
via Horizontal Form
when the new comment is submitted
View UsingReactOnRails.md
View async-await.js
var longFn = function(x) {
return new Promise(function(res, rej) {
if (x) {
setTimeout(res(x), 1000);
} else {
rej("ERROR from not passing in a value to longFn");
}
});
};
You can’t perform that action at this time.