Skip to content

Instantly share code, notes, and snippets.

View arrowcircle's full-sized avatar

Oleg Bovykin arrowcircle

  • Ivy Knob
  • Berlin, Germany
View GitHub Profile
@arrowcircle
arrowcircle / controller.rb
Last active August 29, 2015 14:01
How to refactor view?
class ProductsContrller < AcpplicationController
def index
@products = Product.order('category_id ASC')
end
end
@arrowcircle
arrowcircle / _form_example.html.haml
Created May 23, 2014 08:55
How to make custom form_for?
= super_form_for @book do |f|
= f.input :title
= f.input :body
@arrowcircle
arrowcircle / headhunter.md
Last active August 29, 2015 14:07
WANTED! RailsRumble 2014

About us

I and my collegue looking for two teammates for RailsRumble 2014 contest.

IDEA

We are planning to rewrite from scratch our lib redditor - it adds super content editor to any rails model. Content can be build from any number of any blocks: texts (1, 2 and 3 columns), images, sliders, videos, cut-separators and pairs of text + image (video, text or anything else). We are adding default css and js to work out of the box. Its really easy and fun to use redditor for content management - and we want to make it event better!

We are looking for

@arrowcircle
arrowcircle / console output
Last active August 29, 2015 14:13
elixir cowboy handler problem
iex(1)> TimelineHandler.handle("foo", "bar")
** (UndefinedFunctionError) undefined function: :cowboy_http_req.reply/4 (module :cowboy_http_req is not available)
:cowboy_http_req.reply(200, [{"content-type", "application/javascript"}], "Pusher.JSONP.receive(1, null, {});", "foo")
(puxir) lib/timeline_handler.ex:9: TimelineHandler.handle/2
#!/bin/bash
if [ ! -f ~/runonce ]
then
sudo locale-gen ru_RU.UTF-8
sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo yum update
sudo yum install ansible -y
touch ~/runonce
fi
@arrowcircle
arrowcircle / race.rb
Created October 8, 2012 18:25
racecondition
def update_audio_marker
transaction do
marker = available_markers.order(:date).lock(true).try(:first)
if marker
marker.complete_markers += 1
marker.calculate
marker.save!
end
end
end
@arrowcircle
arrowcircle / gist:3893778
Created October 15, 2012 17:22
whats better?
money_development=> explain analyse insert into audio_markers (user_id, total_markers, date) SELECT users.id, count(*) as count, '2012-10-15' FROM users INNER JOIN portfels ON portfels.user_id = users.id where portfels.status = 6 and portfels.valid_til is not null group by users.id;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Insert on audio_markers (cost=844.24..844.27 rows=1 width=12) (actual time=4.175..4.175 rows=0 loops=1)
-> Subquery Scan on "*SELECT*" (cost=844.24..844.27 rows=1 width=12) (actual time=4.107..4.111 rows=2 loops=1)
-> HashAggregate (cost=844.24..844.25 rows=1 width=4) (actual time=4.079..4.079 rows=2 loops=1)
-> Nested Loop (cost=227.27..844.24 rows=1 width=4) (actual
module.exports = function(ws) {
ws.onopen = function() {
ws.send('biff');
};
ws.onmessage = function(m) {
console.log(m);
};
};
gem 'piet'
User.find_by_sql("insert into usercalcs (username, amount, created_at, updated_at, flag) select u.username::integer, sum(t.amount) as tr_sum, '#{t}', '#{t}', 0 from users u join archive_transfers t on u.username = t.receiver_id where t.status = 2 and t.currency = 1 and t.created_at between '#{s}' and '#{e}' group by u.username")