Wednesday, September 13, 2017

Grep and find aliases

Two quick bash functions to speed up name and content search on files. These are to be appended at ~/.bashrc file:
function gr { clear ; grep -rn $1 . ; }
function ff { clear ; find . -name "$1" ; }

Sunday, September 10, 2017

Holy Grail CSS layout with overflow

This morning – yep, a Sunday morning – I needed to implement an HTML page with the Holy Grail layout. A quick search gave me dozens of implementations, but all of them broke apart when you trew a lot of content into the sections. Being fond of the Flexbox model, I quickly came with an implementation that had all the needed overflow control:

This implementation is also modular: if you don’t need any of the panels, just remove them – the layout will stay working. Also, the satellite panels can have fixed dimensions, see the commented values for width and height.

The funny part is that min-height: 0. It’s there for Firefox; without it, the overflow goes wild. Other interesting thing is the absence of the height: 100% to html and body elements, it’s not needed.

Friday, September 8, 2017

Disabling the useless npm package-lock.json

Recently I’ve updated npm to version 5 while working in one of my projects. Much to my dismay, a “package-lock.json” file started to appear, and I finally understood why I’ve seen this file commited in some projects lately.

But since this feature is basically a horrible idea, I started searching a way to permanently disable it. It looks like I’m not the only one who dislikes this, because I found this excellent post, which points to the solution:

npm set package-lock false

And any more “package-lock.json” files that appear in front of me will be summarily deleted.

Thursday, September 7, 2017

Visual Studio Code settings

This morning I was setting up Visual Studio Code at a Lubuntu virtual machine, and after saving the keyboard shortcuts, I opened my current editor to get the settings. Since some of them I consider essential, I decided to publish them here, for further reference.

