Skip to content

Instantly share code, notes, and snippets.

View araslanov-e's full-sized avatar

Araslanov Evgeny araslanov-e

  • Russia. Tyumen
View GitHub Profile
@scarfacedeb
scarfacedeb / carrierwave.rb
Last active August 29, 2015 14:02
A quick and dirty way to download files from s3 to local for development
CarrierWave.configure do |config|
if Rails.env.development? || Rails.env.test?
config.storage = :file
else
config.storage = :fog
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: Rails.application.secrets.aws_access_key_id,
aws_secret_access_key: Rails.application.secrets.aws_secret_access_key
@Overbryd
Overbryd / json_store.rb
Last active August 29, 2015 14:05
JSON PStore support
require "pstore"
require "json"
class JSON::Store < PStore
def dump(table)
# use JSON.pretty_generate(table) to make it even more human readable
JSON.generate(table)
end
@dira
dira / ro.yml
Created April 25, 2009 00:10
rails - translation/localization for time_ago_in_words - Romanian
# rails - translation/localization for time_ago_in_words - Romanian
ro-RO:
datetime:
distance_in_words:
less_than_x_minutes:
one: 'mai putin de un minut'
other: 'mai putin de {{count}} minute'
x_minutes:
one: 'un minut'
other: '{{count}} minute'
@dave1010
dave1010 / jquery.detach-select-options.js
Created December 12, 2010 19:33
jQuery plugin to detach (hide) select options and add them again.
// this is because of http://stackoverflow.com/questions/4398966/how-can-i-hide-select-options-with-javascript-cross-browser/4423543
(function($){
$.fn.extend({detachOptions: function(o) {
var s = this;
return s.each(function(){
var d = s.data('selectOptions') || [];
s.find(o).each(function() {
d.push($(this).detach());
@RainerBlessing
RainerBlessing / deploy.rb
Created February 25, 2012 20:10
Capistrano deploy file for git, nginx, thin and sqlite
require 'bundler/capistrano'
set :application, "videonight"
set :repository, "git://github.com/RainerBlessing/Videonight.git"
set :scm, :git
# Prevents error if not parameter passed, assumes that default 'cap deploy' command
# and should deploy the master branch to the production server
set(:env, 'production') unless exists?(:env)
@lengarvey
lengarvey / mongo_test.rb
Created March 10, 2012 08:20
mongo stuff
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("so_test")
end
class Client
include Mongoid::Document
belongs_to :contact
field :name, type: String
~ % source tmuxinator_completion
/home/kill/.rvm/gems/ruby-1.9.3-p125@global/bin/tmuxinator_completion:9: command not found: require
/home/kill/.rvm/gems/ruby-1.9.3-p125@global/bin/tmuxinator_completion:11: command not found: version
/home/kill/.rvm/gems/ruby-1.9.3-p125@global/bin/tmuxinator_completion:16: parse error near `end'
~ % which tmuxinator_completion
/home/kill/.rvm/gems/ruby-1.9.3-p125@global/bin/tmuxinator_completion
~ % cat =tmuxinator_completion
#!/home/kill/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
#
# This file was generated by RubyGems.
set :max_asset_age, 2 ## Set asset age in minutes to test modified date against.
after "deploy:finalize_update", "deploy:assets:determine_modified_assets", "deploy:assets:conditionally_precompile"
namespace :deploy do
namespace :assets do
desc "Figure out modified assets."
task :determine_modified_assets, :roles => assets_role, :except => { :no_release => true } do
set :updated_assets, capture("find #{latest_release}/app/assets -type d -name .git -prune -o -mmin -#{max_asset_age} -type f -print", :except => { :no_release => true }).split
@sandeepravi
sandeepravi / image.rb
Last active October 5, 2015 16:37
A Countable Field for Mongoid
class Image
include Mongoid::Document
field :likes_count, :type => Integer, :default => 0
has_many :likes
end
@lengarvey
lengarvey / assets_location_nginx.conf
Created September 25, 2012 01:14
Access control allow origin header for nginx
location /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
add_header Access-Control-Allow-Origin *;
}