#!/usr/bin/env python3 import asyncio import iterm2 import time async def main(connection): app = await iterm2.async_get_app(connection) @iterm2.RPC async def clear_current_tab(): code = b'\x1b' + b']1337;ClearScrollback' + b'\x07' window = app.current_terminal_window tab = window.current_tab for session in tab.sessions: await session.async_inject(code) await clear_current_tab.async_register(connection) iterm2.run_forever(main)Now bind it to a keystroke in Prefs > Keys by selecting the action Invoke Script Function and giving it the invocation clear_current_tab().
8.10.2020
iterm2 Clear all Sessions on Current Tab
On mac, save this as /Users/[username]/Library/Application Support/iTerm2/Scripts/AutoLaunch/clear_current_tab.py
7.14.2020
Use nvm For Managing Dev Environments For Any Version of Angular
Install nodejs 1. Install xcode $ xcode-select --install 2. Install nvm $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash 3. Open another bash session to get settings from nvm install 4. List installed node versions $ nvm list 5. Or list from the cloud (last 9 versions) $ nvm ls-remote | tail -n9 6. Install v14.5.0 $ nvm install v14.5.0 7. Setup this version as default $ nvm use v14.5.0 $ nvm alias default v14.5.0 8. Check node version $ node -v v14.5.0 9. Update npm $ npm install -g npm 10. Check npm version $ npm -v 6.14.6 Install yarn package manager 1. $ npm install -g yarn Install angular cli on local project 1. Go to project base directory $ cd ./project/ui 2. Add angular cli (with versioning if needed) $ yarn add @angular/cli@9.1.12 3. Check version $ ng --version Angular CLI: 9.1.12 Node: 14.5.0 OS: darwin x64 Angular: 9.1.12
3.20.2020
Revert back to previous Django Migration
This procedure is only for the development environment while actively working on changes. Say you have several migrations already created but since after making changes realized that some of them are unnecessary and you want to come up with just one migration before checking in code for production deploy. This procedure will revert back migrations to previous level and then will give opportunity to create just one migration file that can then be deployed to production. This can potentially damage databases if not applied properly so use your discernment.
1. Show migrations for an app $ python3 manage.py showmigrations orchestrator ... [X] 0051_auto_20191217_2328 [X] 0052_auto_20200212_2250 [X] 0053_job_miscellaneous 2. If you want to revert back the last 2 migrations $ python3 manage.py migrate orchestrator 0051_auto_20191217_2328 Operations to perform: Target specific migration: 0051_auto_20191217_2328, from orchestrator Running migrations: Rendering model states... DONE Unapplying orchestrator.0053_job_miscellaneous... OK Unapplying orchestrator.0052_auto_20200212_2250... OK 3. Show migrations again $ python3 manage.py showmigrations orchestrator ... [X] 0051_auto_20191217_2328 [ ] 0052_auto_20200212_2250 [ ] 0053_job_miscellaneous 4. Delete the undesired migration files $ rm 0052_auto_20200212_2250.py 0053_job_miscellaneous.py 5. Show migrations again $ python3 manage.py showmigrations orchestrator ... [X] 0051_auto_20191217_2328 6. Now make a new migration. This will have all latest changes in model $ python3 manage.py makemigrations Migrations for 'orchestrator': orchestrator/migrations/0052_job_miscellaneous.py - Add field miscellaneous to job 7. Now apply new migration $ python3 manage.py migrate Running migrations: Applying orchestrator.0052_job_miscellaneous... OK
Subscribe to:
Posts (Atom)