Skip to content

Instantly share code, notes, and snippets.

View 907th's full-sized avatar

Aleksei Chernenkov 907th

View GitHub Profile
@907th
907th / Main Rinkeby Account
Created September 18, 2017 16:39
Main Rinkeby Account
0x847DaF6adA406EF834343EC6365b969ee160472E
@907th
907th / rails http status codes
Created June 28, 2016 13:48 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@907th
907th / exception_helpers.rb
Created June 28, 2016 13:41
Exception helpers
module MemberApi
module ExceptionHelpers
# Usage:
# render_validation_errors(model) unless model.valid?
#
# @param model [ActiveRecord::Base]
#
def render_validation_errors(model, status: :bad_request)
render json: {
full_messages: model.errors.full_messages,
@907th
907th / MULTITHREADING_READINGS.md
Last active December 15, 2015 12:29 — forked from somebody32/gist:5232120
Multithreading reading list for Rubyists

Введение

Начать стоит отсюда. Не пугайтесь то, что это книга по незнакомой OS, эти термины практически везде одинаковые и здесь они изложены в понятной для начинающих форме.

http://www.qnx.com/developers/docs/6.4.1/neutrino/getting_started/s1_procs.html

Прочесть нужно треть главы до подраздела "Starting a process", если С не пугает, читайте полностью. После прочтения вы будете понимать, что такое process, thread, mutex, priorites, semaphores, scheduler, contex-switch, kernel states.

Ruby

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

Namespace for classes and modules that handle serving documentation over HTTP

@907th
907th / Dockerfile
Created June 26, 2014 18:16
907th/drone-ruby:2.1.2
FROM bradrydzewski/base
WORKDIR /home/ubuntu
USER ubuntu
ADD rbenv.sh /etc/drone.d/
RUN cd /home/ubuntu/.rbenv/plugins/ruby-build && \
git pull
RUN export PATH="/home/ubuntu/.rbenv/bin:$PATH" && \
@907th
907th / Dockerfile
Last active August 29, 2015 14:03
rbnev install 2.1.2 - Wrong owner for .rbenv/versions/2.1.2/lib/ruby/gems/2.1.0 directory
FROM bradrydzewski/base
WORKDIR /home/ubuntu
USER ubuntu
ADD rbenv.sh /etc/drone.d/
RUN cd /home/ubuntu/.rbenv/plugins/ruby-build && \
git pull
RUN export PATH="/home/ubuntu/.rbenv/bin:$PATH" && \
@907th
907th / parameterized_content_for_helper.rb
Last active August 29, 2015 14:01
#content_for with custom parameters
module ParameterizedContentForHelper
# Warning! Content is being rewritten on each next call!
def parameterized_content_for(name, *params, &block)
@parameterized_content_for ||= {}
if block_given?
@parameterized_content_for[name] = block
else
block = @parameterized_content_for[name]
capture *params, &block if block
end
@907th
907th / erb2haml
Created April 7, 2014 10:13
Convert all *.erb temlates to *.haml (with html2haml)
#!/bin/bash
if [ -z "$1" ]; then
wdir="."
else
wdir=$1
fi
for f in $( find . -name '*.erb' ); do
out="${f%.erb}.haml"
@907th
907th / AFTER.rb
Created August 27, 2015 12:11
Hey, ya! Use recursion!
# Split long `address_line` line into array of lines
# each with length not greater than `max_length`
def divide_address(address_line, max_length)
assert max_length > 0, "max_length should be a positive number"
address_line = address_line.strip
if address_line.length <= max_length
return [address_line]
else
head = address_line.truncate(max_length, separator: " ", omission: "")
tail = address_line[head.length..-1]