Snippets Collections
Ahh, the fabled URL hack. For years, Salesforce admins have used formulas to create dynamic URLs behind custom links. The classic use case is linking from a record to a report, and filtering that report to information relevant to that particular record. In the Classic UI, this was (and still is) pretty easy to achieve. You add one URL parameter to the link that represents the report filter, and pass in the Record ID tag.

When the Lightning UI came out, many admins were disappointed (horrified?) to learn that their beloved URL hacks wouldn’t work in Lightning. Salesforce product managers heard the feedback, and in the Spring ‘17 release, we got the ability to filter reports via URL parameters in Lightning! Here’s the basic syntax, as it appears in the release notes, used in a HYPERLINK:


But wait! That looks different! Indeed it is. The Lightning URL hack is different from the Classic URL. OK, so we can update our formula fields…but what happens if your org has some users in Classic and some in Lightning? Two different formula fields? Ugh. What’s an Awesome Admin to do?

Community to the rescue! Salesforce MVPs Thomas Taylor and Jeremiah Dohn both came up with a very clever way to create One Link to Rule Them All! Let’s take a look… (Did you know you could put comments in a formula field? Bonus tip!)


We’re using two key functions here: HYPERLINK generates the link itself, and IF lets us check the user’s displayed theme. Essentially we say if they’re in Lightning (AKA “Theme4d” behind the scenes), use the Lightning syntax, otherwise use the Classic syntax. Pretty simple once we take advantage of that $User.UIThemeDisplayed parameter!

Unfortunately, this cleverness isn’t tolerated by custom buttons, but it is tolerated fine by links in formula fields. I suggest converting any filtered-report buttons into links for the duration of your transition to Lightning.

If you are working on the Lightning transition at your organization, check out the Lightning Experience Rollout module on Trailhead. Once you’re ready to level up your skills, dive into the Lightning Experience Specialist Superbadge.
<?php
// Add Re-Order submenu to each post type
function add_reorder_submenu() {
    $post_types = get_post_types(array('show_ui' => true), 'objects');
    foreach ($post_types as $post_type) {
        // Skip the attachment post type
        if ($post_type->name === 'attachment') {
            continue;
        }
        $parent_slug = ($post_type->name === 'post') ? 'edit.php' : 'edit.php?post_type=' . $post_type->name;
        add_submenu_page(
            $parent_slug,
            'Re-Order ' . $post_type->label,
            'Re-Order',
            'edit_posts',
            $post_type->name . '-reorder',
            'display_reorder_page'
        );
    }
}
add_action('admin_menu', 'add_reorder_submenu');

// Display the reorder page
function display_reorder_page() {
    if (!current_user_can('edit_posts')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }

    $current_screen = get_current_screen();
    $post_type = $current_screen->post_type;
    if (empty($post_type)) {
        $post_type = sanitize_text_field($_GET['post_type'] ?? 'post');
    }
    $post_type_object = get_post_type_object($post_type);

    if (!$post_type_object || $post_type === 'attachment') {
        wp_die(__('Invalid post type.'));
    }

    $query_args = array(
        'post_type' => $post_type,
        'post_status' => array('publish', 'draft', 'pending', 'future', 'private'),
        'posts_per_page' => -1,
        'orderby' => 'menu_order',
        'order' => 'ASC',
        'suppress_filters' => true,
    );
    $posts = get_posts($query_args);

    $total_items = count($posts);

    ?>
    <div class="wrap">
        <h1><?php echo esc_html(sprintf('Re-Order %s', $post_type_object->labels->name)); ?></h1>
        
        <div id="message" class="updated notice is-dismissible" style="display:none;"><p></p></div>
        
        <p><?php esc_html_e('Drag and drop items to reorder them. Click "Update Order" to save changes.'); ?></p>
        <button id="update-order" class="button button-primary"><?php esc_html_e('Update Order'); ?></button>
        <button id="reset-order" class="button"><?php esc_html_e('Reset Order'); ?></button>
        
        <p class="item-count"><?php esc_html_e('Total items:'); ?> <span id="total-items"><?php echo esc_html($total_items); ?></span></p>
        
 <ul id="sortable-list" class="widefat striped">
        <?php foreach ($posts as $post) : 
            $title = $post->post_title;
            $status = get_post_status($post->ID);
            $status_class = ($status !== 'publish') ? sprintf(' post-status-%s', sanitize_html_class($status)) : '';
        ?>
            <li class="ui-state-default<?php echo esc_attr($status_class); ?>" data-id="<?php echo esc_attr($post->ID); ?>">
                <span class="dashicons dashicons-menu"></span>
                <?php echo esc_html($title); ?>
                <span class="post-status">(<?php echo esc_html($status); ?>)</span>
            </li>
        <?php endforeach; ?>
        </ul>

        <p class="reorder-footer">
            <?php
            echo wp_kses(
                sprintf(
                    'Created by <a href="%s" target="_blank">Yasir Shabbir</a>',
                    'https://yasirshabbir.com'
                ),
                array(
                    'a' => array(
                        'href' => array(),
                        'target' => array()
                    )
                )
            );
            ?>
        </p>
    </div>

    <style>
        #sortable-list { list-style-type: none; margin: 20px 0; padding: 0; }
        #sortable-list li { 
            padding: 10px 15px !important; 
            background: #fff; 
            border: 1px solid #ddd; 
            margin-bottom: 5px; 
            cursor: move; 
            font-size: 14px !important;
            line-height: 1.4;
        }
        #sortable-list li:hover { background: #f9f9f9; }
        #sortable-list .dashicons { 
            color: #bbb; 
            margin-right: 10px;
            font-size: 20px;
            line-height: 1;
        }
        .ui-sortable-helper { 
            background: #f9f9f9 !important; 
            box-shadow: 0 2px 5px rgba(0,0,0,0.15); 
        }
        #update-order, #reset-order { display: inline-block; margin-right: 10px; margin-bottom: 20px; }
        .updating { opacity: 0.5; pointer-events: none; }
        .post-status { font-size: 0.8em; color: #666; margin-left: 5px; }
        .post-status-draft { opacity: 0.7; }
        .post-status-pending { background-color: #fef7f1; }
        .post-status-future { background-color: #f1fef7; }
        .post-status-private { background-color: #fef1f1; }
        .item-count { margin-top: 10px; font-weight: bold; }
        
             .reorder-footer {
            margin-top: 20px;
            text-align: center;
            font-style: italic;
            color: #666;
        }
    </style>

    <script>
    jQuery(document).ready(function($) {
        $("#sortable-list").sortable({
            handle: ".dashicons-menu"
        });

        function updateOrder(action, buttonId) {
            var $button = $("#" + buttonId);
            var $list = $("#sortable-list");
            var order = $list.sortable("toArray", {attribute: "data-id"});
            
            $button.addClass("updating").text(action === "update_post_order" ? "<?php esc_html_e('Updating...'); ?>" : "<?php esc_html_e('Resetting...'); ?>");
            $list.addClass("updating");
            
            $.ajax({
                url: ajaxurl,
                type: "POST",
                data: {
                    action: action,
                    order: order,
                    post_type: <?php echo wp_json_encode($post_type); ?>,
                    security: <?php echo wp_json_encode(wp_create_nonce('post_order_nonce')); ?>
                },
                success: function(response) {
                    if (response.success) {
                        $("#message").html("<p>" + response.data + "</p>").show();
                        if (action === "reset_post_order") {
                            location.reload();
                        }
                    } else {
                        $("#message").html("<p><?php esc_html_e('Error:'); ?> " + response.data + "</p>").show();
                    }
                },
                error: function() {
                    $("#message").html("<p><?php esc_html_e('An error occurred.'); ?></p>").show();
                },
                complete: function() {
                    $button.removeClass("updating").text(action === "update_post_order" ? "<?php esc_html_e('Update Order'); ?>" : "<?php esc_html_e('Reset Order'); ?>");
                    $list.removeClass("updating");
                }
            });
        }

        function updateItemCount() {
            var count = $("#sortable-list li").length;
            $("#total-items").text(count);
        }

        $("#update-order").click(function() {
            updateOrder("update_post_order", "update-order");
        });

        $("#reset-order").click(function() {
            if (confirm("<?php esc_html_e('Are you sure you want to reset the order? This cannot be undone.'); ?>")) {
                updateOrder("reset_post_order", "reset-order");
                setTimeout(updateItemCount, 500);
            }
        });

        updateItemCount();

        $("#sortable-list").on("DOMSubtreeModified", function() {
            updateItemCount();
        });
    });
    </script>
    <?php
}

// AJAX handler to update post order
function update_post_order() {
    check_ajax_referer('post_order_nonce', 'security');
    
    $order = $_POST['order'];
    $post_type = $_POST['post_type'];
    
    if ($post_type === 'attachment') {
        wp_send_json_error('Reordering media items is not supported.');
        return;
    }
    
    foreach ($order as $menu_order => $post_id) {
        wp_update_post(array(
            'ID' => intval($post_id),
            'menu_order' => intval($menu_order)
        ));
    }
    
    wp_send_json_success('Order updated successfully');
}
add_action('wp_ajax_update_post_order', 'update_post_order');

// AJAX handler to reset post order
function reset_post_order() {
    check_ajax_referer('post_order_nonce', 'security');
    
    $post_type = $_POST['post_type'];
    
    if ($post_type === 'attachment') {
        wp_send_json_error('Reordering media items is not supported.');
        return;
    }
    
    $posts = get_posts(array(
        'post_type' => $post_type,
        'posts_per_page' => -1,
        'post_status' => 'any',
    ));
    
    foreach ($posts as $post) {
        wp_update_post(array(
            'ID' => $post->ID,
            'menu_order' => 0
        ));
    }
    
    wp_send_json_success('Order reset successfully');
}
add_action('wp_ajax_reset_post_order', 'reset_post_order');

// Update post order when posts are created or trashed
function set_default_post_order($post_id, $post, $update) {
    if (!$update && $post->post_type !== 'attachment') {
        $post_type = get_post_type($post_id);
        $last_post = get_posts(array(
            'post_type' => $post_type,
            'posts_per_page' => 1,
            'orderby' => 'menu_order',
            'order' => 'DESC'
        ));
        $new_menu_order = (!empty($last_post)) ? $last_post[0]->menu_order + 1 : 0;
        wp_update_post(array(
            'ID' => $post_id,
            'menu_order' => $new_menu_order
        ));
    }
}
add_action('wp_insert_post', 'set_default_post_order', 10, 3);
{
	"blocks": [
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": ":lemon: Boost Days - Whats On This Week! :lemon:"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "Mōrena Ahuriri & happy Monday! :smiling-hand-over-mouth:\n\nWe're excited to bring you another great week in the office with our Boost Day Program! :yay: Please see below for whats on this week :arrow-bounce:"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": ":calendar-date-13: Wednesday, 13th November",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "\n:coffee: *Café Partnership*: Enjoy coffee and café-style beverages from our cafe partner, *Adoro*, located in our office building *8:00AM - 11:30AM*.\n:croissant: *Morning Tea*: Provided by *Mitzi and Twinn* *10:30AM - 11:30AM* in the Kitchen. \n :bike: *Wellness*: Week 3 of our 8 Week Group Fitness programme! This week's Cycle Class is on *7:30AM - 8:05AM* at *City Fitness Napier* :party-woohoo: Book *<https://docs.google.com/spreadsheets/d/1d5GoOxrRyLoQExk5P5IgfgVCXOpbXXoVduwNvMMlUik/edit?gid=617105650#gid=617105650|here>* to secure your slot for upcoming classes! :yeah:"
			}
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": ":calendar-date-14: Thursday, 14th November",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": ":coffee: *Café Partnership*: Enjoy coffee and café-style beverages from our cafe partner, *Adoro*, located in our office building *8:00AM - 11:30AM*. \n:breakfast: *Breakfast*: Provided by *Roam* *9:30AM - 11:00AM* in the Kitchen. \n:orange: *Social+*: Aperitivo Hour :clinking_glasses: featuring aperol spritz, local wine 'tastings' & canapes *4:00PM - 6:00PM*"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*LATER THIS MONTH:*"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*Friday, 22nd November* \n:unicorn_face: *RSVP Deadline for EOY Event*: Register <https://xero-wx.jomablue.com/reg/store/eoy_hwk|*here*> :magic_wand:\n\n*Wednesday, 27th November*\n:xero: *Global All Hands*: Streaming in Clearview *11:00AM - 12:00PM*."
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "Stay tuned to this channel for more details, check out the <https://calendar.google.com/calendar/u/0?cid=eGVyby5jb21fbXRhc2ZucThjaTl1b3BpY284dXN0OWlhdDRAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ|*Hawkes Bay Social Calendar*>, and get ready to Boost your workdays!\n\nWX Team :party-wx:"
			}
		}
	]
}
import { Component } from '@angular/core';
import { PaymentService } from '../Services/payment.service';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Router } from '@angular/router';
import { Location } from '@angular/common';
import * as XLSX from 'xlsx';
import * as FileSaver from 'file-saver';
import { MasterSideNavBarComponent } from '../master-side-nav-bar/master-side-nav-bar.component';
import { SideNavBarComponent } from '../side-nav-bar/side-nav-bar.component';
declare var $: any;

