Skip to content

Instantly share code, notes, and snippets.

View romainl's full-sized avatar
💰
Alwayz Into Somethin'

Romain Lafourcade romainl

💰
Alwayz Into Somethin'
  • Razorfish France
  • Paris, France
View GitHub Profile
@romainl
romainl / generatecodeverifier.js
Last active May 24, 2018 09:34
Generate a best effort cryptographically secure string of arbitrary length for use as a Proof Key for Code Exchange (PKCE)
// See https://www.oauth.com/oauth2-servers/pkce/
function generateCodeVerifier(limit) {
const krypto = window.crypto || window.msCrypto;
const pool = new Uint8Array(1024);
const chars = [];
krypto.getRandomValues(pool);
pool
.filter((code) => {
@romainl
romainl / dynaline.gif
Last active March 20, 2024 10:11
How to add dynamic highlighted parts to your status-line
dynaline.gif

It looks like define and include can't match on the same line.

define alone

Goal: set define to a simple value and see if it works as intended.

  1. Open sample_a with:

     $ vim -Nu NONE sample_a
    
@romainl
romainl / javascript_deep_dive.md
Created October 7, 2017 19:28 — forked from faressoft/javascript_deep_dive.md
JavaScript Deep Dive to Crack The JavaScript Interviews
@romainl
romainl / nonemptylines.vim
Created September 23, 2017 13:59
Fun with non-empty lines
" jump to next non-empty line
nnoremap <key> :<C-u>call search('^.\+')<CR>
" jump to previous non-empty line
nnoremap <otherkey> :<C-u>call search('^.\+', 'b')<CR>
" extend visual selection to next non-empty line
xnoremap <key> :<C-u>k`\|call search('^.\+')\|normal! <C-r>=visualmode()<CR>``o<CR>
" extend visual selection to previous non-empty line
@romainl
romainl / countrepeat.md
Last active November 9, 2024 21:02
Repeat last edit n times

Repeat last edit n times

Did you ever wish you could repeat the last edit an arbitrary number of times without mashing the . key?

Well now you can.

Before

......
@romainl
romainl / headings.vim
Created September 23, 2017 13:50
Markdown : jump to next heading
" markdown : jump to next heading
function! s:JumpToNextHeading(direction, count)
let col = col(".")
silent execute a:direction == "up" ? '?^#' : '/^#'
if a:count > 1
silent execute "normal! " . repeat("n", a:direction == "up" && col != 1 ? a:count : a:count - 1)
endif
@romainl
romainl / toolong.vim
Last active April 25, 2023 08:04
Highlight characters after line 80
augroup TooLong
autocmd!
autocmd winEnter,BufEnter * call clearmatches() | call matchadd('ColorColumn', '\%>80v', 100)
augroup END
@romainl
romainl / vanilla-linter.md
Last active July 24, 2025 19:09
Linting your code, the vanilla way

Linting your code, the vanilla way

You may want a linter plugin to lint your code in Vim but you probably don't need it. At least try the built-in way before jumping on the plugin bandwagon.

Defining makeprg

autocmd FileType <filetype> setlocal makeprg=<external command>

This autocommand tells Vim to use <external command> when invoking :make % in a <filetype> buffer. You can add as many similar lines as needed for other languages.

@romainl
romainl / autocommands.md
Last active November 9, 2024 21:04
Dealing with autocommands

Dealing with autocommands

Anatomy of a minimal autocommand

autocmd BufNewFile,BufRead *.foo set filetype=html
  • BufNewFile,BufRead is the list of events that trigger this autocommand.
  • *.foo is the pattern we want to match against the data returned by the event.
  • set filetype=html is the command we want to execute when the pattern matches the data returned by the event.