Skip to content

Instantly share code, notes, and snippets.

View nebolsin's full-sized avatar
🎯
Focusing

Sergey Nebolsin nebolsin

🎯
Focusing
View GitHub Profile

Optimize non-Apple SSDs on OS X. (Run the following commands in the terminal.)

Enable TRIM support

Check IOAHCIBlockStorage version:

open /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/version.plist
@nebolsin
nebolsin / postgresql_patches.rb
Created June 24, 2011 15:33
Rails Postgresql adapter patches for better schema support
# config/initializers/postgresql_patches.rb
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter
def quote_table_name(name)
schema, name_part = extract_pg_identifier_from_name(name.to_s)
return quote_column_name(schema) unless name_part
table_name, name_part = extract_pg_identifier_from_name(name_part)
"#{quote_column_name(schema)}.#{quote_column_name(table_name)}"
@nebolsin
nebolsin / nginx_upload.conf
Created March 1, 2011 08:56
Excerpt from nginx config file for using nginx_upload_module with Rails
location = /videos/ {
upload_pass_form_field "^video";
upload_store /path/to/your/app/tmp/upload;
upload_pass @large_upload;
upload_pass_args on;
upload_store_access all:rw;
upload_set_form_field "$upload_field_name[name]" "$upload_file_name";
upload_set_form_field "$upload_field_name[content_type]" "$upload_content_type";
upload_set_form_field "$upload_field_name[path]" "$upload_tmp_path";
upload_aggregate_form_field "$upload_field_name[md5]" "$upload_file_md5";
@nebolsin
nebolsin / paperclip_extensions.rb
Created February 24, 2011 13:26
Paperclip extension to work with nginx upload module
module Paperclip
class Attachment
class UploadedPath
attr_reader :original_filename, :content_type, :size, :path
def initialize(uploaded_file)
@original_filename = uploaded_file["name"].downcase
@content_type = uploaded_file["content_type"].to_s.strip
@file_size = uploaded_file["size"].to_i
@path = uploaded_file["path"]
@nebolsin
nebolsin / string_inquirer.rb
Created February 15, 2011 16:45
Rails 2.3.10 ActiveSupport::StringInquirer class
module ActiveSupport
# Wrapping a string in this class gives you a prettier way to test
# for equality. The value returned by <tt>Rails.env</tt> is wrapped
# in a StringInquirer object so instead of calling this:
#
# Rails.env == "production"
#
# you can call this:
#
# Rails.env.production?