Snippets Collections
      const units = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];

      function niceBytes(x) {
        let l = 0,
          n = parseInt(x, 10) || 0;
        while (n >= 1000 && ++l) {
          n = n / 1000;
        }
        return n.toFixed(n < 10 && l > 0 ? 1 : 0) + " " + units[l];
      }
const formatter = new Intl.NumberFormat("en-IN", {
  style: "currency",
  currency: "INR",
  minimumFractionDigits: 0,
  maximumFractionDigits: 0,
  notation: "compact",
  compactDisplay: "short",
});
$(window).load(function() {
  setTimeout(function()  {
    var submitBtn = $('.wrapper .hs-form .actions > input[type="submit"]');
    submitBtn.parent().html(submitBtn.parent().html().replace(/input/g,"button"));
    $('.wrapper .hs-form .actions > button[type="submit"]').text(submitBtn.attr('value'));
  }, 100);
});
{{ require_js(get_asset_url('../js/stacktable.js')) }} 
// https://s3-us-west-2.amazonaws.com/s.cdpn.io/7635/stacktable.js

{% require_js %}
<script>
  $('table[data-stack]').stacktable({myClass:'stacked stacked--vertical'});
</script>
{% end_require_js %}


@media(min-width: 768px) {
    .stacked--vertical {
        display:none !important
    }
}
@media(max-width: 767px) {
    table[data-stack] {
        display:none !important
    }
}
var dynamicText = function() {
  var windowWidth = window.innerWidth;
  var dynamicTextContainers = document.querySelectorAll('.sqs-dynamic-text');

  for (var el of dynamicTextContainers) {
    var elementWidth = el.offsetWidth;
    var widthRatio = elementWidth / windowWidth * 100; 
    var existingRatio = el.getAttribute('data-width-percentage'); 


    if (elementWidth == windowWidth || existingRatio == widthRatio) {

      continue;
    } 

    el.setAttribute('data-width-percentage', widthRatio);
    el.style.fontSize = widthRatio + '%';

    var dynamicTextEls = document.querySelectorAll('.sqs-dynamic-text');
    for (var el of dynamicTextEls) {

//       el.style.fontSize = widthRatio + '%';

      for ( var p of el.children ){
        if ( parseInt(getComputedStyle(p).fontSize.replace("px", "")) <= 13 ) {
          p.style.fontSize = '13px';
        }
      }
    }



  }
};

