Skip to content

Instantly share code, notes, and snippets.

View caryfuk's full-sized avatar
😱

Pavel Moravec caryfuk

😱
View GitHub Profile
var html = [
'<div>',
<span class="monster">ahoj</span>,
'</div>'
].join('');
@caryfuk
caryfuk / getPosition.js
Last active June 25, 2021 16:24
alternative to Element.getBoundingClientRect() by https://github.com/kirupa
function getPosition(elm) {
var xPos = 0, yPos = 0;
while(elm) {
xPos += (elm.offsetLeft - elm.scrollLeft + elm.clientLeft);
yPos += (elm.offsetTop - elm.scrollTop + elm.clientTop);
elm = elm.offsetParent;
}
return { x: xPos, y: yPos };
.ellipsis {
width: whatever;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
@caryfuk
caryfuk / typewriter.js
Last active March 1, 2016 10:36
typewriter effect using es6 spread
(function() {
let textNode, elm,
textWrapper = document.getElementById('content'),
text = [...textWrapper.textContent];
// clear content of the node
while(textWrapper.hasChildNodes()) {
textWrapper.removeChild(textWrapper.lastChild);
}
### Terminal Syntax Highlighting
# Setup: "brew install highlight"
# Pipe Highlight to less
export LESSOPEN="| $(which highlight) %s --out-format xterm256 --line-numbers --quiet --force --style solarized-light"
export LESS=" -R"
alias less='less -m -N -g -i -J --line-numbers --underline-special'
alias more='less'
@caryfuk
caryfuk / vars-in-calc.less
Last active April 4, 2018 08:23
Using variables in within calc in less
~"calc(100% - @{variable})";
// or
calc(100% ~"-" @variable);
@caryfuk
caryfuk / atan2-alternative.js
Created June 20, 2016 15:04
compute angle on unit circle (alternative to built in Math.atan2)
const angle = (x, y) => {
let result = Math.atan(y / x);
if (x < 0) {
result += Math.PI;
} else if (y < 0) {
result += 2 * Math.PI;
}
return result;
};
@caryfuk
caryfuk / gitlog.txt
Created July 3, 2016 08:19
pretty git log
git log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
-p (with commit changes)
--graph (displayed as graph)
via Filipe Kiss
document.documentElement.webkitRequestFullScreen();
@caryfuk
caryfuk / android-emulator-homebrew.sh
Last active February 9, 2018 17:21 — forked from spilth/android-emulator-homebrew.sh
Android Emulator with Homebrew
touch ~/.android/repositories.cfg
brew cask install caskroom/versions/java8
brew cask install android-sdk
brew cask install intel-haxm
brew install qt
export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"
sdkmanager "platform-tools" "platforms;android-27" "extras;intel;Hardware_Accelerated_Execution_Manager" "build-tools;27.0.0" "system-images;android-27;google_apis;x86" "emulator"
avdmanager create avd -n test -k "system-images;android-27;google_apis;x86" --tag google_apis
/usr/local/share/android-sdk/tools/emulator -avd test