Skip to content

Instantly share code, notes, and snippets.

@fobiasmog
fobiasmog / vscode
Created August 24, 2022 12:57
Vscode
Active line color
"workbench.colorCustomizations": {
"editor.lineHighlightBackground": "#39dc4f39",
}
@fobiasmog
fobiasmog / git_notes.md
Last active January 16, 2023 10:47
Git notes

Using not default ssh key

GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_another" git clone ...
# in project root
git config --local core.sshCommand 'ssh -i ~/.ssh/id_rsa_another'

Reset merge commit

git reset --merge HEAD~1
@fobiasmog
fobiasmog / docker_notes.md
Created December 10, 2021 15:04
Docker notes

Стопнуть кучу контейнеров по фильтру

docker ps -f 'name=shop*' --format "{{.ID}}" | xargs -L 1 docker stop
@fobiasmog
fobiasmog / rspec_notes.md
Last active April 22, 2023 13:27
Заметки по Rspec

Проверка того, что один массив хэшей содержится в другом (при этом порядок объявления ключей не важен, в отличии от использования .to eq)

RSpec.describe [{ a:  1 , b:  2 }, { a:  2 , b:  1 }, { c:  11 , d:  22 }] do
  let (:val) { [{ b:  1 , a:  2 }, { c:  11 , d:  22 }] }
  it  { is_expected.to include(*val) }
end

Вызов метода у subject для теста (its выпилили из rspec 3, https://gist.github.com/myronmarston/4503509, тут можно поставить гем https://github.com/dnagir/its)

@fobiasmog
fobiasmog / js_notes.md
Last active March 23, 2023 11:26
Заметки по JS

Рекурсивное получение массива значений в хэше/дереве

import flatMapDeep from 'lodash/flatMapDeep'

function getResponseErrors(errors) {

  function deep(n) {
    if (typeof(n) === 'object') return flatMapDeep(n, deep);
    return n;
}
@fobiasmog
fobiasmog / stylus.md
Created March 23, 2021 20:09 — forked from neretin-trike/stylus.md
Туториал по CSS препроцессору Stylus
@fobiasmog
fobiasmog / ruby.md
Last active September 13, 2023 08:52
Ruby & Rails hacks

Проверка, что все элементы в массиве идут по порядку от 1 до Х

arr.select.with_index { |e, i| e == i+1 }.size == arr.size

extend self

Полезен, когда нужно сделать метод модуля

module X
 extend self
@fobiasmog
fobiasmog / iata.json
Last active November 11, 2022 13:11
Коды стран IATA в формате ISO 3166-1 (двухбуквенная)
[
{
"text":"Австралия",
"value":"AU"
},
{
"text":"Австрия",
"value":"AT"
},
{
@fobiasmog
fobiasmog / nginx.conf
Created June 30, 2019 14:44 — forked from nrollr/nginx.conf
NGINX config for SSL with Let's Encrypt certs
# UPDATED 17 February 2019
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
listen [::]:80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
}
# SSL configuration