Today I Learned
A collection of concise write-ups on small things I learn day to day across a variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at Hashrocket.
For a steady stream of TILs from a variety of rocketeers, checkout til.hashrocket.com.
649 TILs and counting...
- Ack
- Chrome
- Clojure
- CSS
- Devops
- Elixir
- Git
- Go
- Internet
- JavaScript
- Linux
- Mac
- MySQL
- Phoenix
- PostgreSQL
- Rails
- React
- ReasonML
- Ruby
- tmux
- Unix
- Vim
- VSCode
- Webpack
- Workflow
- Access A Value Logged To The Console
- Easier Access To Network Throttling Controls
- Pretty Print Tabular Data
- Reference The Selected Node
- Selecting DOM Elements Faster Than Ever
- Simulating Various Connection Speeds
- Toggle Device Mode
- Toggle Open The Console Drawer
- Aggregation Using merge-with
- Argument Requirements For A Function
- Combinations Of Items From A Sequence
- Define Something Only Once
- Evaluate One Liners With lein-exec
- Expanding Macros
- Get The Value Of An Environment Variable
- List Functions For A Namespace
- Load A File Into The REPL
- Mapping With An Index
- Open JavaDocs
- Pretty Print The Last Thing
- Quick Clojure Docs
- Reductions
- Set Max Heap Size
- Specify the Directory of a Shell Command
- Splitting On Whitespace
- Swap Two Items in a Vector
- Try A Clojure Project In The REPL
- Type of Anything
- When Overflow Is Desired
- Apply Styles To The Last Child Of A Specific Type
- Dry Up SCSS With Mixins
- Lighten And Darken With CSS Brightness Filter
- Lighten And Darken With SCSS
- Parameterized SCSS Mixins
- Aliasing An Ansible Host
- Check The Status of All Services
- Check The Syntax Of nginx Files
- Determine The IP Address Of A Domain
- Path Of The Packets
- Push Non-master Branch To Heroku
- Reload The nginx Configuration
- Running Out Of inode Space
- Wipe A Heroku Postgres Database
- Append To A Keyword List
- Assert An Exception Is Raised
- Binary Representation Of A String
- Check For A Substring Match
- Compute md5 Digest Of A String
- Counting Records With Ecto
- Create A Date With The Date Sigil
- Create A List Of Atoms
- Creating A PID
- Creating Indexes With Ecto
- Defining Multiple Clauses In An Anonymous Function
- Determine The Latest Release Of A Hex Package
- Do You Have The Time?
- Do You Have The Time? - Part 2
- Documentation Lookup With Vim And Alchemist
- Dynamically Generating Atoms
- Execute Raw SQL In An Ecto Migration
- Expose Internal Representation
- Include Captures With String.split
- Inspecting The Process Message Queue
- List Functions For A Module
- Listing Files In IEx
- Pattern Matching In Anonymous Functions
- Quitting IEx
- Range Into List Using Comprehensions
- Referencing Values In IEx's History
- Remove One List From Another
- Replace Duplicates In A Keyword List
- Requiring Keys For Structs
- Reversing A List
- Reversing A List - Part 2
- Root Directory Of A Project
- Round Floats To Integers
- Run ExUnit Tests In A Deterministic Order
- Same Functions Should Be Grouped Together
- String Interpolation With Just About Anything
- Unique Indexes With Ecto
- Updating Values In A Map
- Virtual Fields With Ecto Schemas
- Word Lists For Atoms
- Accessing a Lost Commit
- Amend Author Of Previous Commit
- Caching Credentials
- Checking Commit Ancestry
- Checkout Old Version Of A File
- Checkout Previous Branch
- Cherry Pick A Range Of Commits
- Clean Out All Local Branches
- Clean Up Old Remote Tracking References
- Clone A Repo Locally From .git
- Delete All Untracked Files
- Determine The Hash Id For A Blob
- Diffing With Patience
- Dry Runs in Git
- Excluding Files Locally
- Find The Initial Commit
- Get The Short Version Of The Latest Commit
- Grab A Single File From A Stash
- Grep For A Pattern On Another Branch
- Grep Over Commit Messages
- Ignore Changes To A Tracked File
- Include Some Stats In Your Git Log
- Intent To Add
- Interactively Unstage Changes
- Last Commit A File Appeared In
- List All Files Changed Between Two Branches
- List Different Commits Between Two Branches
- List Filenames Without The Diffs
- List Most Git Commands
- List Untracked Files
- Move The Latest Commit To A New Branch
- Rebase Commits With An Arbitrary Command
- Reference A Commit Via Commit Message Pattern Matching
- Rename A Remote
- Renaming A Branch
- Resetting A Reset
- Show All Commits For A File Beyond Renaming
- Show File Diffs When Viewing Git Log
- Show List Of Most Recently Committed Branches
- Show The diffstat Summary Of A Commit
- Show The Good And The Bad With Git Bisect
- Single Key Presses in Interactive Mode
- Staging Changes Within Vim
- Staging Stashes Interactively
- Stashing Only Unstaged Changes
- Stashing Untracked Files
- Untrack A Directory Of Files Without Deleting
- Untrack A File Without Deleting It
- Update The URL Of A Remote
- Verbose Commit Message
- Viewing A File On Another Branch
- What Changed?
- What Is The Current Branch?
- Whitespace Warnings
- Access Go Docs Offline
- Build For A Specific OS And Architecture
- Not So Random
- Replace The Current Process With An External Command
- Sleep For A Duration
- Upgrading From An Older Version On Mac
- Add Emoji To GitHub Repository Description
- Exclude Whitespace Changes From GitHub Diffs
- Focus The URL Bar
- Search Tweets By Author
- Show All Pivotal Stories With Blockers
- Accessing Arguments To A Function
- Character Codes from Keyboard Listeners
- Computed Property Names In ES6
- Create An Array Containing 1 To N
- Create Bootstrapped Apps With Yarn
- Custom Type Checking Error Messages With Yup
- Default And Named Exports From The Same Module
- Destructuring The Rest Of An Array
- Enable ES7 Transforms With react-rails
- Expand Emojis With The Spread Operator
- Fill An Input With A Ton Of Text
- Freeze An Object, Sorta
- Get The Location And Size Of An Element
- Globally Install A Package With Yarn
- Immutable Remove With The Spread Operator
- Initialize A New JavaScript Project With Yarn
- Install The Latest Version Of Node With Nvm
- ISO-8601 Formatted Dates Are Interpreted As UTC
- Link A JavaScript Package Locally
- List Top-Level NPM Dependencies
- Matching Multiple Values In A Switch Statement
- New Dates Can Take Out Of Bounds Values
- Numbers Are Empty
- Object Initialization With Shorthand Property Names
- Random Cannot Be Seeded
- Render An Array Of Elements With React 16
- Running ES6 Specs With Mocha
- Scoping Variables With A Block Statement
- Splat Arguments To A Function
- Spread The Rest With ES6
- String Interpolation With Template Literals
- Throttling A Function Call
- Timing Processes
- Transforming ES6 and JSX With Babel 6
- Truthiness of Integer Arrays
- Waiting On Multiple Promises
- Who Am I: NPM Edition
- Yarn Commands Without The Emojis
- Yup Schemas Are Validated Asynchronously
- Check Ubuntu Version
- Configure Your Server Timezone
- List The Statuses Of All Upstart Jobs
- Upgrading Ubuntu
- Clean Up Old Homebrew Files
- Default Screenshot Location
- Display A Message With Alfred
- Insert A Non-Breaking Space Character
- List All The Say Voices
- Require Additional JS Libraries In Postman
- Resizing Both Corners Of A Window
- Run A Hardware Check
- Display Output In A Vertical Format
- Dump A Database To A File
- List Databases And Tables
- Show Create Statement For A Table
- Show Tables That Match A Pattern
- Show Indexes For A Table
- Bypass Template Rendering
- Check The Installed Version
- Generate New App Without Brunch
- Render A Template To A String
- Serve Static Assets From Custom Directory
- Specifying The Digest Directory
- Specifying The Server Port
- A Better Null Display Character
- Add ON DELETE CASCADE To Foreign Key Constraint
- Adding Composite Uniqueness Constraints
- Aggregate A Column Into An Array
- Assumed Radius Of The Earth
- Auto Expanded Display
- Between Symmetric
- Capitalize All The Words
- Change The Current Directory For psql
- Checking Inequality
- Checking The Type Of A Value
- Clear The Screen In psql
- Clear The Screen In psql (2)
- Compute Hashes With pgcrypto
- Compute The md5 Hash Of A String
- Configure The Timezone
- Constructing A Range Of Dates
- Count Records By Type
- Create A Composite Primary Key
- Create hstore From Two Arrays
- Create Table Adds A Data Type
- Creating Conditional Constraints
- Creating Custom Types
- Day Of Week By Name For A Date
- Day Of Week For A Date
- Default Schema
- Defining Arrays
- Determining The Age Of Things
- Dump And Restore A Database
- Edit Existing Functions
- Escaping A Quote In A String
- Escaping String Literals With Dollar Quoting
- Export Query Results To A CSV
- Extracting Nested JSON Data
- Find The Data Directory
- Find The Location Of Postgres Config Files
- Fizzbuzz With Common Table Expressions
- Generate A UUID
- Generate Series Of Numbers
- Generating UUIDs With pgcrypto
- Get The Size Of A Database
- Get The Size Of A Table
- Get The Size Of An Index
- Getting A Slice Of An Array
- Insert Just The Defaults
- Integers In Postgres
- Intervals Of Time By Week
- Is It Null Or Not Null?
- Limit Execution Time Of Statements
- List All Columns Of A Specific Type
- List All Rows In A Table
- List All The Databases
- List All Versions Of A Function
- List Available Schemas
- List Connections To A Database
- List Database Objects With Disk Usage
- List Database Users
- List Various Kinds Of Objects
- Lower Is Faster Than ilike
- Max Identifier Length Is 63 Bytes
- pg Prefix Is Reserved For System Schemas
- Prepare, Execute, And Deallocate Statements
- Pretty Print Data Sizes
- Pretty Printing JSONB Rows
- Print The Query Buffer In psql
- Renaming A Sequence
- Renaming A Table
- Restart A Sequence
- Restarting Sequences When Truncating Tables
- Salt And Hash A Password With pgcrypto
- Send A Command To psql
- Set Inclusion With hstore
- Set A Seed For The Random Number Generator
- Sets With The Values Command
- Show All Versions Of An Operator
- Sleeping
- Special Math Operators
- Storing Emails With citext
- String Contains Another String
- Temporarily Disable Triggers
- Temporary Tables
- Terminating A Connection
- Timestamp Functions
- Toggling The Pager In PSQL
- Truncate All Rows
- Truncate Tables With Dependents
- Turning Timing On
- Two Ways To Compute Factorial
- Types By Category
- Use A psqlrc File For Common Settings
- Use Argument Indexes
- Use Not Valid To Immediately Enforce A Constraint
- Using Expressions In Indexes
- Using Intervals To Offset Time
- Who Is The Current User
- Word Count for a Column
- Write A Query Result To File
- Add React With Webpacker To A New Rails App
- Advance The Date
- All or Nothing Database Transactions
- Attach A File With Capybara
- Attribute Getter without the Recursion
- Attribute Was
- Autosave False On ActiveRecord Associations
- Capybara Page Status Code
- Change The Nullability Of A Column
- Code Statistics For An Application
- Conditional Class Selectors in Haml
- Convert A Symbol To A Constant
- Creating Records of Has_One Associations
- Custom Validation Message
- Demodulize A Class Name
- Generating And Executing SQL
- Hash Slicing
- Ignore Poltergeist JavaScript Errors
- List The Enqueued Jobs
- Mark For Destruction
- Migrating Up Down Up
- Params Includes Submission Button Info
- Perform SQL Explain With ActiveRecord
- Polymorphic Path Helpers
- Pretend Generations
- Read-Only Models
- Remove The Default Value On A Column
- Rescue From
- Retrieve An Object If It Exists
- Select A Select By Selector
- Select Value For SQL Counts
- Set Schema Search Path
- Show Pending Migrations
- Show Rails Models With Pry
- Show Rails Routes With Pry
- Truncate Almost All Tables
- Where Am I In The Partial Iteration?
- A Component Is Just A Bag Of Data
- Accessing Env Vars In create-react-app
- Alter The Display Name Of A Component
- create-react-app Comes With Lodash
- Defining State In A Simple Class Component
- Destructure Variables As Props To A Component
- Dispatch Anywhere With Redux
- Dynamically Add Props To A Child Component
- Force A Component To Only Have One Child
- Inactive And Active Component Styles With Radium
- Inline Style Attributes Should Be Camel Cased
- Mapping Over One Or Many Children
- Passing Props Down To React-Router Route
- Proxy To An API Server In Development With CRA
- Quickly Search For A Component With React DevTools
- Read Only Input Elements
- Rendering Multiple Nodes With Fragments
- Use A Ref To Autofocus An Input
- Use withRouter To Pass Down React-Router History
- Visually Select A React Element For Inspection
- Who Is Your Favorite Child?
- Defining Variants With Constructor Arguments
- Exhaustive Pattern Matching Of List Variants
- Helping The Compiler Help Us With Variants
- Inline Component Styles With Reason React
- Multi-Argument Functions As Syntactic Sugar
- Pattern Match On Exceptions
- Quickly Bootstrap A React App Using Reason
- Seeding And Generating Random Integers
- String Interpolation With Integers And Sprintf
- String Interpolation With Quoted Strings
- Are They All True?
- Assoc For Hashes
- Block Comments
- Chaining Multiple RSpec Change Matchers
- Colorful Output With MiniTest
- Comparing Class Hierarchy Relationships
- Comparing Arrays In RSpec
- Construct A Constant From A String
- Create an Array of Stringed Numbers
- Create A Hash From An Array Of Arrays
- Create Thumbnail Image For A PDF
- Defaulting To Frozen String Literals
- Destructuring Arrays In Blocks
- Disassemble Some Codes
- Double Splat To Merge Hashes
- Edit Previous Parts Of The Pry Buffer History
- Editing Code In Pry
- Evaluating One-Off Commands
- FactoryGirl Sequences
- Fail
- Finding The Source of Ruby Methods
- Identify Outdated Gems
- If You Detect None
- Ins And Outs Of Pry
- Invoking Rake Tasks Multiple Times
- Last Raised Exception In The Call Stack
- Limit Split
- Listing Local Variables
- Navigate Back In The Browser With Capybara
- Next And Previous Floats
- Or Operator Precedence
- Override The Initial Sequence Value
- Parallel Bundle Install
- Pass A Block To Count
- Passing Arbitrary Methods As Blocks
- Passing Arguments To A Rake Task
- Percent Notation
- Question Mark Operator
- Rake Only Lists Tasks With Descriptions
- Rendering ERB
- Replace The Current Process With An External Command
- Require Entire Gemfile In Pry Session
- Rerun Only Failures With RSpec
- Returning With Sequel
- Running A Single MiniTest Example
- Safe Navigation Operator
- Scroll To Top Of Page With Capybara
- Set RVM Default Ruby
- Show Public Methods With Pry
- Squeeze Out The Extra Space
- String Interpolation With Instance Variables
- Summing Collections
- Uncaught Exceptions In Pry
undef_method
And The Inheritance Hierarchy- Up And Down With Integers
- Use A Case Statement As A Cond Statement
- Use dotenv In A Non-Rails Project
- Who Are My Ancestors?
- Zero Padding
- Adjusting Window Pane Size
- Break Current Pane Out To Separate Window
- Create A Named tmux Session
- Create A New Session In A New Server
- Cycle Through Layouts
- Enabling Vi Mode
- Hiding The Status Bar
- Jumping Between Sessions
- Kill Other Connections To A Session
- Kill The Current Session
- List All Key Bindings
- List Sessions
- Open New Window With A Specific Directory
- Organizing Windows
- Paging Up And Down
- Pane Killer
- Reclaiming The Entire Window
- Rename The Current Session
- Swap Split Panes
- tmux in your tmux
- All The Environment Variables
- Cat A File With Line Numbers
- Change Default Shell For A User
- Change To That New Directory
- Check If A Port Is In Use
- Check The Current Working Directory
- Clear The Screen
- Command Line Length Limitations
- Copying File Contents To System Paste Buffer
- Create A File Descriptor with Process Substitution
- Curling For Headers
- Curling With Basic Auth Credentials
- Display All The Terminal Colors
- Display Free Disk Space
- Do Not Overwrite Existing Files
- Exclude A Directory With Find
- File Type Info With File
- Find Newer Files
- Forward Multiple Ports Over SSH
- Get The Unix Timestamp
- Global Substitution On The Previous Command
- Globbing For All Directories In Zsh
- Globbing For Filenames In Zsh
- Grep For Files Without A Match
- Grep For Multiple Patterns
- Hexdump A Compiled File
- Jump To The Ends Of Your Shell History
- Kill Everything Running On A Certain Port
- Killing A Frozen SSH Session
- Last Argument Of The Last Command
- Less With Style
- List All Users
- List Files Ordered By Modification Date
- List Names Of Files With Matches
- List Of Sessions To A Machine
- List Parent pid With ps
- List The Available JDKs
- Map A Domain To localhost
- Only Show The Matches
- Open The Current Command In An Editor
- Partial String Matching In Bash Scripts
- PID Of The Current Shell
- Repeat Yourself
- Saying Yes
- Search Files Specific To A Language
- Search History
- Search Man Page Descriptions
- Securely Remove Files
- Show Disk Usage For The Current Directory
- Show The Size Of Everything In A Directory
- SSH Escape Sequences
- SSH With Port Forwarding
- Sort In Numerical Order
- Switch Versions of a Brew Formula
- Undo Some Command Line Editing
- View A Web Page In The Terminal
- Watch The Difference
- Watch This Run Repeatedly
- Where Are The Binaries?
- Absolute And Relative Line Numbers
- Add A File Without Loading It
- Add Custom Dictionary Words
- Almost The End Of The Line
- Alternate Files With vim-rails
- Amend Commits With Fugitive
- Backspace Options
- Beginning And End Of Previous Change
- The Black Hole Register
- Blank Lines Above And Below
- Breaking The Undo Sequence
- Buffer Time Travel
- Build And Install A Go Program
- Case-Aware Substitution With vim-abolish
- Case-Insensitive Substitution
- Center The Cursor
- Check For An Executable
- Check Your Current Color Scheme
- Close All Other Splits
- Close All Other Windows
- Close the Current Buffer
- Coerce The Current Filetype
- Coercing Casing With vim-abolish
- Count the Number of Matches
- Create A New Directory In netrw
- Create A New File In A New Directory
- Creating Non-Existent Directories
- Default netrw To Tree Liststyle
- Delete Every Other Line
- Delete Lines That Match A Pattern
- Delete To The End Of The Line
- Deleting Buffers In BufExplorer
- Deleting Directories Of Files From netrw
- Detect If You Are On A Mac
- Difference Between :wq and :x
- Display Word Count Stats
- Edges Of The Selection
- End Of The Word
- Escaping Terminal-Mode In An Nvim Terminal
- Filter Lines Through An External Program
- Fix The Spelling Of A Word
- Fold A Visual Selection And Expand It Back
- Format Long Lines To Text Width
- From Ruby Variables To JavaScript Variables
- Generate and Edit Rails Migration
- Get The pid Of The Session
- Go To File With Line Number
- Grepping Through The Vim Help Files
- Head of File Name
- Help For Non-Normal Mode Features
- Highlighting Search Matches
- Horizontal to Vertical and Back Again
- Increment All The Numbers
- Incremental Searching
- Interact With The Alternate File
- Interactive Buffer List
- Joining Lines Together
- Jump To Matching Pair
- Jump To The Next Misspelling
- List All Buffers
- List Of Plugins
- Load A Directory Of Files Into The Buffer List
- Marks Across Vim Sessions
- Match The Beginning And End Of Words
- Moving To A Specific Line
- Navigating By Blank Lines
- NETRW Listing Styles
- Next Modified Buffer
- Open A Tag In A Split Window
- Open an Unnamed Buffer
- Open Routes File With vim-rails
- Open The Directory Of The Current File
- Open The Gemfile
- Open The Latest Rails Migration
- Open Vim To A Tag Definition
- Opening a URL
- Opening Man Pages In Vim
- Paste A Register From Insert Mode
- Preventing Typos with Abbreviations
- Previous Buffer
- Previous Visual Selection
- Print Version Information
- Quick File Info
- Quick Man Pages
- Quick Quickfix List Navigation
- Quickly Switch To A Buffer By Number
- Re-indenting Your Code
- Read In The Contents Of A Rails File
- Rename Current File
- Repeat The Previous Change
- Repeating Characters
- Replace A Character
- Reset Target tslime Pane
- Reverse A Group Of Lines
- Rotate Everything By 13 Letters
- Running Bundle With vim-bundler
- Scrolling Relative to the Cursor
- Searching For Hex Digits
- Set End Of Line Markers
- Set Your Color Scheme
- Setting Filetype With Modelines
- Show All Syntax Highlighting Rules
- Show Matching Entries For Help
- Split Different
- Split The Current Window
- Splitting For New Files
- Swap Occurrences Of Two Words
- Swapping Split Windows
- Tabs To Spaces
- The Vim Info File
- Toggle Absolute And Relative Paths In BufExplorer
- Toggling Syntax Highlighting
- Turning Off Search Highlighting
- Unloading A Buffer
- Use Active Window With BufExplorer
- Verbose Commits With Fugitive
- View Commit History of a File
- Viewing Man Pages with man.vim
- Vim Without The Extras
- What Is On The Runtime Path?
- Whole Line Auto-Completion
- Wrap With Some Room
- Better Module Imports With Aliases
- Debugging With Full Source Maps
- Run ESLint As A Preloader
- Specify Port Of CRA's Webpack Dev Server
- Use A Specific Config File
The .vimrc
file for this project contains a function CountTILs
that can
be invoked with <leader>c
. This will do a substitution count of the
current number of TILs and display the result in the command tray.
I shamelessly stole this idea from thoughtbot/til.
© 2015-2018 Josh Branchaud
This repository is licensed under the MIT license. See LICENSE
for
details.