instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I'm wondering if there is a better (cleaner?) method than my current implementation. I'm currently encoding a PHP SimpleXMLObject (USPS Tracking API) to JSON and looping through said JSON object via JavaScript to operate the front-end.
Examples from my current implementation below:
Function to display dialog implemente... | stackexchange/codereview |
I have a 3D data set made of a certain number of points (x,y,z) that cover a certain region of space. Using the scatteredInterpolant object I can interpolate this data set over a grid to produce a rectangular mesh. Note that the mesh may extend to regions that are not defined by the data set; in fact, after the mesh ge... | stackexchange/codereview |
I have a script for parsing BAM files. The script's input thus is lines like
E00489:44:HNNVYCCXX:3:1101:24890:5616 99 22 16052014 150M
E00489:44:HNNVYCCXX:1:1110:21704:27345 99 22 16052044 150M
E00489:44:HNNVYCCXX:1:1217:2372:69519 163 22 16052044 150M
E00489:44:HN... | stackexchange/codereview |
I am currently developing a Django Rest Framework API with TDD. I have 15 tests and counting for two views, which doesn't seem right to me. It takes me a lot of time to write the tests and a lot of the testing logic seems redundant to me, especially because I have to check permissions for each test request. Furthermore... | stackexchange/codereview |
I would like general ideas on improvement for this implementation of Minesweeper I wrote in C++. I am not really good in OOP yet, so I want ideas about how I can refactor the code by adding objects (or structs) without it getting too bulky.
/*Minesweeper C++
Written by:-Teodor D.*/
#include<iostream>
#include<time.h... | stackexchange/codereview |
I wrote a bash script for reviewing scientific articles. It adds a blank page for notes and creates a new landscape file. I'm sure it can be made better code wise. Any suggestions?
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Usage example: ./bashscript src.pdf"
exit $E_BADARGS
else
NUM=$(pdftk $1 dump_data | grep 'Nu... | stackexchange/codereview |
I want to save and load an arbitrary Java String in a Text node in a XML file using the Java DOM API.
The Transformer and the DocumentBuilder already escape and unescape predefined entities such as ", &, ', <, > and a few other characters by replacing them with with ", &, ', <, > and &#c;, where c ... | stackexchange/codereview |
import random
def qsort(qslist):
small = []
big = []
if (len(qslist) < 2):
return qslist
elif (len(qslist) > 1):
pivot = qslist[int(random.randrange(len(qslist)))]
for x in range(len(qslist)):
if qslist[x] <= pivot:
small.append(qslist[x])
... | stackexchange/codereview |
Given a number as a string, no leading zeros, determine the sum of all integer values of substrings of the string.
Given an integer as a string, sum all of its substrings cast as integers. As the number may become large, return the value modulo 10**9+7.
Example:
n='42'
ans=4+2+42=48
Full problem: https://www.hackerra... | stackexchange/codereview |
I wrote a working code and was wondering if it could be shortened as I saw a lot of similarities in my loop and if statements. I hope it's possible as I want to make it a bit cleaner.
I had to print a list of license plate numbers of all cars that went over the speed limit, as well as the average speed of each of those... | stackexchange/codereview |
My background is with C and python, and Javascript is fairly new to me, so I'm wondering if this is reasonable code.
In particular, is it appropriate to use the higher order function makecb in this context, or is there a better/shorter/clearer way of writing it?
$(function(){
var controllers = {
"#showhelp": { na... | stackexchange/codereview |
What my code does
I am building an Express API server with mongoDB as my database.
I have a list of players which must be added to 2 mongoDB collections (teamList and countryList).
The data schema is similar. My code is as follows.
Data Model model.js
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
v... | stackexchange/codereview |
Below a function which answers: is there a winner in tic-tac-toe game?
Also, there is a test suite I wrote for it.
def is_win(field):
# check horizontal
N = len(field)
for i in range(N):
if field[i][0] != 0 and len(set(field[i])) == 1:
return True
vertical = [field[j][i] for j in... | stackexchange/codereview |
I have created canvas (800x400) - and filled it with a grid. It works but the rendering of the grid (lines) takes around 3 seconds, which seems excessively long. Am I doing something wrong?
var drawGrid = function(w, h, id) {
var canvas = document.getElementById(id);
var ctx = canvas.getContext('2d');
ctx... | stackexchange/codereview |
I was looking to replace my use of axios with just fetch, but I didn't like how verbose fetch was with regard to handling JSON output (having to have a separate then call just to return the json). Unfortunately calling text() first to see if it's a JSON response and then only calling json() if so seems wasteful because... | stackexchange/codereview |
I want to improve my C++ skills ( or learn it properly ) so I decided to work on some algorithms for maze generation.
Here is the gist:
https://gist.github.com/imerovic/0cb7396bb67b345235054b5027d2eadf
I have some doubts about memory management and if I'm using pointers properly.
Please review it because I wanna know ... | stackexchange/codereview |
It's pretty typical for Linux command-line utilities that deal with files to accept either a file as input, or stdin. It's also pretty common for them to be able to output to a file or to stdout.
These should be supported:
python myprogram.py input output
cat input | python myprogram.py > output
python myprogram.py in... | stackexchange/codereview |
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... | stackexchange/codereview |
I just finished a challenge (noted above) and I was wondering how good is this approach or is there some simpler solution that I am not aware of?
If you have a different solution, try to explain the code for people less experienced than myself rather just than pasting a solution.
Here is an example text file to be read... | stackexchange/codereview |
Given an array and a string and bounds within which to search, I need to find the position of the string within those bounds.
What I want to optimise:
If possible, I want to re-design the function so that it doesn't have 10 optional arguments, some of which are not actually optional depending on the size of the array... | stackexchange/codereview |
I implemented a 2D counterpart of std::array named array2d in C++17. It is an aggregate like std::array, and provides similar interface. The goal is that if you know how to use std::array, then you will find yourself at home using array2d. Any comments are welcome :) For better viewing experience with highlighting, you... | stackexchange/codereview |
Here is my code for Tarjan's strongly connected component algorithm. Please point out any bugs, performance/space (algorithm time/space complexity) optimization or code style issues.
from collections import defaultdict
class SccGraph:
def __init__(self, vertex_size):
self.out_neighbour = defaultdict(list)
... | stackexchange/codereview |
I wonder, what might be the best (most pythonic) way of implementing multiple observerables in Python. There are multiple objects, which should be able to register themselves at one or multiple observables.
Shall I simply submit the update methods, like this:
class MethodObservable():
def __init__(self, data_sourc... | stackexchange/codereview |
In view of the recent LinkedIn breach, would anyone care to review my data access routines relating to user access?
This is a standard node.js module, accessing a Postgres database.
(function () {
'use strict';
var crypto = require('crypto'),
hash = function (pass, salt) {
var h = crypto.c... | stackexchange/codereview |
I'm trying to wrap my head around OOP but so far I feel like I'm just moving functions into classes and calling them methods. I am trying to create a "Rock Paper Scissors" game using OOP best practices.
Yesterday I asked someone to review this code and was told that my use of OOP was akin to being handed an electric d... | stackexchange/codereview |
Here's my solution for Project Euler Problem 30. Any optimizations in time, space, or style would be greatly appreciated.
from timeit import default_timer as timer
def digit_powers(exponent):
def power(k):
return int(k) ** exponent
if exponent <= 1:
return "The exponent must be at least 2."
... | stackexchange/codereview |
Another graph algorithm, this time to create a priority or build order. Provided with a starting List<Project> and List<ProjectWithPrerequisite> the algorithm will return the order to build them in. For a list of projects a, b, c, d, e, f and their corresponding prerequisites where a, d means that a is a prerequisite f... | stackexchange/codereview |
I had to solve three problems on graph theory that I solved by implementing a utility function and 3 functions, one for each of the problems.
The problem set defines the input for all my functions as a E+1 x 2 matrix (they call this an edge list) where the first row V E contains the number of vertices V in the graph an... | stackexchange/codereview |
I am trying to learn AngularJS as a start to my revival of learning, I think that I am getting the hang of it so far, but would like to see what I can do differently with some super simple applications, hopefully I can see what I need to work on this way.
First thing is first, a basic calculator.
This is a super basi... | stackexchange/codereview |
To begin, I have an XML file at /Users/gaze/lab/lab/gpib_lib/out.xml that contains lines like...
<MemberCall method_name="setFastCoupleMode" callee_name="GPIB_7280" fname="/Users/gaze/lab/lab/gpib_lib/../apps/capbridge/capbridge.C" lineno="394" colno="9" />
<MemberCall method_name="setInputLineFilter" callee_name="GPI... | stackexchange/codereview |
I'm looking for feedback on this here code. Is readability an issue? Is it good to mess with all these data types in Java (e.g. strings and Chars and using .equals() and != to compare data from different data types), or is there an easier way to do it? And in general, how can I improve this code?
Write a method named... | stackexchange/codereview |
I wrote a small program that collects the server status, caches it for a certain amount of seconds, and then sends that to a mothership server. It's broken down into a few pieces, starting with main.py, config.json, and a few small 'libs' to keep things visually separate:
main.py
#!/usr/bin/python
import os
import sys
... | stackexchange/codereview |
I'm a solo developer and a friend told me that my code is not very readable. I always write code trying to keep it DRY while not taking longer than it would take doing it in an "easier" way.
Here is the skeleton for My Profile feature which will initially have read-only values. When the user wants to update it, it turn... | stackexchange/codereview |
The below script is one I made to check the disk space on mounted partitions under Debian Wheezy. I tried adding a -d switch to force printing out the used data, but its main purpose is to run as a cron job, and email the administrator if any disks are below a certain threshold.
What I'm looking for is to make sure it'... | stackexchange/codereview |
Which is best practice for creating an enum-like lookup for templates? I enjoy being able to bring up my templates with VS IntelliSense so either works for me.
Option 1 (enum/Dictionary combo):
public enum Template
{
AccountInformation = 1,
Registration = 2,
Signed = 3
}
static readonly IDictionary<Template... | stackexchange/codereview |
I've written a framework in MVC. I call it Midget MVC, as it's so darn small. The reason I wrote it is because I wanted a lightweight and extensible framework to use in projects. It eventually got abandoned due to it's break-ability and my lack of experience in the subject. However, I've got a bigger project I'm workin... | stackexchange/codereview |
This little program was written for an assignment in a data structures and algorithms class. I'll just note the basic requirements:
Given an inputted string, the program should check to see if it exists
in a dictionary of correctly spelled words. If not, it should return a
list of words that are obtainable by:
ad... | stackexchange/codereview |
I have a function which does the following:
When new Post Entity is added some fields in Category table are updated.
When new Thread Entity is added the same fields in Category table are updated.
Because of this, some lines are completely the same.
public function postPersist(LifecycleEventArgs $args)
{
$entity =... | stackexchange/codereview |
Problem
We have a tool which produces output as json array
We have another tool which anticipates input as ndjson (newline delimited json)
I need to write a converter to transform json array to ndjson
Sample json array
[
{
"Property1": true,
"Property2": 0.1,
"Property3": "text"
},
{
"Property1"... | stackexchange/codereview |
After reading about the Shunting-yard algorithm, I decided to try to make a expression parser, before trying to make a actual language parser, using it. The way i translated the algorithm into C++ code seems pretty compact, so there is really not much code to post:
Shunting-yard algorithm(in C++):
#include <iostream>
... | stackexchange/codereview |
I have a comboBox and a TextBox in the View and when the view is loaded, the ComboBox should be populated. After that when a user selects particular item from the ComboBox, its related ValueMember should be displayed in the TextBox.
The View doesn't know about DAL or Presenter and, it only has properties and events.
... | stackexchange/codereview |
I found this code in our project and it just feels like the wrong way to do what it seems to be doing
id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for (symbol in results) {
// this just selects the first symbol in the results
}
Presumably it actually d... | stackexchange/codereview |
I am working on a service that is supposed to run on a large installation 24/7. Once the software is deployed, I will most likely not be able to make any changes anymore. This is my first time working on a network application so I want to make sure I am not making any obvious mistakes.
60 instances of this program are ... | stackexchange/codereview |
I am a student, trying to learn C++11 and data structures. I would like to ask you to to review my code.
I have spent some time and analyse similar questions on Code Review and it gave me basic idea what I should pay attention to.
I have learnt about the rule of three, but I am not sure if my implementation is correc... | stackexchange/codereview |
This code uses recursion to solve the 01Knapsack problem. It evaluates all the item permutations that can be added to the knapsack and checks if it gives the maximum profit. What else could have been used to get a faster solution?
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.... | stackexchange/codereview |
This is my first real attempt and playing with GoLang
In my project, I will be contacting multiple carriers to get their "estimate". I have carriera at the moment, but there will be carrierb etc too.
As I will be wanting to use the same struct from the package "estimate", I decided that I should share the struct in one... | stackexchange/codereview |
I'm fetching a string that is JSONP, and looking to convert it to JSON.
I'm using the following regular expression for matching (for removal) the padding on the JSON.
([a-zA-Z_0-9\.]*\()|(\);?$)
In python, here's the line I'm using for converting the JSONP to JSON:
apijson = re.sub(r'([a-zA-Z_0-9\.]*\()|(\);?$)','',... | stackexchange/codereview |
My goal is to work out which lines a piece of text is on within a set of paragraphs.
For example, in the image below:
I want to find text starting from "Maecenas non" to the next instance of "nisi" and return that the sentence starts on Line 3 and ends on Line 6.
My attempt is below, and it does the job, but I don't t... | stackexchange/codereview |
I often need to update properties using the out parameter of the standard TryParse methods. However, use of a property as out or ref parameter is not allowed. So, I wrote my own implementation of the TryParse method MyTryParse using the generic extension method, which is supposed to work for all standard value types.
C... | stackexchange/codereview |
Here is a search implementation for my tree. It searches each node in a breadth-first manner first, but it goes deeper in a depth-first manner, in the event it needs to go deeper. I know there may be multiple identical items in the tree (well, not my current use of it, but I still need to presume that), so it just re... | stackexchange/codereview |
The following is code I'm running to FIRST, SECOND, THIRD and so on until SEVENTH with a master query and a query of query.
As it's clear that I'm using the master query for each of FIRSTCONN, SECONDCONN etc., I want to have only one master query and the rest subqueries.
Is this an efficient way to do so?
How can I ma... | stackexchange/codereview |
I made the following code in C, which is supposed to create a list of booleans $n + 1$ long, such that the $i$'th element is true if $i$ is prime and $i$'th element is false if $i$ is not prime (starting the count from zero). So for n = 10, it is supposed to give [false, false, true, true, false, true, false, true, fal... | stackexchange/codereview |
I'm dealing with a searching query where the user will pick from menus and checkboxes the variables-criteria I'm passing to the toWeb method and a list will be returned. This works fine but I'm going to add two more variables and it's already hard to follow.
public List<newEvent> toWeb(string name, string egk, string ... | stackexchange/codereview |
Some folks told that a two-dimensional array can solve almost all the problems, but let me disagree with that. That's why I made this Deca dimensional array sort function. The array must be symmetrical, meaning that it must contain elements corresponding to all the existing elements in the other dimensions.
I didn't pu... | stackexchange/codereview |
I'm working on a clone of Hunter Story. You shoot monsters with your bow. Recently I implemented collision detection, this is all working correctly, and I don't think the code needs any dramatic optimisations. The only thing I'm a bit worried about is how exactly I implemented it. I'm not sure if it complies with OOP s... | stackexchange/codereview |
A while ago I started solving Binary Puzzles (also known as "binero"). Not having done much C++ in my life, although it feels like I have a pretty good understanding of C++ in general, I figured it was time to do some C++!
The rules for a Binary Puzzle are:
The entire grid should be filled up with 1's and 0's.
There c... | stackexchange/codereview |
I need to get the numbers in a string like "1,2,5-9", the function should return a list with these values [1,2,5,6,7,8,9]
Here's what I did. Is this the best way or there's something simpler/better?
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function getNumbers(stringNumbers) {
var num... | stackexchange/codereview |
I have a superclass with several subclasses. Each subclass overrides the "solve" method with some a different algorithm for estimating the solution to a particular problem. I'd like to efficiently create an instance of each subclass, store those instances in a list, and then take the sum (or average) of the estimates t... | stackexchange/codereview |
Problem on Algorithm for same like 'stations'
Problem is to use weather data to run ARIMA model fit on each group of like named 'stations' with their associated precipitation data, then finally execute a 30 day forward forecast. Looking to process specific same named stations and then next process the next unique same ... | stackexchange/codereview |
I've been working on a library that includes a list-like structure, which I use internally multiple times to store different types of structs. However, I'm not entirely confident with my ability to safely manage memory in C yet, so I'd appreciate if someone could let me know if there's anything wrong with my code (it s... | stackexchange/codereview |
I'm writing a static class to log my application errors into a text file. I am planning on using this as a library on any application I intend to develop in the future. Please let me know how I can improve this more and what could be changed so it would perform better.
public static class Logger
{
public static voi... | stackexchange/codereview |
I've written a script that gets a list of all groups in AD along with a few specific properties for each group (DistinguishedName, CN, Type, and Description). Then it goes through each group and, for each member of type "user" (to exclude computers, servers, etc.), it gets the user's full name, title, and their manager... | stackexchange/codereview |
So some background here.
I recently discovered the ease of LXC containers on Ubuntu. I've been building some 'test' containers locally for testing things I develop on Ubuntu, but the evil thing is that creating these containers then getting all the software I want in the container and everything set up the way I want ... | stackexchange/codereview |
1) Postgresql
2) User has_many :reports
3) Report belongs_to :user
3) Report belongs_to :publication
4) Publication has_many :reports
4) Publication scope :photos, -> { where(publication_type: 'Social::Photo').where(show: true) }
4) Publication scope :tweets, -> { where(publication_type: 'Social::Tweet').where(show: ... | stackexchange/codereview |
I am using asp.net core entitiy framework. The page displays the customers. The user can add new customers or delete existing ones. I am looking for ways to improve my code.
Here is my cshtml page
@Html.Partial("Index")
@model ecommerce.Models.Users
<h6>Add a new customer</h6>
<form asp-controller="Customer" asp-act... | stackexchange/codereview |
A binary relation \$R\$ on a set \$A\$ is called reflexive if and only if \$R(a, a)\$ for every element \$a \in A\$.
I want to know if there can be any improvements made on the function below to make it more efficient.
def reflexive(R):
'''
@param R : set containing homogenous elements
'''
result = []
... | stackexchange/codereview |
I was asked to give a high level design of Pacman. Please review the OOP design, this is not a full implementation. only the design is important here.
Please comment if the design is missing anything. or can be improved? The main problem I think is to keep Single responsibility, I am having a hard time here not have al... | stackexchange/codereview |
We have modified the tee program with your suggestions from the previous pull request. Did I implement well? I would like to optimize the program even more, what else could I improve? What other possible issues are being implemented?
previous question Implementation of the "tee" utility program
#include <stdio.h>
#incl... | stackexchange/codereview |
I'm working on a writing platform and am using a modified version of the Levenshtein distance algorithm to track a writer's engagement with their writing. It tracks not only words added to their content, but also rewards editing by including words removed and words substituted in the count.
Here's my algorithm in Ruby ... | stackexchange/codereview |
I created a web service which can be called from a form to add new users to the system. The final service will add users to Active Directory and Exchange in the required format (please note that FirstName and LastName are required fields in the form, so they will never be null):
using System.Collections.Generic;
using... | stackexchange/codereview |
I have a string, where I am only interested in getting the numbers encapsulated in single quotes.
For instance if I have the string "hsa456456 ['1', '2', ...]
I only want the 1 and the 2 and whatever numbers follow
To do this, I have the following code:
import re
#pattern = re.compile("dog")
#l = re.findall(pattern, ... | stackexchange/codereview |
I have a project in school. This is the game that I've created, but I need to make some improvements. I put a swing.timer inside the action event to create a score/time decrements effects. But, I have a problem because there is a textfield inside the frame and I can't type any words there because of the timer.setRepe... | stackexchange/codereview |
This is my implementation of lowest common ancestor problem,I tried to solve it using square root decomposition
pre processing time : O(n)
query time:O(sqrt(h))
h -> height of tree
This was LCA on spoj
Well i added comments in my code and
My approach very well explained here with every line of code https://www.gee... | stackexchange/codereview |
Basically, I need to regroup keys by values from an object to an array
An example worth a thousand words in my case, as I don't know how to clearly explain my problem.
Here is my input object:
{
"Data 1": 0,
"Data 2": 1,
"Data 3": 3,
"Data 4": 0
}
What I should output:
[
["Data 1", "Data 4"], // da... | stackexchange/codereview |
I need to write a custom reducer utility. It should take a dictionary of reducers and a publish subject to return a state, with a dispatch method to dispatch actions and notify the publish subject.
It should be 100% type-checked with TypeScript, compatible with strict compiler options, and should only use type-inferenc... | stackexchange/codereview |
Here is a simple Tic Tac Toe game. I would like to know how I can improve this code further.
#include <iostream>
#include <cctype>
#include <array>
#include <random>
enum struct Player : char
{
none = '-',
first = 'X',
second = 'O'
};
std::ostream& operator<<(std::ostream& os, Player const& p)
{
... | stackexchange/codereview |
Considering I've got an exam on Spring tomorrow, I figured you could review a small example application I whipped together as preparation (and as such, I'd prefer the emphasis to be on Spring-related concepts).
Its functionality is straightforward: you start with a list of 3 games and you can edit or view its details,... | stackexchange/codereview |
Purpose
The code is for a timer with a starting time of 25 minutes. The goal is to have a very simple pomodoro application with Start, Pause and Reset. Also you can tick a box to make the UI stay in front of the desktop so you always have the timer in front of your eyes.
Hierarchy
main.c
/src
structures.h
/fe... | stackexchange/codereview |
I wanted to implement a bubble sort in Scala following the steps described in: http://www.bbc.co.uk/education/guides/z22wwmn/revision/3
import scala.collection.mutable.MutableList
val result = bubbleSort(List(3,2,4,1,5))
def bubbleSort(list: List[Int]): (List[Int]) = {
def doIteration(list: List[Int]): (List[Int], ... | stackexchange/codereview |
I'm doing a bunch of work with echonest audio objects (as returned by the echonest API) in the Python CLI and rather than having to recreate them each time, they can be saved.
This bit of code reloads them all, referenced via a dict:
def get_saved(directory = 'audio/', extension = 'en'):
return glob.glob(directory ... | stackexchange/codereview |
I've written some code using python having tried to comply with OOP design for the purpose of collecting name of the app, price and developer name from i-tune site by going deeper until there is a limit [which can be toggled within my script] to stop as it has millions of links to go. It is working impeccably at this m... | stackexchange/codereview |
I'm looking for a better way to create objects based off of a value of a string.
Consider the following:
Input file:
//each Vehicle type has a list of different options
//whose length varies, I provided a simple case
van*2006*dodge*grand caravan*green~
car*2010*toyota*corolla*red~
truck*2005*toyota*tundra*black~
Clas... | stackexchange/codereview |
I am supposed to be creating a doubly circular linked list, but I am now have problems creating the actual linked list. Is there a problem with the classes? Also, for the assignment, the list is suppose to be a template class, but now I just want to get the code to work.
#include <iostream>
#include <string>
#include ... | stackexchange/codereview |
Background
I was looking for a simple Event Broker or EventBus (whatever else keyword you can come up with) to use in a small(-ish) WinForms application. In Java I was using org.greenrobot.EventBus for a long time, but couldn't find a comparably established and simple solution in C# - everything looks to be enterprise ... | stackexchange/codereview |
I have some simple tests written, however, the names are not good...I think, any suggestions on better names? I'm not really sure how these tests should be named.
I'm looking for a format or pattern I can follow.
[TestClass]
public class DoorTests
{
[TestMethod]
public void DoorIsNotVirtualIfNameStartsWithLett... | stackexchange/codereview |
namespace SharpDream.Api
{
public enum SourceType
{
Test,
Xml
}
public class UserFinder
{
private IUserInformationSource _sourceType;
private IParser _parserType;
private string _source;
public UserFinder(SourceType sourceType)
{
... | stackexchange/codereview |
This script sorts files from current directory into known subdirectories. it is built for speed because the keyword database used can be up to 20kb. each line of the database has subdirname,1,keywords?string where the number is how many points this keyword is worth. It then counts these points and puts the file to the ... | stackexchange/codereview |
Please review my code for above problem. I tried to cover the maximum possible boundary condition. Any optimizations or new easy and fast solution are welcome.
public class CheckStringAreRotationalyEquals {
private static boolean areRotaionalyEquals(String s1, String s2) {
boolean areRotaionalyEquals = Boo... | stackexchange/codereview |
I'm trying to work HTML5 canvas video into a React application while making the code as clean as possible. What kind of improvements should be made to improve the performance utilizing the React to its fullest potential?
import React, { Component } from 'react';
import './App.css';
import video from './video.mp4';
impo... | stackexchange/codereview |
Please tell me what you think of this its my first try and I have only been learning Python for 3 days now, works with both 'index' and 'find':
data = ["XBOX 360 | 150 | New",
"PlayStation 3 | 35 | Broken",
"Windows 8 | 275 | New"]
Id = 0
one = data[Id].index("|")
two = data[Id].index("|", one+1)
prod... | stackexchange/codereview |
I'm working through a practice problem that is having me build and modify a linked list over a series of steps. I am particularly interested in knowing if there's a more elegant way of prompting the user to input a data value for a new element in a linked list (see step 5 below).
I'd also like to know if there's a bett... | stackexchange/codereview |
I have tried to implement a copy on write string class with value semantics and reference counting.
I wanted to support indexing, so I have overloaded the operator[] and to differentiate between the l-value and r-value usage it is returning a proxy object.
#include <iostream>
#include <string.h>
class proxy;
//Referen... | stackexchange/codereview |
I was wondering if there was a more efficient way of taking strings that represent dates with the pattern being mmddyy or mmd yy or m d yy and converting them into a DateTime object?
111110 would be 11 11 10
111 10 would be 11 1 10
1 1 10 would be 1 1 10
The spaces are either ' ' or '\0' (the input I am given is not ve... | stackexchange/codereview |
I am building a form with multiple select option fields. I am trying to only show the next field if it exists as a combination in the CSV file I am reading in. It's working fine right now and I am using onchange for each select field to call the next function.
Is there a way to reduce to the code and make it more e... | stackexchange/codereview |
Auto populate user info from database when user inputs employee number. The same applies when the user inputs name/extension/mobile/email/
Some code is duplicated. Is there any way to make it shorter?
$(document).ready(function () {
$("#empnum").change(function () {
var fourdigitpatrn = /^[0-9]{4}$/;
... | stackexchange/codereview |
I'd like some advice about any better or cleaner way to implement this class, if there's any.
I made it using this answer, posted on Stack Overflow, as reference. A lot of problems arose when I switched C function pointers to std::function due to the lack of the equality operator on it, so I ended up implementing a in... | stackexchange/codereview |
The interface and some of the implementation is take from Boost. However, it is intended to be transferable between projects by only copying one file. I have removed most of the policy classes in favor of more condensed code that requires less files to move around. Please tell me where my strengths are as well as where... | stackexchange/codereview |
I'd like to have a generic way for validating user provided email with a bias toward ease of use. Does the following do so in a clear way for implementations that have the URL interface available? The sample input below is only intended to exercise the range of expected input and demonstrate it works. The UI is not in ... | stackexchange/codereview |
I ported the Star Trek 1971 game to Clojure to help me learn more about the language and functional programming in general. You can see the entire game on Github. The game plays (you can start it with lein run). Instructions are i game or you can see the first link to get more details on the history or gameplay.
While ... | stackexchange/codereview |
So my project was to make an algorithm that finds a path out the maze using "backtracking" to help. This is my first time attempting to solve anything with backtracking so I want to be sure if what I did is actually backtracking and if it is an efficient way to apply it to my problem. Bellow is the main logic:
public v... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.