instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
Right now I have this messy method to collect the deck statistics while building a window that will display those statistics. These statistics are things like the type and mana cost of the card. I know that this method is too large, so I would like to get some advice for how to make it smaller.
The challenge is that ... | stackexchange/codereview |
I recently got rejected at a job interview for submitting this:
https://bitbucket.org/gnerr/password-validator
The interviewer asked for a password validation library that was configurable via Spring, with the following default validations:
Must consist of a mixture of lowercase letters and numerical digits only, wit... | stackexchange/codereview |
Last time I posted my code of Tant Fant Game. I got some really good advice and I have implemented all the suggested changes to my code. I was wondering if there were any other revisions that would be good to implement? Thanks! =)
class board:
def __init__(self) :
self.loc = ['B', 'B', 'B', '', '', '', 'W'... | stackexchange/codereview |
I have a Timer class executing a function in a specified interval:
#include <chrono>
#include <functional>
#include <future>
#include <iostream>
#include <list>
#include <mutex>
#include <thread>
using namespace std;
// Timer
// =====
template <typename Result>
class Timer
{
public:
typedef std::chrono::mill... | stackexchange/codereview |
So basically I am building an app that helps to download some documents via a rest api.
Here is the SearchViewController
import UIKit
class SearchViewController: UIViewController, UISearchResultsUpdating, UISearchBarDelegate {
let searchController = UISearchController(searchResultsController: nil)
@IBOutlet ... | stackexchange/codereview |
I have written a series of Regex.Replace() lines to take an input like {"id":36} and convert it to id 36 and I was wondering if it is possible to combine all the calls I am making into one.
Results = Regex.Replace(Results, @"\{", "");
Results = Regex.Replace(Results, @"\}", "");
Results = Regex.Replace(Results, @"\""",... | stackexchange/codereview |
input:140153(seconds)
output:38:55:53
I have solved this problem in this way:
#include <stdio.h>
int main(){
int N;
double hour;
double minute;
double seconds;
scanf("%d",&N);
hour=N / 3600.0;
double floating = hour;
double fractional, integer;
//split the floating value(hour) in... | stackexchange/codereview |
I am new to programming and wrote this code for a Tic-Tac-Toe game.
The game works as desired, however, I feel the code can be condensed a bit especially within the functions, Map_1st_Player_Input_to_Player_Board, Map_2nd_Player_Input_to_Player_Board, and Check_For_Win where I rely heavily on if, elif statements.
Can... | stackexchange/codereview |
I've created this thin wrapper class for a socket project that I'm working on. Can someone review my class and give me some points on if I'm on right track?
#include <iostream>
#include <WinSock2.h>
const int MAX_RECV_LEN = 8096;
const int MAX_MSG_LEN= 1024;
const int PORT_NUM = 1200;
class Sokect
{
private:
... | stackexchange/codereview |
This code plays a note for a specific period of time using NAudio.dll 1.3.8.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NAudio.Midi;
using System.Threading;
namespace SoundVision
{
class Note
{
public Note(MidiOutWrapper mid... | stackexchange/codereview |
My implementation is based on the incremental prime sieve described on Wikipedia. I'm relatively new to lisp so I would appreciate any comments on my coding style or on the algorithm.
The below code implements a min-heap and uses it in the prime number generation algorithm:
(defstruct heap
; (cmp x y) should return t... | stackexchange/codereview |
So I have this sub query:
*(select p.value1 From Params as p where p.PAR_Field = 'Taxe' and p.PAR_KEY = 'TVA')*
And I was using it 3 times to get the same value.
In this SELECT statement:
Select a, b, c, d,
price *(select p.value1 From Params as p where p.PAR_Field = 'Taxe' and p.PAR_KEY = 'TVA')/100 as RealTVA... | stackexchange/codereview |
Following snippet reads CSV Line count using BinaryReader.
Currently it checks \r and \n for line delimiters.
private static int GetLineCount(string fileName)
{
BinaryReader reader = new BinaryReader(File.OpenRead(fileName));
int lineCount = 0;
char lastChar = reade... | stackexchange/codereview |
I have been working on this question, https://open.kattis.com/problems/sequences.
You are given a sequence, in the form of a string with characters ‘0’, ‘1’, and ‘?’ only. Suppose there are n ‘?’s. Then there are 2ⁿ ways to replace each ‘?’ by a ‘0’ or a ‘1’, giving 2ⁿ different 0-1 sequences (0-1 sequences are sequen... | stackexchange/codereview |
I built one JavaScript debounce function. I need a JavaScript expert's opinion if this is the correct way to do it, and if not, then what the flaw is in this current function.
var debounce = function(inpFun, wait) {
var timeout;
return function () {
if(!timeout) {
inpFun.apply(this, argume... | stackexchange/codereview |
Hi I participated in Leetcode weekly contest 213 and am facing issue with submission for below question
Kth Smallest Instructions
Bob is standing at cell (0, 0), and he wants to reach destination:
(row, column). He can only travel right and down. You are going to
help Bob by providing instructions for him to reach des... | stackexchange/codereview |
I have a list of n cities and hourly weather prediction for each one of them for h hours. I'm writing a script to find a pair of cities which has the most similar weather. And to represent the similarity in terms of a percentage scale.
An example dataset with 5 hour forecast for 3 cities are as follows:
city ... | stackexchange/codereview |
I am accepting a form from the user with a bunch of inputs and I am constructing a string from those inputs. I am trimming each input and 2 of the inputs (GID & Clone) are not required fields so I'm doing null checks before building the string to avoid null object errors.
I wrote this method and it works, but I was wo... | stackexchange/codereview |
I want you to pick my code apart and give me some feedback on how I could make it better or simpler.
public int heightHelper(TreeNode node) {
int height = -1;
if (node == null) return height;
final Queue<TreeNode> queue = new LinkedList<TreeNode>();
queue.add(node);
int currentLevelNodeCount = 1;... | stackexchange/codereview |
package calc;
import com.sun.tools.corba.se.idl.constExpr.Equal; //imports .equals(variable)
import java.util.Scanner; //imports scanners
public class Calc {
public static void main(String[] args) {
boolean go = true; //sets up loop
while(go) //creates loop to top
{
... | stackexchange/codereview |
So I have started creating a UITableView with multiple prototype cells. I currently have the below code setup, which works fine
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell: UITableViewCell?
if indexPath.row == tableView.numberOfRowsInSecti... | stackexchange/codereview |
The goal of this function is to open a menu with a CSS class (animation is done through CSS transition), call an overlay on top of content and prevent scrolling at the same time. Also, since the designer didn't add any hamburger icon, I created a class (.header.isG_navSemiOpen) to add an in-between transition to tell t... | stackexchange/codereview |
So I've attempted this project from hyperskills where you're asked to make a calculator script that can calculate annuity and differentiated payments given that 3 of 4 values are known. I think i went with a real hardcoding way of doing this, as such I would like some advice on making my code more compact and efficient... | stackexchange/codereview |
I wrote a program which gets two sorted arrays a and b (with sizes m and n respectively), and calculates the median value of these arrays without merging them.
Here is my code:
#include <iostream>
using namespace std;
int findMedian(int a[], int b[], int m, int n);
int max(int a, int b);
int min(int a, int b);
void ... | stackexchange/codereview |
I have some function like:
void foo() { ... }
int main() {
...
try {
...
foo();
...
} catch (const std::exception &e) {
std::cout << "Fatal error: e.what() << std::endl();
return;
}
...
}
If an exception is thrown from foo, I'd like to know it. Also I want to know the reason of the orig... | stackexchange/codereview |
I have an API application with token authorization. A token is valid for one hour. Each business client has its own instance of the API application:
{"client_1": "http://localhost:1"},
...
{"client_n": "http://localhost:n"}
In another application I have a class ApiService to make HTTP requests to the API. I create o... | stackexchange/codereview |
I'm a new and self-taught Python programmer. I've been working my way through the Google FooBar challenges and wrote the following for the prepare_the_bunnies_escape challenge. I submitted the code and it passed all tests, but I had to do a poor workaround that I'd like to fix.
The gist of the challenge is to find the... | stackexchange/codereview |
I have created an Electron Application with a JavaScript/NodeJS Backdoor and a Ruby command-line listener.
I created this program for remote administration of my home computer securely using a new technology (WebSockets) which I found very interesting.
The program has two parts:
The Electron application written in Ja... | stackexchange/codereview |
This was one of my assignments in which I had to create a backup script that will individually compress all files (of an arbitrary number) of file-types (indicated by their .extension).
Example: backup a b c will take all files ending in .a, .b and .c and compress them using tar, keeping the original file, and naming t... | stackexchange/codereview |
Requesting code review, best practices, optimizations for this solution to the Tower of Hanoi problem.
final class PlatePair {
private final String source;
private final String destination;
public PlatePair (String source, String destination) {
this.source = source;
this.destination = dest... | stackexchange/codereview |
I stumbled my way through some Rust yesterday and today to make a simple ASCII art API. It can draw lines, circles, and a canvas.
use std::collections::HashMap;
#[derive(PartialEq, PartialOrd, Debug)]
struct Point(u32, u32);
#[derive(PartialEq, PartialOrd, Debug)]
struct Dimension(u32, u32);
#[derive(PartialEq, Par... | stackexchange/codereview |
A couple of weeks I had a coding interview and the problem to solve was very simple: reverse the words order of a string. What did I do wrong here?
public static String reverse(String phrase) {
String[] words = phrase.split(" ");
StringBuffer sb = new StringBuffer();
for (String word : words) {
... | stackexchange/codereview |
It is commonly known that env does not allow passing of arguments - at least not reliably. There are various workarounds described here, but they felt to hacky and unreadable to me. That's why I developed an alternative, ex.
ex:
#!/usr/bin/env bash
# save the string given in the sheband line
shebang_line="$1"
# remov... | stackexchange/codereview |
This is a drill from the Programming Principles and Practice Using C++. I managed to get it to work but somehow it doesn't feel right to me. I 'd appreciate any pointers on how to simplify/improve the solution.
Especially when it comes to best check if '|' was entered. I feel that creating two extra string variables an... | stackexchange/codereview |
This is the "Pairs with Positive Negative values" problem from geeksforgeeks.org.
Given an array of distinct integers, print all the pairs having positive value and negative value of a number that exists in the array.
NOTE: If there is no such pair in the array , print "0".
Input:
The first line consists of an int... | stackexchange/codereview |
As part of an android app, I've written a simple wrapper that makes requests to an api and fetches stuff.
import android.app.Activity
import android.util.Log
import android.widget.Toast
import com.github.kittinunf.fuel.core.Parameters
import com.github.kittinunf.fuel.httpGet
import com.github.kittinunf.fuel.json.respo... | stackexchange/codereview |
I wrote a server-client application in Python where the server sends a never-ending stream of messages to connecting clients.
I was in need for such an architecture since I want to retrieve and process data from a public streaming endpoint, however the company limits the number of active connections to one per user.
... | stackexchange/codereview |
I am finished with my implementation of PUB/SUB or Observer pattern, however I just want to see any ways that I may be able to improve this pattern. I wanted to be able to use the typical PubSub pattern except add performance enhancements by using the new key word to instantiate each new instance of a PubSub object, as... | stackexchange/codereview |
I am designing an in-depth poker game. I am first focusing on recognizing the strength of a hand given the set of cards.
Is the following algorithm suitable for the stated purpose?
Am I using correct OOP design principles and implementation in my code?
Algorithm:
Go from a top down approach checking for the following... | stackexchange/codereview |
You can find the complete code on github. Since I'm rather new to C++ I thought that it might be a good idea to write a simulation of the n-body problem to apply some of the concepts that I learned in class. The relevant part can be found in main.cpp on the above linked github repo, but the imporant part is given by:
#... | stackexchange/codereview |
I decided to redo the first program I wrote (after the hello world thing). So, what it does is to convert a DNA sequence string to an array of strings that represent the amino acids that are made in a cell by ribosomes when that DNA sequence gets used (DNA codon table).
#include <stdio.h>
#include <stdlib.h>
#include <... | stackexchange/codereview |
Would the following be the right way to do it in your opinion? Can you suggest a better alternative or, if not, is there something that can be done to make the existing version better?
ps -e | grep skype | cut -d" " -f1 | xargs kill -s term
| stackexchange/codereview |
I have 3 radio buttons all grouped inside a group box in a WinForms project. Currently, I am checking which button is checked and assigning values using the following if/else statement, similar to the below example
if (rb1.Checked)
{
selectedButton = 1;
selectedButtonText = rb1.T... | stackexchange/codereview |
I was just wondering if someone could check my small "random dice game", which I programmed due to a "do it yourself" from my PHP book. I am happy that it is working and finished the DIY, but however, I want to know if the solution is okay or if there is a way better/easier way to do it.
Also please let me know if the ... | stackexchange/codereview |
The purpose of this program is to have one thread (main thread) working on I/O reading lines from a file and feeding it to a pool of worker threads whose job is to perform some processing on each line provided. In this case, the processing is running the String.contains() method.
Please note that as test input, I used ... | stackexchange/codereview |
These two functions search for directories with a certain prefix that contain no files of a given type.
Does the code adhere to Ruby standards and conventions?
Am I doing something the hard way or the "non-Ruby" way?
Should I use more/fewer/different comments?
def find_empties(directory, dirprefix, fsuffix)
empty_... | stackexchange/codereview |
I'm trying to implement a simple "monitoring" tool in C to be used on our servers to check NGINX status, executed periodically with a cron task.
This is my very first attempt to use C instead of bash or (lovely) Python - just for some practice.
So I googled code for "socket open" and used some code in the socket_get() ... | stackexchange/codereview |
I have a class that delegates some responsibilities to another helper class which is abstract. When instantiating the class the user needs to provide a pointer to a concrete instance of the abstract helper class. I'm wondering who should be responsible for deleting the helper class instance, the user, or the class itse... | stackexchange/codereview |
Previously asked here.
The code is now available on GitHub.
Since the previous review I have added unit tests.
Since it is big it will come in a couple of parts.
Part 1 | Part 2 | Part 3 | Part 4
Part 4
Printing strings and integers did not work the same way on streams as they did in printf(). So I had to write some sp... | stackexchange/codereview |
My VBA code currently loops for 5,000 iterations and takes about 25 minutes to collect the output data in the Output excel sheet. Is there a way to reduce the time taken for instance by improving the copying and pasting of values, collecting the output data in some kind of array etc.? Given that I will be looping it fo... | stackexchange/codereview |
I was playing around with ES6 arrow functions, currying and partial application and I decided to try a functional implementation of the FizzBuzz problem:
function* range(start, stop) {
for (var i = start; i < stop; i++)
yield i
}
var map = fn => res => x => fn(x) ? res : null
var isDividedBy = dividend => diviso... | stackexchange/codereview |
CodeEval FizzBuzz
Quick Description:
Take 1 command line argument of a file-path. This file will contain
test cases formatted as such 3 space separated numbers per line. For
numbers X, Y and Z you must print out all numbers between 1 and
Z, space separated, replacing all numbers divisible by X with 'F'
and all... | stackexchange/codereview |
The code I have is based on BFS and a little bit of Dijkstra and returns the shortest path of an unweighted directed graph as an integer. I was wondering if someone could take a look at my code too see if anything could be changed or improved:
public int bfsshortestpath (V source, V target) {
Map<V, Integer> dist =... | stackexchange/codereview |
The problem can be found here and is essentially asking us to generate J many numbers containing N many digits, where these digits have to be either 0 or 1. The catch is that the these numbers that we generate have to be composite when interpreted as being written in base i, where i ranges from 2 to 10, inclusive. Furt... | stackexchange/codereview |
I have a use case where I need to run multiple tasks in series. Each task is required to perform some database operations. In my code step_1, step_2 and step_3 are these task which get executed in series (Async Waterfall)
Following is my code
const config = require('config.json');
var mysql = require('mysql');
var asyn... | stackexchange/codereview |
I am trying to come up with a minimal example of what is known as callback hell in JavaScript (so this would be a bad code review I guess). This is what I have so far, and I would like it to also run without making external requests. I'm not sure if that's possible or if this example is hellish enough (do I need to int... | stackexchange/codereview |
I have been doing some programming 'exercises'. I'm trying to come up with the most efficient algorithm for tree traversal.
Consider the following function signature:
CNode * CNode::find(int number) const
where CNode structure is not organized as a binary search tree (otherwise obviously a faster algorithm would hav... | stackexchange/codereview |
I am wondering if this code will work in 10.1.
This video at 1:02 says not to create mxd based services. I think that just means not using IMapServerObjects3, but seems like IMapDocument should be OK.
#region IServerObjectExtension Members
private IPageLayout m_Layout = null;
public void Init(IServerObjectHelper pSOH)... | stackexchange/codereview |
problem statement: using React and Redux build an interest calculator that, given a principal, rate of annual interest, and number of years, will display the total principal plus interest using the formula
TOTAL = principal * (1 + (rate * years))
Any feedback welcome on the style, approach, etc.
<!doctype html>
<html><... | stackexchange/codereview |
I have got a JTable implementing a TableModel interface. There are ID (primary key, auto-increment), tbl_Date, Flat, Mobile, Food, Alcohol, Transport, Outdoor, Pauls_stuff, Income, Stuff columns.
Every time I start the program, I want to get rows filled with data: tbl_Date until tommorow, everything else except ID, set... | stackexchange/codereview |
$roleId = pg_escape_string($_POST['role']);
$grantValue = pg_escape_string($_POST['grant']);
$feature = pg_escape_string($_POST['feature']);
$permission = pg_escape_string($_POST['permission']);
$permissionsModel = new Permissions();
$record = $permissionsModel->getPermission($roleId);
//assemble ob... | stackexchange/codereview |
I had a problem that I posted on StackOverflow about that I could not connect to windows phone 7 from a 64-bit application. I got one response that said I should try to create a WCF Service over named pipe transport. Now, I have something that is working but since I am new to C#, WCF and COM, I would be happy for any g... | stackexchange/codereview |
Background
I am teaching a course at university level, and have lately been working on creating a home exam for my students. However, the institute has given clear instructions that collaboration is not allowed. In order to comply with this, I saw no other way than to give each student their own variant of the exam (mi... | stackexchange/codereview |
In class we created our own ArrayList class; the code I wrote is meant to interact with the ArrayIntList class. I'm looking for general feedback to help with the next time I write code. I'm also wondering if it's "safe" to change the value of the size variable in my method (size represents the current size of the Array... | stackexchange/codereview |
I'd like to have some feedback on this sieve of erasthotones that I've wrote. It outputs all prime numbers up to n correctly (I've tested with the first 10k prime numbers).
Is this well written? Does it look good for python programmers?
I've made the math up to the sqrt of n + 1, which improved the performance a lot.
i... | stackexchange/codereview |
Background information for those of you who don't know what 4chan tripcodes are:
Via Wikipedia:
A tripcode is the hashed result of a password that allows one's identity to be recognized without storing any data about users. Entering a particular password will let one "sign" one's posts with the tripcode generated from... | stackexchange/codereview |
I'm making a connect4 game in c++ and so far i have almost got the board class done
before I continue coding i want your thoughts on what I should improve because
i definently feel like this could be way simpler
class Board {
public: enum Type {
player1,
player2,
empty
};
private:
std::array<std:... | stackexchange/codereview |
My system is a .NET Core 7 console app, which starts some background threads. I need to pass some int values (counters, etc.) between the main and background threads, in a thread-safe manner.
Although I can pass an int by reference (e.g. DoFoo(ref myInt)), I can't assign it in the background thread (e.g. I can't pass i... | stackexchange/codereview |
Given two arrays: actual and expected; is there a more efficient way to write the is equal check?
actual.reduce((total, element)=> {
if (element !== expected[actual.indexOf(element)]) {
return total = false;
} else return total;
},true);
| stackexchange/codereview |
I am a newbie in Python and would very much need help in arranging and setting out function. I have programmed a number guessing game. The outlook of the program is very messy but I don't where to fix since my Python knowledge is very limited.
import random
def random_num():
# bound preferences and number of trial... | stackexchange/codereview |
I want to optimise this code and improve it using advanced C++.
#include <iostream>
template <class T>
class LinkedList
{
struct Node
{
T data;
Node * next;
Node(T value) : data(value), next(nullptr) {}
};
Node *head;
public:
LinkedList() : head(nullptr) {}
~LinkedList();
void insert(T);
v... | stackexchange/codereview |
I wanted to ask if this is a better way to find a latest file in given directory. This is my current approach:
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attr... | stackexchange/codereview |
This is the Text Justification challenge at LeetCode:
Given an array of words and a length \$L\$, format the text such that each
line has exactly \$L\$ characters and is fully (left and right) justified.
You should pack your words in a greedy approach; that is, pack as many
words as you can in each line. Pad extra... | stackexchange/codereview |
In the absence of feature-complete and easy-to-use one-hot encoders in the Python ecosystem I've made a set of my own. This is intended to be a small library, so I want to make sure it's as clear and well thought out as possible.
I've implemented things from a previous question concerning only the base encoder, but als... | stackexchange/codereview |
The task: take a byte[][] and transpose it.
The complication: the original array is a result of a partition operation that might not be even, so the last subarray might have fewer items than the others. This should be preserved in transposition without any padding.
For example:
$$ A^\intercal = \begin{bmatrix}
1 & 2 & ... | stackexchange/codereview |
I've been reading Uncle Bob's Clean Code and have read many articles on the use of Optionals whenever you are faced with returning a null in a Java method. I'm currently refactoring my code and I just don't know how to optimize it with Optionals. Can someone give me some pointers?
public UserLog selectById(String use... | stackexchange/codereview |
I'm writing a communications library for a class. Part of the requirements is that semi-reliable communications, which leads me to this monstrosity:
unit UDP.Communicator;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, DateUtils, SyncObjs, blcksock, fgl, SimpleThread, Common.Types, UDP.Shared;
type
{ TU... | stackexchange/codereview |
I am building a basic authentication system with a node backend and wonder whether I am using the try-catch block excessively. I have this example controller:
export const getUser = async (req: Request, res: Response) => {
try {
const user = await User.findById(req.body.id);
if (!user) {
return res.sta... | stackexchange/codereview |
I have some coordinates looking like
N47° 15' 36.75",E011° 20' 38.28",+001906.00
and I've created a class to parse and convert them to Double:
struct PLNWaypointCoordinate {
var latitude: Double = 0.0
var longitude: Double = 0.0
init(coordinateString: String) {
self.latitude = convertCoordinate(s... | stackexchange/codereview |
I have written the below code which generates 4 random, whole integer values between 1 and 6 and then saves the sum of the 3 largest values. It generates a total of 6 values this way, displays the total along with all 6 values once finished.
The order in which each value was generated must be preserved.
The total of a... | stackexchange/codereview |
I've implemented the cryptographic method of the Fleissner-grille aka Turning-grille .
Here's the code:
import java.util.Scanner;
import java.util.Random;
public class fleissner {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Scanner scanner2 = new Scanner(System... | stackexchange/codereview |
This is built with Python 2.7.15.
The goal of this script is to count the number of words spoken by each Senator on the floor of Congress between given dates.
It pulls from the Congressional Record, cuts out the sections not spoken on the floor (eg lists of Amendments) and returns a count of words by senator. The curre... | stackexchange/codereview |
I'm designing a Matrix class and I feel like what I've come up with requires too many calls to new. I know it's possible that caring about this is premature, but I already know I need this code to be fast, so I'd like to think about streamlining it now.
Here's a test to show how I intend to use the API:
[Fact]
public ... | stackexchange/codereview |
I was tasked with this assignment with almost no time and I cannot stand up a new environment to test this. The risk is pretty high with what is the request is for so I'm asking for as much peer and code review as I can get.
I'm tasked to check all the web.configs that have a certain DB Server and change it to a new va... | stackexchange/codereview |
Below is my implementation of dynamic array without help of library functions. Kindly provide your suggestions on design, coding style and algorithm.
MyDynamicArray.java
import java.util.NoSuchElementException;
public class MyDynamicArray<T>
{
private int positionPointer=0;
private int arraySize;
private T... | stackexchange/codereview |
I have an application in which I am querying an XML web service continuously every 2 seconds in a thread. The returned XML is very big and I am retrieving lots of stuff from them using XPath and plugging the values into labels in the GUI, using delegates for thread safety.
But the way I've done this, it looks bizarre t... | stackexchange/codereview |
This is a depth-first search Kings Tour. I call it like this because the king must pass by all coordinates only touching them once (like a knights tour).
How could I improve?
Thank You
# author @reivaJ
from collections import defaultdict
from itertools import product
import sys
import numpy as np
from random impor... | stackexchange/codereview |
People here often ask to share as much code as possible. My app is just a sandbox, a typical freshly created AspNetCore + Angular template without much code. So please don't blame me - I provide ALL OF the code related to dates & timezones.
I'm playing with dates in .NET and started learning Moment.js in detail.
I thi... | stackexchange/codereview |
I'm trying to write a small macro library in Racket that extends a few of the racket/match functions I use, by printing which clause was expanded.
While this seems to be decent practice for learning macros in Racket, I still find them incredibly daunting. At some point, I wind up just trying everything with no real se... | stackexchange/codereview |
I am trying to be as efficient as a I can using a CSV to import users to a CMS called "Concrete5 - Version 8.2.1". I have a list of 700+ users and i've created an upload screen to take in a CSV and process the creation of new users. Code below.
Now I have ran the code several times (and then removed the users) to test ... | stackexchange/codereview |
These are five implementations I’ve come up with for an equivalent for Haskell’s Maybe in Python. It’s not called Optional because typing.Optional already exists.
Here’s a simple monolithic class. The benefit of this one is that it can be inherited from:
from __future__ import annotations
from typing import Callable, G... | stackexchange/codereview |
Currently I need to download thousand of images, I can use 2 functions to download the images: LoadUrl or LoadUrlProxy.
Each function has different parameters:
LoadUrl(url, timeout)
LoadUrlProxy(url, proxy_client, proxy_params)
As I don't want to duplicate the code, I'm looking to simplify the way I'm passing a functi... | stackexchange/codereview |
I'm pretty new to python but after watching Mr Robot I felt inspired to make a CLI portscanner. With all the fancy console outputs you see in movies like a progress bar.
It's finished and works nicely however I am not very happy with having to write twice global host_IP in main() and scan_tcp(). I have to do this the o... | stackexchange/codereview |
I have a React component that generates a table based on an array of objects, which gets populated with data in an object.
I'm trying to learn as much as I can about React.js / JavaScript. Could anyone with more experience in this area show me a way to simplify the code that I have here? Or if there are any other 'fanc... | stackexchange/codereview |
For a list li, I want to print only the values of the triplets a, b, c where 0 <= index(a) < index(b) < index(c) < len(li).
Example:
f([6, 3, 88, 4])
6 3 88
6 3 4
6 88 4
3 88 4
Here is my solution, but it is O(n**3) (time complexity):
def f(li):
for i, n in enumerate(li):
for j, o in enumerate(li):
... | stackexchange/codereview |
I need to improve the performance of a function that calculates the integral of a two-dimensional kernel density estimate (obtained using the function stats.gaussian_kde) where the domain of integration is all points that evaluate below a given value.
I've found that a single line takes up pretty much 100% of the time ... | stackexchange/codereview |
I wrote this code to interpolate precipitation data. When I run this code, it works very well, but the problem is that it slows my computer down so I have to wait 5 mins to interpolate the data.
Is there any way to make this function work faster?
Function IDWW(Value1, Value2, Value3, Dist1,Dist2,Dist3)
Dim a1 As Va... | stackexchange/codereview |
Starting to write an article about Socket Programing.
So I need a simple C++ version of a client/server app.
So here it is for review (Also on github)
A linked question is the C version
Makefile
all: client server
.PHONY: all
.INTERMEDIATE: %.o
CC = $(CXX)
CXXFLAGS += -Wall -Wextra -Werror -p... | stackexchange/codereview |
EDIT: Link to the github,
https://github.com/Evanml2030/Excel-SpaceInvader
THE README (APPLIES HERE TOO):
VBA version of a classic game
Yes, I know that "Missile" is repeatedly written as "Missle".
It will not run unless you change the pathways to images that will be uploaded into form controls. You can find these ins... | stackexchange/codereview |
I am implementing a parent-child relationship, represented by hashes that look like this:
parent = { 'parent' => nil, 'id' => 3 }
child = { 'parent' => parent, 'id' => 7 }
These hashes are data given to me, for example, through a JSON API.
(As per a question in the comments, the JSON for the child would look like:)
{
... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.