View

Copy a Paperclip attachment to another record

Just assign the existing attachment to another record:

new_photo = Photo.new
new_photo.image = old_photo.image

Paperclip will duplicate the file when saving.

To use this in forms, pimp your attachment container like this:

class Photo < ActiveRecord::Base
  has_attached_file :image
  
  attr_accessor :copy_of

  def image_url
    if copy_of
      copy_of.url
    else
      image.url
    end
  end
end

And in the controller do:

new_photo = Photo.new(:copy_of => old_photo)

Highlighted prompt for production shells

Insert into ~/.bashrc and reload afterwards: source ~/.bashrc

PS1='${debian_chroot:+($debian_chroot)}\[\033[41;33m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
Linked content

Generate CSS Sprites on the Fly with Lemonade

Lemonade’s goal as a sprite generator is to be incredible easy to use, so you’ll use ist for every project—just because there’s no overhead. It needs no configuration, no Rake task, no Photoshop, just a little change in your Sass or SCSS files.

Linked content

Handy! RGB to HSL and RGB to HSV color model conversion algorithms in JavaScript - Axon Flux // A Ruby on Rails Blog

Here is a set of additive color model conversion algorithms that I found published on Wikipedia and have implemented in JavaScript.

Linked content

jnicklas's carrierwave at master - GitHub

File upload solution that supports form roundtrips when a validation fails.

Linked content

michaeldv's awesome_print at master - GitHub

Pretty print your Ruby objects with style – in full color and with proper indentation

Linked content

CSS Speech Bubble · David DeSandro

Speech bubble icons have become synonymous with comments. When creating yet another one for a standard comment link, it occurred to me that there might be a way to make the icon without ever opening up an image editor. It could all be done with CSS

Linked content

htmlBurger PSD to HTML » Home - Convert your Design into Standards compliant XHTML/CSS

We simply convert your design (PSD, PNG, AI, etc.) into a hand coded, pixel perfect and Standards compliant XHTML/CSS. Since our service is targeted to agencies and freelancers the job done by us is 100% confidential. In addition we are offering payment after satisfaction.

Linked content

Image Rollover Borders That Do Not Change Layout | CSS-Tricks

It’s a fact of CSS life that the ‘border’ of any block level element gets factored into it’s final box size for layout. That means that if you add a border on a hover to an element that didn’t already have a border of that exact size, you will cause a layout shift.

Linked content

MailStyle: A HTML Email Plugin for Ruby on Rails | Purify Blog

MailStyle allows you to write the css for your html emails as you normally would, then writes the styles inline when you send your emails. It also makes sure that your image paths are absolute rather than relative.

Linked content

The DevIL Image Library For Ruby « Like Dream of Banister Fiend

DevIL is a fast and lightweight image library that supports the loading and saving of images in almost any graphics format. It also provides some basic image manipulation functionality.

Linked content

Highslide JS - JavaScript thumbnail viewer

Highslide JS is an open source image, media and gallery viewer written in JavaScript.

Linked content

Pennysmalls

I just released a gem to find image dimensions and type information fast.

Linked content

Why Should I Care What Color the Bikeshed Is?

Just because you are capable of building a bikeshed does not mean you should stop others from building one just because you do not like the color they plan to paint it.

Linked content

Index of /projects/sleight

PNG transparency for IE 6.

This website uses cookies to improve usability and analyze traffic.
Accept or learn more