{"id":19147142,"url":"https://github.com/marcharriss/general_tips","last_synced_at":"2025-08-10T03:35:44.974Z","repository":{"id":138595391,"uuid":"182244601","full_name":"MarcHarriss/general_tips","owner":"MarcHarriss","description":"A list of commands that I always find myself coming back to.","archived":false,"fork":false,"pushed_at":"2019-07-02T06:56:35.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-28T11:46:35.892Z","etag":null,"topics":["cheatsheet","coding-tips","docker","documentation","examples","help","tldr"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarcHarriss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-19T10:02:52.000Z","updated_at":"2019-07-02T06:56:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"5b3a1dac-e853-47fb-9b99-67cd36c650e3","html_url":"https://github.com/MarcHarriss/general_tips","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MarcHarriss/general_tips","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcHarriss%2Fgeneral_tips","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcHarriss%2Fgeneral_tips/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcHarriss%2Fgeneral_tips/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcHarriss%2Fgeneral_tips/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarcHarriss","download_url":"https://codeload.github.com/MarcHarriss/general_tips/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcHarriss%2Fgeneral_tips/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269672078,"owners_count":24457114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cheatsheet","coding-tips","docker","documentation","examples","help","tldr"],"created_at":"2024-11-09T07:49:07.260Z","updated_at":"2025-08-10T03:35:44.950Z","avatar_url":"https://github.com/MarcHarriss.png","language":null,"readme":"# Introduction \t\n\nJust a curation of commands I keep finding myself having to google.\nIf your often scouring through documentation or saving snippets, I would recommend using (Dash)[https://kapeli.com/dash].\n\n## Linux\n\n### Monitoring\n\nMonitor the end of a file\n\n`sudo tail -f /var/log/apache2/access.log`\n\n### Scp\n\nCopying from remote to local\n\n`scp -vr user@remote:/path/to/file destination/folder`\n\nInverse for local to remote\n\n`scp -vr /local/file user@remote:/path/to/destination`\n\n_scp may not work while using zsh, so you may need to switch to bash._\n\n## Docker\n\nBuild image (from directory where there is a dockerfile)\n\n`docker build -t __placeholder__ .`\n\nCreate background container\n\n`docker run -dp 9200:9200 --name ES elasticsearch`\n\n_The \"d\" from -dp actually makes it run in the backfound_\n\nRemove all images\n\n`docker rmi -f $(docker images -q)`\n\nRun commands inside container\n\n`docker run -it --rm __placeholder__ bash`\n\nStop containers all\n\n`docker stop $(docker ps -q)`\n\n## Git\n\n### Branching\n\nCreate Branch\n\n`git branch _branch_name_`\n\n`git checkout _branch_name_`\n\nShorthand for the above\n\n`git checkout -b _branch_name_`\n\nWhen happy with changes, merge\n\n`git checkout master`\n\n`git merge _branch_name_`\n\n### changing config\n\nSet global username and email\n\n`git config --global user.name \"Marc Harriss\"`\n\n`git config --global user.email my@email.com`\n\nGet config\n\n`git config -l`\n\nWhere to find git conf\n\n`sublime ~/.gitconfig`\n\n### Submodules\n\nPull all changes in the repo including changes in the submodules\n\n`git pull --recurse-submodules`\n\nPull all changes for the submodules\n\n`git submodule update --remote`\n\nAdd submodule and define the master branch as the one you want to track\n\n`git submodule add -b master [URL to Git repo]`\n\n`git submodule init`\n\n### General\n\n`grep -lr '\u003c\u003c\u003c\u003c\u003c\u003c\u003c' . | xargs git checkout --theirs`\n\nCopy ssh key\n\n`cat ~/.ssh/id_rsa.pub | pbcopy .` _(mac)_\n\nFix host verification issue\n\n`ssh-keyscan -H __website.com__ \u003e\u003e ~/.ssh/known_hosts`\n\n### Time-machine\n\nRemove folder once uploaded\n\n`git rm -r --cached node_modules \u0026\u0026 touch .gitignore \u0026\u0026 echo \"node_modules/\" \u003e\u003e .gitignore`\n\nUndo commits\n\n`git reset --soft HEAD^`\n\nReset to last commit\n\n`git reset --hard HEAD^`\n\n## JavaScript\n\nListen to all events\n\n```JavaScript \nObject.keys(window).forEach(key =\u003e {\n\tif (/^on/.test(key)) {\n\t\twindow.addEventListener(key.slice(2), event =\u003e {\n\t\t\tconsole.log(event);\n\t\t});\n\t}\n});\n```\n\nPsuedo elements\n\n```JavaScript\nvar color = window.getComputedStyle(\n\tdocument.querySelector('.element'), ':before'\n).getPropertyValue('color')\n```\n\n## NPM\n\n### Fix paths\n\n`cd ~/npm-global/bin`\n\n_Check if command your are trying to run exists_\n_Add alias in ~/.zshrc | ~/.bashrc whichever terminal you use_\n\n`alias ng=\"~/.npm-global/bin/__placeholder__`\n\n### Fix npm links\n\nAdd to top of ~/.zshrc | ~/.bash_profile\n\n`source /Users/YOUUSERNAME/.bash_profile`\n\nView all global packages\n\n`npm ls -g --depth 0`\n\nShell autocomplete\n\n`npm completion \u003e\u003e ~/.bashrc`\n\nOr\n\n`npm completion \u003e\u003e ~/.zshrc`\n\n\n## MacOS\n\nAdd app bar space\n\n`defaults write com.apple.dock persistent-apps -array-add '{\"tile-type\"=\"spacer-tile\";}’`\n\n`$Killall Dock`\n_repeat for each spacer_\n\nFlush dns\n\n`sudo killall -HUP mDNSResponder;say DNS cache has been flushed`\n\nIf that doesnt work then \n\n`sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache;say MacOS DNS cache has been cleared`\n\nLaunching programs from the terminal.\n\n```shell\nchrome () {\n\topen -a /Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome \"$1\"\n}\n```\n\n```shell\ncode () {\n\topen -a /Applications/Visual\\ Studio\\ Code.app/Contents/MacOS/Electron \"$1\"\n}\n```\n\nWatching files\n\n`sudo fs_usage | grep my.cnf`\n\n### Obliterate MYSQL from MAC\n\n_Backup your databases_\n\nCheck for MySQL processes\n\n`ps -ax | grep mysql`\n\nStop and kill any MySQL processes\nAnalyze MySQL on HomeBrew:\n\n`brew remove mysql`\n\n`brew cleanup`\n\nRemove files:\n\n`sudo rm /usr/local/mysql`\n\n`sudo rm -rf /usr/local/var/mysql`\n\n`sudo rm -rf /usr/local/mysql*`\n\n`sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist`\n\n`sudo rm -rf /Library/StartupItems/MySQLCOM`\n\n`sudo rm -rf /Library/PreferencePanes/My*`\n\nUnload previous MySQL Auto-Login:\n\n`launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist`\n\nRemove previous MySQL Configuration:\n\n`sublime /etc/hostconfig`\n\n_Remove the line MYSQLCOM=-YES-_\nRemove previous MySQL Preferences:\n\n`rm -rf ~/Library/PreferencePanes/My*`\n\n`sudo rm -rf /Library/Receipts/mysql*`\n\n`sudo rm -rf /Library/Receipts/MySQL*`\n\n`sudo rm -rf /private/var/db/receipts/*mysql*`\n\n`sudo rm -rf /etc/my.cnf`\n\n`sudo rm -rf /etc/mysql/`\n\nReboot just to ensure any MySQL processes are killed\nTry to run mysql, it shouldn't work\n\n## MongoDB\n\nCheck if apache2 active\n\n`sudo netstat -plunt | grep apache2`\n\n### Install and fix\n\n`brew update`\n\n`brew install mongodb`\n\n`mkdir -p /data/db`\n\nIt's likely to encounter perm issues.\n\n`sudo chown -R \"id -un\" /data/db`\n\n## Browser JS\n\n```JavaScript\nAdd script to head\nvar script = document.createElement('script');\nscript.src = \"https://code.jquery.com/ui/1.12.1/jquery-ui.js\";\nscript.integrity = \"sha256-T0Vest3yCU7pafRw9r+settMBX6JkKN06dqBnpQ8d30=\";\nscript.crossOrigin = \"anonymous\";\ndocument.head.append(script);\n```\n\nChange icons Across Page\n```JavaScript\n(function (newS, selector) {\n\tvar fonts = document.querySelectorAll(selector)\n\tfonts.forEach(function(item) {\n\titem.classList.remove(selector);\n\titem.classList.add(newS);\n})   \n})('far', 'fa')\n```\n\n## Ruby\n\n### Managing gems\n\n```shell\ngem build \u003cgemname\u003e\n\ngem push \u003cgemname\u003e-\u003cversion\u003e\n```\n\n### Ruby gems credentials \n\n```shell\ncurl -u mharriss https://rubygems.org/api/v1/api_key.yaml \u003e ~/.gem/credentials; chmod 0600 ~/.gem/credentials\n```\n\n## Python\n\n### Python packages\n\n```shell\n# Install latest version of setuptools and wheel\npython3 -m pip install --user --upgrade setuptools wheel\n\n# Run in the directory where setup.py is located \npython3 setup.py sdist bdist_wheel\n\n# Install Twine to upload the generated packages\npython3 -m pip install --user --upgrade twine\n\n# Upload to test.pypi.org\npython3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcharriss%2Fgeneral_tips","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcharriss%2Fgeneral_tips","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcharriss%2Fgeneral_tips/lists"}