Skip to content

Instantly share code, notes, and snippets.

Avatar

James Paden JamesPaden

View GitHub Profile
View ex05-error-cases-callback-method.rb
def write_active_migrator_destination_model
begin
write_active_migrator_destination_model!
rescue Exception => e
ActiveMigrator.config.exception_handler.call(e, active_migrator_source_class: active_migrator_source_klass.name, active_migrator_source_id: id)
end
true
end
View ex03-happy-path-destination-model.rb
module ActiveMigrator
class ActiveMigratorDestinationModel < ActiveRecord::Base
self.abstract_class = true
# disable STI for this "copy" model
self.inheritance_column = :_type_disabled
establish_connection DB_ACTIVE_MIGRATOR_CONFIGURATION[:destination]
end
end
module ActiveMigrator
module ActiveMigratorSource
View ex01-happy-path-after-commit.rb
def write_active_migrator_destination_model!
if ActiveMigrator.config.enabled_checker.call(id)
ActiveMigrator.config.metric_incrementer.call("active_migrator.#{active_migrator_source_klass.name}.write_active_migrator_destination_model")
original_record = find_original_model
if original_record
active_migrator_destination_model = original_record.find_active_migrator_destination_model
original_record.transformed_attributes_for_active_migrator.each do |name, value|
active_migrator_destination_model.send(:write_attribute, name, value)
end
active_migrator_destination_model.save!
@JamesPaden
JamesPaden / instrumental-notices.js
Last active Sep 28, 2016
Example usages of Instrumental Notices in various languages
View instrumental-notices.js
var I = require('instrumental-node');
I.configure({ apiKey: 'YOUR_PROJECT_TOKEN' });
// WITHOUT DURATION
I.notice('Deployed database query rewrites')
// WITH DURATION
start_time = Date.now()
// Maybe put your deploy code here?
@JamesPaden
JamesPaden / gist:7a020357e533f4ab31cd
Created Sep 3, 2015
Apache Config for Wordpress Reverse Proxy
View gist:7a020357e533f4ab31cd
# Put this inside the <VirtualHost> directive
<Location /blog>
RequestHeader set X-Is-Reverse=Proxy true
RequestHeader set X-Original-Host yourwebsite.com
ProxyPass http://yourpressableblog.com
ProxyPassReverse http://yourpressableblog.com
</Location>
@JamesPaden
JamesPaden / reverse-proxy.php
Last active Feb 11, 2020
Wordpress Reverse Proxy Plugin
View reverse-proxy.php
<?php
/**
* @package Reverse Proxy
*/
/*
Plugin Name: Reverse Proxy
Plugin URI: https://instrumentalapp.com/
Description: Reverse proxy setup for Instrumental blog
Version: 1.0
Author: James Paden
@JamesPaden
JamesPaden / prince-bootstrap-grid-fix.css
Last active Aug 16, 2017
PrinceXML Bootstrap Grid Fix
View prince-bootstrap-grid-fix.css
/*
PrinceXML calculates Bootstrap's ".66666667%" grid width literally, resulting in a
grid that is technically over 100%. Prince then drops the last column to a new row.
These styles override Bootstrap and set the appropriate grid elements to simply
end in "...6%".
*/
.col-xs-11 {
width: 91.66666666%
}
.col-xs-8 {
View Sublime Preferences
{
"always_show_minimap_viewport": true,
"auto_complete_commit_on_tab": true,
"auto_complete_delay": 10,
"caret_style": "wide",
"color_scheme": "Packages/User/Phoenix Dark Blue Customized.tmTheme",
"create_window_at_startup": false,
"enable_tab_scrolling": false,
"fade_fold_buttons": false,
"font_size": 14,
@JamesPaden
JamesPaden / gist:5447096
Created Apr 23, 2013
Sublime Shortcuts
View gist:5447096
[
//FOCUS GROUP
{ "keys": ["super+ctrl+1"], "command": "focus_group", "args": { "group": 0 } },
{ "keys": ["super+ctrl+2"], "command": "focus_group", "args": { "group": 1 } },
{ "keys": ["super+ctrl+3"], "command": "focus_group", "args": { "group": 2 } },
{ "keys": ["super+ctrl+4"], "command": "focus_group", "args": { "group": 3 } },
{ "keys": ["super+ctrl+5"], "command": "focus_group", "args": { "group": 4 } },
{ "keys": ["super+ctrl+6"], "command": "focus_group", "args": { "group": 5 } },
{ "keys": ["super+ctrl+7"], "command": "focus_group", "args": { "group": 6 } },
{ "keys": ["super+ctrl+8"], "command": "focus_group", "args": { "group": 7 } },
You can’t perform that action at this time.