Skip to content

Instantly share code, notes, and snippets.

View merqlove's full-sized avatar

Alexander Merkulov merqlove

View GitHub Profile
@merqlove
merqlove / optimization.rake
Created January 9, 2015 13:55
PostgreSQL optimization tasks for ActiveRecord
namespace :optimization do
desc "Provide DB vacuum for production environment"
task :vacuum => :environment do
begin
tables = ActiveRecord::Base.connection.tables
tables.each do |table|
ActiveRecord::Base.connection.execute("VACUUM FULL ANALYZE #{table};")
end
rescue Exception => exc
Rails.logger.error("Database VACUUM error: #{exc.message}")
@merqlove
merqlove / README.md
Last active March 19, 2023 23:17
ESIA gost certs

Требования

  1. Алгоритм формирования электронной подписи должен быть RS256 (указывается в настройках ИС на технологическом портале).

Как запустить пример

Для ОС Windows 10 необходимо установить Windows Subsystem for Linux и Ubuntu 18.04 в нём.
Действия выполняются внутри терминала этой ОС.
Для ОС Windows Server 2008 R2 необходимо установить OpenSSL 1.1.1g Win64. А также установить библиотеку gost.dll сборка и настройка по инструкции

@merqlove
merqlove / iconv_install_ubuntu14.sh
Last active August 25, 2021 10:28 — forked from paulczar/gist:5493708
Install libiconv on Ubuntu 14.04
--- srclib/stdio.in.h.orig 2011-08-07 16:42:06.000000000 +0300
+++ srclib/stdio.in.h 2013-01-10 15:53:03.000000000 +0200
@@ -695,7 +695,9 @@
/* It is very rare that the developer ever has full control of stdin,
so any use of gets warrants an unconditional warning. Assume it is
always declared, since it is required by C89. */
-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+#endif
@merqlove
merqlove / file_io.rb
Created July 25, 2019 08:35
RUBY Buffered File Reader by Char
class FileIO
def initialize(filename, buffer_size: 50)
@filename = filename
@buffer = ""
@buffer_size = buffer_size
end
def each(&block)
File.open(@filename, 'r') do |f|
f.each_char do |c|
@merqlove
merqlove / multilabel_svm.py
Last active October 26, 2017 07:45
NN SVM SCIKIT-LEARN
#!/usr/bin/env python
import numpy as np
from sklearn.pipeline import Pipeline
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.svm import SVC
from sklearn.feature_extraction.text import TfidfTransformer
from sklearn.multiclass import OneVsRestClassifier
@merqlove
merqlove / publisher.ex
Last active July 12, 2017 23:28
Elixir AMQP resilent publisher
defmodule Publisher do
use GenServer
use AMQP
require Logger
@amqp [host: "localhost", port: "5682"]
@reconnect_timeout 5000
def start_link() do
@merqlove
merqlove / pip_uninstall_azure.sh
Created June 2, 2017 12:32
Uninstall package list from pip with grep
pip uninstall $(pip list --format json | jq -r ".[]|.name" | grep ^azure | paste -sd ' ' -) -y
@merqlove
merqlove / mounter.rb
Last active May 27, 2017 07:26
Mount all disks, provide selected filesystem & partition type with Chef, works for Azure & co
#
# Cookbook Name:: some
# Definition:: mounter
#
# Copyright (C) 2017 Alexander Merkulov
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1
@merqlove
merqlove / phoenix_ng2.ts
Last active March 6, 2017 14:09
Phoenix provider with Angular2
import {Injectable, OpaqueToken, Inject} from '@angular/core';
import * as PhoenixBase from 'phoenix/web/static/js/phoenix.js';
import {Channel, Socket} from 'phoenix/web/static/js/phoenix.js';
import {Observable} from 'rxjs/Observable';
import {isFunction} from 'lodash';
import {Observer} from 'rxjs/Observer';
import {LoggerService} from './';
export declare class Timer {
callback: any;