Skip to content

Instantly share code, notes, and snippets.

View divineforest's full-sized avatar

Alexander Balashov divineforest

View GitHub Profile
require 'rvideo'
class Video < MediaFile
after_create :process
FLV_WIDTH = 400
FLV_HEIGHT = 316
CLIP_SIZE_LIMIT_MEGABYTES = 50
# Paperclip Video
function Wish(wish_div) {
this._wish_div = wish_div;
this._header = this._wish_div.find("div.header");
this._content = this._wish_div.find("div.content");
this._showItems = this._wish_div.find(".showItem");
this._tools = this._wish_div.find("div.tools");
}
with(Wish) {
prototype.hide = function() {
class FriendsController < ApplicationController
def create
@friend = find_friend
current_user.request_friend(@friend)
render :text => "Заявка отправлена"
end
def requests
@friends_requested = current_user.friends_requested
end
@divineforest
divineforest / god
Created May 4, 2011 06:54
god ubuntu init.d script
#!/bin/sh
### BEGIN INIT INFO
# Provides: god
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: God
### END INIT INFO
@divineforest
divineforest / dj_watch.rb
Created May 31, 2011 08:26
God DJ watch config
DJ_WORKERS_NUM = 1
DJ_WORKERS_NUM.times do |num|
God.watch do |w|
script = File.join(RAILS_ROOT, "script/delayed_job -i #{num}")
w.name = "dj-#{num}"
w.group = 'dj'
w.interval = 30.seconds
w.start = "#{script} start"
@divineforest
divineforest / gist:2842339
Created May 31, 2012 09:55
sublime config
{
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
"*.dds",
@divineforest
divineforest / gist:3656037
Created September 6, 2012 13:04
Delete all logs from your projects
rm -f ~/Sites/**/log/**/*.log
rm -f ~/Sites/**/log/*.log
@divineforest
divineforest / deploy.rb
Created September 17, 2012 12:58
Lock deploy in Capistrano (only 1 deploy at a moment)
set :deploy_lock_file, "#{shared_path}/tmp/deploing_lock_file"
namespace :deploy do
desc "Check if somebody already is deploing"
task :check_lock do
result = capture("if [ -f #{deploy_lock_file} ]; then cat #{deploy_lock_file}; else echo '0'; fi").strip
if result != '0'
run "echo '#{result} already deploing' 1>&2"
exit
@divineforest
divineforest / spec_helper.rb
Created May 16, 2013 15:32
factory_girl benchmark
config.before(:suite) do
$factory_girl_results = {}
$factory_girl_total_times = {}
$factory_girl_total_time = 0
ActiveSupport::Notifications.subscribe("factory_girl.run_factory") do |name, start, finish, id, payload|
factory_name = payload[:name]
strategy_name = payload[:strategy]
$factory_girl_results[factory_name] ||= {}
$factory_girl_results[factory_name][strategy_name] ||= 0
$factory_girl_results[factory_name][strategy_name] += 1
class Seed
@ids = {}
@classes = {}
def self.create(factory_name, attributes = nil)
raise "attributes must be a hash" if attributes && !attributes.is_a?(Hash)
model = FactoryGirl.create(factory_name, attributes)
@ids[factory_name] = model.id
@classes[factory_name] = model.class