Skip to content

Instantly share code, notes, and snippets.

View dhargitai's full-sized avatar
💭
Everything is awesome 😎

David Hargitai dhargitai

💭
Everything is awesome 😎
View GitHub Profile
@dhargitai
dhargitai / composerOauthToken.md
Last active December 4, 2022 04:03
Stop Composer asking for GitHub credentials

Because of GitHub's rate limits on their API it can happen that Composer prompts for authentication asking your username and password so it can go ahead with its work.

If you would prefer not to provide your GitHub credentials to Composer you can manually create a token using the following procedure:

Create an OAuth token on GitHub.

Add it to the configuration running composer config -g github-oauth.github.com <oauthtoken>

Now Composer should install/update without asking for authentication.

@dhargitai
dhargitai / LoadNodeVersionBasedOnNvmRcFile.sh
Created February 16, 2021 09:45
Put this at the end of .zshrc
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
mongoexport --uri="mongodb://username:pass@0.0.0.0:27017/strapi" --authenticationDatabase=admin --authenticationMechanism=SCRAM-SHA-256 --collection=products --out=/bckp/products.json
@dhargitai
dhargitai / machine.js
Last active November 16, 2020 07:57
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@dhargitai
dhargitai / machine.js
Last active October 16, 2020 11:40
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@dhargitai
dhargitai / vscode-keyboard-shortcuts.json
Created October 7, 2020 15:49
My VSCode keyboard shortcuts
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "alt+cmd+l",
"command": "editor.action.formatDocument",
"when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+f",
"command": "-editor.action.formatDocument",
@dhargitai
dhargitai / vscode-settings.json
Created October 7, 2020 15:43
My VSCode settings
{
"editor.snippetSuggestions": "top",
"editor.formatOnPaste": true,
"editor.fontSize": 14,
"files.autoSave": "onWindowChange",
"editor.rulers": [
100
],
"editor.scrollBeyondLastLine": false,
"[yaml]": {
@dhargitai
dhargitai / machine.js
Created October 7, 2020 14:19
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
alias gitpurge='git branch --merged | egrep -v "(^\*|master|develop)" | xargs -n 1 git branch -d'
alias mirror='wget -p -k -e robots=off -H'
let generateCode = (givenOptions = {}) => {
const {pool, length} = {
...{length: 3, pool: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.split('')},
...givenOptions
};
let code = '';
while (code.length < length) {
code += pool[Math.floor(Math.random() * pool.length)];
}
return code;