dynamicText();
javascript: (function() {
var itemsLength = $('.hs_cos_wrapper_type_rich_text [class]:not(.hs-responsive-embed):not(.hs-responsive-embed-inner-wrapper):not(.hs-responsive-embed-iframe)').length;
itemsLength > 0 ? alert(`Classes in richtext content: ${itemsLength}`) : alert('No classes found in richtext content')
})();
<h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</h3>
<p>Donec commodo ante mauris, vel pretium ex semper at. Morbi dolor enim, faucibus sit amet blandit id, hendrerit et sem. Vivamus elit erat, finibus eleifend eleifend et, bibendum at velit. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque quis rutrum tortor, in malesuada tortor. Sed magna massa, faucibus non massa et, fringilla viverra sem. Integer suscipit, tellus non ultrices aliquam, nunc diam mattis ex, in <a href=“/#” rel=“noopener”>laoreet </a>lectus est in velit. Ut mattis posuere arcu in fringilla. Integer molestie sed purus id varius.</p>
<h2>Nunc ullamcorper in dolor sed pellentesque.</h2>
<p>Aliquam rutrum, sem eget congue congue, augue lectus lacinia massa, vitae <a href=“/#” rel=“noopener”>accumsan </a>augue nulla dapibus est. Etiam porta maximus lectus. Duis in mattis neque. Curabitur at mauris dictum, accumsan sem in, feugiat lacus. Etiam congue nisi leo, nec tincidunt nisi sodales at. Integer ipsum mi, gravida quis enim ac, porta suscipit <span style=“font-weight: bold;“>nunc</span>. Phasellus rutrum tellus eu risus condimentum, at sagittis tortor pharetra.</p>
<h4>Donec eget mauris feugiat, molestie velit non, vulputate nisi.</h4>
<p>Pellentesque quis condimentum nisl, sed placerat ligula. Duis metus sem, euismod nec quam ac, rhoncus facilisis mauris. Phasellus vitae mauris viverra, euismod lorem in, facilisis elit. Mauris consectetur, lectus eu pulvinar aliquet, augue erat maximus ex, et <span style=“font-weight: bold;“>commodo</span> lorem risus id elit. Nullam <span style=“font-weight: bold;“>ullamcorper</span> ut mi lacinia <a href=“/#” rel=“noopener”>malesuada</a>. Aenean rutrum libero sed dictum luctus. In dictum leo vitae rutrum interdum.</p>
<p>Curabitur sagittis, eros eget rhoncus tincidunt, nunc nisi molestie diam, vel venenatis nunc nulla a sapien. Sed lobortis arcu et purus dignissim, ut luctus est ultrices. In sed molestie sem, sed rutrum dolor. Ut posuere aliquam lobortis. Etiam mollis elit tellus, sit amet fermentum eros vehicula <span style=“font-weight: bold;“>eget</span>. Duis et finibus erat. Phasellus convallis rutrum dolor ut varius.</p>
<ul>
<li>Lorem ipsum dolor sit amet, <strong>consectetur</strong> adipiscing elit.</li>
<li>Donec quis augue id ipsum luctus placerat.</li>
<li>Nullam finibus diam nec nulla tincidunt, sed lobortis metus <a href=“/#” rel=“noopener”>bibendum</a>.</li>
<li>Ut a diam nec est bibendum <strong>ultrices</strong> quis venenatis leo.</li>
<li>Curabitur nec augue sit amet dui condimentum pretium a a leo.</li>
</ul>
<p>Suspendisse sollicitudin, lectus non lacinia porttitor, magna tellus vulputate ipsum, sed scelerisque magna nisi a magna. Sed accumsan, libero ut varius blandit, libero diam blandit justo, et dapibus neque est ac elit. Duis fringilla diam vel ligula fermentum tempor. Quisque urna magna, bibendum eu enim nec, fermentum consequat ex. Nam sed orci lobortis, volutpat risus mattis, eleifend purus. Morbi non tempor felis, quis ornare erat. Curabitur aliquet ut tellus vel laoreet. Nam condimentum dictum eros, quis lobortis diam viverra non. Vestibulum eleifend pretium porttitor.</p>
================================
Sample Blog by Hubspot Migrations Team
Sample HubSpot User
SampleHubSpotUser@hubspot.com
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using ‘Content here, content here’, making it look like readable English.
https://facebook.com
https://twitter.com
https://linkedin.com
$(function() {
        $('a[href*="#"]:not([href="#"])').click(function() {
            if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
    
                var target = $(this.hash);
                target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
                if (target.length) {
                    $('html,body').animate({
                        scrollTop: target.offset().top
                    }, 1000);
                    return false;
                }
            }
        });
    });
