Skip to content

Instantly share code, notes, and snippets.

@kazeno
kazeno / access_paths.py
Created September 1, 2024 19:29
Example of retrieving the {data install scheme dir} and {scripts install scheme dir} paths in Python
# example of retrieving the {data install scheme dir} and {scripts install scheme dir} paths
import sysconfig
data_path = sysconfig.get_path('data')
scripts_path = sysconfig.get_path('scripts')
# now you can construct the full paths to the stuff you need inside those directories...
@kazeno
kazeno / docker-compose.yml
Created November 13, 2021 16:48
Docker Compose files for TTRSS on Azure Pipelines + App Service for Containers
#run file
version: '3.2'
services:
app:
image: YOUR_APP_IMAGE_URL_HERE
restart: unless-stopped
environment:
TTRSS_DB_HOST
TTRSS_DB_NAME
DELIMITER $$
CREATE FUNCTION WORKDAYSDATEDIFF (date1 DATE, date2 DATE, workdays VARCHAR(7))
RETURNS INT DETERMINISTIC
/* Calculates working days between 2 dates, work days are supplied as a string with numbers from 0-6 corresponding to WEEKDAY, for example Mon-Fri would be '01234' */
BEGIN
DECLARE date_start DATE;
DECLARE date_end DATE;
DECLARE total_days INT;
DECLARE weeks INT;
DECLARE start_weekday INT;
@kazeno
kazeno / issue14041.php
Created June 17, 2019 18:52
Proof of concept of Prestashop Github Issue 14041 https://github.com/PrestaShop/PrestaShop/issues/14041
<?php
/**
* Proof of concept of Prestashop Github Issue 14041 https://github.com/PrestaShop/PrestaShop/issues/14041
* Put this code inside modules/issue14041/issue14041.php and install the module, it will replicate the issue any time the module's configuration is accessed.
*/
class Issue14041 extends Module
{
public function __construct()
@kazeno
kazeno / AdminThemesController.php
Created September 13, 2016 13:15
Prestashop Preferences > Themes blank screen fix override
<?php
class AdminThemesController extends AdminThemesControllerCore
{
public function init()
{
$this->logged_on_addons = false;
parent::init();
}
}
@kazeno
kazeno / recursive_sort_yii.php
Created September 13, 2016 13:08
Sort objects hierarchically in recursive multidimensional arrays in Yii
<?php
$sections = Section::model()->findAll(
array('order'=>'parent ASC NULLS FIRST,"order"')); //PostgreSQL FTW
$entryRecords = array();
$entryPaths = array();
foreach ($sections as $section) {
$section->children = array();
$entryPaths[$section->id] = array();
if ($section->parent === NULL) {
$entryRecords[$section->order] = $section;
@kazeno
kazeno / recursive_sort_generic.php
Last active September 13, 2016 13:02
Sort objects hierarchically in recursive multidimensional arrays
<?php
$entries = yourGetEntriesFromDbFunction(); //The array with our retrieved DB entries
$entryRecords = array(); //Our hierarchy will be created in this array
//We will track the path of each entry here, with an array
//for each entry containing the ids of all its ancestors:
$entryPaths = array();
foreach ($entries as $entry) {
//Create a new key inside each entry to store its children:
$entry['children'] = array();
$entryPaths[$entry['id']] = array(); //Make a space for the path of the entry
@kazeno
kazeno / jquery_prop_1.6.js
Created September 13, 2016 12:43
Retrofitting jQuery prop() for jQuery > 1.6
if (typeof jQuery.fn.prop != 'function') {
jQuery.fn.prop = jQuery.fn.attr;
}