@Component({
  selector: 'app-payment',
  standalone: true,
  imports: [CommonModule, FormsModule, ReactiveFormsModule, MasterSideNavBarComponent, SideNavBarComponent],
  templateUrl: './payment.component.html',
  styleUrl: './payment.component.css'
})
export class PaymentComponent {
  userTypeID: number | null = null;
  payments: any[] = [];
  selectedPayment: any | null = null;
  filterPayment: any[] = [];
  searchTerm: string = '';
  helpContent: any[] = [];
  filteredContent: any[] = [];

  constructor(private paymentService: PaymentService, private router: Router, private location: Location, private snackBar: MatSnackBar) {}

  ngOnInit(): void {
    const userTypeId = JSON.parse(localStorage.getItem('User') || '{}').userTypeId;
    this.userTypeID = userTypeId;

    this.loadPayments();


    // Initialize help content
    this.helpContent = [
      {
        title: 'Payment Manager Page Context-Sensitive Help',
        content: `
          <p><strong>Overview:</strong> The Payment Manager page allows you to view and manage payment records, including searching for specific payments, viewing detailed payment information, and exporting payment data to Excel.</p>
          <p><strong>Page Components:</strong></p>`
      },
      {
        title: '1. Search Bar',
        content: `
          <ul>
            <li><strong>Purpose:</strong> Allows you to search for specific payments by ID, member name, amount, date, or payment type.</li>
            <li><strong>Usage:</strong> Enter your search term into the input field. The list of payments will automatically filter to show matching results based on your search criteria.</li>
          </ul>`
      },
      {
        title: '2. Payment Table',
        content: `
          <ul>
            <li><strong>Purpose:</strong> Displays a list of all payments with their ID, member name, amount, payment date, payment type, and action buttons.</li>
            <li><strong>Usage:</strong> View details of each payment by clicking the "View" button. The table will update based on the search term entered in the search bar.</li>
          </ul>`
      },
      {
        title: '3. Export to Excel Button',
        content: `
          <ul>
            <li><strong>Purpose:</strong> Exports the currently displayed payment data to an Excel file.</li>
            <li><strong>Usage:</strong> Click the "Export to Excel" button to generate and download an Excel file containing the filtered payment data.</li>
          </ul>`
      },
      {
        title: '4. Modal for Payment Details',
        content: `
          <ul>
            <li><strong>Purpose:</strong> Provides detailed information about a selected payment.</li>
            <li><strong>Usage:</strong> Click the "View" button next to a payment in the table to open the modal. The modal will display detailed information including Payment ID, Member Name, Amount, Payment Date, and Payment Type. Click "Close" to dismiss the modal.</li>
          </ul>`
      },
      {
        title: 'Common Questions',
        content: `
          <p><strong>Q:</strong> How do I search for payments?</p>
          <p><strong>A:</strong> Use the search bar at the top of the page. Enter terms such as payment ID, member name, amount, date, or payment type to filter the payments shown in the table.</p>
          <p><strong>Q:</strong> How can I view details of a payment?</p>
          <p><strong>A:</strong> Click the "View" button next to the payment in the table. This will open a modal with detailed information about the selected payment.</p>
          <p><strong>Q:</strong> How do I export payment data to Excel?</p>
          <p><strong>A:</strong> Click the "Export to Excel" button. An Excel file with the filtered payment data will be generated and downloaded to your computer.</p>
          <p><strong>Q:</strong> Why isn't the search working?</p>
          <p><strong>A:</strong> Ensure that you are entering the search terms correctly and that there are payments that match your criteria. Check for any typos or mismatches in the search terms.</p>
          <p><strong>Q:</strong> What should I do if the export to Excel fails?</p>
          <p><strong>A:</strong> Ensure that your browser supports Excel file downloads and that no errors occur during the generation of the file. Verify that the Excel library (XLSX) is correctly integrated and functioning.</p>`
      },
      {
        title: 'Troubleshooting:',
        content: `
          <p><strong>Problem:</strong> The search bar is not filtering results.</p>
          <p><strong>Solution:</strong> Ensure that the search terms are correctly entered and that there are matching payments. Verify that the search functionality is correctly implemented and check for any console errors.</p>
          <p><strong>Problem:</strong> The export to Excel button is not working.</p>
          <p><strong>Solution:</strong> Ensure that the Excel export library (XLSX) is properly integrated and that there are no issues with file generation. Check for network or console errors that might indicate the problem.</p>`
      }
    ];

    // Initialize filtered content
    this.filteredContent = [...this.helpContent];
  }

