rockyourcode: How I Remove Duplicate Lines From a File With awk, Notes on ”How to Promote Yourself to Potential Employers”, TIL: Pass Multiple Commands to Xargs, Notes on ”CBT for Imposter Syndrome and Career Advancement”, Doubts About My Daily Blogging Experiment, TIL: How to Set Multiple GOPATHs, Notes on ”The Counterintuitive Secret to Shipping Better Articles Faster”
Hello 👋! Thanks for subscribing.
Here are the articles from last week:
How I Remove Duplicate Lines From a File With awk
Published on: 2021-06-28
tags: TIL, Unix, Shell
One of the repositories I maintain is a beginner’s GitHub repo. New developers can make their first pull request by adding their GitHub handle to a simple text file.
When pull requests get merged into the master branch, they often contain duplicates. The file has more than 7,000 lines. Names are not sorted alphabetically.
I needed a simple way to remove all duplicates lines from the file without sorting the lines.
I’m using awk
, a Unix shell program. I’m not proficient in using awk
, but I’ve found useful one-liners that do what I want.
For reference, this is how my file should look like:
# CONTRIBUTORS
- [@RupamG](https://github.com/RupamG)
- [@hariharen9](https://github.com/hariharen9)
- [@clevermiraz](https://github.com/clevermiraz)
- [@smeubank](https://github.com/smeubank)
- [@LJones95](https://github.com/LJones95)
- [@shannon-nz](https://github.com/shannon-nz)
- [@sammiepls](https://github.com/sammiepls)
Here’s how it often looks like:
# CONTRIBUTORS
- [@RupamG](https://github.com/RupamG)
- [@hariharen9](https://github.com/hariharen9)
- [@clevermiraz](https://github.com/clevermiraz)
- [@smeubank](https://github.com/smeubank)
- [@LJones95](https://github.com/LJones95)
- [@hariharen9](https://github.com/hariharen9)
- [@shannon-nz](https://github.com/shannon-nz)
- [@sammiepls](https://github.com/sammiepls)
- [@shannon-nz](https://github.com/shannon-nz)
1. Remove all empty lines
awk 'NF > 0' file.txt
NF
is the Number of Fields Variable.
2. Remove duplicates
awk '!seen[$0]++' file.txt
I stole this command from opensource.com, where you can find an explanation on how it works.
3. Add Empty Lines Again
awk '{print; print "";}' file.txt
See Stackexchange.
Links
Notes on ”How to Promote Yourself to Potential Employers”
Published on: 2021-06-27
tags: Notes, Lab
In this talk, Abbey Perini enthusiastically shares her tips for showcasing your strengths for the job search as a software developer.
How to Practice Confidence
- collect wins
- set goals (beware the productivity trap)
- mantras
- building things (no coding)
- vision boards
- find a support network (helpful: other people that are also going through a similar experience)
- rest & recuperate
How to Apply Your New Confidence
- practice “self-promotion”: it feels icky at first!
- what are your top 3 skills? practice telling others about them!
Job Search
- no one ever matches the job description 100%!
- requirements: if you meet at least one of them, you are normally qualified enough to apply
- search for keywords that you meet: tech stack, job description, etc.
- use those keywords for the cover letter/resume
- for prior job experience in a non-tech role: your experience applies, especially soft skills
- previous job experience shows that you are reliable, you are employable
- if you are stay-at-home-parent or have other gaps in your resume, come up with your story about the gap and practice it (note: watch this part of the YouTube video for great tips!)
Interview Questions
- “Tell us a little about yourself”
- “Tell us about a difficult project you worked on and how you handled it.”
- “Tell me about [X] project from your resume.”
- for career transitioners: practice to describe your learning process
- re-frame your doubts: you can always find reasons to discount your experience, but is that true? You have skills!
Other Tips
- networking
- online presence
- share your learnings, share that you’re on a job search, share the cool thing that you made (loose the caveats)
- references
Links
- How to Promote Yourself to Potential Employers – Abbey Perini – Virtual Coffee Brownbag
- Abbey Perini
- Virtual Coffee — a community for all developers
image credit: Karsten Winegart
TIL: Pass Multiple Commands to Xargs
Published on: 2021-06-26
tags: TIL, Unix, Shell
I’m using fd
, an alternative to the Unix native find
, to find a list of files and copy them to a different location, using xargs
. On Unix, we use cp
to copy the files, but the command is silent.
I don’t know which files cp
will copy. Maybe I could use echo
to log the files?
How can I pass multiple shell commands to xargs
?
Previous command:
fd --changed-within 1hour -0 | xargs -I cp {} /new/location/
fd -0 --changed-within
: find all files changed within a time frame, separate results by null character|
: pipe previous command asstdin
to the next commandxargs -I cp {} /new/location/
: takes the input from previous command (fd
) and usescp
to copy the files;{}
is a placeholder
What does not work:
fd --changed-within 1hour -0 | xargs -I cp {} /new/location/ | xargs -I echo {}
What does work:
fd --changed-within 1hour -0 | xargs -0 sh -c \
'for arg do echo "$arg"; cp "$arg" /new/location/; done' _
xargs -0
: use null as separating character (useful for files that contain whitespace)sh -c
: read commands from next string'for arg do echo "$arg"; cp "$arg" /new/location/; done' _
: loop over each input and first useecho
to log, thencp
to new location_
is a placeholder for$0
, such that other data values added byxargs
become$1
and onward, which happens to be the default set of values afor
loop iterates over.
This is shell magic to me!
I found the solution on StackOverflow, where you can also find a more detailed explanation.
Notes on ”CBT for Imposter Syndrome and Career Advancement”
Published on: 2021-06-25
tags: Notes, Lab
Here are my notes from the ~ 45 min talk by Rahat Chowdhury.
What is CBT?
Cognitive Behavioral Therapy is a talk therapy where you challenge your thoughts.
Example of an initial thought (imposter syndrome):
They gave me the job and I don’t understand why. I couldn’t finish the code challenge and the interviewer had to guide me through the process. How will I manage to do this job on my own?
Cognitive Distortions
Cognitive Distortions are how your mind fools you.
Examples:
- filtering: removing the positive information and focusing on the negative ones
- catastrophizing - exaggerating an event to an absolute worst case scenario
- always being right
- polarized thinking
- overgeneralization
- jumping to conclusions
- fallacy of change
- shoulds: “I should have done that differently.”
Challenge your thoughts!
Imposter Syndrome
We need to explore the deeper reasoning behind our imposter syndrome.
Strategies to Help With Imposter Syndrome
- record your wins (in private or public)
- wins are wins even if they are small
- use those for stories to tell in interviews
- remember that it’s a process: you will suck at it first, until you get better
Links
- CBT for Imposter Syndrome and Career Advancement – Rahat Chowdhury – Virtual Coffee Brownbag
- Rahat Chowdhury
- Virtual Coffee — a community for all developers
Doubts About My Daily Blogging Experiment
Published on: 2021-06-24
tags: this_blog, Writing, Lab
Last month I decided to try to write a blog post each day.
Today’s article is the embodiment of my frustration with this experiment.
While I code every day, some days I don’t have anything interesting to share. No learnings, no insights that warrant a blog post.
Today the daily writing habit feels pointless.
I will try to keep it up for a few days more.
My new job (first job in tech!) starts next week. Will this be the time to ditch the writing experiment?
TIL: How to Set Multiple GOPATHs
Published on: 2021-06-23
tags: TIL, Go, Unix, Fish, Shell
How to set multiple workspaces (GOPATH)
A Go Workspace is how Go manages our source files, compiled binaries, and cached objects used for faster compilation later. It is typical, and also advised, to have only one Go Workspace, though it is possible to have multiple spaces. The
GOPATH
acts as the root folder of a workspace. 1
Why multiple workspaces?
I’d like to install my global binaries into a central location. These programs are third-party CLIs that I want to use everywhere in my terminal as a consumer. I don’t develop these progams.
At the same time, I’d like to make sure that my GOPATH
is correct for my actual projects that I’m working on.
Executables are installed in the directory named by the GOBIN environment variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH environment variable is not set. 2
How to Set GOPATH?
Check the wiki for your operating system and shell.
For Unix, Fish shell:
set -x -U GOPATH $HOME/.go:$HOME/projects/go/workspace
This command sets an universal variable for both $HOME/.go
and $HOME/projects/go/workspace
.
Fish Shell: Add GOPATH folders to $fish_user_paths
Use fish_add_path
to add more locations to fish’s $PATH
.
To use the “global” Go binaries as well as your own workspace binaries:
fish_add_path $HOME/.go
fish_add_path $HOME/projects/go/workspace
Notes on ”The Counterintuitive Secret to Shipping Better Articles Faster”
Published on: 2021-06-22
tags: Notes, Lab
In this ~1 hour video developer advocate Sam Julien shares his tips for shipping faster:
tl;dr
You’ll need a system that enables you to consistently produce results on which you can get feedback on.
Action + Speed + Feedback = Growth
How to Create Consistently?
The problem:
The “Ultimate Guide” Trap: Trying to write a big, all-encompassing article leads to exhaustion and burn-out. You stop writing for months.
The Developer Content Creator Cycle
- Overwhelming to know what to create
- Difficult to cross things off the list (unfinished drafts)
- Never-ending cycle
Explorer’s Mindset
Don’t think of content (or any other skill you’re building) as a dictionary to memorize.
Instead: think like an explorer.
The secret lies in Consistent Small Wins.
Comfort is the enemy of growth.
(But self-care, too!)
Sam does not encourage the “hustle mindset”.
How to Grow
Do challenging things quickly and get feedback.
What?
- production-focused (article, video)
- trackable
- measurable
Getting feedback:
- does it work?
- learning in groups
- learning in public
Building a Content System
Systems trump Motivation
Build a small but complete system.
1. Draft
- gathering notes
- creating an outline
- first draft
2. Create
- writing/recording
- adding images
- code samples
3. Publish
- publish on your site
- adding social images
- cross-posting
4. Promote
- Twitter threads
- forums & chat groups
- talks
5. Garden
- Update over time
- maintain & correct
- cross-link
Creation Phase (Step 1 to 3)
Tools
Scratch pad
Eliminate the distraction of figuring out where to jot something down.
Look for: speed, ease of use, ability to export.
Google Keep, Drafts app, etc.
Knowledge Base
Slow burn your drafts and link your ideas together.
Look for: cross-linking, collections, multimedia.
Evernote, Obsidian, Roam, Notion.so, etc.
Task Manager
Ship things faster by determining the next action and context for a project.
Look for: works with your brain, ability to add context/tags
OmniFocus, Google Keep, etc.
Tips for Creating Content
- In the beginning, move fast to define your process (do tiny expirements).
- Start with what you know.
- Stuck? Try the TIL format.
- Don’t over-engineer too quickly.
TIL Format
- Intro: 2 or 3 sentences describing the problem.
- Body: describe the solution and how you got there.
- Final Solution: Finished code for copy&paste.
- Conclusion: 1 or 2 sentences re-capping the problem and solution.
Post-Publication Phase (Step 3 to 5)
- Every piece of content has a price tag (promotion & maintenance).
- Provide direct value on each platform (don’t dump your stuff).
- Be patient.
Links
- The Counterintuitive Secret to Shipping Better Articles Faster - Sam Julien at Hashnode Bootcamp III
- Talk Resources
image credit for the cover image: Andy Li
Thank you for reading my blog.