Site Tools


onny:notizen:programmierung

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
onny:notizen:programmierung [2026/08/11 11:03] – [php] fdc9:281f:4d7:9ee9::1onny:notizen:programmierung [2026/10/06 19:56] (current) – [php] fdc9:281f:4d7:9ee9::1
Line 670: Line 670:
 printf("SQL: %s\n", $query->getSQL()); printf("SQL: %s\n", $query->getSQL());
 printf("Parameters: %s\n", print_r($query->getParameters(), true)); printf("Parameters: %s\n", print_r($query->getParameters(), true));
 +</code>
 +
 +check if array key exists (avoid undefined warning) via "null casting"
 +
 +<code php>
 +if ($config['listCalendars'] ?? false) {
 +</code>
 +
 +check if string in array
 +
 +<code php>
 +if (in_array('trashbin', $config['match'], true)) {
 +    // trashbin was requested
 +}
 </code> </code>
 ==== nextcloud app dev ==== ==== nextcloud app dev ====
Line 703: Line 717:
 </code> </code>
  
 +logging
 +
 +<code php>
 +$this->logger->debug('Running actual SQL query {sql} with parameters {params}', [
 + 'sql' => $query->getSQL(),
 + 'params' => print_r($query->getParameters(), true),
 + 'app' => 'cleanup',
 +]);
 +</code>
 ==== wordpress ==== ==== wordpress ====
 registering menus registering menus
Line 911: Line 934:
 </code> </code>
  
 +sort column by timestamp and convert to datetime
 +
 +<code sql>
 +SELECT
 +    `id`,
 +    `calendarid`,
 +    FROM_UNIXTIME(`firstoccurence`) AS firstoccurence,
 +    FROM_UNIXTIME(`lastoccurence`)  AS lastoccurence
 +FROM `oc_calendarobjects`
 +WHERE (`lastoccurence` < 1606694400)
 +  AND (`firstoccurence` > 0)
 +  AND (`componenttype` = 'VEVENT')
 +ORDER BY `lastoccurence` DESC;
 +</code>
 +
 +==== django ====
 +
 +admin, searchable dropdown. plan field will be searchable.
 +
 +<code python>
 +class GovernmentPlanUpdateAdmin(admin.ModelAdmin):
 +    [...]
 +    autocomplete_fields = ["plan"]
 +    
 +[...]
 +
 +class GovernmentPlanAdmin(admin.ModelAdmin):
 +    form = GovernmentPlanForm
 +    [...]
 +    search_fields = ("title",)
 +</code>
 +
 +===== nix =====
 +
 +====== lib ======
 +
 +remove prefix
 +
 +<code nix>
 +stripped =
 +  lib.removePrefix "www."
 +    (lib.removePrefix "https://" url);
 +</code>
onny/notizen/programmierung.1786446211.txt.gz · Last modified: by fdc9:281f:4d7:9ee9::1