javascript: (function() {  var cookiesHTML = `<div id="hs-eu-cookie-confirmation" class="" data-nosnippet="">            <div id="hs-eu-cookie-confirmation-inner">              <div id="hs-eu-policy-wording">This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.</div>              <p id="hs-eu-cookie-disclaimer">We won't track your information when you visit our site. But in order to comply with your preferences, we'll have to use just one tiny cookie so that you're not asked to make this choice again.</p>              <div id="hs-en-cookie-confirmation-buttons-area">                                <a href="javascript:void(0);" id="hs-eu-confirmation-button">    Accept  </a>                <a href="javascript:void(0);" id="hs-eu-decline-button">Decline</a>              </div>            </div>          </div>`;          document.body.insertAdjacentHTML('afterbegin', cookiesHTML)          })();
// for IE browser - object fit property
if ('objectFit' in document.documentElement.style === false) {
  $('.rec-post-wrap img.hs-featured-image').each(function(){
    var w = $(this).width();
    var h = $(this).height();
    var s = $(this).attr('src');
    var final = 'data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'' + w + '\' height=\'' + h + '\'%3E%3C/svg%3E';
    $(this).css('background','url('+s+') no-repeat 50% center \/cover');
    $(this).attr('src',final);
  });
}
window.addEventListener('load', function () {
  $(".hs-form .hs-form-field .hs-input").focus(function () {
    $(this).parent().parent().removeClass("blured");
    $(this).parent().parent().addClass("focused");
  }).blur(function () {
    $(this).parent().parent().removeClass("focused");
    $(this).parent().parent().addClass("blured");
  });

  $('.hs-form .hs-form-field .hs-input').on('keyup keydown', function () {
    if ($(this).val() !== "") {
      $(this).parent().parent().removeClass("blank");
      $(this).parent().parent().addClass("filled");
    }
    else {
      $(this).parent().parent().removeClass("focused");
      $(this).parent().parent().addClass("blank");
    }
  });
  $('.hs-form .hs-form-field .hs-input').blur(function () {
    if ($(this).val() == "") {
      $(this).parent().parent().removeClass("filled");
      $(this).parent().parent().addClass("blank");
    }
  });
});
var childMenu = document.querySelectorAll('.custom-menu-primary.visible-phone .hs-menu-wrapper > ul .hs-menu-item.hs-menu-depth-1.hs-item-has-children > a');
  Array.prototype.slice.call(childMenu).forEach(function (ele) {
    ele.insertAdjacentHTML('afterend', '<div class="child-trigger"></div>');
  });
function loadData() {
  var winURL = window.location.href.split('?')[0];
  var queryParams = $("#filterForm").serialize();
  var queryURL = winURL + '?' + queryParams;
  $('#yachts_items').load(queryURL + ' #yachts_items > *', function() {
    $('#yachts_items').attr('query', queryParams);
  });
}
function handle(e) {
  e.preventDefault();
  loadData();
}
$('#filterForm').submit(handle);
$('#filterForm select').change(handle);
var debounce;
$('#filterForm input').on('input', function(e) {
  clearTimeout(debounce);
  debounce = setTimeout(function() { 
    handle(e);
  }, 1000);
});
function goToNav(){
  $('.gallery-nav .sub-nav').click(function(e) {
    e.preventDefault();
    var slideno = $(this).attr('data-id');   
    var getIndex = $(".owl-item .gallery_item[data-group='"+slideno+"']").attr('data-slick-index');
    console.log('slideno',slideno,'getIndex',getIndex);
    setTimeout(function(){
      $('.owl-item').slick('slickGoTo', getIndex);
      console.log('check')
    },300)
  });
}


$(document).ready(function(){
  goToNav()
})

$(document).load(function(){
  goToNav()
})
$('.custom-menu-primary ul li > a > .menu-item-text').each(function () {
  if ($(this).html().indexOf('<br>') != -1) {
    var title = $(this).html().split('<br>')[0];
    var desc = $(this).html().split('<br>')[1];
    if (title == undefined) {
      var titleText = '';
    } else {
      var titleText = '<span class="menu-text">' + title + '</span>';
    }
    if (desc == undefined) {
      var descText = '';
    } else {
      var descText = '<span class="menu-desc">' + desc + '</span>';
    }
    var finalText = titleText + descText;
    $(this).html(finalText);
  }
});
Celo Composer CLI
? Choose front-end framework: React
? Choose web3 library for react app: rainbowkit-celo
? Choose smart-contract framework: Hardhat
? Create a subgraph: No
? Project name:  crowdfunding_celo_dapp
Celo Composer CLI
? Choose front-end framework: React
? Choose web3 library for react app: rainbowkit-celo
? Choose smart-contract framework: Hardhat
? Create a subgraph: (Use arrow keys)
  Yes 
❯ No 
Celo Composer CLI
? Choose front-end framework: React
? Choose web3 library for react app: rainbowkit-celo
? Choose smart-contract framework: (Use arrow keys)
❯ Hardhat 
  Truffle 
  None 


Celo Composer CLI
? Choose front-end framework: React
? Choose web3 library for react app: (Use arrow keys)
  react-celo 
❯ rainbowkit-celo 

Celo Composer CLI
? Choose front-end framework: (Use arrow keys)
❯ React 
  React Native (With Expo) 
  React Native (without Expo) 
  Flutter 
  Angular 