{
// "editor.fontFamily": "'Cascadia Code Light'", "editor.fontSize": 15,
// "editor.fontFamily": "'Cascadia Code SemiLight'", "editor.fontSize": 14.5,
// "editor.fontFamily": "'CommitMono'", "editor.fontSize": 14.25,
// "editor.fontFamily": "'Dank Mono'", "editor.fontSize": 15.75,
// "editor.fontFamily": "'Fira Code'", "editor.fontSize": 14.5,
// "editor.fontFamily": "'Iosevka'", "editor.fontSize": 15.45,"editor.fontLigatures": "'calt' off, 'JSPT' on",
// "editor.fontFamily": "'JetBrains Mono'", "editor.fontSize": 14,
// "editor.fontFamily": "'Liga Cousine'", "editor.fontSize": 14,
// "editor.fontFamily": "'Liga DejaVu Sans Mono'", "editor.fontSize": 14.5,
// "editor.fontFamily": "'Liga Droid Sans Mono'", "editor.fontSize": 14.25,
// "editor.fontFamily": "'Ligalex Mono'", "editor.fontSize": 14.5,
// "editor.fontFamily": "'LigaSrc Pro'", "editor.fontSize": 14.5,
// "editor.fontFamily": "'LigaSrc Pro'", "editor.fontSize": 15.5,
// "editor.fontFamily": "'Monaspace Neon'", "editor.fontSize": 13.9,"editor.fontLigatures": "'calt', 'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'ss07', 'ss09', 'liga'",
// "editor.fontFamily": "'Monaspace Neon'", "editor.fontSize": 14.25,"editor.fontLigatures": "'calt', 'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'ss07', 'ss09', 'liga'",
// "editor.fontFamily": "'Victor Mono Regular'", "editor.fontSize": 16,
// "editor.fontFamily": "'Anonymous Pro'", "editor.fontSize": 17,
// "editor.fontFamily": "'AverageMono'", "editor.fontSize": 15,
// "editor.fontFamily": "'BPMono'", "editor.fontSize": 14.25,
// "editor.fontFamily": "'CamingoCode'", "editor.fontSize": 15,
// "editor.fontFamily": "'CentSchbook Mono BT'", "editor.fontSize": 15,
"editor.fontFamily": "'Consolas'", "editor.fontSize": 15.5,
// "editor.fontFamily": "'Droid Sans Mono'", "editor.fontSize": 14,
// "editor.fontFamily": "'Go Mono'", "editor.fontSize": 14.5,
// "editor.fontFamily": "'Inconsolata SemiExpanded'", "editor.fontSize": 15.5,
// "editor.fontFamily": "'Inconsolata'", "editor.fontSize": 16.45,
// "editor.fontFamily": "'Intel One Mono'", "editor.fontSize": 14,
// "editor.fontFamily": "'Lucida Console'", "editor.fontSize": 14.5,
// "editor.fontFamily": "'Menlo'", "editor.fontSize": 14.25,
// "editor.fontFamily": "'Monaco'", "editor.fontSize": 14.25,
// "editor.fontFamily": "'Operator Mono Light'", "editor.fontSize": 15.5,
// "editor.fontFamily": "'Roboto Mono'", "editor.fontSize": 14.25,
// "editor.fontFamily": "'Sometype Mono'", "editor.fontSize": 15,
// "editor.fontFamily": "'Source Code Pro'", "editor.fontSize": 14.5,
// "editor.fontFamily": "'TeX Gyre Cursor'", "editor.fontSize": 15.25,
"breadcrumbs.enabled": false,
"chat.agent.enabled": false,
"diffEditor.ignoreTrimWhitespace": false,
"editor.accessibilitySupport": "off",
"editor.bracketPairColorization.enabled": false,
"editor.codeLens": false,
"editor.colorDecorators": true,
"editor.fontLigatures": true,
"editor.inlayHints.enabled": "offUnlessPressed",
"editor.insertSpaces": false,
"editor.lineHeight": 18,
"editor.minimap.enabled": false,
"editor.mouseWheelZoom": true,
"editor.renderLineHighlight": "none",
"editor.renderWhitespace": "trailing",
"editor.rulers": [80],
"editor.tabSize": 3,
"editor.semanticTokenColorCustomizations": {
"[Default Light+]": {
"rules": {
"boolean": {
// "foreground": "#9932cc", // violet
"foreground": "#1848e3", // VS blue
},
"macro": {
"foreground": "#5599ee", // baby blue
// "foreground": "#ff8040", // orange
// "foreground": "#9932cc", // violet
"italic": true,
},
"namespace": "#9d9d00", // gold
"*.constant": "#008080", // Rust doc
// "*.documentation": "#00b400", // green; Rust doc
"*.documentation": "#aaa", // gray; Rust doc
// "struct": {
// "foreground": "#0066ee",
// },
},
},
},
"editor.stickyScroll.enabled": false,
// "editor.suggest.showKeywords": false,
"editor.tokenColorCustomizations": {
"[Default Light+]": {
"functions": {
"foreground": "#74533d", // VS brown
},
// "keywords": "#9932cc", // used by JS
"keywords": "#1848e3", // VS blue
"numbers": "#c00000",
"strings": "#da3d3d", // red-like
// "strings": "#057d16", // intellij-green
// "types": "#1848e3", // VS blue
// "types": "#2891af", // VS teal
"types": "#9932cc", // violet
// "types": "#5599ee", // baby blue
// "variables": {
// "fontStyle": "italic",
// },
"textMateRules": [{ // used by Rust
"scope": "keyword",
"settings": {
"foreground": "#1848e3", // VS blue
},
}, {
"scope": "variable.parameter",
"settings": {
"foreground": "#000",
"fontStyle": "italic",
},
}, {
"scope": "comment",
"settings": {
"fontStyle": "italic",
// "foreground": "#00b400", // green
"foreground": "#aaa", // grey
},
}, {
"scope": "entity.other.attribute-name",
"settings": {
"fontStyle": "italic",
// "foreground": "#ff732f", // orange
"foreground": "#009000", // green
},
},
{"scope": "support.type.property-name.table", "settings": {"fontStyle": "italic", "foreground": "#9d9d00"}}, // Even Better TOML
{"scope": "support.type.property-name", "settings": {"foreground": "#5599ee"}},
{"scope": "entity.name.tag.css", "settings": {"foreground": "#000"}},
{"scope": "entity.name.tag.nesting.selector.css", "settings": {"foreground": "#ff6384"}},
{"scope": "entity.other.attribute-name.class.css", "settings": {"foreground": "#000"}},
{"scope": "entity.other.attribute-name.pseudo-class.css", "settings": {"foreground": "#9d9d00"}},
{"scope": "storage.modifier.async", "settings": {"foreground": "#1848e3"}}, // TS shit
{"scope": "storage.modifier.await", "settings": {"foreground": "#1848e3"}},
{"scope": "constant.language.null", "settings": {"foreground": "#1848e3"}},
{"scope": "constant.language.boolean", "settings": {"foreground": "#1848e3"}},
{"scope": "constant.language.undefined", "settings": {"foreground": "#1848e3"}},
{"scope": "keyword.operator.new", "settings": {"foreground": "#1848e3"}},
{"scope": "storage.type.function.arrow", "settings": {"foreground": "#000"}},
{"scope": "constant.language.java", "settings": {"foreground": "#1848e3"}}, // Java shit
{"scope": "keyword.operator.instanceof.java", "settings": {"foreground": "#1848e3"}},
{"scope": "storage.type.primitive.java", "settings": {"foreground": "#1848e3"}},
{"scope": "storage.type.java", "settings": {"foreground": "#9932cc"}},
{"scope": "storage.type.primitive.array.java", "settings": {"foreground": "#1848e3"}},
// {"scope": "variable.other.enummember", "settings": {"foreground": "#080"}},
{"scope": "storage.modifier.java", "settings": {"foreground": "#1848e3"}},
{"scope": "storage.modifier.extends.java", "settings": {"foreground": "#1848e3"}},
{"scope": "meta.declaration.annotation.java", "settings": {"foreground": "#9d9d00"}}, // Java annotation @
{"scope": "storage.type.annotation.java", "settings": {"foreground": "#9d9d00"}}, // Java annotation word
{"scope": "punctuation.definition.annotation-arguments.begin.bracket.round.java", "settings": {"foreground": "#333"}},
{"scope": "punctuation.definition.annotation-arguments.end.bracket.round.java", "settings": {"foreground": "#333"}},
{"scope": "punctuation.section.block.begin.bracket.curly.java", "settings": {"foreground": "#333"}},
{"scope": "punctuation.section.block.end.bracket.curly.java", "settings": {"foreground": "#333"}},
],
},
},
"explorer.sortOrder": "type",
"extensions.ignoreRecommendations": true,
"files.associations": {
"*.ixx": "cpp",
"*.prefs": "spring-boot-properties"
},
"files.eol": "\r\n",
"files.exclude": {
"**/node_modules": true,
"**/x64": true,
"target/": true,
"Cargo.lock": true,
"*.exe": true,
},
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true,
"target/**": true,
},
"git.allowForcePush": true,
"git.blame.statusBarItem.enabled": false,
"git.confirmForcePush": false,
"git.inputValidation": true,
"git.openRepositoryInParentFolders": "always",
"git.showActionButton": {
"commit": false,
"publish": false,
"sync": false,
},
"js/ts.implicitProjectConfig.experimentalDecorators": true,
"security.workspace.trust.enabled": false,
"telemetry.feedback.enabled": false,
"telemetry.telemetryLevel": "off",
// "terminal.integrated.cwd": "D:\\Stuff\\Core",
"terminal.integrated.defaultProfile.windows": "Git Bash",
"window.titleBarStyle": "native",
"workbench.colorCustomizations": {
"[Default Light+]": {
"breadcrumb.background": "#f7f7f7",
"editor.background": "#f8f8f8",
"editorBracketHighlight.foreground1": "#000000",
"editorBracketMatch.background": "#ffffd0",
"editorBracketMatch.border": "#e4e4e4",
"editorIndentGuide.activeBackground1": "#e2e2e2",
"editorIndentGuide.background1": "#e2e2e2",
"editorRuler.foreground": "#e3e3e3",
"editorWhitespace.foreground": "#a8d8a8",
"editorInlayHint.foreground": "#88aa88",
"editorInlayHint.background": "#eeeeee",
"editorSuggestWidget.focusHighlightForeground": "#0060c0",
"editorSuggestWidget.selectedBackground": "#e0e0e0",
"editorSuggestWidget.selectedForeground": "#000000",
// "editorSuggestWidget.selectedIconForeground": "#ff0000", // https://stackoverflow.com/a/68330327/6923555
"separators.classes.borderColor": "#cbe0fa",
"separators.constructors.borderColor": "#a0f1d3",
"separators.enums.borderColor": "#cbe0fa",
"separators.functions.borderColor": "#a0f1d3",
"separators.interfaces.borderColor": "#cbe0fa",
"separators.methods.borderColor": "#a0f1d3",
"separators.namespaces.borderColor": "#a0f1d3",
"separators.structs.borderColor": "#cbe0fa",
},
},
"workbench.colorTheme": "Default Light+",
// "workbench.editor.decorations.badges": false,
"workbench.editor.decorations.colors": true,
"workbench.editor.wrapTabs": true,
"workbench.settings.editor": "json",
"workbench.startupEditor": "none",
"workbench.tree.enableStickyScroll": false,
"workbench.tree.indent": 16,
"workbench.tree.renderIndentGuides": "none",
"[go]": {
"editor.tabSize": 4,
},
"[html][plaintext]": {
"editor.wordWrap": "on"
},
"[javascript][typescript][typescriptreact]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
},
},
"[markdown]": {
"editor.insertSpaces": true,
"editor.renderWhitespace": "boundary",
"editor.tabSize": 4,
"editor.wordWrap": "on",
"files.trimTrailingWhitespace": false,
},
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true,
},
"[sql]": {
"editor.tabSize": 4,
},
"go.inlayHints.assignVariableTypes": true,
"go.inlayHints.compositeLiteralFields": true,
"go.inlayHints.rangeVariableTypes": true,
"go.survey.prompt": false,
"rust-analyzer.cargo.buildScripts.enable": false,
"rust-analyzer.cargo.features": "all",
"rust-analyzer.completion.autoimport.enable": false,
"rust-analyzer.completion.autoself.enable": false,
"rust-analyzer.completion.postfix.enable": false,
"rust-analyzer.lens.enable": false,
// "rust-analyzer.rustfmt.extraArgs": ["+nightly"],
"rust-analyzer.typing.continueCommentsOnNewline": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"typescript.preferences.quoteStyle": "single",
"typescript.tsserver.experimental.enableProjectDiagnostics": true,
"window.customTitleBarVisibility": "never",
"window.newWindowProfile": "Default",
"workbench.iconTheme": "old-programmers-icons",
"zig.formattingProvider": "off",
"zig.zls.enabled": "on",
"separators.enabledSymbols": [], // none by default
"[go][rust]": {
"separators.enabledSymbols": [ // see workbench.colorCustomizations
"Classes",
// "Constructors",
"Enums",
// "Functions",
"Interfaces",
// "Methods",
// "Namespaces",
"Structs"
],
},
"separators.classes.borderStyle": "dashed",
"separators.classes.borderWidth": 2,
"separators.enums.borderStyle": "dashed",
"separators.enums.borderWidth": 2,
"separators.interfaces.borderStyle": "dashed",
"separators.interfaces.borderWidth": 2,
"separators.location": "aboveTheComment",
"separators.structs.borderStyle": "dashed",
"separators.structs.borderWidth": 2,
}
view raw settings.json hosted with ❤ by GitHub