Skip to content

Instantly share code, notes, and snippets.

View le0pard's full-sized avatar
:octocat:
Simplicity is the soul of efficiency

Oleksii Vasyliev le0pard

:octocat:
Simplicity is the soul of efficiency
View GitHub Profile
@le0pard
le0pard / tribit.md
Last active January 2, 2020 17:57
Tribit алгоритм

Для обработки малых пирамид при применении системы правил и усечении, генерируются индексы соответствующие каждой пирамиде. Эти индексы соответствуют номерам символов входной строки, которые соответствуют пирамиде.

Например: во входной строке символы нумеруются

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

в пирамиде соответствующие индексы будут соответствовать ячейкам

@le0pard
le0pard / test.rb
Created September 22, 2015 20:37
pop3 by ruby from mailtrap
2.2.0 :014 > s.puts "LIST\r"
=> nil
2.2.0 :015 > s.gets
=> "+OK 50 messages (4192565 octets)\r\n"
2.2.0 :016 > s.gets
=> "1 14181\r\n"
2.2.0 :017 > s.gets
=> "2 127\r\n"
2.2.0 :018 > s.gets
=> "3 127\r\n"
@le0pard
le0pard / shell.sh
Created September 22, 2015 20:23
pop3 telnet
telnet ruby-2.2.0
telnet> toggle crlf
Will send carriage returns as telnet <CR><LF>.
telnet> open mailtrap.io 1100
Trying 54.164.81.148...
Connected to mailtrap.io.
Escape character is '^]'.
+OK POP3 ready <190442990.1442953303@mailtrap.io>
USER ***
+OK
require 'net/pop'
raise "args shoud be email ans pass" if ARGV.length < 2
username, password = ARGV[0], ARGV[1]
Net::POP3.start('mailtrap.io', 1100, username, password, true) do |pop|
if pop.mails.empty?
puts 'No mail.'
else
pop.each_mail do |m|
@le0pard
le0pard / lovefield_test.patch
Created May 12, 2015 12:00
lovefield + browserify
diff --git samples/calculator/calculator.html samples/calculator/calculator.html
index 7f80d0c..acfd40b 100644
--- samples/calculator/calculator.html
+++ samples/calculator/calculator.html
@@ -2,11 +2,7 @@
<head>
<title>Calculator</title>
<link rel="stylesheet" type="text/css" href="style.css" />
- <script src="jquery/jquery.min.js"></script>
- <script src="lovefield.js"></script>
@le0pard
le0pard / test.ex
Created June 26, 2014 15:32
Elixir 0.4.1 error
case worker_record do
record = WorkerRecord[at: at, at_queue: at_queue] when is_number(at) and at > timestamp and is_bitstring(at_queue) ->
# do something
_ ->
# do something
end
## I get error:
## cannot invoke remote function Access.get/2 inside match
@le0pard
le0pard / pg_bloat.sql
Last active August 29, 2015 14:01
PG table and indexes bloat
WITH constants AS (
SELECT current_setting('block_size')::numeric AS bs, 23 AS hdr, 4 AS ma
), bloat_info AS (
SELECT
ma,bs,schemaname,tablename,
(datawidth+(hdr+ma-(case when hdr%ma=0 THEN ma ELSE hdr%ma END)))::numeric AS datahdr,
(maxfracsum*(nullhdr+ma-(case when nullhdr%ma=0 THEN ma ELSE nullhdr%ma END))) AS nullhdr2
FROM (
SELECT
schemaname, tablename, hdr, ma, bs,
@le0pard
le0pard / scout_simple_check_ssl.rb
Last active December 16, 2015 09:49
This scout plugin give info about ssl cert, which installed on web server. You can create trigger, which will notify before ssl cert expired.
require 'net/https'
require 'uri'
class SimpleSslCheckPlugin < Scout::Plugin
OPTIONS=<<-EOS
url:
default: https://localhost
EOS
def build_report
# ROUTER
GWS.Router.map (match) ->
#match("/").to("home") # home.handlebars gets rendered automatically and mapped to /
# according to guide the previous logic shouldn't be needed. but it won't work without it
# you can either use model: () -> or
# setupController: (controller, model) ->
# controller.set 'content', model
@le0pard
le0pard / gist:4048375
Created November 9, 2012 21:28
Unicorn config for chef-solo
app_root = '<%= node['app']['web_dir'] %>'
rails_root = "#{app_root}/current"
rails_env = '<%= node['app']['env'] %>'
pid_file = "#{app_root}/shared/tmp/pids/unicorn.pid"
socket_file= "#{app_root}/shared/tmp/sockets/unicorn.sock"
log_file = "#{rails_root}/log/unicorn.log"
username = '<%= node['user']['name'] %>'
group = '<%= node['user']['name'] %>'
old_pid = "#{pid_file}.oldbin"