instruction
stringlengths
71
95.1k
The following source code is a solution to the Marching Square problem. The explanation of using random numbers in ambiguous cases can be found here. using System; using System.Collections.Generic; using System.Drawing; using System.Text; namespace G__Marching_Sqaure { public static class StaticRandomNumber ...
Brief introduction: so the point of the question is that the author doesn't really talk about good or bad code quality and I really wanted some feedback to have a grasp of how the code for others to read should look like. I mean, for the very first solution of the task I would check different parameters manually just t...
I have the following Ruby method. def get_status(creds) client = create_client(creds) status = client.account_status client.close_session status end Usually I optimize this kind of code by using tap or yield_self. I have come up with a way to use these, but it doesn't seem like the nicest way to optimize it. d...
I'm new to react and am building a basic react app and have just built a basic area where navigation links render on a page but wonder whether my current start could be optimised - for example, I wonder whether an area like this: render() { return ( <Root navLinks={this.state.navLinks}></Root> ); } ...
Assessment Question: Print an array of size n*n, with border as 1's and rest of the element as 0's. Sample Input: 5 Sample Output: [[1 1 1 1 1] [1 0 0 0 1] [1 0 0 0 1] [1 0 0 0 1] [1 1 1 1 1]] Here is my solution: import numpy as np n = int(input("Enter a number:")) np_box = np.zeros([n, n], dtype='int') np_box[:,...
I built a quite simple webpage to display a random quote from an array of quotes. I would love to have some feedback on the JS, CSS, and HTML, for example, feedback about best practices, maintainability, readability, accessibility, semantic markup, performance, or anything you can spot that could be improved. This is i...
Amateur c++ programmer here, working my way through the Project Euler problems (problem 4). I would love for someone to take a look at my ~40 lines of code and give suggestions on improving the effectiveness of the code, and how/what to change to better follow the general guidelines for the flow of a c++ program. The t...
For this graph and its vertex cover I try to compare the LP solution with the optimal and the rounded solution. from scipy.optimize import linprog obj = [1, 1, 1, 1, 1, 1, 1, 1] lhs_ineq = [[ -1, -1, 0, 0, 0, 0, 0, 0],[ -1, 0, 0, -1, 0, 0, 0, 0],[ 0, -1, -1, 0, 0, 0, 0, 0],[ 0, -1, 0, 0, -1, 0, 0, 0],[ 0, 0, -1, ...
The function below passes most test cases: function numOfSquares(a, b) { const isSquare = function (n) { return n > 0 && Math.sqrt(n) % 1 === 0; }; let squareCount = 0; for (let i = a; i <= b; i++){ if (isSquare(i)) { squareCount++; } } return squareCount } ...
Background I have a code that basically caches file. The way it works is it will first check if the file exists on the local drive and if it does if there is a flag passed called validate_file_size then it will do another check to see if the size of the file on local drive equals the size of the file on S3. if they equ...
This code is utilized within a platform that has strict limitations on script execution time, occasionally being exceeded if there is a very large number of lines within the CSV input that is passed into this script. The script then outputs JSON by capturing the necessary data from each CSV line, and grouping data bas...
def merge_arrays(list1, list2): len_list1 = len(list1); len_list2 = len(list2) merge_len = len_list1 + len_list2 merge_list = [] l1_ptr = 0 l2_ptr = 0 # import pdb; pdb.set_trace() while(l1_ptr <= len_list1-1 and l2_ptr <= len_list2-1): if (list1[l1_ptr] <= list2[l2_ptr]): merge_list.append(l...
I wrote the following x86 program to make sure I'm following the correct practices in calling a function and then exiting to the OS: .globl _start _start: # Calculate 2*3 + 7*9 = 6 + 63 = 69 # The multiplication will be done with a separate function call # Parameters passed in System V ABI # The firs...
I'm still new to coding and self-taught. If anyone could take a look at my code for my Ruby Hangman game and give any tips or advice whatsoever, it would be greatly appreciated. I'm trying to improve! The game is completely functional right now, and has a save/load feature. Repli link: https://repl.it/@MaBuCode/hangman...
I was told my code contains a lot of force unwrapping. I thought it's okay to do that if I am sure that the value operated won't be nil: private var x: Int? private var y: Int? @IBAction func startButtonPressed(_ sender: UIButton) { guard let numberOfRooms = selectedRooms.text, !numberOfRooms.isEmpty else { ...
I want to wrap NSCache in a Singleton in order to use dependency injection in my code. This has resulted, rather unfortunately, in passing the type through a function parameter, and I even need two mocks for success and failure since it is a singleton instance. I think there might be a better way, but any comments appr...
Category Service: public Boolean deleteCategory(int id) { try { Category category = categoryDao.getCategoryById(id).orElseThrow(NoSuchElementException::new); categoryDao.deleteCategory(id); categoryDao.moveCategoriesUp(category.getUserid(), category.getPosition()); return true; ...
I wrote a script to reorder the columns in a CSV file in descending order and then write to another CSV file. My script needs to be able to handle several tens of millions of records, and I would like it to be as performant as possible. This is basically a mockup of a more complex CSV transformation I would be working ...
I used the Bootstrap v4.0.0 accordion to display my business services. Further, I created a custom post type "service" for my services (Each service is a post). To display my services dynamically and not hardcode them, I implemented a for-loop within the WordPress while-loop which uses an enumeration to provide the num...
Idea After a handfull of small javascript-projects, I also wanted to work a bit with php now. I decided to create a simple contact-form. Of course, I wanted it to be as spam-save as possible, so I used some of the ideas I found online (honeypott and some sort of CAPTCHA). I realized the CAPTCHA-idea in the following wa...
This is web exercise 2.3.20. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a recursive program that takes a command-line argument n and plots an N-by-N Hadamard pattern where N = 2^n. Do not use an array. A 1-by-1 Hadamard pattern is a single black square. In general a 2N-by...
I'm drawing a square on a window using an implementation of Xlib. I put a colored pixel with my_pixel_put at a specific (x,y) coordinate. Code to review #define LWST_VAL 200 #define HGHST_VAL 400 int main() { t_data img; //image data int x = LWST_VAL, y = LWST_VAL; // steps creating a window, creatin...
I want to move two element of my array to the beginning. This solution works but I would like to know a better approach since using sort() twice is probably not the best. Array Input: colors = [{name: yellow}, {name: blue}, {name: green}, {name: red}, {name: orange}] JS Function: sort(){ let green= colors.find(color=>...
Two parties communicate over a network sending back and forth up to 100 messages. Each message sent is a response to the last received message and depends on it. This means that both parties have to wait idly for the response to arrive before they can carry on with computations. Speed is quite critical and deteriorates...
I'm learning how to use SequelizeJS. What i found was that (at least for me) the definition of the DB model was too invasive in my code when creating object. I was thinking that the user of your model should not have to learn how to use sequelize (or even that i use it at all) So I created 2 class that add a layer on t...
Getting started in VB.net I've written this console calculator based heavily off Nicholas Dingle youtube channel (in case it looks familiar). What I want to do is have a separate sub called Operation(parameter) and take the if statements out of CollectNumbers() since it doesn't make sense to have them in that sub. To m...
I'm working on a project (it's a language), and for that project, I decided to go with a low-level C++ style, so that means making my own data types. I recently got done making my own string class implementation. This is actually the first time I've made a string class before, so I may be doing a lot of things wrong. A...
Say the beginning dataframe is this: System Sizes X Y Z 0 1 1 1.0 0 0 1 1 2 2.4 0 0 2 1 3 50.0 50 0 3 3 100 500.0 500 0 4 3 100 501.0 501 0 5 3 100 505.0 506 0 6 3 100 1000.0 1000 0 7 3 ...
I've started programming using Python two months ago. My only prior programming experience was VBA. I'm completely self taught. I wrote the code below for a project I'm creating as a way to learn the language. I was hoping someone experienced with Python could look over my code quickly and let me know which places coul...
I'm trying to implement some domain driven design architecture, such as a repository to talk to the database, and a service that talks to the repository. I have an action where I want to see if a User exists, and if he does, update his data, if he doesn't, create it and then perform a task (this could be done using eve...
This is exercise 2.4.20. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Implement a class that simulates Conway’s Game of Life. One thing to note: I did not want my grid to have passive edges and so in my program I considered the grid to be an opened torus (for example in a 10-by-10 ...
I'm pretty new to algorithms, and it's my first attempt to implement sentinel linear search in JS. I'm wondering if it can be improved. const array1 = ['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', 'cras', 'eu', 'metus', 'volutpat', 'sagittis', 'nunc', 'in', 'porta', 'quam']; let i = 0;...
Trying to come up with a pattern where the code to open db, writing queries is elegant and clean while handling all possible error conditions. Following code let file = try! FileManager.default.url(for: .cachesDirectory, in: .userDomainMask, appropriateFor: nil, create: false).appendingPathComponent("mydb.db") var res...
I've recently reviewed code twice, from two different authors, where the author has cleverly used Thingy z = Optional.ofNullable(x).orElse(y) rather than using, say, Thingy z = x == null ? y : x. My first reaction was that this is not the intended use or semantic of Optional and that a ternary conditional operator, or ...
I'm currently writing on a Router for a MVC framework that will be the core part of my application. The Router is implemented as a Servlet to be registered on any embedded servlet container. In the Router I'm matching the route using the URI given by HttpServletRequest#getPathInfo but later I'm registering the route in...
Here's a constexpr hash function, that will pack a string into the largest unsigned integral type available. So, what do you think? #include <climits> #include <cstdint> #include <utility> #include <iostream> namespace detail { template <typename T, std::size_t ...I> constexpr T hash(char const* const s, std::size...
I'm a chemistry student working on a simple bash script to automate HPC density functional theory calculations using Quantum Espresso (pw.x). I am very much a novice at shell scripting and would appreciate some criticism/feedback before I try to implement it on the cluster. The script calls in-gen.py which is a Python ...
I'm a total noob to OpenGL just following the tutorial at learnopengl.com. Anyway, I'm trying to build a GUI that involves rectangles that have border radiuses. I figured I could do this using the fragment shader. Essentially, I'm masking each corner with a circle that is r units away from each wall for that corner. I ...
I'm really bothered with my approach in this, as I'd like to use the client in multiple projects. The client extends Guzzle and I'm using a factory method to initialize the client with the necessary settings: <?php namespace App\Services\ApiClient; use App\Tenant; use GuzzleHttp\Client as GuzzleClient; use GuzzleHtt...
I have created the following Bash script to somewhat automate the upgrade of any MediaWiki website which contains one extension (ContactPage). I have tested the essential parts of the script several times and also tested the version here line by line from the edit mode and I didn't find any problem with it; my website ...
Update! I got a lot of pointers, suggestions and tips on improving the readability, structure and efficiency of my program yesterday, so I made the suggested improvements to the program and am happy to announce I managed to reduce the execution time of the program to nearly 1/25th! Still, I would love feedback on the i...
I've started learning to program, and as the first program I wrote on my own I wanted to come up with a number guessing game - the below is what I got. I'm mainly looking for a review of my Guess function, but I do have a few specific questions: Does it make sense to have my loop variable as a function parameter? I'm ...
I currently have a utility that will display details about a list of specified users. In its current state I don't use any functions, which I've noticed make it a little more repetitive than I would like. I'm specifically interested in how to make this more functional, but I'd be interested in any suggestions for how t...
I offer same day shipping if the user places an order before 9AM ET. If they place the order after 9AM, same day shipping is unavailable. My server is using UTC time so I need to check if the time is greater than or less than 9AM ET regardless of the time where the user is located. Not being an expert with JS, I cobble...
I have this problem to solve: Given an integer \$z\$ and an array \$a\$ of distinct integers sorted in ascending order, find two numbers, \$x\$ and \$y\$, belonging to the array such that \$x + y = z\$. All this has to be done with \$O(n)\$ time performance in the worst case and \$O(1)\$ space. I tried to jot down a ...
I was wondering whether I could use more data.table functions rather than using for loops in the following piece of code: library(data.table) n1 <- data.table(A = c(1:5), B = c(1:5), C = c(1:5)) n2 <- data.table(D = c(1:5), E = c(1:5), F = c(1:5)) n3 ...
I have an .htaccess template I have been working on that I want to submit for code review. I want to accomplish these things: Custom error handling Remove index.php if in url Force HTTPS Remove www. SEO friendly URLs for a blog Disable directory browsing Protect .htaccess Protect phpinfo.php Here is my code: RewriteE...
In my ongoing quest to automate everything I have to do at my job, I've decided to learn how to do webscraping with VBA. I wanted to start with something easy, so the following simply fills out a time-off request and submits it. My main goals while writing this were to: Make the code readable and very obvious what ev...
On linux there is the utility called unix2dos which converts UNIX EOLs(\n) to DOS EOLs(\r\n). However on windows there is no such tool so as a result I decided to make one. unix2dos.c: #include <windows.h> #include <stdint.h> #include <stddef.h> #define chunksize (1 << 13) #define nullptr ((void *)0) uint8_t buffer[ch...
This is a Windows forms application. this.Server.GetLogMessages() will block if there are no messages to get, so I want this in a separate thread. I'm putting the messages into a ConcurrentStack and then pulling them out on the main thread to output them. Here is the respective code: private async Task UpdateLogs() { ...
What?, Why? I have been inspired by several other posts on the topic of OOP implementations in VBA to try and create a Pacman clone. I think this task is not all that hard in most languages; but, I first learned how to code via VBA and I, perhaps, have a masochistic fondness for the framework. VBA comes with a host of ...
As per tutorial here, I have the following classes: (In reference to this tutorial's section) namespace Supermarket.API.Domain.Services { public interface ICategoryService { Task<IEnumerable<Category>> ListAsync(); } } IProductService.cs namespace Supermarket.API.Domain.Services { public inter...
My C++ knowledge is outdated and I'm trying to learn about C++11 threading. I'm working on a SoapySDR driver where the client acquires a buffer it wants to write to and the hardware transmits from that same buffer once it's filled. Rather than post the actual code here, I've distilled it down to an example using std::c...
I have some nominal variables encoded as integers (not ordinal), which I would like to encode as binary (not dummies nor one hot!). The following code is what I came up with (adapted from other code I found). Is this a valid/scalable approach? Thanks! library(binaryLogic) df <- data.frame(x1 = c(1, 1, 2, 3), x2 = c(1,...
I am following this sample by Gunnar Peipman to create a multi-tenant architecture in my ASP.NET Core 3.1 application. It is working as expected up to the point shown in the sample. public class Tenant { public Guid Id { get; set; } public string Name { get; set; } public string Host { get; set; } publi...
I have to go through files with metadata and I am unhappy with the iteration and how I have build it due to the fact, that I have a modeltree with lists. So basically I iterate through filesOfFolder and pick each file and then I am adding the metadata. In the else I am checking, if the fileName has the same beginning t...
I have implemented a substring search, which works as expected and provides the right output. On some edge cases tho, I get either Memory or Time limit exceeded because: the string length is too big there are too many queries The code asks for a few inputs: a string the number of queries query Info about the string...
I have implemented Astar algorithm for a problem on an online judge relating to maze given start and end positions along with a grid representing the maze. I output the length of the path along with the path itself. The following is the implementation in Python using the Euclidean distance: import heapq, math, sys inf...
I'm am trying to classify MLB (Baseball) games whose score go over the total based on the total and the number of people who have bet the over. The total is a number set by Vegas and a bettor can either bet the over - meaning both team's combined scores will be greater than the number Vegas set or you can bet the under...
This is the first exercise from https://gophercises.com/. Basically the idea is to parse a CSV file in a form of 'question:answer' and count the number of correct answers. Also you have a time out range in which you must finish it. I would appreciate any comments, good or bad :) Thanks a lot ! package main import ( ...
This script calculates points in reciprocal space for hexagonal 2D lattices, then uses the cartesian product from itertools to add each vector from one lattice to all of the vectors of the other in the line np.array([a+b for a, b in list(itertools.product(p1.T, p2.T))]) It's slow right now because as written its insta...
This question is a follow up question to the Common Unit Testing Code portion of my lexical analyzer questions. My primary concern is the code in the header file and the C source file that implements strdup(). Since the program this code is a part of is designed to be cross platform it needs to compile and run on eithe...
Haven't worked too much with jQuery and I had to get the values from different elements (they have the ids 0, 1 and 2) in order to compute the sum of them and update a field with that value. The code works well but I was wondering if it is possible to write less code and use something like a for loop in this case. Here...
I did a simple to-do application for native Javascript. This is my first time, previously I used only jQuery. What recommendations would be useful? https://codepen.io/denibudeyko/pen/MWyEmox (function(window) { 'use strict'; // Initial Const const input = document.getElementsByClassName('new-todo')[0] const...
I wrote the following script to fill a Triangle. import pygame import random pygame.init() WIN = pygame.display D = WIN.set_mode((1200, 600)) p1 = (200, 50) p2 = (1000, 600) class Vec2: def __init__(self, x, y): self.x = x self.y = y def getLine(start, end): # RETURNS ALL THE PIXELS THAT N...
This is exercise 3.1.4. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a program that takes the name of a grayscale image file as a command-line argument and uses StdDraw to plot a histogram of the frequency of occurrence of each of the 256 grayscale intensities. Here is my pro...
I'm learning modern C++ and also algorithms, and am doing some practice by coding up some simple algorithms. Also trying to use templates whenever possible as I'm quite unfamiliar with generic programming. Would like some help in reviewing the code in terms of design, efficiency, conciseness, and style. Please do not h...
I have this short function, it converts a human selected name like "Accelerometer" to "Acc" which a sensor can use: private final String[] sensorNames = {"Acc", "Gyro", "Magn", "IMU9", "Temp"}; /** * Converts human representation of sensor names to movesense names. TODO: better code * @param sensorType Human represe...
I recently interviewed for a backend developer role at a startup involved in financial products, as a 2020 grad. The take-home assignment they had me submit had a few basic goals and they recommended the Nodejs/MongoDB stack. I received the following feedback on my submission: 1. Visibility of REST architecture is less...
Goal: Currently creating an application using Node JS and Handlebars. I have a to do list set up in Handlebars, when clicked on Start today's report, it shows up the to do list: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9K...
Currently the class takes a json file and retrieves data from it, and i'd like to improve this class. ConfigLoader.h #ifndef LEVELEDITOR_CONFIGLOADER_H #define LEVELEDITOR_CONFIGLOADER_H #include <string> #include <json/json.h> #include <stdexcept> #include <fstream> namespace Editor { class JsonInit { pu...
for learning purposes (and I found it kinda useful), I built a very basic command-line based metronome in rust. It's the first actual smaller project I built in rust. It consists of 4 source files. What I'm most concerned about: Audio Handling: At the moment i'm loading the audio files on the fly, every time I want to...
Raku script to open files from terminal with xdg-open and, with del option, asks for deletion. Happy to receive Raku syntax improvements. Thanks! use v6; #| Linux: Opens file 'pattern.ext' with xdg-open and, with del option, asks for deletion sub MAIN( $pattern is copy, Str $ext, Str $del? where ( $del ∈ < del nodel ...
I am currently experimenting a bit with C# and as a way of learning I am making a very simple 2D game (asteroids-ish). I am using the monogame framework and the general plan of attack was to have all data "flow one way", if that makes sense? In the sense that I have multiple layers of objects such as this: CoreGame.Upd...
I needed to execute a sequence of async tasks in JavaScript. They are async because I need them to be non-blocking, but I still want the current task to end before starting the next one. The order of tasks doesn't matter, the only important thing is that they are in mutual exclusion with each other. For this reason, ma...
I'm trying to write simple parser using regexes. This is what I currently have, it looks really messy. Any tips what can I change? from re import compile from typing import Dict, Iterator, List, NamedTuple, TextIO # PATTERNS registers_pattern = list(map(compile, [ r'(rax=[0-9a-f]{16}) (rbx=[0-9a-f]{16}) (rcx=[0-9a-...
I'm currently going over Robert Sedgewick's Algorithms book. For the implementation of A priority queue using a binary heap I implemented the code using ES6. I believe to have more experience with Ruby but I have come to enjoy working with ES-6 using classes. I would like feedback on how can the code be improved, if th...
In an app which it is possible to transfer money between accounts I have the following logic: View: class GiftCardRegisterBuyConfirmationView(LoginRequiredMixin, generic.CreateView): template_name = "giftcard/buy-card-modal-content.html" model = BuyGiftCardOrder form_class = BuyGiftCardOrderForm success...
I am working on an API wrapper for calls to a website. Each of several types of calls can take a large number of optional arguments, some of which contradict. In the interest of preventing the user from supplying incompatible parameters, I would like to verify that the arguments are correct before submitting the reques...
As i am learning bash, i have written a small code which is nothing but a simple ldapsearch query which lists all thememberNisNetgroup under Infra_Global netgroup. I am pulling the list out of the netgroup and iterating over the list with a for loop which works fine. I am just curious if the below code which works fine...
I'm trying to build up a toolset of best practices, so as this is my first complete program (if you can call it that) writen in c++, I know there's definitely better ways of doing things #include <iostream> #include <string> #include <limits> using namespace std; void buildGrid(char arr[]) { string line = "---|---...
I am learning some assembly for a compiler project I am working on and I have come across the Exponentiation by Squaring algorithm when it came to calculating x ^ n. To get a grasp on how the algorithm works before I add the operation to my code generation, I have written it out to see if it works. Is my code optimum? ...
I have a data frame, which contains three columns: import numpy as np import pandas as pd np.random.seed(0) dataframe = pd.DataFrame({'operation': ['data_a', 'data_b', 'avg', 'concat', 'sum', 'take_a', 'concat'], 'data_a': list(np.random.uniform(-1,1,[7,2])), 'data_b': list(np.random.uniform(-1,1,[7,2]))}...
This is exercise 3.1.31. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a filter KamasutraCipher that takes two strings as command-line argument (the key strings), then reads strings (separated by whitespace) from standard input, substitutes for each letter as specified by the...
Asking here instead of SO as suggested. I'm trying to use Julia to solve the common tile game 15 Puzzle using Julia using A* algorithm. I am quite new to the language and my style may seem very C like. When I try the following code, I run out of memory. I'm not sure if its related to the use of a pointer style in my st...
I need to get familiar with web programming, so I decided to write up a fairly simple PHP page that accepts GET requests and serves back an image of the Mandelbrot set... as a table of colored cells. Examples: and I'm sending the response as a table because I didn't want to get into using image libraries yet, so I wa...
I have this snippet, which computes on two columns, and if I get some increasing pattern then I will consider it a valid Key. How can I optimize this in pandas? Sample Code Here there is only one group of track_id. However, I will have many track_id groups, I need to apply the same for all groups. import pandas as pd i...
I'm working through Stanford's algorithms course on edX. One of the programming assignments is to find strongly connected components using Kosaraju's algorithm, on a graph with ~875,000 vertices. My implementation is the most basic translation from the textbook's pseudo code into Python, and it works fine on smaller gr...
I have a potentially long running operation and I want to trigger some action if takes too long time. Also I want to reuse this logic. Operation to check: public static async Task Do(CancellationToken ct, TimeSpan actionDuration) { await Task.Delay(actionDuration, ct); Debug.WriteLine("action finished"); } Exa...
I'm building an android application and I have some second thoughts on some error handling case. I have a method that gets data from the internet by calling this method: public static string StoredDatesList { get => Preferences.Get(nameof(StoredDatesList), string.Empty); set => Preferences.Set(nameof(StoredDate...
I have an array of data in the below format let input = [ { time: "2020-7", tasks: [ { key: "p1", value: 15 }, { key: "p2", value: 13 }, ] }, { time: "2020-8", tasks: [ { key: "p1", value: 16 }, { key...
Reasons I'm recently learning Go with various exercises (might be more questions coming in the future) However, I'm quite annoyed with the default argument parsing module in Go flag as it doesn't satisfy my needs most of the time. So as a learning exercise I went ahead and created a simplified clone of python's argpars...
This is a small part of a larger program for implementing a limited syntax regular expression constructor using Ken Thompson's construction algorithm. Converting to postfix before the regular expression is processed makes the processing vastly simpler because everything can be smoothly read and processed left to right....
I am learning Graphs on my own and want to use a graph for a personal small project, so I decided to take a look here in Code Review for some cool implementations and came across this one by Maksim Dmitriev I found it really great, so, heavily inspired and based on his implementation, I present you my own implementatio...
I have a dataframe df such that: print(df['user_location'].value_counts()) India 3741 United States 2455 New Delhi, India 1721 Mumbai, India 1401 Washington, DC 1354 ... SpaceCoast,Florida ...
I have a link aimed to '/FridgeTemperatureRoute' and a checkbox. Purpose of the checkbox is to show the user whether the check has been done or not. <div class="row"> <div class="col"> <a id="FridgeTemperatureBtn" href="/FridgeTemperatureRoute">Fridge and Freezer Temperature</a> </div> <...
I'm not actually that new to writing Python. But I've no formal training and have only learnt to build applications to solve problems for my job out of necessity. Starting to bring my existing skills up to a professional standard is a long overdue project. I'd like to humbly post some snippets here for criticism to gui...
I have a list of Components. When an actor is connected, I want to run onActorConnected on each component. However, if a component's onActorConnected method throws an exception for whatever reason, this cannot affect other components' execution of that method. Here's a minimized extract of my code: import static java.l...
I have a ViewModel where objects are all string and the model from the database Address is a list. I wanted to know if there is any other way to set the viewModel string values other then the way I have it done below? Any advice on how to make this code; cleaner, more effective, just overall better! static void Main(s...
Here is my bubble sort algorithm that I would like to improve in any way possible #include<iostream> int main(){ int arr[6] = {5,2,3,7,2,6}; int f = 0; int b = 0; for(int i = 1;i < 6;i++){ if(arr[i] < arr[i-1]){ f = arr[i]; b = arr[i-1]; arr[i] = b; ...