Skip to content

Instantly share code, notes, and snippets.

View guilhermejcgois's full-sized avatar
✍️
Writing amazing solutions

Gois guilhermejcgois

✍️
Writing amazing solutions
View GitHub Profile
@guilhermejcgois
guilhermejcgois / repo-scopes.sh
Last active August 2, 2022 01:57
Getting all scopes from commits summary in a repo for commitizen friendly repos
git log --pretty="%s" | grep -o -P '(?<=\().*(?=\))' | grep -v -F 'pull request' | uniq
@guilhermejcgois
guilhermejcgois / md5-from-deps.js
Created December 17, 2018 13:07
Get MD5 hash from dependencies and devDependencies from a package.json
const crypto = require('crypto');
const pjson = require('../package.json');
const depsStr = JSON.stringify(pjson.dependencies);
const devDepsStr = JSON.stringify(pjson.devDependencies);
const allDepsStr = depsStr + devDepsStr;
console.log(crypto.createHash('md5').update(allDepsStr).digest("hex"));
#!/bin/sh
echo "\nChecking for console.logs()...\n"
# Get from http://frontend.turing.io/lessons/module-4/git-hooks.html
exec 1>&2
# enable user input
exec < /dev/tty
@guilhermejcgois
guilhermejcgois / tslint-pre-commit.sh
Created September 28, 2017 02:24
Run lint on typescript files before commit (under test)
#!/bin/bash
# Based on: https://github.com/observing/pre-commit/issues/50
# Stash modified files, but keep the index tree
git stash -q --keep-index
# 1. Run diff for tree index withtou create a new index tree, showing only files names and iff the file was added or copied or deleted or renamed.
# 2. Grep only for .ts files
# 3. Execute tslint for each file that was modified with type checking enabled
@guilhermejcgois
guilhermejcgois / getStyle.ts
Last active July 20, 2023 11:38
Get computed styles (in typescript)
// Gist adapted from: https://gist.github.com/cms/369133
export getStyle(el: Element, styleProp: string): string {
let value;
const defaultView = el.ownerDocument.defaultView;
// W3C standard way:
if (defaultView && defaultView.getComputedStyle) {
// sanitize property name to css notation (hypen separated words eg. font-Size)
styleProp = styleProp.replace(/([A-Z])/g, '-$1').toLowerCase();
return defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
} else if (el['currentStyle']) { // IE
@guilhermejcgois
guilhermejcgois / 0_reuse_code.js
Created June 10, 2016 02:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console