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 / 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 / .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 / 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 / vue.config.js
Created March 15, 2019 10:00
vue config example working with purge css and terser (uglify / uglifyjs)
/**
npm i --save-dev terser-webpack-plugin purgecss @fullhuman/postcss-purgecss purgecss-webpack-plugin glob-all path
*/
const TerserPlugin = require('terser-webpack-plugin')
const PurgecssPlugin = require('purgecss-webpack-plugin')
const glob = require('glob-all') // required for purgecss
const path = require('path') // re quired for purgecss
...
@dekadentno
dekadentno / 1_primitive_comparison.js
Last active April 1, 2019 12:10 — forked from nicbell/1_primitive_comparison.js
JavaScript object deep comparison.Comparing x === y, where x and y are values, return true or false. Comparing x === y, where x and y are objects, returns true if x and y refer to the same object. Otherwise, returns false even if the objects appear identical.Here is a solution to check if two objects are the same.
//Primitive Type Comparison
var a = 1;
var b = 1;
var c = a;
console.log(a == b); //true
console.log(a === b); //true
console.log(a == c); //true
console.log(a === c); //true