Skip to content

Instantly share code, notes, and snippets.

Avatar

Kelly Sutton kellysutton

View GitHub Profile
View butForWhyPlusEquals.js
var createMyWrappedInput = function (defaultValue) {
var wrappedInput = "<div class='Wrapper'>";
wrappedInput += '<input type="text" value="' + defaultValue + '"/>';
wrappedInput += '</div>';
return wrappedInput;
};
@kellysutton
kellysutton / joinThoseBros.js
Created Aug 17, 2011
Example with an Array.join()
View joinThoseBros.js
var createMyWrappedInput = function (defaultValue) {
return [
'<div class="Wrapper">',
'<input type="text" value="' + defaultValue + '"/>',
'</div>'
].join("");
};
@kellysutton
kellysutton / LetUsAppend.js
Created Aug 17, 2011
Use jQuery for element construction
View LetUsAppend.js
var createMyWrappedInput = function (defaultValue) {
var wrapper = $("<div class='Wrapper'></div>"),
input = $('<input type="text" />');
input.val(defaultValue);
wrapper.append(input);
return wrapper;
};
View html5Form.html
<style>
.ProFeature {
display: none;
}
</style>
<form action="/episodes" method="POST" data-is-pro="<%= user.pro %>">
<input type="email" name="email" />
<input type="email" name="alternate_email" class="ProFeature" disabled />
</form>
@kellysutton
kellysutton / BlipForm.html
Created Aug 19, 2011
Dynamically Generated Form
View BlipForm.html
<div id="Placeholder"></div>
<script>
var myForm = new BLIP.Form({
target: "Placeholder",
action: "/episodes",
method: "POST",
inputs: [
{
name: "email",
@kellysutton
kellysutton / newest.rb
Created Nov 20, 2011
So fresh and so new (new)
View newest.rb
class Array
def newest
records = self.select{ |e| e.kind_of? ActiveRecord::Base }
records.sort do |a, b|
a.created_at <=> b.created_at
end
records.last
end
@kellysutton
kellysutton / gist:2050328
Created Mar 16, 2012
ActionMailer assets with hash-based asset hosting
View gist:2050328

In config/production.rb

  config.action_mailer.asset_host = "https://123123.cloudfront.net"

In config/initializers/mail_image_tag.rb

module ActionView
View gist:5471922
NSString *pathToRelaunch = [host bundlePath];
if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)])
pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater];
NSString *relaunchToolPath = [relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS/finish_installation"];
[NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:[NSArray arrayWithObjects:[host bundlePath], pathToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], tempDir, relaunch ? @"1" : @"0", nil]];
[NSApp terminate:self];
@kellysutton
kellysutton / layervault_install.sh
Created Jun 19, 2013
Install the LayerVault Mac app with homebrew
View layervault_install.sh
brew tap phinze/homebrew-cask
brew install brew-cask
brew cask install layervault
@kellysutton
kellysutton / my_serializer.rb
Last active Dec 20, 2015
ActiveModel::Serializer cache_digest-esque behavior
View my_serializer.rb
class PersonSerializer < ActiveModel::Serializer
def model_version
Digest::MD5.hexdigest(File.read(File.join(Rails.root, "app/serializers", "#{self.class.to_s.underscore}.rb")).gsub(/\s/,''))
end
end
You can’t perform that action at this time.