1980. Find Unique Binary String

Given an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums. If there are multiple answers, you may return any of them.
/**
 * @param {string[]} nums
 * @return {string}
 */
var findDifferentBinaryString = function(nums) {
    const n = nums.length;
    const numsSet = new Set(nums);

    // Generate all possible binary strings of length n
    for (let i = 0; i < 2 ** n; i++) {
        // Convert the number i to a binary string of length n
        const binaryString = i.toString(2).padStart(n, '0');
        // Check if the generated binary string is not in numsSet
        if (!numsSet.has(binaryString)) {
       

Array map for WP_Post objects

Carino modo di sostituire un loop FOREACH con un array_map, ad. es. quando usi wp_Query/get_posts

function map_posts() {

  // wp_query or get_posts()
  $p = get_posts(['post_type' => 'post', 'posts_per_page' => 5]);
  if(!$p) return ["Error", "No more posts found!"];

  // Anzichè un foreach, questo array map ti fa restituire un array di tutti campi che vuoi. Nota solo che la array viene inserito come secondo argomento.
  $posts = array_map(function ($post) {
      return [
          'id' => $post->ID,
          'title' => $post->post_title,
          'image' => get_the_post_thumbnail_url(

Create woocommerce order programatically

Useful for integrating front-end customizations/fetch requests with backend woocommerce capabilities. Watch out for the changed "wc_get_product" function.
function create_vip_order() {

  global $woocommerce;

  $address = array(
      'first_name' => '111Joe',
      'last_name'  => 'Conlin',
      'company'    => 'Speed Society',
      'email'      => 'joe@testing.com',
      'phone'      => '760-555-1212',
      'address_1'  => '123 Main st.',
      'address_2'  => '104',
      'city'       => 'San Diego',
      'state'      => 'Ca',
      'postcode'   => '92121',
      'country'    => 'US'
  );

  // Now we create the order
  $order = wc_create

How to check the driver used by a device in linux

# How to check the driver used by a device in linux

## The fast way

Simply:

```
$ sudo lspci -v
```

And check the result for your device:
```
08:00.0 Ethernet controller: Intel Corporation 82571EB/82571GB Gigabit Ethernet Controller (Copper) (rev ff) (prog-if ff)
	...
	Kernel driver in use: e1000e
	Kernel modules: e1000e
```

## The manual way
First, check the devices id in the pci bus by:

```
$ sudo lspci
```

It should show something like:

```
00:00.0 Host bridge: Intel Corporation 8th G

Trigger Complianz cookie banner

/** Show the banner when a html element with class 'cmplz-show-banner' is clicked **/
function cmplz_show_banner_on_click() {
	?>
	<script>
        function addEvent(event, selector, callback, context) {
            document.addEventListener(event, e => {
                if ( e.target.closest(selector) ) {
                    callback(e);
                }
            });
        }
        addEvent('click', '.cmplz-show-banner', function(){
            document.querySelectorAll('.cmp

border-radiusでは作れない位置のコーナーをclip-pathで作る

<div class="corner corner-1"></div>
<div class="corner corner-2"></div>
<div class="corner corner-3"></div>
<div class="corner corner-4"></div>

GIT команды

git rm --cached test.html - убрать отслеживание файла из гита, перед этим добавить в гитигнор
git revert 222222хеш - отменяет последний комит

git commit -am "название комита" - добавить в гиб без add .

clip-pathで楕円をつくる

<div class="box"></div>

Hacker Rank Activity Notifications

function activityNotifications(expenditure, d) {
    let notifications = 0;
    let median = 0;
    let middle = 0;
    const n = expenditure.length;
    
    for (let i = d; i < n; i++) { // Start from `d`, not `d - 1`
        let trailingExpenditures = expenditure.slice(i - d, i); // Correct trailing selection
        let sortedExpenditures = [...trailingExpenditures].sort((a, b) => a - b);
        middle = Math.floor(sortedExpenditures.length / 2);

        if (sortedExpenditures.length % 2 =

Javascript Classes

class Player {
    constructor(name, score) {
        this.name = name;
        this.score = score;
    }
    
    greet(){
      console.log(`Hello, my name is ${this.name} and I am ${this.age} years old.`);
    }
}

class Checker {
    //means we don’t need to create an object
    static compare(a, b) {
        // Sort by score in descending order
        if (a.score !== b.score) {
            return b.score - a.score;
        }
        // If scores are the same, sort by name in ascending orde

Hacker Rank maximum toys

function maximumToys(prices, k) {
    // Sort prices in ascending order to buy cheapest toys first
    prices.sort((a, b) => a - b);
    
    let maxToys = 0;
    let totalCost = 0;
    
    for (let i = 0; i < prices.length; i++) {
        if (totalCost + prices[i] <= k) {
            totalCost += prices[i];
            maxToys++;
        } else {
            break; // Stop if we exceed budget
        }
    }
    
    return maxToys;
}

Hacker Rank Buble Sort

function countSwaps(a) {
    let swaps = 0;
    const n = a.length;
    //[6, 4, 1]
    for (let i = 0; i < n - 1; i++) {  // Outer loop (passes)
        for (let j = 0; j < n - i - 1; j++) {  // Inner loop (comparison)
            if (a[j] > a[j + 1]) {
                [a[j], a[j + 1]] = [a[j + 1], a[j]];  // Swap
                swaps++;
            }
        }
    }
    
    const firstElement = a[0];
    const lastElement = a[(n - 1)];
    console.log(`Array is sorted in ${swaps} swaps.`);
 

How to change the name a Mac app displays in the menu bar

[How to change the name a Mac app displays in the menu bar] [Answer from AskDifferent](https://apple.stackexchange.com/a/385074/225185) I use this to rename "Firefox Developer Edition" to "FF Dev" so my menu bar doesn't overflow!
Renaming the .app package in Finder only changes the name there, it doesn't change the name shown in the menu. To do so edit `YOUR.app/Contents/Resources/XY.lproj/InfoPlist.strings` (with XY being the language you are using) and change `CFBundleName` there.

For applications without localization files you can also edit `YOUR.app/Contents/Info.plist` and set a new value for `CFBundleName` there.

WooCommerce pricing and user roles

WooCommerce pricing and user roles
<?php

// Set different prices in WooCommerce based on user roles using a hook.

function custom_role_based_pricing( $price, $product ) {
    if ( is_user_logged_in() ) {
        $user = wp_get_current_user();
        
        // Example: 10% discount for "wholesale" users
        if ( in_array( 'wholesale', $user->roles ) ) {
            $price = $price * 0.90; // 10% off
        }
        
        // Example: 20% discount for "vip" users
        if ( in_array( 'vip', $user->roles ) ) {
       

1415. The k-th Lexicographical String of All Happy Strings of Length n

A happy string is a string that: consists only of letters of the set ['a', 'b', 'c']. s[i] != s[i + 1] for all values of i from 1 to s.length - 1 (string is 1-indexed). For example, strings "abc", "ac", "b" and "abcbabcbcb" are all happy strings and strings "aa", "baa" and "ababbc" are not happy strings. Given two integers n and k, consider a list of all happy strings of length n sorted in lexicographical order. Return the kth string of this list or return an empty string if there are less than k happy strings of length n.
/**
 * @param {number} n
 * @param {number} k
 * @return {string}
 */
var getHappyString = function(n, k) {
    // Helper function to perform backtracking and generate all happy string
    function backtrack(current, result) {
        // If the current string has reached the desired length, add it to the result list
        if (current.length === n) {
            result.push(current);
            return;
        }
        // Iterate through the characters 'a', 'b', 'c'
        for (let char of [

Scan Event Log for Specific Text

$JobGuid = '896c75c7-7b35-40f2-abb3-faff54ce5ab9'
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().DomainControllers.Name | Sort-Object | ForEach-Object {
    $ServerName = $_
    Write-Host "Running job against $ServerName..."
    
    $ScriptBlock = {
        Invoke-Command -ComputerName $args[0] -ScriptBlock {
            $EventMessageText = 'System.OutOfMemoryException'
            $LastBootUpTime = Get-CimInstance -ClassName Win32_OperatingSystem -ErrorAction St