Skip to content

Instantly share code, notes, and snippets.

Araslanov Evgeny araslanov-e

Block or report user

Report or block araslanov-e

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@araslanov-e
araslanov-e / benchmark_methods.rb
Last active Mar 17, 2019
Ruby: class methods vs. instance methods
View benchmark_methods.rb
require "benchmark/memory"
class A
def self.class_method
puts 'hello'
end
def instance_method
puts 'hello'
end
end
View nested.js
/**
*
* usage: $('#select-container').nested({url:'/path/to/backend/which/returns/options/'})
*
*/
(function($){
$.fn.extend({
//pass the options variable to the function
nested: function(options) {
//Set the default values
@araslanov-e
araslanov-e / benchmark.rb
Created Mar 11, 2014
The fastest and most readable way to remove the first character from a string
View benchmark.rb
require 'benchmark'
N = 1_000_000
puts RUBY_VERSION
STR = "[12,23,987,43"
Benchmark.bm(7) do |b|
b.report('[0]') { N.times { "[12,23,987,43"[0] = '' } }
View database.yml.example mysql2
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
View digitalocean.md

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@araslanov-e
araslanov-e / events_helper_test.rb
Created Dec 13, 2013
Тест скорости генерации URL
View events_helper_test.rb
class EventsHelperTest < ActionView::TestCase
def setup
country = Country.create(name: 'Belarus')
state = State.create(name: 'Minsk')
@event = Event.create(country: country, state: state, name: 'Drinking bear')
end
def test_url_for
n = 10000
Benchmark.bmbm do |x|
View .tmux.clipboard
# configuration for osx clipboard support
set-option -g default-command "reattach-to-user-namespace -l sh"
@araslanov-e
araslanov-e / gist:6445658
Created Sep 5, 2013
Сервис КЛАДР (http://kladr-api.ru/) совместно с Select2 (http://ivaynberg.github.io/select2/)
View gist:6445658
$("#street").select2
minimumInputLength: 1
ajax:
url: 'http://kladr-api.ru/api.php'
dataType: 'jsonp'
data: (term, page) ->
token: 'token'
key: 'key'
cityId: 'cityId'
query: term
View Install_tmux
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@araslanov-e
araslanov-e / gist:6130213
Created Aug 1, 2013
Dashboard::DashboardController.ancestors => [Dashboard::DashboardController, Dashboard::ApplicationController, ApplicationController, ... ] Member::MemberController.ancestors => [Member::MemberController, ApplicationController, ... ]
View gist:6130213
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
end
# app/controllers/dashboard/application_controller.rb
module Dashboard
class ApplicationController < ::ApplicationController
before_filter :authenticate_user!
end
You can’t perform that action at this time.