Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Artem tyomo4ka

🏠
Working from home
View GitHub Profile
@tyomo4ka
tyomo4ka / virtualenv-auto-activate.sh
Created Aug 20, 2019
Automatically activates .venv
View virtualenv-auto-activate.sh
#!/bin/bash
# virtualenv-auto-activate.sh
#
# Installation:
# Add this line to your .bashrc or .bash-profile:
#
# source /path/to/virtualenv-auto-activate.sh
#
# Go to your project folder, run "virtualenv .venv", so your project folder
# has a .venv folder at the top level, next to your version control directory.
@tyomo4ka
tyomo4ka / postman-prerequest-tyk-hmac.js
Last active Jun 12, 2020
Requests signing using HMAC authentication with TYK Gateway
View postman-prerequest-tyk-hmac.js
# An example of adding requests signature using HMAC authentication with TYK Gateway.
var sdk = require('postman-collection'),
apiKey = environment.api_key,
apiSecret = environment.api_secret,
date = (new Date()).toUTCString(),
signatureContentString = 'date: ' + date,
signatureString = CryptoJS.HmacSHA1(signatureContentString, apiSecret).toString(CryptoJS.enc.Base64),
authHeader = 'Signature keyId="' + apiKey + '",algorithm="hmac-sha1",signature="' + encodeURIComponent(signatureString) + '"';
View test.js
(function() {
console.log(1);
setTimeout(function(){console.log(2)}, 1000);
setTimeout(function(){console.log(3)}, 0);
console.log(4);
})();
@tyomo4ka
tyomo4ka / git-aliases.md
Last active Apr 18, 2020 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup on OS X (brew)
View git-aliases.md

The Ultimate Git Alias Setup on OS X (brew)

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bash_profile
View buttons.js
for (var i = 0; i < 5; i++) {
var btn = document.createElement('button');
btn.appendChild(document.createTextNode('Button ' + i));
btn.addEventListener('click', function(){ console.log(i); });
document.body.appendChild(btn);
}
@tyomo4ka
tyomo4ka / bs-labels-css-truncate.css
Created Feb 15, 2014
GitHubs like behavior for Twitter Bootstrap labels.
View bs-labels-css-truncate.css
span.label.css-truncate {
max-width: 80px;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: middle;
line-height: 1;
padding: 2px 3px;
height: 11px;
}
@tyomo4ka
tyomo4ka / lt_ie_8.js
Created Feb 1, 2014
Approach to run IE specific code when you can not edit HTML code on page directly.
View lt_ie_8.js
var lt_ie_8 = function () {
var div = document.createElement("div");
div.innerHTML = "<!--[if lt IE 8]>]><i></i><![endif]-->";
if (div.getElementsByTagName("i").length) {
return true;
}
return false;
};
You can’t perform that action at this time.