Skip to content

Instantly share code, notes, and snippets.

View shilovk's full-sized avatar

Kᴏɴsᴛᴀɴᴛɪɴ Sʜɪʟᴏᴠ shilovk

View GitHub Profile
// Функция для извлечения URL изображения из описания
function getImageSrc(descriptionBody) {
let parser = new DOMParser();
let doc = parser.parseFromString(descriptionBody, 'text/html');
let imageElement = doc.querySelector('action-text-attachment[content-type^="image"]');
return imageElement ? imageElement.getAttribute('url') : null;
}
$('#tree').jstree({
'core': {
@shilovk
shilovk / moveable_location.rb
Last active March 8, 2024 22:08
For example: `locations` have many `trains`, `copters`, `trucks`, `ships`. And `trains`, `copters`, `trucks`, `ships` have many `locations`.
#db/migrations/create_moveable_locations.rb
class CreateMoveableLocations < ActiveRecord::Migration
def change
create_table :moveable_locations do |t|
t.references :moveable, polymorphic: true
t.references :location
t.timestamps
end
@shilovk
shilovk / openconnect.md
Created September 13, 2022 19:16 — forked from moklett/openconnect.md
OpenConnect VPN on Mac OS X

Unfortunately, the Cisco AnyConnect client for Mac conflicts with Pow. And by "conflicts", I mean it causes a grey-screen-of-death kernel panic anytime you connect to the VPN and Pow is installed.

As an alternative, there is OpenConnect, a command-line client for Cisco's AnyConnect SSL VPN.

Here's how to get it set up on Mac OS X:

  1. OpenConnect can be installed via homebrew:

     brew update
    

brew install openconnect

@shilovk
shilovk / example.md
Last active July 18, 2022 20:41 — forked from sdnts/example.md
Postman pm.sendRequest example

To send a request via the sandbox, you can use pm.sendRequest.

pm.test("Status code is 200", function () {
    pm.sendRequest('https://postman-echo.com/get', function (err, res) {
        pm.expect(err).to.not.be.ok;
        pm.expect(res).to.have.property('code', 200);
        pm.expect(res).to.have.property('status', 'OK');
    });
});
@shilovk
shilovk / ffmpeg-install.sh
Created December 21, 2021 15:35 — forked from clayton/ffmpeg-install.sh
Install FFMPEG on OS X with HomeBrew to convert Mp4 to WebM
# Installation
brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid
# Easy Peasy
ffmpeg -i video.mp4 video.webm
@shilovk
shilovk / decider.rb
Created October 20, 2021 16:20 — forked from TimothyClayton/decider.rb
RSpec easy loop testing
# frozen_string_literal: true
class Decider
def self.undecided
loop do
break if decision?
end
end
def self.decision?
# code yielding true or false
@shilovk
shilovk / psql_drop_tables_by_user.sh
Last active July 12, 2021 09:17 — forked from dsci/drop.sh
Dropping tables in a PostgreSQL database by table owner
# first, login with psql
psql -U user_name -W -d database_name -h ip_address
# set output for all queries
\o file_name.sql
# run this query
select 'drop table if exist "'|| tablename ||'" cascade;' from pg_tables where tableowner='user_name' and schemaname='public';
# logout from psql
@shilovk
shilovk / curl.md
Created June 9, 2021 17:34 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

Setup

Replace IRB with Pry (in your Gemfile) and Byebug with pry-byebug.

gem 'pry-rails', group: [:development, :test]
gem 'pry-byebug', group: [:development, :test]

Using PRY

@shilovk
shilovk / BootstrapToRails6.md
Created April 10, 2021 13:12 — forked from nachozt/BootstrapToRails6.md
Bootstrap to Rails 6 with webpacker

Step 1:

Add bootstrap and its dependencies:

yarn add bootstrap jquery popper.js

Step 2:

in config/webpack/environment.js add the following: