WordPress Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Async version of Array.prototype.reduce() | |
| * await reduce(['/foo', '/bar', '/baz'], async (acc, v) => { | |
| * acc[v] = await (await fetch(v)).json(); | |
| * return acc; | |
| * }, {}); | |
| */ | |
| export async function reduce(arr, fn, val, pure) { | |
| for (let i=0; i<arr.length; i++) { | |
| let v = await fn(val, arr[i], i, arr); | |
| if (pure!==false) val = v; |
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Lodash mixins for combinatorics | |
| * by: wassname & visangela | |
| * url: https://gist.github.com/wassname/a882ac3981c8e18d2556/edit | |
| * lodash contrib issue: https://github.com/node4good/lodash-contrib/issues/47 | |
| * lic: same as lodash | |
| * Inspired by python itertools: https://docs.python.org/2.7/library/itertools.html | |
| * | |
| * Usage: | |
| * permutations([0,1,2],2) // [[0,1],[0,2],[1,0],[1,2],[2,0],[2,1]] |
- Ушел из компании мечты (фейл, пришлось), а потом ее купила Airbnb (вин);
- Запустил второй проект на Эрланге в продакшн (трекер общественного транспорта, щас он уже все);
- Для этого проекта на Эрланге сделал красивое приложение для Windows Phone в продакшн (прям качали с магазина);
- Затащил лучшего друга в программирование, всячески ему помогал и сейчас он уже на зарплате;
- Затащил этот проект с трекингом транспорта в дипломную и защитил на отлично, закончил универ;
- Попал в сильную команду рубистов, там немного научили в DDD и поставили на путь, куда идти дальше в ООП;
- Попал в другую сильную команду рубистов, где хорошо прокачал теорию и практику распределенных систем;
- Возненавидел тех, кто использует Elasticsearch не по назначению (никогда в жизни не устану это повторять, это травма);
- Прокачался во фронтенде (react, babel и все такое модное с БД на клиенте и иммутабельными стейтами);
- Попал в команду ROM, написал два адаптера в продакшн (rom-elasticsearch, rom-redis) и один для себя (rom-rethin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if ($request_method = 'OPTIONS') { | |
| add_header 'Access-Control-Allow-Origin' '*'; | |
| add_header 'Access-Control-Allow-Credentials' 'true'; | |
| add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS, HEAD'; | |
| add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; | |
| add_header 'Access-Control-Max-Age' 1728000; | |
| add_header 'Content-Type' 'text/plain charset=UTF-8'; | |
| add_header 'Content-Length' 0; | |
| return 204; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| The MIT License (MIT) | |
| Copyright (c) 2015 Justin Perry | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of | |
| this software and associated documentation files (the "Software"), to deal in | |
| the Software without restriction, including without limitation the rights to | |
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
| the Software, and to permit persons to whom the Software is furnished to do so, | |
| subject to the following conditions: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " ---------------------------------------------------------------------------- | |
| " vimawesome.com | |
| " ---------------------------------------------------------------------------- | |
| function! VimAwesomeComplete() abort | |
| let prefix = matchstr(strpart(getline('.'), 0, col('.') - 1), '[.a-zA-Z0-9_/-]*$') | |
| echohl WarningMsg | |
| echo 'Downloading plugin list from VimAwesome' | |
| echohl None | |
| ruby << EOF | |
| require 'json' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* bling.js */ | |
| window.$ = document.querySelector.bind(document); | |
| window.$$ = document.querySelectorAll.bind(document); | |
| Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); }; | |
| NodeList.prototype.__proto__ = Array.prototype; | |
| NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); }; |