Skip to content

Instantly share code, notes, and snippets.

View gertig's full-sized avatar

Andrew Gertig gertig

View GitHub Profile
@gertig
gertig / 00_Heroku-Release-Phase-Review-Apps-Rails_README.md
Created August 2, 2020 03:02 — forked from stevenharman/00_Heroku-Release-Phase-Review-Apps-Rails_README.md
Heroku Release Phase script for managing Rails DB migrations, and playing nice with Review Apps and postdeploy scripts

Heroku Release Phase + Review Apps + Rails

This is a simplified, but fairly thorough, set of scripts and configuration to enable Heroku Release Phase for Rails apps. Further, this particular set up plays nicely with Heroku Review Apps in that the release phase script will:

  1. Fail, loudly, if the DB does not yet exist.
  2. Load the DB schema if the current schema version (as determined by bin/rails db:version) is 0.
  3. Run DB migrations otherwise.

For a "normal" app that usually means it will run the DB migrations.

@gertig
gertig / machine.js
Created June 23, 2020 01:16
Generated by XState Viz: https://xstate.js.org/viz
const integrationMachine = Machine({
id: "integration",
initial: "noAuthorization",
states: {
noAuthorization: {
on: {
OAUTH_SUCCESS: "needsSiteSelection",
HAS_SITE: "needsCollectionSelection",
HAS_COLLECTION: "needsFieldMapping",
@gertig
gertig / 1_rmtwrk_devise_mailer.rb
Last active January 21, 2019 23:37
Custom Devise Mailer and views using Mailgun and Premailer
class RmtwrkDeviseMailer < Devise::Mailer
helper :application # gives access to all helpers defined within `application_helper`.
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
default from: 'RMTWRK <rmtwrk@inflowhq.com>'
default reply_to: 'RMTWRK <rmtwrk@inflowhq.com>'
layout 'mailer_rmtwrk'
#############################
# CONFIRMATION EMAIL
Verifying my Blockstack ID is secured with the address 1R3Uo79S42SdauJgefHJaXHFYeiFvrd2F https://explorer.blockstack.org/address/1R3Uo79S42SdauJgefHJaXHFYeiFvrd2F
@gertig
gertig / VisibleToUser.js
Created April 3, 2017 14:21 — forked from jcgertig/VisibleToUser.js
React Pundit
require('./styles.css');
import React, {Component, PropTypes} from 'react';
import { connect } from 'react-redux';
import { meetsPolicy } from 'policies';
class VisibleToUser extends Component {
render() {
let { children, hasUser, type, value, user, action } = this.props;

I am the owner of lvh.me. And I'm glad to hear it's helpful. In truth, it's just a fancy DNS trick. lhv.me and all of it's sub-domains just point back to your computer (127.0.0.1). That means running ssl is as simple (or difficult) as running ssl on your computer.

I'm not sure how comfortable you are with the command line, but here's my how I setup my development environment. (rvm, passenger, nginx w/ SSL, etc).

Install rvm (no sudo!)

------------------------------------------------------

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head ) source ~/.rvm/scripts/rvm rvm install ree-1.8.7-2010.02

<iframe width="512" height="288" src="http://www.hulu.com/embed.html?eid=ltswvhy0clvhymb7egakig&et=266&st=243" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe>
@gertig
gertig / ugly_numbers.rb
Created October 1, 2014 18:16
Ugly Numbers Challenge
class Numeric
def ugly?
self == 0 || self % 2 == 0 || self % 3 == 0 || self % 5 == 0 || self % 7 == 0
end
end
# lines.each do |line|
orig_arr = line.strip.split(//)
line_arr = line.strip.gsub(/(0+)/, "0").split(//) # replace multiple zeros with one (for speed)
App.ApplicationAdapter = DS.RESTAdapter.extend({
host: 'http://hackerbarapp.com',
buildURL: function (type, id) {
var s = this._super("api", id);
console.log("URL: ", s);
return s + "?version=v1&api_key=2659a3fd-2f13-40ed-86ca-b7a40692979c";
},
pathForType: function(type) {
if (type == "api") {
return "api";
<?php
// Encode a string to URL-safe base64
function encodeBase64UrlSafe($value)
{
return str_replace(array('+', '/'), array('-', '_'),
base64_encode($value));
}
// Decode a string from URL-safe base64
function decodeBase64UrlSafe($value)