Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

idvorkin/techdiary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

286 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This version is now obsolete - see https://idvork.in/td

Cardinal copy is @ https://idvork.in/td Leaving this stuff here for history.


Igor's Technical Diary

Projects

Awesome Lists

VIM

C Sharp

Java

  • Lambok

Python

  • Hug: Python API generator
  • Httpie: wget replacement
  • Pendulum: The best datetime library (better then arrow).
  • PipEnv - Finally sane dependency management for python!
  • Datalore - Jetbrain's version of Jupyter
  • Requests Http requests for humans
  • Requests-HTML Web Parsing for humans
  • Scapy Web crawling for humans.
  • Records Raw SQL for humans
  • Delegator Sub process for humans
  • Pylinkvalidator - Crawl a web site for errors (great for web testing)

Typescript

Apple

Home Automation

Text manipulation tools

  • XPath and HtmlAgilityPack
  • Regexp + VIM
  • Beautiful soup

jq

jq is the JavaScript equivalent of regexp I'm very enamored with it!

By default it colorizes:

cat x.json | jq

It has funny escaping syntax - so I'll list out some recipes. Notice the specific of dots open brackets and quote types. They matter. Select every object in the array and string interpolates out object elements of name defaultHostName and appServicePlanId

cat x.json | jq '.[] | "\(.defaultHostName) \(.appServicePlanId) "'

Read the Algolia key from my secretBox

cat ~/gits/igor2/secretBox.json | jq '.AlgoliaKey'

List AWS lightsail properties

saws> aws lightsail get-instances  | jq '.instances[] | .name, .state.name, .publicIpAddress'
"Amazon_Linux-1GB-Oregon-1"
"running"
"54.190.183.299"

Cool shell tools

Decent blog posts:

https://remysharp.com/2018/08/23/cli-improved
  • Mosh - A better ssh (I no longer recommend)
  • fzf - Fuzzy file finder (Try C-R and C-T)
  • Rg - RipGrep (like ag)
  • linuxbrew - Brew for Linux
  • Ngrok - Pipe ports to the internet web site (great for local host development on iOS)
  • Bat - cat but with paging/git integration.
  • Pretty ping - Graphical Ping
  • glances - Prettier Top
  • iftop - Network based top based on network connection
  • nethogs - Network based top based on process
  • fd - Better find/recurse. (fd "regexp")

Natural Language Processing

Azure One Liners

Deploy webapp via git checkin

https://docs.microsoft.com/en-us/azure/app-service/deploy-local-git

  1. Create the git credentials to deploy which gives a new git repository.
  2. Add a git remote
  3. Push to the git remote

git

npx add-gitignore - update gitignore files

Find when text is deleted:

# ignore the path if you don't know it.
git log -c -S'missingtext' /path/to/file

Diff-So-Fancy

Diff so fancy - a very nice diff

My original git tricks from 2014 :)

Git Stats

Git stats

Tig

The TUI clone of git gui - my day to day git interface.

lazygit

Alternate TUI to tig

fac

