Skip to content

Instantly share code, notes, and snippets.

View tecfu's full-sized avatar

Tec Fu tecfu

  • Tec Fu
View GitHub Profile
@tecfu
tecfu / fzgrep
Created July 13, 2023 05:24 — forked from TripleDogDare/fzgrep
An interactive fuzzy grep showing surrounding context
#!/bin/bash
set -euo pipefail
# go get github.com/junegunn/fzf
BEFORE=10
AFTER=10
HEIGHT=$(expr $BEFORE + $AFTER + 3 ) # 2 lines for the preview box and 1 extra line fore the match
PREVIEW="$@ 2>&1 | grep --color=always -B${BEFORE} -A${AFTER} -F -- {}"
@tecfu
tecfu / .surfingkeysrc
Last active September 18, 2024 08:31
Surfingkeys Configuration
const {
aceVimMap,
mapkey,
imap,
imapkey,
getClickableElements,
vmapkey,
map,
unmap,
cmap,
@tecfu
tecfu / delayJobs.js
Created February 3, 2022 03:59
Javscript execute promises sequentially, subject to delay
/**
* How to execute a list of functions subject to a delay
*/
const interval = 3000
const delay = time => new Promise(resolve => setTimeout(resolve, time))
// in practice, this would be an array of functions with nested callbacks
const fns = Array(3).fill((() => console.log(Date.now())))
// wait for each delay before executing the next function
@tecfu
tecfu / nvme_mount.md
Created August 14, 2021 20:56 — forked from a-maumau/nvme_mount.md
how to mount m.2 ssd/hdd
@tecfu
tecfu / abilities.js
Created August 29, 2019 23:02 — forked from stalniy/abilities.js
CASL Vue routes
import { AbilityBuilder, Ability } from 'casl'
// Alternatively this data can be retrieved from server
export default function defineAbilitiesFor(user) {
const { rules, can } = AbilityBuilder.extract()
can('read', 'User')
can('update', 'User', { id: user.id })
if (user.role === 'doctor') {
@tecfu
tecfu / ParseTODOs.md
Last active November 1, 2018 12:15
Parse and output TODOs and FIXMEs from comments in your files

Parsing

ack/ag

$ ag --color --color-match 00 -Rio '@todo.*|@fixme.*' src

To save same output as STDOUT (when redirecting to file ag sends different output):

@tecfu
tecfu / docker-wordpress.sh
Created July 24, 2017 04:47 — forked from tatemz/docker-wordpress.sh
A quick way to get a WordPress installation up and running with Docker
#!/bin/bash
mkdir wordpress-site && cd wordpress-site
touch docker-compose.yml
cat > docker-compose.yml <<EOL
version: "2"
services:
my-wpdb:
@tecfu
tecfu / saved.tabs
Last active September 5, 2016 05:32
Tab list for syncing between browsers.
[
"http://psung.blogspot.com/2011/09/network-audio-with-pulseaudio-made.html",
"http://manurevah.com/blah/en/p/PulseAudio-Sound-over-the-network",
"http://unix.stackexchange.com/questions/193208/program-run-in-ssh-accessing-pulseaudio-on-the-machine-where-it-runs"
]
@tecfu
tecfu / cVim.vim
Last active March 11, 2017 11:15
cVim .vimrc
let mapleader = "<Space>"
" Remap home and end to "ctrl+;" and ";" in addition to default "0" and "$"
noremap <leader>a ^
noremap <leader>; $
" Application-specific remapping example here:
" http://askubuntu.com/questions/97213/application-specific-key-combination-remapping/98355
noremap <C-b> 10j
noremap <C-m> 10k
@tecfu
tecfu / comprehensions-example.js
Last active March 18, 2016 06:43
Javascript comprehensions workaround example. Like Python's range() function.
var a = [];
//Create an array of 10 numbers, spaced by 3
for(i of Array(10).keys()) a.push(i*3);
//[ 0, 3, 6, 9, 12, 15, 18, 21, 24, 27 ]
//The same but starting from 10
for(i of Array(10).keys()) a.push(10 + i*3);
//[ 10, 13, 16, 19, 22, 25, 28, 31, 34, 37 ]