Skip to content

Instantly share code, notes, and snippets.

AllCops:
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'tmp/**/*'
- 'vagrant/**/*'
TargetRubyVersion: 2.3
Lint/EndAlignment:
EnforcedStyleAlignWith: variable
@s-mage
s-mage / prevent_parent_scroll.js
Last active March 16, 2018 20:57
Prevent scrolling of parent element.
jQuery($ =>
$(document).on('wheel', '.scrollable', function(ev) {
let $el = $(this);
let height = $el.outerHeight(true);
let delta = ev.originalEvent.deltaY;
let up = delta < 0;
let prevent = function() {
ev.stopPropagation();
ev.preventDefault();
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord', '5.1'

Keybase proof

I hereby claim:

  • I am s-mage on github.
  • I am smagin (https://keybase.io/smagin) on keybase.
  • I have a public key whose fingerprint is 349B 7B52 9D18 E43B 1014 45E7 E2C5 C5D9 1549 AC85

To claim this, I am signing this object:

<!DOCTYPE HTML>
<html>
<head>
<style>
body {
font: 10px sans-serif;
}
svg {
def vim(*args)
if self.class == Rush::Dir
system "cd #{full_path}; vim +NERDTree"
else
super
end
end
alias_method :v, :vim
require 'matrix'
class TwoSquare
attr_accessor :first_square, :second_square
ALPHABET = 'йцукенгшщзхъэждлорпавыфячсмитьбю.,- '.split('')
def initialize
@first_square = build_square
@second_square = build_square
@s-mage
s-mage / graph_search.rb
Created April 22, 2014 09:58
Solucion of well-known puzzle about river crossing.
# Search of graph.
#
# Algorightm of graph construction:
# Define start state.
# Define finish state.
# Define valid state.
# For each not opened node
# open node
# end
#
@s-mage
s-mage / test_by_tag.rb
Created February 8, 2014 07:30
Find test in cucumber by tag.
TAG_STRING = /(@\w+\W?)+/
EMPTY_STRING = /^\W*$/
def scan_project(dirname, tag)
Dir.new(dirname).
select { |file| File.extname(file) == '.feature' }.
inject('') { |r, f| r << format_file(f, scan_file(f, tag)) }
end
def format_file(filename, scan_result)
@s-mage
s-mage / 2flickr.rb
Last active January 3, 2016 02:49
Upload photos to flickr.
#!/usr/bin/env ruby
require 'flickraw'
require 'json'
CREATE_API_KEY = 'https://secure.flickr.com/services/apps/create/apply'
CONFIG_FILE = File.expand_path '~/.config/2flickr.json'
def init