instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I wrote a small code in Python to conduct a backtest. My rebalance function is very slow and I would like to improve it. I need to profile it but I would welcome any opinion on how to refactor my code nicely.
def Rebalance(self, currentDate, data, VolatilityForSizing,Wthtslippage=True):
# Handle open positions... | stackexchange/codereview |
I've created a class that creates key->value pairs but also value->key pairs - i.e. a reversible hash-map. This is because I want to be able to switch between corresponding members of 2 enums with different values, or between an enum and the text representation of its members.
My approach is to wrap two Scripting.Dicti... | stackexchange/codereview |
I've made a little function for myself that replaces certain variables to text in an org file. I declare a bunch of variables in the beginning of the file and then the function replaces all references to the variable with the value. So for example
#+VAR:location=AAAAAA
text text text \v{location} text text text
becom... | stackexchange/codereview |
Here is the problem,
Given a 2D numpy array 'a' of sizes n×m and a 1D numpy array 'b' of
size m. You need to find the distance(Euclidean) of the 'b' vector
from the rows of the 'a' matrix. Fill the results in the numpy array.
Follow up: Could you solve it without loops?
a = np.array([[1, 1],
[0, 1],
... | stackexchange/codereview |
Problem
I've written a timer module in C for an SDL game. I'd like to get some eyeballs on. I wrote this for 2 requirements: I needed a timer that would signal on an elapsed interval, AND that was pausable and restartable. The timers in SDL signal a callback on a set interval, but they aren't pausable. I've seen other ... | stackexchange/codereview |
I should estimate the effect of B fields on particle deflection using \$F=V \times B \times Force\$.
I have a 2D mesh with \$n_x\$ and \$n_y\$ which show the number of points in each direction. \$B\$ is the magnetic field which is a 2D mesh arrays (with dimension \$n_x \times n_y= 1600 \times 900 = 1440000\$) and \$V\$... | stackexchange/codereview |
Consider the following:
If myString = "abc" Or myString = "def" [...] Or myString = "xyz" Then
In C# when myString == "abc" the rest of the conditions aren't evaluated. But because of how VB works, the entire expression needs to be evaluated, even if a match is found with the first comparison.
Even worse:
If InStr(1, ... | stackexchange/codereview |
I'm currently learning about PDO, and trying to connect to the database and CRUD in OOP way, this is a simple code that I use.
index.php
include_once("connection.php");
include_once("model.php");
$con = new Connection();
$model = new Model();
$model->insert();
$con->closeConnection();
connection.php
class Connec... | stackexchange/codereview |
By profiling my application, I found that the bottleneck of my application is the function below. In particular it will be executed by a lot of entities (monsters) in a game, that will go onto a smartphone.
The graph is the model for this type of grid: (the final one is 25x45)
Also, each cell has an array of 4 pointer... | stackexchange/codereview |
I have some code, that works fine. However, I know there is a lot of code duplication and C-style programming. In the code example there only is a DeviceOneDispatcher, in reality there are more child classes and case options.
The question is how to optimize/refactor this code best following c++11-c++17.
I believe a b... | stackexchange/codereview |
In my implementation of a binary search tree, most functions take a pointer to a node (because of their recursive nature). So I found myself having to overload them, and the overloaded versions form somewhat of a public interface to the functionalities of the class. Is the design of the class good or bad? If it's bad p... | stackexchange/codereview |
I've created a program for my job that unlocks spreadsheet files quickly and efficiently. What we use to have to do before this program is we'd have to go into the system, search for the file, kill the users process containing the file, unlock the file, then the user can finally get back into their spreadsheet. With my... | stackexchange/codereview |
In order to perform form validation, I have created a custom object:
define(["jquery", "validate", "activities/new/common/components/BaseFormdata"],
function($, Validate, BaseFormData){
var FormData = function(options){
this.defaults = {
name: "",
privacy: "",
... | stackexchange/codereview |
I've got an array like this, which is a result from a Google analytics request. I asked for the amount of visits for the last three months.
$statPerMonth
array (size=2)
'08' => // The month (August)
array (size=34)
0 =>
array (size=3)
0 => string '08' (length=2) // Month again
... | stackexchange/codereview |
I have been watching this video:
https://www.youtube.com/watch?v=M6lYob8STMI
And here is the code of it in groovy (just the add method):
def addNode(k, v){
def newNode = new MNode(key: k, value: v)
if(!root){
root = newNode
}else{
MNode currentNode = root
MNode parent
w... | stackexchange/codereview |
first time poster here.
I'm creating a session cookie which should expire after 30 minutes of user inactivity. I've added the following code to the base controllers OnActionExecuted method.
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
var sessionCookie = Request.Cookies[CO... | stackexchange/codereview |
Context: I have a client app which consumes an API. I want to call this API is async way (using java.net.http.HttpClient) and once I receive this data then I want to model the response because it can have either error or actual data in java.net.http.HttpResponse<String>. So it will be good if I cloud transform to model... | stackexchange/codereview |
I'm developing a Chrome extension so I can use bleeding-edge technologies like flexbox:
jsfiddle
HTML:
<label for="example-search">Classic search example</label>
<div class="input-wrapper">
<input type="text" id="example-search" />
<button>Search</button>
</div>
CSS (cleared to highlight flexbox):
.input-wrapp... | stackexchange/codereview |
I haven't done anything similar so I got nothing to go on. The point was to load everything from the file and I thought a struct would be a good choice to be the handler to store the information.
The loading part is, however, not really something that is to my satisfaction as I find it very primitive and illusive. I tr... | stackexchange/codereview |
In the Elm examples I have seen for form handling, they attach each input element with an update handler that sends out a very specific message to update the model according to the new input state.
So you end up with a lot of message definition in your Msg union type.
Alternatives I have seen for "dynamic" or complex f... | stackexchange/codereview |
i am trying to learn mvc (model view controller). there are many texts out there explaining what mvc is. but not many explaining how to actually code mvc. i found a bunch of questions here asking about mvc. some seem to contradict each other (view observe model or not, controller listens to view or not).
i made a simpl... | stackexchange/codereview |
I am trying to return distinct characters from the combination of 2 Strings. The following is my solution which seems to work based on my tests.
Is there a more efficient way of going about this? I have converted the strings to arrays, to sets, to a StringBuilder and back to a String. I'm wondering if I have overcompli... | stackexchange/codereview |
I am using the ancestry gem to organize my post categories tree.
I have 8 parent categories, and they all have many child categories.
To retrieve an array of child categories, I use:
parent_category.children
I defined these relations in my category model:
has_ancestry
has_many :posts
has_many :users, through: :... | stackexchange/codereview |
I'm working on a Swift app for macOS, where I take input from MIDI devices and transform that input. The MIDI devices being supported come in for flavors.
What my code does is scan for MIDI devices, filter all the MIDI devices to only leave the ones I want, initiates classes on them and puts them in a array.
However, w... | stackexchange/codereview |
I made a very simple user account registration program that works in the terminal using no external libraries other than java.util.Scanner. I want to know what improvements I can make to this code to make it more efficient and more readable:
private static void newAccount(){
boolean next = false;
System.out.pri... | stackexchange/codereview |
I am learning C and decided to make an implementation of Base64 encoding according to the info Wikipedia provides about it.
My main question is: should I declare the index_table array inside the get_base64_digit function like static char index_table[] = "blabla"?
A general code review would also be appreciated.
funcs.c... | stackexchange/codereview |
This is my current coursework for university where I am to write a spell checking application and compile using C++11.
I have a dictionary file that is read into the program automatically and stored into a binary search tree in order. The user provides a text file that they would like to check which is split into token... | stackexchange/codereview |
I'm adding rather extensive xml-doc comments to all Rubberduck inspection classes, like this:
namespace Rubberduck.Inspections.Concrete
{
/// <summary>
/// Warns about a variable that is assigned, and then re-assigned before the first assignment is read.
/// </summary>
/// <why>
/// The first assign... | stackexchange/codereview |
I decided using a C++ map or unordered_map is the most appropriate option to store 'Regions' where which can be loaded in arbitrary patterns
The rest of the project is written in C, so I made a C interface:
#include <unordered_map>
#include "Region.hpp"
static std::unordered_map<uint64_t, void *> Regions;
extern "C" {
... | stackexchange/codereview |
I'm learning command design pattern right, so I decided to make this project. Basically it's a remote controller and it issues commands to VCR. I've seen different implementations of this pattern so I'm not really sure if I got it right. So the key points are:
Is the implementation correct? If not, what's the problem?... | stackexchange/codereview |
I was wondering if there was a better way to do this. Would that mean there would need to be no client-side refreshing to show the cookies when they are created?
<?php
class cookieMonster
{
public static $lastDestroyed;
public function __construct() { }
/**
* Register a cookie with the browser.
... | stackexchange/codereview |
I have a simple task that comes up often my work. I need to create a dictionary for an id key to a list of data associated with that key. I'm wondering if there is a better way to do this than the one I am using. The pattern is so common that I feel there must be better solution.
value_list_dict = {}
for line in f:
... | stackexchange/codereview |
This takes a string input like 1,2,3,4,5, splits it using , delimiter, converts each char to int and output it in a single line like this : 12345
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int* createIntArray(char* numbersInString, int* array_size);
int* createIntArray(char* numbersInString, int* arra... | stackexchange/codereview |
Edit: Just to clarify, this isn't my original code, I've simplified it to make it smaller/easier to understand what I'm trying to do.
It's my first time working with threads in Java, and I was wondering if I'm synchronizing correctly. I did some quick research on locks, synchronized and volatile, but I'm still not sure... | stackexchange/codereview |
Goal: create a new OrderedDict instance's keys in such way that keys in the specified order list appear first. If some keys in order list are not present in OrderedDict, ignore them.
Additionally, reordering should be "stable", that is, if some keys were not specified in order list, they should keep their original ord... | stackexchange/codereview |
I recently decided that putting strategically placed print statements scattered about my python programs to debug was getting to be a little messy.
I had thought to try out other debugging plugins I found online, but thought I would give writing my own simple breakpoint plugin a shot.
I know of python's pdb module, but... | stackexchange/codereview |
Given
You’re given the pointer to the head node of a linked list, an integer to add to the list and the position at which the integer must be inserted. Create a new node with the given integer, insert this node at the desired position and return the head node. A position of 0 indicates head, a position of 1 indicates ... | stackexchange/codereview |
For the queries mentioned in link in 3 parts, the first two parts have been addressed, as mentioned below:
Part I (6 points)
list/DList.java contains a skeleton of a doubly-linked list class. Fill in the
method implementations.
Note: "node" is passed in these methods so that user of class DList can avoid slow \$O(n)\$... | stackexchange/codereview |
I have a 3-D array in numpy, of dimensions 3000 x 2000 x 8
I need to modify the cells of the array so that each cell will contain the sum of all cells above and left of it, inclusive the current cell.
I am doing it using loops like below, but it is taking around 5 minutes to complete the program run. Is there a faster ... | stackexchange/codereview |
I want to implement reactive write to file.
In low level, it uses NIO and Futures.
After reading this section
I created this code but maybe there's more clean or less code solution.
Thanks.
public class LocalImageService implements IImageService {
private String imageDir = "/tmp";
@Override
public Mono<String> st... | stackexchange/codereview |
I am making a game in which the player has a certain amount of available boost. To show this, I am using a blue bar inside a black frame. The bar can grow and shrink at different rates as available boost goes up and down. It works well and looks nice, but it almost halves my FPS.
The relevant snippet:
var boostStyle... | stackexchange/codereview |
Out of pure curiosity, I decided to create a short F# script to calculate the letter frequencies based on the input file. Everything works smoothly and as I would expect. My questions regarding my code are as follows:
Does it conform to formal F# standards?
I have done my best to keep it as functional as possible whil... | stackexchange/codereview |
K and R Exercise 5-10
Write the program expr, which evaluates a reverse Polish expression
from the command line, where each operator or operand is a separate
argument.
For example,
expr 2 3 4 + *
evaluates
2 * (3+4)
#include <stdio.h>
#include "expression_parser.h"
int parse_polish(int size, char *expression[... | stackexchange/codereview |
I'm solving easy CodeEval challenges in Python 2.7. Usually my solutions use around 256 bytes of memory according to CodeEval. With Road Trip however while time used is still low (30-40ms), memory is >5881866 bytes. As I'm somewhat of a beginner, is there an easy way to decrease memory usage?
For each test case, which... | stackexchange/codereview |
I have this really really long controller action and would like someone to help me break it down.
def index
@credit_unions = Company.parent_with_branches
@loan_officers = []
@loan_requests = LoanRequest.includes(:dealer, :loan_officer, :branch => :parent)
if params[:query].present?
results = @... | stackexchange/codereview |
I have a browserify module I've made for resizing two divs I have beside each other. The idea is that I have two panes with a bar between them which I can grab and drag to resize the panes. As one pane gets bigger the other gets smaller. It's not really that important for the code review that this is a browserify modul... | stackexchange/codereview |
I am trying to perform a loop and then stop the loop when the last line of code in the if statement is printed to screen saving on CPU cycles.
I want to start a while loop and then kill the loop after it is complete, but not breaking out of the loop so I can re-initiate the loop once again by pressing a GPIO button "B1... | stackexchange/codereview |
I'm implementing argument check in a method where one parameter is a List of LocalDate objects (from Joda-Time). I want to make sure that List contains at most one LocalDate per month.
public List<LocalDate> generateAllDates(List<LocalDate> firstYearDates, ...) { }
Thus, for example
Arrays.asList(
new LocalDate(2... | stackexchange/codereview |
I wrote a simple implementation of Conway's Game of Life in Java using 2 arrays and for loop and used StdDraw library for plotting generations.
It turned out that algorithm works ok for little number of cells (e.g. glider pattern), but becomes terribly slow for big number of cells (e.g. random filling) even with small ... | stackexchange/codereview |
This is my take on binary and ternary heapsort implementation for a university assignment. The code works but I wonder if there are any mistakes or things to improve.
class HeapSorter {
static int[] array;
static int heapSize;
//=============================BINARY HEAPSORT=============================//
... | stackexchange/codereview |
I created a quick function to convert n bytes into binary for my student.
She is not on that level yet, but I think it would be best for her if my demonstrative functions aren't trash.
void binary (void* p, size_t nBytes)
{
int iBit = 0;
int iByte = 0;
putchar('[');
for(iByte = 0; iByte < nBytes;... | stackexchange/codereview |
I made a snake game in HTML/CSS/JavaScript. I want to make my code better and shorter.
Here is my codes:
index.html:
<!DOCTYPE html>
<html>
<head>
<title>Snake Game</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<p class="score" draggable="true"></p>
<canvas class="canvas" height=... | stackexchange/codereview |
I'm new to Scala, and would appreciate any notes about a better approach, correctness, or style.
/**
* Call proc(f) for each file in the directory tree rooted at dir.
*
* proc will not be called for directories, just for files.
*/
def traverse(dir: File, proc: File => Unit): Unit = {
dir.listFiles foreach { (f... | stackexchange/codereview |
First time poster, be gentle.
I wanted something similar to Mojo::Promise->all, except with an option to discard certain rejected (or, I guess, resolved) promises dependent on rejection value, as determined by caller.
Only using this internally, so nevermind my polluting the Mojo::Promise:: namespace.
package Mojo::... | stackexchange/codereview |
Well I had a idea about making a platformer but wanted to challenge myself to doing it without using canvas. It uses some other codes from github for collision detection.
Here is the result.
var currentKey; //records the current key pressed
var charSpeed = 40; //how fast the character will move
var coll = setInterval... | stackexchange/codereview |
Made after seeing A Simple Word Guessing Game. Any code critique is welcome!
import urllib.request as Web
import random
import string
def get_words():
url = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain"
req = Web.Request(url)
res = Web.urlopen(req).read().splitlines()
... | stackexchange/codereview |
I have some side projects by using a private module I have. My main goals are to match the list if they started with the pre-defined prefix, then put them into a list. From that filtered list, I extract two elements each time and modify their label name. I am trying to clean up my code to make it more concise and user-... | stackexchange/codereview |
I am aware there are several ways to deal with shell-executions in Python but I haven't really found the right one for me as it includes the following structure:
command [--maincommand.subcommand value]
I want to create a backup of a collection from my ArangoDB, using:
arangodump --server.endpoint tcp://qohelet.at:81... | stackexchange/codereview |
Awhile back, I wrote a quick and dirty webapp to read the remote server's log files, without a user needing to ssh in to view it via command line. It's meant to be a quick and dirty tool since we don't have anything like logstash available.
I am rewriting in Java 8 and have used the Streaming API to remove about 60% of... | stackexchange/codereview |
I wrote this function to remove whitespaces in strings. Please help me improve it. I intended to use the function for a Big Integer ADT.
#include <iostream>
#include <string>
#include <string.h>
void rs(char* str){
int i(0);
int j(0);
while((*(str + i) = *(str + j++)) != '\0')
if(*(str + i) != '... | stackexchange/codereview |
I am trying to implement a live chat for my websites visitors. I am currently using a PHP script that processes in background and that is called by AJAX. I am not familiar with sockets and node.js that also allow to create a live chat so I tried to make one longpolling-like code upon my possibilities. What I am hoping ... | stackexchange/codereview |
Is this a good solution for FizzBuzz? What can I do better?
for num in range(1, 101):
if num % 3 == 0:
if num % 5 == 0:
print("FizzBuzz")
else:
print("Fizz")
elif num % 5 == 0:
print("Buzz")
else:
print(num)
| stackexchange/codereview |
I need to write a program where the user can switch between rect positions.( rects position re-ordering rellevant for activating other functions that not rellevant for this question.)
My algorithm works good but I'm sure there are better ways in terms of logical structure, memory and runtime. Unfortunately I did not fi... | stackexchange/codereview |
I have been working on a board game in C++ using Qt. The game consists of four players with four different colors.
This is all working fine, but I want to know if there is any other way to do this. Any ideas on how to improve this code and especially ideas on completely different ways to achieve the same are welcome.I... | stackexchange/codereview |
It has been a while since I've implemented a QuickSort and I wanted to write it down like I remembered.
int MyPartition(List<int> list, int left, int right)
{
int pivot = list[left];
while(true)
{
while(list[left] < pivot)
left++;
while(list[right] > pivot)
right--;... | stackexchange/codereview |
I am very new to coding and really started a few weeks ago for a new job I have. out of necessity, I am slowly learning VBA (which I can't say is very easy...) I started by recording macros in Excel and copy/paste bits of VBA codes from the internet. A good chunk of them came from SO, which prompted me to join and try ... | stackexchange/codereview |
Given input such as:
foos = [
[],
[{'a': 1}],
[{'a': 1}, {'a': 2}],
[{'a': 1}, {'a': 2}, {'a': None}],
[{'a': 1}, {'a': 2}, {'a': None}, {'a': None}],
[{'a': 1}, {'a': None}, {'a': 2}],
[{'a': 1}, {'a': None}, {'a': 2}, {'a': None}],
[{'a': 1}, {'a': None}, {'a': 2}, {'a': None}, {'a'... | stackexchange/codereview |
This is a form generator I created so users can input a URL, description and link. The output will eventually be a JavaScript news slider. The HTML the form generated is irrelevant for now but I'd like to see how I can improve the JavaScript code handing the processing.
This is my first version/draft.
<style>
body{
... | stackexchange/codereview |
I have created a thread-safe and lock-free memory pool program using C++11 features. A couple of notable features:
g_memStack is a stack that contains the memory unit; we can allocate memory from it.
g_waitingReclaims is something like a stack that contains units waiting reclaim from the memory unit.
g_allocatingCount... | stackexchange/codereview |
Whilst learning from a Python Networking book, I've made this tool to perform a Man in the Middle attack by ARP-Spoofing on a Network. I think this has been done plenty before.
from scapy.all import *
import os
import sys
import threading
import signal
def restore_target(gateway_ip, gateway_mac, target_ip, target_ma... | stackexchange/codereview |
After the tips from my previous review. I have come up with these changes:
Changed my braces to start on a new line
Used the Single Responsibility Principle
Return early whenever possible
Use a namespace that doesn't start with an underscore
I'm not entirely sure I have used the namespace correctly. If it's wrong, c... | stackexchange/codereview |
I have thought a lot about this but can't come to a proper solution. Also, it's hard to google things like this.
Note: The code itself is irrelevant, it's about how to do such a thing in general.
I have a class named Creature which has the following method:
private void move(int direction, LyxCamera camera, MapLayers m... | stackexchange/codereview |
I was having a chat with a friend about data structures (as you do), and that, and his love of portmanteaus meant that he came up with a Quack - A queue and a stack, stuck together in the dumbest way, as it just gives you a tuple of the front and back items. I thought that it might be at least possibly useful if it was... | stackexchange/codereview |
I am new to C# and I have a simple /upload controller to upload an image to S3. Everything seems to work, just fine but it seems messy.
The function:
Takes multipart form data
Reads it async
Picks out the image
Picks out the associated identity of the image
Reads the identity as a stream
Gets a stream of the image b... | stackexchange/codereview |
I have been a VB developer for couple of years, but strictly using functional programming paradigms — I just started using object-oriented paradigms a few days ago, and want some advice on how to improve.
I'm writing a small calculator application in order to understand VB.NET object-oriented principles. The program is... | stackexchange/codereview |
I have this universal error handler for my HomeKit app (currently in development). It grew out of wanting a single place to write error messages, show alerts, etc. I wanted a short, simple way to call it from anywhere that may generate an error.
Here's the class:
import UIKit
import HomeKit
class ESErrorHandler : NSOb... | stackexchange/codereview |
I'm in the process of making my first GUI with Python. I'm trying to make something for work, so I've replaced all the info with fruits. It just lets the user tick some boxes, then creates a word doc
It's quite messy, and the variable names will be renamed later. But what I wanted to ask about was the functions I've de... | stackexchange/codereview |
I made a navigation bar on the left side of my site. It works perfectly, the only problem is I'm new to jQuery and I think I'm repeating too much code. Is this the case? If it is please help me out.
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.... | stackexchange/codereview |
I have created a queue in javascript. This queue also has blocking take(). As you all probably know this is not really true, because javascript does not have threads. It just wait until element has been added to queue. You can view to source-code at https://gist.github.com/2467432. I try to write testable code. As you ... | stackexchange/codereview |
A quick and dirty line-based approach for detecting duplicated text blocks.
Did not find any references as to what (deterministic) algorithms are there for detecting duplicated text blocks, so went with the most straightforward way: take the biggest possible text block starting from fist line + 1 to the bottom, keep re... | stackexchange/codereview |
I have multiple products that all have sizes and I need to find the cheapest configuration that meets the minimum required size.
For example, John needs a minimum of 10 litres of storage - it can be more, but not less.
There are 2L, 3L, 5L, 8L and 10L options (but this can change).
As an example, it might be cheaper ... | stackexchange/codereview |
Right now I'm studying Java, and as a part of understanding arrays, I've implemented a Tic-Tac-Toe game based on two-dimensional array.
Any suggestions/comments are much appreciated!
Source code will be below, also available in GitHub repo.
Main.java
package TicTacToe;
import java.io.BufferedReader;
import java.io.IOE... | stackexchange/codereview |
I think that the following code isn't really nice. I can't see however another way (other than a switch statement) to better implement this. Especially since I don't think replacing this with the strategy pattern for instance is a better way.
String status;
if(userHasContact&&contactHasUser) {
status = "HAS_CONTACT... | stackexchange/codereview |
I am trying to come up with a good File System Design using C++ / OOP. This is being done to gain an understanding of System Design and Design Patterns.
I have some basic functionality, like reading and writing files, adding and deleting files and folders, calculating the size of files and folders. The design pattern I... | stackexchange/codereview |
Every shim I have seen for this function has used the IE-only CSS expression trick. While there's no denying it's effective, it's made useless if the browser is not IE and doesn't support querySelectorAll either.
jQuery is out of the question, since I don't want to get a whole framework just to shim one tiny little fun... | stackexchange/codereview |
I have a Dockerfile with ubuntu:22.04 as a base image and a manual Python installation(specific version i.e., 3.11.1) layer which takes a long time.
Approach 1:
Build a custom_image with ubuntu:22.04 as a base image and a manual Python installation layer.
Create another Dockerfile with custom_image as the base image a... | stackexchange/codereview |
I'm doing a simple task in Rust after reading the Rust book:
read a text file
split it at whitespace
sanitize words by removing non-letter characters
sort the words by their frequency of occurrence
Here's what I've got, which works, but I'd like some advice:
are there any unnecessary implicit copies that could be re... | stackexchange/codereview |
I'd like to improve this code.
DoublyLinkList.java
public class DoublyLinkList<T> {
private static class Node<T> {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
}
public void displayNode() {
Sy... | stackexchange/codereview |
Until now we have always initialized the repositories, that containing MySql functions, at the beginning of each Form
Something like that
Form example code:
public partial class FormTest: Form
{
private readonly ProductRepository prodRep = new ProductRepository();
private readonly UserRepository userRep = new U... | stackexchange/codereview |
This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++ and A recursive_transform Template Function with Execution Policy. Based on the previous questions, I am trying to consider execution policy parameter for recursive_transform function here.
The exp... | stackexchange/codereview |
I wrote a matrix library to replace my old matrix library. I was using my old matrix library to do basic operations for 3D rendering but that library grew old and now I'm seeking to replace it. I'm mostly looking for comfort while writing code and I want to know what you think about the coding style and the simplicity ... | stackexchange/codereview |
I am making a video editor with tkinter, and seriously need to clean it up and make it nicer to read / more efficient. Can anybody help me clean up my code (I was sent here from stackoverflow)
Here it is: https://github.com/MiniMinnoww/moviepy-video-editor
The parts I kinda need to figure out are:
Buttons and popup wi... | stackexchange/codereview |
I want to return a list of the values from the binary tree. Is there a shorter and more efficient way to write the method for numbers?
class BTNode(object):
"""A node in a binary tree."""
def __init__(self, item, left=None, right=None):
"""(BTNode, object, BTNode, BTNode) -> NoneType
Initializ... | stackexchange/codereview |
I want to create a monad which will prevent more than 10 instances of recursion (which I am implementing by preventing more than 10 instances of >>=). My >>= definition seems kind of long and messy though, so I am wondering if there is a better way to do it.
I am including a factorial function which uses this monad as ... | stackexchange/codereview |
My project is written in node JS + Express and has the following architecture:
routes (e.g controllers)
models (stateless functional modules)
app
Models objects only doing SQL queries like this:
exports.setPassword = function (id, password, callback) {
pg.connect(conString, function (err, client, done) {
if (er... | stackexchange/codereview |
Is this a performant strategy to implement a stack in Kotlin to compare and delete values?
Expect
Create a stack in order to compare an array of asteroids (ASTs) and handle collisions (deletions), returning the final array of ASTs after collisions.
Each AST moves at the same speed
Negative numbers move left, positive ... | stackexchange/codereview |
I have a file to process with sed but I am not quite familiar with the commands with capital letters used for multi-line patterns. I use seq to test the script and I have converted it to the problem described below. The sed script and expected output are also attached. I believe the script can be written in a much bett... | stackexchange/codereview |
Here is my attempt on implementing "Degrees of Wikipedia" (much faster version can be seen at degreesofwikipedia.com.It's basically an algorithm which tries to connect two unrelated Wikipedia pages by traversing the internal wikilinks they contain. This version in order to produce faster result doesn't look for the exa... | stackexchange/codereview |
I am solving a problem on Leetcode that requires me to design a hash set. I intend to solve it using linked lists where each linked list would represent a bucket.
I am intending to implement this:
However, I am failing in one large test case.
This is my solution that failed a test case mentioned below:
class MyHashSet... | stackexchange/codereview |
Recently I was asked in an interview to convert the string say "aabbbccccddddd" to "a2b3c4d5". i.e we have to avoid repeating same character and just adding the repeat count. Here 'a' is repeated twice in the input and so we have to write it as 'a2' in the output. Also i have to write a function to reverse the format (... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.