For base find-and-replace on vim, we can use the :substituto (:s) command.
The general form of the substitute command is as follow:
:[range]s/{pattern}/{string}/[flags] [count]
The command search each line in [range] for a {pattern}, and replaces it with a {string}. [count] is a positive integer that multiplies the command.
If no [range] and [count] are given, only the pattern found in the current line is replaced.
The current line is the line where the cursor is placed.
For example, to search for the first occurrences of the string "foo" in the current line, and replace it with "bar", you should use:
:s/foo/bar
To replace all occurrences of the search pattern in the current line, add the g flag:
:s/foo/bar/g
If you want to search and replace the pattern in the intire file, use the percentage character % as a range.
This caracter indicates a range from the first to the last line of the file:
:%s/foo/bar/g
We can also use | as parameter separator:
:s|foo|bar
To show confirmation for each substituition, use c flag:
:s/foo/bar/gc
To ignore case sensitivity, use i flag:
:s/foo/bar/gi
There is much more options, look at the ref link for more...
How to use a "application-only" volume on MOCP for change volume on mocp without affect system
mocplinuxalsasoundplayer
I was using MOCP on linux for a while to listenning some musics that I have downloaded on my machine, but the only defect of MOCP is the volume controll... until now...
The default volume controll of MOCP controlls the volume from ALSA hardware mixer setting, which change the volume from all system. That is a pain when you want to listennig musics as background music, while listenning another sounds too (like noisekun.com).
Today I discovered that there is a way to make mocp volume controll independent from system volume.
You may see that on volume bar (lower left corner) was writen "Master":
This mean that the volume controll reflect the system volume, so we need to change this with the key X. Now our bar is:
And the volume is independent of system volume.
If your volume bar is writen "S.Off", you can type W to change to "Soft"
Reading some Rust code examples in documentation and blogs, I can see the use of Box<T> declaration. Like:
structSchema { commands:Vec<Box<dynMigration>>,}
structSchema { commands:Vec<Box<dynMigration>>,}
According to the official Rust documentation: "All values in Rust are stack allocated by default. Values can be boxed (allocated on the heap) by creating a Box<T>. A box is a smart pointer to a heap allocated value of type T. When a box goes out of scope, its destructor is called, the inner object is destroyed, and the memory on the heap is freed."
For run SQL queries on SQLite database from Rust, we can use the sqlite3 crate:
let connection =sqlite::open(":memory:").unwrap();connection.execute(" CREATE TABLE users (name TEXT, age INTEGER); INSERT INTO users (name, age) VALUES ('Alice', 42); INSERT INTO users (name, age) VALUES ('Bob', 69); ", ).unwrap();
Open a connection, create a table, and insert some rows.
let connection =sqlite::open(":memory:").unwrap();connection.execute(" CREATE TABLE users (name TEXT, age INTEGER); INSERT INTO users (name, age) VALUES ('Alice', 42); INSERT INTO users (name, age) VALUES ('Bob', 69); ", ).unwrap();
Open a connection, create a table, and insert some rows.
connection.iterate("SELECT * FROM users WHERE age > 50", |pairs| {for&(column, value) in pairs.iter() {println!("{} = {}", column, value.unwrap()); }true }).unwrap();
Select some rows and process them one by one as plain text:
connection.iterate("SELECT * FROM users WHERE age > 50", |pairs| {for&(column, value) in pairs.iter() {println!("{} = {}", column, value.unwrap()); }true }).unwrap();
Select some rows and process them one by one as plain text:
When we run a node script, we can see incovenie warnings like:
(node:3174) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.(Use `node --trace-deprecation ...` to show where the warning was created)
(node:3174) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.(Use `node --trace-deprecation ...` to show where the warning was created)
For disable this warnings, just pass NODE_NO_WARNINGS=1 as environment variable before node command or script, e.g.:
NODE_NO_WARNINGS=1 node index.js
NODE_NO_WARNINGS=1 node index.js
On package.json script:
// ..."script": {"test": "NODE_NO_WARNINGS=1 jest --watch" }// ...
// ..."script": {"test": "NODE_NO_WARNINGS=1 jest --watch" }// ...
Position Sticky
Use position sticky with tailwindcss
tailwindcsscssui
We can use sticky class when using tailwind to make an element fixed on screen while the parent element is visible.
Sometimes you are testing a component and need to mock a module (in this case I needed to mock a zustand store), but with the exemple of "next/navigation" mock, you are mocking the module for entire test suit on the file that you declare the jest.mock(). But, if you want to mock a specific implementation for each test? So first, with need to declare the module mock, without pass the implementation function:
jest.mock('../../stores/sounds-state-store')
jest.mock('../../stores/sounds-state-store')
In this case we are mocking "../../stores/sounds-state-store" module
And, inside each test, we will use the jest.Mock.mockImplementation() function to mock the implementation of module inside it/test scope:
the store we want to mock is useSoundsStateStore, from '../../stores/sounds-state-store'
When you try to test a component or hook that uses some function from "next/navigation" module (like useRouter, useSearchParams, useSearchParams, etc.), you may come across the error:
● Test suite failed to run invariant expected app router to be mounted 5 | 6 | export default function useQueryState(key: string, defaultValue: string = '') { > 7 | const router = useRouter() | ^ 8 | const searchParams = useSearchParams() 9 | const pathname = usePathname() 10 |
● Test suite failed to run invariant expected app router to be mounted 5 | 6 | export default function useQueryState(key: string, defaultValue: string = '') { > 7 | const router = useRouter() | ^ 8 | const searchParams = useSearchParams() 9 | const pathname = usePathname() 10 |
This happening because the "next/navigation" just works when app router was monted, to solve this, you need to mock the entire module. Put this before all your describes and it/tests:
Enable some locales to use when they not appear on "Region & Language" menu
desktophow-tolanguagesconfiggnome
When we go to Region & Language menu to change locale (language and units) of a newly installed system with GNOME, may not have the language you are looking for. For the most cases is a question of enable it on /etc/locale.gen.
For this, just edit the file /etc/locale.gen with root privileges:
$ sudo vim /etc/locale.gen
And uncomment the language that you looking for, e.g:
for
#pt_BR.UTF-8 UTF-8
remove the #, and save
pt_BR.UTF-8 UTF-8
After edit the locale file, regenerate locales with command:
sudo locale-gen
That's it! Just go to Region & Language and select your language.
Black wallpaper on xfce4 when restart the computer
bugdesktophow-toxfce
This problem consists of black background insted the wallpaper on xfce4, apparently is the xfdesktop daemon that was not starting on login. To fix it, wee just need to setup this daemon to auto start on login:
Go to Session and Startup > Application Autostart
Then click on Add
Will appear a window, enter some name, like "Wallpaper Daemon" and the description, "Daemon to load the xfce4 wallpaper", on the command field, add the command xfdesktop --replace.