TUI (merge tool)[https://github.com/mkchoi212/fac]

GitHub

SSH

Exit the ssh session (very helpful when stuck in a nested tmux session.

<enter> ~ .

Get help on the in built console

<enter>  ~ ?

List forwarded ports

<enter>  ~ #

Connect on 8889 will get redirected to 8888 on the remote_host.

# Connections on 4444 will get redirected to 8888 on the remote_host.
ssh -N -L localhost:8888:localhost:4444 remote_user@remote_host

Use a tool to auto re-connect (MOSH should do this, but it's been flaky for me of late)

autossh -M 0 server

For my memory here are the many ports I forward, which you can also configure in your ssh config

# jupyter
ssh -N -L localhost:8888:localhost:8888 lightsail

# jekyll
ssh -N -L localhost:4000:localhost:4000 lightsail

# jekyll live reload
ssh -N -L localhost:35729:localhost:35729 lightsail

# grip
ssh -N -L localhost:6419:localhost:6419 lightsail

TMUX

This is so hard for me to remember:

Install tmuxp to re-create sessions. Look at my config to see how to setup vi mode Look at tmux plugin manager

https://gist.github.com/MohamedAlaa/2961058

  • C-A w - See all windows and sessions.
  • C-A $ - rename session
  • C-A , - rename windows
  • C-A % - split left right
  • C-A " - split top bottom
  • C-A q - show pane #
  • C-A navigate panes
  • C-A ? - list shortcuts (then search using / )
  • C-A swap-window -t -1 -- Move window to the left
  • C-A swap-window -t 0 -- Move window to the front
  • C-A x - kill-pane

Tmux command line

Re-attach to current session

tmux attach

Force resize to current terminal size while reattaching

tmux attach -d

Random 1-liners

Clean up dead MOSH instances

kill $(ps --no-headers --sort=start_time -C mosh-server -o pid | head -n -1)

zsh path append

path+="/my/new/path"

App Launchers

  • Alfred on OSX
  • WoX on Windows + (switcheroo to switch windows) [win - app name]

Chrome extensions

Web tools (http)

wuzz

TUI http debugger

httplab

A TUI http server - The oppositve of wuzz.

httpie

httpie is like wget and curl, but easier to use.

Here's an example of sending content to a web hook which would send a message to chime. Notice -pHBhb prints request response, and Content is a JSON field.

http -pHBhb POST https://hooks.chime.aws/incomingwebhooks/botaddress -- Content=We love PMs

httpprompt

Graphical httpie with tab completion. It's actually built on httpie

bcl - Link Checkers

You'd think there would be a slew of these, but all the ones I tried weren't great (can't limit recurse depth, don't group errors, etc). I'm using bcl right now, but would love a good alternative.

Using BLC I crawl my website using (-r recurse ; -o group output; -e skip external):

    blc https://idvork.in/d -roe

scrapy - Link Checkers

I disliked bcl so much I wrote my own using scrapy

brow.sh - Text based web browser

This looks pretty cool. I had to run it in a container:

docker run --rm -it browsh/browsh

The keybindings are desktop-esk, which is too bad as they conflict with my terminal bindings. If you try it C-Q gets you out of it, can also run extensions, so I bet you could run vimium in there. Although, your'e going a little crazy at this point

w3m - Text based web browser

A text based browser better then lynx. But,

Video Manipulation Tools

Decent cross plat video editors.

ffmpeg recipes:

Convert video formats

ffmpeg -i in.mov -qscale 0 -out.mp4

Trimming

https://superuser.com/questions/138331/using-ffmpeg-to-cut-up-video As other people mentioned, putting -ss before (much faster) or after (more accurate) the -i makes a big difference. The section "Fast And Accurate Seeking" on the ffmpeg seek page tells you how to get both, and I have used it, and it makes a big difference. Basically you put -ss before AND after the -i, just make sure to leave enough time before where you want to start cutting to have another key frame. Example: If you want to make a 1-minute clip, from 9min0sec to 10min 0sec in Video.mp4, you could do it both quickly and accurately using:

ffmpeg -ss 00:08:00 -i Video.mp4 -ss 00:01:00 -t 00:01:00 -c copy VideoClip.mp4

The first -ss seeks fast to (approximately) 8min0sec, and then the second -ss seeks accurately to 9min0sec, and the -t 00:01:00 takes out a 1min0sec clip. -c copy doesn't re-transcode so faster, but has problems since needs key frames.

ffmpeg -ss 00:08:00 -i $infile -ss 00:01:00 -t 00:01:00 -c copy $outfile

Video To Gif on iOS

On github, it's common to share an inline view of a repro. A great way to do that is to make a gif of the issue. To do that on iOS you need to do do a screen recording, and then save that to a gif. I used GifMaker, seems good engouh.

Linters and formatters

You know what sucks less then coding standards? Arguing about coding standards. Nothing pains me more then arguing about formatting (and other minutia). As such I love having lint failures being build breaks and including formatting on save. Even better when you have opinionated formatters that don't have options. Sure standards suck, but they suck much less then arguing.

Switching between Unix and DOS file ending

(https://stackoverflow.com/questions/2466959/git-removing-carriage-returns-from-source-controlled-files) On windows, when you switch between windows and WSL, you can get your line endings messed up in git.

To have git honor settings in the existing files set:

In: ~.gitconfig set:

core.autocrlf=input
core.safecrlf=false

Sometimes your repository gets screwed up and needs to be fixed. In that case, erase all files, and re checkout.

#!/bin/sh
# remove local tree
git ls-files -z | xargs -0 rm
# checkout with proper crlf
git checkout .

Also, can set a single file in vim by settings set ff=unix

Spelling

Command line spelling. Ispell has nicer word highlighting, but aspell is supposed to have better spelling correction.

aspell ispell

(Bragging - I fixed aspell highlighting in WSL) GNUAspell/aspell#590 Homebrew/homebrew-core#48163

Web scripting

I like to watch YouTube (engineering documentaries) before bed, and need a sleep timer. JS will let you close a windows you opened, so this script opens a new window to watch YouTube in for an hour.

// Open in another window so I have perms to close it
var customWindow = window.open('https://youtube.com', '_blank', '');
// Close tab in 2 hours
setTimeout(()=>customWindow.close(),1000*60*120)

Programming Helpers

howdoi

A quick tool to show you how to 'spell' your task in language of choice.

> howdoi do time to minutes in python

import datetime as DT
t1 = DT.datetime.strptime('00:05:36.0100000', '%H:%M:%S.%f0')
t2 = DT.datetime(1900,1,1)

print((t1-t2).total_seconds() / 60.0)

PlantUML alternatives

Huh, turns out there are lots (for UML and graphicing, etc). Read the list here, I haven't played with them yet:

https://hackmd.io/features#UML-Diagrams

PlantUML

PlantUML Tools

  • PlantText Interactive editor with vi-keybindings, but needs a manual refresh
  • LiveUML - Interactive editor with auto-refresh
  • VS Code has a great plugin for PlantUML
  • Vim has a PlantUML preview in ASCII

PlantUML in Markdown

You can't directly render PlantUML in Markdown, but you can render images, and get PlantUML to load content from file. E.g:

https://www.plantuml.com/plantuml/proxy?idx=0&format=svg&src=**URL_with_uml_file**&cache_buster=**increment_to_avoid_caching**

Store your PlantUML file somewhere - e.g.

[https://raw.github.com/idvorkin/techdiary/master/sample_diagrams.puml](https://raw.githubusercontent.com/idvorkin/techdiary/master/sample_diagrams.puml)

Then render it like an image e.g.

![UML rendered](https://www.plantuml.com/plantuml/proxy?idx=0&format=svg&src=https://raw.githubusercontent.com/idvorkin/techdiary/master/sample_diagrams.puml&c=1)

UML rendered

Quirks

  • GitHub caches, so increment the c parameter

Windows Managers

Tools that let you re-tile

  • OSX - Magnets
  • Windows - Windows Power Toys - FancyZones

CLI Screen Recoding

OK, this is a 2 putter: First run asciinema, then svgterm

asciinema rec foo.cast
# records till you hit C-D  (curious how that works)
cat foo.cast | svg-term --out foo.svg
# Copy out your svg file

If on iOS then you need to click to open the image in a new tag

inamged image

(Note, to include an svg from raw.githubusercontent.com/blah.svg you'll need to add blah.svg?sanatize=true)

Show pressed keys

Carnac

Other Resources

Good list of tools

About

A place to store my technical journeys

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors