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 / Dockerfile
Created February 13, 2019 19:33
Minimal image to be used as Kubernetes default backend as maintenance page
FROM nginx:stable-alpine
COPY default.conf /etc/nginx/conf.d/default.conf
COPY maintenance.html /usr/share/nginx/html/
AllCops:
TargetRubyVersion: 2.5
Style/AsciiComments:
Enabled: false
Metrics/LineLength:
Max: 120
@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 / 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 / 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
@Envek
Envek / photo-touch.rb
Created May 8, 2012 02:45
Script for changing photo creation timestamp (in EXIF metadata and filesystem) in all jpeg's in current directory.
#!/usr/bin/ruby
# encoding: utf-8
#
# Script for changing photo creation timestamp (in EXIF metadata and filesystem)
# If you're using rvm, please run script as `ruby photo-touch.rb`
# Tested in ruby-1.9.3-p125 and ree-1.8.7-2012.02
#
# Install ExifTool: http://www.sno.phy.queensu.ca/~phil/exiftool/install.html
#
# You need next gems for script to work (use gem install gem_name)
@Envek
Envek / README
Created August 14, 2011 03:07
Demo page for interaction between HTML5 and SVG.
Demo page, shows interaction between HTML page and embedded SVG.
Browsers with SVG support (incomplete list): IE 9+, Opera 8+, Firefox 1.5+, Chrome
Due to 'same origin policy' in modern browsers, it's recommended to run web server. For example, run 'python -m SimpleHTTPServer' from this directory and visit http://localhost:8000/
For converting SVG to PNG, I recommend to use "rsvg-convert" command from "librsvg2-bin" package. Run in console something like this: cat map.svg | rsvg-convert > map.png
@Envek
Envek / maxprimemultiplier.cpp
Created July 13, 2011 11:47
Calculate maximum prime multiplier of number
#include <iostream>
#include <inttypes.h>
#include <math.h>
using namespace std;
uint64_t maxPrimeMul (uint64_t num);
bool isPrime (uint64_t num);
int main () {
uint64_t num; // = 600851475143;