instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
This is a piece of C89 code testing a function titled logging_function(), which takes two arguments and uses them to log a bit of information. In this case, the first argument to the function is the string to be logged, and the second argument is a string holding a path in a filesystem to a log file. The first string ...
stackexchange/codereview
Finished Someone helped me see that i was framenting the output by writing to each file inside the for loop instead i needed to have one big for loop for each file so that the harddrive didnt have to move its head everytime https://stackoverflow.com/questions/9913788/outputing-dictionary-optimally I have 4 Dictionar...
stackexchange/codereview
I was asked the following problem: What is the smallest positive integer n that can be written as a sum of three positive cubes in at least 12 ways? Can this be coded better way such that it is easy to compute the smallest positive integer that is sum of m nth powers? I'm not a professional programmer, so I managed o...
stackexchange/codereview
Here is the RPS game I made. I watched a 4 hour tutorial about C++ from freecodeacademy and produced this game right after it. If you have any feedback or suggestions please let me know. Or if there's anything I should be aware of or shouldn't be doing that would be great. #include <iostream> #include <conio.h> #includ...
stackexchange/codereview
Usually it is a good style in Java to create a named constant for a string (and other) hardcoded values. Using the example below I want to know how pedantic I should be in it. I use a Java class as a wrapper of XML settings. Each function is suppose to return a value from a related XML file. I defined a lot of constant...
stackexchange/codereview
I have a big project called 'PyDOS', written in Python 3.4, and it's going very well. Post your answers of anything that could make it look cleaner. import time import os import sys import random import operator def textviewer(): os.system('cls' if os.name == 'nt' else 'clear') print ("Text Viewer.") file_nam...
stackexchange/codereview
I have been working for about a week on a calculator in Tkinter, and the result is a very ugly, but functional calculator. Is it possible to clean up the code, and make it more readable? from Tkinter import * import tkMessageBox import sys import os import math main = Tk() string = [] x = 'add' def exit(): sys....
stackexchange/codereview
This code seems to be working. I am allocating matrices on the stack and passing them to functions to modify in place. Is this a standard practice, or am I doing it wrong? Header: #ifndef _MATRIX_H #define _MATRIX_H typedef enum {MT_OK, MT_INVAL} MT_RESULT; typedef float mat4[4][4]; typedef float vec4[4]; MT_RESULT ...
stackexchange/codereview
The problem can be found here. The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated by a single space): the first five are Player 1's cards and the last five are Player 2's cards. You can assume that all hands are valid (no invalid c...
stackexchange/codereview
I have translated Dijkstra's algorithms (uni- and bidirectional variants) from Java to Python, eventually coming up with this: Dijkstra.py import heapq from Digraph import Digraph from random import choice from random import uniform from time import time __author__ = 'Rodion "rodde" Efremov' class HeapEntry: def...
stackexchange/codereview
This is exercise 3.1.31. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a filter KamasutraCipher that takes two strings as command-line argument (the key strings), then reads strings (separated by whitespace) from standard input, substitutes for each letter as specified by the...
stackexchange/codereview
I have written this program to search for a value in an array using sequential search. And well, I've been trying to implement the same algorithm using recursive structure. is this a good implementation? or is there any other way to make it a little more...? (I'm not sure if..., to say if there is a better way to imple...
stackexchange/codereview
I have a class that creates user accounts and to avoid SQL injection attacks, I am using the following functions to sanitize both the user name and password inputs: $admUsername = filter_var($_POST['admUsername'], FILTER_SANITIZE_STRING); $admPassword = filter_var($_POST['admPassword'], FILTER_SANITIZE_STRING);...
stackexchange/codereview
Given a string A = "Hello world" and another string B = "wor", I have to print ("TRUE" or "FALSE") whether the characters in B are present in A. For example, if B = "ollw l" the result should be TRUE; if B = "worlds" the result should be FALSE; if B = "ww", result is FALSE. It has to be done in O(n) time complexity. My...
stackexchange/codereview
I have a dataset on which I need to do entity resolution. Hence in this dataset some records have links some records have address. I need to build a logic for it to identify each record and put the acronym as a unique identifier. Example Dataset ID LINK acronym address 1 google NAN a 2 google...
stackexchange/codereview
I have function that processes text and returns it in altered state. Result of the processing is a property list with following properties of interest: :success - t if processing finished correctly :text - complete changed text :changedLines: list of changed lines as 2 element vectors [number-of-line line-text] (numbe...
stackexchange/codereview
I have written a small JavaScript class that makes use of setInterval to create a delayed loop for iterating an array. I've used this technique in the past but never utilised a library to do so (and as a result it produced quite messy spaghetti code), and so I wrote up this: var DelayedLoop = function() { }; DelayedLo...
stackexchange/codereview
I have implemented the following in order to handle JS XHR requests coming from HTML pages. Is there a better way to do this with OWIN? public class Startup { public void Configuration(IAppBuilder app) { app.UseFileServer(new FileServerOptions { FileSystem = new PhysicalFileSystem(st...
stackexchange/codereview
The following code creates a WhatsApp button. How would you improve this code? document.body.insertAdjacentHTML('beforeend', ` <aside class="cbwtphone_wrapper"> <img class="cbwtphone_icon" src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/WhatsApp.svg/1024px-WhatsApp.svg.png"></img> <...
stackexchange/codereview
I'm toying around with a Caesar cipher that supports keys. The cool thing about it is that, unlike most Caesar ciphers you see, it works with byte arrays, not just strings, so you can encode text as well as files and other data. Of course, if you're looking for true security, you wouldn't want Caesar encryption of any ...
stackexchange/codereview
I'm doing a code-challenge problem: Captain Kaban: National Treasure is a popular football simulation game which can be played on most smartphones. In this game, you put up a team of 11 players and then compete in either story mode or multi-player mode. As you might already know, a football match is played by 11 player...
stackexchange/codereview
Question: What do you think about this design and the implementation? This is a simple networking framework for IPv4, IPv6 TCP client and TCP server for Linux and MS-Windows in C++14. It uses a single-thread solution around the system call select(), that is IO-multiplexing. Connect and network read are asynchronous, ne...
stackexchange/codereview
Given a 2d array, the problem is to find the largest sum, where each subsequent is >= the previous digit but < all of the 'neighbour' digits. You can only move up, down, left and right. My solution will run in \$O(N*M)\$ time with \$O(N*M)\$ space (please correct me if I'm wrong). The solution is as follows: Start at a...
stackexchange/codereview
Since I am working alone on this, I would like someone who would take a look and point out any mistakes or things I could have done better. My questions: How could I improve this big switch statement? Is there any obvious beginner flaws? The executeModeration is a method I call when a command is an moderation command...
stackexchange/codereview
We have been working on a mutation analysis tool for Haskell tests called MuCheck. It accepts any Haskell source file, and a function name to mutate, applies a defined set of mutation operators on it, and runs the specified test suite on it. The mutation of code is accomplished using the haskell-src-ext library, and SY...
stackexchange/codereview
I am relatively new to python and am trying to teach myself. I have created a python program that will take the current month's first three letters, and add one letter to the first, two to the second and three to the third. It does this by converting the month's characters to an ASCII number, then adding X to that. Ple...
stackexchange/codereview
I am trying to create a function that I want to use in my real data. Is there any way to optimize the following function? This is a function I created to filter the data. filter <- function(x, m, delt) { series <- x series_filtered <- rep(0,length(series)) delta_t <- delt # time step between data points (hours) ...
stackexchange/codereview
Here's one way to solve the serialization problem in c++20, using a json library: #include <functional> #include <unordered_map> #include "json.hpp" namespace nlm = nlohmann; class properties { struct property_info { std::function<void(nlm::json const&)> deserializor; std::function<nlm::json()> serializ...
stackexchange/codereview
I had an uneventful afternoon, so I thought I might try and write a string formatter. This is based on the documentation I found here. #include <string> #include <vector> #include <map> #include <ostream> #include <iostream> #include <exception> #include <stdexcept> #include <typeindex> #include <cstdint> #include <cst...
stackexchange/codereview
I have created a simple class that maintains a pool (with maximum size) of objects. It acts like a connection pool (that is where the name came from - initially it was used just to maintain a pool of SMTP connections). When an item is retrieved - if the pool is not empty, a value is retrieved from it; if it is empty, t...
stackexchange/codereview
My Application looks something like this (Screenshot). To Control the URL Routing i am using a Angular Js Router. On Click of Store of the Side Panel the StoreList Appears. And on Click of the Edit, the portion template gets fetched from Spring MVC and displayed along with the details. I have written the Code for app.j...
stackexchange/codereview
Thank you to everyone for the feedback provided to the initial version of this program posted here. Please find below the newest version, revised based on the comments provided, for review and comment on how I can further improve my coding. I have removed the portion of the program that checked if the provided value wa...
stackexchange/codereview
I came across a problem in my NodeJS app, which I solved by creating a method called groupBy. The purpose of this method is simple: take an array, and a function which will select a field from an element in the array. Each element in the array should then be grouped based on this field and returned as an object with th...
stackexchange/codereview
I am trying to implement a Doctor/patient scheduling system. It would be great if someone can review my code and suggest how I can improve it further. I would like to know how to have a date-based calendar for this. I also want some idea on how to protect a patient record data from one doctor to another. One more feat...
stackexchange/codereview
I have been provided a text splitter class that will take a text input and use re.sub to make replacements when matches are found and also splits sentences up and stores them in a list. I had an idea to improve the code by storing the expressions in a list and iterating over the list and for each expression looking for...
stackexchange/codereview
I've been learning C# for about a month and have a finished game. I would like some constructive feedback on my progress so far. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using...
stackexchange/codereview
I'm a beginner in OOP programming and I'm wondering what is the best way to put all the windows and functions of a window application in the code. My biggest questions are: Am I using classes and function in the right way? There is an efficient way to create windows and widgets? Why do I see so many peoples inheriting...
stackexchange/codereview
The point of this method is to emulate Java hashCode(). In order for this to work the project must have arithmetic overflow allowed under: project --> compiler options --> advanced. Public Shared Function GetHashCodeStr(value As String) As Integer Dim finalCode As Integer = 0 For i As Integer =...
stackexchange/codereview
I am writing the Cloud function for Parse whose purpose is to update my database with a provided array of data objects. The main problem are the nested promises, which doesn't look right. Any help to refactor this code or any other critiques? /** * Updating multiple object arrays: * Look for object with the same ...
stackexchange/codereview
I Have a class which calls a method, that will convert an excel file, and each sheet will be a DTO, and returns a list containing those DTOs List<Object> dtos = convertExcelToDTO(); Inside this list, I have 9 DTOs. But I need to get some attributes individually from each DTO. At first, I could iterate that list doing ...
stackexchange/codereview
I'm writing a service that receives a list of Latitude/Longitude objects, prepares them for transaction, and then calls a web service to write them to the organization's Mainframe. According to the existing application that I'm replacing, the Mainframe can only accept "chunks" of up to 5 Lat/Long values at a time, how...
stackexchange/codereview
I'm looking into basic API examples and I've got the following to work as I want it to. Is there a better way to determine the direction of latitude and longitude? It feels like I could do it better. import requests from time import strftime, localtime response = requests.get('http://api.open-notify.org/iss-now.json')...
stackexchange/codereview
I have created a program that turns a decimal into a fraction: package main import ( "fmt" "github.com/retep-mathwizard/utils/convert" "github.com/retep-mathwizard/utils/input" "math" "strings" ) func main() { fmt.Println("Input your decimal") num := input.Strin...
stackexchange/codereview
I have recently coded my own authentication system and wondered if there was any way I could make it better? I coded it with Laravel 5.4. getView is called on Route::get and onPost is called on Route::post use Auth; use App\User; use App\Http\Controllers\Controller; use Validator; use Redirect; use Illuminate\Http\Requ...
stackexchange/codereview
I've been learning C++ on and off, and recently learnt about overloading and templates. I wanted to used these concepts to create classes about matrices using std::array. Note that this has to be compiled using std=c++17 or newer, following a clarification involving constexpr. #include <array> #include <iostream> temp...
stackexchange/codereview
I have solved the given assignment below is the question and getting correct answer. but my question is is there any way to reduce the complexity of my code or there is any other efficient way to write the code? Given two arrays of integers output the smallest number in the first array not present in the second one....
stackexchange/codereview
I am interested in learning a more succinct (or better performing) way of writing the following working code. I just figured it out but it is pretty messy. This program takes a file full of daily financial transactions for x number of months (for example), and appends each line to the appropriate month file to create s...
stackexchange/codereview
This is one of the projects on freecodecamp. I would like a review on my code. Thanks in advance. Javascript: var answers; function formatSearchString() { var searchString = document.getElementById("searchBar").value; var words = searchString.split(" "); searchString = words.join("_"); return searchString; }...
stackexchange/codereview
I am creating an interactive quad(heat) map of USGS Quadrangles wherein each quad has 12 different attribute fields CSV attached to the JSON using papa.parse. Currently, I am using two different radio buttons to select values that update an interactive web map. I plan to expand the values available to toggle (e.g., ins...
stackexchange/codereview
I have an array and must fill another one. Depending of a boolean I copy first or second element and the rest must be as is... Currently I do it like this (data has the desired info): const newArray = []; newArray[0] = theBoolean ? data[0] : data[1]; for (let i = 2; i < data.length; i += 1) { newArray[i - 1] = data[i...
stackexchange/codereview
This is my solution to a "vacancy test" task. I'm not sure at all if I have correctly implemented the task, but here is my solution. Goals of code: Parse rows of table from a URL and extract some data (make a list of jsons from this data). Parse rows of table from a URL and download PDF (link is placed inside a row). ...
stackexchange/codereview
Trying to solve this combinatorics problem, I wrote some functions to count the number of unordered distinct factorizations of an integer n into k distinct parts. The following function builds up a list of unordered distinct factorizations of n with largest part at most m. duf' :: Integer -> Integer -> [[Integer]] duf'...
stackexchange/codereview
I've been asked to output the users name, what day of the week they were born on, output a line from a poem corresponding with the day they were born on, and their scores for a vark test. We were told to calculate the month of birth as a number and find the number/ month. This is the first bit of code I've done and I'm...
stackexchange/codereview
I'm just getting started with F# and was writing some unit tests for some functionality I had written. In the interest of brevity, I decided to create some lists of the different test cases and just run through them all in one test instead of creating separate test methods for each one (I'm not focusing on that design ...
stackexchange/codereview
Didn't post on the Codereview for a while but trying to learn Golang now and wrote my first utility a few days ago and will be glad to see what I did wrong here and what can be done better. This tool is used to check public repositories in out GitHub organization and compare such a list with another list which conta...
stackexchange/codereview
I'm using Bootstrap 3 as the front-end framework for this. It is quite simple but I feel I'm doing it wrong. I'm sure this code can be optimized not to duplicate the $('a[href=""]') functions but I just can't wrap my head around it. For now, this code is only for mobile. I'll have to figure out how to control the menu ...
stackexchange/codereview
I started Python 2-3 months ago, but I really haven't done much since then, just little things. Yesterday, I wrote this simple quadratic equation solver. You can give \$a, b\$ and \$c\$ any value, but they must all be integers. I really want to know what you think about it. from math import sqrt while True: tr...
stackexchange/codereview
A section of my page lists 'Workshops' and just uses objects from a queryset. The page/site uses bootstrap. <div class="row my-4"> <div class="container"> {% if workshops|length %} <div class="row"> <h3 class="text-uppercase font-weight-bolder font-title ml-4">Learn through workshops</...
stackexchange/codereview
Is this implementation of binary search correct? Any special or edge cases that I missed out? Maybe it should be optimized for elements that are less than the first element of the array or greater than the last element? bool binarySearch (int* array, int arraySize, int element) { if ( arraySize == 0 ) { ...
stackexchange/codereview
I am having trouble with applying to 3 steps needed to proof correctness, most likely because I did not formally study CS or Mathematics and am still learning about loop and class invariants. The three steps: Initialization Maintenance Termination My understanding of the invariant is that, at the end of the partition...
stackexchange/codereview
I have been working with Rcpp to perform a forward and backward Hilbert Mapping. Below is an implementation based on this code. My application is in genomics and I may be dealing with enormous datasets, which necessitates the use of very large integers for indices, so I found this code for passing large integers to R ...
stackexchange/codereview
I am trying to see if anyone can help me in making this Excel VBA code a little faster in rendering the data from the weather site I am using. Maybe instead of getting all 14 days it includes in the site, could I get help in getting just 10 days? Any help is much appreciated. Thanks! Sub MiamiWeather() Dim HTTP As...
stackexchange/codereview
I wrote this login program as part of my project for school. Should I use my implementation of a login program, or is there some standardized patterns of login programs, like the ones in encryption where we use made packages instead of writing our own? Also, please correct me if am doing anything wrong or if there is a...
stackexchange/codereview
I have written a function that is designed to convert an object into an array of key/pair values ("flattening it") like so: Input { "a": true, "b": { "c": 500 } } Output [ ["a", true], ["b", [ ["c", 500] ] ] Here is the code I have written to do it: function isCyclicObject(object, seenObjects) { ...
stackexchange/codereview
I wanted to see if I could implement codepen-like or jsfiddle-like window resizing by using simple boxes and CSS grid without any third party libraries. Live version can be found here: https://codepen.io/Aquazi/pen/bYomRN?editors=0011 HTML, a simple div containing 3 divs: <div class="container" id="topcontainer"> <d...
stackexchange/codereview
I am making a program to find primes between the given range of numbers. Unfortunately, the algorithm I created is too slow. Do you have any ideas of how to optimize the code? import java.io.*; import java.util.*; public class Main { public static void main(String[] args)throws IOException { Scanner s =...
stackexchange/codereview
I am using a class which is taking care of minimum value so far. Please let me know of any improvements or suggestions. class MinStack { Stack<Node> s1 = new Stack<>(); public void push(int x) { if(s1.isEmpty()) { s1.push(new Node(x,x)); } else { s1.push(new Node(x,Math...
stackexchange/codereview
Is there possibly a way to take out the nested if statements without losing the error reports? I am just learning SDL and would like to further simplify my code so that it is readable by me when I look at in a few days. #include <SDL.h> #include <iostream> int main(int argc, char *argv[]) { SDL_Window *window = nu...
stackexchange/codereview
I keep getting a time limit exceeded for this solution to SPOJ Prime1. I need to print all primes within a given interval (with intervals as large as 105, and numbers as large as 109). I've tried everything I could think of to get this code to be faster but nothing works. What can I do? #include <iostream> bool ispri...
stackexchange/codereview
I am very new to this and am using php and MySQLi to create a form which will create a record in a third table. This works fine but I can't help but think that there is a way to do it with a single query rather than a query for each table as I have now. The third table is called tblcars, and I will use this form to b...
stackexchange/codereview
Hi I have written the following code in Python. Any improvements on my code will be appreciated as this is my first shot at pygame! There are some problems in terms of functionality, to state briefly ball sometimes gets stuck within a paddle, which I am continuing to resolve import pygame, sys import random from mat...
stackexchange/codereview
I've been developing a small screen sharing project for the last months, it's a desktop application, pct protocol based. I'm going to show the logic and the code and I hope to get reviews. I would like to hear every suggestion. First of all, I'm using a service called Desktop Duplication API. Here's the C# implementati...
stackexchange/codereview
In learning golang, I wrote a small CLI utility that will take paths as arguments and list out their md5 hash as hex strings. Included are two flags that alter functionality, --check | -c which takes an additional file, hashes both, and returns whether or not they match (and exits with the proper return code), and --te...
stackexchange/codereview
The exercise is part of a React course in which I'm currently enrolled. Description: The way it shall look on desktop-screen: How it shall look on mobile: Here's my solution: HTML <div id="display"></div> JSX // Manager bundles the single components together. var React = require('react'); var ReactDOM = require('r...
stackexchange/codereview
This program's main function is to: Watch a directory. If there are new files, insert those as entries into the database. Delete the files from the directory. My below code runs well, but I want to optimize it and I think it needs better error handling. import os import time import mysql.connector import MySQLdb imp...
stackexchange/codereview
I am putting together a php Rest API service that uses Controller and Command pattern to handle requests. Firstly, in Apache config I redirect all requests to a single end point, /api/v1/index.php. RewriteEngine On RewriteRule ^/api/v1/([^/]*)/([^/]*)/* /api/v1/index.php/?command=$1&subcommand=$2 [PT] RewriteRule ^/api...
stackexchange/codereview
When creating little games or other programs I often need multidimensional arrays. Usually I just do the simple std::vector<std::vector<T>> thing for simplicity's sake. However, this runs way more allocations and the data is not stored in one contiguous location, which brings some drawbacks with it. To fix this I wante...
stackexchange/codereview
The University Library where I work is in the process of redesigned our home page. One of the features we wish to include is a widget to display the current hours. Unfortunately for a variety of reasons this must be done using client side scripting instead of a PHP script which pulls from Google Calendar. After much...
stackexchange/codereview
I have implemented few functions of a linked list. Feedback is welcome. Please note I have specifically avoided using pointer to pointers. #include <stdio.h> #include <stdlib.h> // Node data structure inside the linked list. struct node { int data; struct node* next; }; struct node* BuildOneTwoThree(void); void...
stackexchange/codereview
I have the following program that I wrote as an exercise for learning C. It simulates the scheduling of processes according to round-robin, first-come-first-served, shortest-job-first, and priority-scheduling policies. It reads a list of processes from a file, which are represented with the format [id] [cpu burst lengt...
stackexchange/codereview
I have a rails app with a Project model. Each project has usages which is numeric data. I need to get all the usage for each month and year. I also need to get usage for specific months and years across multiple projects. Instead of writing one large service file with raw SQL queries to handle this, I have decided to e...
stackexchange/codereview
Here is my JSON in which I have only three reportRecords just for demonstration purpose but in general sometimes we are getting pretty huge JSON, then it doesn't have three reportRecords only, it has large number of reportRecords. { "parentRecords":{ "reportRecords":[ { "min":1.0, ...
stackexchange/codereview
I am just wondering what, if any, more elegant ways might exist to write a script to accomplish the task that the script below accomplishes. The script works, so I don't need it to be debugged, but I want to learn more. Other commands to be used, other ways of structuring it, etc. I have taken it through shellcheck. Ye...
stackexchange/codereview
I am pushing an Excel file to the server and then reading it's contents. XLS and XLSX files need to be read differently, but the DLL that I'm using has the EXACT same function calls for both types. If I use a 'dynamic' type, I can save a lot of lines of code and avoid redundancy. However, I've been told many times befo...
stackexchange/codereview
Some time ago I started with a small Ruby project. I call it social_aggregator. This software aggregates information from different networks to one xml-stream, which you can reuse. For instance on your personal website to show some of your activity to your audience or as your personal news feed. I've a built in Webric...
stackexchange/codereview
I have written the Rabin-Miller test in Python and ported it to C. But somehow, the C version is ~20 times slower on my system, and I am not sure how. Anyway, here is my code. Python import random import time def rabin_miller(n): if n in [2, 3, 5]: return True if n < 2 or n % 2 == 0: return Fal...
stackexchange/codereview
I came across this problem and I was wondering if you could help me to improve my solution. Problem: Count the number of ways you can reduce a deletable prime to a one digit number. A "deletable prime" is a prime number where you can delete digits one at a time and still have a prime number. Input: a number < 8.00...
stackexchange/codereview
I've written a piece of code that determines if a piece toast with butter lands on the butter-side or not, depending on its initial velocity and the table height. The code is written in Mathematica and to be honest, it was my first time writing a piece of code in this language (which wasn't a simple calculation of an ...
stackexchange/codereview
I have a time, in seconds, which has the possibility to be very large. I wish to convert said time into the "appropriate" rounded, readable format. I already have code which achieves this, however it's not very efficient (and contains a whole bunch of magic numbers): String readable = decayTime + " minutes"; if(decayTi...
stackexchange/codereview
We were asked to create a Base64 encoder for Assembly x86-64 on Linux. Was wondering how my code below could be improved, be it notation or anything else. We only had Assembly for 3 months so I'm not really that used to any kind of particular notation. That's a reason why I'm asking. Thanks for your help ! SECTION .dat...
stackexchange/codereview
Details about code: Dataframe (x) shape: (20494463, 31) In this Dataframe, each id shows up multiple times with different events and the event dates. What I'm looking for is the time between the first time event A occurs and the first time event B occurs for each id feature_final.index.values is another Dataframe whos...
stackexchange/codereview
I have made the algorithm that split text into n-grams (collocations) and it counts probabilities and other statistics of this collocations. When file is more then 50 megabytes it takes long time to count maybe some one will help to improve it. import math import re import csv from itertools import zip_longest from dat...
stackexchange/codereview
I have a dice game called Pig to play (a simple google search will show rules, they are included in my .js file as well). I am new to JavaScript and the main goal of this code review is to give me an understanding of whether or not I am designing my code well (in terms of performance, as well as readability/beautifully...
stackexchange/codereview
I coded this program as a challenge for /r/dailyprogrammer. Basically this program can convert any number from any base to another base including negative bases as long as the input is coherent. Did I follow the Python 3 standard or commit any obvious mistakes? I am also wondering if I can efficiently filter out nonsen...
stackexchange/codereview
I got a database with members, each member has a list of sports they do. now I want to loop through a listbox and add every selected item to my database. This is my database : And this is my code : foreach (var item in sportCheckedListBox.CheckedIndices) { int sportindex = Convert.ToInt32...
stackexchange/codereview
Could be useful? OrdinalIgnoreCase s1 = "a"; OrdinalIgnoreCase s2 = "A"; Assert.AreEqual(s1, s2); Where: public class OrdinalIgnoreCase : IEquatable<OrdinalIgnoreCase> { public static StringComparer Comparer { get; } = StringComparer.OrdinalIgnoreCase; public static implicit operator OrdinalIgnoreCase(string ...
stackexchange/codereview
Consider this code: public class DataSt { DataType time; DataType memory; public DataSt(DataType time, DataType memory) { this.time=time; this.memory=memory; } private static void saveIt(DataSt p, Data...
stackexchange/codereview
I'm looking for improvements of a code that filter the output of git status --ignored and git status --ignored -bs commands. I feel that it could be more readable but I'm not sure how since I'm a beginner. Please, all your critics and advice are welcome. This is my code: function filter(str, regExp) { const reg = n...
stackexchange/codereview
This PHP class connects to and queries the database MuSKL. I am a novice, and I ask you to comment on the approach and style of code. <?php class MysqlAccess { private $dsn = 'mysql:dbname=bid;host=127.0.0.1'; private $user = 'bid_root'; private $password = 'e1e2e3e4e5er'; private static $_db; pr...
stackexchange/codereview
Challenge Given a list of numbers and a positive integer k, reverse the elements of the list, k items at a time. Specifications The first argument is a path to a file. The file contains multiple lines. Each line is a test case represented by a comma separated list of numbers and the number k, separated by a semicolon....
stackexchange/codereview