npx @celo/celo-composer create
public static float DamageCalculation(PlayerStats attackerStats, PlayerStats receiverStats)
    {
        // Damage calculation
        float physicalDamage = attackerStats.physicalDamage;
        float magicDamage = attackerStats.magicDamage;
        
        // Resistance Calculation
        float enemyArmor = (receiverStats.armor - attackerStats.armorPenetrationFlat) * (1 - attackerStats.armorPenetrationPercentage);
        enemyArmor = (enemyArmor > 0) ? enemyArmor : 0;
        float physicalDamageReduction = Mathf.Exp(-(enemyArmor / 50));
        
        float enemyMagicResistance = (receiverStats.magicResistance - attackerStats.magicPenetrationFlat) * (1 - attackerStats.magicPenetrationPercentage);
        enemyMagicResistance = (enemyMagicResistance > 0) ? enemyMagicResistance : 0;
        float magicDamageReduction = Mathf.Exp(-(enemyMagicResistance / 50));

        return physicalDamage * physicalDamageReduction + magicDamage * magicDamageReduction;
    }
>>> import shutil, os

>>> os.chdir('C:\\')
>>> shutil.copy('C:\\spam.txt', 'C:\\delicious')
# C:\\delicious\\spam.txt'

>>> shutil.copy('eggs.txt', 'C:\\delicious\\eggs2.txt')
# 'C:\\delicious\\eggs2.txt'
>>> import os
>>> os.makedirs('C:\\delicious\\walnut\\waffles')
>>> import os

>>> os.getcwd()
# 'C:\\Python34'
>>> os.chdir('C:\\Windows\\System32')

>>> os.getcwd()
# 'C:\\Windows\\System32'
>>> my_files = ['accounts.txt', 'details.csv', 'invite.docx']

>>> for filename in my_files:
...     print(os.path.join('C:\\Users\\asweigart', filename))
...
# C:\Users\asweigart\accounts.txt
# C:\Users\asweigart\details.csv
# C:\Users\asweigart\invite.docx
import csv

import json



# Open the JSON file

with open('data.json') as json_file:

    data = json.load(json_file)



# Create a new CSV file and write the data

with open('data.csv', 'w', newline='') as csv_file:

    writer = csv.DictWriter(csv_file, fieldnames=data[0].keys())

    writer.writeheader()

    for row in data:

        writer.writerow(row)
sudo apt-get install wget g++ make expat libexpat1-dev zlib1g-dev
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
set<string> sem;

void solve(string s, int i) {
    if (i == s.size()) {
        sem.insert(s);
        return;
    }
    for (int k = i; k < s.size(); k++) {
        swap(s[i], s[k]);
        solve(s, i + 1);
        swap(s[i], s[k]);
    }
}

int main() {
    string s = "hello";
    solve(s, 0);
    cout << sem.size() << endl;
    for (auto it = sem.begin(); it != sem.end(); it++) {
        cout << *it << endl;
    }
    return 0;
}
function alphabetPosition(text) {
 return /[a-z]/ig.test(text) ? text.toLowerCase().match(/[a-z]/g).map((letter) => letter.charCodeAt(letter) - 96).join(' ') : ""
}
function pigIt(str){
  return str.replace(/(\w)(\w*)(\s|$)/g, "\$2\$1ay\$3")
}
total = 0;
k = 1;
while (k <= 50){
    total += k * k;
    k++;
}
First, you would want to know which process is using port 3000

sudo lsof -i :3000
 Save
this will list all PID listening on this port, once you have the PID you can terminate it with the following:

kill -9 <PID>
star

Sun Sep 24 2023 14:34:29 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript

@StephenThevar #javascript

star

Sun Sep 24 2023 14:07:18 GMT+0000 (Coordinated Universal Time) stack overflow

@StephenThevar #javascript

star

Sun Sep 24 2023 14:02:20 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 14:00:30 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 13:32:05 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 13:11:22 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 13:08:30 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 13:03:53 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 13:02:47 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/c-programming/online-compiler/

@musmanhamed #c

star

