Skip to content

Instantly share code, notes, and snippets.

@nidble
nidble / block.module
Created September 29, 2017 15:07
block.module profiling
<?php
// _block_render_blocks:
$startTime = microtime(true);
// original code:
$array = module_invoke($block->module, 'block_view', $block->delta);
$endTime = microtime(true);
$elapsed = $endTime - $startTime;
@nidble
nidble / setup.js
Last active October 25, 2017 19:34
mongoose setup
// 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 / mock.js
Created August 31, 2018 09:11
redis mock require example
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 / m3u_maker.sh
Created June 15, 2019 10:54
Build m3u playlist magically
#!/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 / comands.sh
Last active November 22, 2021 09:11
Spared commands
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 / .gitconfig
Last active August 10, 2023 08:14
My git config <3
[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