Skip to content

Instantly share code, notes, and snippets.

View antonlvovych's full-sized avatar

Anton Fedulov antonlvovych

View GitHub Profile
@antonlvovych
antonlvovych / readme
Last active February 28, 2024 02:21
NVM on fish shell using bass
# Install NVM manually (https://github.com/creationix/nvm)
# Install bass (https://github.com/edc/bass)
# Add code below to your config.fish
function nvm
bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv
end
nvm use default --silent
@antonlvovych
antonlvovych / script.js
Last active April 30, 2020 08:46
LinkedIn skill endorsements
// This script will help you to endorse all skills w/o manual clicking on each
// Open target LinkedIn profile and paste code below in browser's console
Array.from(document.querySelectorAll('.pv-skill-entity__featured-endorse-button-shared')).filter(e => e.ariaPressed === 'false').forEach(e => e.click())
@antonlvovych
antonlvovych / 1-try-catch.js
Last active October 22, 2015 22:22
Wraps and executes the passed function into try-catch
function tryCatch (/* fn, context, arguments */) {
var args = Array.prototype.slice.call(arguments);
var fn = args[0];
var context = args[1];
args = args.slice(2, args.length);
try {
fn.apply(context, args);
} catch (e) {
@antonlvovych
antonlvovych / root.js
Last active June 21, 2024 17:35
Get root path of node.js application
var path = require('path');
module.exports = (function () {
return path.dirname(require.main.filename || process.mainModule.filename);
})();
// Example of usage:
var root = require('root'); // In root will be absolute path to your application
@antonlvovych
antonlvovych / uri-parser.js
Last active October 22, 2015 22:23 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@antonlvovych
antonlvovych / git-convention
Last active November 15, 2017 20:26
Convention for git commit messages
EXAMPLE OF FULL-FETURED COMMIT MESSAGE:
================================================================================
EMKT-0000: Summarize changes in around 50 characters or less | <-- COMMIT SUBJECT
More detailed explanatory text, if necessary. Wrap it to about 72 |
characters or so. In some contexts, the first line is treated as the |
subject of the commit and the rest of the text as the body. The blank |
line separating the summary from the body is critical (unless you omit |
the body entirely); various tools like `log`, `shortlog` and `rebase` |
@antonlvovych
antonlvovych / console-log-wrapper.js
Last active August 29, 2015 14:18
Simple console.log wrapper with colors and labels
;(function () {
var options = {
name: 'logger',
label: '❤',
date: true,
color: '#2980b9'
};
window[options.name] = function () {
var label = options.label + (options.date ? ('[' + Date() + ']') : '')
, _arg = [];
@antonlvovych
antonlvovych / user-catcher.js
Created April 5, 2015 11:45
Catches user once at any of defined on node events
var userCatched = 0;
var handler = function (e) {
if (!userCatched) {
userCatched = !0;
console.log('You\'re catched!');
} else {
document.removeEventListener(e.type, arguments.callee);
}
}
// A list of possible usernames to reserve to avoid
// vanity URL collision with resource paths
// It is a merged list of the recommendations from this Quora discussion:
// http://www.quora.com/How-do-sites-prevent-vanity-URLs-from-colliding-with-future-features
// Country TLDs found here:
// http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains//Country_code_top-level_domains
// Languages found here:
@antonlvovych
antonlvovych / _font-face.scss
Last active April 9, 2018 16:48
A Sass mixin to take the pain out of creating bullet-proof @font-face declarations.
// Generate @font-face
//
// $font-base-path {String} - path to fonts directory relative to CSS location
// $font-family {String} - font-family (w/o spaces)
// $font-weight {Number} - font-weight
// $font-style {String} - font-style (default: normal)
//
// File path & file name are based on font props which we include.
// Examples of path mapping:
// @include font-face("../../fonts/", "open-sans", 300); => ../../fonts/open-sans/300/open-sans-300.*