Skip to content

Instantly share code, notes, and snippets.

View okiwan's full-sized avatar

Sergio Ocaña Gálvez okiwan

View GitHub Profile
@okiwan
okiwan / userChrome.css
Created March 17, 2019 17:23
Configure visibility of bookmark toolbar when fullscreen is active on Mozilla Firefox
/* Place this file in ~/.mozilla/firefox/<profile folder>/chrome/userChrome.css */
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
#navigator-toolbox[inFullscreen] toolbar:not([collapsed="true"]) {
visibility:visible!important;
}
@okiwan
okiwan / clean_code.md
Created March 3, 2019 17:15 — forked from jeremyjackson89/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@okiwan
okiwan / alterRootPassword.md
Created December 16, 2018 10:45
Alter root password on MariaDB instance startup
  1. sudo systemctl stop mariadb
  2. mysqld_safe --skip-grant-tables --skip-networking &
  3. mysql -u root -p
  4. set password for 'root'@'localhost' = password('')
  5. Exit, stop server (kill -9) and start normally using systemctl
@okiwan
okiwan / deploy-insight.sh
Created November 14, 2018 19:14
Insight Debugger installation script for Bash on Ubuntu. Tested on 18.04LTS
#!/usr/bin/env /bin/bash
ORI_FOLDER=$(pwd)
TMP_FOLDER=$(mktemp -d)
LOG=$(mktemp)
APT_FLAGS="-y --reinstall"
GIT_FLAGS="-q --recursive"
INSIGHT="./configure --prefix=/usr/. --libdir=/usr/lib64 --disable-binutils --disable-elfcpp --disable-gas --disable-gold --disable-gprof --disable-ld --disable-rpath --disable-zlib --enable-sim --with-gdb-datadir=/usr/share/insight --with-jit-reader-dir=/usr/lib64/insight --with-separate-debug-dir='/usr/lib/debug' --with-expat --with-python --without-libunwind"
# Stop script at first error found
@okiwan
okiwan / firewall.sh
Created October 15, 2018 08:21
Just a firewall script configuring iptables.
#!/bin/bash
# Description: Firewall script. This is great, but maybe you should consider 'iptables-persistent'
iptables=/sbin/iptables
function start_firewall {
# Clean Rules
$iptables -F
import io # Operating system I/O
import re # Regular expression module
import pycurl # Curl module
def log(text, end='\n'):
print(text, end=end, flush=True)
c = pycurl.Curl()
buffer = io.BytesIO()
@okiwan
okiwan / gist:d90f0daac6a8c88693c54c0e9e2fafb9
Created March 30, 2017 09:48
CTAGS for PHP+Yii projects
ctags -h ".php" -R --exclude="assets" --exclude="uploads" --exclude="runtime" --exclude=".git" --exclude="wiki" --totals=yes --tag-relative=yes --fields=+afkst --PHP-kinds=+cf
@okiwan
okiwan / aws-billing.sh
Last active April 6, 2016 09:20
AWS Billing Bash script to consolidate costs
#!/usr/bin/env /bin/bash
# Checks if element (first argument) is in array (second argument)
elementIn() {
local e
for e in "${@:2}"; do [[ "\"$e\"" == "$1" ]] && return 0; done
return 1
}
# Id strings used to identify resources
select to_timestamp(t.timestamp), u.first_name, u.last_name, t.destination, t.pol_start, t.pol_end, t.status from registered_user u, transaction t where u.id = t.user_id order by t.timestamp desc limit 20;
@okiwan
okiwan / gist:327aa971108f4b748d29
Created March 17, 2016 14:26
Conversión de cadena binaria representando texto en Unicode en cadena binaria representando el texto en UTF-8
Private Function UTF8Encode(b() As Byte) As Byte()
' Function to convert a Unicode Byte array into a byte array that can be written to create a UTF8 Encoded file.
' Note the function supports the one, two and three byte UTF8 forms.
' Note: the MS VBA documentation is confusing. It says the String types only supports single byte charset
' however, thankfully, it does in fact contain 2 byte Unicode values.
' Wrote this routine as last resort, tried many ways to get unicode chars to a file or to a shell script call
' but this was the only way could get to work.
' RT Perkin
' 30/10/2015