  filterHelpContent(): void {
    const term = this.searchTerm.toLowerCase();
    this.filteredContent = this.helpContent.filter(item =>
      item.title.toLowerCase().includes(term) || item.content.toLowerCase().includes(term)
    );
  }

  loadPayments(): void {
    this.paymentService.getPayments().subscribe({
      next: (data) => {
        this.payments = data;
        this.filterPayment = data;
        console.log(data)
      },
      error: (err) => {
        console.error('Error fetching payments:', err);
      }
    });
  }  

  filteredPayments(): void {
    if (!this.searchTerm) {
      this.filterPayment = this.payments;
    } else {
      const term = this.searchTerm.toLowerCase();
      this.filterPayment = this.payments.filter(payment =>
        payment.payment_ID.toString().includes(term) ||
        payment.memberName.toLowerCase().includes(term) ||
        payment.amount.toString().includes(term) ||
        payment.payment_Date.toString().includes(term) ||
        payment.paymentTypeName.toLowerCase().includes(term)
      );
    }
  }
 
  openModal(payment: any): void {
    this.selectedPayment = payment;
    $('#userModal').modal('show');
  }
 
  closeModal(): void {
    $('#userModal').modal('hide');
  }
 
  goBack(): void {
    this.location.back();
  }

  exportToExcel(): void {
    const customHeaders = [
      { header: 'Payment ID', key: 'payment_ID' },
      { header: 'Member Name', key: 'memberName' },
      { header: 'Amount', key: 'amount' },
      { header: 'Payment Date', key: 'payment_Date' },
      { header: 'Payment Type', key: 'paymentTypeName' }
    ];

    const worksheetData = this.filterPayment.map(payment => ({
      payment_ID: payment.payment_ID,
      memberName: payment.memberName,
      amount: payment.amount,
      payment_Date: this.formatDate(payment.payment_Date), // Format the date
      paymentTypeName: payment.paymentTypeName
    }));

    const worksheet = XLSX.utils.json_to_sheet(worksheetData, { header: customHeaders.map(h => h.key) });
    const workbook = { Sheets: { 'Payments': worksheet }, SheetNames: ['Payments'] };

    // Modify column headers
    customHeaders.forEach((header, index) => {
      const col = XLSX.utils.encode_col(index); // Convert 0 -> 'A', 1 -> 'B', etc.
      worksheet[`${col}1`] = { t: 's', v: header.header };
    });

    const excelBuffer: any = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
    this.saveAsExcelFile(excelBuffer, 'payments');
  }

  private formatDate(date: string): string {
    return new Date(date).toISOString().split('T')[0];
  }

  private saveAsExcelFile(buffer: any, fileName: string): void {
    const data: Blob = new Blob([buffer], { type: EXCEL_TYPE });
    FileSaver.saveAs(data, `${fileName}_${new Date().getTime()}.xlsx`);
  }
}

const EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
Data Analysis using numpy and pandas:

Program:
import numpy as np
x1 = np.array([[1,2,3],[4,5,6]]) 
print(x1.shape)
x2 = np.array([[1,2,3],[4,5,6]])
x2.shape = (3,2)
print(x2.size)
x11 = np.zeros((5,2), dtype = np.int)
print(x11)
x13 = np.ones([2,2], dtype=int)
x14 = np.arange(10, 20, 2)
x15 = np.arange(10, 20, 0.5)
i1 = np.array([[21,12,43],[54,25,6],[27,8,99]])
print(np.amin(i1,1))  #across rows
print(np.amin(i1,0))  #across cols
i2 = np.array([[20,50,80],[30,60,90],[40,70,100]])
print(np.percentile(i2,100))
print(np.median(i2))
i3 = np.array([[1,2,3],[3,4,5],[4,5,6]])
print(np.mean(i3))
i4 = np.array([1,2,3,4])
print(i4)
print(np.average(i4))
i5 = np.array([1,2,3,4])
print(np.var(i5))
print(np.std(i5))


O/P:
(2, 3)
6
[[0 0]
 [0 0]
 [0 0]
 [0 0]
 [0 0]]
[12  6  8]
[21  8  6]
100.0
60.0
3.6666666666666665
[1 2 3 4]
2.5
1.25
1.118033988749895



import pandas as pd   
 dict1 ={'a':1, 'b':2, 'c':3, 'd':4}   # Program to Create Data Frame with two dictionaries
dict2 ={'a':5, 'b':6, 'c':7, 'd':8, 'e':9} 
Data = {'first':dict1, 'second':dict2}
a = pd.DataFrame(Data)  
print(a)
s1 = pd.Series([1, 3, 4, 5, 6, 2, 9])   # Define series 1
s2 = pd.Series([1.1, 3.5, 4.7, 5.8, 2.9, 9.3])   # Define series 2       
s3 = pd.Series(['a', 'b', 'c', 'd', 'e'])     # Define series 3
Data1 ={'first':s1, 'second':s2, 'third':s3}  # Define Data
dfseries = pd.DataFrame(Data1)  # Create DataFrame
print(dfseries)
d1 =[[2, 3, 4], [5, 6, 7]] # Define 2d array 1
d2 =[[2, 4, 8], [1, 3, 9]] # Define 2d array 2
Data ={'first': d1, 'second': d2}  # Define Data
df2d = pd.DataFrame(Data)  # Create DataFrame
print(df2d)

O/P:
   first  second
a    1.0       5
b    2.0       6
c    3.0       7
d    4.0       8
e    NaN       9
   first  second third
0      1     1.1     a
1      3     3.5     b
2      4     4.7     c
3      5     5.8     d
4      6     2.9     e
5      2     9.3   NaN
6      9     NaN   NaN
       first     second
0  [2, 3, 4]  [2, 4, 8]
1  [5, 6, 7]  [1, 3, 9]


<ifModule mod_headers.c>
Header set X-Content-Type-Options nosniff
</ifModule>
/** 
 * Enables the HTTP Strict Transport Security (HSTS) header in WordPress. 
 */
function tg_enable_strict_transport_security_hsts_header_wordpress() {
    header( 'Strict-Transport-Security: max-age=31536000; includeSubDomains; preload' );
}
add_action( 'send_headers', 'tg_enable_strict_transport_security_hsts_header_wordpress' );
import bpy

class MI_PANEL(bpy.types.Panel):
    bl_label = "Mi Panel"
    bl_idname = "OBJECT_PT_mi_panel"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'Mi Addon'

    def draw(self, context):
        layout = self.layout

def register():
    bpy.utils.register_class(MI_PANEL)

def unregister():
    bpy.utils.unregister_class(MI_PANEL)

if __name__ == "__main__":
    register()
//Insights Insallation

cd frappe-bench
bench get-app insights //*For Latest Version
Or
bench get-app insights --branch version-3
bench --site site1.local install-app insights


//if not working then run
bench update --reset
void showSnackBar(
  String text,
) {
  ScaffoldMessenger.of(globalNavigatorKey.currentContext!)
    ..hideCurrentSnackBar()
    ..showSnackBar(
      SnackBar(
        backgroundColor:
            Theme.of(globalNavigatorKey.currentContext!).colorScheme.primary,
        padding: const EdgeInsets.all(0),
        content: Container(
          height: 60,
          decoration: const BoxDecoration(
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(
                20,
              ),
              topRight: Radius.circular(
                20,
              ),
            ),
          ),
          child: Center(
            child: Text(
              text,
              overflow: TextOverflow.visible,
              style: Theme.of(globalNavigatorKey.currentContext!)
                  .textTheme
                  .titleMedium!
                  .copyWith(
                    color: Theme.of(globalNavigatorKey.currentContext!)
                        .colorScheme
                        .onPrimary,
                  ),
            ),
          ),
        ),
      ),
    );
}
Print Designer Installation

