Skip to content

Instantly share code, notes, and snippets.

View john45's full-sized avatar
♦️

Eugene john45

♦️
  • Everlabs
  • Ukraine, Cherkassy
View GitHub Profile
# You have an array of ints. Create function which groups numbers by sum of pairs
# (for example: sum = 5). Each element of array has to be used only once.
# function getPairs(arr, sum) {
# // ...
# }
# ---
# test data:
# input: [22, 3, 5, 0, 2, 2]
# resutls: [[3, 2], [5, 0]]
# input: [-5, 33, 2, 2, 3, 5, 0, 10, 3]
@john45
john45 / everbot_nginx.config
Created April 23, 2019 09:11
nginx rule for everlabs bot
upstream everbot-puma {
server unix:///home/deployer/apps/everbot/tmp/sockets/puma.sock fail_timeout=0;
}
server {
server_name bot.everlabs.com;
root /home/deployer/apps/everbot;
try_files $uri/index.html $uri @everbot-puma;
@john45
john45 / puma_autostart_autoreload
Created April 15, 2019 21:00
autostart puma through systemd
1. create file in /etc/systemd/system/<your-puma>.service
[Unit]
Description=Puma HTTP Server Everbot
After=network.target
[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple
@john45
john45 / client_check.rb
Last active December 19, 2018 10:32
check clients emails and add to correct or incorrect. Last two parts from one system
require_relative 'log_to_db'
require_relative '../models/log_record'
require_relative '../models/report'
class ClientCheck
attr_accessor :users, :correct_users, :incorrect_users
def initialize(users)
@users = users
@john45
john45 / geo.js
Last active March 25, 2018 19:36
geo
var addressPoints = [
[55.626808,37.745056,"2018-03-25 05:51:15 +0300","completed"],
[55.61932,37.719244,"2018-03-25 08:06:19 +0300","cancelled"],
[55.781224,37.450152,"2018-03-25 08:51:00 +0300","cancelled"],
[55.744244,37.56178,"2018-03-25 09:11:32 +0300","cancelled"],
[55.798368,37.569148,"2018-03-25 09:01:15 +0300","cancelled"],
[55.612116,37.61782,"2018-03-25 09:02:11 +0300","cancelled"],
[55.854308,37.408488,"2018-03-25 09:02:15 +0300","cancelled"],
[55.827344,37.649724,"2018-03-25 08:56:00 +0300","cancelled"],
[55.601236,37.61794,"2018-03-25 09:32:21 +0300","cancelled"]
@john45
john45 / active_admin.en.yml
Created March 13, 2018 15:15 — forked from mreigen/active_admin.en.yml
Add "not equals" option to ActiveAdmin string filter
# in my experience, adding this will duplicate the filter list next to the input
en:
active_admin:
filters:
predicates:
not_eq: "Not equals"
@john45
john45 / location_config
Created January 15, 2018 15:12
nginx config for two upstrim
upstream app_1 { server unix:/home/deployer/apps/first_app/tmp/sockets/puma.sock fail_timeout=0; }
upstream app_2 { server unix:/home/deployer/apps/second_app/tmp/sockets/puma.sock fail_timeout=0; }
server {
listen 80;
server_name some.domen.ru;
return 301 https://$server_name$request_uri;
}