Skip to content

Instantly share code, notes, and snippets.

View alexesDev's full-sized avatar

Alexey Yurchenko alexesDev

  • Digital Nomad
View GitHub Profile
require 'arbre'
require 'benchmark'
def generate_html
context = Arbre::Context.new do
100000.times do |i|
div class: 'article' do
div "Article #{i}", class: 'article__title'
div "Awesome content", class: 'article__content'
end
@alexesDev
alexesDev / patch.rb
Created May 21, 2019 07:33
ERR Client sent AUTH, but no password is set
class Redis
class Client
class Connector
class Sentinel
def sentinel_detect
@sentinels.each do |sentinel|
client = Client.new(@options.merge({
:host => sentinel[:host],
:port => sentinel[:port],
:password => sentinel[:password], # patch!
@alexesDev
alexesDev / .dockerignore
Last active May 17, 2019 09:45
Multi-stage Dockerfile for Rails 5.2
.git
.gitignore
Dockerfile
log
tmp
public/system
#include "GridRenderer.h"
#include <Magnum/SceneGraph/Camera.h>
#include <Magnum/DebugTools/ResourceManager.h>
using namespace Magnum;
Color3 getLineColor(Float i, const Color3 &baseColor, const Color3 &axesColor, const Color3 &subColor) {
if (i == 0) {
return axesColor;
@alexesDev
alexesDev / main.go
Last active October 18, 2018 19:52
golang http server template
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"sync/atomic"
"time"
function calculateInterceptShotPosition(pShooter, pTarget0, vTarget, sProjectile)
local R = pTarget0 - pShooter
local a = vTarget.x^2 + vTarget.y^2 - sProjectile^2
local b = 2 * (R.x * vTarget.x + R.y * vTarget.y)
local c = R.x^2 + R.y^2
if R:len2() < 1 then
return nil
end
#!/bin/bash
read -r -d '' CHECK_QUERY <<-EOM
create extension if not exists plpgsql_check;
SELECT
(pcf).functionid::regprocedure, (pcf).lineno, (pcf).statement,
(pcf).sqlstate, (pcf).message, (pcf).detail, (pcf).hint, (pcf).level,
(pcf)."position", (pcf).query, (pcf).context
@alexesDev
alexesDev / ProgressButton.js
Created August 15, 2018 12:10
antd + recompact: If the function passed in via the onClick prop return a Promise or if a promise is passed as an argument of the loading method, the component will automatically transition to its success or error states based on the outcome of the Promise without the need for external manipulation of state using a ref.
import { Button } from 'antd';
import { compose, omitProps, withState, withHandlers } from 'recompact';
const enhance = compose(
withState('loading', 'setLoading', false),
withHandlers({
onClick: props => e => {
if (!props.onClick) {
return;
}
@alexesDev
alexesDev / search.sql
Created August 13, 2018 12:35
PostgreSQL: search a top-level root parent id
with recursive r as (
select id, parent_id
from products
where id = 100
union
select p.id, p.parent_id
from products p
join r on p.id = r.parent_id
)
select id from r where parent_id is null;
@alexesDev
alexesDev / deploy.tmpl
Created August 4, 2018 20:18
createteable sqitch template ~/ .sqitch/templates
-- Deploy [% project %]:[% change %] to [% engine %]
[% FOREACH item IN requires -%]
-- requires: [% item %]
[% END -%]
[% FOREACH item IN conflicts -%]
-- conflicts: [% item %]
[% END -%]
BEGIN;