Skip to content

Instantly share code, notes, and snippets.

View aablinov's full-sized avatar

Andrey Blinov aablinov

  • Uscreen.tv
  • Cyprus
View GitHub Profile
@aablinov
aablinov / dropzone_controller.js
Created May 26, 2023 06:12 — forked from lazaronixon/_form.html.erb
Dropzone.js + Stimulus + Active Storage
import { Controller } from "stimulus"
import { DirectUpload } from "@rails/activestorage"
import Dropzone from "dropzone"
import { getMetaValue, findElement, removeElement, insertAfter } from "helpers"
Dropzone.autoDiscover = false
export default class extends Controller {
static targets = [ "input" ]
import * as React from "react";
import { useMousePosition } from "~/hooks/useMousePosition";
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) {
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {};
const [mouseX, mouseY] = useMousePosition();
const positions = { x, y, h, w, mouseX, mouseY };
return (
<div
@aablinov
aablinov / remove_file.rb
Created October 26, 2020 08:21 — forked from gjtorikian/remove_file.rb
How to remove a file from a subdirectory using the GitHub API v3
#!/usr/bin/env ruby
require 'octokit'
# !!! DO NOT EVER USE HARD-CODED VALUES IN A REAL APP !!!
login = ENV['GH_LOGIN']
password = ENV['GH_LOGIN_PASSWORD']
repo = "gjtorikian/crud-test"
master = client.ref(repo, "heads/master")
### DigitalOcean Ubuntu 18.04 x64 + Rails 5 + Nginx + Unicorn + PostgreSQL9.6 + Capistrano 3
SSH into Root
$ ssh [email protected]
Change Root Password
$ passwd
@aablinov
aablinov / dry_monads_with_handler.rb
Created February 20, 2019 13:06 — forked from davydovanton/dry_monads_with_handler.rb
dry_monads_with_handler
def result_handler(result)
case result
when Success, Some
puts 'success, user created'
when Failure { |message, _| message == :http_error }
puts "HTTP request error, #{result.failure[2]}"
when Failure { |message, _| message == :validation_error }
puts "validation error, #{result.failure[2]}"
when Failure(ROM::Error)
puts 'User not created'
@aablinov
aablinov / Gemfile
Created February 27, 2018 20:08 — forked from octoberstorm/Gemfile
Rails upload using Carrierwave + Fog + Openstack Swift
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.3'
gem 'sqlite3'
gem "rmagick"
gem "carrierwave"
gem "fog"
@aablinov
aablinov / Caddyfile
Created February 27, 2018 19:37 — forked from jpoehls/Caddyfile
Proxy + Static File serving with caddy
# Caddyfile
localhost:2015 {
startup "go run ./server.go" &
root ./static_files
proxy / localhost:2016
}
# FILE TREE
#