Skip to content

Instantly share code, notes, and snippets.

View leemour's full-sized avatar

Viacheslav Ptsarev leemour

  • Blinkist
  • Valencia, Spain
View GitHub Profile
@drogus
drogus / Rakefile.rb
Created July 26, 2013 10:49
This is the example contents of the Rakefile, which you would use to run active record tasks without using Rails. It assumes using the same directories as rails uses: `db/migrate`, `config/database.yml`.
require 'bundler/setup'
require 'active_record'
include ActiveRecord::Tasks
db_dir = File.expand_path('../db', __FILE__)
config_dir = File.expand_path('../config', __FILE__)
DatabaseTasks.env = ENV['ENV'] || 'development'
@leemour
leemour / _footer.html.haml
Last active December 19, 2015 16:39
Rails 4 HTML5 Haml layout
@leemour
leemour / Ruby.sublime-build
Last active December 19, 2015 15:29 — forked from pmarreck/Ruby.sublime-build
Sublime use rvm
# Get Sublime to use your rvm ruby... Change your Packages/Ruby/Ruby.sublime-build to this,
# or drop it in Packages/User:
{
"env":{
"PATH":"/home/leemour/.rvm/bin:${PATH}"
},
"cmd": [
"/home/leemour/.rvm/bin/rvm-auto-ruby", "$file"
],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
@leemour
leemour / Padrino generate.sh
Last active December 19, 2015 07:18
Padrino project generation example
padrino g project APP -d activerecord -t cucumber -e haml -c sass -s jquery -m mocha --migration_format=timestamp
@leemour
leemour / routes.rb
Created July 3, 2013 09:25 — forked from araslanov-e/gist:5895283
Routing constraint
# app/constraints/photo_constraint.rb
class PhotoConstraint
def initialize
@types = Photo::TYPES
end
def self.matches?(request)
@types.include?(request.path_parameters[:type])
end
end
# app/constraints/photo_constraint.rb
class PhotoConstraint
def initialize
@types = Photo::TYPES
end
def self.matches?(request)
@types.include?(request.path_parameters[:type])
end
end
@leemour
leemour / Padrino.sh
Created June 28, 2013 21:34
Padrino generate project
padrino g project padrino_test -d activerecord -t cucumber -s jquery -e haml -c sass -m mocha
@leemour
leemour / recreate_versions.rb
Last active December 19, 2015 00:09
Pass a file to Rails Console. Recreate versons of images with Carrierwave
# bundle exec rails runner "eval(File.read 'lib/scripts/recreate_versions.rb')"
Product.all.each do |p|
%w(photo1 photo2 photo3 photo4 photo5).map(&:to_sym).each do |photo|
p.send(photo).recreate_versions! if p.read_attribute(photo).present?
end
end
{
"color_scheme": "Packages/User/Railscasts.tmTheme",
"font_size": 12,
"tab_size": 2,
"translate_tabs_to_spaces": false,
@runlevel5
runlevel5 / puma.sh
Last active July 18, 2022 17:37
pumactl is very broken, @nemshilov and @JONESLEE85 wrote this bash script replacement and it works so reliably on production server. So here it is, share with the world!
#!/usr/bin/env bash
# Simple move this file into your Rails `script` folder. Also make sure you `chmod +x puma.sh`.
# Please modify the CONSTANT variables to fit your configurations.
# The script will start with config set by $PUMA_CONFIG_FILE by default
PUMA_CONFIG_FILE=config/puma.rb
PUMA_PID_FILE=tmp/pids/puma.pid
PUMA_SOCKET=tmp/sockets/puma.sock