Skip to content

Instantly share code, notes, and snippets.

View dapi's full-sized avatar
🌴
Open for offers

Danil Pismenny dapi

🌴
Open for offers
View GitHub Profile
@dapi
dapi / invoice.pdf.erb
Created July 26, 2019 15:26
Invoce PDF
<!doctype html>
<html>
<head>
<meta charset='utf-8' />
<style>
body {
font-size: 12px;
}
table {
border-collapse: collapse;
@dapi
dapi / ya_counter_finder.js
Last active December 10, 2019 07:28
Находит наименование первого яндекс счетчика установленного на сайте через JavaScript
Object.getOwnPropertyNames( window ).find(function(str) { return str.includes('yaCounter'); })
@dapi
dapi / flash.coffee
Last active December 10, 2019 07:28
# Author: Danil Pismenny https://github.com/dapi
#
# Install:
#
# add gem 'rails-assets-noty' with source 'https://rails-assets.org'
#
# Usage:
#
# window.Flash.show('error', 'message')
#
@dapi
dapi / request_with_subdomain.rb
Last active December 10, 2019 07:26
Add request subdomain for rspec
# Это такой замысловатый спосбо добавить поддомен в запрос для rspec
#
# Использовать:
#
# RSpec.configure do |config|
# config.include ProcessWithRequestSubdomain, type: :controller
#
module ProcessWithRequestSubdomain
extend ActiveSupport::Concern
# Это такой замысловатый спосбо добавить поддомен в запрос для rspec
#
# Использовать:
#
# RSpec.configure do |config|
# config.include ProcessWithRequestSubdomain, type: :controller
#
module ProcessWithRequestSubdomain
extend ActiveSupport::Concern
@dapi
dapi / list_queries.sql
Created June 7, 2017 11:45
Finding and killing long running queries on PostgreSQL
SELECT pid, now() - query_start as duration, query, state FROM pg_stat_activity WHERE now() - query_start > interval '5 minutes';
;; cancel
SELECT pg_cancel_backend(__pid__);
;; kill stucked
SELECT pg_terminate_backend(__pid__);
class SpfChecker
Response = Struct.new(:correct, :spf_value, :message)
def initialize(value)
@value
end
def check(domain)
result = Net::DNS::Resolver.start(domain, Net::DNS::TXT)
values = result.each_mx.map(&:txt)
@dapi
dapi / SSL_OCSP_Stapling.conf
Last active October 17, 2019 21:50
nginx ssl conf
# Проверка HTTPS на Comodo:
# https://sslanalyzer.comodoca.com/?url=https%3A%2F%2Fkiiiosk.ru
# Проверка на Trusted
# https://www.digicert.com/help/
# source:
# https://support.comodo.com/index.php?/Default/Knowledgebase/Article/View/1091/1/certificate-installation--nginx
ssl_stapling on;
@dapi
dapi / gist:6a9d61e95019b4f5666a
Created December 4, 2015 05:24
Виджет для upload
<script type="text/javascript">
window.art=window.art||[],art.load=function(t,r){art.appId=t,art.config=r=r||{};var e=r.forceSSL||"https:"===document.location.protocol,a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src="http://cdn.1clickanalytics.ru/widget.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n);for(var o=function(t){return function(){art.push([t].concat(Array.prototype.slice.call(arguments,0)))}},c=["clearEventProperties","identify","setEventProperties","track","unsetEventProperty"],s=0;s<c.length;s++)art[c[s]]=o(c[s])},art.load("100003");
</script>
@dapi
dapi / find_ordered.rb
Last active December 10, 2019 07:20
Ordered find record by intarray in Postgresql with Rails
# Find ordered record for postgresql in Rails
# enable_extension "intarray"
module FindOrdered
extend ActiveSupport::Concern
included do
scope :find_ordered, ->(ids) { where(id: ids).order("idx(ARRAY#{ids}::integer[], id)") }
end
end