cd frappe-bench
bench get-app print_designer
bench --site site1.local install-app print_designer

//if not Run or Show

Bench update --reset
Bench restart
or Restart Computer
{
	"blocks": [
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": "✨ :magic_wand::xero-unicorn: End of Year Celebration – A Sprinkle of Magic! :xero-unicorn: :magic_wand:✨",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*Hi Melbourne!* \nGet ready to wrap up the year with a sprinkle of magic and a lot of fun at our End of Year Event! Here’s everything you need to know:"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"fields": [
				{
					"type": "mrkdwn",
					"text": "*📅 When:*\nThursday 28th November"
				},
				{
					"type": "mrkdwn",
					"text": "*📍 Where:*\n<https://www.google.com/maps/place/The+Timber+Yard/@-37.8331021,144.918894,17z/data=!3m1!4b1!4m6!3m5!1s0x6ad667735e56fcab:0x966480f06c58c00c!8m2!3d-37.8331021!4d144.9214743!16s/g/11gyy7sy4c?entry=ttu&g_ep=EgoyMDI0MDkxOC4xIKXMDSoASAFQAw==/|*The Timber Yard*> \n351 Plummer Street, Port Melbourne"
				},
				{
					"type": "mrkdwn",
					"text": "*⏰ Time:*\n4 PM - 10 PM"
				}
			]
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*:magic_wand::xero-unicorn: Theme:*\n_A Sprinkle of Magic_ – Our theme is inspired by the Xero Unicorn, embracing creativity, inclusivity, and diversity. Expect unique decor, magical moments, and a fun-filled atmosphere!"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*:dress: Dress Code:*\nSmart casual – Show your personality, but no Xero tees or lanyards, please!\nIf you're feeling inspired by the theme, why not add a little 'Sprinkle of Magic' to your outfit? Think glitter, sparkles, or anything that shows off your creative side! (Totally optional, of course! ✨)"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*🚍 Transport Info:*\n*Public Transport:* Via bus routes 234 & 235 - 5 min walk from bus stop\n*Parking:* 200+ unmetered and untimed spaces on Plummer & Smith Street\n*Xero Chartered Bus:* 3:15 PM departure from the Melbourne office - opt-in via your email invite."
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*🎤 :hamburger: Entertainment & Food:*\nPrepare to be dazzled by live music, enchanting magic shows, cozy chill-out zones, delicious bites, refreshing drinks, and plenty of surprises! ✨🎶"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "*🎟 RSVP Now:*\nPlease click <https://xero-wx.jomablue.com/reg/store/eoy_mel|*here*> to RSVP!\nMake sure you RSVP by [insert RSVP deadline]!"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": ":question::question:Got questions? See the <https://docs.google.com/document/d/1iygJFHgLBRSdAffNsg3PudZCA45w6Wit7xsFxNc_wKM/edit|FAQs> doc or post in the Slack channel.\nWe can’t wait to celebrate with you! :partying_face: :xero-love:"
			}
		}
	]
}
https://www.microsoft.com/en-us/dynamics-365/blog/it-professional/2017/07/06/customizing-the-warehousing-mobile-app/?source=dynamicsaxscm
<?php 
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}

class Custom_Podcast_Widget extends \Elementor\Widget_Base {
    public function get_name() {
        return 'custom_audio_podcast';
    }

    public function get_title() {
        return __('Custom Audio Podcast', 'plugin-name');
    }

    public function get_icon() {
        return 'eicon-play';
    }

    public function get_categories() {
        return ['general'];
    }

