Skip to content

Instantly share code, notes, and snippets.

View slava-vishnyakov's full-sized avatar

Slava Vishnyakov slava-vishnyakov

View GitHub Profile
@slava-vishnyakov
slava-vishnyakov / add-docker-compose-to-phoenix
Created April 22, 2023 11:39
Adds docker-compose.yml and package.json to Phoenix app with postgres exposed on random port
#!/bin/bash
# Generate random ports
postgres_port=$((5000 + RANDOM % 1000))
redis_port=$((7000 + RANDOM % 1000))
elastic_port=$((9000 + RANDOM % 1000))
# Set test ports
postgres_test_port=$((postgres_port + 1))
redis_test_port=$((redis_port + 1))
@slava-vishnyakov
slava-vishnyakov / readme.md
Last active October 11, 2024 03:19
How to upload images with TipTap editor
  1. Create a file Image.js from the source below (it is almost a copy of Image.js from tiptap-extensions except that it has a constructor that accepts uploadFunc (function to be called with image being uploaded) and additional logic if(upload) { ... } else { ... previous base64 logic .. } in the new Plugin section.
import {Node, Plugin} from 'tiptap'
import {nodeInputRule} from 'tiptap-commands'

/**
 * Matches following attributes in Markdown-typed image: [, alt, src, title]
 *
@slava-vishnyakov
slava-vishnyakov / README.md
Last active September 5, 2017 13:38
Laravel Slice Consecutive (like Array#each_cons in Ruby)
@slava-vishnyakov
slava-vishnyakov / _browser_ide_helper.php
Last active June 5, 2020 15:23
Laravel Dusk IDE helpers
<?php
namespace Laravel\Dusk {
class Browser
{
use Concerns\InteractsWithAuthentication,
Concerns\InteractsWithCookies,
Concerns\InteractsWithElements,
Concerns\InteractsWithJavascript,
@slava-vishnyakov
slava-vishnyakov / main.go
Created March 21, 2016 12:56
leaky gorequests
package main
import (
"fmt"
"log"
"os"
"os/exec"
"strings"
"time"
#!/bin/bash
set -o errexit
echo "Removing exited docker containers..."
docker ps -a -f status=exited -q | xargs -r docker rm -v
echo "Removing dangling images..."
docker images --no-trunc -q -f dangling=true | xargs -r docker rmi
@slava-vishnyakov
slava-vishnyakov / README.md
Last active August 29, 2015 14:01 — forked from rezgaa/install_graphite_statsd_ubuntu_precise.sh
Graphite/Statsd installation

After install run

# start statsd
# start graphite

statsd is on 8125 port graphite is on http://127.0.0.1:8080/

% ls
foot.c foot.h foot.o toe.c toe.o
% rm * .o
rm: .o: No such file or directory
% ls
%
@slava-vishnyakov
slava-vishnyakov / gist:4966944
Created February 16, 2013 13:27
Nicer foundation.css layout for Rails 3.2
<!DOCTYPE html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7 ]><html class="ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
@slava-vishnyakov
slava-vishnyakov / youtube.rb
Created November 4, 2012 09:30 — forked from jamieowen/youtube.rb
Octopress Youtube plugin...
# Example:
# {% youtube http://www.youtube.com/watch?v=Awf45u6zrP0 %}
require 'cgi'
require 'uri'
module Jekyll
class Youtube < Liquid::Tag
@width = 640
@height = 390