This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AttrObject | |
def self.attr_logger(*args) | |
args.each { |attribute| define_method(attribute) { | |
value = instance_variable_get("@#{attribute}") | |
STDERR.puts "#{Time.now} - #{value}" | |
}} | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AttrLogger | |
def self.included(base) | |
base.extend ClassLevelMethods | |
end | |
module ClassLevelMethods | |
def attr_logger(*args) | |
args.each { |attribute| | |
define_method(attribute) do | |
value = instance_variable_get("@#{attribute}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server.bind('entry-posted', function(entry) { | |
$("#entries").prepend(entry); | |
$("#entries div.entry:first").fadeIn(); | |
}); | |
server.bind('image-posted', function(image) { | |
addImage(image); | |
}); | |
server.bind('entry-removed', function(entry) { | |
$("#entries #entry-" + entry).remove(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for Entries#create | |
Pusher['live'].trigger('entry-posted', render_to_string("entries/push", :layout => false)) | |
# for Images#create | |
Pusher['live'].trigger('image-posted', render_to_string("images/push", :layout => false)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CarrierWave rake tasks | |
# | |
# Task: reprocess | |
# Desc: Reprocess all images for a given class | |
# Usage: rake carrierwave:reprocess class=<ClassName> mount_uploader=<mount_uploader> | |
namespace :carrierwave do | |
task :reprocess, [:class, :mount_uploader] => :environment do |task, args| | |
desc "Reprocess all images for a given class." | |
args[:class].constantize.all.each do |object| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
if [[ -n "$PS1" ]]; then | |
# don't put duplicate lines in the history. See bash(1) for more options | |
# ... or force ignoredups and ignorespace | |
HISTCONTROL=ignoredups:ignorespace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module A | |
abstract struct BaseFactory | |
alias ValidContextTypes = A::Context | |
def initialize(@context : ValidContextTypes) | |
end | |
end | |
end | |
module A |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "CrSerializer" | |
register_assertion CrSerializer::Assertions::Matches, [ :matcher ] | |
register_assertion CrSerializer::Assertions::ValidURI, [] of Symbol | |
register_assertion CrSerializer::Assertions::ExpectValid, [] of Symbol | |
register_assertion CrSerializer::Assertions::ValidEmail, [] of Symbol | |
register_assertion CrSerializer::Assertions::IFTTT, [ :property, :ruleset ] of Symbol | |
module CrSerializer::Assertions | |
class MatchesAssertion(ActualValueType) < CrSerializer::Assertions::Assertion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## MX Record Resolver for Email Provider | |
# | |
# This script takes a CSV file with a column of email addresses and adds a column | |
# with the email provider (e.g. Google, Microsoft, etc.) based on the MX record | |
# of the email address domain. | |
# | |
# The MX record is the DNS record that specifies the mail server responsible for | |
# accepting email messages on behalf of a domain name. The MX record is used to | |
# route email messages to the correct mail server. | |
# |