Skip to content

Instantly share code, notes, and snippets.

View af23me's full-sized avatar
👋

Evghenii M af23me

👋
View GitHub Profile
@af23me
af23me / main.rb
Created May 17, 2024 23:55
Test task for ruby
# Create a fork and workout the solution. do not capture solution here
def find_embedded_word(arr, random_string)
arr.detect do |word|
return word if random_string.include?(word)
random_substring = random_string.scan(/[#{word}]/).join('')
word.split('').all? { |letter| random_substring.slice!(letter) }
end
@af23me
af23me / mac-setup-redis.md
Created May 3, 2020 13:44 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@af23me
af23me / nginx.conf
Created February 6, 2020 20:54 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@af23me
af23me / gist:5bad131506766a69b1749b6b818408fc
Created February 6, 2020 19:37 — forked from caok/gist:4065758
Deploy from a git tag with capistrano
ref: http://nathanhoad.net/deploy-from-a-git-tag-with-capistrano
Deploy from a Git tag with Capistrano
Are you using Capistrano and Git and want to easily deploy from Git tags? It couldn't be simpler
Using Git, tag a new release:
git tag -a 09.10.02.01 -m "Tagging a release"
You can use git tag to list your tags:
@af23me
af23me / request_logger.rb
Created December 30, 2019 23:32 — forked from jugyo/request_logger.rb
Rack middleware for logging all rails request
# Add below into config/application.rb:
#
# config.middleware.use 'RequestLogger'
#
class RequestLogger
def initialize app
@app = app
end
def call(env)
@af23me
af23me / measure.rb
Created May 22, 2019 08:15 — forked from camertron/measure.rb
Measure the memory taken by a Ruby object (by Robert Klemme)
#!/bin/env ruby
# lazy hack from Robert Klemme
module Memory
# sizes are guessed, I was too lazy to look
# them up and then they are also platform
# dependent
REF_SIZE = 4 # ?
OBJ_OVERHEAD = 4 # ?
@af23me
af23me / .rubocop.yml
Created March 27, 2019 12:21 — forked from jhass/.rubocop.yml
My preferred Rubocop config
AllCops:
RunRailsCops: true
# Commonly used screens these days easily fit more than 80 characters.
Metrics/LineLength:
Max: 120
# Too short methods lead to extraction of single-use methods, which can make
# the code easier to read (by naming things), but can also clutter the class
Metrics/MethodLength:
$.ajax({
type: 'POST',
url: "https://sandbox-api.didww.com/v3/orders",
data: JSON.stringify({
data: {
type: "orders",
attributes: {
allow_back_ordering: false,
items: [{
type: "did_order_items",
@af23me
af23me / letsencrypt_2017.md
Created December 20, 2017 08:45 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@af23me
af23me / bootstrap-popover-extension.css
Created December 14, 2017 13:48
Extend Bootstrap 3 Popover positions
.popover.topLeft {
margin-top: -10px;
}
.popover.topLeft .arrow {
bottom: -11px;
left: 20%;
margin-left: -11px;
border-top-color: #999999;
border-top-color: rgba(0, 0, 0, 0.25);