Skip to content

Instantly share code, notes, and snippets.

View ratacibernetica's full-sized avatar

Martín Roldán-Araujo ratacibernetica

View GitHub Profile
@ratacibernetica
ratacibernetica / inbucket.sh
Last active August 13, 2024 02:03
Create a disposable email server like mailinator
#!/bin/bash
# Optional:
# add an A DNS record pointing to you server's IP address
# e.g, for mydomain.com, mail -> 127.0.0.1. Would be mail.mydomain.com
docker run -it --rm --name inbucket -p 9000:9000 -p 25:2500 -p 1100:1100 inbucket/inbucket
@ratacibernetica
ratacibernetica / PHP, ODBC, DB2 in linux or macOS.md
Last active March 27, 2020 19:50
PHP, ODBC, DB2 in linux or macOS

A scary tale where docker saves the day

TL;DR you may want to use this docker image https://cloud.docker.com/u/mkphp/repository/docker/mkphp/php-ibm-odbc

How do you connect PHP to a Database?

Well, you use the right driver, right? Which is usually ready for you to use out-of-the-box or at least, you just download it, enable it and that’s it.

For DB2 it’s bit more complicated than that.

@ratacibernetica
ratacibernetica / send_commit_report
Created February 17, 2020 16:14
Send a commit report to your boss
git log --author=$USER --format="- %B" --since=-7days --reverse |mail -s "What I've done this week" boss@company\.com # Send a commit report to your boss
@ratacibernetica
ratacibernetica / speedtest.sh
Created November 29, 2019 00:16
speedtest from command line with bash
#! /bin/bash
curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -
@ratacibernetica
ratacibernetica / .vimrc
Last active June 13, 2020 06:24
basic vimrc
syntax on
filetype plugin indent on
set swapfile
set dir=/tmp
set nu
set expandtab ts=4 sw=4 ai
let mapleader=","
imap ,w <ESC>:w<CR>
imap jj <ESC>
nnoremap <Leader>w :w<CR>
@ratacibernetica
ratacibernetica / pw.sh
Created October 23, 2019 05:01
phpunit run automatically with inotifywait (linux)
#!/bin/bash
while true; do
FILE=$(inotifywait tests/*/*.php --format="%w%f" ) &&
clear &&
vendor/bin/phpunit --color $FILE
done
@ratacibernetica
ratacibernetica / pw.sh
Created October 23, 2019 05:00
run phpunit automatically with watchman
watchman-make -p 'app/**/*.php' 'tests/**/*.php' --make=vendor/bin/phpunit -t tests
@ratacibernetica
ratacibernetica / autossh-vnc-tunnel.service
Created August 29, 2019 18:00
autossh reverse ssh tunnel vnc on boot using systemd
#file: /etc/systemd/system/autossh-vnc-tunnel.service
[Unit]
Description=AutoSSH tunnel service everything
After=network.target
[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -N -o "ExitOnForwardFailure=yes" -o "PubkeyAuthentication=yes" -o "StrictHostKeyChecking=false" -o "PasswordAuthentication=no" -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R 5903:localhost:5901 -i /home/pi/.ssh/id_rsa user@server -p1234
[Install]
# this-account-is-currently-not-available-error-when-trying-to-ssh
su -l www-data -s /bin/bash
<?php
/**
* Removes unwanted key|values from array.
* @param array $filters
* @return array
*/
function applyFilters(array $request){
$allowedFields = ['field_1','field_2','field_3','field_4'];
$filters = array_intersect_key($request, array_flip($allowedFields));
return $filters;