instruction
stringlengths
71
95.1k
Little history to give context to the problem: The Krusty-Burgers Homer Simpson is a smart guy who likes to eat Krusty-Burgers, and it takes m minutes for Homer to eat a Krusty-Burger. However, there is a new type of burger on the market, the Apu-Burger. Homer likes them too, and takes n minutes to eat one. Given just ...
I'm trying to create a binary search tree that would be used to insert my Packet objects'. It holds information like partId, description, price, and partCount. It's a basic binary search tree. Could you take a look and tell me if there's nothing odd in the code? Because I'm trying to brush up on my BST. Please give me ...
Concrete Context: I parse the header information from curl execution/request and get the array named $headerARR. At this point it looks like the next example, but it can vary and the content-type can be on any index (not have a certain order). I need to work around this, because it is the format accepted by the softwar...
The code shown below takes the partial derivative of each pixel of the output fused image of a neural network with respect to input image of the neural network using tensorflow's tf.gradients(Y, X) and compute a Jacobian matrix for each of the two input images MRI and PET. However, the code is really slow since I curre...
Can someone please help me modify this script to generate and modify the document faster? It currently takes about 5-10 seconds to create the variables. About 10 seconds for the entire script to run. Here is the code for the script: Copy Word Template to Local C Drive: Copy-Item \\172.16.0.75\allaccess\Scripts\transfer...
I wrote this program to make a simple in-memory database using SQLite and JDBC. Requirements I was trying to accomplish are below. It should consume a CSV file, parse the data, and insert it into the in-memory database. Table name is X and it has 10 columns (named A - J). If any of the columns in a row of the CSV file...
Here is a set of classes that are used to build where clause for SQL Server and Oracle for different field types e.g. text, numeric and date. public interface IConditionBuilder { bool CanHandle(FilterAction filterAction); string BuildCondition(SearchCondition filterCondition); } public abstract class Conditio...
With the following interface in mind EasyRandom<unsigned int> prng(a, b); auto x = prng(); // scalar auto v = prng(10); // vector I wrote the following class: // https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution template <typename T = unsigned int> class EasyRandom { private: std::random_de...
Here is the working code for my Spring service: @Service public class UploadService { @Inject @Qualifier("session") Session session; @Inject AsyncImageConvertService asyncImageConvertService; @Value("${aws.bucket-name}") String awsBucketName; @Inject AmazonS3 amazonS3; @Inje...
I'm in the midst of re-learning python. My current effort is an implementation around prime factorization. I am attempting to reproduce something similar to the table found here (in binary): https://math.stackexchange.com/questions/586010/relative-size-of-most-factors-of-semiprimes-close Performance seems to be rather...
I'm trying to organize my gallery, and I have certain folders rife with copies. My daily work is mostly javascript and php, being your generic web developer. However I took this as an opportunity to bodge something in python, a language I normally do not use, but have always wanted to pick up at least a little bit. You...
Here's my updated version of the problem I posted at Calculating time windows for entities, adding in suggested changes as well as a change I did so that the Reflection is 'cached' in a ConcurrentDictionary and happens only once per Type. using System; using System.Collections.Concurrent; using System.Collections.Gener...
I want to create a dynamic query to display: all the invoices if the user has moderator rank only his invoices if the user is a simple member code public function getAllBill($user_rank, $user_id){ $sql = 'SELECT * FROM invoice_user INNER JOIN users on users.user_id = invoice_user.user_id'; $sql_clause = 'W...
My goal is to write a smaller compiler-like program, which allows me to draw geometric shapes into a 3D Diagram. There is no need for turing-completeness and the program should only be viewed as an exercise and not as a program used by anybody. However, I want the program to have a compiler-like nature. At the moment t...
I created this simple macro that works fine for its purpose: allow the user to create a list of updates that need to be made based on groups in a target table (to basically do mass updates). However, I am very concerned about the performance of this macro, it would take less time to do it manually if the list of updat...
I was trying to write Sieve for the first time and I came up with this code: def sieve(num): numbers = set(range(3, num, 2)) for i in range(3, int(num**(1/2)) + 1 , 2): num_set = set(i*c for c in range(3, num//2, 2)) numbers = numbers - num_set return list(sorted((2, *numbers))) The problem...
I am writing a class for delayed operations on variables which are resolved at a later time. I am using pythons operator overloading but my class definition seems very boilerplatey. Is there a more succinct way to define the following class? from functools import partialmethod import operator class Forward: def ...
I'm just finished my version of iterable hashtable. I want to review code in general (code style, data structures, remarks about the algorithms) and I have some questions: I don't know how to implement errors in return-value way. So, I chose way when we contain error flag variable in struct. Is it correct? What funct...
I have set of points on the coordinate plane. I need to find the 4 points which form a square with the biggest area. I'm new in JavaScript so I'd like to get any suggestions about code style, patterns, code idioms, etc. Thank you in advance! "use strict"; /* * Point */ (function() { function numbersEqual(a, b) ...
I'm writing code for embedded systems (IAR compiler) and it should adhere to Misra C++ 2008. This limits the available features of the language quite a bit: no C++1x features use of the standard library is banned as well no dynamic memory (no heap) We use PC-Lint to check for adherence. Rule 5-0-15 of Misra states: ...
I implemented a prime number finder using the Miller-Rabin prime test in Haskell and it seems to be working. You enter a number and it finds the next prime following that number. I also tried to make it parallel and I'm looking for some advice for how I can speed up the parallel version. Right now it runs much slower t...
I wrote a quick sodoku solver as an exercise and am curious how to make it faster. Parsing and printing is largely irrelevant only there for readability. How can I make the code cleaner and faster? #include <array> #include <tuple> #include <bitset> #include <cassert> #include <optional> #include <iostream> constexpr ...
This function converts a Javascript Object into a CSV. var dataFromAPI = [{"name":"first"},{"name":"sec,ond"},{"name":"third 'jibberish"},{"name":"fourth, jibberish"}] function convertToCSVandDownload(objArray) { var csvOutput = ""; Object.keys(objArray).forEach(function(key) { if (csvOutput.length == ...
In the following code we use the function Incrementer (capitalized for clarity, despite that it's to be used without new), to instantiate a number. Incrementer provides a method increment to augment a counter in a span. We have two such counters, and so we define Incrementer to avoid code duplication (although it would...
Objective: I'm trying to create a BST in order to insert Packet objects for search purposes. Packet holds information like partId, description, price, and partCount. This is a follow up question of this post. I have since revised it so that: No or minimal memory leaks Includes minimized Namespace usage is minimized or...
`Boggle is a word game in which letters are randomly placed in a 4x4 grid e.g: A D Q P N L E M O S R T V K J H Words can be started from any letter and are formed by finding a sequence of connecting letters. Letters may connect diagonally, vertically or horizontally. Example words on the above board are "son", lad" a...
Is the code below an efficient way to get the zip file from the server? The code works fine but I'm wondering if I should throw some exceptions for the following conditions: if(param1 == null || param2 == null) } else if ("".equals(param1) || "".equals(param2)) { The way I call this servlet from a web browser is as f...
This question is a follow up to my previous one which can be found here. The user dfhwze suggested me to look into compiler construction and recommended me to write a lexer and a parser that would process the input step by step. I am very grateful that he pointed me into this direction, because I have the feeling every...
In a game of Connect4: we start with an empty grid two players place pieces X and O on the grid the first player to achieve 4 pieces in a line wins! this is a text based console game Here is the code I wrote to print each cell in the grid: def asText(grid: Grid) = { def asText(x:Int, y:Int) = { val is...
The task is taken from LeetCode In a row of trees, the i-th tree produces fruit with type tree[i]. You start at any tree of your choice, then repeatedly perform the following steps: Add one piece of fruit from this tree to your baskets.  If you cannot, stop. Move to the next tree to the right of the current tree...
I'm seeking a critique of the simple program below, which displays two counters and increments them through a button, using D3.js. In real life of course no one has a need for displaying buttons that increment counters. It's a stand-in to talk about how to craft the code over the scaffold of a trivial problem. I would ...
I don't know why in most of the interviews, interviewers are asking this question commonly. The question is: There are n number of persons standing in a circle. The first person has a gun and he kills the very next person who is alive and hands over the gun to the next person. Who will remain? Here is my code for the ...
I was recently given a task to implement a data-checker script which given an input file containing (date, last_price) values should check for 3 different kind of errors - missing values, stale values and outliers and returns list of errors. I wrote the code below and the feedback I got was that it was not "pythonic" ...
I am building a Python client for an alert process engine. The users can use this client to publish and clear the alerts. The client exposes two methods publish and clear to the users. These methods accept some parameters which would define the alerts from the users and enriches them with a few more fields and valida...
I have a couple of projects: GameAI ConnectFour GameAI implements a couple of algorithms: Minimax, Alpha-beta pruning and Alpha-beta pruning with state ordering. The actual game tree search algorithms seems to be in order, yet when I play against the bot connected to such an algorithm, it acts rather dumb. My best gu...
The task is taken from LeetCode (subscription required) - From any string, we can form a subsequence of that string by deleting some number of characters (possibly no deletions). Given two strings source and target, return the minimum number of subsequences of source such that their concatenation equals target. If the...
I am working on a Monte Carlo simulation using OpenMP multithreading. To avoid race conditions when multiple threads work on the same resolution element, I have implemented the following module to atomically (using OMP atomic, since AFAIK there's no easy way to do atomic operations directly in Fortran) acquire and rele...
Here is an update to my previous boggle solver. The new version has an almost instantaneous output, removing the need to limit the length of words being searched for. Any comments on my general coding implementation or layout would be appreciated. """Boggle game solver""" class Trie: """Trie class to speed up p...
I'm working with SQL Server 2008 and wanted to make table builder, similar to Laravel's migration classes. I would like to be able to expand this down the road but the main purpose of this code will be to initialize the database. It will likely only be run a few times in production, but likely more for development wo...
There is a problem which discusses in how many ways can the words in a sentence be permuted . I wrote a code as follows which works for the sentences (I think so) . It would be helpful if anyone can assure me if it's actually correct or not . Besides , any suggestion regarding the shortening of code or easing the logic...
I wanted something equivalent to this Java program: TreeMap<Integer,Integer> map = new TreeMap<Integer,Integer>(); map.put(10, 100); map.put(20, 200); map.put(30, 300); map.put(40, 400); map.put(50, 500); map.put(60, 600); map.put(70, 700); map.put(80, 800); System.out.println(map...
This is the task I am working on: In this assignment you will implement the K-Nearest Neighbour and Naïve Bayes algorithms and evaluate them on a real dataset using the stratified cross validation method. You will also evaluate the performance of other classifiers on the same dataset using Weka. Finally, you will inve...
Can you please review my code and suggest why it may or may not be a professional looking code? I am just starting out as a programmer I am able to write code but I don't really know where I am right and where I am wrong. Also, I have heard that using the MVC approach in code is a smart way. Please suggest what changes...
I've created a simple little class called JSONSelector to be able to select relevant data from a JSON object (a dict in Python). Here's what I have so far - it's based off of a few SQL statements, NumPy methods, and JavaScript iterating methods: class JSONSelector: def __init__(self, json): self.json = json...
So, I'm new to socket programming. I wanted to get started learning, and start making stuff, but was really surprised to find out there was no standard C++ network library yet. I'd have to look for a third party library, or make my own. A third party library search turned up some solutions. Boost::Asio seemed to be the...
I am new to Python and I have not yet done any OOP. I wrote this text adventure as a first project and I would like to know if there is a better and more efficient way to write my code within its current paradigm. Any suggestions or critique are more than welcome. The code is quite long. I don't expect anyone to read a...
I'm implementing a STL-like vector with the essential functionalities. I would like to know what is good in this code and what is bad. In terms of everything (memory usage, functions implementations, naming conventions, etc,...). The header: #ifndef BVECTOR_H #define BVECTOR_H #include <memory> static const int MIN_...
This is a working program to check an item's price against available credit. I'm trying to simplify this program to the bare minimum. It would require to run so I'll be better able to understand each part of the 'if' and 'else' processes. Is there a simpler way to write a program that accomplishes the task below? I'm n...
Prompted by discussion about SQL injection, I wanted to put a proof of concept forward to get feedback about whether this is in fact safe and protected against SQL injection or other malicious use. For good reference on the subject of constructing a dynamic search with dynamic SQL, I'd probably look there. This is mean...
I am a beginner in python. I found this problem in the book Automate the Boring Stuff with Python. How can I improve this program using latest version of python. def generateCollatzSequence(number): print(str(number) + " ") while number != 1: if number % 2 == 0: number = number / 2 ...
Working with currencies I am aware it is not good to work with floating point values due to rounding and maintaining precision. Better is to work with integers. Would the following Currency class make sense, where an amount is defined as an instance of Currency and converted to cents. class Currency(): def __init_...
For some machine learning purpose, I need to work with sequences with different lengths. To be able to process efficiently those sequences, I need to process them in batches of size size_batch. A batch typically has 4 dimensions and I want to convert it to a numpy's ndarray with 4 dimensions. For each sequence, I need ...
Below a function which answers: is there a winner in tic-tac-toe game? Also, there is a test suite I wrote for it. def is_win(field): # check horizontal N = len(field) for i in range(N): if field[i][0] != 0 and len(set(field[i])) == 1: return True vertical = [field[j][i] for j in...
I am learning python and am working through some try and except codes. What is wrong here? The code aims to convert the input in to an integer unless it is not numeric. try: def get_integer(my_var): try: x = round(my_var, 0) return x except: y = int(my_var) ...
I have a website where my users can create "table-like" layout dynamically. So imagine that my users can upload a text document, and then append columns to the document, and the output will then be parsed into a table-like layout. For example: My text document Date: 20-06-2019 Created by: OJ...
Web-app summary: I'm a complete beginner in web development and I made a sample web application that can trigger sirens on security cameras located in remote locations. Here's the functionality seen by the user: Go to website and brought to a landing page with a search bar. Type in the name of a location. Be shown all...
I've done this activity selection piece of code, which is a greedy approach. I need some feedback/suggestions. # Python 3 import random import operator begin = [random.randint(1, 10) for i in range(10)] end = [x + random.randint(1, 4) for x in begin] pair = sorted(list(zip(begin, end)), key=operator.itemgetter(1)) ls ...
I've created a script in python to make proxied requests by picking working proxies from a list of proxies scraped from a free proxy site. The bot traverses few links to parse the urls of the different posts from a website. The script however uses a new working proxy every time it makes a new requests as there are mult...
I set up an error handler class to handle all server errors, I know there are already quite a few out there, but I like creating my own for better learning and understanding of how things work. I am currently using this in a framework I am working on (again, for learning purposes), and its working as it should. With th...
Here's my code for the Egyptian fraction written in Python. I need your feedback if there is any room for improvement. def eg_fr(n, d): ls = [] ls_str = [] fraction = n / d total = 0 for i in range(1, 1000): ls.append((1/i, str(1) + '/' + str(i))) for i in ls: while i[0] + total ...
I have written a little script that does a pretty good job of obfuscating android/meterpreter payloads. It will generate payloads or used supplied msf payloads while also injecting a custom icon. The Original payload generated by metasploits msfvenom triggers 28 0f 60 anti-viruses on virustotal.com. After running my sc...
I have a Rock Paper Scissors project in C# and I was wondering if I could get some feedback on how to improve my code. I ask the user how many rounds the user wants to play. The maximum number of rounds allowed is 10, anything else besides a number 1-10, will exit the program. I would also like to know if I could use a...
For those who are unfamiliar with the game: https://en.wikipedia.org/wiki/Mastermind_(board_game) A link to the workbook: https://github.com/Evanml2030/Excel-Mastermind Had trouble getting the form and scroll bar to adjust based on the resolution of the monitor that it is inside. It does not work on screens running wi...
I have created a function which is used to create a list of named tuples. The tuple which is created is dependent on the format of 'instructions' in which there are 3 different formats. Instructions is just a list of lists. I wanted to improve the readability/maintainability of this function and had 3 ideas in mind but...
This is a question I was asked in an interview, below is a cleaned-up copy of the answer I gave. Apparently this answer was not satisfactory. How can it be improved? Question: Given a dictionary of words (a text file with 100000+ entries) and a list of n letters with possible repeats (i.e. a Scrabble tray), return the ...
I'm an intern and have an ETL project I'm doing in python. Part of it is to make sure after I move files I delete empty directories. I wrote this code to clean up directories that are empty and in testing it works for me but I want to make sure it won't end up deleting folders full of files. def folderCleanup(p_rootPa...
Below is the code of a command line tool built with Python that will download email via IMAP. Omitted from the code below are 2 important functions parse_line and server_login. parse_line takes a string containing data and returns the email and password from that string as a dictionary. server_login tries to log in to...
I'm a complete beginner, but I'd like to learn how to program. I really started 2 weeks ago. So I tried the common exercise, aka the multiplication table, but I tried to add little things I learnt recently in order to challenge myself, like functions, tables and pointers even if it's useless here. The code works well, ...
I am fairly new to coding and decided to test my skills and make a program from scratch on my own. I chose to make a Hangman game, it's pretty straight forward. The code reads a file consisting of ~40,000+ words to choose from when generating a word for the user. The user inputs the number of attempts and the minimum l...
I was reading into the proper way to consume an iterator on this question as well as here and I notices there is no actual proper function for this that clearly explains itself. Using: collections.deque(maxlen=0).extend(iterable) isn't exactly very descriptive whereas making a properly named method for this that just ...
I'm trying to create an efficient function for re-sampling time-series data. Assumption: Both sets of time-series data have the same start and end time. (I do this in a separate step.) Resample function (inefficient) import numpy as np def resample(desired_time_sequence, data_sequence): downsampling_indices = np.l...
A few days ago I started writing my own compiler-like program which has the goal to compile plain text into executable python code. After I let my first version review here, I made huge changes to the overall code and added the possibility of adding rectangles. I try to add all the suggested improvements as best as I c...
I build a cart for an ecommerce website, and I want to know if I did well. I want to record the changes in the DB and display the information from the DB to the customer. To be sure that what he sees is the good information. I use an ajax request and JSON to do so. Please give me your comments. I especially want to kno...
I have this function and looks ugly because there are a lot of "catch" doing the same. Any idea how to make it better? saveUser: function(){ let user_id = this.$route.params.user_id; let payload = this.user; updateUser(user_id, payload).then(response => { updateOrCreateAddresses(payload).then(respo...
I'm not sure how to title this post as I'm a bit confuse here. My code updates a field in line. It's done in two separate functions. It works well but I wonder if it's possible to handle it in only one function? Here is the HTML code. The form is shown on hover only and value is updated on change. <form class='editable...
I have created a date component (working GIF at the bottom; please ignore the styling). There isn't a problem with the working of the code but rather the code I wrote seems messy and something hard for any other person to comprehend. This is what I am doing: For the date Component in screen, I am creating refs and st...
Stackblitz - https://stackblitz.com/edit/angular-plp4rb-formarray-total-prs9ay I'm new to RxJS observables. I've created a form array where the total for a line is quantity * rate. Via valueChanges for the line form group I set the total via the calcTotal method. On form changes I emit all the lines up to parent to ca...
Given an array of size n that has the following specifications: Each element in the array contains either a policeman or a thief. Each policeman can catch only one thief. A policeman cannot catch a thief who is more than K units away from the policeman. We need to find the maximum number of thieves that can be caught....
I was refactoring an ugly piece of code, and I'm unsure if there is a better way of doing this, and whether I'm overdoing it with streams. Basically I get a bunch of columns, which should be grouped by the name of the sheet they belong to, so that I can return a map of sheet names to a set of column names. BTW, I can...
I was working on a client for a remote api and realized that I needed to throttle requests at a maximum rate of 4 Hertz (4 requests per second). I wrote a simple typescript class to do it and wanted to solicit code review. It basically should accept a () => Promise<R> and return a Promise<R> that resolves once executed...
This is a story-based adventure program I coded by myself (forgive the length). It took a long time but it was fun. It includes loading times, changes in relationships, relationship levels, storyline and possible outcomes, user input with xbox-style options, function calling and more. Your choices determine the outcome...
I'm trying to measure how many CPU cycles a mutex lock takes. Can you find any problems in my mutex lock benchmark? #include <iostream> #include <thread> #include <mutex> #include <chrono> #include <string> std::mutex twiceMutex; typedef std::int64_t i64; i64 twice(i64 x) { return 2 * x; } i64 twiceM(i64 x) { ...
I am working on a Daily Coding Challenge to print the BST if given an in-ordered and pre-ordered array. Below is my code in JavaScript ES6. Please can you review it. This is my first fully-featured JS program so I am very unaware of standard syntax or shortcuts in JS function Tree(){ this.value = null this.ri...
Below I have setup an extension method that takes any object, cycles through its properties, and prints each out to a Console window in the format Name: Value. Specification / Scope: Handle only single objects (no collections) code public static string PropertiesToString<T>(this T obj, int tabs = 0) where T : class...
I am making a subclass of a well-established python class: pendulum.Period, which overrides both __new__ and __init__ (it does this because it is subclassing the python builtin class timedelta, which uses __new__). In my case, I want my class to handle a wider range of arguments than the superclass. The only way I h...
Investigating how to use tkinter controls with buttons and sliders and to combine these with matplotlib, I have come to the following code. Suggestions for improvements and tips are most welcome. Ultimate goal is to make some apps showing behavior of pendulums, springs and other physical systems where I can interactive...
I wrote a file manager API in C++ to make the read-write operations easier in read/write cases, needing big structured data to/from multiple files. I want to get a review of the library if it's readable and easy to understand, and if it serves its purpose. File.hpp #ifndef FILESAPI_FILE_H #define FILESAPI_FILE_H #incl...
I'm a front end developer who is brand new to backend development. My task is to model json in a Java object. It's just some mock data for now that my controller returns. { "data": { "objectId": 25, "columnName": [ "myCategory", "myCategoryId" ], "columnValues": [ [ ...
In my application I am using two view models. MainViewModel if fiered when MianWindow is initialized. And UpdateViewModel is fiered when UpdateWindow is initialized. The update VM is supposed to use data from collection that is a property of the main VM and has its instance aready, and I need to refer to it somehow. An...
I've solved question 10 on Project Euler using the Sieve of Eratosthenes, what can I do to optimize my code? def prime_sum(n): l=[0 for i in range(n+1)] l[0]=1 l[1]=1 for i in range(2,int(n**0.5)+1): if l[i]==0: for j in range(i * i, n+1, i): l[j]=1 s=0 f...
This post is a continuation of post here: Create mosaic task. I improved code readability, hopefully it'll be reviewable now. Once again, I'm asking for tips to write better code. Task: The point of this task is to create a service, which will generate a mosaic for given images downloaded from provided URLs. mos...
I want to display multiple radio buttons in a layout with multiline style as an item inside a RecyclerView. Look at the code I provided below and suggest how I can refactor the code to be more efficient or optimized: Layout in XML: <RadioButton android:id="@+id/rb_rad1" android:layout_width="wrap_content" a...
I wanted to create a function describing a sport game called "Leader". The idea is that you make as many push-ups as you can, increasing each repetition by 1 and as you reach your maximum, each next repetition is decreased by 1 until you reach 0 push-ups eventually. I managed to do this using dictionaries, but I think ...
The task is taken from LeetCode Given an array A of distinct integers sorted in ascending order, return the smallest index i that satisfies A[i] == i. Return -1 if no such i exists. Example 1: Input: [-10,-5,0,3,7] Output: 3 Explanation: // For the given array, A[0] = -10, A[1] = -5, A[2] = 0, A[3] = 3, thus the...
I want to be able to store and retrieve a unique user throughout the app. Multiple accounts are not used. The code I have written is stated below. This is my first attempt using KeyChain. The test succeeds. I am wondering if anything if the code can be improved. Security issues perhaps? import XCTest class KeyChain { ...
I have the implementation of A* search algorithm that allows to find the shortest path from start to goal. The implementation looks like this public class AStarShortestPathContext { private Vertex[][] matrix; private int rows, columns; private int cost; private PriorityQueue<Vertex> openList; priva...
The following code is my solution for the following Daily Coding Challenge Given an array of numbers, find the maximum sum of any contiguous subarray of the array. For example, given the array [34, -50, 42, 14, -5, 86], the maximum sum would be 137, since we would take elements 42, 14, -5, and 86. Given the array ...
Quite some time ago I have created the Simple object validator (see also self-answer). The more I used it the more I thougt its API could be better so I have heavily refactored it and would like to you take another look at the new version. Requirements I'd like my validator to be: intuitive easy to use extendable test...
I've been working on this concept for the past few days where a variable_t is of any type T; assuming that it is at least arithmetic, and that all of the available C++ language operators that perform arithmetic, comparison, pre&post-increment&decrement, and bitwise operations makes sense. I have expressed my intention...
I have a React component with a copyToClipboard method, which all works fine, but feels extremely verbose and quite hacky (namely, having to create a new select element, hide it, focus/select/copy it and then delete it). From what I've read, there are a couple of different ways to achieve copy-to-clipboard functionalit...