Skip to content

Instantly share code, notes, and snippets.

@kapkaev
kapkaev / _orders.html.erb
Created November 11, 2011 21:25 — forked from yrgoldteeth/_orders.html.erb
Rails 3.1 - will_paginate and ajax
<ul>
<% @orders.each do |order| %>
<li>
<!-- Show order stuff -->
</li>
<% end %>
</ul>
<%= will_paginate @orders %>
@kapkaev
kapkaev / config-initializers-resque.rb
Created November 19, 2011 15:25 — forked from andreaseger/config-initializers-resque.rb
carrierwave resque background image processing foo
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
rails_env = ENV['RAILS_ENV'] || 'development'
resque_config = YAML.load_file(rails_root + '/config/resque.yml')
Resque.redis = resque_config[rails_env]
#secure the admin view of resque
Resque::Server.use(Rack::Auth::Basic) do |user, password|
password == "secret"
end
@kapkaev
kapkaev / downloads_controller.rb
Created January 11, 2012 09:41 — forked from matiaskorhonen/downloads_controller.rb
unicorn secure download rails
class DownloadsController < ApplicationController
DOWNLOAD_EXPIRY = 30.minutes
DOWNLOAD_SECRET = "MYSECRET"
def show
download = Download.find(params[:id])
# download.file_path - get the path to the file, relative to the downloads directory
serve_file(download.file_path)
@kapkaev
kapkaev / gist:1641413
Created January 19, 2012 17:47 — forked from phillipkoebbe/gist:1457544
Installing ruby-debug19 on ruby 1.9.3-p0 on Mac OS X Lion 10.7.2 with Xcode 4.2.1
# assumes 1.9.3-p0 is already installed in RVM (1.9.2) and you are in an empty gemset
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
gem install rake
gem install archive-tar-minitar
gem install ruby_core_source
gem install columnize
gem install linecache19-0.5.13.gem -- --with-ruby-include="$rvm_path/src/`rvm tools strings`"
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include="$rvm_path/src/`rvm tools strings`"
@kapkaev
kapkaev / stage0-change-mirror-to-korean.sh
Created January 31, 2012 19:22 — forked from premist/stage0-change-mirror-to-korean.sh
Installing GitLab on CentOS 6.2 (Part 1)
curl https://raw.github.com/gist/1588091/8b7b7a203074231f3dc75bdee48b3017078fb621/CentOS-Base.repo -o /etc/yum.repos.d/CentOS-Base.repo
curl https://raw.github.com/gist/1588091/2e5ab750cd0603dd7210ea7a999d15f9aadae711/epel.repo -o /etc/yum.repos.d/epel.repo
@kapkaev
kapkaev / elasticsearch.conf
Created March 7, 2012 07:58 — forked from tobiasmcnulty/elasticsearch.conf
upstart job for elastic search
# ElasticSearch Service
description "ElasticSearch"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
@kapkaev
kapkaev / server.conf
Created March 21, 2012 10:06
NginX config for Rails 3.1 & Unicorn
upstream example_backend {
server unix:/var/www/example.com/shared/unicorn.sock;
}
server {
listen 80;
server_name example.com www.example.com;
access_log off;
error_log off;
client_max_body_size 20M;
@kapkaev
kapkaev / ffmpeg.rb
Created March 29, 2012 13:29 — forked from ehlyzov/ffmpeg.rb
ffmpeg & carrierwave
module CarrierWave
module FFMPEG
extend ActiveSupport::Concern
module ClassMethods
def faststart
process :faststart => true
end
def transcode options
@kapkaev
kapkaev / hack.sh
Created March 31, 2012 16:51 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.redis.redis-server</string>
<key>Program</key>
<string>/usr/local/redis/bin/redis-server</string>
<key>ProgramArguments</key>