    protected function register_controls() {
		$this->start_controls_section(
            'author_section',
            [
                'label' => __('Author Information', 'plugin-name'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'author_name',
            [
                'label' => __('Author Name', 'plugin-name'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('Author Name', 'plugin-name'),
            ]
        );

        $this->add_control(
            'author_image',
            [
                'label' => __('Author Image', 'plugin-name'),
                'type' => \Elementor\Controls_Manager::MEDIA,
                'media_type' => 'image',
            ]
        );

        $this->end_controls_section();
		
		
// 		Content section
        $this->start_controls_section(
            'content_section',
            [
                'label' => __('Content', 'plugin-name'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );

        $repeater = new \Elementor\Repeater();
		
		$repeater->add_control(
			'media_type',
			[
				'label' => __('Media Type', 'plugin-name'),
				'type' => \Elementor\Controls_Manager::SELECT,
				'options' => [
					'audio' => __('Audio', 'plugin-name'),
					'video' => __('Video', 'plugin-name'),
				],
				'default' => 'audio',
			]
		);


        $repeater->add_control(
			'file',
			[
				'label' => __('Media File', 'plugin-name'),
				'type' => \Elementor\Controls_Manager::MEDIA,
				'media_type' => ['audio', 'video'], 
			]
		);


        $repeater->add_control(
            'thumbnail',
            [
                'label' => __('Thumbnail', 'plugin-name'),
                'type' => \Elementor\Controls_Manager::MEDIA,
                'media_type' => 'image',
            ]
        );

        $repeater->add_control(
            'title',
            [
                'label' => __('Title', 'plugin-name'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('Podcast Title', 'plugin-name'),
            ]
        );

        $repeater->add_control(
            'subtitle',
            [
                'label' => __('Subtitle', 'plugin-name'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('Subtitle', 'plugin-name'),
            ]
        );

		$repeater->add_control(
            'broadcast_label',
            [
                'label' => __('Broadcast Label', 'plugin-name'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('Broadcast on:', 'plugin-name'),
                'label_block' => true,
            ]
        );

		$repeater->add_control(
            'release_date',
            [
                'label' => __('Release Date', 'plugin-name'),
                'type' => \Elementor\Controls_Manager::DATE_TIME,
                'default' => '',
                'label_block' => true,
            ]
        );

        $this->add_control(
            'podcast_items',
            [
                'label' => __('Podcast Items', 'plugin-name'),
                'type' => \Elementor\Controls_Manager::REPEATER,
                'fields' => $repeater->get_controls(),
                'default' => [],
                'title_field' => '{{{ title }}}',
            ]
        );

        $this->end_controls_section();
		
		$this->start_controls_section(
				'content_post',
				[
					'label' => __('Content Post', 'plugin-name'),
					'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
				]
			);

			$this->add_control(
				'post_count',
				[
					'label' => __('Number of Posts', 'plugin-name'),
					'type' => \Elementor\Controls_Manager::NUMBER,
					'default' => 4,
				]
			);

			$this->add_control(
				'post_category',
				[
					'label' => __('Post Category', 'plugin-name'),
					'type' => \Elementor\Controls_Manager::SELECT2,
					'options' => $this->get_post_categories(),
					'multiple' => false,
					'default' => '',
				]
			);

			$this->end_controls_section();

    }
	private function get_post_categories() {
		$categories = get_terms('category');
		$category_options = [];
		if (!empty($categories)) {
			foreach ($categories as $category) {
				$category_options[$category->term_id] = $category->name;
			}
		}
		return $category_options;
	}


		protected function render() {
			$settings = $this->get_settings_for_display();

			if ($settings['podcast_items']) {
				echo '<div class="custom-podcast-faq-widget">';

				echo '<div class="faq-header">';
				echo '<div class="faq-header-image"><img src="' . esc_url($settings['author_image']['url']) . '" alt="' . esc_attr($settings['author_name']) . '"></div>';
				echo '<div class="faq-header-title">' . esc_html($settings['author_name']) . '</div>';
				echo '<div class="faq-header-arrow">';
				echo '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="800px" height="800px" viewBox="0 -4.5 20 20" version="1.1">
						<title>arrow_down [#338]</title>
						<desc>Created with Sketch.</desc>
						<defs></defs>
						<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
							<g id="Dribbble-Light-Preview" transform="translate(-220.000000, -6684.000000)" fill="#000000">
								<g id="icons" transform="translate(56.000000, 160.000000)">
									<path d="M164.292308,6524.36583 L164.292308,6524.36583 C163.902564,6524.77071 163.902564,6525.42619 164.292308,6525.83004 L172.555873,6534.39267 C173.33636,6535.20244 174.602528,6535.20244 175.383014,6534.39267 L183.70754,6525.76791 C184.093286,6525.36716 184.098283,6524.71997 183.717533,6524.31405 C183.328789,6523.89985 182.68821,6523.89467 182.29347,6524.30266 L174.676479,6532.19636 C174.285736,6532.60124 173.653152,6532.60124 173.262409,6532.19636 L165.705379,6524.36583 C165.315635,6523.96094 164.683051,6523.96094 164.292308,6524.36583"></path>
								</g>
							</g>
						</g>
					</svg>';
				echo '</div>';
				echo '</div>';

				echo '<div class="faq-content" style="display:none;">';
				foreach ($settings['podcast_items'] as $item) {
					$media_type = $item['media_type'];
					$file_url = $item['file']['url'];
					$title = $item['title'];
					$subtitle = $item['subtitle'];
					$broadcast_label = $item['broadcast_label'];
					$release_date = $item['release_date'];

					if ($media_type === 'audio') {
						$thumbnail = wp_get_attachment_image_src($item['thumbnail']['id'], 'full')[0];

						echo '<div class="podcast-item podcast-audio">';
						echo '<div class="podcast-thumbnail"><img src="' . esc_url($thumbnail) . '" alt="' . esc_attr($title) . '"></div>';
						echo '<div class="podcast-info">';
						echo '<h3 class="podcast-title">' . esc_html($title) . '</h3>';
						echo '<p class="podcast-subtitle">' . esc_html($subtitle) . '</p>';
						if (!empty($release_date)) {
							echo '<p class="podcast-release-date">' . esc_html($broadcast_label) . ' ' . esc_html(date('F j, Y', strtotime($release_date))) . '</p>';
						}
						echo '<audio controls><source src="' . esc_url($file_url) . '" type="audio/mpeg"></audio>';
						echo '</div>'; // .podcast-info
						echo '</div>'; // .podcast-item
					} elseif ($media_type === 'video') {
						echo '<div class="podcast-item podcast-video">';
						echo '<div class="video-thumbnail">';
						echo '<div class="icon-play-podcast"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zM188.3 147.1c7.6-4.2 16.8-4.1 24.3 .5l144 88c7.1 4.4 11.5 12.1 11.5 20.5s-4.4 16.1-11.5 20.5l-144 88c-7.4 4.5-16.7 4.7-24.3 .5s-12.3-12.2-12.3-20.9l0-176c0-8.7 4.7-16.7 12.3-20.9z"/></svg> </div>';
						echo '<video class="video-popup-trigger" src="' . esc_url($file_url) . '" muted></video>';
						echo '</div>';
						echo '<div class="podcast-info">';
						echo '<h3 class="podcast-title">' . esc_html($title) . '</h3>';
						echo '<p class="podcast-subtitle">' . esc_html($subtitle) . '</p>';
						if (!empty($release_date)) {
							echo '<p class="podcast-release-date">' . esc_html($broadcast_label) . ' ' . esc_html(date('F j, Y', strtotime($release_date))) . '</p>';
						}
						echo '<button class="watch-now-btn video-popup-trigger" data-video="' . esc_url($file_url) . '">Watch Now</button>';
						echo '</div>'; 
						echo '</div>'; 
					}
				}
				
				if (!empty($settings['additional_card_items'])) {
					echo '<div class="additional-podcast-cards">';

						$post_count = !empty($settings['post_count']) ? intval($settings['post_count']) : 3; 
						$category_id = !empty($settings['post_category']) ? intval($settings['post_category']) : 0; 

						var_dump($post_count);
						var_dump($category_id); 

						
						$args = array(
							'posts_per_page' => $post_count,
							'category__in'   => array($category_id), 
						);

						$query = new WP_Query($args);

						if ($query->have_posts()) {
							while ($query->have_posts()) {
								$query->the_post();
								echo '<div class="additional-card-item">';
								echo '<div class="card-image" style="position: relative;">';
								echo '<img src="' . get_the_post_thumbnail_url(get_the_ID(), 'full') . '" alt="' . get_the_title() . '">';
								echo '<a class="play-link" href="' . get_the_permalink() . '">';
								echo '<svg aria-hidden="true" class="e-font-icon-svg e-fas-play" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"></path></svg>';
								echo '</a>';
								echo '<p class="card-date">' . get_the_date() . '</p>';
								echo '</div>';
								echo '<div class="card-info">';
								$tag_link = get_tag_link(get_the_tags()[0]->term_id);
								echo '<div class="card-season-title">';
								echo '<a href="' . esc_url($tag_link) . '">';
								echo '<svg aria-hidden="true" class="e-font-icon-svg e-fas-headphones-alt" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="M160 288h-16c-35.35 0-64 28.7-64 64.12v63.76c0 35.41 28.65 64.12 64 64.12h16c17.67 0 32-14.36 32-32.06V320.06c0-17.71-14.33-32.06-32-32.06zm208 0h-16c-17.67 0-32 14.35-32 32.06v127.88c0 17.7 14.33 32.06 32 32.06h16c35.35 0 64-28.71 64-64.12v-63.76c0-35.41-28.65-64.12-64-64.12zM256 32C112.91 32 4.57 151.13 0 288v112c0 8.84 7.16 16 16 16h16c8.84 0 16-7.16 16-16V288c0-114.67 93.33-207.8 208-207.82 114.67.02 208 93.15 208 207.82v112c0 8.84 7.16 16 16 16h16c8.84 0 16-7.16 16-16V288C507.43 151.13 399.09 32 256 32z"></path></svg>';
								echo esc_html(get_the_tags()[0]->name);
								echo '</a>';
								echo '</div>';
								echo '<h3 class="card-main-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
								echo '</div>';
								echo '</div>';
							}
							wp_reset_postdata();
						} else {
							echo '<p>' . __('No posts found.', 'plugin-name') . '</p>';
						}


						echo '</div>'; // .additional-podcast-cards
					}
					echo '</div>'; // .faq-content
					echo '</div>'; // .custom-podcast-faq-widget
				}
			}
}
{
	"blocks": [
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": ":star: What's on in Melbourne this week! :star:"
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "\n\n Hey Melbourne, happy Monday! Please see below for what's on this week. "
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": "Xero Café :coffee:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "\n :new-thing: *This week we are offering:* \n\n Unicorn Cookies, Rocket Ship Cookies & Vegan Choc Raspberry Slice \n\n *Weekly Café Special*: _Jaffa Latte_"
			}
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": "Monday, 30th September :calendar-date-30:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "Hackathon begins! We're kicking off with an office lunch from 12pm in the Level 3 Kitchen. We'll have Poke Bowls available for everyone to grab! :poke-bowl:"
			}
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": " Wednesday, 2nd October :calendar-date-2:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "\n\n:fruits: *Afternoon Tea*: From *2pm* in the L3 kitchen + breakout space! \n\n:yoga2:*Wellbeing - Yoga Flow*: Confirm your spot <https://docs.google.com/spreadsheets/d/1iKMQtSaawEdJluOmhdi_r_dAifeIg0JGCu7ZSPuwRbo/edit?gid=0#gid=0/|*here*>. Please note we have a maximum of 15 participants per class, a minimum notice period of 4 hours is required if you can no longer attend."
			}
		},
		{
			"type": "header",
			"text": {
				"type": "plain_text",
				"text": "Thursday, 3rd October :calendar-date-3:",
				"emoji": true
			}
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": ":breakfast: *Breakfast*: Provided by *Kartel Catering* from *8:30am - 10:30am* in the Wominjeka Breakout Space.\n\n"
			}
		},
		{
			"type": "divider"
		},
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": ":connect: *Reminder - Boost Survey:* Our Boost Day feedback survey is live until the 1st of October 2024, give us your thoughts <https://yourvoice.xero.com/jfe/form/SV_eyA8ArYHfnsfUwu|*here*>. All responses are anonymous! \n\n *Later this month*: We have our Hackathon themed Social+ on the 31st of October 2024! :xero-unicorn: \n\n Stay tuned to this channel for more details, and make sure you're subscribed to the <https://calendar.google.com/calendar/u/0?cid=Y19xczkyMjk5ZGlsODJzMjA4aGt1b3RnM2t1MEBncm91cC5jYWxlbmRhci5nb29nbGUuY29t|*Melbourne Social Calendar*> :party-wx:"
			}
		}
	]
}
import time
import pygame
import pendulum

def alarm():
    pygame.mixer.init()
    pygame.mixer.music.load('alarm.mp3')
    pygame.mixer.music.play()

    while pygame.mixer.music.get_busy():
        time.sleep(1)


def set_alarm(target_time):
    while True:
        dt = pendulum.now()
        current_time = dt.strftime('%I:%M:%S %p')
        print(current_time, target_time)
        time.sleep(1)
        if current_time == target_time:
            break


target_time = '07:09:00 PM'
set_alarm(target_time)
alarm()
<button type="button">Click Me!</button>
url = "https://api-demo.sambasafety.io/oauth2/v1/token";
	headers = {
		"x-api-key": "WJDBWMdYFX3FbAlf3WY8DWBzaG3MaQI9SPbWE0j7",
		"Content-Type": "application/x-www-form-urlencoded",
		"Authorization": "Basic MG9hMTl5Yjlod2dyU3VnNVMzNTg6ZHBvNGFYLWZlWFBqQ2tHanF1YjgwdTc2OG5PY0pUQ3ZGSmtlOTVXUkc2RVFNbWdmMlQxWlUzOUthOEEtT0dnMA=="
	};
	params = map();
	params.put("grant_type", "client_credentials");
	params.put("scope", "API");
	x = invokeurl
	[
		url: url
		type: POST 
		parameters:params
		headers: headers
];
//info x;
access_token = x.get("access_token");
/////////////////////////////////////////////
/////////////////////////////////////////////////////////

url = "https://api-demo.sambasafety.io/organization/v1/groups/92790";
headers = {
    "x-api-key": "WJDBWMdYFX3FbAlf3WY8DWBzaG3MaQI9SPbWE0j7",
    "Content-Type": "application/x-www-form-urlencoded",
    "Authorization": "Bearer " + access_token 
};

x = invokeurl
[
    url: url
    type: get
    headers: headers
];

info x;
add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) {
	return array(
		'width'  => 400,
		'height' => 400,
		'crop'   => 1,
	);
} );
import numpy as np
import math
from typing import Tuple
import pandas as pd
import os
from PIL import Image
import shutil

