Skip to content

Instantly share code, notes, and snippets.

View tyomo4ka's full-sized avatar
🏠
Working from home

Artem tyomo4ka

🏠
Working from home
  • Cover Genius
  • Sydney
View GitHub Profile
@tyomo4ka
tyomo4ka / virtualenv-auto-activate.sh
Created August 20, 2019 23:53
Automatically activates .venv
#!/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 May 8, 2023 12:55
Requests signing using HMAC authentication with TYK Gateway
# 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) + '"';
(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 March 19, 2024 22:10 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup on OS X (brew)

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
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 February 15, 2014 13:17
GitHubs like behavior for Twitter Bootstrap labels.
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 February 1, 2014 11:44
Approach to run IE specific code when you can not edit HTML code on page directly.
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;
};
<a href="#">