Skip to content

Instantly share code, notes, and snippets.

Vitalik Danchenko vitalikdanchenko

Block or report user

Report or block vitalikdanchenko

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
View ruby_variables.rb
=begin
This is a machine generated main stub file using stdlib-doc
Created on 2016-08-05 11:57:38 +0300 by IntelliJ Ruby Stubs Generator.
This documentation uses content from the book "Programming Ruby - The Pragmatic Programmer's Guide"
Copyright (C) 2001 by Addison Wesley Longman, Inc. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/)).
Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder.
Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.
This documentation uses content form the article http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Variables_and_Constants#Pre-defined_Variables
View sublime_text_2_useful_shortcuts.md

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
View deep_group.rb
require 'ostruct'
def deep_hash_with_default(level, default)
default_value = level > 1 ? deep_hash_with_default(level - 1, default) : default
Hash.new { |hash, key| hash[key] = default_value }
end
def deep_group(collection, *keys)
result = deep_hash_with_default keys.length, []
collection.each do |item|
@vitalikdanchenko
vitalikdanchenko / http-status-codes
Created Oct 16, 2015
List of http status codes
View http-status-codes
100 = :continue
101 = :switching_protocols
102 = :processing
200 = :ok
201 = :created
202 = :accepted
203 = :non_authoritative_information
204 = :no_content
205 = :reset_content
206 = :partial_content
@vitalikdanchenko
vitalikdanchenko / internal_ip.js
Created Mar 31, 2015
Detect Internal IP address
View internal_ip.js
//get the IP addresses associated with an account
function getIPs(callback) {
var ip_dups = {};
//compatibility for firefox and chrome
var RTCPeerConnection = window.RTCPeerConnection
|| window.mozRTCPeerConnection
|| window.webkitRTCPeerConnection;
var useWebKit = !!window.webkitRTCPeerConnection;
@vitalikdanchenko
vitalikdanchenko / ror_gems
Last active Mar 22, 2016
Useful Ruby on Rails gems
View ror_gems
gem 'haml-rails' # simple and pretty template language
gem 'devise' # authentication
gem 'cancan' # authorization
gem 'formtastic' # form builder, also use 'formtastic-bootstrap'
gem 'kaminari' # pagination, analogs: 'will_paginate'
gem 'draper' # use output decorators instead of helpers
gem 'paperclip' # upload files, analogs: 'carrierwave'
gem 'rmagick' # process images
gem 'letter_opener' # preview letters instead of sending
gem 'activeadmin' # administrative panel
View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
View DDoS checker
# group log file by IP
tail -f /var/log/some_file.log | cut -d ' ' -f 1 | logtop -s <number of lines>
You can’t perform that action at this time.