Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Envek's full-sized avatar
☮️
Stop the war | Нет войне!

Andrey Novikov Envek

☮️
Stop the war | Нет войне!
View GitHub Profile
@Envek
Envek / keybase.md
Created May 26, 2015 08:17
Identity proof for keybase.io

Keybase proof

I hereby claim:

  • I am Envek on github.
  • I am envek (https://keybase.io/envek) on keybase.
  • I have a public key whose fingerprint is 5439 E3DC F03F 4317 524E E679 301A D540 0512 05A2

To claim this, I am signing this object:

@Envek
Envek / dnsmaster-update.sh
Last active August 12, 2017 23:55
Updates A and/or AAAA DNS records in DNS Master provider of Dynamic DNS. Works on Linux and OS X.
#!/bin/sh
usage() {
echo "DNS Master DynDNS update script. Updates A and/or AAAA records with public IPs that you have on your interfaces."
echo "Usage: $0 -h hostname[,hostname…] -u username -p password"
}
if [ $# -eq 0 ]; then usage; exit 1; fi
USERNAME=""
@Envek
Envek / Gemfile
Created February 3, 2015 14:14
Temporary script to get GLONASS/GPS data from Skuapso PSQL module: https://github.com/skuapso/psql
source "https://rubygems.org"
gem "pg"
gem "activesupport"
@Envek
Envek / timezones.ru.rb
Last active August 19, 2023 19:40
Full list of russian time zones for Ruby on Rails
# Full list of Russian Federation time zones with helper to get this list.
# Place this file in config/initializers/timezones.ru.rb
class ActiveSupport::TimeZone
@country_zones = ThreadSafe::Cache.new
def self.country_zones(country_code)
code = country_code.to_s.upcase
@country_zones[code] ||=
TZInfo::Country.get(code).zone_identifiers.select do |tz_id|
@Envek
Envek / pg_interval_support_4_1.rb
Last active December 18, 2023 14:41
Enables PostgreSQL interval datatype support (as ActiveSupport::Duration) in Ruby on Rails from 4.1 to 6.0
# Enables PostgreSQL interval datatype support (as ActiveSupport::Duration) in Ruby on Rails 4.1.
# Based on https://gist.github.com/clarkdave/6529610
require 'active_support/duration'
# add a native DB type of :interval
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:interval] = { name: 'interval' }
# add the interval type to the simplified_type list. because this method is a case statement
# we can't inject anything into it, so we create an alias around it so calls to it will call
@Envek
Envek / ruby_enable_gost.patch
Created July 26, 2014 11:57
Enable GOST cryptoalgorithms support in Ruby, patch for Rbenv
--- ext/openssl/ossl.c
+++ ext/openssl/ossl.c
@@ -1048,6 +1048,7 @@ Init_openssl()
*/
/* CRYPTO_malloc_init(); */
/* ENGINE_load_builtin_engines(); */
+ OPENSSL_config(NULL); /* Makes Ruby respect system OpenSSL config */
OpenSSL_add_ssl_algorithms();
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
@Envek
Envek / pg_schema_dump_pkey_bug_test.rb
Created July 9, 2014 19:45
ActiveRecord::SchemaDumper does not correctly dump UUID primary keys (when you use not uuid-ossp but pgcrypto)
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'rack', github: 'rack/rack'
gem 'pg'
GEMFILE
system 'bundle'
@Envek
Envek / test_counter_cache_with_default_scope.rb
Created November 19, 2013 15:19
Self-contained gist for Ruby on Rails bug report
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.0.1'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
@Envek
Envek / status2tv.sh
Last active December 19, 2015 05:49
Script for creating videos from printed html page. Each printed page — separate videofile.
#!/bin/bash
# Beautiful script, that creates videos from printed html.
# Authors: Andrey Novikov, Olga Kosolapova, Timofey Karev
# Distributed AS IS under terms of MIT License
#
# Required packages:
# wkhtmltopdf : ~> 0.11.rc1
# imagemagick :
# libav || ffmpeg : (with mpeg2video codec)
@Envek
Envek / test_8217.rb
Created April 11, 2013 04:41
Test case for issue rails/rails#8217
unless File.exists?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'sqlite3'
GEMFILE
system 'bundle'
end