Skip to content

Instantly share code, notes, and snippets.

View dmitryck's full-sized avatar

dmitryck dmitryck

  • krasava
View GitHub Profile
@mrk21
mrk21 / tailcall_optimization.rb
Created May 21, 2020 06:28
Tail call optimization for Ruby
# @see [Rubyの末尾呼び出し最適化を試す - Qiita](https://qiita.com/rsnni/items/8f818f2c2da07896fc7e)
RubyVM::InstructionSequence.compile_option = {
:tailcall_optimization => true,
:trace_instruction => false
}
RubyVM::InstructionSequence.new(<<-EOS).eval
def fact(x)
return 1 if x == 0
@dnovik
dnovik / cities.csv
Created January 19, 2019 06:55 — forked from nalgeon/cities.md
Города России с координатами
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 21 columns, instead of 18. in line 5.
Индекс,Тип региона,Регион,Тип района,Район,Тип города,Город,Тип н/п,Н/п,Код КЛАДР,Код ФИАС,Уровень по ФИАС,Признак центра района или региона,Код ОКАТО,Код ОКТМО,Код ИФНС,Часовой пояс,Широта,Долгота,Федеральный округ,Население
385200,Респ,Адыгея,,,г,Адыгейск,,,0100000200000,ccdfd496-8108-4655-aadd-bd228747306d,4: город,0,79403000000,79703000001,0107,UTC+3,44.8783715,39.190172,Южный,12689
385000,Респ,Адыгея,,,г,Майкоп,,,0100000100000,8cfbe842-e803-49ca-9347-1ef90481dd98,4: город,2,79401000000,79701000001,0105,UTC+3,44.6098268,40.1006527,Южный,144055
649000,Респ,Алтай,,,г,Горно-Алтайск,,,0400000100000,0839d751-b940-4d3d-afb6-5df03fdd7791,4: город,2,84401000000,84701000,0400,UTC+7,51.9582681,85.9602957,Сибирский,62861
658125,край,Алтайский,,,г,Алейск,,,2200000200000,ae716080-f27b-40b6-a555-cf8b518e849e,4: город,0,01403000000,01703000,2201,UTC+7,52.4920914,82.7794145,Сибирский,28528
656000,край,Алтайский,,,г,Барнаул,,,2200000100000,d13945a8-7017-46ab-b1e6-ede1e89317ad,4: город,2,01401000000,01701000,2200,UTC+7,53.
require 'cucumber'
require 'selenium-webdriver'
# require 'cukehub' # optional, but recommended. See cukehub.com for more details
caps = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { binary: "/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary",
args: [ "--headless" ]})
Before do
@browser = Selenium::WebDriver.for :chrome, desired_capabilities: caps
end
@itsamoreh
itsamoreh / caps-as-escape
Last active October 29, 2019 15:20
Dconf remap caps as escape - Tested on Ubuntu 16.10
dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:escape']"
@UKNC
UKNC / Install headless Firefox on CentOS 6 for Selenium automation.md
Last active May 5, 2023 15:06
Install headless Firefox on CentOS 6 for Selenium automation

Abstract

In the manual the steps required to install headless Firefox on CentOS 6 are described. Headless Firefox may be needed to perform GUI automated testing.

All steps of this manual have been validated on CentOS 6.8. It should not be a problem to adapt the solution to other distros.

Steps

Upgrade yum

@k1r8r0wn
k1r8r0wn / devise.ru.yml
Last active May 12, 2023 18:47
Russian i18n locale for `Devise` gem
# Русский перевод для https://github.com/plataformatec/devise/tree/v4.7.1
# Другие переводы на https://github.com/plataformatec/devise/wiki/I18n
ru:
devise:
confirmations:
confirmed: "Ваша учётная запись успешно подтверждена."
send_instructions: "В течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи."
send_paranoid_instructions: "Если ваш адрес email есть в нашей базе данных, то в течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи."
failure:
@Val
Val / build_rest-like_api.rb
Created January 19, 2016 14:28
Token protected REST-like API using Grape, Swagger on top of Rails. Based on http://www.toptal.com/ruby/grape-gem-tutorial-how-to-build-a-rest-like-api-in-ruby/
# -*- mode:ruby;tab-width:2;indent-tabs-mode:nil;coding:utf-8 -*-
# vim: ft=ruby syn=ruby fileencoding=utf-8 sw=2 ts=2 ai eol et si
#
# build_rest-like_api.rb: sample REST-like API server
# (c) 2016 Laurent Vallar <val@zbla.net>, WTFPL license v2 see below.
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
@Ravenstine
Ravenstine / reactor.cr
Created September 8, 2015 05:29
A very simple event loop written in Crystal. (crystal-lang.org)
module Reactor
class Task
property :block
def initialize(timestamp=Time.now, milliseconds=0, &block : Loop ->)
@block = block
@timestamp = timestamp.epoch_ms
@milliseconds = milliseconds
end
def run reactor
@maxivak
maxivak / readme.md
Last active January 12, 2024 06:53
Integrating Gem/Engine and Main Rails App
@shuber
shuber / add_index_patch.rb
Created April 1, 2015 07:43
ActiveRecord `add_index` patch for PostgreSQL JSONB GIN indexes
# This patch detects {index_columns} that match something like
# the example below, then strips the surrounding double quotes.
#
# "(settings->'example')"
#
# The resulting CREATE INDEX sql looks something like:
#
# CREATE INDEX "idx_users_on_settings_example" ON "users" USING gin ((settings->>'example'))
#
# Your {add_index} call should looks something like: