Skip to content

Instantly share code, notes, and snippets.

Avatar
👁️
Learning

Tommaso Belluzzo TommasoBelluzzo

👁️
Learning
View GitHub Profile
@TommasoBelluzzo
TommasoBelluzzo / TextSearch.sql
Last active Nov 1, 2018
A stored procedure for searching a specific string in Sybase objects.
View TextSearch.sql
CREATE PROCEDURE dbo.TextSearch
(
@Text VARCHAR(100),
@Type CHAR(1) = NULL,
@Normalized BIT = 0
)
AS
BEGIN
IF (@Text IS NULL)
@TommasoBelluzzo
TommasoBelluzzo / table_sql.m
Last active Jul 17, 2020
A script for performing SQL CRUD operations on Matlab tables. An SQLite JDBC driver is required.
View table_sql.m
% [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 Mar 8, 2020
A script for detecting dependancies and minimum required version of other Matlab scripts.
View check_requirements.m
% [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 / BMC.cs
Last active Sep 9, 2018
A C# implementation of the Boyer-Moore-Horspool algorithm.
View BMC.cs
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 / crc32.m
Last active Sep 9, 2018
A script for calculating the CRC32 checksum of a given file.
View crc32.m
% [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 / rootogram.m
Last active Sep 9, 2018
A script for plotting Tukey's rootograms.
View rootogram.m
% [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 Sep 9, 2018
A script for creating color maps with multiple gradients.
View create_colormap.m
% [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.
You can’t perform that action at this time.