Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kugaevsky's full-sized avatar
🏠
Working from home

Nick Kugaevsky kugaevsky

🏠
Working from home
View GitHub Profile
@kugaevsky
kugaevsky / datetime.ru.yml
Created September 3, 2014 14:17
Datetime Russian i18n for Ruby on Rails
ru:
date:
formats:
# Форматы указываются в виде, поддерживаемом strftime.
# По умолчанию используется default.
# Можно добавлять собственные форматы
#
#
# Use the strftime parameters for formats.
# When no format has been given, it uses default.
@kugaevsky
kugaevsky / semantic_breadcrumbs_builder.rb
Created February 7, 2017 19:26
Breadcrumbs on Rails Builder for Semantic UI
class SemanticBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
def render
@elements[-1].options[:last] = true
@elements.collect do |element|
render_element(element)
end.join(@options[:separator] || separator)
end
def render_element(element)
element.options[:class] ||= 'section'
@kugaevsky
kugaevsky / revert.sh
Last active July 4, 2018 09:06
Reverting back to node 0.10.36 on Mac OS X with Homebrew
$ cd /usr/local
$ git checkout b64d9b9c431642a7dd8d85c8de5a530f2c79d924 Library/Formula/node.rb
$ brew unlink node
$ brew install node
$ npm install -g npm@latest
@kugaevsky
kugaevsky / cleanup_all_gemsets.sh
Last active November 15, 2017 16:49
Cleanup outdated gems from all your rvm gemsets
#!/bin/sh
echo "NB! This process could be too destructive sometimes and you may need to run 'bundle' command from your project directory."
echo "Do you want to cleanup all gemsets?"
read -p "(anything other than 'yes' will cancel) > " ANSWER
if [[ $ANSWER != "yes" ]]
then
echo "Phew...\nMay be another day."
else
#!/bin/bash
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y yarn
sudo apt-get install -y nodejs
gem install bundler rake
bundle install
[alias]
co = checkout
ci = commit
cl = clean
st = status
br = branch
up = pull --rebase
pr = pull --rebase
last = log -1 HEAD
olog = log --oneline
@kugaevsky
kugaevsky / application.coffee
Last active January 26, 2016 13:51
Access to XHR object in angular $http service
class AppConfig
@$inject: []
constructor: () ->
# Dirty XHR hack
XMLHttpRequest::setRequestHeader = ((sup) ->
(header, value) ->
if header is '__XHR__' and angular.isFunction(value)
value @
else
sup.apply @, arguments
@kugaevsky
kugaevsky / taxpayer_id.rb
Last active December 31, 2015 19:19
Russian taxpayer id validator
class TaxpayerID
FACTORS = [ 3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0 ]
def initialize value
@digits = value.to_s.chars.map(&:to_i)
raise ArgumentError, 'unexpected argument length (must be 10 or 12 chars)' unless @digits.length == 10 || @digits.length == 12
@result = (@digits.length == 10 ? check_ten : check_twelve)
end
@kugaevsky
kugaevsky / play.js.coffee
Last active December 24, 2015 15:59
Play sound proof-of-concept
# --------------------
# Define Audio Context
# --------------------
window.AudioContext = window.AudioContext||window.webkitAudioContext
window.MyAudioContext = new AudioContext()
window.MyAudioDecodeAndPlay = (arrayBuffer) ->
MyAudioContext.decodeAudioData arrayBuffer, (buffer) ->
source = MyAudioContext.createBufferSource()
@kugaevsky
kugaevsky / .zshrc
Last active December 23, 2015 05:29
oh-my-zsh config
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Example aliases