instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
This is a function for JavaScript validation:
var alpha = "[ A-Za-z]";
var numeric = "[0-9]";
var alphanumeric = "[ A-Za-z0-9]";
function onKeyValidate(e,charVal){
var keynum;
var keyChars = /[\x00\x08]/;
var validChars = new RegExp(charVal);
if(window.event)
{
keynum = e.keyCode;
}
... | stackexchange/codereview |
I have written the following program in C# to display an ASCII pyramid.
public static void method1()
{
int k;
int kCond = 5;
int i;
int inc = 0;
for (int p = 0; p <=5; p++)
{
for(k = 0; k <= kCond; k++)
{
Console.Write(" ");
}
kCond--;
for(i=0; i<=inc; i++)
{
Cons... | stackexchange/codereview |
Background
I tried to make the underlying container resizable if the corresponding weights are provided. But then, I faced a problem: C++ doesn't have standard interface for resize() or push_back()/insert(). As a result, I had to fall back to solving a much more simple problem:
Select an element in [container.begin(), ... | stackexchange/codereview |
I have a list [5,2,7,4,3,2,0,8, 9,100,99,98,97,93,92]
i need out [100,99,98,97]
but i am getting 4, 3, 2, 100, 99, 98, 97, 93, 92
`arr=[5,2,7,4,3,2,0,8, 9,100,99,98,97,93,92]
z=[]
l=[]
for i in range(len(arr)-1):
if(arr[i]==arr[i+1]+1):
if(arr[i] not in z):
z.append(arr[i])
... | stackexchange/codereview |
I am currently using an enum in my Android application to display time periods:
Weekly
Bi-Weekly
Monthly
Quarterly
Yearly
I created the enum like this, because I wanted to know the description, and (roughly) number of days:
public enum SpendingPeriods {
WEEKLY("Weekly", 7),
BIWEEKLY("Bi-Weekly", 14),
MONT... | stackexchange/codereview |
I have a piece of code that checks if two strings are anagrams. I would like this to be as pythonic as possible.
def are_two_string_anagram(string1, string2):
if len(string1) != len(string2):
return False
def char_count(string):
char_count = {}
for s in string:
char_count[s]... | stackexchange/codereview |
I've just started learning Golang and was solving some problems which required me to read lines of text from a file. I decided to abstract away the reading part so that I can use Go's range keyword to iterate over lines of any "file".
Here is my attempt:
import (
"bufio"
"fmt"
"io"
"io/fs"
"os"
... | stackexchange/codereview |
Good evening. I am studying mathematics at the moment, so I have little to no formal education in actual computer engineering. However, I am trying my hands at learning Python because I will need lots of it for my future career. I hope you can point out any bad practices or mistakes on my part, so that I can fix them e... | stackexchange/codereview |
FizzBuzz in VBA. Takes start and end numbers as arguments. Will handle any pair of integers to +- 2 Billion or so, determine whether the sequence is increasing or decreasing and output numbers to the immediate window.
Public Sub PrintFizzBuzz(ByVal startNum As Long, ByVal endNum As Long)
Dim currentNum As Long
... | stackexchange/codereview |
After working on it, my regenerating reserve vector may not be so bad after all. (In this stackoverflow question, I presented a vector with a regenerating reserve, faster at push_back when reserve can't be predicted).
Deque may be cool, but the vector is faster. So, I ameliorated my Vector, with two reserves: one befor... | stackexchange/codereview |
Objective: Given a set of sequences ( eg: step1->step2->step3, step1->step3->step5) ) arranged in an array of lists, count the number of times every contiguous sub-lists occur
Where I need your help:
The code below works, but is very slow on my original dataset (100M sequences, with 100 unique steps). Can you help me ... | stackexchange/codereview |
I'm a hobby programer and I had an idea for pixelating images and I wrote it.
I was wondering how would a better programer write the same function.
I want to learn and I think that this would help me a lot to see how code is supposed to be written. Also my code is quite slow and I would like to make it quicker.
I use P... | stackexchange/codereview |
This is a LeetCode Problem
You have a pile of stones presented as an array. On each turn you must merge k consecutive piles of stones, starting from any pile you wish. You must continue merging piles until you are left with one pile only. You must do this with minimum overall cost, where the cost is the sum of the ong... | stackexchange/codereview |
I have implemented a method which will send one data to the server if it (Raspberry Pi Pin Input HIGH, in this case) occurs within 10 seconds. If this doesn't happen within 10 seconds then I should send some other data.
This implementation works for me, but I think that there should be another better implementation.
Sc... | stackexchange/codereview |
My script takes a CSV file of strings and then creates an XML file for Android and a .strings file to be used for iOS. It separates each locale meaning that a file will be created for each language.
This has come in handy so far, making localising mobile apps easier. However, I am always seeking feedback so let me know... | stackexchange/codereview |
This code is the basic structure I use for coding plugins. It's pretty standard with the settings extended and the each loop. However, now I'm working on the best way to provide setters/getters. For example, I may want to do something like:
var sp = $("#container").wScratchPad();
alert(sp.wScratchPad('size'));
sp.wS... | stackexchange/codereview |
I have a table with this schema
ID, int primary key
PathKey, string not null
InsertDate, datetime not null
Value, int not null
In the table there are a medium-large number of records. 1632 different pathkey and 645627 total records
The PathKey is not unique (because I store also the old values).
You can identify a r... | stackexchange/codereview |
My application compiles and seems to work correctly, but this is my first C project so I welcome any criticism. I developed this in Pelles C with no standard lib. Efficiency and optimizations are more important to me than readability or conformity. The parts that I'm particularly concerned about are marked with comment... | stackexchange/codereview |
This has been asked a couple of times but here is my implementation in C++. I have 11/12 solutions completed. The 6th test case which has 200000 intial scores and Alice has even more scores causes my program to timeout. Below is the problem statement and the code. My question is, am I missing something in code complexi... | stackexchange/codereview |
Note: This was originally posted at SO, and as per the recommendation moving to this form.
In my effort to learn JS on the backdrop of SVG development, I got lot of help from SO so far. The answer to previous query was the best to understand closure; its usage and caveats in very short time. While continuing on the sa... | stackexchange/codereview |
I am participating in a challenge and one of the challenges was to write a script to sort a list of software versions (ex: 1.0, 1.3.2, 12, 1.3.0). Here is the my solution:
def answer(l):
return sorted(l, key=lambda s: [int(i) for i in s.split('.')])
print(answer(eval(raw_input())))
In this code, I am essentially ... | stackexchange/codereview |
Recently, I've been trying to get back into Haskell, so I tried coding up a LZSS implementation. I realize this is much more easily implemented imperatively, but I wanted to challenge myself. The last time I tried doing this was back in my Functional Programming class and it went poorly. It worked, but the compression ... | stackexchange/codereview |
From this library I wrote, I have created this function in Swift, but I'm not happy with the implementation. Can anyone suggest a better way to do this? I really don't like changing counters inside for-loops...
extension Array {
/// Removes all items that conform to the given closure
mutating func removeAll(cl... | stackexchange/codereview |
This program is a practise exercise in using instance methods, and also in recursion which I struggle to get my head around. I want to know how my technique for the recursion could be improved, and if there's anything else which could be made more efficient.
The program creates a Rational object type (a fraction) which... | stackexchange/codereview |
This arose out of the incident where it was realized that WMI could not be expected to be reliable across all various computers. The next thing I looked at was API which was positively awful to work with. Based on a suggestion, I decided to try and use tasklist. Note that efforts was made to ensure there are no disk I/... | stackexchange/codereview |
The objective of the game is to guess the hue, saturation, and lightness values of a given color swatch across ten rounds.
https://github.com/shreyasminocha/guess-the-hsl
https://guess-the-hsl.now.sh
This being my first svelte project, I'd like some insight into best practices, especially svelte-specific ones.
Versio... | stackexchange/codereview |
Just wondering if this basic performance test between an untyped array of arrays and a vector (typed array) of arrays in Actionscript 3... is fair and balanced? It's simple, designed to test random access on the collections as well as pushing new items, etc. Here goes:
import flash.events.Event;
import flash.utils.getT... | stackexchange/codereview |
When onSaveInstanceState() is customized it should always call the same method on the super instance first.
I usually write:
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
saveState(outState);
}
private void saveState(Bundle outState) {
outState.putParcela... | stackexchange/codereview |
In the code below, I take the number of square the user wants, then calculate the size of each square (so that they all fit in the container.)
I then define var square as in the 3rd line of code. I find this string pasting technique very hard to read and error-prone. The general question is thus: Is there a better way ... | stackexchange/codereview |
I am currently working on a small internal rating system for clients to be able to prioritise my work based on what client pays best. The input data is the hourly rate they are paying and based on that they should be divided into categories in are the range from A-D. The first setup looks like this:
def category_for(cl... | stackexchange/codereview |
I solved the following question
You are asked to ensure that the first and last names of people begin
with a capital letter in their passports. For example, alison heck
should be capitalised correctly as Alison Heck.
Given a full name, your task is to capitalize the name appropriately.
Input Format
A single line of in... | stackexchange/codereview |
I have a method that's called thousands of times during one process. Before optimization, it called the database on every execution. After optimization, it only calls the database when required. However, this optimization came at the expense of readability.
Method before optimization:
private function addHandleToOrg( $... | stackexchange/codereview |
This is my game manager script and is there anyway i can improve this code.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.SceneManagement;
public class GameManager : Singleton<GameManager>
{
public Game game=new Game();
public PendingGam... | stackexchange/codereview |
When reviewing a Graham scan convex hull algorithm implementation, I wrote the following function in an answer:
giftWrap :: [Vector2] -> [Vector2]
giftWrap vs = result
where
-- Decides whether to keep or reject vertex b.
-- Vertex b is provisionally kept if a left turn occurs there; the result
-- is final... | stackexchange/codereview |
This is the Microsoft Word portion of the application described in this question. It is considerably simpler than the excel portion of the project. Any classes not defined in this question can be found in the excel question. The full source code for this project including the UI can be found in my GitHub repository.
Th... | stackexchange/codereview |
I have these two classes and they should remain separate classes, but I have a feeling that this could be implemented more efficiently and with less duplicate code. After googling around I still didn't figure a better way, so perhaps someone here could point me out. Ideally I want to get tick() method from Clock and ju... | stackexchange/codereview |
I have a method I created which is a custom indexOf(). This code seems ugly to me so I was wondering if anyone could recommend a cleaner and perhaps faster implementation of my method.
public static int myIndexOf(char[] str, char[] substr, int index) {
if (str == null) {
throw new NullPointerException();
... | stackexchange/codereview |
I'm writing code to create a list of new areas for patches of conserved land within a watershed based on the current size distribution of conserved land patches that are in the watershed now.
I'm generating a new random area based on a normal probability density function fitted to the log-transformed distribution of t... | stackexchange/codereview |
I am using a driver that retrieves data from HW (Driver) and a display (Viewer) that will output data to the user.
The user calls a trigger function to initiate the getting of data from the Driver. The Driver's constructor accepts a "publish" callback function to be called when data is ready.
The Viewer receives a "get... | stackexchange/codereview |
This is one result of my work on Project Euler to learn Java. I'm interested in how well this conforms to best practices as well as any recommendations on efficiency. (I'm pretty sure this code is a lot more efficient than it is readable, but it's not deliberately obfuscated, I swear! :) )
import java.util.ArrayList;... | stackexchange/codereview |
I am trying to validate time entry. ArrTime is the time entered by the user from the UI. I am trying to make it so that when a user attempts to add a time, it must be between 8:45 and 17:30. Is there any thing wrong with my code? I am not very good at JavaScript so I have a feeling it is that, but if you can help me at... | stackexchange/codereview |
I have a Ruby program which should solve the following problem:
Consider the divisors of 30: 1,2,3,5,6,10,15,30. It can be seen that
for every divisor d of 30, d+30/d is prime.
Find the sum of all positive integers n not exceeding 100 000 000 such
that for every divisor d of n, d+n/d is prime.
require 'prime'
cl... | stackexchange/codereview |
I don't have a formal description for this problem, but here are the parameters:
Given a string S check that each opening bracket has a matching closing bracket.
Any nesting violations are invalid.
Assume multiple nested sets of similar brackets are invalid.
Because the nesting level matters and we can't just arbitra... | stackexchange/codereview |
I am working on Word Ladder - LeetCode
Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that:
Only one letter can be changed at a time.
Each transformed word must exist in the word list. Note that beginWord is no... | stackexchange/codereview |
I am currently writing a C# console application. Part of it is, that the user needs to enter a fairly complex system name. To make it easier I wrote a function that uses a string[] keywords and auto completes the string the user is typing in - on the run (which makes it different to this post in my opinion)
The code is... | stackexchange/codereview |
Looking for some feedback on the Two Sum LeetCode problem. Looking for feedback on code style in general, use of var, variable naming and initialization, return placement, and any other feedback or optimizations I could make.
Problem
Given an array of integers, return indices of the two numbers such that they add up to... | stackexchange/codereview |
Short Story: I created this website last year in plain HTML, CSS, JS which I can't even remember how I wrote that and now I can't even edit the website without breaking it. So, I'm re-writing everything in a proper way using React.
So, I'm making a website using React ( I'm still learning ) and I got confused about us... | stackexchange/codereview |
This is not your typical mastermind question, I am not trying to find the right answer. Merely to check the answer and provide a result as fast as possible. The function signature cannot be changed, however the contents are just my best guess. Here's what I've come up with :
typedef int Code[100]; /* Arbitrary size */
... | stackexchange/codereview |
UPDATE: After getting "a kind of" affirmation from various platforms( my discussions on twitter, reddit, other stack overflow posts,etc) I have written an article on this style of view binding. Kindly check that out too, as that's the only place i am currently updating my latest version of the code (It's not behind t... | stackexchange/codereview |
I've builded a 2D-shape area calculator. Currently it can only calculate:
Circle
Rectangle
Triangle
Originally I was thinking how to encapsulate the parameter(s) into a class, Parameters, so that I could delegate the responsibility of loading those parameter(s) to a specific shape, for example, a rectangle will need ... | stackexchange/codereview |
I want to use something like Setting.RES_WIDTH in my code without the need for a getter function (i.e.: custom getter, enum's .name(), .toString() or .valueOf()).
Someone suggested using a final class, so I wrote this:
public final class Setting {
public final static String RES_WIDTH = "resolution_width";
... | stackexchange/codereview |
I've been studying data structures and have taken a stab at implementing a doubly LL in JavaScript. Please review and advise on any additional improvements and optimizations. I'm more interested in feedback particularly regarding the implementations of removeAt(), contains() and getItem() methods as they share similar,... | stackexchange/codereview |
I am building TODO app using MVVM pattern. I have a recycler view that holds all the daily tasks.
My goal was to update the task to be "complete task" and change the row layout when it's completed.
I managed to do that successfully, however, I am wondering about the way I did that.
My implementation:
Every time the tas... | stackexchange/codereview |
I'm playing around with using Dapper with Mediatr in a .NET Core API. It's all working nicely.
Its a learning project for me so I am just putting together a system that will hold user details against some training qualifications/certifications.
I am just building out the api's first and then will have a look at a UI.... | stackexchange/codereview |
This is a Target number solution finder which I made with tkinter and is where the user enters a number they want and enters 4 other numbers to find the sum to make the number they want.
This is a screenshot on what the GUI looks like:
This is the code for the project:
from tkinter import Tk, Frame, Label, Button, Int... | stackexchange/codereview |
I had an half an hour interview with Microsoft for an intern position. I was asked to generate a list of alternatively positioned odd and even number out of an array of unsorted integers. I guess it was below the interviewer expectations since I did not get the offer. Can any one give me some hints on improving my c... | stackexchange/codereview |
I am creating some small project for my portfolio. It will be an app written in .NET and React but for now I've done backend part and I seek code review. I wanted it to be aligned with DDD principles and clean architecture. Can you review it and tell me is there any areas to improve to make it more readable and scalabl... | stackexchange/codereview |
I am able to develop this matrix but I think code can be improved. I am creating a map on which each rectangle may have zero through many list items with their titles (still need to add code for adding titles):
var width = 600,
height = 600;
var margin = {top: -5, right: -5, bottom: -5, left: -5};
var zoom = d3.beha... | stackexchange/codereview |
My code writes, reads, and removes program settings in the registry. I'm using Visual Studio 2019 and my target Framework is .NET Framework 4.8.
I'm looking for more elegant functions.
Is there error handling I missed in these functions?
How can I optimize the code?
I have the following functions at the moment:
public ... | stackexchange/codereview |
I'm developing a Social Engineering Awareness Training Application. This is the focus of my thesis for my undergraduate degree. This will be a multi-part review request, however, if you want to see the entire application, it can be found on GitHub. For this request, I'm looking to see how my EmailController is set up a... | stackexchange/codereview |
I was wondering if this implementation of insertion sort could be improved. Are there any things that I have done wrong?
template<typename Element>
void insertion_sort(Element arr[], size_t size) {
size_t index, index_sorted;
for (index = 0u; index < size; ++index) {
auto temp = arr[index];
inde... | stackexchange/codereview |
I have solved an assignment (Exercise 3) from the MOOC Object-Oriented programming with Java, part II, but I'm not enrolled in said course.
Assignment Summary:
Make a simple calculator. You may create a Reader class that
encapsulates the Scanner-object in order to communicate with the user.
The Scanner-object can... | stackexchange/codereview |
This code searches for the word "Disbursements" and copies all of the rows with data below it, including the row with the specified word. After the rows are copied to a new sheet, the unnecessary rows below the contiguous range of data are deleted. In order to search for the last cell, I used a function that finds the ... | stackexchange/codereview |
I have multiple threads calling a method, passing in an ID and value.
I have two constraints I need to place on this method:
Only one of the same ID can be processed at a time. Additional threads with the same ID must wait.
Subsequent calls with the same ID must be processed in the order they were received.
Here's an... | stackexchange/codereview |
I implemented this peak finder for practice. I have tested it. Everything looks pretty good to me. Please let me know if there is any improvement I can make.
Peak Finder
Let input be an array. input[i] is a peak if input[i] >= input[i + 1] and input[i] >= input[i - 1].
Implement a recursive algorithm of time complexi... | stackexchange/codereview |
I'm an intermediate-level C++ programmer aiming to write reference-quality code. I hope to learn about any mistakes in this piece of code and blind spots in my understanding of concepts. Notes:
The stylistic use of public:/private: on every member is subject of a question on Software Engineering.
I'm not totally sure... | stackexchange/codereview |
I've found pretty simple and clear pattern which can be used to make any data members truly private (invisible, inaccessible) without affecting class behavior (no prototypes and Object.XXX magics required).
This "Lock & Key" pattern uses closures with ES6 Symbol's and Proxy approaches:
const MyClass = (()=>{
const... | stackexchange/codereview |
I tried implementing visitor patter and have questions about my usage of is and as keywords. Is there a big performance hit when using them?
class Program
{
static void Main(string[] args)
{
List<IVisitor> visitors = new List<IVisitor>();
visitors.AddRange(new List<IVisitor>()
{
... | stackexchange/codereview |
This script checks specific directories for *.pgp files. It returns a list of the filenames and modified dates. It then returns a list of the filenames and modified dates, each on a new line. I'm new to Python, like literally two weeks now and this script was written for a specific work purpose, but I'm betting it coul... | stackexchange/codereview |
I have got an array of javax.security.cert.X509Certificate and need to convert it into an array of java.security.cert.X509Certificate.
My thoughts when I implemented the following code was that I must keep the order of the certificate thus I used a LinkedList. In the first step I am converting all of them into the new... | stackexchange/codereview |
My goal is to grab some data inside asp.net core app on server from external source via wcf service. In future i would like wcf responses to be cached on server and provide asp.net app clients "normal" errors if they appear.
Some things to notice: I'm using .net core 2.0 and generated wcf service proxy with a help of W... | stackexchange/codereview |
I am programming a parallel tree algorithm where I have to send data to other processors. The amount of data is not constant. Therefore I have to work with dynamic arrays using malloc() and realloc(). Since I am new to C I wondered if I am doing it right. I do not get any error. But I think that is not proof enough, th... | stackexchange/codereview |
Another try at this problem in LISP. This time rather than generating every possible row combination for the melody I tried to calculate the best combination directly. Unfortunately there's a problem - the output is a messy list full of vectors and single values. Is there a good way to concatenate vectors together with... | stackexchange/codereview |
First post. I posted this on stack as well but somebody suggested I post it here too/instead.
I wrote a shortest-path script for a Unity game project, and while it works, it gets so slow when applied at scale that it crashes Unity when executed. This is to say, it works slowly for a single test character, but scale is ... | stackexchange/codereview |
Below is an exercise project I was doing on a certain educational site.
It is supposed to parse a given (static address in this example) URL for html data, search articles of a given type there and then save their text data on your drive.
It is working fine but since there're no code reviews on this site, I'm sort of w... | stackexchange/codereview |
I have taken over maintenance of some code, and have restructured it after reading some documents about PSR-2:
<?php
function calc_p()
{
list($arg1, $arg2, $arg3) = func_get_args();
switch($arg1) {
case 'ebook':
$bp = 5;
$tax = .08;
break;
case 'audio_book':
... | stackexchange/codereview |
I really like c#'s Using statement as it allows you to pair Open statements with their corresponding Close/Dispose statements in an elegant way which matches C#'s syntax.
I realised that something similar can be achieved in PowerShell; e.g. Push-Location should be paired with a Pop-Location, and this can be enforced by... | stackexchange/codereview |
Please review my class. It uses iconv() (it's probably not the best solution however I haven't found any better alternative to change unknown characters).
<?php
/**
* Class NiceUrl
*
* Creates friendly url from given name
*/
class NiceUrl
{
/**
* Whether convert to lower
*
* @var bool|null
... | stackexchange/codereview |
Newton's method for finding cube roots states that for any given \$x\$ and a guess \$y\$, a better approximation is \$\dfrac{(\dfrac{x}{y^2} + 2y)}{3}\$.
What do you think of this code for finding a cube root in Scheme?
(define (improveguess y x)
; y is a guess for cuberoot(x)
(/ (+ (/ x (expt y 2)) (* 2 y)) 3))
(... | stackexchange/codereview |
I've published a Vim plugin that nudges visually selected lines up or down, which for the most part seems to function as designed. However, I believe there are likely ways that this plugin could be improved.
Questions
How do I register a movement that takes an optional amount?
In other words how can this plugin dif... | stackexchange/codereview |
I wrote the following prefix tree data structure for this Leet code challenge.
Implement a trie with insert, search, and startsWith methods.
Note:
You may assume that all inputs are consist of lowercase letters a-z.
However it keeps timing out on the long input. As far as I know the insert, search and startsWith ... | stackexchange/codereview |
I have a query that can be seen on this fiddle and I'm relatively new to PSQL, having a few months of experience.
DB Fiddle
As mentioned in the comment I should put the query here and the code is perfectly working. The reason for this question is to find an improvement on it.
The link to the third party is to show the ... | stackexchange/codereview |
I am sure you can find many weak spots, please let me know about them.
My main question is if this is a sensible approach to separate the construction phase from the constructed phase.
Basically I have a set of objects that needs to be transformed into similar (but different) objects. Once transformed I want to be abl... | stackexchange/codereview |
Assume $ is not the browser. Now have to implement $, it will take a string, which is a query, it will use the querySelector to select the element. (Reference: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector)
$('text')
Now implement jquery like functions addClass and removeClass. (Reference: ht... | stackexchange/codereview |
I am traversing two objects that may share a common ancestor. To make the code small enough to show here, I have changed it into two dictionaries with values. As you can see, a_d and b_d are the inverse of each other. The idea is to step into each dictionary step by step until we find an overlapping value for the two. ... | stackexchange/codereview |
<?php
require_once '../db.php';
session_start();
// Check if user is logged in using the session variable
if( $_SESSION['logged_in'] != 1 ){
$_SESSION['message'] = "";
header("location: error.php");
} else {
$username = $_SESSION['username'];
}
//here starts the code to insert data on DB, and to make a s... | stackexchange/codereview |
I am using the following code to format an address retrieved using the Google Places API. According to Googles docs they recommend looping through the response based on what you list in the componentForm array. Is there a way to optimize this code and simplify it without having to specify the individual if statements?
... | stackexchange/codereview |
An entry for the August 2016 Community Challenge
I slightly modified the input and output to suit the snippet tool, and also because I really like the mapped output with the basins.
I have been golfing a lot recently, which always impacts my coding style. You will find a number of possibly too smart one-liners. I am lo... | stackexchange/codereview |
I have made a timeline component that can have multiple milestone/major/minor as sub components nested within timeline container component. I have also added a side navigation for that lists all Milestones. Therefore I append range property to TimelineMilestoneComponent which contains the top position value(offestTop) ... | stackexchange/codereview |
I'm new to data science. I wrote this script for plotting all different kinds of iris data set scatter plot. trying not to plot something with itself . how can I optimize my code ?
from sklearn.datasets import load_iris
import matplotlib.pyplot as plt
import numpy as np
import pand... | stackexchange/codereview |
The Problem
I'm asking to see if there are methodically better solutions to this problem. The situation is as follows, I am receiving an array of events, they are marked by timestamp and there is a designated order of events. That is, that after every event of type a, there should always be a corresponding event b.
Du... | stackexchange/codereview |
I have been attempting to have a method call, with a parameter, inside of a ternary operator to simplify some code.
Code:
if (window.addEventListener) {
btnArray[index].addEventListener('click', function() {
doMassClick( btnArray[index], nameArray[index]);
});
} else {
btnArray[index].attachEve... | stackexchange/codereview |
In our latest Veracode scan for an application, I have come across the issue of Improper Resource Shutdown or Release. It is pointing at a function. Here's what the code looks like:
Imports System.Data.SqlClient
Public Class DAL
Public Shared ConnString As String = ConfigurationManager.ConnectionStrings("connect... | stackexchange/codereview |
Having coded in Objected-Oriented style my entire programming career, it's hard to adapt to functional style fully.
I implemented a simple Hangman game:
{- A simple gameLoop of hangman.-}
module Hangman where
import qualified Data.Set as Set
import qualified System.IO as IO
import qualified System.Random as Rand
impor... | stackexchange/codereview |
I'm fairly new to Java, arriving in the "future" from C and returning to type safety from Python. I've programmed an algorithm to return the weight of the heaviest path from the root of a binary tree to one of its leaves.
Each Node in the tree has a weight (its data). The weight of the path is the sum of all of the N... | stackexchange/codereview |
I implemented a MVC Framework with Generic DAO and I would like know if is correct. I did not have developed yet the MySQLDAO.
My controller class
class ClienteController {
public function __construct() { }
public function actionSubmit(){
$objCliente = new Cliente();
$objCliente->setNome($_POST['nome'... | stackexchange/codereview |
Part of my standard modules deal with my company's employees and linking them to/from various data sets.
The following are a series of enums/functions to handle peoples' names, namely an Enum for advisers and functions to:
Provide a collection of names associated to each adviser (e.g. their name before/after getting m... | stackexchange/codereview |
This is my implementation of a red-black tree that I'm planning to use in a little personal project. It works fine, however I'm not sure that the code is very good as I'm only a beginner, and insertions are 4x slower than in a broken implementation I found here (it stops working after a few insertions).
I was wondering... | stackexchange/codereview |
Below is my River Flood Warning System version 2 build 1. After following the help and advice given for version 1 the whole program is looking and behaving much better. The original code would only allow for a single river to be processed at a time, and even then not all rivers would process due to stage/flood inaccura... | stackexchange/codereview |
This code completes under a second, however its seems like I've taken the "Mr. Bean" way around getting there.
The goal is to get the average number of orders processed in a single day based on how many days exist in the current database. The loadcount column represents how many orders are processed in a single batch. ... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.