Skip to content

Instantly share code, notes, and snippets.

@Gazzell
Gazzell / pre-commit
Created January 31, 2018 09:09
pre-commit. Only commit if pass tests and there are not leftovers (.only and .skip)
branch=`git symbolic-ref HEAD`
if [ "$branch" = "refs/heads/master" ]; then
echo "Direct commits to the branch master are not allowed"
exit 1
fi
testLeftOvers=`git diff --staged test/**/* | grep '^+' | grep '.only\|.skip'`
if [ -n "$testLeftOvers" ]; then
@Gazzell
Gazzell / pre-push
Created January 31, 2018 09:12
pre-push git hook, only pushes if there's a versioning message in at least one of the commits ('feat:', 'fix:', 'chore:'....)
#!/bin/sh
# An example hook script to verify what is about to be pushed.  Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed.  If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
@Gazzell
Gazzell / viewHierarchy
Last active January 31, 2018 16:54
prints pixi.js node hierarchy in console (assuming nodes has 'name' property)
function printHierarchy(node, padding="") {
let newPadding = padding;
if (node.name) {
newPadding += " |";
console.log(`${padding}-${node.name}`);
}
node.children.forEach(child => printHierarchy(child, newPadding));
}
@Gazzell
Gazzell / index.html
Last active December 13, 2018 08:14
Maze
<canvas id='canvas' width='800' height='800'></canvas>
@Gazzell
Gazzell / index.html
Created January 21, 2019 14:33
Waves
<canvas id='canvas' width='400' height='400'></canvas>
@Gazzell
Gazzell / commands.txt
Last active March 16, 2020 09:24
useful bash commands
# delete node_modules for in all projects (dirs)
find ./ -name "node_modules" -maxdepth 2 -exec rm -rf {} \;
##GIT
#remove all merged local branches
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
@Gazzell
Gazzell / draw_crosshair.js
Last active April 17, 2020 08:22
show PIXI hit areas
class Crosshair {
constructor(size = 3, color = "red") {
this.element = document.createElement("span");
this.element.textContent = "+";
this.style = this.element.style;
this.style.color = color;
this.style.fontFamily = "Arial";
this.style.fontSize = `${size}em`;
this.style.fontWeight = "";
@Gazzell
Gazzell / printHierarchy.js
Created January 28, 2020 12:36
print PIXI hierarchy
function printHierarchy(node, padding="") {
let newPadding = padding;
if (node.name) {
newPadding += " |";
console.log(`${padding}-${node.name}`);
}
node.children.forEach(child => printHierarchy(child, newPadding));
}
@Gazzell
Gazzell / .eslintrc
Last active January 31, 2024 18:28
React, typescript, use craco to set custom tests paths and import aliases
{
"extends": [
"eslint-config-react-app"
],
"plugins": ["react", "import"],
"rules": {
"import/no-unresolved": "error"
},
"settings": {
"import/parsers": {