Skip to content

Instantly share code, notes, and snippets.

View ston1x's full-sized avatar
AeroPressing

Nicolai Stoianov ston1x

AeroPressing
View GitHub Profile
@ston1x
ston1x / script.js
Created May 24, 2022 21:55
VK export songs
// Took from https://github.com/fivemru/export-vk-playlist-to-file
(async () => {
const scroll = (top) => window.scrollTo({ top });
const delay = (ms) => new Promise((r) => setTimeout(r, ms));
async function loadFullPlaylist() {
const spinner = document.querySelector('.CatalogBlock__autoListLoader');
let pageHeight = 0;
do {
pageHeight = document.body.clientHeight;
@ston1x
ston1x / DependencyInjectionInRuby.md
Created October 17, 2020 12:09 — forked from blairanderson/DependencyInjectionInRuby.md
Dependency Injection in Ruby. Originally from Jim Weirich’s blog which does not exist except for googles cache.

Dependency Injection in Ruby 07 Oct 04

Introduction

At the 2004 Ruby Conference, Jamis Buck had the unenviable task to explain Dependency Injection to a bunch of Ruby developers. First of all, Dependency Injection (DI) and Inversion of Control (IoC) is hard to explain, the benefits are subtle and the dynamic nature of Ruby make those benefits even more marginal. Furthermore examples using DI/IoC are either too simple (and don’t convey the usefulness) or too complex (and difficult to explain in the space of an article or presentation). I once attempted to explain DI/IoC to a room of Java programmers (see onestepback.org/articles/dependencyinjection/), so I can’t pass up trying to explain it to Ruby developers.

Thanks goes to Jamis Buck (the author of the Copland DI/IoC framework) who took the time to review this article and provide feedback.

What is Dependency Injection?

@ston1x
ston1x / gist:d91701ab9bfe93e2e188d52eb154cbcf
Created June 14, 2020 19:45 — forked from rkumar/gist:445735
ruby's OptionParser to get subcommands
#!/usr/bin/env ruby -w
## Using ruby's standard OptionParser to get subcommand's in command line arguments
## Note you cannot do: opt.rb help command
## other options are commander, main, GLI, trollop...
# run it as
# ruby opt.rb --help
# ruby opt.rb foo --help
# ruby opt.rb foo -q
# etc
@ston1x
ston1x / kill_unicorn.sh
Last active May 26, 2020 19:52
Kill unicorn process
#!/bin/bash
function kill_unicorn() {
kill $(ps aux | grep "unicorn master" | grep -v "grep" | awk '{print $2}' | tail -1)
}
@ston1x
ston1x / vim_humanize_fix_message.md
Last active February 7, 2020 11:01
vim • Humanize FIX message

🏦

Imagine you have a long line of FIX message:

"8=FOO.4.2\u00019=73\u000135=XyZ\u000149=BRKR\u000156=INVMGR\u000134=235\u000152=19980604-07:58:28\u0001112=19980604-07:58:28\u000110=235\u0001"

And you need to humanize it in order to be able to read each field like this:

8=FOO.4.2
9=73
35=XyZ
### Keybase proof
I hereby claim:
* I am ston1x on github.
* I am stoniques (https://keybase.io/stoniques) on keybase.
* I have a public key ASCkQIcKDEN_9SgAf6x3PdVC6fuLcNEvrj5mIdGDZ6qIGwo
To claim this, I am signing this object:
@ston1x
ston1x / gist:5a92c4f55197daac778c7a2a050f064e
Last active February 14, 2019 10:13
Quick notes in vim
# Write a quick note and instantly stash it to a place where all your quick
# thoughts can be stored to sort them out later.
# Can be added to your .bashrc / .zshrc / etc.
function stash_note {
echo $(date; cat ~/note) >> ~/notes && cat /dev/null > ~/note
}
alias notes='vim ~/notes'
alias note='vim ~/note && stash_note'