Skip to content

Instantly share code, notes, and snippets.

View nhevia's full-sized avatar
👁️
_ 👁️

Nico Hevia nhevia

👁️
_ 👁️
View GitHub Profile
@nhevia
nhevia / index.js
Created October 19, 2022 11:38
NCC-js
// Product data: fetched from a database/any storage
const products = [
{ code: "VOUCHER", name: "Voucher", price: 5 },
{ code: "TSHIRT", name: "T-shirt", price: 20 },
{ code: "MUG", name: "Coffee mug", price: 7.5 },
];
// Rules. This is where business logic lives.
const rules = {
secondFree: (total, amount) => {
if (amount < 2) return total;
@nhevia
nhevia / index.ts
Created October 19, 2022 11:35
NCC
// Product data: fetched from a database/any storage
const products = [
{ code: "VOUCHER", name: "Voucher", price: 5 },
{ code: "TSHIRT", name: "T-shirt", price: 20 },
{ code: "MUG", name: "Coffee mug", price: 7.5 },
];
// Rules. This is where business logic lives.
const rules = {
secondFree: (total, amount) => {
if (amount < 2) return total;
{
"ABAP": "#E8274B",
"ActionScript": "#882B0F",
"Ada": "#02f88c",
"Agda": "#315665",
"AGS Script": "#B9D9FF",
"Alloy": "#64C800",
"AMPL": "#E6EFBB",
"ANTLR": "#9DC3FF",
"API Blueprint": "#2ACCA8",
@nhevia
nhevia / settings.json
Last active July 17, 2022 16:11
VSCode global Settings (JSON)
{
// -- Visual IDE changes
"window.zoomLevel": 1,
"workbench.colorTheme": "One Dark Pro", // ext: zhuangtongfa.material-theme
"workbench.iconTheme": "material-icon-theme", // ext: PKief.material-icon-theme
"editor.tabSize": 2,
// - font
"editor.fontFamily": "Fira Code", // https://github.com/tonsky/FiraCode
"editor.fontLigatures": true,
// - bracket colors (Bracket Pair Colorizer native plugin)
@nhevia
nhevia / jest.config.js
Created April 26, 2021 21:21
Jest starter configuration file
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html
module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,
// Stop running tests after `n` failures
// bail: 0,
@nhevia
nhevia / line_count_git_repo.sh
Created November 17, 2020 13:55
A command to show amount of lines in a git repository, excluding files
$ git ls-files --exclude-standard -- ':!:**/*.[pjs][npv]g' ':!:**/*.eslintrc' ':!:package-lock.json' | xargs wc -l
// Excludes png, jpg, svg and package.json files.
// For excluding other configuration files (eslint for example): ':!:**/*.eslintrc'
@nhevia
nhevia / semantic_git_commit_count.sh
Created August 21, 2020 11:16
Counts semantic git commits
git log --pretty=oneline --no-merges --since 2019/01/01 --until 2021/12/31 | cut -d " " -f 2 |\
cut -d "(" -f 1 | cut -d ":" -f 1 | sort -r | uniq -c | sort -nr -k1
@nhevia
nhevia / memoization.js
Created November 29, 2019 20:59
Test demostrating basic memoization for a cached parameter, using previously calculated result
// our cache
let cache = {
val: null,
res: null
}
const myLongTask = num => {
// if parameter is equal to our cached value, we don't repeat the calculation
if (num === cache.val) {
const t1 = new Date().valueOf()
@nhevia
nhevia / ubuntu-remove-initial-pkgs.sh
Created November 20, 2019 00:48
Remove ubuntu initial packages
sudo apt-get remove account-plugin-facebook account-plugin-flickr account-plugin-jabber account-plugin-salut account-plugin-twitter account-plugin-windows-live account-plugin-yahoo aisleriot brltty duplicity empathy empathy-common example-content gnome-accessibility-themes gnome-contacts gnome-mahjongg gnome-mines gnome-orca gnome-screensaver gnome-sudoku gnome-video-effects gnomine landscape-common libreoffice-avmedia-backend-gstreamer libreoffice-base-core libreoffice-calc libreoffice-common libreoffice-core libreoffice-draw libreoffice-gnome libreoffice-gtk libreoffice-impress libreoffice-math libreoffice-ogltrans libreoffice-pdfimport libreoffice-style-galaxy libreoffice-style-human libreoffice-writer libsane libsane-common mcp-account-manager-uoa python3-uno rhythmbox rhythmbox-plugins rhythmbox-plugin-zeitgeist sane-utils shotwell shotwell-common telepathy-gabble telepathy-haze telepathy-idle telepathy-indicator telepathy-logger telepathy-mission-control-5 telepathy-salut totem totem-common totem-plugin