Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexey Chernenkov 907th

View GitHub Profile
@907th
907th / Main Rinkeby Account
Created Sep 18, 2017
Main Rinkeby Account
View Main Rinkeby Account
0x847DaF6adA406EF834343EC6365b969ee160472E
@907th
907th / rails http status codes
Created Jun 28, 2016 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
View rails http status codes
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
View exception_helpers.rb
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 / AFTER.rb
Created Aug 27, 2015
Hey, ya! Use recursion!
View AFTER.rb
# 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]
View yardoc_cheatsheet.md

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 Jun 26, 2014
907th/drone-ruby:2.1.2
View Dockerfile
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 Aug 29, 2015
rbnev install 2.1.2 - Wrong owner for .rbenv/versions/2.1.2/lib/ruby/gems/2.1.0 directory
View Dockerfile
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 Aug 29, 2015
#content_for with custom parameters
View parameterized_content_for_helper.rb
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 Apr 7, 2014
Convert all *.erb temlates to *.haml (with html2haml)
View erb2haml
#!/bin/bash
if [ -z "$1" ]; then
wdir="."
else
wdir=$1
fi
for f in $( find . -name '*.erb' ); do
out="${f%.erb}.haml"
@907th
907th / MULTITHREADING_READINGS.md
Last active Dec 15, 2015 — forked from somebody32/gist:5232120
Multithreading reading list for Rubyists
View MULTITHREADING_READINGS.md

Введение

Начать стоит отсюда. Не пугайтесь то, что это книга по незнакомой 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