instruction
stringlengths
71
71.9k
I have a sleep function which displays the time remaining in sec, some feedback would be appreciated use warnings; $x=$ARGV[0]; $|++; $n=0; # arguments could be 1, 1s , 1m or 1h if($x=~/([0-9]+)([a-zA-Z]?)/) { $t = lc($2) ; if($t eq "h"){$n = $1*3600;} elsif( $t eq "m" ){$n = $1*60;} elsif( $t eq "s...
Recently I noticed that the idiomatic python two-dimensional array initialisation is extremely slow. I am wondering, is there a good, proper way of doing this simple task fast? Also, are those two variants equivalent? Here are some code snippets using timeit import timeit A = 5000 B = 7000 N = 10 def list_comprehens...
The purpose of the data-structure is to manage person-objects. Persons can be added at any time. But the order can't be changed afterward. Only the deletion of a person is possible. Represents the case of cancellation. The whole thing is intended to be as simple as possible. Nevertheless: I'm thinking about an additi...
I made a function that should ease the making of new objects out of objects or arrays. I extended underscore so thats why the _. _.dictionary = function (obj, keyIteratee, valueIteratee) { var newObj = new Object(); if (Array.isArray(obj)) { var length = obj.length; ...
I'm currently in the process of refactoring some code and I was wondering if I should use switch or if-else for the is code: Switch for (int i = 0; i < length; i++) { CameraStream stream = null; var id = (Guid)CameraGridView.Rows[i].Cells[0].Value; ...
The task is: I get companies' information from a large CSV file and then I need to compare this information with each company in the database to know if the company is a new one or if it is already in the database. The problem is: The information from the CSV file could contain some errors (wrong zip code, typo in the ...
I have implemented a generic dynamic array implementation using defines. As I am new to C, I am not sure whether the code has any flaws. The code is as follows, #define INIT_CAPAC 5 #define INC_CAPAC 5 #define list(t) struct{ t* data; unsigned int count; unsigned int capac;} #define list_init(lst) lst.data = malloc(s...
I need to add class is_active to all div's when I click on <div id="all-tags"> and remove class if I click again. Only every div have class is_active then main div (<div id="all-tags">) have class is_active. Please tell me if this is ok or not. I need as fast of a solution as possible. I'm also not sure using .each() i...
I'm using Passport in Node.js app to authenticate user by email and password (login) and also by token. Email and password are used only when user is logging in. Passport local strategy generates token when user email and password matched. Token will be later used for bearer token authentication. It would be nice to he...
Can you write an a simpler Rust fizzbuzz program than I have? Use my output or the spec: Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuz...
I have a function that takes a four-dimensional NumPy array M and, for each value i of its second index, takes all of M without the i-th "column", evaluates the product over all other columns, and stacks the results so that the array returned has the same shape as M. In other words, what I want to evaluate is: $$R_{ijk...
I have the following unit test that is testing predicate logic in a repository (Note: mockOpportunityRepository.Setup): [Test] public void GetFollowedByUserIdShouldGetTheUsersFollowedOpportunitiesFromOpportunityFollowRepositoryAndThenGetThoseFollowedOpportunities() { const int ExpectedOpportunityId = 9; var te...
I have tried to implement a Bloom Filter in Java here. https://github.com/srirammanoj/skynet/tree/master/bloomfilter I just wanted to know if my implementation can be called 'thread-safe' , and if there is an improvement to be made on the locking I have used here. I opted for locks instead of 'sychronized', as I wante...
I have the following code which loads in a URL based on the id of a user-clicked button. I'm looking to compress it down as much as possible, and make it more modular and reusable: <!-- Function to load in info from different docs --> function loadDoc(UrlString) { var xhttp = new XMLHttpRequest(); xhttp.onreadystat...
This is an implementation of optional<T> from C++17, it is mostly standard conforming. I'm looking for a review on efficiency, correctness and performance. Sample usage #include "optional.h" int main() { util::optional<std::string> s0{ "abc" }; util::optional<std::string> s1; if ( s1 ) s0 = s1; else s...
Problem: Write a program that manages robot factory settings. When robots come off the factory floor, they have no name. The first time you boot them up, a random name is generated, such as RX837 or BC811. Every once in a while we need to reset a robot to its factory settings, which means that their name gets wipe...
I wrote a query for SEDE that I think is pretty cool. It uses the currently available graphing capabilities (scatter plots) to create a bar graph. I have used it as the subject for a self-answer on MSE. This query finds potential "recommendation questions" based on the words in the title. The graph looks like this when...
I tried to make a program to find a string whose MD5-hash starts like the digits of pi, where dot is omitted. Is there a faster way to do it than this: import hashlib import random import string n = 1 while True: word = ''.join(random.choice(string.ascii_lowercase) for _ in range(20)) if (str(hashlib.md5(word.e...
With the following data in a table, +----+-----------+-----------+---------+ | id | name | parent_id | prev_id | +----+-----------+-----------+---------+ | 1 | Section 1 | NULL | NULL | | 2 | Item 1.1 | 1 | NULL | | 3 | Item 1.2 | 1 | 2 | | 4 | Item 1.3 | 1 | 3 ...
This is a follow-up on my previous post. I have made modifications based on the feedback received on the previous post, hence I request another review on the modified code if ok. Note: review purpose is just to check good practices (code / performance wise) and see if anything's missing. I created a jsfiddle here: ht...
I want a matrix that can grow dynamically and build up a structure in RAM as input arrives from standard input och terminal (shell). First I tried with a matrix like A[nrows][ncols] but I changed to the char **matrix[32]; and I want to refactor so that there are fewer constants and that malloc will be safe. char ***w...
I've just started out using C#. I've used Scratch (drag and drop programming for kids) for quite some time. Since Scratch didn't have classes and methods I have a feeling this code could be a lot more streamlined, neat, efficient, more read-able, shorter and in general just better. using System; using System.Collection...
Can you please point out any problems with this C forward list with remove node functionality? I believe this can be way simpler ( removeNode function ) but I somehow cannot grasp it #include <stdlib.h> #include <stdio.h> #include <assert.h> struct node { int val; struct node* next; }; typedef struct node node; n...
I wrote a small, cross browser compliant implementation of xhr requests in client JavaScript that closely follows the jQuery $.ajax() API and standards. The goal is to keep the xhr() very small in size, yet cover most common xhr scenarios and needs. I'd like code review for performance, general best practice, and the m...
The function findMinimal() receives a tuple from a list which contains 171 tuples, each of them go into the function one by one and, for each tuple, it searches the best pair via minimalTscore out of those that match by industry (approx. 20 names, for each one). How can I make the function to run faster? At the moment,...
I am currently working on a project, and I just wrote a piece of it that requires a lot of array manipulation. Given a text input I want to expand it to fill the number of rows and columns I have. I worked out a solution, but I am concerned that I am creating too many arrays in my solution. I am looking for pointers...
I want an istream that you can safely peek arbitrarily many characters from. This works as far as I can tell, but I am unsure if this is really "the right way" to do it since the iostream library is pretty cryptic to me. #include <streambuf> #include <vector> class peekbuf : public std::streambuf { std::streambuf*...
I am studying design patterns and I've implemented a composite prototype pattern which is also a singleton (one instance per JVM). The main and most important part of the code is the Registry class which is a singleton. The Movie and Book classes are inherited from the abstract Item class which implements the Cloneabl...
The program below generates a prime normalised sequence. So, what happens is this: It asks you to provide a number within a range. Program then calculates a factor which is inverse of product of all the prime numbers till the first prime number larger than the number you provided. It then divides each number from 1 ti...
I created an Encryption class that encrypts data and decrypts it using the AesCryptoServiceProvider class with an HMACSHA256 hash. The goal was to replace our existing encryption class with something that was FIPS compliant. I would like a review of my structure, security and FIPS compliance. Encryption.cs using System...
I have a library which makes HTTP calls to my service. I was trying to calculate running average of how much time my service is taking on an average. Here is the core logic of how I am calculating "running average": import java.math.BigDecimal; import java.math.RoundingMode; import java.util.LinkedList; import java.uti...
I'd like to know how I can refactor my JS code for usability. Currently my JavaScript uses some HTML to build out a simple calendar with the following functionality: a. opens into the current month with today's date highlighted b. allows you to view next and previous month My goal was to build out a calendar with the p...
I was given the below Exercise as part of a coding Exercise to do at home for a technical interview, and I did not get through past this round. I would like to get some input on what i could have done wrong. Appreciate your time and effort in providing valuable feedback !! Exercise : Given the following text file(of ...
I just recently wrote a program to simulate how multicast routing works. The program uses a weighted graph to represent the network and simply runs it through the algorithm. I would like to know if there is a better and more efficient way of going about this. Here are my classes: /* * To change this license header, c...
This is a much improved version (I hope) of code in this previous code review of mine. I have: renamed several things. Are the names good? made it lazily start the worker thread only after the first timer is added. Is it clear that the implementation uses one worker thread to handle an unlimited number of timer callba...
In this code: tmr represents timer array n represents number of frames in memory m represents number of pages rs represents the reference string There are many functions in this program, but the important one is the timer_confg. This is the function that tests the particular page refereed is least refereed or just re...
I've to authorize some users to do POST requests from their CMSs in order to create a new resource on my database. I've to send a JSON response containing the status of the response (successful or not), and on failure, send an array of the errors. To not continuously repeat the return statement (i.e. return response->j...
today I created a simple hangman game, which has 10 different categories with 10 words each. The words order is being randomized each time you pick a category. You have the chance to pick a wrong letter 8 times, after this it's game over and your progress on the current category is being wiped out. The game also saves ...
I'm curious how I can improve the readability of this short program I wrote. Mainly, if and how there is a way to remove the for loops and maybe refactor the getTruncatedSubListsOf methods to one method since they are pretty similar. I tried using comments only when clarification was necessary. import java.io.IOExcepti...
I just wrote this script that calculates the time difference between two times. It's going to be used in a larger program that will store the returned value in a database. I'm mainly wondering if I've used docstrings, comments and try/raise/except correctly since it's my first time really using them. def time_differen...
I was wondering if someone could help me refactor this code. Although I know this looks bad, it works. Now I would like to refactor it so I would respect the open/closed principle in SOLID. Let's say the client wants a new search field to search data on, then I need to come to this method and add it in and this breaks ...
In short, what this script aims to do is take the following data: 1 Alpha Beta Delta 2 Beta Echo Foxtrot Kilo 3 Alpha Kilo 4 Beta Echo Kilo Zulu And re-arrange like this: 1 2 3 4 Alpha Beta Alpha Beta Beta Echo Kilo Echo Delta Foxtrot Kilo Kilo Zulu The...
I am creating a volume converter. It allows users to enter a value and select the unit to convert from and the one it will be converted into. It uses a <select> tag for user input selection. The <select> looks like this: <select name="from"> <option value=0>--select--</option> <option value=1>cm3</option> <option...
I know this question has been asked before now but in Python. Recently, I set out to write an anagram in C#. For instance, orchestra can be rearranged into carthorse and the anagram should not have more repeated than the original. The function is meant to check if the two words are the same and return true in this case...
I have a small function which checks if the given String has all 0's. This method would be used quite often and want to know if it's effectively written. Any help would be greatly appreciated. /* * Input parameters: Employee Number * Returns true if sum of employee number is greater than 0, * else false. */ privat...
I wrote a simple Python simulation to answer the "Amoeba" population question posed here: A population of amoebas starts with 1. After 1 period that amoeba can divide into 1, 2, 3, or 0 (it can die) with equal probability. What is the probability that the entire population dies out eventually? The script seems to wor...
So I have implemented three linear time (\$\mathcal{O}(V + E)\$) algorithms for finding strongly connected components of a (directed) graph. A strongly connected component is just a maximal subset of nodes, such that any node in the subset can be reached from any other node in the subset. The algorithms I am comparing ...
I am new to Swift and I am trying to use the optional binding feature in as efficient way as possible but I am a bit confused on how to use it (if I can) in this scenario: var jsonData:AnyObject? = nil jsonData = try? NSJSONSerialization.JSONObjectWithData(data!, options: []) if(jsonData == nil) { print("Could not...
I am writing a function that, given a list and a target sum, returns zero-based indices of any two distinct elements whose sum is equal to the target sum. If there are no such elements, the function should return null. For example, FindTwoSum(new List<int>() { 1, 3, 5, 7, 9 }, 12) should return any of the following ...
I'm beginner with CMake and C++ compilation but it's seems that unlike Java I need to be very explicit with my CMakeList.txt in order to link src with correct header and libraries in my project. Here is my CMakeList.txt cmake_minimum_required(VERSION 3.4) project(AwesomeScheduler) include_directories(header) set(CMAK...
I have a WinForms MVC application that uses Ninject for it's Dependency Injection (DI) / IoC Container. I have build quite a nice framework that allows the main shell (which uses a Docking Container to house an manipulate windows - like Visual Studio), to manipulate IDocument types (actual documents .txt, .xlsx etc.) a...
My makefile looks like this and I translated it to cmake: CC = gcc GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags) CFLAGS := $(CFLAGS) -L/usr/local/include/ -L/usr/include -pedantic -std=c99 -Wall -O3 -g -DVERSION=\"$(GIT_VERSION)\" -ledit -lncurses LDIRS = -L/usr/local/lib -L/usr/lib LIBS =su ...
I have several lists that contain Part objects with a partNumber and quantity. When the user selects to add a part to an existing list, I want to check to see if the part is already on the list. If it is, I simply want to add the new quantity to the existing quantity, and if the part is not already on the list, I want ...
I was recently tasked with architecting a user/profile object in Objective-C and wanted the ability to access a static instance from the class level, similar in style to the way Parse manages their current user (a static variable on a class, not a singleton). With Parse, I can call a class method to return the current...
This is a follow-up on my previous post. I have made modifications based on the feedback received on the previous post, hence I request a third (final?) review on the modified code if ok. Note: review purpose is just to check good practices (code / performance wise) and see if anything's missing. I did all updates as ...
Problem statement: Calculate the date of meetups. Typically meetups happen on the same day of the week. Examples are the first Monday the third Tuesday the Wednesteenth the last Thursday Note that "Monteenth", "Tuesteenth", etc are all made up words. There was a meetup whose members realised that there are exactly...
I just made my first pygame program, ChickenDodger, and I would like to know how I could make my code better. I think I did pretty good for my first time, except the way I added the 2nd egg. I do not like the way I added it. Any advice? (I made a lot of comments for my younger brother, so he understands it easier, I th...
I'm quite new to trying to write my own macros and I've been able to piece this one together, but it takes quite some time to run. Here is the macro for one value (I have to create workbooks for ~20 different values). Are there any ways I can improve its speed? Also, I am assuming I can just replicate my For/Next loop ...
I have created a Matlab Simulink model with a series of dot products. Embedded Coder generates a for loop for each dot product, as evidenced by this excerpt of the generated output: /* DotProduct: '<S3>/Dot Product1' incorporates: * Inport: '<Root>/LngPwr' */ EPAR_SPAF_dot_B.DotProduct1 = 0.0F; for (temp_ = 0; tem...
Mat told me to create a struct create a struct for the individual commands and arguments. It should have something like the "executable" name, number of args and arg list. Create a few functions to create such a struct, free it, and add to the argument list So i did. struct str_list { char *const *name; ...
Based on this question and this answer, I decided to try the enum approach to do some more conversions I need in my application. This time I required to convert between the different field naming conventions I use in my application: SQL naming convention (used for my field names in SQL DBs): field_name. Java naming co...
Despite looking terribly ugly, it is pretty interesting due to some specific connections to cellular automata theory. I'm looking for ways of simplifying it further. This program takes 2.7 seconds to run on my machine. Is it possible, by merely changing the logic / control flow on magic, to speed it up? How fast can it...
I've made an Arduino program to run on my Teensy 3.1 board. It accepts characters and strings sent to a Bluetooth module (BC417) from any Bluetooth-enabled device and uses these to power certain pins on my 8x8 LED matrix. I believe the code works, but I haven't been able to test it fully yet. I'm hoping (if it's the ri...
How would you merge these two functions into a single more generic function? // concatStringsFromObject :: Object, Array, String -> Strings const concatStringsFromObject = (o = {}, a = [], j = ' ') => { return a.filter( x => o.hasOwnProperty(x) ) .map( x => o[x] ) .join(j); }; // concatStri...
I wrote a Rails model instance method that checks many separate conditions, and returns a single boolean. It does not employ any nesting of branching structures. Each check has its own comments describing its reasoning. Every check is necessary for the method to return an accurate value, and none of the checks are like...
The below code I have written is to allow me to Sum the results data for every year from 1 to 1000 over a range of 5000 locations. although a 1000 years seems extreme, for the application I am using this makes sense. Column K in the Class Calculation Sheet calculates the Data size for every year for a specific class. I...
Please help review my code. public class Maze { // question: give a maze. Find shortest path from left top corner to right bottom corner. // 1 is wall. cannot go thru. int minFoundLen = Integer.MAX_VALUE; int m = 0; int n = 0; public void findPath(int[][] mazePlan){ if(mazePlan.length =...
The class Functions can store/load any functions. It does this by assigning a unique name to every function that gets added. You can then call the function by specifying its name and return type. Here is a sample usage //Create class Functions funcs; //Add 2 functions (foo -> void(int, int) | add -> int(int, int)) fun...
I have written a ScreenVideoCapture class that implements an interface for capturing frames from a specified monitor connected to the PC. It uses OpenCV structures (including a cv::Mat for image output) and implements the core of the methods that OpenCV's VideoCapture has so that they can be used mostly interchangeably...
I have this little piece of code which determines the base URL of PHP: $root = $_SERVER["SERVER_NAME"]; if(basename(__FILE__) !== trim($_SERVER["PHP_SELF"], "/\\")) { $root .= "/" . basename(__DIR__); } This is working for me, but are there other solutions for this "problem," or are there any cases where this woul...
I needed a deque who's maxlen can be set again after it has been initialized. So, since new-style classes in Python are treated as types, I decided to create a new class borrowing from deque to accomplish this. My approach is to have an internal deque as an attribute and when maxlen is set, it replaces the internal deq...
I am trying to get into the habit of solving programming puzzles in my spare time but am stuck on the first one (which I know can be for a large number of reasons, hence my posting for help). Shown below is my code that is meant to solve the 3n+1 Challenge: from sys import stdin def main(): curr_Line=stdin.readlin...
There is a large list of email addresses and there is a limitation of max 100 email addresses to process once. This is the code I have written. //Create a list of email addresses to test List<string> emails = new List<string>(); for (int i = 0; i < 10000; i++) { emails.Add(st...
For couple of days now I am trying to speed up my Force-Directed graph implementation. So far I've implemented Barnes-Hut algorithm that's using octree to decrease number of computations. I've tested it multiple times and number of force related computations is indeed drastically decreased. Below is the plot of computa...
I have made this app to get a bit more familiar with JavaScript and CSS. I functionality seem to work as expected. Although I've noticed problems with the flexbox-layout in Firefox. Currently no good idea what causes that issue. Any tips how to improve the app appreciated. var sc = {}; sc.btns = document.querySele...
I'm new to unit testing, and to learn, I've decided to "contribute" to Monogame to help with their testing efforts. The issue at hand is to test the input device classes. I've started with the GamePad class. Here are the tests that I have implemented. namespace MonoGame.Tests { [TestFixture] public class GamePa...
I am really new at this and I was wondering if there is a more efficient way of writing this code, which converts time format to 12-hour from 24-hour format, and vice-versa. For example 07:16:35PM converts to 19:16:35, and 13:05:25 to 1:05:25PM. public static void convertTimeTo24(String time) { if(time.substring(8...
I’ve been working on a Rampart inspired multiplayer game for a few weeks now, and it is finally in a playable state. The big thing left to do before going alpha was to add a tutorial to the game. I did a tutorial once before for my city building game, but I was very unhappy with how I coded it. I had a Tutorial class ...
I wrote a download function and I wanted to know if my code clean, readable and maintainable, or if I could make things easier. Please tell me if this function could be used in the real world. public static void Download(Uri _downloadUri, string _path, string _passedSong, Song _currentObj) { if (_downloadUri !...
I have the following models: class Donation(models.Model): donation_amount = models.DecimalField(max_digits=9, decimal_places=2) donor_name = models.CharField(max_length=200) class Charge(models.Model): donation = models.ForeignKey(Donation) error = models.TextField(null=True, blank=True) And I have ...
I was thinking to rewrite my Python code to C++ since it contains quite a lot of simple loops. I was stunned to find out that this critical part of code (the code below) is about 5 times slower than the Python code, and I'm hoping you could help me figure out why. The context is some kind of game similar to Tetris, whe...
I'm trying to learn programming with python by myself and I've made a hangman game for exercise purposes. import random words = ['egypt', 'automobile', 'world', 'python', 'miniority', 'treehouse', 'friend', 'program' , 'people'] def start(): print "Hello! Welcome to a tiny hangman game that I made for exercise pu...
I hope you can get me out of my current predicament which involves coding style when it comes to appending many elements in a pretty flexible and typesafe way. Now I see my code below and I feel that it can be written in a more compact and shorter manner, especially in my set function. Also, I'm not sure if I should me...
Problem Statement: Write a program that cleans up user-entered phone numbers so that they can be sent SMS messages. The rules are as follows: If the phone number is less than 10 digits assume that it is bad number If the phone number is 10 digits assume that it is good If the phone number is 11 digits and the fi...
I've got this fizzbuzz project I am using for a blog series, among other things. In this version, the fizzbuzz function is fed from a Fibonacci generator. I'm particularly concerned with the efficiency of the Fibonacci generator, but all scrutiny is welcomed. Here is a link to the entire project, but below are the part...
Is there a one-liner that can accomplish this same thing? Essentially I have two dataframes: one that has my raw data (data), and one that has values that I want to lookup (lookup). I want to find the percent of values in data (by 2 factors, Site and variable) that are less than the lookup value for those same 2 factor...
I'm trying to remove the duplicate from the list and count the list after removing the duplicates seq = [[1,2,3], [1,2,3], [2,3,4], [4,5,6]] new_seq = [[1,2,3], [2,3,4], [4,5,6]] count = 3 My code takes around 23 seconds for around 66,000 lists in a list How can I make my code faster? def unique(seq): new_seq =...
I wrote the following code in Angular as to accomplish a technical test for a UK job. My impression was that it is very neat and well object oriented. To my big surprise, they rejected it. Could someone find any problematic points as to ameliorate my coding performance? angular.module('myApp', []). controller('myC...
After comparing my newbie attempt with other people's answers, I have a couple questions: I've made s1_set the size of s1. I've seen other people assume that the strings are ASCII-256 and use s1_set(256) but to me this doesn't make sense. Won't s1_set have at most s1.size() bytes (and fewer if s1 has duplicate charact...
I have a small console application that runs a very long task and I would like to hide the console window when I click on the minimize button but keep a notify icon in the system tray so that I would know when the task is completed or something went wrong. Well, I did a lot of research mostly here on SE and I came up w...
I am interested in hearing opinions on this. I need a way to dispose the old value of a property in a way that's compatible with BindableBase. Specifically, I have a few bound properties of type System.Drawing.Bitmap. Am I going about this all wrong? using Prism.Mvvm; using System; using System.Runtime.CompilerServices...
This is an odd case scenario, but I would like to display a message that tells if indexedDB is not supported or if it is removed due to being in private mode (yes ie10+/edge remove indexedDB in private mode, crazy uh?). I think found a way without doing crazy UA sniffing or documentMode hacks that I think could work. ...
I've been tasked with giving a legacy codebase some love. The actual code is written in C, but is not very relevant aside from the #includes each file makes. No, the bulk of this task involves GNU Autotools. Project hierarchy . ├── AUTHORS ├── buildall ├── ChangeLog ├── configure.ac ├── COPYING ├── include │   ├── Ma...
I'm implementing the Binary Search Tree data structure in Swift. It looks like this: class BinarySearchTree<Key: Comparable, Value> { let key: Key var value: Value var left, right: BinarySearchTree<Key, Value>? init(key: Key, value: Value) { self.key = key self.value = value } ...
I have written a simple Tic Tac Toe game in WPC C#. I am just a beginner and learning. Could you tell me if there is something wrong with my code / could be done better? I am pretty much satisfied with how it works, but I´d like to know if I made some things, that could have been done better. Thanks in advance. In the ...
I'm working on unlocking feature: public class UnlockManager { private static UnlockManager instance; public static UnlockManager Instance { get { if (instance == null) { instance = new UnlockManager(); } return instance; } } ...
Currently I have the following callback system: var saveTask = function(err, result) { if (err) return callback(err, result); var newid = mongoose.Types.ObjectId(); var task = new Task({ _id: newid, taskname: req.body.name, teamid: req.body.team, content: req.body.content, ...
I have written a simple linked list visualization program in JavaScript: I am just a beginner in html5 canvas. I am pretty much satisfied with how it works, but I´d like to know if I made some things, that could have been done better. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" con...
I have written this code which basically sorts the array using bubble sort, however, I feel it is not very readable. Please let me know me how I can improve this code. public class BubbleSort { public static void main(String[] args) { int arr[] = new int[] { 4, 1, 8, 5, 2, 0, 4, 3, 7, 9 }; for (i...
My application needs Field objects, which encapsulate 1D, 2D or 3D gridded data. The number of dimensions and their size are known only at run time. Furthermore, I need the encapsulated data to be in one contiguous memory block for performance reasons. I've based my code on the following code, which defines simple mult...