Skip to main content

quick sort

0 likes • Nov 19, 2022 • 0 views
JavaScript
Loading...

More JavaScript Posts

Canvas File Downloader

0 likes • Nov 18, 2022 • 4 views
JavaScript
results =
{
"11345240":"Media Comment-80e47004-1719-493a-af69-a43b2652b41c",
"11345282":"zoom_3_22_21.mp4",
"11345303":"Recording-2.m4a",
"11345348":"February 12%2C 2021.mp4",
"11345826":"Lecture_Rousso_Chapter_06-2.pptx",
"11345933":"Themes_InClassAssigment.pptx",
"11346193":"Agenda – Week of March23.pptx",
"11346318":"MUJS 2370 SP2021 Updated Rhythm Changes Drills Bb - Score.pdf",
"11346319":"MUJS 2370 SP2021 Updated Rhythm Changes Drills C - Score.pdf",
"11346322":"MUJS 2370 SP2021 Updated Rhythm Changes Drills Eb - Score.pdf",
"11346323":"MUJS 2370 Updated Rhythm Changes Drills Bass - Score.pdf",
"11346381":"Anthropology with colored highlighter analysis - Mar 22 2021 - 10-36 AM.pdf",
"11346449":"Anthropology with colored highlighter analysis - Mar 22 2021 - 10-36 AM.pdf",
"11346450":"MUJS 2370 SP2021 Updated Rhythm Changes Drills Bb - Score.pdf",
"11346451":"MUJS 2370 SP2021 Updated Rhythm Changes Drills C - Score.pdf",
"11346453":"MUJS 2370 SP2021 Updated Rhythm Changes Drills Eb - Score.pdf",
"11346454":"MUJS 2370 Updated Rhythm Changes Drills Bass - Score.pdf",
"11346495":"Steinel chromatic ornamentation étude rhythm changes - Aug 23 2020 - 12-19 PM.pdf",
"11346532":"Media Comment-136242b4-7f2c-4d5d-8aa4-091f07e797cf",
"11346581":"2019 Trust Based Relationship Intervention Manual.pdf",
"11346584":"TBRI ppt.pptx",
"11346593":"Trauma informed care.ppt"
}
function NewTab(testing) {
window.open(testing, "_blank");
}
for(test in results) {
var testing = 'https://unt.instructure.com/files/' + test + '/download';
NewTab(testing);
//window.open = 'https://unt.instructure.com/files/' + test + '/download';
}

QM Helper

0 likes • Mar 22, 2022 • 1 view
JavaScript
//QM Helper by Leif Messinger
//Groups numbers by number of bits and shows their binary representations.
//To be used on x.com
const minterms = prompt("Enter your minterms separated by commas").split(",").map(x => parseInt(x.trim()));
const maxNumBits = minterms.reduce(function(a, b) {
return Math.max(a, Math.log2(b));
});
const bitGroups = [];
for(let i = 0; i < maxNumBits; ++i){
bitGroups.push([]);
}
for(const minterm of minterms){
let outputString = (minterm+" ");
//Count the bits
let count = 0;
for (var i = maxNumBits; i >= 0; --i) {
if((minterm >> i) & 1){
++count;
outputString += "1";
}else{
outputString += "0";
}
}
bitGroups[count].push(outputString);
}
document.body.textContent = "";
document.body.style.setProperty("white-space", "pre");
for(const group of bitGroups){
for(const outputString of group){
document.body.textContent += outputString + "\r\n";
}
}

getURLParameters

0 likes • Nov 19, 2022 • 0 views
JavaScript
const getURLParameters = url =>
(url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce(
(a, v) => (
(a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a
),
{}
);

Temperature Converter

0 likes • Nov 19, 2022 • 0 views
JavaScript
const celsiusToFahrenheit = (celsius) => celsius * 9/5 + 32;
const fahrenheitToCelsius = (fahrenheit) => (fahrenheit - 32) * 5/9;
// Examples
celsiusToFahrenheit(15); // 59
celsiusToFahrenheit(0); // 32
celsiusToFahrenheit(-20); // -4
fahrenheitToCelsius(59); // 15
fahrenheitToCelsius(32); // 0

stripe api json iteration

0 likes • Nov 18, 2022 • 0 views
JavaScript
var arr = [{
"success": true,
"data": [
{
"id": "ipi_1KrrbvDOiB2klwsKhuqUWqt1",
"object": "issuing.transaction",
"amount": -2743,
"amount_details": {
"atm_fee": null
},
"authorization": "iauth_1KrrbuDOiB2klwsKoFjQZhhd",
"balance_transaction": "txn_1KrrbwDOiB2klwsK1YkjJJRi",
"card": "ic_1Krqe5DOiB2klwsK44a35eiE",
"cardholder": "ich_1KrqL8DOiB2klwsKtBnZhzYr",
"created": 1650753567,
"currency": "usd",
"dispute": null,
"livemode": false,
"merchant_amount": -2743,
"merchant_currency": "usd",
"merchant_data": {
"category": "advertising_services",
"category_code": "7311",
"city": "San Francisco",
"country": "US",
"name": "Aeros Marketing, LLC",
"network_id": "1234567890",
"postal_code": "94103",
"state": "CA"
},
"metadata": {},
"type": "capture",
"wallet": null
},
{
"id": "ipi_1Krrbvc62B2klwsKhuqUWqt1",
"object": "issuing.transaction",
"amount": -9999,
"amount_details": {
"atm_fee": null
},
"authorization": "iauth_1KrrbuDOiB2klwsKoFjQZhhd",
"balance_transaction": "txn_1KrrbwDOiB2klwsK1YkjJJRi",
"card": "ic_1Krqe5DOiB2klwsK44a35eiE",
"cardholder": "ich_1KrqL8DOiB2klwsKtBnZhzYr",
"created": 1650753567,
"currency": "USD",
"dispute": null,
"livemode": false,
"merchant_amount": -9999,
"merchant_currency": "usd",
"merchant_data": {
"category": "fast_food",
"category_code": "7311",
"city": "San Francisco",
"country": "US",
"name": "Aeros Marketing, LLC",
"network_id": "1234567890",
"postal_code": "94103",
"state": "CA"
},
"metadata": {},
"type": "capture",
"wallet": null
}
]
}];
const reduced = arr.reduce((prev, curr) => {
prev.push({
amount: curr.data[0].merchant_amount,
id: curr.data[0].id,
currency: curr.data[0].currency,
category: curr.data[0].merchant_data.category
});
console.log(prev)
return prev;
}, []);

Untitled

CAS
0 likes • Aug 13, 2023 • 2 views
JavaScript
function sortNumbers(arr) {
return arr.slice().sort((a, b) => a - b);
}
const unsortedArray = [4, 1, 9, 6, 3, 5];
const sortedArray = sortNumbers(unsortedArray);
console.log("Unsorted Numbers:", unsortedArray);
console.log("\n");
console.log("Sorted Numbers:", sortedArray);