Skip to content

Instantly share code, notes, and snippets.

View TommasoBelluzzo's full-sized avatar
👁️
Learning

Tommaso Belluzzo TommasoBelluzzo

👁️
Learning
View GitHub Profile
@TommasoBelluzzo
TommasoBelluzzo / table_sql.m
Last active July 17, 2020 08:00
A script for performing SQL CRUD operations on Matlab tables. An SQLite JDBC driver is required.
% [INPUT]
% query = A string representing a valid SQL query to be performed on one or more tables defined within the main workspace.
% Only CRUD operations (DELETE, INSERT, SELECT and UPDATE) are supported.
%
% [OUTPUT]
% out = The result of the specified SQL query, whose content depends upon the performed operation:
% - for SELECT statements, an m-by-n table representing the result set returned by the database;
% - for DELETE, INSERT and UPDATE statements, an integer representing the number of affected rows.
function out = table_sql(varargin)
@TommasoBelluzzo
TommasoBelluzzo / check_requirements.m
Last active March 8, 2020 03:17
A script for detecting dependancies and minimum required version of other Matlab scripts.
% [INPUT]
% path = A string representing the path on which to perform the requirements check (optional, default=pwd).
% It can be either the path to a Matlab script or the path to a directory containing one or more Matlab scripts at any level of depth.
% type = A string representing the requirements check to perform (optional, default=ALL), its value can be one of the following:
% - ALL: dependancies and minimum version.
% - DEP: dependancies only.
% - VER: minimum version only.
% extv = A boolean indicating whether to return detailed information concerning the minimum version (optional, default=false).
% If false, the result is returned in the form of a string representing the minimum version.
% Otherwise, the result is returned in the form of a table listing all the called functions and their respective minimum version (if available).
@TommasoBelluzzo
TommasoBelluzzo / TextSearch.sql
Last active November 1, 2018 14:12
A stored procedure for searching a specific string in Sybase objects.
CREATE PROCEDURE dbo.TextSearch
(
@Text VARCHAR(100),
@Type CHAR(1) = NULL,
@Normalized BIT = 0
)
AS
BEGIN
IF (@Text IS NULL)
@TommasoBelluzzo
TommasoBelluzzo / crc32.m
Last active September 9, 2018 22:17
A script for calculating the CRC32 checksum of a given file.
% [INPUT]
% file_path = A char array representing the file path.
%
% [OUTPUT]
% crc32 = A char array representing the CRC32 Checksum of the file.
function crc32 = calculate_crc32(file_path)
persistent array;
@TommasoBelluzzo
TommasoBelluzzo / BMC.cs
Last active September 9, 2018 22:17
A C# implementation of the Boyer-Moore-Horspool algorithm.
public static Int64 IndexOf(this Byte[] value, Byte[] pattern)
{
if (value == null)
throw new ArgumentNullException("value");
if (pattern == null)
throw new ArgumentNullException("pattern");
Int64 valueLength = value.LongLength;
Int64 patternLength = pattern.LongLength;
@TommasoBelluzzo
TommasoBelluzzo / rootogram.m
Last active September 9, 2018 22:17
A script for plotting Tukey's rootograms.
% [INPUT]
% ax = An object of type "matlab.graphics.axis.Axes" representing the axis on which the rootogram is plotted (optional, default=gca).
% occ = A numeric vector representing the number of occurrences.
% exd = A numeric vector representing the expected (fitted) frequencies.
% obs = A numeric vector representing the observed (real) frequencies.
% flo = A boolean that indicates whether to use floating bars (optional, default=true).
% squ = A boolean that indicates whether to use the squared root of frequencies (optional, default=true).
%
% [OUTPUT]
% h_rec = A vector containing the rectangle handles (optional).
@TommasoBelluzzo
TommasoBelluzzo / create_colormap.m
Last active September 9, 2018 22:16
A script for creating color maps with multiple gradients.
% [INPUT]
% c1 = A vector of three floats [0,1] representing the first RGB color.
% c2 = A vector of three floats [0,1] representing the second RGB color.
% c3 = A vector of three floats [0,1] representing the third RGB color.
% n1 = An integer [0,512] representing the span of the first gradient (c1 and c2).
% n2 = An integer [0,512] representing the span of the second gradient (c2 and c3).
%
% [OUTPUT]
% cmap = An (n1+n2)-by-3 matrix of floats representing the colormap.