Skip to content

Instantly share code, notes, and snippets.

View miladvafaeifard's full-sized avatar
🙌
always looking simple solutions

Milad Vafaeifard miladvafaeifard

🙌
always looking simple solutions
View GitHub Profile
@miladvafaeifard
miladvafaeifard / object-append-chain.js
Created November 23, 2018 15:55
object appends chains
Object.appendChain = function (oChain, oProto) {
if (typeof oProto !== 'object' && typeof oProto !== 'string') {
throw new TypeError('second argument must be an object or a string');
}
var oNewProto = oProto;
var oReturn = o2nd = oLast = oChain instanceof this ? oChain : new oChain.constructor(oChain);
for (var o1st = this.getPrototypeOf(o2nd); o1st !== Object.prototype && o1st !== Function.prototype; o1st = this.getPrototypeOf(o2nd)) {
o2nd = o1st;
@miladvafaeifard
miladvafaeifard / gitlab.yml
Created November 23, 2018 16:33
deploy to heroku
image: node:8.9.1
cache:
paths:
- node_modules/
stages:
- deploy
@miladvafaeifard
miladvafaeifard / commit-msg.sh
Last active January 28, 2019 08:35
The hook will check if the current branch is a story branch.
#!/bin/sh
#
# The hook will check if the current branch is a story branch.
#
# If it is then it will check the commit message if it contains the correct prefix.
#
# Correct commit message form:
# [STORY-ID] A commit message
#
# If the commit message does not follow the from above the hook will fix it.
@miladvafaeifard
miladvafaeifard / pre-commit.sh
Created November 23, 2018 16:37
typescript validation and testing (tslint)
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
#!/bin/sh
@miladvafaeifard
miladvafaeifard / test-go.go
Created November 23, 2018 17:45
test golang
package main
import "fmt"
type Person interface {
getName() string
}
func (e Employee) getName() string {
let num = 2;
console.log(~num); // -3
// how it works
// first we should know binary code, convert 2 to 0010 and flip it to 1101 (-2), and then add 1 to it, the result is -3.
num = -2;
conosle.log(~num); // 1
@miladvafaeifard
miladvafaeifard / factory-pattern.js
Last active December 1, 2018 23:40
understand factory pattern in plain javascript
class Animal {
constructor(pet) {
this.pet = pet;
}
speak() {
console.log(this.pet);
}
join(animal) {
@miladvafaeifard
miladvafaeifard / install-vscode-extensions-cli
Last active December 11, 2022 22:22
How to install VSCode extensions from command line run
abusaidm.html-snippets
andys8.jest-snippets
ashinzekene.nestjs
christian-kohler.npm-intellisense
CoenraadS.bracket-pair-colorizer
DavidAnson.vscode-markdownlint
dawhite.mustache
dbaeumer.jshint
dbaeumer.vscode-eslint
dracula-theme.theme-dracula
@miladvafaeifard
miladvafaeifard / custom-element.js
Created November 30, 2018 11:27
Using custom elements
class WordCound extends HTMLElement {
constructor() {
super();
var shadowRoot = this.attachShadow({ mode: "open" });
var p = document.createElement("p");
p.textContent = "Hello World";
p.setAttribute("class", "red-color");
var style = document.createElement("style");
@miladvafaeifard
miladvafaeifard / .dockerignore
Created December 4, 2018 21:23
init docker ignore
# Common
README.md
CHANGELOG.md
docker-compose.yml
Dockerfile
# Node
## Logs
logs
*.log