Skip to content

Instantly share code, notes, and snippets.

@korun
korun / git_fork_update.sh
Last active December 28, 2015 00:49
How to update a fork from the original repository? The answer in this article.
git remote add --track master repo_orig SOME_REPO.git
# Verify new remote
git remote -v
git fetch repo_orig
git merge repo_orig/master
# -*- encoding : utf-8 -*-
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.wrappers :bootstrap3, tag: 'div', class: 'form-group', error_class: 'has-error',
defaults: {input_html: {class: 'default_class'}} do |b|
b.use :html5
b.use :min_max
b.use :maxlength
b.use :placeholder
@korun
korun / devise.ru.yml
Last active August 29, 2015 13:57 — forked from EvilFaeton/ devise.ru.yml
Russian I18n locale for devise.
ru:
devise:
confirmations:
confirmed: "Ваша учётная запись подтверждена. Теперь вы вошли в систему."
send_instructions: "В течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи."
send_paranoid_instructions: "Если ваш адрес email есть в нашей базе данных, то в течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи."
failure:
already_authenticated: "Вы уже вошли в систему."
inactive: "Ваша учётная запись ещё не активирована."
invalid: "Неверный адрес email или пароль."
@korun
korun / .gitignore
Last active August 29, 2015 14:03
Выгрузка комментариев ВКонтакте
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore popular IDE local-settings.
.idea/*
.settings/*
require 'net/ftp'
CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk"
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory
Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp|
files = ftp.list
@korun
korun / octo.gif
Last active August 29, 2015 14:05
At work.
octo.gif
@korun
korun / time_ago.js
Last active August 29, 2015 14:05 — forked from codeincontext/gist:1285806
Javascript function to show how long ago a timestamp was as a pretty string (support Russian language and genitive)
// time in seconds
// genitive - использовать ли родительный падеж (true / false)
(function (){
var units = [
{ name: "second", limit: 60, in_seconds: 1 },
{ name: "minute", limit: 3600, in_seconds: 60 },
{ name: "hour", limit: 86400, in_seconds: 3600 },
{ name: "day", limit: 604800, in_seconds: 86400 },
{ name: "week", limit: 2629743, in_seconds: 604800 },
{ name: "month", limit: 31556926, in_seconds: 2629743 },
require 'benchmark'
n = 1_000_000
login = 'login'
time = Time.now.to_i
Benchmark.bmbm 20 do |results|
results.report 'cycle' do
n.times do
@korun
korun / benchmark.rb
Created April 3, 2015 07:46
ruby const_get vs ::
require 'benchmark'
n = 1_000_000
class Parent
HANDLER_METHOD = :awesome_method
end
class Children < Parent
HANDLER_METHOD = :not_very_awesome_method