OOZOU
與我們聯繫
Insights

Today I Learned

Short, practical notes from the OOZOU team: quick lessons from daily engineering and design work.

all topicsshell 30ruby on rails 22ruby 12macos 10vim 7figma 4cli 3javascript 3heroku 1elixir 1
cliFebruary 16, 2026

Run Claude Code Fully Autonomously with a YOLO Alias

The --dangerously-skip-permissions flag lets Claude Code run commands and edit files without confirmation prompts. Typing it every time gets old fast.

cliMarch 20, 2024

Run a command on your GNU/Linux dedicated Nvidia GPU (e.g. ollama)

To make sure a command (CLI) is using your NVIDIA GPU in GNU/Linux, you can use the environment variables \\NV\PRIME\RENDER\OFFLOAD=1 and \\GLX\VENDOR\LIBRARY\NAME=nvidiabefore your command.

ruby on railsFebruary 10, 2022

Use Pundit Policies to manage permitted parameters, defaults and per action

To manage permitted params you can add permitted\attributes and permitted\attributes\for\#{action} in your policies e.g.

ruby on railsJanuary 31, 2022

Use `requestSubmit` for form submits with Turbo

Turbo listens to submit events on form.  Hence, always use requestSubmit to submit  a form using JS.

ruby on railsJanuary 19, 2022

Ignore bundled gems for Rubocop and ESLint in GitHub Actions

Rails projects will often install gems into the vendor directory in GitHub actions so we can cache them for the consecutive runs.

macosAugust 20, 2021

Add a macOS-style drop shadow to your "partial" screen captures or plain-bordered images

By default, and like it or hate it, the macOS keystrokes to capture full app screen (⇧- ⌘- 5) will add a subtle drop shadow around your saved image.  This can make it more visually appealing when…

figmaJune 22, 2021

Create monochrome screen using overlay layers covered with hue fill effect

Create monochrome screen using overlay layers covered with hue fill effect

figmaJune 18, 2021

Hold ⌥option while click & drag along an input field to adjust sizing

Hold ⌥option while click & drag along an input field to adjust sizing

cliMay 25, 2021

git check-ignore

This command lets you debug if a certain file/path is ignored and, with the -v flag, it also shows you the matching exclude pattern (Docs).

rubyApril 30, 2021

Allow pasting multiline ruby blocks in Pry when using leading dot notation

We use leading dot notation a lot now e.g.

ruby on railsApril 18, 2021

Rails 6, Ruby 3, Bootstrap 5 and Hotwire

