Skip to content

Instantly share code, notes, and snippets.

Toni Homedes i Saun thomedes

Block or report user

Report or block thomedes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thomedes
thomedes / README.md
Last active Nov 6, 2019
Full system backup excludes
View README.md
@thomedes
thomedes / ini.sed
Last active Jul 11, 2019
sed one-liners to deal with .ini / .conf files
View ini.sed
# List all [sections] of a .INI file
sed -n 's/^[ \t]*\[\(.*\)\].*/\1/p'
# Read KEY from [SECTION]
sed -n '/^[ \t]*\[SECTION\]/,/\[/s/^[ \t]*KEY[ \t]*=[ \t]*//p'
# Read all values from SECTION in a clean KEY=VALUE form
View keybase.md

Keybase proof

I hereby claim:

  • I am thomedes on github.
  • I am thomedes (https://keybase.io/thomedes) on keybase.
  • I have a public key whose fingerprint is D6CC 1A77 AB07 E83D DDD3 2A95 712C F7B5 4CCC D59C

To claim this, I am signing this object:

View SortedVector.hpp
template<typename T, typename Container = std::vector<T> >
class SortedVector {
public:
typedef T value_type, &reference;
typedef const T &const_reference;
typedef Container container_type;
typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator;
typedef typename container_type::size_type size_type;
@thomedes
thomedes / figlet_demo.sh
Created Feb 15, 2017 — forked from pestilence669/figlet_demo.sh
Show a message using all available fonts for figlet
View figlet_demo.sh
#!/bin/bash
# vim: set ts=4 sw=4 noet fileencoding=utf-8:
fontDir=`figlet -I2`
if [[ $# -eq 0 ]]; then
echo "usage: $(basename $0) [message] -- print given message for every available font in figlet"
exit 0
fi
@thomedes
thomedes / cif.sql
Last active Jan 3, 2016
Calculo de la letra del DNI con MySQL
View cif.sql
DELIMITER $$
DROP FUNCTION IF EXISTS `cif_letra` $$
CREATE FUNCTION `cif_letra` (`p_cif` INT UNSIGNED) RETURNS CHAR(1)
-- ----------------------------------------------------------------------------
-- Calcula la letra que corresponde al núm. de CIF dado
-- ----------------------------------------------------------------------------
DETERMINISTIC
NO SQL
@thomedes
thomedes / ini.sed
Last active Dec 21, 2015
sed one-liners to deal with .ini / .conf files
View ini.sed
#
# Get all sections from .INI file
#
sed -n 's/^[ \t]*\[\(.*\)\].*/\1/p' /etc/samba/smb.conf
#
# Get all values of given section in a clean key=value form
#
section=global; sed -n '/^[ \t]*\['"$section"'\]/,/^[ \]t*\[/s/^[ \t]*\([^;#\[][^ \t]*\)[ \t]*=[ \t]*\(.*\)/\1=\2/p' /etc/samba/smb.conf
#
# Get a specific value for a given key and section
@thomedes
thomedes / README.md
Last active Dec 20, 2015
Compare string versions in bash
View README.md

version_cmp()

Simple function to (properly) compare version strings in bash

The problem

You can not do alphabetic comparison:

@thomedes
thomedes / Windows-UTC-Time.reg
Created Jul 28, 2013
Windows 7 hack to have BIOS clock (RTC) in UTC. Useful for dual-booting Windows / Linux. Don't give me any credit for it. I just googled for the solution and pasted it here for my own convenience.
View Windows-UTC-Time.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001
@thomedes
thomedes / is_assoc_array.php
Last active Dec 19, 2015
php: Check if an array is associative or plain
View is_assoc_array.php
<? php
function is_assoc_array($a) {
return (is_array($a)
&& (array_keys($a) !== range(0, count($a) - 1)));
}
function is_plain_array($a) {
return is_array($a) && !is_assoc_array($a);
}
You can’t perform that action at this time.