Skip to content

Instantly share code, notes, and snippets.

View azelenets's full-sized avatar
:octocat:
Impossible is nothing

Andrii Zelenets azelenets

:octocat:
Impossible is nothing
View GitHub Profile
def solution(a)
# a.uniq.each { |element| return element if a.count(element).odd? }
a.reduce(:^)
end
@azelenets
azelenets / CyclicRotation.rb
Created April 15, 2022 12:23
CyclicRotation
def solution(a, k)
# write your code in Ruby 2.2
k.times do
last_element = a.pop
a.unshift(last_element)
end
a.compact
end
@azelenets
azelenets / binary_gap.rb
Last active April 15, 2022 12:24
Binary gap
def solution(n)
# write your code in Ruby 2.2
binary_representation = n.to_s(2)
counter = 0
zero_counts = []
binary_representation.split('').each do |element|
if element == '1'
zero_counts << counter
counter = 0
next
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0 (https://spdx.org/licenses/MIT-0.html)
import json
import subprocess
import shlex
import boto3
S3_DESTINATION_BUCKET = "ffmpeg-processed-videos"
SIGNED_URL_TIMEOUT = 7200
@azelenets
azelenets / ruby script to verify and acknowledge Android InApp purchase.rb
Last active April 15, 2022 12:26
Rails script to verify/acknowledge Android In App Purchases
# 1. Add `candy_check` gem (https://github.com/jnbt/candy_check) to the rails `Gemfile`:
`gem 'candy_check'`
#
# 2. Ensure that used Google Service Account have "Financial" permissions;
# 3. Obtain Google service account credentials json file from the Google Cloud Console:
# 2.1. Navigate in the browser to the "https://console.cloud.google.com/iam-admin/serviceaccounts?authuser=1&folder=&organizationId=&project=you-project-name)"
# Don't forget to substiture your-project-name to the URL;
# 2.2. Select apropriate Service account;
# 2.4. Go to `KEYS` tab;
# 2.5. Click on the `ADD KEY` dropdown and select Create new key`;
@azelenets
azelenets / active_admin.rb
Created August 17, 2020 08:09 — forked from jasper502/active_admin.rb
Active Admin, Devise and Pundit
# /config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
# == User Authentication
#
# Active Admin will automatically call an authentication
# method in a before filter of all controller actions to
# ensure that there is a currently logged in admin user.
#
# This setting changes the method which Active Admin calls
@azelenets
azelenets / meta-tags.md
Created March 3, 2020 11:35 — forked from lancejpollard/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
var detectExtension = (extId, installedHook, notInstalledHook) => {
let scriptHtmlTag = document.createElement('script');
scriptHtmlTag.onerror = notInstalledHook;
scriptHtmlTag.onload = installedHook;
document.body.appendChild(scriptHtmlTag);
scriptHtmlTag.src = 'chrome-extension://' + extId + '/manifest.json';
}
detectExtension('EXTENSION_ID', () => { alert('installed') }, () => { alert('not installed'); })
# FIZZBUZZ Game:
# Count from 1 to 50
# output each number, but
# if number is divided by 3, output FIZZ
# if number is divided by 5 — output BUZZ
# if number is divided by 3 and 5 — output FIZZBUZZ
# Expected output:
#
# 1
class CreateDeliveryOrders < ActiveRecord::Migration[5.2]
def up
execute <<-SQL
CREATE TYPE full_address AS
(
google_place_id VARCHAR,
address VARCHAR,
lat NUMERIC,
lng NUMERIC
);