Skip to content

Instantly share code, notes, and snippets.

@nidble
nidble / .gitconfig
Last active Mar 27, 2021
My git config <3
View .gitconfig
[user]
#git config --global alias.lol "log --oneline --graph --decorate"
email = xxxxx
name = XXX XXX
[core]
editor = vim
pager = diff-so-fancy | less --tabs=4 -RFX
[alias]
purge = !git branch -D $1 && git push origin :$1
@nidble
nidble / comands.sh
Last active May 19, 2021
Spared commands
View comands.sh
netstat -tulpn
netstat -polenta
#ask for www.foo.baz
dig +short www.foo.baz
#ask at 208.67.222.222 for foo.baz MX
dig @208.67.222.222 foo.baz MX
ps axfww
tcpdump -n -S -s 0 -A 'tcp dst port 80' and src 172.31.4.7
# kill by port
PORT=3030
@nidble
nidble / m3u_maker.sh
Created Jun 15, 2019
Build m3u playlist magically
View m3u_maker.sh
#!/bin/bash
dir=${1:-$PWD}
find "$dir" -type f -name "*.mp4" | sort | awk -F\/ '
$7 ~ /^[0-9]{1,2}/ {
folder=gensub(/^[^0-9]*([0-9]+).*$/,"\\1","G", $7)
idx=gensub(/^[^0-9]*([0-9]+).*$/,"\\1","G", $8)
# arr[folder][length(arr[folder])+1]=$0 #auto incremental idx
arr[folder][idx]=$0
@nidble
nidble / mock.js
Created Aug 31, 2018
redis mock require example
View mock.js
const Module = require('module')
const originalRequire = Module.prototype.require
const Redis = require('ioredis-mock')
Module.prototype.require = function () {
const filePath = Array.prototype.concat.apply([], arguments)[0]
if (!filePath.includes('setup/redis')) {
return originalRequire.apply(this, arguments)
}
@nidble
nidble / setup.js
Last active Oct 25, 2017
mongoose setup
View setup.js
// https://github.com/KunalKapadia/express-mongoose-es6-rest-api
// print mongoose logs in dev env
if (config.MONGOOSE_DEBUG) {
mongoose.set('debug', (collectionName, method, query, doc) => {
debug(`${collectionName}.${method}`, util.inspect(query, false, 20), doc);
});
}
@nidble
nidble / block.module
Created Sep 29, 2017
block.module profiling
View block.module
<?php
// _block_render_blocks:
$startTime = microtime(true);
// original code:
$array = module_invoke($block->module, 'block_view', $block->delta);
$endTime = microtime(true);
$elapsed = $endTime - $startTime;