CLASS_COLORS = {
    0: {'color_rgb': (0, 0, 0), 'label': 'background'},
    1: {'color_rgb': (255, 0, 0), 'label': 'chondroosseous border'},
    2: {'color_rgb': (0, 255, 0), 'label': 'femoral head'},
    3: {'color_rgb': (0, 0, 255), 'label': 'labrum'},
    4: {'color_rgb': (255, 255, 0), 'label': 'cartilagineous roof'},
    5: {'color_rgb': (0, 255, 255), 'label': 'bony roof'},
    6: {'color_rgb': (159, 2, 250), 'label': 'bony rim'},
    7: {'color_rgb': (255, 132, 0), 'label': 'lower limb'},
    8: {'color_rgb': (255, 0, 255), 'label': 'baseline'},
    9: {'color_rgb': (66, 135, 245), 'label': 'lower limb template'},
    10: {'color_rgb': (255, 69, 0), 'label': 'lower limb - alg. v3'}
}

def detect_bump(mask: np.ndarray, skip: int = 15, threshold: int = 5) -> int:
    """
    Wykrywa garb na bony roof. Zwraca 1, jeśli garb wykryto, w przeciwnym wypadku 0.
    """
    label_bony_roof = 5
    binary_mask = (mask == label_bony_roof).astype(np.uint8)

    height, width = binary_mask.shape
    upper_contour = []

    for x in range(width):
        column = binary_mask[:, x]
        if np.any(column):
            y = np.where(column)[0][0] 
            upper_contour.append((x, y))
        else:
            upper_contour.append((x, np.nan))

    print(f"Upper contour (pierwsze 10 punktów): {upper_contour[:10]}")

    # Odfiltrowanie wartości NaN (kolumn bez bony roof)
    valid_contour = np.array([y for x, y in upper_contour if not np.isnan(y)])

    if len(valid_contour) == 0:
        print("Brak pikseli bony roof")
        return 0
    
    min_y = np.min(valid_contour)

    print(f"Najwyższy punkt (min_y): {min_y}")

    distances = valid_contour - min_y
    
    print(f"Odległości od najwyższego punktu (pierwsze 10): {distances[:10]}")

    differences = pd.Series(distances).diff(periods=skip).diff().fillna(0).abs()

    print(f"Pierwsze 3 różnice z różnic: {differences[:3].values}")
    max_diff = differences.max()
    print(f"Max różnica: {max_diff}")

    return 1 if max_diff >= threshold else 0

def process_masks_and_save_with_visualization(mask_dir, bump_dir, no_bump_dir, skip=7, threshold=6):
    """
    Przetwarza maski, wykrywa obecność garbu, zapisuje je do odpowiednich folderów 
    i tworzy ich wizualizacje.
    """
    if not os.path.exists(bump_dir):
        os.makedirs(bump_dir)
    if not os.path.exists(no_bump_dir):
        os.makedirs(no_bump_dir)

    for filename in os.listdir(mask_dir):
        file_path = os.path.join(mask_dir, filename)
        
        if os.path.isfile(file_path) and filename.endswith('.png'):
            mask = Image.open(file_path).convert('L')  # Konwertuj do odcieni szarości
            mask_np = np.array(mask)
            
            # Wykrycie garbu
            bump_present = detect_bump(mask_np, skip, threshold)
            
            # Obliczanie max_diff
            label_bony_roof = 5
            binary_mask = (mask_np == label_bony_roof).astype(np.uint8)
            height, width = binary_mask.shape
            upper_contour = []

            for x in range(width):
                column = binary_mask[:, x]
                if np.any(column):
                    y = np.where(column)[0][0]  # Najwyższy piksel w danej kolumnie
                    upper_contour.append(y)
                else:
                    upper_contour.append(height)

            upper_contour = np.array(upper_contour)
            min_y = np.min(upper_contour)
            distances = min_y - upper_contour
            differences = pd.Series(distances).diff(periods=skip).fillna(0).abs()
            max_diff = differences.max()
            
            # Wizualizacja maski
            visualized_image = np.zeros((height, width, 3), dtype=np.uint8)
            
            for label, color_info in CLASS_COLORS.items():
                color = color_info['color_rgb']
                visualized_image[mask_np == label] = color

            # Zapisanie do odpowiedniego folderu
            if bump_present:
                save_path = os.path.join(bump_dir, filename)
            else:
                save_path = os.path.join(no_bump_dir, filename)

            Image.fromarray(visualized_image).save(save_path)
            print(f'Zapisano zwizualizowaną maskę do: {save_path} - max_diff: {max_diff}')


process_masks_and_save_with_visualization('./Angles/dane/masks', './Angles/dane/garb_obecny','./Angles/dane/garb_nieobecny')
add_filter( 'woocommerce_get_image_size_single', function( $size ) {
	return array(
		'width'  => 500,
		'height' => 500,
		'crop'   => 1,
	);
} );
add_filter( 'woocommerce_get_image_size_thumbnail', function( $size ) {
	return array(
		'width'  => 500,
		'height' => 500,
		'crop'   => 1,
	);
} );
        PM2 is a Production Process Manager for Node.js applications
                     with a built-in Load Balancer.

                Start and Daemonize any application:
                $ pm2 start app.js

                Load Balance 4 instances of api.js:
                $ pm2 start api.js -i 4

                Monitor in production:
                $ pm2 monitor

                Make pm2 auto-boot at server restart:
                $ pm2 startup

                To go further checkout:
                http://pm2.io/
function add_gtm_script() {
    ?>
    <!-- Google Tag Manager -->
    <script>
    (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
    var f=d.getElementsByTagName(s)[0], j=d.createElement(s), dl=l!='dataLayer'?'&l='+l:'';
    j.async=true; j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
    f.parentNode.insertBefore(j,f);
    })(window,document,'script','dataLayer','GTM-WXR2BQ93');
    </script>
    <!-- End Google Tag Manager -->
    <?php
}
add_action('wp_head', 'add_gtm_script');
function add_gtm_noscript() {
    ?>
    <!-- Google Tag Manager (noscript) -->
    <noscript>
        <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WXR2BQ93"
        height="0" width="0" style="display:none;visibility:hidden"></iframe>
    </noscript>
    <!-- End Google Tag Manager (noscript) -->
    <?php
}
add_action('wp_body_open', 'add_gtm_noscript');
<div class="switch">
    <input id="checkbox1" class="look" type="checkbox">
    <label for="checkbox1"></label>
