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 / gist:f84a65ffa850a0bc2e88
Last active August 29, 2015 14:06
Solving the file name with multiple dots problem in Grunt:

Solving the file name with multiple dots problem in Grunt:

Use the extDot property instead of the ext property.

In Grunt, this is how your can match filenames with multiple dots and write to filenames that contain the original dot sequence, except for file extension.

/path/to/module.somename.scss -> /path/to/module.somename.css
@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 ]
@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 / 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 / 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 / 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 / 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 / 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 / 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 / .surfingkeysrc
Last active July 23, 2023 05:55
Surfingkeys Configuration
const {
aceVimMap,
mapkey,
imap,
imapkey,
getClickableElements,
vmapkey,
map,
unmap,
cmap,