Skip to content

Instantly share code, notes, and snippets.

View Mehonoshin's full-sized avatar
💪
Working hard

Stanislav Mekhonoshin Mehonoshin

💪
Working hard
View GitHub Profile
class Movie
attr_accessor :link, :movie, :year, :country, :showing, :jenre, :length, :value, :director, :actor
def initialize(link, movie, year, country, showing, jenre, length, value, director, actor)
@link = link
@movie = movie
@year = year
@country = country
@showing = showing
@jenre = jenre
@Mehonoshin
Mehonoshin / python_repl_history.txt
Last active January 8, 2019 17:20
Python repl history
# Add auto-completion and a stored history file of commands to your Python
# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is
# bound to the Esc key by default (you can change it - see readline docs).
#
# Store the file in ~/.pystartup, and set an environment variable to point
# to it: "export PYTHONSTARTUP=~/.pystartup" in bash.
import atexit
import os
import readline
@Mehonoshin
Mehonoshin / boot.rb
Created December 13, 2017 10:12
Checking how long each gem from Gemfile takes to load
require "benchmark"
if ENV['TRACE_GEMS']
def require(file_name)
result = nil
time = Benchmark.realtime do
result = super
end
"address-book", "address-book-o", "address-card", "address-card-o", "bandcamp", "bath", "bathtub", "drivers-license", "drivers-license-o", "eercast", "envelope-open", "envelope-open-o", "etsy", "free-code-camp", "grav", "handshake-o", "id-badge", "id-card", "id-card-o", "imdb", "linode", "meetup", "microchip", "podcast", "quora", "ravelry", "s15", "shower", "snowflake-o", "superpowers", "telegram", "thermometer", "thermometer-0", "thermometer-1", "thermometer-2", "thermometer-3", "thermometer-4", "thermometer-empty", "thermometer-full", "thermometer-half", "thermometer-quarter", "thermometer-three-quarters", "times-rectangle", "times-rectangle-o", "user-circle", "user-circle-o", "user-o", "vcard", "vcard-o", "window-close", "window-close-o", "window-maximize", "window-minimize", "window-restore", "wpexplorer", "address-book", "address-book-o", "address-card", "address-card-o", "adjust", "american-sign-language-interpreting", "anchor", "archive", "area-chart", "arrows", "arrows-h", "arrows-v", "asl-interpretin
@Mehonoshin
Mehonoshin / test.rb
Created October 24, 2016 12:18 — forked from servzin/test.rb
class BasketController
def add_to_basket
item = Item.find_by_title(params[:item_title])
basket = $basket
basket.add_item(item)
if basket.count_items > 10
basket.error_messages.add("Слишком много товаров в корзине")
@Mehonoshin
Mehonoshin / post-commit
Created October 20, 2016 14:11
Git autocommit hook
#!/usr/bin/env bash
# Drop this file to .git/hooks/post-commit
branch_name=`git symbolic-ref --short HEAD`
retcode=$?
non_push_suffix="_local"
# Only push if branch_name was found (my be empty if in detached head state)
if [ $retcode = 0 ] ; then
@Mehonoshin
Mehonoshin / gist:9871192
Last active January 20, 2018 21:39 — forked from dmexe/gist:1508019
Git workflow

После установки

Указываем свое имя и почту

git config --global user.name "Your Name Comes Here"
git config --global user.email [email protected]

Настраиваем себе shell чтобы показывал как минимум текущий бранч, а лучше ставим себе zsh и oh-my-zsh с гит плагином.

$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
def koeff
1.0 / (department.first_semester_seminars_num + department.second_semester_seminars_num + 5)
end
def set_rate_after
if exam_test? && exam_practice? && exam_theory?
self.rate_after = (exam_test*0.1 + exam_practice*0.2 + exam_theory*0.7) * 10
end
end
@Mehonoshin
Mehonoshin / gist:4977178
Created February 18, 2013 12:57
Чтобы получить в наследуемом методе доступ к константе, определенной в дочерних классах, надо делать так:
class A
def initialize
puts self.class::MY_CONSTANT
end
end
class B < A
MY_CONSTANT = "something"
end