Skip to content

Instantly share code, notes, and snippets.

View Razzo78's full-sized avatar

Rudy Azzan Razzo78

View GitHub Profile
@Razzo78
Razzo78 / PyString.py
Last active October 19, 2017 14:38
Python - Search all strings contained in a list of strings that contain a particular substring
some_list = ['abc-123', 'def-456', 'ghi-789', 'abc-456']
if any("abc" in s for s in some_list):
# If you really want to get all the items containing abc, use
matching = [s for s in some_list if "abc" in s]
@Razzo78
Razzo78 / PyDir.py
Last active October 19, 2017 14:38
Python - Look for all methods of an object that contain a specified string as part of the method name
import numpy as np
[s for s in dir(np) if "array" in s]
@Razzo78
Razzo78 / ResetIndex.sql
Last active October 20, 2017 07:28
Sqlite - To set automatic counter index number to the preferred value in Sqlite
UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='Table_name'
@Razzo78
Razzo78 / ForeignKeys.sql
Last active October 19, 2017 14:38
Sqlite - Enable Sqlite foreign keys. Note: This is to be done after connecting to db.
PRAGMA foreign_keys = ON;
@Razzo78
Razzo78 / QTSleep.cpp
Last active February 11, 2019 06:15
QT - Three different ways to pause a thread with QT
//METODO 1:
//Using the class QTest
QTest::qSleep(100); // it block the event processing
QTest::qWait(100); // it does not block the event processing
//METODO 2:
//Using the classes QWaitCondition and QMutex
QWaitCondition waitCondition;
QMutex mutex;
@Razzo78
Razzo78 / Cycle.cs
Last active October 19, 2017 14:38
C# - Execute and remove elements from a collection in only one cycle
var itsCommands = new List<Command>();
while (itsCommands.Count > 0)
{
Command c = (Command) itsCommands[0];
c.Execute();
itsCommands.RemoveAt(0);
}
@Razzo78
Razzo78 / ButtonPanel.qml
Last active April 10, 2022 13:18
QML - A panel of buttons that fill a row and maintains the button width setting
import QtQuick 2.7
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.1
Item {
width: 640
height: 480
RowLayout {
id: rowLayout
@Razzo78
Razzo78 / PropertyChanged.qml
Last active October 19, 2017 14:44
QML - Function connected to property changed event
property bool isBusy: true
Connections {
target: targetItem
onIsBusyChanged: {
// function code
// ...
}
}
@Razzo78
Razzo78 / NumberToLetter.js
Last active October 19, 2017 15:31
Javascript - Convert number to letter, following the alphabet
function numberToLetter(number)
{
return (number + 9).toString(36).toUpperCase();
}
@Razzo78
Razzo78 / CustomAutoCount.sql
Created October 20, 2017 07:35
SQL Server - Force to add custom auto value count
-- Alter auto index count
set identity_insert table_name ON
insert into table_name (id, another_field) VALUES (1, NULL)
-- Restore auto index count
set identity_insert table_name OFF