This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import argparse | |
# Command: `python bulk_removal.py del dbnames.txt legacy-vector` | |
def execute_composer_commands(operation, dblist_file, dblist_name): | |
# Check if the operation is valid | |
if operation not in ("add", "del"): | |
print("Invalid operation. Use 'add' or 'del'.") | |
return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getComputedFontSizes(classNames) { | |
const results = {}; | |
classNames.forEach(className => { | |
// Get all elements with the specified class name. | |
const elementsWithClass = document.getElementsByClassName(className); | |
if (elementsWithClass.length > 0) { | |
// Select the first element with the specified class. | |
const targetElement = elementsWithClass[0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import os | |
import re # Import the re module for regular expressions | |
# Define the directory path containing Less files | |
less_directory = 'YOUR_DIRECTORY_PATH' | |
output_csv_file = 'font_sizes.csv' # Define the output CSV file name | |
# Initialize a list to store font-size values along with filename, line number, class name/ID | |
font_sizes_info = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sample of opening the cart via componentEvents.emitEvent. | |
// NOTE: openerElement needs to be populated with an actual DOM Node | |
// or jQuery object and not just a selector. | |
// In this instance, test is the trigger element with the ID flyout-test. | |
const test = document.getElementById('flyout-test') | |
// Event emitter | |
componentEvents.emitEvent('open-cart-flyout', [{ | |
openerElement: test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Print 1 to 20 (Source: https://stackoverflow.com/questions/3895478/does-javascript-have-a-method-like-range-to-generate-an-array-based-on-suppl) | |
Array.from(new Array(20), (x,i) => i) | |
//Result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var c = 2; c <= 100; c++) { | |
for (var i = c - 1; i >= 1; i--) { | |
if (i === 1) { | |
console.log(c); | |
} | |
if (c % i === 0) { | |
break; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sum = [1, 2, 3].reduce((a, b) => a + b, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Source: https://codereview.stackexchange.com/questions/92966/multiplying-and-adding-big-numbers-represented-with-strings | |
function add(a, b) { | |
if ((a | 0) == 0 && (b | 0) == 0) { | |
return '0'; | |
} | |
a = a.split('').reverse(); | |
b = b.split('').reverse(); | |
var result = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.codewars.com/kata/simple-fraction-to-mixed-number-converter/ | |
var greatest = (a,b) => (b===0) ? a : greatest(b,a%b) | |
function mixedFraction(s){ | |
arr = s.split('/') | |
dividend = Number(arr[0]) | |
divisor = Number(arr[1]) | |
if(divisor === 0){ | |
throw "ZeroDivisionError"; | |
} else { | |
if(dividend%divisor === 0){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gcd(a,b){if(b===0) return a; return gcd(b,a%b)} | |
// ES6 | |
let gcd = (a,b) => (b===0) ? a : gcd(b,a%b) | |
// Original: Java | |
// public int GCD(int a, int b) { | |
// if (b==0) return a; | |
// return GCD(b,a%b); |
NewerOlder