Skip to content

Instantly share code, notes, and snippets.

View Gedrovits's full-sized avatar

Vjatseslav Gedrovits Gedrovits

View GitHub Profile
@Gedrovits
Gedrovits / config
Last active December 17, 2015 08:49
GitHub configuration to push same repository into different services. Just change according to your needs your repository .git/config file.
# GitHub configuration to push same repository into different services
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
# git push all
[remote "all"]
url = git@github.com:<login>/<repository>.git
url = git@bitbucket.org:<login>/<repository>.git
@Gedrovits
Gedrovits / script.js
Last active December 29, 2015 21:29
60 FPS scrolling in browser
var body = document.body,
timer;
window.addEventListener('scroll', function() {
clearTimeout(timer);
if(!body.classList.contains('disable-hover')) {
body.classList.add('disable-hover')
}
timer = setTimeout(function(){
@Gedrovits
Gedrovits / _index.js.haml
Created December 30, 2013 11:11
Kaminari-powered shared paginator
-# shared/_index.js.haml
:plain
$("##{escape_javascript models.first.class.name.tableize.dasherize}").html("#{escape_javascript render(models)}");
$('#pager').html("#{escape_javascript(paginate(models, remote: true).to_s)}#{escape_javascript(page_entries_info models)}");
@Gedrovits
Gedrovits / how-to-fix-on-mac.sh
Last active May 3, 2018 21:50
How to fix 'dyld: lazy symbol binding failed: Symbol not found: _yajl_set_static_value'
# Copy the gem location to clipboard
bundle show yajl-ruby | pbcopy
# Example: /Users/gedrovits/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/yajl-ruby-0.8.2
cd <cmd + v>
cd ext/yajl
# Now we need to replace 'inline void' to 'static void'. This will also create backup of old files.
sed -i '.bak' 's/inline void/static void/g' yajl_ext.h yajl_ext.c
# Now we must rebuild changed extension
make clean all
# After this you should not have any problems with yajl-ruby
@Gedrovits
Gedrovits / support.rb
Last active July 9, 2016 14:09
Snippet to generate base FactoryGirl factory from existing models
# Rebuild Task
# @author Vjatseslav Gedrovits
# @license MIT
namespace :db do
desc 'Drop, create, migrate, seed the database with prompt.'
task rebuild: [:environment, :production_protection] do
puts 'Database rebuild process started...'
$stdout.puts 'Drop old database? (y/n)'
if $stdin.gets.strip == 'y'
@Gedrovits
Gedrovits / gpg-import-and-export-instructions.md
Created April 6, 2016 23:01 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@Gedrovits
Gedrovits / bash-cheatsheet.sh
Created April 8, 2016 14:40 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@Gedrovits
Gedrovits / rebuild.rake
Last active September 23, 2016 13:26
Rebuild task to drop, create, migrate and seed the database
# Rebuild Task
# @authors Vjatseslav Gedrovits, Irina Shumilova
# @license MIT
namespace :db do
desc 'Drop, create, migrate, seed the database with prompt.'
task rebuild: [:environment, :production_protection, :internal_metadata_check] do
puts 'Database rebuild process started...'
$stdout.puts 'Drop old database? (y/n)'
if $stdin.gets.strip == 'y'

Keybase proof

I hereby claim:

  • I am gedrovits on github.
  • I am gedrovits (https://keybase.io/gedrovits) on keybase.
  • I have a public key whose fingerprint is 93E6 4EED D8DF 67EA 5838 86AA CE41 332C AEEB 5145

To claim this, I am signing this object:

@Gedrovits
Gedrovits / retriable-bundle.sh
Created December 27, 2016 14:06
Retriable Ruby bundler
# Source: http://www.zhuwu.me/blog/posts/solve-gem-installation-timeout-when-building-docker-image
N=0
STATUS=1
until [ ${N} -ge 5 ]
do
bundle install --without development test --jobs 4 --deployment && STATUS=0 && break
echo 'Try bundle again ...'
N=$[${N}+1]
sleep 1
done