Extending the blogpost from Bootrails with Hotwire: All the fancy new things (as of when I'm writing this TIL):

figmaFebruary 17, 2021

Convert Text Object to Title Case in Figma

You can set Text box property to convert everything into Title Case automatically (along with other common text cases)

herokuJanuary 6, 2021

Reduce Heroku Slug Size

First, install the Heroku Repo plugin:

shellDecember 8, 2020

Run incognito/private commands for Bash and Zsh

Simply put a space before the command and it won't be saved to ~/.bash\_history. E.g. qrencode -o out.png "Some secret text"

macosNovember 7, 2020

Convert SVG to PNG

On MacOS, install inkscape (with brew) and use it like this:

figmaOctober 31, 2020

CMD+Click behaviour in Figma

Holding ⌘CMD+Left Clicking in Designer mode will select the deepest layer resides within that frame/group whilst doing so in inspector/developer mode will select the outermost object/frame/group…

ruby on railsOctober 27, 2020

Rails Cache-Control

For enabling setting cache-control headers of static assets and using a CDN on Heroku:

shellOctober 22, 2020

Upgrade postgres database with homebrew

To upgrade postgres you can run

ruby on railsOctober 14, 2020

Fix input on Heroku's rails console

If you end up pasting lots of lines into a rails console on Heroku (or else where), you might get issues with the lines "bleeding" into each other.

rubyOctober 14, 2020

Heredoc without interpolation

Sometimes you want to use Ruby's Heredoc without interpolation ('#{....}'). You can do this by adding single dashes around your keyword:

ruby on railsOctober 14, 2020

Unique ID for DOM in Rails

Rails has many great view helpers, one of which is dom\id:*

ruby on railsOctober 13, 2020

Add new types to Rails 5 attributes API

The Rails 5 attributes API allows us to build form objects very easily.

macosOctober 13, 2020

Add spacers to your macOS app dock to make groups

Open term (or equivalent) and paste the following one-liner:

shellOctober 13, 2020

Amazon AWS S3 CLI copy with set perms

Open term (or equivalent) and paste the following:

shellOctober 13, 2020

Angry Docker Purge

If you receive No Space left error on Docker this the brute force solution:

ruby on railsOctober 13, 2020

Attaching file to ActiveStorage without HTTP

If you want to attach a file you generated on disk or downloaded from a user-submitted URL, you can do it like this.

rubyOctober 13, 2020

Automagical Intermediate-level Hashtables in Ruby

All intermediate-level hashtables will be created automagically

shellOctober 13, 2020

Back up a file with same name + prefix

NOTE: Actually you can use !#:1 in every command 'cause that's last argument passed to a command.

shellOctober 13, 2020

Bash aliases and magic

I have a seperate file in my user folder named ~/.aliases. I use this to store all of my bash aliases. I use aliases a lot and add new ones regularly so I created a bash function to add new aliases…

elixirOctober 13, 2020

Calculate anagrams in Elixir

For example:

rubyOctober 13, 2020

Change Ruby version for single command with rbenv

You can switch Ruby version temporarily with rbenv local

macosOctober 13, 2020

Change system names on macOS

From term (or equivalent), copy and paste:

rubyOctober 13, 2020

Change VS Code Go to definition to Cmd+Click

Just open your user settings JSON file and use this option:

shellOctober 13, 2020

Check for IKEA item availability

If you're waiting for an IKEA item to restock, here's a practical solution to stay updated automatically. This guide explains how to use a shell script to check IKEA's stock availability and get…

shellOctober 13, 2020

Check if command exists with shell script

Check if command exists with shell script

macosOctober 13, 2020

Chrome tab manipulation

Sometimes I want to go back to the last page I viewed while still keeping the same one open. You can very easily achieve this with shortcuts

macosOctober 13, 2020

Cleanup stale formulas on brew

Use brew cleanup to get some spaces back!

ruby on railsOctober 13, 2020

Create a Hash from an Enumerable (Rails 6.0)

New method allowing you to create a Hash from an Enumerable:

ruby on railsOctober 13, 2020

Create idempotent migrations

When you want to write destructive migrations please use if\exists: true when you’re trying to remove a table and check for a table existence when you want to add or remove a column…

shellOctober 13, 2020

Create your own git commands (aliases)

Ever wanted to shorten a git command? You can go with shell alilas for sure but you have to always include context so that you don't forget what each ailas stands for but you can define your own…

shellOctober 13, 2020

Delete already-merged branchs in Git

You can safelist more branches in egrep -v 'master|develop|foo|bar'

shellOctober 13, 2020

Delete merged git branches

Handy git command for deleting all local git branches that already merged git branch --merged | egrep -v "(^\\|master|dev)" | xargs git branch -d*

javascriptOctober 13, 2020

Destructuring assignment in JS

Simple ones javascript const [a, b, ...c] = [10, 20, 100,200] // a= 10, b=20, c=[100,200] const { first, second } = { first: 1, second: 2 } // first = 1, second = 2

shellOctober 13, 2020

Diff a local file with remote version in Git

Easily run the below command and get a diff version from the remote

shellOctober 13, 2020

Find a branch based on a commit

c198bb715 Make default expired description logic pretty `

shellOctober 13, 2020

Force push previous commit to repo

If you push some code and want to force push a previous commit you can do so with shell git push origin +commit\sha^:branch\name

shellOctober 13, 2020

Get current git branch name

Get current git branch name

macosOctober 13, 2020

Get the password of the wifi you're on

password: "!forHackers" `

shellOctober 13, 2020

Go through a file Git history (GUI)

Go through a file Git history (GUI)

javascriptOctober 13, 2020

How to Create an HTML Element with Attributes in One Line in JavaScript

When working on a JavaScript project, it's common to create HTML elements dynamically. Traditionally, you might use several lines of code to create an element and set multiple attributes…

ruby on railsOctober 13, 2020

How to find god objects in your project (Rails)

Go to your project root and cd into app/models (using CLI obviously) then run wc -lw \ | sort -u*

vimOctober 13, 2020

How to quit Vim

1. Install latest version of Vim 2. Open a file in Vim 3. ⌘-Q and close the terminal 4. Reopen terminal

vimOctober 13, 2020

How to really!! quit vim

In terminal

vimOctober 13, 2020

How to save a file with sudo in VIM

How to save a file with sudo in VIM

ruby on railsOctober 13, 2020

HTML forms that submit to another action

I've known for a long time that you can submit values with submit buttons so you can track which button was used to submit the form e.g.

ruby on railsOctober 13, 2020

If you want to override previously set order

If you want to override previously set order (even through default\_scope), use reorder() instead.

rubyOctober 13, 2020

Improve Bundler performance

Level up your bundler performance by running bundler tasks concurrently in jobs:

shellOctober 13, 2020

Kill rails that got stuck

I'd like to kill rails running w/specific port. (My laptop running several rails servers. )

shellOctober 13, 2020

Kill unresponsive SSH session

Occasionally an SSH session may become unresponsive. If I put my laptop to sleep this happens fairly often. Rather than killing the tab you can use SSH Escape Characters to kill the session

ruby on railsOctober 13, 2020

Limited has_many associations

Limited has_many associations

shellOctober 13, 2020

List directory structure except one or more dirs

Ever wanted to display the structure of the current directory except or two directories?

ruby on railsOctober 13, 2020

List your model names

NOTE: RUBYOPT=-W0 avoids verbosity when running rails command which suppresses warnnings.

shellOctober 13, 2020

make a pr from command line using hub

install hub first with brew: brew install hub then use a simple command, like at the example below: hub pull-request -m "best pr ever" -b oozou:develop -h feature/awesome-improvements

macosOctober 13, 2020

My most used slack shortcuts

⌘-K(or T) to open the channel switcher (I navigate channels solely with this shortcut and have my slack set to hide all channels without new messages)

rubyOctober 13, 2020

optional relation + RSpec w/shoulda-matchers

User 1 - 0..1 Laptop

ruby on railsOctober 13, 2020

Postgres Functions & Non-sargable Queries

Using postgres functions inside a where clause can make a query non-sargable.

ruby on railsOctober 13, 2020

PostgreSQL UPDATE Join

This query shows how to use the PostgreSQL UPDATE join syntax to update data in a table based on values in another table. for example;

vimOctober 13, 2020

Quickly move lines up and down in any Vim mode

I often move lines around in vim so I have created mappings to make this easier. These map to ⌘-j for move down and ⌘-k for move up. Works in normal, insert, and visual modes. vim nnoremap <D-j> :m…

rubyOctober 13, 2020

Remove ruby 2.6 bundled bundler

Generating a rails 6 app with ruby 2.6+ when you have bundler v2 installed creates unusable binstubs. If you are seeing this error You must use Bundler 2 or greater with this lockfile. you can remove…

shellOctober 13, 2020

Remove unwanted commit from your branch

Remove unwanted commit from your branch

vimOctober 13, 2020

Rename files in VIM

Here's a handy function that I use to rename files in VIM (works in MacVIM and Neovim too)

macosOctober 13, 2020

Reset Postgres table sequence after DELETE

When deleting recent records from a table, you can reset it's sequence counter if auto-increment field continuity is important to you. Consider actions on the following table, users:

shellOctober 13, 2020

Restore a deleted file in Git

Restore a deleted file in Git

rubyOctober 13, 2020

Run rubocop against your current branch

Run rubocop against your current branch

rubyOctober 13, 2020

Run rubocop before commit

Git hooks are super powerful for automating tasks and enforcing coding standards in a Git repository. One common use case for Git hooks is to run automated tests and code analysis tools before…

shellOctober 13, 2020

Run same command on different input/inputs

If you have to run the same command repetitively over different input/inputs.

ruby on railsOctober 13, 2020

Scope or scope in Rails

scope :human, -> { user.or(author) } scope :terminator, -> { admin.or(robot) } `

shellOctober 13, 2020

See deleted files in previous commits [git]

See deleted files in previous commits [git]

shellOctober 13, 2020

Send messages to Slack using cURL

Slack allows you to send messages via the Webhooks service

shellOctober 13, 2020

Shallow clone a old repo

If you don't need the full git history for a repo you will be working on you can supply a clone depth to only clone x revisions of the repo.

ruby on railsOctober 13, 2020

Show TODO and other notes in your Rails app

Did you know you can show all TODOs/OPTIMIZE/FIXME in your rails app with rails notes?

javascriptOctober 13, 2020

Simple Flux architecture with Vue.js

For a small app that only needs a simple state management pattern. I always use one component to hold the state of the app, a container. This act as a single source of truth for an app to refer to…

rubyOctober 13, 2020

Suppress rspec warnings

$ RUBYOPT=W0 bundle exec rspec spec/ ...

ruby on railsOctober 13, 2020

Tag rails logs with useful information

Just learned about tagged logging in rails. Did you know you can tag a log by using

vimOctober 13, 2020

Use capital letters in VIM mappings

NOTE: @joe this solves your problem :D

macosOctober 13, 2020

Use FFmpeg and Apple Script to compress videos

Build an application you can drag-and-drop videos onto to compress them significantely:

shellOctober 13, 2020

Use `host` to get more information about domains

You might be using dig to find out A/CNAME/MX etc records of a domain from DNS servers. But if you just want to get a quick overview, use host:

ruby on railsOctober 13, 2020

Use minItems/maxItems in collection JSON schemas

To make your collection JSON schemas more reilable use minItems and maxItems so that you can trust your API.

vimOctober 13, 2020

Use Neovim as a git difftool

Just paste this into your ~/.gitconfig

shellOctober 13, 2020

Using Git's aliases feature

Git allows you to create aliases internally through the config. Your global config should be located here ~/.gitconfig

shellOctober 13, 2020

Watch CI status on Github

When you have Github's hub installed, you can get the ci-status of your current branch like this:

rubyOctober 13, 2020

You can use FactoryBot for non ActiveRecord models

You can use FactoryBot's initialize\with* method to initialize an object any way you like which allows you to factorize any of your objects at will

shellOctober 13, 2020

Zsh function to list file tree

When navigating through directories on the command line, it’s often helpful to see the structure of directories and subdirectories in a "tree" format. While there are plenty of tools out there, such…

有專案構想嗎?

我們很樂意聆聽您正在打造的產品。

開始對話hello@oozou.com
OOZOU Logo

曼谷 · 新加坡 · 香港

X
Facebook
Instagram
LinkedIn

服務

  • Web 開發
  • AI 與生成式 AI 解決方案
  • 行動應用程式開發
  • 資料分析與工程
  • UI/UX 設計與產品設計
  • 數位轉型

公司

  • 關於我們
  • 職涯
  • 部落格
  • 白皮書
  • 案例研究
  • Today I Learned
  • 聯繫我們

更多

  • 產業
  • 索取報價
  • 合作夥伴網絡
© 2026 OOZOU. 版權所有。
隱私政策行為準則反賄賂反貪腐政策