</div>

.switch {
position: relative;
}

.switch label {
width: 55px;
height: 23px;
background-color: #999;
position: absolute;
top: 0;
left: 0;
border-radius: 50px;
}

.switch input[type="checkbox"] {
visibility: hidden;
}

.switch label:after {
content: '';
width: 21px;
height: 21px;
border-radius: 50px;
position: absolute;
top: 1px;
left: 1px;
transition: 100ms;
background-color: white;
}

.switch .look:checked + label:after {
left: 32px;
}

.switch .look:checked + label {
background-color: lightsteelblue;
}
//Disabling Automatic Scrolling On All Gravity Forms
add_filter( 'gform_confirmation_anchor', '__return_false' );
//Aim is to divide the list recursively into smaller sublists
//until each sublist conatins only 1 element or no elements
function merge_sort(xs) {
    if (is_null(xs) || is_null(tail(xs))){
        return xs;
    } else {
        const mid = middle(length(xs)); // to find value of half
        return merge (merge_sort(take(xs,mid)), merge_sort(drop(xs, mid)));
    }
}

//Aim is to combine two sorted sublists into a single sorted sublist
function merge(xs,ys){
    if (is_null(xs)) {
        return ys;
    } else if (is_null(ys)) {
        return xs;
    } else {
        const x = head(xs);
        const y = head(ys);
        return x < y
               ? pair(x, merge(tail(xs), ys))
               : pair(y, merge(xs, tail(ys)));
    }
}

//Half rounded downwards
function middle(n){
    return math_floor(n/2);
}

//Take first n elements of list
function take(xs,n){
    return n===0
           ? null 
           : pair(head(xs), take(tail(xs), n-1));
}
//Drop first n elements of list, return the rest         
function drop(xs, n){
    return n === 0
           ? xs
           : drop(tail(xs), n-1);
}


// Test
merge_sort(list(7, 6, 3, 8, 4, 6, 5, 9, 8, 3, 1, 5, 2));
We've disabled your account
You no longer have access to curtisfrederickkennethbarry
Account disabled on 28 August 2024
elem {
    width: 100%;
    width: -moz-available;          /* WebKit-based browsers will ignore this. */
    width: -webkit-fill-available;  /* Mozilla-based browsers will ignore this. */
    width: fill-available;
}

elem {
    height: 100%;
    height: -moz-available;          /* WebKit-based browsers will ignore this. */
    height: -webkit-fill-available;  /* Mozilla-based browsers will ignore this. */
    height: fill-available;
}
DISM /Online /Cleanup-Image /StartComponentCleanup /ResetBase
#include <iostream>
#include <string>
#include <set>

using namespace std;

int minimumNumber(int n, const string& password) {
    // Define character sets
    const string numbers = "0123456789";
    const string lower_case = "abcdefghijklmnopqrstuvwxyz";
    const string upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    const string special_characters = "!@#$%^&*()-+";

    // Flags to check the presence of required character types
    bool has_digit = false;
    bool has_lower = false;
    bool has_upper = false;
    bool has_special = false;

    // Check for each character in the password
    for (char ch : password) {
        if (numbers.find(ch) != string::npos) has_digit = true;
        else if (lower_case.find(ch) != string::npos) has_lower = true;
        else if (upper_case.find(ch) != string::npos) has_upper = true;
        else if (special_characters.find(ch) != string::npos) has_special = true;
    }

    // Count how many character types are missing
    int missing_types = 0;
    if (!has_digit) missing_types++;
    if (!has_lower) missing_types++;
    if (!has_upper) missing_types++;
    if (!has_special) missing_types++;

    // Calculate the total number of characters needed
    int total_needed = max(6 - n, 0); // Length requirement
    return max(missing_types, total_needed);
}

int main() {
    int n;
    cin >> n; // Length of the password
    string password;
    cin >> password; // The password string

    int result = minimumNumber(n, password);
    cout << result << endl; // Output the minimum number of characters to add

    return 0;
}
#include <iostream>
#include <string>

using namespace std;

int camelcase(const string& s) {
    int wordCount = 1; // Start with 1 to account for the first word
    
    for (char ch : s) {
        if (isupper(ch)) {
            wordCount++; // Increment the count for every uppercase letter
        }
    }

    return wordCount;
}

int main() {
    string s;
    cin >> s; // Input the CamelCase string
    cout << camelcase(s) << endl; // Output the number of words
    return 0;
}
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

string checkPangram(const string& sentence) {
    bool letters[26] = {false}; 

    for (char ch : sentence) {
        if (isalpha(ch)) {
            int index = tolower(ch) - 'a';
            letters[index] = true; // Mark this letter as present
        }
    }

    for (bool present : letters) {
        if (!present) {
            return "not pangram";
        }
    }

    return "pangram";
}

int main() {
    string input;
    getline(cin, input);
    cout << checkPangram(input) << endl;
    return 0;
}
star

Wed Sep 25 2024 02:16:32 GMT+0000 (Coordinated Universal Time) https://biggerboatconsulting.com/supporting-report-filter-url-hacks-in-lightning-and-classic/

@WayneChung

star

Tue Sep 24 2024 23:29:23 GMT+0000 (Coordinated Universal Time)

@FOHWellington

star

Tue Sep 24 2024 19:56:42 GMT+0000 (Coordinated Universal Time)

@iamkatmakhafola

star

Tue Sep 24 2024 14:01:16 GMT+0000 (Coordinated Universal Time)

@TitaMC #php

star

Tue Sep 24 2024 13:43:24 GMT+0000 (Coordinated Universal Time)

@TitaMC #php

star

Tue Sep 24 2024 12:33:30 GMT+0000 (Coordinated Universal Time)

@Yohigo #python

star

Tue Sep 24 2024 12:29:32 GMT+0000 (Coordinated Universal Time)

@Taimoor

star

Tue Sep 24 2024 11:46:10 GMT+0000 (Coordinated Universal Time)

@Rishi1808

star

Tue Sep 24 2024 10:36:53 GMT+0000 (Coordinated Universal Time)

@Taimoor

star

