Skip to content

Instantly share code, notes, and snippets.

View justin808's full-sized avatar
💭
Hiring!

Justin Gordon justin808

💭
Hiring!
View GitHub Profile
########################################################################################################################
########################################################################################################################
# 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
@justin808
justin808 / pgk.zsh
Last active April 10, 2017 23:04
Script to kill errant rails development processes
export PROCESSES_TO_QUIT='bpos puma rake sidekiq spring rails$ ruby-debug phantomjs zeus passenger guard resque "node server.js" ruby$ node foreman fsevent_wat'
pgr() {
echo "Finding processes in list: $PROCESSES_TO_QUIT"
echo $PROCESSES_TO_QUIT | xargs -n 1 pgrep -l
}
pgk() {
echo "Killing processes in list: $PROCESSES_TO_QUIT"
echo $PROCESSES_TO_QUIT | xargs -n 1 pkill -l
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
// app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx
import { HELLO_WORLD_NAME_UPDATE } from '../constants/helloWorldConstants';
export const updateName = (text) => ({
type: HELLO_WORLD_NAME_UPDATE,
text,
});
// 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;
};
@justin808
justin808 / poltergeist.rb
Last active November 26, 2016 09:29
Switch from PhantomJS to Selenium Chrome when PhantomJS crashes. Original at https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/spec/support/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}"

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,
@justin808
justin808 / errors-for-tutorial-different-drivers
Last active March 6, 2016 22:15
Errors when running non-selenium drivers (anybody know how to fix this?) for the https://github.com/shakacode/react-webpack-rails-tutorial/
➜ ~/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
@justin808
justin808 / Rakefile
Last active December 17, 2015 05:39
Addition to Octopress Rakefile to rename blog postings to correspond to dates. Does not change the title part. It will print which files change. If any posts changed that had external references to them (tweets, etc.), then you need to put in an alias. Note, this applies to using org-mode files. Be sure to remove the line for org_posts_dir if yo…
# Based on blog post http://www.ewal.net/2012/09/08/octopress-customizations/
# Modified to option of either all or no drafts, and also to use org-mode files
desc "Redate files in the posts directory if the filename does not match the post date in the YAML front matter. Note, URLs based on 'date' metadata, so this shouldn't break any links"
task :redate_posts do
redate_posts true, source_dir, posts_dir, org_posts_dir
end
desc "Redate files in the posts directory, skipping drafts, if the filename does not match the post date in the YAML front matter. Note, URLs based on 'date' metadata, so this shouldn't break any links"
task :redate_posts_no_drafts do
redate_posts false, source_dir, posts_dir, org_posts_dir
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");
}
});
};