instruction stringlengths 71 95.1k |
|---|
Just a disclaimer this code was one of the last homework submission for my CSCI intro to C++ class and from my guess very rough around the edges. If any of you are bored during the quarantine and want to look at around 450 lines of a novices code, please, by all means, be brutally honest I can take it and I would actua... |
Can anyone help me improve the performance of my code.
Given a sorted array of distinct integers, write a function indexEqualsValue that returns the lowest index for which array[index] == index. Return -1 if there is no such index.
function indexEqualsValue(a) {
var arr =[]
a.forEach((el, i) => {
if( el==i... |
I recently began to learn Python and encountered this problem.
The condition:
You and your friends are playing the next game. Friends write natural numbers in a row on the board. Your task is to find as many consecutive numbers as possible that are divisible by the same number greater than 1. Since it is difficult to ... |
I have many users. Each time a user uses their smartphone it register them. I am determining the last time each user used their smartphone each day.
Additionally smartphone usages from 18:00 to 06:00, the next day, should be considered as an entry on the previous day. I have created a dummy example.
I did the following... |
As a personal challenge I want to implement a C++ JSON Parser. As part of that I have implemented the following Types/Data-structures and a way of querying them.
To represent the type of an individual JSON attribute I defined the following std::variant and aliased it as JSONType. My thought behind using an std::variant... |
#!/usr/bin/env stack
{- stack
--install-ghc
exec ghci
--package lens
-}
module Main where
import Control.Lens
import Data.List.Lens
import Debug.Trace
import Text.Printf
import Prelude hiding (Left, Right)
data Direction = Up | Left | Down | Right
data Location = Location Int Int
type Grid = [[Int]... |
Puts and calls are two types of options. One parameter that they both share is called a strike price. The valuation of an option is related to the strike price, but the exact methodology is different depending on the type of option. All things being equal, a lower strike price is better when valuing a call, and vice ve... |
I think I can summarize the idea to the Producer-Consumer problem, with some modifications.
And I think I misused the term "Producer" (it depends from which point of view :))
An infinite consumer/producer produces a result from a given input
The result is computed from another thread
Only one product can be producted ... |
Imagine we have a custom dictionary class which is derived from Dictionary<string, object>. Dictionary is case-insensitive about keys and elements arrange is not important.
So what is the most optimized way to compare two instance of this class, or in another word what is the best override of
Equals method in this clas... |
I was using Karatsuba algorithm to multiply two polynomials and return the coefficients and I am using java, we are asked to use arraylists here, however, my code is too complicated and it takes much longer to run than I expected, can anyone help me with reducing the running time and simplify my code? Thanks a lot!
pub... |
I am new to Rust, so I created a mini library/wrapper for creating multi-cliented Tcp Servers. This is a starter project for me to learn Rust.
How the module works is a user can pass in a function or closure to the start fn to use to handle each new client's connection, the function has to accept HandleClientType as a ... |
I have an implementation of depth first search, which I want to test using the pytest framework.
I would be making test cases for other graph algorithms, and would like to know if this approach is good enough to be replicated on similar programs.
Here is what it looks like currently:
(This may not be a very exhaustive ... |
I'm using the following handler to resolve assemblies in a specifically named subfolder of the main assembly's folder.
I am looking for improvements in:
clarity
correctedness
flexibility, as long as it doesn't conflict with other goals of this code
The code does not need to be thread-safe as the intended environment ... |
I made a calculator in C++. I wanted to ask is this code well written, understandable, and alright.
#include <iostream>
using namespace std;
int main() {
// Declares the variable to store the asked value
int num1, num2;
char op;
// Asks the user for the input of numbers and the operatio... |
I'd like to hear some reviews or tips where I can improve in my code - or better if you can post your own version of the code from somebody experienced where I can visually see to why you have coded it in your way rather than my way.
What this code does is simply loads data into the dataGridView using Windows Forms and... |
Given a floating-point number, which is representing a dollar value, I'm aiming to return a rounded, human-readable string. Here are the rules for numbers equal to or greater than 1 million, equal to or greater than 1 but less than 1 million, and, finally, less than 1:
one decimal place for million, two places for bil... |
I always read questions about a Windows solution to find a file in a directory structure like find and grep.
I created this working c++ program, where you give the program a path and a file name to find.
#include <iostream>
#include <string>
#include <sys/stat.h>
#include <windows.h>
#ifndef INVALID_FILE_ATTRIBUTES
co... |
Suppose I have 3 classes, Animal, Dog, and Cat
public abstract class Animal {
private static final List<Animal> allObjects = new ArrayList<>();
public Animal(){
allObjects.add(this);
}
// Returns immutable list of all Animal objects
public static List<? extends Animal> getInstantiate... |
I created a script to automate the task of uploading a CSV file to Box. I have a couple of files a Box client and a MySQL client. I create an instance of both on the function.rb file which is the one below. I wonder if there is anything to improve? if there are principles I'm not following or if I'm breaking best pract... |
I have written a code for data management and parallel arrays but it has to be broken into methods/subroutines. Whenever I try to do so, some aspect of my code stops working. Would it be possible for anyone to roughly outline how and what I can break into subroutines without it causing problems in my code?
Scanner ... |
I solved this question on LeetCode.com:
Alice has a hand of cards, given as an array of integers. Now she wants to rearrange the cards into groups so that each group is size W, and consists of W consecutive cards. Return true if and only if she can. For e.g., for hand=[1,2,3,6,2,3,4,7,8] and W=3, the answer should ... |
I implemented the intersection of two (convex) polygons in C++. It finds the polygon in the intersection like in this image.
Looking for any and all feedback. I left the logic for line intersection and point containment out.
#include <algorithm>
#include <cmath>
#include <iostream>
#include <optional>
using std::atan2... |
I created a simple enum macro that creates a to_string method for the enum. This has been done before, but my version is designed to compile quickly. From what I can tell, existing libraries use deep preprocessor macros and lots of template instantiations which is taxing for large enums.
Here is the code:
#include <a... |
While learning JavaScript I thought it was a good idea to make a digital clock program. I followed a youtube tutorial (with some tweaks to my preference) and came up with my final code that I have. I came to CodeReview to get the script reviewed, and to ask is there anything wrong with the script and/or any way to impr... |
I'm going through books and various questions to improve my algorithm knowledge. I solved each NxN matrix first by hand and applied that process to build the code from that. I have done my best to break each task into its own step and keep them encapsulated. Below is the class followed by its accompanying unit tests. H... |
I'd like to see and hear some reviews on my current WinForms Login and Dashboard code.
It's a desktop application to be used only internally and not over the web.
If you have any code suggestions - I'd be more than happy to see it and see where I can improve.
LoginScreen.cs
using System;
using System.Collections.Generi... |
Consider the following example code:
c1 = ["Mary herself","Mary is mine","John himself","John is mine","Alan himself","Alan is mine"]
s1 = pd.Series(c1)
c2 = [1,2,3,4,5,6]
s2 = pd.Series(c2)
dictionary = {"A":s1,"B":s2}
df = pd.DataFrame(dictionary)
print(df)
for i in range(6):
name = df["A"].iloc[i]
if "Mary" in... |
Here is my implementation of arg max in Scala. q_table_test.txt contains:
["---------,'0','0','0','0','0','0','0','0','0', "X--------,'0.', '0.1', '0.1', '0.1', '0.1', '0.1', '0.1', '0.1', '0.1'"]
For example the String ---------,'0','0','0','0','0','0','0','0','0' maps to key: "---------" , with values: [0,0,0,0,0,0,... |
First time creating my own Proxy handler, instead of copy pasting code.
Goal is to chain CSS definitions: style(element).color("red").background("green")
and allow whole CSS objects:
style(element).CSS({color:"red",font:"12 px Arial"}).background("green")
Any optimizations?
let handler = {
get: (target, prop) => va... |
I am writing a small application to generate the domain name of computers, from their known properties, and business rules.
My Asset class is:
public enum AssetSite
{
Rotterdam,
Sydney,
}
public class Asset
{
/// <summary>
/// Gets the Asset Tag of the asset.
/// </summary>
public string AssetTag { get;}
/// ... |
int get_digits (int num)
{
if(num < 10)
return 1;
if(num < 100)
return 2;
if(num < 1000)
return 3;
if(num < 10000)
return 4;
if(num < 100000)
return 5;
if(num < 1000000)
return 6;
if(num < 10000000)
return 7;
if(num < 100000000)
return... |
This is a class from an implementation of SQL in C# I am writing. It fully buffers all reads and writes, and also logs changes to a log file so that updates are atomic ( all or nothing ). It implements the standard IO.Stream methods, but also has a "FastRead" method that allows direct access to the buffer to increase r... |
I've ported a prime-number calculation program from primes.pyx to C++ for benchmark purpose.
Since I wrote it in C++, I thought that my program would be faster than the original. However, mine took 25.8 ms at the fastest, while the original took only 1.45 ms on the same machine. I tested 10 times each, but got similar ... |
The problem
As a Front-end developer, I do not have control over the data that is returned from the Backend. I sometimes notice that the data shape and types I expect on the Front-end are different from the actual data inside the API response. I don't want to manually look up these differences and I want to have some k... |
I wrote a makefile that would generate a simple executable from the example directory structure.
project/
source/
include/
makefile
The makefile itself comes equipped with dependency tracking, and automatically generates two directories named build and dependency. Currently the makefile I made works, yet it take... |
I am working on a game in Unity/C#. I have a section of code that both feels like the best solution and code smell.
There are two objects. A player, and something interactable. The interactable object defines a method from an interface IInteractable with the signature void Interact(GameObject interactor). The player ca... |
I'm learning c++ and I know some algorithms and data structures. I was wondering what is the best way to do merge sort for a vector in c++.
// will write a program for merge sort
/* steps:
* have an array of size n call it A
* divide A into left and right halves L and R
* call merge sort on the two halves now L' and... |
I have subclassed tkinter treeview object added many features like cut,paste etc and context menus to insert rows, delete etc. Would like some feedback on how well it works and if it's intuitive or not.
Current version is @: https://github.com/unodan/TkInter-Treeview-Example-Demo
import json
import tkinter as tk
import... |
This is an easy level LeetCode question, obviously not much code to review. I'm posting C++/Java/Python here. If you'd like to review, please do so. Thank you!
Problem
Given an array of integers, return indices of the two numbers such
that they add up to a specific target.
You may assume that each input would have exa... |
I made the switch from JavaScript to Python lately. This is my first Python project and my first web-scraper. Do I have good practices? And could this be optimized?
from bs4 import BeautifulSoup
import requests
urlHalf = 'codingbat.com'
print("what is your email")
inputOne = input(">")
print("password")
inputTwo = i... |
This code is using XPath to expose a library function that can check whether an XML file contains a string or an expression:
private XPath xPath = XPathFactory.newInstance().newXPath();
public boolean applyFilter(String xml, String xPathExpression) {
String result = xPath.evaluate(xPathExpression, new In... |
I returned to study assembly language. And this is actually my first function written in Yasm. Implementing this function is a suggested project from this book. I slightly modified the pseudo code presented in that book:
input:
an array of integers 'array'
length of 'array' 'len'
algorithm:
for i := 0 to l... |
I recently started doing some competitive programming in C and one of my first requirements was a high-speed token reader (analogous to the java Scanner class' next() function). A few examples of input I am most likely to read are:
5
ccadd
bddcc
5 4 1
1 2 5
2 3 7
3 4 8
4 5 2
2 3
The integer/float inputs will be handl... |
I implemented binary logistic regression for a single datapoint trained with the backpropagation algorithm to calculate derivatives for a gradient descent optimizer.
I am primarily looking for feedback on how I approached the functions that return optional derivatives. I used nullptr as a flag to indicate that derivati... |
I am new to writing unit tests and i am facing some difficult writing unit tests for this class.
I am using Xunit and moq.
public class WriteFileOutput: IWriteFileOutput
{
public string File { get; set; }
public WriteFileOutput(string fileName)
{
File = fileName;
}
public void writeFile(... |
I've created a method that groups Item entities below based on their Value property. The idea is to produce groups that also includes possible "edge duplicates", i.e.
[{ Value: 9 }, { Value: 10 }, { Value: 11 }]
With rangeSize set to 10 yields two groups:
[ [{ Value: 9 }, { Value: 10 }], [{ Value: 10 }, { Value: 11 }]... |
JavaScript beginner here! I have written a Tic Tac Toe game is JS that seems to be unbeatable (Title says 'almost' because I'm not sure if it's really unbeatable or just I can't beat it :) ). I really appreciate any help to improve my code and learn from my mistakes.
Project's CodePen = https://codepen.io/MiladM1715/... |
I wrote this hashcons data structure in C and it works correctly. It uses larger twin primes as the capacity and double hashing (open addressing). Page 614 of "Data Structures and Other Objects Using C++ (4th Edition)" describes the approach.
I am wondering if I can get some feedback on whether I followed the standards... |
I'm exploring String relativity and comparison techniques, and I found Hamming distance algorithm in my search so I give a try to implement that approach in Java and below I'm sharing my implementation.
Please let me know if this approach is correct or I need to improve it more.
HammingDistance.java
public interface Ha... |
I have a function that I created in Codepen. It does what I want, where the div that you select gets a blue border and changes its text. But I would like to know if there is any way to make the JavaScript that actually makes this work more compact/efficient.
Codepen
JavaScript
function toggle(el) {
const contentRefer... |
According to LeetCode, the following question is one of the most frequent interview questions asked by companies such as Facebook and Google. Here, I'm posting C++/Java codes, if you'd like to review, please do so.
LeetCode 560
Given an array of integers and an integer target (K), you need to find the
total number of ... |
What I want is to extract min/max range of salary from a text which contains either hourly or annual salary.
import re
# either of the following inputs should work
input1 = "$80,000 - $90,000 per annum"
input2 = "$20 - $24.99 per hour"
salary_text = re.findall("[\$0-9,\. ]*-[\$0-9,\. ]*", input1)
if salary_text and ... |
Write a function that takes an array of integers (Both Positive and negative) and return the maximum sum of non adjacent elements. Note that even if all values are negative, I don't have an option to choose empty subset and return sum as 0.
Recursive solution that I wrote:
public static int maxSubsetSumNoAdjacent(int[]... |
I have created an simple elevator design for 100 floors building with just one elevator.
I have dependency between classes which I want to eliminate, any thoughts/suggestion to make it more better in-terms of SOLID principles?
I have created following set of classes and detailed their purpose
class Request: This holds ... |
I believe I'm writing in the correct place. However, I'm not fully sure, and I am relatively new to Stack Exchange. If it is not, and can be moved by an admin/moderator in the correct place, please do so. Or else let me know where and why, and I'll fix it.
PS: Sorry for any grammar mistakes. I'm a dad of a newborn. So ... |
I would like to obtain some feedback on a simple code I wrote to
implement an easy and hopefully fast way to generate a large number of floats
with CURAND and use them one at a time.
This is achieved by switching between two large buffers that get generated and copied onto host memory asyncronously while the other buff... |
I'm building a platform like Rundeck/AWX but for server reliability testing.
People could log into a web interface upload scripts, run them on servers and get statistics on them ( failure / success).
Each script is made up of three parts, probes to check if the server is fine, methods to do stuff in the server, and rol... |
I want to calculate the hitting time of a sequence of prices. I define a log price corridor by for forming a double barrier, up_threshold and down_threshold.
When one of the barriers is touched, I note the time and reset the barriers around the last price
My script looks as follows:
import pandas as pd
def speed(pric... |
I'm have recyclerView which is needed for displayed for show list of my audio records. I added the ability to sort my audio records. Please take a look at the code that I use for sorting and tell me how it can be improved.
enum class AudioRecordSort {
SortByDate {
override fun sort(empties: List<AudioRecor... |
So, I've tried to extend my compiler so that it can target GNU Assembler. And I've made a simple program to demonstrate that.
Syntax GAS
;So, this is an example of how to target GNU Assembler (GAS) using AEC, and how to target Linux.
AsmStart ;What follows is the assembly code produced by CLANG 9.0 on Linux, I don't un... |
I've decided to learn more about C++ with the time that I have right now through Udemy courses. To test out the stuff that I've learned up until now, I decided to try and code with some of the knowledge I've gained. I wanted try out object oriented features since I've been doing stuff through procedural programming ins... |
guys I'm new to python and I decided to learn it via doing some project myself so I started working on Hangman game is there somebody willing to chceck my code for some common mistakes and what could be better done than it is, btw the works fine.
import random
def rand_word(version):
if version.lower() == "slovak... |
I'm posting my Java code for the Minimum Window Substring. If you have time and would like to review, please do so, I appreciate that.
Problem
Given a string string and a string target, find the minimum window
in string which will contain all the characters in target in
complexity O(n).
Example:
Input: string = "ADOBE... |
I'm fairly new to Python but had to start using it and for reasons I have to use 2.7, which is why I am using that syntax. I have this function which gets data from a file, if it exists, and then gets passed onto other functions to perform SQL queries etc. The script is only intended to work for the directory it is run... |
I'm posting an sliding window problem of LeetCode (Minimum Window Substring) with C++. If you have time and would like to review the code, please do so, I appreciate that.
On LeetCode, we are only allowed to change the variable names and brute force algorithms are discouraged, usually fail with TLE (Time Limit Error) o... |
I'm posting a two-pointer, sliding-window problem of LeetCode (Minimum Window Substring) solved with Python. If you have time and would like to review the code, please do so, I appreciate that.
On LeetCode, we are only allowed to change the variable names and brute force algorithms are discouraged, usually fail with TL... |
I implemented getting the \$k\$-nearest neighbours of an origin point to a set of points in C++17. I tried to use some more modern C++ lambda techniques and was looking for feedback on use of lambdas, auto return types, and using a custom comparison function with priority queue.
Should other lambdas be captured by ref... |
So I've written a URL router which also allows for wildcards (path parameters).
A URL like /users/{uuid} can be added and then, when a user sends a request to the server with the following target /users/955b2a88-ae80-11ea-b3de-0242ac130004, the uuid will then equal 955b2a88-ae80-11ea-b3de-0242ac130004.
Example:
PathMat... |
I wanted to make a calculator in python so I first wrote a tokenizer. I have written one before but this time I tried to refine it a bit. Any thoughts on improvements, things I could of done better.
import re
class KeyWord:
def __init__(self, name, regex):
self.name = name
self.regex = regex
class... |
I implemented the following function using the matrix object from breeze library. Basically it is just a glorified while loop.
The convolution there is extremely slow so I rolled out my own, optimized on a kernel which is just a vector. This is already much faster but I figured there must be something else I can to to ... |
I'm getting into learning python so to learn I made a die-rolling application.
What would you do differently? What would you suggest to improve performance/readability? What tips do you have? Suggest pretty much anything.
import random
import time
import re
#installed via pip install inflect (https://pypi.org/project/i... |
Submitting for review by experts.
Inspired by this question to color value cell having duplicates with a different color. So "Apple" will have one color for all duplicates. Then "Banana" will have a different color for all its duplicates. What if number of such values exceeds 56 (max number of ColorIndex property ?
Wit... |
If the user/visitor has access to the API route, then the status code will 200, else 401.
I know that I can user Vue navigation guards, but I will need to use Vuex.
This way is much simpler and faster, what do you think, is it a right way to protect Vue page from unauthenticated users?
<template>
<v-container>
... |
Link to problem: https://www.codechef.com/JUNE20B/problems/EVENM
Iam trying to solve a simple problem challenge, but getting TLE.
I had a different approach earlier, so tried this, again with no success.
I know this can be optimized further but can't figure how.
The problem: Print the matrix in a format depending upon... |
So this is a modern implementation of a HTTP client, trying to find a way to optimise/simplify this.
Specifically the DeserializeAsync method with the GetStream and the compiler statement for if/debug is a bit messy and I would love for a way to simplify it, but I don't want to remove the debug statement because I love... |
I have a matrix M of size [n_rows, n_cols] and a list of x and y pixel coordinates. I use these coordinates to draw a binary image. Here is my code:
std::vector<std::vector<double>> x;
std::vector<std::vector<double>> y;
// fill x and y
std::vector<std::vector<unsigned int>> M(n_rows, std::vector<unsigned int>(n_cols... |
This is my first web app written in JS. I would like to know how the code can be improved in terms of style and structure, especially in terms of following JS's conventions and general heuristics. I would also be thankful for any improvements that could be made to my HTML or CSS.
var size = 3;
var board = [];
var tea... |
I'm writing some code to take high precision timings of a function call
for (int i = 0; i < iterations; i++) {
beginTime = high_resolution_clock::now();
CallFunc(functionPtr, otherParamaters ...); // inline function call to do the timed function
endTime = high_resolution_clock::now();
elapsedTime = d... |
In my BlogList.vue component I made a search input field:
<input type="text" placeholder="Enter key word ..." v-model="search">
And a computed property:
computed: {
getfilteredData() {
return this.blogs.filter(blog =>
blog.name.toLowerCase().includes(
this.search.toLowerCase()
) ||
... |
I have these 3 methods for ATM mock program.
public decimal CheckBalance(BankAccount account)
{
return account.AccountBalance;
}
public void Deposit(BankAccount account, BankTransaction bankTransaction)
{
account.AccountBalance += bankTransaction.TransactionAmount;
}
public... |
I have a simple macro moving data from Teradata to Excel. The process normally takes me 10 minutes to perform manually, however the macro can run for hours sometimes. This is making the macro seems counterproductive. But I still want to give it a chance.
Manually, I would just simply paste the sql to teradata, and copy... |
I would like to arrange a system messages dictionary for an application in JavaScript.
As an initial intention, I thought something about the following structure:
export const SYS_MESSAGES = Object.freeze({
fileSizeExceeded: {
code: "FILE_SIZE_EXCEEDED",
text: "The file size exceeds allowed limit"
... |
I have started to use C# 7's type based pattern matching. A method that only manages a single pattern-based result looks very clean and is easy to reason about.
However, once a second pattern-based result that depends on the first pattern-based result creates an arrow anti-pattern, and will only get worse with n-result... |
I have an array of the form (3x3 case as an example)
$$A = [a_{11}, a_{12}, a_{22}, a_{13}, a_{23}, a_{33}] $$
corresponding to the symmetric matrix
$$\begin{pmatrix} a_{11} & a_{12} & a_{13}\\ a_{12} & a_{22} & a_{23} \\ a_{13} & a_{23} & a_{33} \end{pmatrix}$$
I want to print out this very matrix (in general of size ... |
I 'm new here. I wrote the following django code. I 'm opening, closing files here and saving them temporarily and deleting them. I tried to use Python's tempfile and was getting Permission Error and I did asked about it on IRC #django but maybe Windows is not a pleasant to use OS for programmers so I couldn't get a go... |
I am (relatively) new to game programming and have been exploring creating an entity component system for my simple 2D game engine.
Here is what I have so far:
Entity.h
#pragma once
using Entity = int;
ComponentArray.h
#pragma once
#include "Entity.h"
#include <unordered_map>
class ComponentArrayAbstract {};
templ... |
I had an assignment last semester to program a payroll app utilizing methods. I went back to it and re-wrote it to include an extra class as well. I would like some feedback regarding whether my code is following the Single Responsibility SOLID principle - should the class be split further into more classes?
I would al... |
So I'm currently using python to unscramble words that are retrieved from an OCR program (pytesseract).
The current code I am using to unscramble words is this:
import numpy as nm
import pytesseract
import cv2
import ctypes
from PIL import ImageGrab
def imToString():
# Path of tesseract executable
pytes... |
I have a class that imports the FX Rates produced by another department.
This works as intended, which is to return a Pandas DataFrame with all FX Rates by month.
The DataFrame it returns is then used by another 5 classes, that basically import other files and do some formatting and calculations with their own columns,... |
I want to fill an array of strings with the name of each directory item. The issue is allocating memory. I either need to count the items before, allocate memory, then go over them again, or I will have to reallocate each iteration of the while loop. Both of these options seem slow. Surely there's a better way.
Which i... |
I have a couple questions about this program
Should I implement runnable instead of using thread class? I like the idea of the consumer and producer being thread objects, it seems simpler to me, but I have seen people argue the benefits if runnable interface.
Are static methods in the main class considered good/bad c... |
I want to fill an array of dirent pointers with each entry of a specified directory. I either need to count the items before, allocate memory, then go over them again, or I will have to reallocate each iteration of the while loop. Both of these options seem slow. Surely there's a better way.
Are these my only option:
s... |
Here I'm posting my code for the Reorganize String problem on LeetCode. If you have time and would like to review, please do so, I'd appreciate that.
On LeetCode, we are only allowed to change the argument names and brute force algorithms are discouraged, usually fail with TLE (Time Limit Error) or MLE (Memory Limit Er... |
I have a writeOnFile() method with too many fwrite().
I think it is not a good implementation because too many system calls may produce a high overhead.
What can I do?
Code
void writeOnFile()
{
char cr[1] = {'\n'}; //Usefull characters
char sp[1] = {' '};
char header1[] = "Instant "; ... |
Hi :) I am a beginner coder who just learnt C++ and I wanted to apply it in projects to solidify my learning process. However, I only took a short tutorial before trying this out hence I'm pretty unsure about my C++ coding practices and I would like to know what areas I can improve on - and perhaps what kind of resourc... |
Python3 - Recursive XML Files to Large Text File
I have a recursive function that looks through a directory (there are 6000+ files).
For each XML file found - the XML is converted to a string and appended to an array.
At the end of the recursion - All these arrays are joined to return a (very) large string.
The error I... |
I am learning about clean and maintainable code. I heard that functions should be no more than 20 lines long (preferably 5 - 10 lines). I have come across this Bob Martin quote where he said:
“The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than tha... |
I've written the following custom event system module and I'm planning to use it in production in the future. Before I do that, I'd like to ask for general suggestions on how to improve it. Thanks a lot.
const event = (function() {
let registry = {};
function on(event, callback) {
if(!registry[event]) registr... |
I have the code below, which works successfully, and is used to parse, clean log files (very large in size) and output into smaller sized files. This would take about 12-14 mins to process 1 GB worth of logs (on my laptop). Can this be made faster? Could Dask or parallelism or asyncio or another help speed this up?
I a... |
I wanted to create an AES encryption service which will use a custom key/iv.
I want 2 methods: dycrypt/encrypt byte[]
The code works as expected, any remarks/issues?
public class AesGenericEncryptionService
{
private readonly byte[] m_Key;
private readonly byte[] m_IV;
public AesGenericEncryptionService(by... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.