Skip to content

Instantly share code, notes, and snippets.

View leemour's full-sized avatar

Viacheslav Ptsarev leemour

View GitHub Profile
#!/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
@leemour
leemour / Rakefile
Created April 1, 2014 12:48 — forked from jeffreyiacono/Rakefile
rake task for precompiling assets using sprockets within a sinatra app + view helpers
require 'rubygems'
require 'bundler'
Bundler.require
require './application'
namespace :assets do
desc 'compile assets'
task :compile => [:compile_js, :compile_css] do
end
@leemour
leemour / time_spec.rb
Created April 26, 2014 15:16
RSpec time stubbing without Timecop
#Timecop is fun, but you don't need a whole gem for that. Just use
#Time.stub(:now), e.g.
describe "time" do
before do
@fake_time = Time.now
Time.stub(:now) { @fake_time }
end
it "is equal" do
Time.now.should == Time.now # now it passes
@leemour
leemour / Guardfile
Created April 27, 2014 10:00
Guardfile ignore rspec livereload
ignore([
%r{^bin/*},
%r{^config/*},
%r{^db/*},
# %r{^lib/*},
%r{^log/*},
%r{^public/*},
%r{^tmp/*}
])
@leemour
leemour / console.rb
Last active August 29, 2015 14:02 — forked from marcamillion/console.rb
Rails 4 cache_counter for has_and_belongs_to_many relationship
## I imagine this could be done in the migration, but it was giving me problems so I moved it to the model
## and just did it on the command line
> Tag.reset_questions_count
@leemour
leemour / rename.sh
Created September 10, 2014 14:06
Rename haml to slim files in all subidrectories
rename 's/\.[^.]*$/.slim/' app/views/devise/**/*
@leemour
leemour / generate.sh
Created April 14, 2015 13:33
Rails generate image polymorphic
rails generate model Image name:string imageable:references{polymorphic}
@leemour
leemour / kill_process.sh
Created April 22, 2015 09:03
Kill process Ubuntu by name
kill $(ps aux | grep 'puma' | awk '{print $2}')
# The ps gives you the list of all the processes.
# The grep filters that based on your search string, [p] is a trick to stop you picking up the actual grep process itself.
# The awk just gives you the second field of each line, which is the PID.
# The $(x) construct means to execute x then take its output and put it on the command line. The output of that ps pipeline inside # that construct above is the list of process IDs so you end up with a command like kill 1234 1122 7654
@leemour
leemour / zsh.md
Last active August 29, 2015 14:19 — forked from tsabat/zsh.md
[
{
line: "Сокольническая линия",
stations: ["Улица Подбельского", "Черкизовская", "Преображенская площадь", "Сокольники", "Красносельская", "Комсомольская", "Красные ворота", "Чистые пруды", "Лубянка", "Охотный ряд", "Библиотека имени Ленина", "Кропоткинская", "Парк культуры", "Фрунзенская", "Спортивная", "Воробьёвы горы", "Университет", "Проспект Вернадского", "Юго-Западная"]
},
{
line: "Замоскворецкая линия",
stations: ["Красногвардейская", "Домодедовская", "Орехово", "Царицыно", "Кантемировская", "Каширская", "Коломенская", "Автозаводская", "Павелецкая", "Новокузнецкая", "Театральная", "Тверская", "Маяковская", "Белорусская", "Динамо", "Аэропорт", "Сокол", "Войковская", "Водный стадион", "Речной вокзал"]
},
{