Skip to content

Instantly share code, notes, and snippets.

View rimian's full-sized avatar

Rimian Perkins rimian

View GitHub Profile
# Doesn't work when code = nil because the operator in the SQL should be 'is' not '='
def shipping_options
if @promotion.present?
code = @promotion.code
else
code = nil
end
Shipping.where('promotion_code = ? AND is_bulky = ? AND minimum_spend <= ?',
code, self.bulky_order?, self.calculate_total_price.to_f)
def a
true
end
def b
true
end
def c
true
end
def d
class Mailer < ActionMailer::Base
default from: "hello@example.com"
def notify
'notify'
end
end
@rimian
rimian / gist:5572765
Last active December 17, 2015 07:29
remove merged git branches
#!/bin/bash
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ "$current_branch" != "master" ]; then
echo "WARNING: You are on branch $current_branch, NOT master."
fi
echo -e "Fetching merged branches...\n"
git remote update --prune
remote_branches=$(git branch -r --merged | grep -v '/master$' | grep -v "/$current_branch$")
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA+FCOW20oxzv6i7hPMNycrlJ0SsmTSNl8IH6yI9CMXv0B4cwOt24dLNEaX95CaXWoHaqMv6u6vkfS8T7MSRMzCTBl7HIrkszXCT/WDtNTV/qaHurRPn0dlxJSeDc52p01+MdGC+b+e7rNRQSt0fV68X0R2EXn3amKfesLqNsv6GQXkzhvNpkafbBc+jIwsfFr0H8sdJODmdjMtugbysPrB+9b/lTPryg01J4Fubwux43X+rSqD5qbCEATeyFeKmb01rjFUQLtfFMRozaeMyzZqxtgQvGoiBiSNB/9hXoJA/oWog1l3yHfakBnkx3L10eN6HfHg2s+Uj6rEPxa2fal3Q== rimianperkins@Macintosh.local
bundle exec cap production rails:console
c = Custcare::Contact.where(:email => 'foo@example.com').first
c.confirm!
#!/usr/bin/perl -w
use strict;
# sets mtime and atime of files to the latest commit time in git
#
# This is useful for serving static content (managed by git)
# from a cluster of identically configured HTTP servers. HTTP
# clients and content delivery networks can get consistent
# Last-Modified headers no matter which HTTP server in the
# cluster they hit. This should improve caching behavior.
@rimian
rimian / gulpfile
Created April 20, 2015 10:53
My Gulp File Yo
var
concat = require('gulp-concat'),
del = require('del'),
gulp = require('gulp'),
karma = require('gulp-karma'),
args = require('yargs');
var Args = function(yargs) {
var _match = yargs.m || yargs.match;
var _file = yargs.f || yargs.file;
% if ($session{'CurrentUser'}->EmailAddress =~ /\@example\.net$/) {
<script type="text/javascript"
% if ( $ENV{'SERVER_NAME'} =~ /integration/ ) {
src="http://bam.integration.example.net/bam.js"
% } else {
src="https://bam.production.example.net/bam.js"
% }
></script>