Sun Sep 24 2023 13:01:44 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 12:59:33 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 12:34:11 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 12:28:53 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 12:28:04 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 12:19:17 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 12:08:26 GMT+0000 (Coordinated Universal Time)

@sagarmaurya19

star

Sun Sep 24 2023 09:38:44 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/c-programming/online-compiler/

@musmanhamed #c

star

Sun Sep 24 2023 08:42:25 GMT+0000 (Coordinated Universal Time)

@azeezabidoye

star

Sun Sep 24 2023 08:00:20 GMT+0000 (Coordinated Universal Time)

@azeezabidoye

star

Sun Sep 24 2023 07:56:58 GMT+0000 (Coordinated Universal Time)

@azeezabidoye

star

Sun Sep 24 2023 07:52:04 GMT+0000 (Coordinated Universal Time)

@azeezabidoye

star

Sun Sep 24 2023 07:49:42 GMT+0000 (Coordinated Universal Time)

@azeezabidoye

star

Sun Sep 24 2023 07:47:28 GMT+0000 (Coordinated Universal Time)

@azeezabidoye

star

Sun Sep 24 2023 07:45:03 GMT+0000 (Coordinated Universal Time)

@azeezabidoye

star

Sun Sep 24 2023 07:43:45 GMT+0000 (Coordinated Universal Time)

@azeezabidoye

star

Sun Sep 24 2023 07:34:45 GMT+0000 (Coordinated Universal Time)

@azeezabidoye

star

Sun Sep 24 2023 03:38:00 GMT+0000 (Coordinated Universal Time)

@BenjiSt #c#

star

Sun Sep 24 2023 02:10:51 GMT+0000 (Coordinated Universal Time) https://www.pythoncheatsheet.org/cheatsheet/file-directory-path

@OperationsBGSC #python

star

Sun Sep 24 2023 02:10:04 GMT+0000 (Coordinated Universal Time) https://www.pythoncheatsheet.org/cheatsheet/file-directory-path

@OperationsBGSC #python

star

Sun Sep 24 2023 02:09:50 GMT+0000 (Coordinated Universal Time) https://www.pythoncheatsheet.org/cheatsheet/file-directory-path

@OperationsBGSC #python

star

Sun Sep 24 2023 02:09:34 GMT+0000 (Coordinated Universal Time) https://www.pythoncheatsheet.org/cheatsheet/file-directory-path

@OperationsBGSC #python

star

Sun Sep 24 2023 01:29:37 GMT+0000 (Coordinated Universal Time) https://codebeautify.org/blog/convert-json-to-csv-using-python/

@OperationsBGSC #python

star

Sun Sep 24 2023 01:26:56 GMT+0000 (Coordinated Universal Time) http://overpass-api.de/no_frills.html

@brooke.delwolf

star

Sat Sep 23 2023 18:17:04 GMT+0000 (Coordinated Universal Time)

@hs1710

star

Sat Sep 23 2023 15:04:40 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/546f922b54af40e1e90001da/solutions/javascript

@Paloma

star

Sat Sep 23 2023 15:01:45 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/520b9d2ad5c005041100000f/solutions/javascript

@Paloma

star

Sat Sep 23 2023 13:20:48 GMT+0000 (Coordinated Universal Time) undefined

@musmanhamed #c

star

Sat Sep 23 2023 06:43:15 GMT+0000 (Coordinated Universal Time) https://platform.openai.com/docs/guides/legacy-fine-tuning

@neuromancer #openai #fine-tune #docs

star

Fri Sep 22 2023 21:35:58 GMT+0000 (Coordinated Universal Time)

@David_Mix

star

Fri Sep 22 2023 19:48:22 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/4075287/node-express-eaddrinuse-address-already-in-use-kill-server

@MuhammadAhmad

star

Fri Sep 22 2023 19:12:01 GMT+0000 (Coordinated Universal Time) https://getliner.com/en/my-highlights

@marky1234

star

Fri Sep 22 2023 18:39:03 GMT+0000 (Coordinated Universal Time) https://getliner.com/en/my-highlights/55383115?entry-type

@marky1234

Save snippets that work with our extensions

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