Skip to content

Instantly share code, notes, and snippets.

View dekadentno's full-sized avatar
📚
mnogo hakovanja, i to baš jakog intenziteta

Matej dekadentno

📚
mnogo hakovanja, i to baš jakog intenziteta
View GitHub Profile
@dekadentno
dekadentno / interceptors.js
Last active August 15, 2020 15:45
axios request interceptor for setting token in header and response interceptor for refresh token and repeat last api call
axios.interceptors.request.use(function(config) {
let userToken = localStorage.getItem('token');
if (userToken) {
axios.defaults.headers.common['Authorization'] = 'Bearer ' + userToken;
config.headers['Authorization'] = 'Bearer ' + userToken;
}
return config;
});
@dekadentno
dekadentno / .bashrc
Last active August 5, 2018 16:58
.bashrc
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# example 1
export PS1="🍔 \[\033[01;35m\]\u@\h:\[\033[01;34m\]\$(parse_git_branch) \[\033[01;32m\]\w \[\033[01;34m\]\n>\[\e[0m\]"
# example 2
export PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] @ \[\033[0;36m\]\h \w\[\033[0;32m\] $(parse_git_branch)\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\] ▶\[\033[0m\] '
@dekadentno
dekadentno / pre-commit
Created August 1, 2018 15:13
Git hook for running eslint before commit
#!/bin/sh
function lintit () {
e=$(eslint . --ext .vue src/*)
echo $e
if [[ "$e" != *"0 problems"* ]]; then
echo "ERROR: Fix eslint errors before commiting your code!"
exit 1 # reject
fi
}
@dekadentno
dekadentno / ssh.md
Last active November 2, 2018 07:18
Generate and import ssh keys for Gitlab and Bitbucket

How to generate and import ssh keys to git

Navigate to your .ssh folder and generate a ssh key. Put a name on it and a password.

ssh-keygen -t rsa

This command will generate 2 files (private and public keys):

key_name
key_name.pub
@dekadentno
dekadentno / pretty json.md
Last active November 5, 2018 13:54
Vue pretty JSON print

How to make a fancy JSON print

Usage:

<pre v-html="prettyJSON(schema)"></pre>

With the following method:

prettyJSON: function(json) {
    if (json) {
@dekadentno
dekadentno / joel test.md
Last active December 10, 2018 06:39
The Joel Test

The Joel Test is a twelve-question measure of the quality of a software team.

  • Do you use source control? Yes
  • Can you make a build in one step? Yes
  • Do you make daily builds? Yes
  • Do you have a bug database? Yes
  • Do you fix bugs before writing new code? Yes
  • Do you have an up-to-date schedule? Yes
  • Do you have a spec? Yes
  • Do programmers have quiet working conditions? Yes
@dekadentno
dekadentno / googleanalytics.js
Last active February 1, 2019 05:57
Google analytics vue and nuxt opt in (gdpr)
/*
Had some problems with implementing google analytics opt-in, as in nuxt (nor vue) doesn't support that out of the box,
so I found a hacky method that works.
Idea:
1. user comes to the page, the famous "this page is using cookies" widget is shown
2. when the user clicks "accept cookies", the google analytics script should be injected into the code
Solution:
1. put your google analytics js script in the static folder of your project
@dekadentno
dekadentno / bulkUnpublish.sh
Created February 7, 2019 09:44
Multiple packages unpublish from npm
# usage:
# chmod 700 bulkUnpublish.sh
# ./bulkUnpublish.sh axios vuex moment
npm set registry "http://xxx.xxx.xxx.xxx"
for var in "$@"
do
echo "Unpublishing: $var"
npm unpublish --force "$var"
done
@dekadentno
dekadentno / retry-queue.js
Created March 8, 2019 06:46
My backup of a javascript async queue implementation by Bolerodan on CodeSandbox. All regards to him.
// the retry service
// retry-queue.js
const service = {
retryQueue: [],
onItemAddedCallbacks: [],
hasMore () {
return this.retryQueue.length > 0
},
push (retryItem) {
this.retryQueue.push(retryItem)
@dekadentno
dekadentno / purgecss.js
Last active May 6, 2022 17:06
Vue CLI 3 + PurgeCSS
/**
1) npm i -D purgecss @fullhuman/postcss-purgecss purgecss-webpack-plugin glob-all path
2) edit vue.config.js
*/
/**
** vue.config.js
*/
const PurgecssPlugin = require('purgecss-webpack-plugin');
const glob = require('glob-all');