Tue Sep 24 2024 09:46:48 GMT+0000 (Coordinated Universal Time) https://app.slack.com/block-kit-builder/TTUJY0L22#%7B%22blocks%22:%5B%7B%22type%22:%22header%22,%22text%22:%7B%22type%22:%22plain_text%22,%22text%22:%22%E2%9C%A8%20:magic_wand::xero-unicorn:%20End%20of%20Year%20Celebration%20%E2%80%93%20A%20Sprinkle%20of%20Magic!%20:xero-unicorn:%20:magic_wand:%E2%9C%A8%22,%22emoji%22:true%7D%7D,%7B%22type%22:%22section%22,%22text%22:%7B%22type%22:%22mrkdwn%22,%22text%22:%22*Hi%20Melbourne!*%20%5CnGet%20ready%20to%20wrap%20up%20the%20year%20with%20a%20sprinkle%20of%20magic%20and%20a%20lot%20of%20fun%20at%20our%20End%20of%20Year%20Event!%20Here%E2%80%99s%20everything%20you%20need%20to%20know:%22%7D%7D,%7B%22type%22:%22divider%22%7D,%7B%22type%22:%22section%22,%22fields%22:%5B%7B%22type%22:%22mrkdwn%22,%22text%22:%22*%F0%9F%93%85%20When:*%5CnThursday%2028th%20November%22%7D,%7B%22type%22:%22mrkdwn%22,%22text%22:%22*%F0%9F%93%8D%20Where:*%5Cn%3Chttps://www.google.com/maps/place/The+Timber+Yard/@-37.8331021,144.918894,17z/data=!3m1!4b1!4m6!3m5!1s0x6ad667735e56fcab:0x966480f06c58c00c!8m2!3d-37.8331021!4d144.9214743!16s/g/11gyy7sy4c?entry=ttu&g_ep=EgoyMDI0MDkxOC4xIKXMDSoASAFQAw==/%7C*The%20Timber%20Yard*%3E%20%5Cn351%20Plummer%20Street,%20Port%20Melbourne%22%7D,%7B%22type%22:%22mrkdwn%22,%22text%22:%22*%E2%8F%B0%20Time:*%5Cn4%20PM%20-%2010%20PM%22%7D%5D%7D,%7B%22type%22:%22section%22,%22text%22:%7B%22type%22:%22mrkdwn%22,%22text%22:%22*:magic_wand::xero-unicorn:%20Theme:*%5Cn_A%20Sprinkle%20of%20Magic_%20%E2%80%93%20Our%20theme%20is%20inspired%20by%20the%20Xero%20Unicorn,%20embracing%20creativity,%20inclusivity,%20and%20diversity.%20Expect%20unique%20decor,%20magical%20moments,%20and%20a%20fun-filled%20atmosphere!%22%7D%7D,%7B%22type%22:%22section%22,%22text%22:%7B%22type%22:%22mrkdwn%22,%22text%22:%22*:dress:%20Dress%20Code:*%5CnSmart%20casual%20%E2%80%93%20Show%20your%20personality,%20but%20no%20Xero%20tees%20or%20lanyards,%20please!%5CnIf%20you're%20feeling%20inspired%20by%20the%20theme,%20why%20not%20add%20a%20little%20'Sprinkle%20of%20Magic'%20to%20your%20outfit?%20Think%20glitter,%20sparkles,%20or%20anything%20that%20shows%20off%20your%20creative%20side!%20(Totally%20optional,%20of%20course!%20%E2%9C%A8)%22%7D%7D,%7B%22type%22:%22section%22,%22text%22:%7B%22type%22:%22mrkdwn%22,%22text%22:%22*%F0%9F%9A%8D%20Transport%20Info:*%5Cn*Public%20Transport:*%20Via%20bus%20routes%20234%20&%20235%20-%205%20min%20walk%20from%20bus%20stop%5Cn*Parking:*%20200+%20unmetered%20and%20untimed%20spaces%20on%20Plummer%20&%20Smith%20Street%5Cn*Xero%20Chartered%20Bus:*%203:15%20PM%20departure%20from%20the%20Melbourne%20office%20-%20opt%20in%20via%20your%20email%20invite.%22%7D%7D,%7B%22type%22:%22section%22,%22text%22:%7B%22type%22:%22mrkdwn%22,%22text%22:%22*%F0%9F%8E%A4%20:hamburger:%20Entertainment%20&%20Food:*%5CnPrepare%20to%20be%20dazzled%20by%20live%20music,%20enchanting%20magic%20shows,%20cozy%20chill-out%20zones,%20delicious%20bites,%20refreshing%20drinks,%20and%20plenty%20of%20surprises!%20%E2%9C%A8%F0%9F%8E%B6%22%7D%7D,%7B%22type%22:%22section%22,%22text%22:%7B%22type%22:%22mrkdwn%22,%22text%22:%22*%F0%9F%8E%9F%20RSVP%20Now:*%5CnCheck%20your%20emails%20-%20Invite%20sent%20to%20you%20via%20Jamablue%20or%20Eventbrite!%5CnMake%20sure%20you%20RSVP%20by%20%5Binsert%20RSVP%20deadline%5D!%22%7D%7D,%7B%22type%22:%22divider%22%7D,%7B%22type%22:%22section%22,%22text%22:%7B%22type%22:%22mrkdwn%22,%22text%22:%22:question::question:Got%20questions?%20See%20the%20%3Chttps://docs.google.com/document/d/1iygJFHgLBRSdAffNsg3PudZCA45w6Wit7xsFxNc_wKM/edit%7CFAQs%3E%20doc%20or%20post%20in%20the%20Slack%20channel.%5CnWe%20can%E2%80%99t%20wait%20to%20celebrate%20with%20you!%20:partying_face:%20:xero-love:%22%7D%7D%5D%7D

@FOHWellington

star

Tue Sep 24 2024 07:03:38 GMT+0000 (Coordinated Universal Time) https://www.microsoft.com/en-us/dynamics-365/blog/it-professional/2017/07/06/customizing-the-warehousing-mobile-app/?source=dynamicsaxscm

@Manjunath

star

Tue Sep 24 2024 06:05:39 GMT+0000 (Coordinated Universal Time) https://thekidcompany.in/

@tillurare

star

Tue Sep 24 2024 06:05:19 GMT+0000 (Coordinated Universal Time) https://thekidcompany.in/

@tillurare

star

Tue Sep 24 2024 03:50:56 GMT+0000 (Coordinated Universal Time)

@quanganh141220

star

Tue Sep 24 2024 01:49:35 GMT+0000 (Coordinated Universal Time)

@WXAPAC

star

Mon Sep 23 2024 14:56:49 GMT+0000 (Coordinated Universal Time) https://www.w3schools.com/tags/tag_button.asp

@antguy #html

star

Mon Sep 23 2024 14:11:30 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/5b145a

@GeraldStar

star

Mon Sep 23 2024 14:08:52 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/145a5b

@GeraldStar

star

Mon Sep 23 2024 13:01:18 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/145a5b

@GeraldStar

star

Mon Sep 23 2024 13:01:11 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/145a5b

@GeraldStar

star

Mon Sep 23 2024 13:01:05 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/145a5b

@GeraldStar

star

Mon Sep 23 2024 13:00:47 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/145a5b

@GeraldStar

star

Mon Sep 23 2024 13:00:25 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/145a5b

@GeraldStar

star

Mon Sep 23 2024 12:02:06 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/145a5b

@GeraldStar

star

Mon Sep 23 2024 12:01:58 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/145a5b

@GeraldStar

star

Mon Sep 23 2024 12:01:27 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/0f3746

@GeraldStar

star

Mon Sep 23 2024 12:01:04 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/2e460f

@GeraldStar

star

Mon Sep 23 2024 12:00:52 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/29460f

@GeraldStar

star

Mon Sep 23 2024 12:00:31 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/460f37

@GeraldStar

star

Mon Sep 23 2024 12:00:14 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/0f3746

@GeraldStar

star

Mon Sep 23 2024 12:00:00 GMT+0000 (Coordinated Universal Time) https://www.colorhexa.com/0f3746

@GeraldStar

star

Mon Sep 23 2024 11:53:12 GMT+0000 (Coordinated Universal Time)

@usman13

star

Mon Sep 23 2024 08:27:20 GMT+0000 (Coordinated Universal Time) https://mikeyarce.com/2018/04/how-to-override-woocommerce-image-sizes/

@bounty31 #woocommerce #wordpress

star

Mon Sep 23 2024 08:27:05 GMT+0000 (Coordinated Universal Time)

@mateusz021202

star

Mon Sep 23 2024 08:26:58 GMT+0000 (Coordinated Universal Time) https://mikeyarce.com/2018/04/how-to-override-woocommerce-image-sizes/

@bounty31 #woocommerce #wordpress

star

Mon Sep 23 2024 08:26:38 GMT+0000 (Coordinated Universal Time) https://mikeyarce.com/2018/04/how-to-override-woocommerce-image-sizes/

@bounty31 #woocommerce #wordpress

star

Mon Sep 23 2024 08:21:40 GMT+0000 (Coordinated Universal Time)

@StephenThevar #nodejs

star

Mon Sep 23 2024 07:33:06 GMT+0000 (Coordinated Universal Time)

@shees

star

Mon Sep 23 2024 07:23:26 GMT+0000 (Coordinated Universal Time) https://codepen.io/MrAaronCasanova/pen/XEaMmN

@froiden ##css #html

star

Mon Sep 23 2024 04:22:31 GMT+0000 (Coordinated Universal Time)

@omnixima #php

star

Mon Sep 23 2024 04:05:05 GMT+0000 (Coordinated Universal Time)

@hkrishn4a

star

Mon Sep 23 2024 01:03:54 GMT+0000 (Coordinated Universal Time) https://www.instagram.com/accounts/disabled/?next

@curtisbarry

star

Sun Sep 22 2024 21:36:34 GMT+0000 (Coordinated Universal Time)

@marcopinero #css

star

Sun Sep 22 2024 11:50:13 GMT+0000 (Coordinated Universal Time) https://github.com/valleyofdoom/PC-Tuning

@Curable1600 #windows

star

Sun Sep 22 2024 09:55:52 GMT+0000 (Coordinated Universal Time)

@CodeXboss

star

Sun Sep 22 2024 09:50:21 GMT+0000 (Coordinated Universal Time)

@CodeXboss

star

Sun Sep 22 2024 09:48:19 GMT+0000 (Coordinated Universal Time)

@CodeXboss

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension