Put the ruby file in .git/hooks/post-commit
Create a deploy script as .deploy_*
Example:
# File: .deploy_production
scp -R html example.com:public_html
Then use "deploy *
" in your commit message.
#!/bin/bash | |
# This takes the maximum forecast between four points surrounding Fairbanks, AK. | |
# Paste this in to https://geojson.io/#map=9/64.5053/-147.4997 to see what those points are. | |
# { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -147, 65 ]}, "properties": {} }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -147, 64 ]}, "properties": {} }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -148, 65 ]}, "properties": {} }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -148, 64 ]}, "properties": {} } ] } | |
JQ=$(cat <<-JQ | |
{ | |
forecast_time: ."Forecast Time" | fromdateiso8601 | strflocaltime("%H:%M (%Z)"), |
class ApplicationDecorator < Draper::Base | |
# See +ApplicationDecorator.humanize+ | |
def humanize(attribute, key = model.send(attribute), default = key.to_s.humanize) | |
self.class.humanize attribute, key, default | |
end | |
# By default, humanize the attributes listed. | |
# | |
# Contrived Example: |
class MyUploader < CarrierWave::Uploader::Base | |
include Thumbkit::Adapters::CarrierWave | |
# Watermark should always be processed after thumbkit, ensuring that we always | |
# have a valid image and we don't need to change the extension | |
def watermark(watermark_image, options = {}) | |
cache_stored_file! if !cached? | |
Watermarker.new(current_path, watermark_image).watermark!(options) | |
end |
Put the ruby file in .git/hooks/post-commit
Create a deploy script as .deploy_*
Example:
# File: .deploy_production
scp -R html example.com:public_html
Then use "deploy *
" in your commit message.
MyController = Ember.Controller.extend({ | |
actions: { | |
save: function() { | |
this.get('model').save().then(function() { | |
// Success, maybe transitionToRoute or whatever | |
}, function(xhr) { | |
// Oh noes, we had an error, maybe it's a validation error | |
if (xhr.status == 400) { | |
$.parseJSON(xhr.responseText).each(function(attribute, errors) { | |
this.get('errors').set(attribute, errors); |
# LineItemsController | |
categories: (-> | |
@get('model').mapBy('category').uniq().map (category) => | |
Ember.Object.create | |
name: category | |
line_items: @get('model').filterBy 'category', category | |
).property('@each.category') |
module ABTestHelper | |
def test | |
yield | |
end | |
def variant(variant) | |
if variant_matches(variant) | |
yield | |
end | |
end |
Based on Mislav's gist, svenfuch's gist and vim-tmux-navigator.
My goal was to allow svenfuch's zoom feature to work in any direction. The original implementation relied on pane numbers, which works when you only split in one direction (either only horizontal or only vertical, but not both).
The logic is simple: use a panes width, height, x, and y along with the width width and height to determine if a pane is the top, bottom, leftmost, or rightmost pane. The reason I switched to ruby is that getting the panes x and y requires parsing the window_layout
string.
module Draper | |
- begin | |
- require 'minitest/rails' | |
- rescue LoadError | |
- end | |
- | |
- active_support_test_case = begin | |
- require 'minitest/rails/active_support' # minitest-rails < 0.5 | |
- ::MiniTest::Rails::ActiveSupport::TestCase |