instruction stringlengths 71 95.1k |
|---|
To practice learning x64 AT&T Assembly (GAS), I implemented three solutions for Project Euler Problem 1 (find the sum of all the multiples of 3 or 5 below 1000).
The codes and a rough pseudocode sketch of each are shown below. I'd like some open-ended feedback (some more specific questions are at the bottom). To clarif... |
I need to manipulate chunks quantity until total will be as close as possible to the requirements. Decimals are ok in the quantity.
Again: I can change only quantity property.
So if the requirements are {a:500; b:1200; c:1500}, then the quantity field in the chunks array should be changed so that when I run this:
// su... |
I have a ViewController and ViewModel. Here I am using the .subscribe() method too many times to bind title property and etc.
As you can see in the bindActions method I am subscribing to action.fetchCaregivers inside and calling fetchCaregivers().
How can I make this code a bit better?
import UIKit
import RxDataSources... |
I am trying to work with a list of Person objects where the Person object has a property called "children" which is an array of same type. I idea is to have methods called “addChildrenToMain” and “removeChildrenFromMain”. In case of addChildrenToMain I want to take the child objects and insert into the array just of th... |
I've understood the method used in post How can I render an html from a JSON-like string?
I guess I can use a for loop to create a bunch of elements as well as go through each of them, setting attributes and textContent.
This code snippet
f1=open('./notes.html', 'a')
num_attributes = 0
num_insert = 0
for i in json_arr:... |
I am fairly new to GUI programming and I am interested in improving my code from every aspect. Performance, security, readability, conciseness, and the look-and-feel aspects are all important to me.
Here is the non-GUI part of the code:
import java.util.Random;
public class Universe
{
private int generation;
p... |
I am currently working on a project for an online course, my goal is to create a bookmark manager web app. So I created this python script to parse a chrome/firefox HTML bookmarks file (Netscape-Bookmark-file) into a JSON object, while preserving the hierarchy and location of the folders and urls.
The code works fine a... |
Just wanted a general review of the code to make sure I'm doing it properly/efficently. New to JS and don't use RegEx too often.
// ==UserScript==
// @name Youtube Subscriptions Redirect
// @namespace https://github.com/spacegIider
// @version 1.0
// @license MIT
// @description Shows all subscrib... |
This code imports a list of equipment (around 8000), and then filters the errors and creates some lots for the processes that come next. The code is working, but I'm sure it can be improved, especially in terms of performance, as it takes a bit. I think the slowest part is in the "ErrorProcessing" sub.
Any suggestion a... |
I have to process raw sql user input with Laravel. I've backed them up as follows:
$query = DB::table('table_name');
function escapeString($str) {
return DB::connection()->getPdo()->quote($str);
}
$column = escapeString($rule['query']['operand']);
$value = escapeString($rule['query']['value']);
if(in_array($rule[... |
I have asked this question on stackoverflow... here, I am asking for some feedback on the solution that I have implemented.
I am using ASP.NET MVC default template to logout user:
// POST: /Account/LogOff
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
AuthenticationManager.SignOut(DefaultAuth... |
I have a array-object which should look something like this and is used to create a form
const questions = [
{
condition_action: "selected",
label: "What is your name?",
question_type: "free_text",
required: true,
},
{
condition_action: "selected",
label: "Where do you live?",
question... |
I have the following Java 8+ code (on Java 14). I have a (terminal) forEach call and I am adding each mapped object to a newly created ArrayList.
Is there a more idiomatic way this could be rewritten using Collectors.toList() and potentially flatMap?
public List<SearchSuggestion> suggest() {
List<Watchlist> watchli... |
This is my second C program (an improved version of the first one). I want to optimize this simulation.
Algorithm
The simulation algorithm is:
The system can go from \$i\$ to \$i+1\$ with probability \$e^{-L\theta(\rho_i)}\$, where \$\rho_i=i/L\$, and \$\theta(\rho)=\rho(2b-\rho)\$.
When system reaches \$n=0\$, it is ... |
Hi I'm trying to create a c++ code based node editor (GUI versions to be implemented). Here is how it works, each node has ports which can be of INPUT or OUTPUT (they only connect with each other so INPUT->OUTPUT or OUTPUT->INPUT).
Here is the code so far:
main.cpp
#include <iostream>
#include "addition_node.h"
#includ... |
I recently posted here about an implementation of the Besenham's line algorithm that I wrote. I've been hard at work improving it and redoing it from the ground up. However I still can't seem to beat BLA--not sure if I'm testing wrong or if it's something else.
void bresenprecalc(int x1, int y1, int x2, int y2) {
/... |
I've recently been learned how to implement a token based authentication with ASP.NET and I would love to get some input on how my code & structure is as well as how I can make it better.
The code I'd like to share consists of the ASP.NET web API controller, and the client Xamarin application.
One question I have been ... |
I have a dataset and I want to search task name inside initialTasks array.
const stagesTasks = [
{
"dataTestID": "stage-0",
"headerText": "Backlog",
"initialTasks": ["task 1", "task 2", "task 3"]
},
{
"dataTestID": "stage-1",
"headerText": "To Do",
"initialTasks": ["task ... |
I made a Three Monte Card game using Java
Problem:
This is the original "ball and cups" game where you try to find out which cup has the ball under it. You may play with three cups and a ball, three cards (two jacks and an ace), or three doors and a car. Basically, randomly select a cup to hide the "ball". Let the pla... |
I'm doing my first big unity project and I'm really unsure about my current code I use for my level generation.
I would greatly appreciate any feedback. I'm very new to c# and I'm not at all aware of all of my options with MonoBehaviour and such.
On the editor side of unity I have Prefabs that have sprite renderers wit... |
The function uses the Windows "Cryptography API: Next Generation" (bcrypt.h)'s BCryptGenRandom function to generate random bytes - one for each character.
It returns the number of characters (excluding NUL-terminator) written to the buffer, -1 in the case of a bad argument, or -2 in the case of an error.
Example usage ... |
The preeminence is to have every method of the formatter return the formatter as a reference. This allows it to add and format text in chain. Such as:
ShapeTextFormatter.Create(Shape).AddText("Hello ").FontSize(16).Bold(True).AddText("Cruel ").StrikeThrough(msoCTrue).FontSize(6) _
.AddText("World!").FontSize(16).Bold... |
I'm a newbie trying to write my own push() and join(). This isn't very serious, just an exercise.
This is what I got so far
function Errey(...values){
this.name=values
}
Errey.prototype={
constructor:Errey,
//join method
myJoin(union = ' '){
let result=""
const length = this.name.length
for(let ... |
I am new to python and to the StackExchange sites. I made an age calculator but i want to improve it till it's a reliable thing. Can i shorten the code? What can be Done more? Does it need any additions?
Thanks in advence.
from datetime import datetime
print("A simple program to calculate your age")
print()
date = da... |
Many people tell me that C++ is a significantly better language for writing compilers than JavaScript is. So, I've decided to rewrite the compiler for AEC (the programming language I've made) from JavaScript to C++ before extending it to be able to target WebAssembly (right now, it's only capable of targeting x86). So ... |
I've made a short simple strip poker game. It follows the traditional rules of poker (4 of a kind>flush>straight,etc.), one round of betting followed by an option to change cards, then another round of betting (if cards were exchanged). It is played in the terminal, and uses Tkinter to display/change the photos dependi... |
This bot uses the PRAW package and jisho.org API. While running, it looks at recent comments for summons. A user either requests a random Chinese character/Kanji and associated definitions or specifies a query to look up, which can be anything, but definitions are not guaranteed to come up. The bot replies with the req... |
I tried to solve the Problem Euler 67 with golang, because I started to study Go recently.
This is my solution:
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
"time"
)
func calculateMaxPath(trianglePointer *[][]int, lines int) int {
trisums := make([][]int, lin... |
The following code should return an array (flatFeatures) which will include feature.name and the most far subscription.expDate. for example if I have some subscriptions with the same features, the flatFeatures array will include distinct of all features from all the subscriptions but for every feature we will have the ... |
I have implemented an in-memory filesystem - this is a design question from LeetCode. Is there a better OOP approach to represent files and directories? The current code uses a boolean flag isDirectory to distinguish between files and directories and I'm not confident that it is the best approach. See the code below. I... |
Is there a way to simplify this script using in keyword or anything like this:
searched_value = 3
data = [("a", 1), ("b",2), ("c",3)]
### can be simplified ?
test = None
for i in data:
if i[1] == searched_value:
test = i[0]
break
###
print(test)
|
I am using fluentvalidation to validate my object model. I have to make sure that the first two characters of an ISIN must be letters / non numeric. The way I did it is to convert the string to a char array and then perform regex on the first two characters. I was wondering if anyone has a nicer way of doing the valida... |
I am trying to capture the screen content of each monitor I have and divide each captured bitmap into small blocks (wxh=128x128). I managed to do this using the GDI+ API, but my implementation (on Windows using VS2019) is a bit expensive in terms of CPU usage and since I am looping it and constantly capturing the scree... |
I have always been amazed at the number of things you can do in a constexpr function, yet I have not thought much about them until recently when I found out that c++20 added the ability to pass user-defined types as a template parameter. Meaning there is a way to pass strings as a template parameter which made me think... |
I am new in NodeJS and I try to write code based on tutorials I find online. I have a NodeJS app (based on Strapi) and an external API from a Cloud Servers provider. The process I follow is as:
Call the cloud servers provider to authorise and get an access token
Call the Strapi to get the list of servers I have added... |
Below is the code I wrote to perform basic Trigonometry without using the math module(except for 1 place) for the purpose of teaching myself basic trig and to improve my python. I have never taken a trig class, so please consider this fact when explaining some fallacies in my trig logic, and please help me correct it.
... |
I am wondering if the following code can be modified to be used with latest version of spring APIs?
The following code works fine. However, I wanted to know if servlet APIs can be avoided which i have used in the code below.
public void download (HttpServletRequest request, HttpServletResponse response, @PathVariable S... |
This is my first Vim plugin and is intended to assist with adding, and editing, MarkDown headings. Features include changing the heading depth, auto-update heading reference links, and adding link title (on hover) text. Currently everything seems to function as designed, however, as this the first Vim script project th... |
We have three methods, the first calls the second one. How would you refactor so the third one can call the second one too as they have similar code?
public async Task UnpublishPersonAsync(string id)
{
await QueueAndUpdateStatusAsync(id, PersonStatus.Unpublishing, QueueNames.Unpublish);
}
private async Task Queue... |
The goal was as much code reuse as I could get. Shooting for a pure-function-y style.
Would love any feedback on general architecture, adherence to standard practice and usability - as well as ideas for improving which I may not have considered.
Would also love advice for making these shapes more generic, in order that... |
I am beginning the cycle of creating my role based access control into my framework. I now want to log the user into my application and my _user table looks like this:
CREATE TABLE `_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`hash` varchar(255) NOT NULL,
`session` varchar(... |
At work, my team hosts a daily standup, in which we discuss what we're working on, what we did the day before and any potential blockers for future development.
I thought as a fun little side project that I would write a script in bash to go through each directory in my /dev/ folder and get all commits from the previou... |
I wrote a program to implement to find the count of words for a given string.
I have applied two different approaches.
The test works for these two approaches and I am looking for other approaches to solve this problem.
Thanks for your valuable comments advance.
package test;
import main.algorithms.WordCount;
import o... |
I have implemented binary search solution by using recursion and iterative approach.
I there any way to improve it?
Tests
package test;
import main.algorithms.BinarySearchDemo;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class BinarySearchTest {
BinarySearchDemo binarySearchDe... |
The parser function is immutable and is completely based on the forest of strings with associated properties (String,Set a).
Changing the forest changes the behavior of the parser.
The use of Data.Tree allows very compact data storage and fast access to the string properties, especially in the case of large databases.
... |
I updated my Instagram API and I read that HttpClient is now the preferred way in .NET Core 3.1. I would like to get a code review, because there are too many examples and too many ways and I'm not quite sure if I did the migration correctly.
One more question: The reason I added _client.Timeout is in case the user is ... |
I have been trying to do a simple query and return the results with node-mysql however I had several problems. Originally I wrote it where there was no promise, but if I tried to access user after just doing a query if returned undefined
The solution I came up with is the following, is this a good way of doing it? I ne... |
This is my latest effort on RFC 1951 compression ( the widely-supported compression standard ) in Rust. It uses 2 extra threads to compute the LZ77 matches and the checksum in parallel with the Huffman coding. Currently it appears to out-perform the standard Rust library by some margin. On my standard test ( compressin... |
To familiarize myself with Javascript (and in particular NodeJS) I embarked on a concrete project.
In this project I need to "build" the URLs of different IP cameras.
All Cameras Information are in a JSON file
Everything works correctly, but I think to use some "bad" coding part and that there is certainly better to do... |
I'm porting my site over from .NET Framework / MVC 5 / EF6 to .NET Core 3.1 MVC / EF Core. MSSQL Server for the database.
EF6 has SqlFunctions of which one method is SquareRoot, which translates to using SQRT in sql queries against MSSQL Server.
EFCore does not have the SqlFunctions class. It does have an equivalent Db... |
I implemented the Largest Triple Products algorithm, but I use sort which makes my time complexity O(nlogn). Is there a way to implement it without a temporary sorted array?
The problem:
You're given a list of n integers arr[0..(n-1)]. You must compute a list output[0..(n-1)] such that, for each index i (between 0 and ... |
In my app I have 3 components:
MovieSearchComponent to "house" the other 2 components
MovieSearch to search an API and retrieve the data
MovieResultList to display the data in the browser
Both components are wrapped in a parent container MovieSearchComponent.
My MovieSearchComponent looks like this:
interface Movie {... |
My code provides the following functionality for interacting with Pinnacle Bets API:
retrieving betting history
retrieving fixtures (future events)
retrieving odds for the given leagues (competitions)
retrieving odds for the given events (games)
placing a bet
Should you need to get acquainted with the API, it provide... |
I wasn't quite sure whether I should do it this way or create a validation service and inject it, but this works:
Controller:
[HttpPost]
public async Task<IActionResult> NewUser(NewUsertVm viewModel)
{
if (UserValidator.NewUserIsValid(viewModel, ModelState) == false)
{
return View(nameof(NewUser), viewM... |
I need to randomly erase 33% of the non-zero elements in each line of a matrix.
Side note: The end goal is to train a denoising autoencoder to remove this noise.
My solution:
import numpy as np
matrix = np.random.rand(1000,3000)
for i in range(matrix.shape[0]):
clean = matrix[i, :] # original matrix line
# fi... |
background story my girlfriend watches about 12 TV-Show episodes everyday and i keep telling her it's not good. I have made this script that kicks her out of my account for 20 times in an hour.
However, After 20 logouts it gives out a Technical difficulties error and i want to improve as to why?
import sched, time
from... |
I have implemented a Producer-Consumer by Semaphore implementation.
I am looking forward to for your code review comments.
Thanks.
package ProducerConsumer.Semaphore;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util... |
I have completed an implementation for finding the first unique character.
Is there any way I can improve it?
package com.datastructures;
public class FirstUniqueCharacter {
public static void main(String args[]){
String string = "neslihan";
System.out.println(firstUniqueChar(string));
}
... |
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time!
Problem
Two strings X and Y are similar if we can swap two letters (in different positions) of X, so that it equals Y. Also two strings X and
Y are similar if they are equal.
For example, "tars" and "rats" are... |
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time!
Problem
Two strings X and Y are similar if we can swap two letters (in different positions) of X, so that it equals Y. Also two strings X and
Y are similar if they are equal.
For example, "tars" and "rats" are... |
I finished a code that sorts and compiles daily work data into a weekly summary. Its triggered by workbook changes so it refreshes automatically.
Trying to respect "good code writing", and using my background in matlab, I tried to split my code as much as possible. It's an intership projet for a company and the Excel s... |
I am using below command to assign a value, Is there a alternative way to get by tweaking the code
var=hdfs dfs -ls /hdfs_path/ | grep col=2020_03 | awk -F' ' '{system("hdfs dfs -count "$8)}' | awk -F' ' '{if ($3 != 0) print $4}' | awk -F'=' '{print $2}'|sort -nr | uniq | head -1
Basically i am need to find the latest... |
I want to build my own link shortening system. Therefore I need a way to create unique strings from the record ids stored in my database table.
So far I came up with this. I wonder if you now a faster or better idea? Or are there any caveats to my method?
// generate unique alphanumeric string from id with map
function... |
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you!
Problem
Two strings X and Y are similar if we can swap two letters (in different positions) of X, so that it equals Y. Also two strings X and
Y are similar if they are equal.
For example, "tars" and "rats" are similar (swap... |
This is a project that I remade to help me understand function definitions better. It may not be great but I am proud of it.
I would love to have you review this project and tell me what I could improve in this project, as well as in general.
from all_wrd import words
import random
import re
class Game:
def __init... |
can someone review my code for me.
Here is my algorithm:
initialize dataQueue with all elements to be added into the nodes in order
initialize parentQueue as empty queue
create the tree's root node with the first element of the data queue
enqueue the root node on parentQueue
while dataQueue has elements
a = dequeue fro... |
I have a lot of Command objects. Each command has lots of Task objects. Tasks and commands are related. Each command wants to know which task belongs to it. Where each task wants to know which command it belongs to.
class Command:
def __init__(self, date):
self.deadline = date
self.tasks = []
... |
My code down below generates entries for my program, but it's veryyy slow. I'm looking to generate about 10 million, is there any way to speed it up?
FirstNames, LastNames, and Objects (.txt) are all files with one entry per line
TempList=[]
maxData=10000000 #The maximum amount of entries that can be produced
import ra... |
I'm writing a tiny Python library that fetches data from Horizons, JPL's solar system data and ephemeris computation service. An overview of their batch CGI is here. While the script is simple, I would like to make it as clear and standardized as possible.
The idea is to initialize the HorizonsRequest class with a loca... |
This is basically based on the following question on stackoverflow which was based on a codewars assignment that can be found here
Problem statement
Complete the function scramble(str1, str2) that returns true if a portion of str1 characters can be rearranged to match str2, otherwise returns false.
Notes:
Only lowe... |
I'm just returning to Java after a multi-decade hiatus -- there are some nice new packages, such as java.nio.
I need to convert an array of floats into bytes and vice versa. The floatToBytes() function feels okay, but I'm pretty certain that bytesToFloats() could be implemented better. Thoughts?
(P.S.: ignore the pub... |
I need to get car info from a 3rd party web service and persist the data in my application DB. If my DB already has the car, I only update property values that may have changed. Otherwise, I create and save the car:
@Transactional //Spring Transaction
void saveCars() {
//get CarInfo from a webservice
List<CarInf... |
Purpose of Code
The purpose of the main function (get_player_penalties()) is to:
Generate simple SQL statements from user input and a template
Query a database using the generated SQL and return a summary table to the user
Ultimately, I will reference this code to create similar functions (and SQL templates) that r... |
I'm absolutely dumbfounded by this. I was trying to demonstrate to myself how much faster C++ is than even modern PHP. I ran a simple CSV parsing program in both that have the same output. The CSV file is 40,194,684 parsed down to 1,537,194 lines.
EDIT: This sparked alot more conversation than I had anticipated, here's... |
I found a simple series named the Lebniez series for finding Pi.
$$1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \frac{1}{9} - \dots = \frac{\pi}{4}$$
I made this in Python. I then realised that because it is an infinite series, and it will give an approximation. Additionally the convergence rate is very slow.
Here is ... |
Looking for a most efficient way to replace some specific exception and to leave others exceptions treatment the same the same.
try
{
// some business logic
}
catch(UniqueConstraintViolationException uex) when (!uex.IsFatal() && !ShouldRetry(descriptor, command, uex, ref retryResult))
{
throw new ItemAlreadyExistsEx... |
I'm trying to write an extension (method chaining) for playing around a bit.
What I made work is an extension to add an item to the list (what is pretty easy):
IEnumerable<int> myList = originalList.Add(12);
What I now want to do is:
IEnumerable<int> myList = originalList.Add(12).If((list, @new) => !list.Contains(@new... |
Given the following generic memoize utility for pure functions with type hints:
function memoize(callable $fn, callable $serialize = null): callable {
$serialize = $serialize ? $serialize : 'serialize';
return function(...$args) use ($fn, $serialize) {
static $cache = [];
$k = $serialize($args)... |
I am trying to solve the warning, which avoids the call of a virtual method, I have seen different answers, but none of them seems to solve my doubt, I understand why this warning appears and is one of the ones you should not suppress. My code gets data from Matlab and uses a method to configure the limits in a usercon... |
I'm working through the classic "99 problems in prolog" collection. But trying to do them Pythonically. Flatten a list is problem 07.
I am flattening a list of lists of arbitrary depth. I have two solutions below. Which is more Pythonic?
# helper function
def isList( x ): return isinstance( x, list )
def flatten3_h( *... |
I started learning functional programming with JavaScript and I have the basic idea of Functors, container types and etc. I was trying to experiment with arrays but I don't know how to solve the problem of a function call that iterates over a array and returns returns another array. So the first call ends up with an ar... |
Goal:
My goal is to filter datagrid by selected month from dropdown options.
January, February, March etc...
I'd like to know if there are easier methods to my current method..
Code:
public Schedule()
{
InitializeComponent();
RefreshGrid();
Dictionary<string, string> allOptions = new Dictionary<string, str... |
I feel like there is a redundency between:
def _determine_nodes_with_no_predecessors(nodes:List[Node])->List[str]:
"""
Given the list of nodes returns the identifiers of nodes that doesn't have any predecessor.
"""
nodes_ids_without_prdecessors = []
for node in nodes:
if not node.predecesso... |
I am trying to solve the following problem:
Input: Input is two arrays (Nx4, sorted in column-2) stored in datasets-1 and 2 in HDF5 file (input.h5). N is huge (originally belonging to 10 GB of file, hence stored in HDF5 file).
Output: Subtracting each column-2 element of dataset-2 from dataset-1, such that the differen... |
Working on finding a way to reduce in-cell formula size and memory usage of my excel workbook, i came up with the idea to "load" (copi-paste) the reference sheet i was mentioning a lot with a workbook open. To make it more efficient i had a loop that verifies if the sheet has changed and only copy-paste it if there a d... |
I have developed NoSQL database.
At the moment it has no threads (async).
When the database needs to save data to disk, it blocks connections until it saves.
This method works OK, because save is fast - 3-4 sec, but I still can improve by background save.
Here is the prototype of the background save facility.
I have th... |
Im currently running an employee name substitution on card scan.
Overall the code takes the entry trough the gun scan, "scan" trough the hidden reference sheet to find a match and then input the actual complete name.
I had to implement that feature to my code so that names are always written the same (for futur data tr... |
Thanks in advance for your interest in my first PyPI project.
While there happen to be a number of projects out there to help with creating & consuming Excel workbooks, I was unable to find one that made working with pywin32 any easier, so I built it myself. Using pywin32 for automating Excel with best practices happen... |
I have this bit of code that works for copy and pasting an autofiltered range. I just wanted to see if anyone knew a more efficient way to do so as it does take quite a while to complete it the way I have it now. I looked into trying to do so with a copying into an array but did not seem to work so I'm happy to hear so... |
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time!
Problem
(This problem is the same as Minimize Malware Spread, with the differences bolded.)
In a network of nodes, each node i is directly connected to another node j if and only if graph[i][j] = 1.
Some nodes in... |
There is a Name class with properties that represent different components that make up a person's name. A Name object requires a FirstName and Surname. All other fields are optional.
class Name
{
public string FirstName { get; set; } = String.Empty;
public string Surname { get; set; } = String.Empty;
public... |
I would like request for a code review and feedback my calculator web page because I want to improve my coding ability.
Basic calculator
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8">
<m... |
Background
The basics of this project have already been discussed here.
I've improved the following things:
Sᴀᴍ Onᴇᴌᴀ mentioned that I shouldn't use multiple elements with the same id. I corrected that and use classes instead. I also removed units from style.css when the value is 0. Furthermore I removed !important.
Sᴀ... |
I’ve created a function that takes a number and, if it’s prime, tells you so, or if it’s composite, gives you the prime factors of the number (and if it’s 1, tells you that it’s neither).
Theoretically it should work for an infinitely large number, but at 8 digits it starts to slow down significantly, particularly if t... |
I created a simple text-based Tic Tac Toe game in Python using OOP. Currently the computer moves are completely random - I plan to add some sort of algorithm later (no idea how to do that yet though)
Any suggestions about how to improve it are welcome.
from random import randint
from itertools import cycle
class Boar... |
I'm writing an a11y widget with vanilla js, but my code got messy.
Here's my code:
class A11yError extends Error {
constructor(msg) {
super(msg);
this.name = "A11yError";
}
}
class A11y {
constructor(options) {
this.color = options?.color || "#17384c";
this.position = options?.position || "left";... |
I would like a code review for my simple pomodoro utility web page because I want to improve my coding ability.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="refresh" content="55">
<meta http-equiv="Content-type" content="text/html; ch... |
I am redesigning a library, which at the moment uses a lot of boilerplate code in a double hierarchy of classes / metaclasses, to attempt to make it much cleaner and reuse as much as possible what dataclasses already provides.
For the library itself it is not an issue to add the @dataclass decorator when defining each ... |
I've made a very simple book list console app in C#. You can add the name, author and the page number of the book. You can also edit the infos or remove the book from the list if you want to. The code is working but I think it's very messy and don't know how to make it better.
using System;
using System.Collections.Gen... |
As an exercise, I've made a text processing utility that wraps arbitrarily long lines of text, but only using fixed-size arrays and other basic C features.
I have mostly programmed in Python, C++ and Java so far, and I recently picked up K&R (second edition) to learn some C. I have only gone through the first chapter s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.