Skip to content

Instantly share code, notes, and snippets.

View yurikoval's full-sized avatar
🌴
On an island in the sun

🇺🇦 Yuri Kovalov yurikoval

🌴
On an island in the sun
View GitHub Profile
@yurikoval
yurikoval / asset_sync.rb
Created November 20, 2013 01:23
asset_sync initializer config to work with non-stupid-digest-assets gem for non-digest asset compilation and upload to S3.
if defined?(AssetSync)
AssetSync.configure do |config|
config.fog_provider = 'AWS'
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
config.fog_directory = ENV['FOG_DIRECTORY']
config.manifest = false
config.existing_remote_files = 'ignore'
@yurikoval
yurikoval / each_with_index.rb
Last active August 29, 2015 14:01
each_with_index with key, value and index
items = {
'orange' => 'shoes',
'pink' => 'skirt',
'borwn' => 'socks',
'blue' => 'hat'
}
items.each.with_index(1) do |(color, item), index|
puts "#{index}. Please wear your #{color} #{item}."
end
@yurikoval
yurikoval / database.yml
Last active August 29, 2015 14:06
Universal Rails database.yml
development: &development
adapter: postgresql
database: <%= Rails.application.class.parent_name.underscore %>_development
host: localhost
pool: 5
timeout: 5000
test:
<<: *development
database: <%= Rails.application.class.parent_name.underscore %>_test
production:
@yurikoval
yurikoval / gist:8265068f1bdfe44b07e4
Last active August 29, 2015 14:08
Set bundler build configs
bundle config build.pg --with-pg-include='/Applications/Postgres.app/Contents/Versions/9.3/include/'
bundle config build.nokogiri --with-iconv-dir=/usr/local/Cellar/libiconv/1.14/
@yurikoval
yurikoval / add_sequence.sql
Last active August 29, 2015 14:10
Add sequence for PostgreSQL after migrating from MySQL
CREATE SEQUENCE feedbacks_id_seq;
ALTER TABLE feedbacks ALTER COLUMN id SET DEFAULT nextval('feedbacks_id_seq'::regclass);
ALTER SEQUENCE feedbacks_id_seq OWNED BY feedbacks.id;
select setval('feedbacks_id_seq', (select max(id)+1 from feedbacks), false);
@yurikoval
yurikoval / column_to_bool.sql
Created November 25, 2014 11:33
Update column to boolean in Postgres after MySQL migration
ALTER TABLE my_table ALTER COLUMN my_column DROP DEFAULT;
ALTER TABLE my_table ALTER my_column TYPE bool USING CASE WHEN my_column=0 THEN FALSE ELSE TRUE END;
ALTER TABLE my_table ALTER COLUMN my_column SET DEFAULT FALSE;
@yurikoval
yurikoval / capybara_steps.rb
Last active March 12, 2016 08:25
Take screenshot on capybara's every browser action.
class Capybara::Session
%i(visit click_on fill_in).each do |method_name|
original_method_name = "old_#{method_name}".to_sym
alias_method original_method_name, method_name
define_method method_name do |*args|
return_value = send original_method_name, *args
save_screenshot(save_path)
increment_counter
return_value
end
@yurikoval
yurikoval / grep_unique_vars
Last active September 4, 2016 04:01
List unique ENV variables
grep -ohR 'ENV\[.[a-zA-Z_]*.]' ./* | uniq
@yurikoval
yurikoval / index.html
Created November 13, 2016 07:08
Pixelate image in console.log
<html>
<body>
<img src="http://i.imgur.com/0jWrSmF.jpg" width="300" height="234">
<canvas id="canvas" width=50></canvas>
<script>
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
img = new Image();
img.crossOrigin = 'http://profile.ak.fbcdn.net/crossdomain.xml';

Keybase proof

I hereby claim:

  • I am yurikoval on github.
  • I am yurik (https://keybase.io/yurik) on keybase.
  • I have a public key ASCzecHfS9Is-DjuUelCP2aJI6mpTpsbWPOR2ppz-Nappwo

To claim this, I am signing this object: