Here's a handy function that I use to rename files in VIM (works in MacVIM and Neovim too)
function! RenameFile() let old_name = expand('%') let new_name = input('New file name: ', expand('%'), 'file') if new_name != '' && new_name != old_name exec ':saveas ' . new_name exec ':silent !rm ' . old_name redraw! endif endfunction nnoremap n :call RenameFile()
NOTE: I've used
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 its states. Vue provides a mechanism to create a global event listener on the root level called EventBus which is a super simple way to mimic flux architecture.
All you need is one module that exports Vue as EventBus like so
// EventBus.js import Vue from 'vue' export const EventBus = new Vue()
Then you can use it inside your container to listen to event from any component inside the app. I normally add the listener on created life cycle.
Then you can import EventBus into any of your components and you can triggers my-custom-event from anywhere without having to emit the event to that component's parent and repeat the whole process in every component in between the component that triggers the change and the target container.
// Goes directly to the global listener and triggers callback EventBus.$emit('event-name')
That's it. If it's getting too complex, consider using Vuex.
⌘-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)
⌘-F opens the search box. Can modify searches with from:@user and in:#channel for extra awesomeness
Up Arrow will edit you last message; perfect for when you hit Enter too early or mispell things
+:emoji: react to the last message. Have to be quick so nobody else replies before you react though or you'll react to the wrong message
/remind [someone usually myself] [to do something] [at this time in words] not really a shortcut but is great for not forgetting simple tasks
The channel switcher also supports fuzzy matching to some extent. If a channel is named foo-bar you can type fb to show it. It's doesn't work so well with multi-user-dm's though.
Using postgres functions inside a where clause can make a query non-sargable.
tracks has_many artists
Using a LOWER function prevents DBMS engine from using indexes.
Track.joins(:artists).where('LOWER(tracks.display_name) LIKE ?', "eric clapton%").explain
Gather (cost=1000.85..56714.32 width=4061) Workers Planned: 2 -> Nested Loop (cost=0.85..55713.62 rows=3 width=4061) -> Nested Loop (cost=0.42..55708.37 rows=3 width=4069) -> Parallel Seq Scan on tracks (cost=0.00..55365.17 rows=41 width=4061) Filter: (lower((display_name)::text) ~~* 'eric clapton%'::text) -> Index Scan using index_artist_relations_on_artist_item_type_and_artist_item_id on artist_relations (cost=0.42..8.36 rows=1 width=16) Index Cond: (((artist_item_type)::text = 'Track'::text) AND (artist_item_id = tracks.id)) -> Index Only Scan using idx_35952_primary on artists (cost=0.43..1.75 rows=1 width=8) Index Cond: (id = artist_relations.artist_id)
Removing LOWER function allows DBMS engine to use indexes, resulting in faster execution.
Track.joins(:artists).where('tracks.display_name ILIKE ?', "eric clapton%").explain
Nested Loop (cost=1497.60..2695.43 width=4061) -> Nested Loop (cost=1497.17..2684.94 rows=6 width=4069) -> Bitmap Heap Scan on tracks (cost=1496.75..1873.05 rows=97 width=4061) Recheck Cond: ((display_name)::text ~~* 'eric clapton%'::text) -> Bitmap Index Scan on index_tracks_on_display_name (cost=0.00..1496.73 rows=97 width=0) Index Cond: ((display_name)::text ~~* 'eric clapton%'::text) -> Index Scan using index_artist_relations_on_artist_item_type_and_artist_item_id on artist_relations (cost=0.42..8.36 rows=1 width=16) Index Cond: (((artist_item_type)::text = 'Track'::text) AND (artist_item_id = tracks.id)) -> Index Only Scan using idx_35952_primary on artists (cost=0.43..1.75 rows=1 width=8) Index Cond: (id = artist_relations.artist_id)