Skip to content

Instantly share code, notes, and snippets.

View osulyanov's full-sized avatar
🎯
Focusing

Oleg osulyanov

🎯
Focusing
  • Passion.io
View GitHub Profile
@osulyanov
osulyanov / gist:4761923
Created February 12, 2013 12:12 — forked from moiristo/gist:1245170
Rails3 way to redirect non-www domain to www domain
# Rails3 way to redirect non-www domain to www domain
# Single domain redirect
'example.com'.tap do |host|
constraints(:host => host) do
match '/(*path)', :to => redirect { |params, request| Addressable::URI.escape request.url.sub(host, "www.#{host}") }
end
end
@osulyanov
osulyanov / application.css
Created February 7, 2013 10:41
Custom file input
.file_upload {
position: relative;
overflow: hidden;
float: left;
margin-right: 4px;
}
.file_upload input {
position: absolute;
top: 0;
right: 0;
@osulyanov
osulyanov / copy_paperclip_data.rb
Created January 28, 2013 06:45
Move existing Paperclip attachments to a new path Case in: lib/tasks/copy_paperclip_data.rb And run: rake copy_paperclip_data
desc "Copy paperclip data"
task :copy_paperclip_data => :environment do
@users = User.find :all
@users.each do |user|
unless user.image_file_name.blank?
filename = Rails.root.join('public', 'system', 'images', user.id.to_s, 'original', user.image_file_name)
if File.exists? filename
image = File.new filename
user.image = image
mkdir ~/bin
export PATH=~/bin:$PATH
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
export EDITOR='subl -w'
git config --global core.editor "subl -n -w"
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');