instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
This is a problem from exercism.io. View the repo here (contains full example of song).
Problem statement:
Generate the lyrics of the song 'I Know an Old Lady Who Swallowed a Fly'.
While you could copy/paste the lyrics,
or read them from a file, this problem is much more
interesting if you approach it algorithmically.... | stackexchange/codereview |
I currently have the following class that takes a custom file object as an argument and makes a copy of the file locally.
class FileCopier
def initialize(file_info_object)
@file_info_object = file_info_object
end
def copy
File.open(local_file_path, 'wb') do |f|
read_file_in_chunks do |chunk|
f.write ch... | stackexchange/codereview |
Context:
I have already seen different implementation of multi-dimensional arrays, but most of them use that kind of access arr(i, j, k) while I find more natural arr[i][j][k] like what we have when we use non dynamic multi-dimensional raw arrays or containers of containers. And I really want contiguous data storage, w... | stackexchange/codereview |
I have that XML-to-JSON function based on ElementTree. It looks very simple but until now it does what it's supposed to do: give a JSON description of the document's ElementTree.
import xml.etree.ElementTree as ET
def dirtyParser(node):
'''dirty xml parser
parses tag, attributes, text, children
recursive
... | stackexchange/codereview |
In F# the Railway Oriented Programming pattern can be implemented synchronously using the Result<'t,'terr> type as result value for functions, so they can be foreward piped like:
let result =
func1
|> Result.bind func2
|> Result.bind func3
|> Result.bind func4
I would like to implement the same patter... | stackexchange/codereview |
I wrote this code for an assignment. It was originally meant to be written in Maple, but got very frustrated with some of Maple's idiosyncrasies that I decided to play around with Pandas instead. This is a very trivial multi-linear regression model, which calculates variable weights using least-squares optimisation, an... | stackexchange/codereview |
I took the basic layout manipulation from a jQuery plugin called flexImages. The idea is to use the directive tag and encapsulate a piece of code that will be transcluded to make up the container cells of each row. Unlike the jQuery plugin I didn't want to force defining the initial width and height of the container ce... | stackexchange/codereview |
Could anyone comment on what could be done better and if I made any mistakes?
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<pair<int, int>, int> Edge; //a, b, length
// A---------B
// length
vector<Edge> prims_algo(vector<vector<int>> graph, int number_of_nodes){
... | stackexchange/codereview |
Recently on SO there was this question
i am trying to get sequence index of each array of array like I have
an element of the array and that 5 arrays have multiple elements and I
want to get the first index of each array then the second and so.
below is my array data const arrData = [[1,2,4,6],[3,8,7],[12,13],[],[9,10... | stackexchange/codereview |
The previous code (as displayed in Timer utilizing std::future) is now:
#include <chrono>
#include <functional>
#include <future>
#include <iostream>
#include <list>
#include <mutex>
#include <thread>
// PeriodicFunction
// =============================================================================
namespace Detail... | stackexchange/codereview |
The following code is what I'm using to send a password reset email. The specific part I'm referring to is how I'm setting $message. Would there be a cleaner way to do this or is this about as clean as you can get?
/**
* Attempt to send reset link
* @return bool True if success, false if not
*/
public function try()... | stackexchange/codereview |
I have a for which loops for X files, if the current file is the file Y i have to skip it if the condition dcc.payload.v[0].dn === dcc.payload.v[0].sd && dcc.payload.v[0].dn > 1 is true, else i have to make my checks and return the result.
The issue is that after adding that new condition my code even if it's small bec... | stackexchange/codereview |
I've been testing login forms on a couple web applications (mostly 'flasky', developed on the O'Reilly book 'Flask Web Development'), developing a bruteforce Python script meanwhile. I have NOT mounted a real attack except on localhost, although parts of the script (NOT the concurrent connections) were tried against ot... | stackexchange/codereview |
MyStack.h
@interface MyStack : NSObject
- (id)pop;
- (void)pushObject:(id)object;
@end
MyStack.m
@interface MyStack ()
@property (atomic) NSMutableArray *stackArray;
@end
@implementation MyStack
- (instancetype)init {
self = [super init];
if (self != nil)
{
_stackArray = [NSMutableArray new];... | stackexchange/codereview |
This is my first project using Python OOP. I don't know whether the code I have written is correctly or not. How can I make this code feasible?
Machine.py
Class containing some default values
class Machine:
dict_coffee = {
'Cappuccino' : 100,
'Cafe Latte' : 200,
'Espresso... | stackexchange/codereview |
Hey everyone I have a very simple go REST API that is running CRUD operations on an in-memory object. I would love some feedback on how I can refactor this code, and how/if I should break this up into more than one file (main.go). I am extremely new to Go and want to learn the best way to write something like this.
Som... | stackexchange/codereview |
This section of code reside in a utility class (LDAPUtility). It's purpose is to subscribe or unsubscribe a user from an LDAP group. My main questions are if I am using the LDAP library correctly and if I am handling the memory management correctly.
+ (BOOL)addUser:(const char *)userDN toGroup:(const char *)groupDN {
... | stackexchange/codereview |
I am working on converting a mailing list that has longitude and latitude coordinates within the CSV file. This script I came up with does what I need, but this is my first real-world use of python. I want to know where I am making any mistakes, not using best-practices, and what can be optimized to make it faster.
The... | stackexchange/codereview |
Here is my very first event dispatcher. I would like to get both, style and code review, as well as some ideas to improve this implementation (new features etc.)
I tried to write code in C++17 style as much as possible.
IEventDispatcher.h
#pragma once
#include <map>
#include <functional>
template<typename EventType>
... | stackexchange/codereview |
I will begin this question with the disclaimer that it is homework but my code is written and working, I just want to know if there any ways in which I can improve what I already have. I want my programs to be as clean and easy to understand as possible.
My task is to Build two classes (Fraction and FractionCounter) a... | stackexchange/codereview |
I'm solving "Unknown amount of duplicates. One missing number.":
In this kata, we have an unsorted sequence of consecutive numbers from a to b, such that a < b always (remember a, is the minimum, and b the maximum value).
They were introduced an unknown amount of duplicates in this sequence and we know that there is a... | stackexchange/codereview |
This is quite a specific script I have written, for Kubernetes Cluster monitoring purposes (specifically the Nodes). Essentially, I need to ensure that the Nodes within a NodeGroup all have the same labels and label values, or else they will not be scaled out evenly for Node Scale out in the version of Kubernetes we ar... | stackexchange/codereview |
In Service.Insert(), I call DeviceRepo.Insert() and in Service.Update(), I call DeviceRepo.Update(). All my other code is exactly the same.
I'm thinking I can make one method that do the same thing update. I want to update and insert when I will insert a device.
The methods respectively insert a new or update an existi... | stackexchange/codereview |
I'm learning object-oriented programming in Python. I've created a class RepositoryMaker that contains all methods required to create a Git repository. The idea is to be able to create a single instance of this class with a constructor that only requires pertinent info to create a new repo.
My code looks like this:
cla... | stackexchange/codereview |
I have cleared all my scripting from the use of JQuery, but sometimes I miss a few handy extensions. Now I'm playing with the idea to "extend" document.querySelectorAll with some handy stuff, using the proxy Object. Here's a snippet to demostrate that idea.
The advantage seems that there's no juggling around with this... | stackexchange/codereview |
I am currently building a small conversational bot, and I am struggling with the architecture. I use Facebook Messenger combined with Wit.ai's API and a Shopify store API. My rails app is the interface between those three APIs.
First, the rails app receives a message from Facebook. It transfers it to Wit, which sends b... | stackexchange/codereview |
Today I started to build my first platformer, first time working with collisions and stuff. Now, surprisingly, everything seems to work, but since this is my first time creating a platformer and I'm still a beginner with collisions I don't know if the way I coded it is good practise.
The game is a ball with a fixed x c... | stackexchange/codereview |
I've used encountered this exercise from a tutorial:
Create a function that takes a string as a parameter and returns True if the initial word of the string passed is an article (“The”, “A”, “An”) and returns False if it isn't an article.
Be careful, if the string starts with “There”, it does not start with an article... | stackexchange/codereview |
I won't restate the problem in full, but in a nutshell you have to parse a file with a "direction" and a "magnitude", for instance:
forward 8
forward 3
down 8
down 2
up 1
forward affects your horizontal position and up and down your vertical position. There are no other directions.
At the end, you're asked to multiply... | stackexchange/codereview |
Scenario
Once upon a time, there was this human (ahem, me, ahem) who tried (and succeeded) to build a small program which would convert JSON to a MSSQL query using Python 3.x.
How does it work?
The user makes a POST request with a JSON (in the code, I've used a JSON file) which looks like this:
{
"endpoint": "rfc",
... | stackexchange/codereview |
I am semi new to coding and have been following a tutorial on making a "text based RPG" on CodeClub.
Here is the full code:
#!/bin/python3
# Replace RPG starter project with this code when new instructions are live
def showInstructions():
#print a main menu and the commands
print('''
RPG Game
========
Get to the... | stackexchange/codereview |
I'm currently learning haskell, and I wanted a simple project to get started. This project uses the JuicyPixels package to handle image reading. The logic of the image to ascii art algorithm is quite simple:
quantize the image in a number of bins equal to the number of ASCII character we want to use
map each pixel to ... | stackexchange/codereview |
I have a problem where I need to replace every base part of URLs in a body of text. However, I only want to replace it in specific URLs. Only URLs that go to "resource.aspx" that have the "source" query string parameter need to get the replacement. Other URLs could have the target base part and we don't want to touc... | stackexchange/codereview |
My code sample for finding the mean for the case of pairs is:
import numpy as np
Data =[]
with open('testdata.txt') as my_file:
for line in my_file:
Data.append(line)
psize = Data.size*Data.size
p_avg =zeros(psize,float)
for i in range(0,Data.size):
for j in range(0,Data.size):
if i != j:
... | stackexchange/codereview |
function ExecuteWindowsTaskScheduler {
param(
[Parameter(Mandatory = $true)]
[String]$TaskName, #e.g. "Open Notepad task"
[Parameter(Mandatory = $true)]
[String]$TimeToExecute, #e.g. "3:45pm/am"
[Parameter(Mandatory = $true)]
[ValidateSet('Once','Daily','Weekly, Monthly')]
[string]$Frequen... | stackexchange/codereview |
I have written this shell script to backup MySQL database to disk. It works fine but I am not well proficient in shell scripting. So what do you think can it be improved?
#!/bin/bash
#For taking backup
APPEND_CLI=$3
DIR=/media/storage/backup/db_backup/
DATESTAMP=$(date +%d-%m-%y-%H-%M)
DB_USER=backup
DB_PORT=$2
DB_PAS... | stackexchange/codereview |
I've written a query to compare the clients in our database with the people in a list that I've received. It needs to check if anyone from the list is one of our clients. I've created a temporary table which has been filled with the names and the query below makes a cross-join with the two tables. That query works very... | stackexchange/codereview |
I'm crawling Flickr for data for my university research project. However it's very slow and I'm not sure what it is exactly. It could be the FileWriter slowing it down. Any advice on speeding it up?
try {
String userID = file.getUserIDFromList(i);
System.out.println(i + "." + " " + userID);//to screen
S... | stackexchange/codereview |
Requirements:
Implement a function that, given a standard date and an indicator
whether or not the output should be in american standard (weeks start
on sundays, the first week of the year is the week containing the
first day of the year) or in ISO8601 standard (weeks start on mondays,
the first week of the year is th... | stackexchange/codereview |
I've been building a system for inputting and monitoring shifts for casual staff, who work across multiple sites with the ability to generate accounting information.
I've had some help from Stack Overflow in building this project, as I had no prior knowledge of PHP or MySQL, and each time I posted some of my code I had... | stackexchange/codereview |
This is just simple code to practice the use of virtual functions from a practice challenge in HackerRank. Could you give me some advice about the best practices and style?
This is just a simple exercise from HackerRank
#include <string>
#include <array>
#include <numeric>
#include <iostream>
#include <algorithm>
cla... | stackexchange/codereview |
I have to run a script against 40 million objects in my database:
I wrote the script and I want 10 instance of it so I process my objects faster.
The goal is to find all the neighborhood for each property.
A little bit of context: Multiple properties can have the same
lat/lon.
A Location is a city.
I stored all th... | stackexchange/codereview |
Goal
I want to get the index of the min of last 3 rows based on low column.
date hy_code low
0 1990/12/19 A 95.79
1 1990/12/20 A 99.98
2 1990/12/21 A 103.73
3 1990/12/24 A 109.13
4 1990/12/25 A 114.55
5 1990/12/26 A 120.25
6 1990/12/27 A 125.27
7 1990/12/28 A 125.28
8 19... | stackexchange/codereview |
I am using TestNG Data Provider and constituting following data set depending on the elements in the list. Offer list would have either one or at-most 2 elements and I would like to test with all of the available elements, along with one extra data value which I always test with -
private Object[][] getProductOffers() ... | stackexchange/codereview |
I'm using react-window to virtualize a list. My list is supposed to fill in the container's completely and the container's width and height are 30vh and 100vh. Since the dimensions are dynamic and react-window requires me to provide constant dimensions, I'm hooking into the onresize event and updating the state of the ... | stackexchange/codereview |
I had an assignment to create a table that will be stored in ROM (read only) and will be used in some algorithms (to convert numbers to strings). However sometimes a user will want to edit the table a bit before using it in the algorithms. So the user must be able to copy the table to RAM, change it and then use it.
W... | stackexchange/codereview |
I'm working off a specification that says a bunch of fields within a record (one record being one line) must be blank. For example, it says that chars 6-14 must be blank. I am building a class hierarchy structure that represents the layout of the file, and within this class hierarchy I'm including every field for each ... | stackexchange/codereview |
Given an undirected graph and a number m, determine if the graph can be colored with at most m colors such that no two adjacent vertices of the graph are colored with same color. Here coloring of a graph means assignment of colors to all vertices.
Special request to verify complexity:
Complexity:
Time:
\$O(EV^2)\$ :w... | stackexchange/codereview |
Inspired a bit by a previous Brainfuck question and the recent fizzbuzz invasion, I decided to make FizzBuzz in Brainfuck.
The code is entirely my own, except for the inclusion of the Printing a number algorithm that I found on StackOverflow.
My code is divided into several parts.
Setup Construct the tape to contain s... | stackexchange/codereview |
Inspired by this question, I went on with the following version. My goal was to focus on pure functions, to avoid mutable variables and to be strictly functional.
I have ignored the computer player part - as it will not change the overall design.
An issue may be that an unchanged player survives from one game state to ... | stackexchange/codereview |
I've made the following and have a few questions:
Do I have some (big) mistakes in this approach? (bad practices, 'this code is trash'...)
1.1 If I do, can you suggest what to fix?
Are appended element created in good way?
Code in success function seems to be a little long. Any way to refactor?
CSS code
.no-displa... | stackexchange/codereview |
I have create a functioning automated traffic light sequence using an array and if statements. It all work correctly but I am wondering if there is anything more I can do to improve my code without changing to structure or way it works, so without the use of dictionaries, etc.
<!DOCTYPE html>
<head>
<title> Traffic ... | stackexchange/codereview |
I had to create a program that had a struct that held data inside of it. I had to read an input file and take the contents and read it into an array of structs. Then, I had to solve for some particular statistical data such as finding the lowest and highest scores from the data. I completed my source code and it runs a... | stackexchange/codereview |
I followed the tutorial Build a PHP MVC Application and have implemented a database connection. I made a seperate database connection class and I call it in the controller.
It works, but now I have to inject it whenever I call a method from the user model. Is this considered good (dependency injection) or bad (repeatin... | stackexchange/codereview |
The code below finds the index of the lowest unique integer on each line of the file. The numbering starts at 1, and when there's no unique value, the 0 should be output.
The sample input looks like this:
3 3 9 1 6 5 8 1 5 3
9 2 9 9 1 8 8 8 2 1 1
And the sample output is this:
5
0
I wonder if this code can be simplif... | stackexchange/codereview |
I am trying to create a horizontal accordion using jQuery. The code works fine, but I just want to know if my approach is correct and if there are any improvements I could make to the existing code.
$(document).ready(function () {
$("ul li").children(".Acc_Content").animate({ width: '0px' },{ duration: 1000, queue: f... | stackexchange/codereview |
I have the following package to generate combinations from a slice of bytes:
//Package combinations generates combinations from a slice.
package combinations
//CombIter generates combinations of bytes of given length from a
//list of elements. It returns values by a channel outC
//An empty list indicates that no furt... | stackexchange/codereview |
I'm working to use everything I'm learning in my reading and former code reviews to keep making this program better. I'm getting stuck on the following issue: the play_many_games and game_is_over methods in the GamesEngine class both call reports. I don't like this because the method names don't at all lead one to beli... | stackexchange/codereview |
Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.
Example: given words = ["practice","makes","perfect","coding","makes"]
Input: word1 = "coding", word2 = "practice"
Output: 3
We assume word1 does not equal to word2, and both are in the list. Lis... | stackexchange/codereview |
I find sometimes it is useful to capture the notion of invertible functions.
The idea is that if two functions f :: a -> b and g :: b -> a are the inverse function of each other, and if there is another function h :: b -> b, then h can also work on values of type a.
Moreover, if there f' and g' are another pair of func... | stackexchange/codereview |
This program is basically a rhyming dictionary. It makes use of Sphinx's groups phonemic dictionary of English which includes a lot of words broken into their respective phonemes, and if we assume that, at least for most cases, anytime the two last phonemes match, the two words rhyme, then it's very easy to whip up a p... | stackexchange/codereview |
import random
import string
# every def from 'def nothing()' to 'def wxyz()' Print out several lines of text, printing: keyword 1, call number, phone number and keyword 2
def nothing():
print("keyword: (nothing)\ncalls: 1\n" + str(random_number()) + "\nkeyword: exit\n")
def abc():
print("keyword: abc\ncalls... | stackexchange/codereview |
Now I'm reading C Premier Plus by Stephen Prata and there's an exercise 4 in chapter 6 which has no solution in the book, so I can't check if I did it properly. My code works like it should, but I want to know maybe there are some better or cleaner solutions.
Here's the description:
Have a program request the user to ... | stackexchange/codereview |
This code is executed very often, so I'm wondering if it's already ideal or if it's possible to optimize it further.
var highlightLinks = function(e)
{
var anchors = e.target.getElementsByTagName("a");
let file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.in... | stackexchange/codereview |
I'm working on building an encrypt/decrypt feature using AES, and a fixed AES 256-bit key size. I have decided on using AES-GCM, as it seems the most performant and secure.
I would like to know whether the following use of the browser's Crypto.js library is correctly used.
async function generateAESGCMKey() {
... | stackexchange/codereview |
I decided to setup a generic makefile to compile SFML programs, as I'm going to be making a bunch of small apps over the next few weeks playing around with it. I'm still new to writing makefiles (still weaning off of using IDEs), but I'm pretty happy with how it turned out.
#############################################... | stackexchange/codereview |
Good day. My code works but I think there is a better way to do this. Like string pattern or string manipulation. I'm not yet familiar with both terms.
The goal is to get "=A1-A2-B3-D4-WHATEVER STRING=". From array of strings.
The code is :
string[] arr = { "A1", "A2", "B3", "D4", "WHATEVER STRING"}; // can be any stri... | stackexchange/codereview |
I am trying to get ordered components of an interface properly without having a local variable orderedComponents outside, and here is my current code.
Reason is because orderedComponents will be in Interface.java and getChildren will be in componentDefinitions.java and I want a more controllable code.
I was also thinki... | stackexchange/codereview |
I'm simulating my real-world application by using a really simple demo app here, but it has the same concept. The question is MVVM Light Toolkit specific, as the purpose of my project is to learn the workings of the toolkit.
Let's say I have a Main form, inside which I have a UserControl. The Main has a stand-alone Tex... | stackexchange/codereview |
The codes below is in DLL.
Here's the problems that I can identify:
1) Caller won't know what's the exception?
2) Catch exception 1 but throw exception 2.
3) num is not sum but overwrite.
What else?
These codes are in production, I just found it not well written.
I would like to get more feedback and is there any othe... | stackexchange/codereview |
The challenge is this: You have a function that is passed a board length (8x8 chess board), with the coordinates of the queen's location, along with an array of obstructions (opponents). Given the location of the queen, how many moves spaces are available for her to move, total?
This is the solution I came up with, bas... | stackexchange/codereview |
I'm new to Haskell, and here is my first not-totally-trivial program. It's the first program I tend to write in any language -- a Markov text generator. I'm wondering what I can change to make it more idiomatic, or what language features I could make better use of.
import Data.List
import System.Environment
import qual... | stackexchange/codereview |
I am developing a chat system including chat bots and human chat users.
Every user must be stored in one large list.
Possible implementation using multiple type constructors:
data User = Human { humanName :: String, humanAge :: Int }
| Bot { botName :: String, botAge :: Int }
deriving (Show, Eq)
... | stackexchange/codereview |
My code have too much nested option processing which makes it ugly. But it has an advantage it has no side effect and typesafe.
package repos
import java.io.{InputStream, File}
import org.apache.poi.hssf.usermodel.HSSFWorkbook
import org.apache.poi.ss.usermodel.{Cell, Row, Workbook, Sheet}
import org.apache.poi.xssf.... | stackexchange/codereview |
This is a follow up question of Importing different type of files into Lists. Where the original lists are acquired.
In this script I am processing the obtained lists, and comparing them with each other to determine whether or not a used material has duplicate functions. This using their most commonly known traits, wh... | stackexchange/codereview |
The code below generates a list of Pascal Coefficients.
e.g pascalList 3 outputs [[1], [1,1], [1,2,1], [1,3,3,1]
Can we write below sample in more idiomatic way
pascalList 0 = [[1]]
pascalList 1 = [[1], [1, 1]]
pascalList n = let pList = pascalList (n-1)
in pList ++ [([1] ++ pascalCoeff (last pList) ++... | stackexchange/codereview |
I have two sheets named source and solution and I have to perform following activities.
Copy new records from source to solution.
Update records if rows present in source and have updated data.
Delete rows from solutions if rows not present in source file.
I have written following vba code.
Sub processDuplicate()
... | stackexchange/codereview |
This is code for Inorder, Preorder, Postorder Traversal of a Tree. Suggest some ways to improve it (since I have made root public and want to make it Private).
#include<iostream.h>
#include<conio.h>
struct Node
{
int data;
Node *left;
Node *right;
};
class Tree
{
private:
Node *p;
public:
Node *roo... | stackexchange/codereview |
Given an array of ints, is it possible to divide the ints into two
groups, so that the sum of one group is a multiple of 10, and the sum
of the other group is odd. Every int must be in one group or the
other. Write a recursive helper method that takes whatever arguments
you like, and make the initial call to y... | stackexchange/codereview |
I have seen UInts being natively supported in other languages. PHP allows you to install a third party extension, but I can't do that ATM, so I've decided to create my own class.
In which ways could/should I improve my code. Both in terms of overall code quality aswel as performance?
final class UintArray implements \C... | stackexchange/codereview |
I have an Account, User and Group model. All User and Group records belong to an Account, so it is possible for both users and groups to be related to various accounts.
Basically, I have some really hacky, pieced together SQL queries that lookup all Account records related to a given User or Group record through variou... | stackexchange/codereview |
The reason I asked about standing the test of time is that I previously used PHP echo to create a string and placed it into a div with .innerHTML, but modern browsers were not passing the value of the select box. (Went back and tested wit IE9 and the innerHTML version worked.)
file:js_selecttest.php
<form method="post"... | stackexchange/codereview |
A month ago I reviewed the code in Resizable split DIVs Vue.js, suggesting that the OP use computed properties and bound styles to simplify the code (at least reducing the need to use $refs to access DOM elements). Below are two variations I devised. They are very similar. The main difference is that the second uses -1... | stackexchange/codereview |
You are driving a little too fast, and a police officer stops you. Write
code to compute the result, encoded as an int value: 0=no ticket, 1=small
ticket, 2=big ticket. If speed is 60 or less, the result is 0. If speed is
between 61 and 80 inclusive, the result is 1. If speed is 81 or more, the
result is 2. Unl... | stackexchange/codereview |
I have a module collection.py that functions as a tool to collect tweets using tweepy. It has two classes : Authentication and Collection.
Authentication class will create an object that acts as a starting point to collect data from twitter. An instance of this will the an argument for Collection.
Collection class will... | stackexchange/codereview |
I have written a small bit of code to tell me how many hours I need to work to finish up my 40 hours a week each day.
I can add hours per day and it will calculate total hours left in the work week.
My main issue with it is the way my math is written. It just seems so complicated and unnecessary but I was unable to fin... | stackexchange/codereview |
I'm currently halfway through a Python project, but would like a review before I spend too much more time on this to avoid going too far down a rabbit hole.
I had previously wanted to use HTML, CSS, and JavaScript, but I swapped to Python so I can get the current Window's user while opening my app.
At my work, we have ... | stackexchange/codereview |
This is my first Qt app and also some of my first non-trivial C++ code. The application displays a menu offering two options. Clicking either option takes you to a sub-page with some text and a back button, taking you back to the menu.
Feedback I'm especially interested in:
Am I doing anything weird, culturally, eith... | stackexchange/codereview |
I'm writing a plugin and want it to have no dependencies. I create a form and append it to the page, but the code is really long. Does anyone have any suggestions to clean it up, perhaps shortening it? I feel like there must be a better way!
// Create elements
var elements = [
reporter_wrapper = ... | stackexchange/codereview |
I'm new to competitive programming and C++ in general. I have solved the Kattis Animal Classification challenge. We are given two classification trees, each represented using nested parentheses. For example, ((3,(1,(5,2))),4) and (((5,1),(2,3)),4) represent the trees
╱╲ ╱╲
╱╲ 4 ... | stackexchange/codereview |
I retrieve data from an Excel file located on sharepoint.com using Microsoft.Graph like this:
var workbookRange = await graphServiceClient
.Sites[SiteId]
.Drive
.Items[ExcelFileId]
.Workbook
.Worksheets[WorksheetIdId]
.Range("B2:C500")
... | stackexchange/codereview |
I am planing to create a small game using C#, so I've decided to create a small logic for that game. I immediately opened Visual studio and started to create some classes to hold on the player's data, so I came up with something like this. However, I don't know whether or not there is better ways to achieve such thing... | stackexchange/codereview |
This is a pong game I created some time ago, but it doesn't have methods to store scores yet and also might have some bugs. It is also very slow.
The code:
from tkinter import Tk
from random import choice
import os
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
class Pong:
def __init__(self):
... | stackexchange/codereview |
I need to convert a string using these rules:
Downcase the string
Replace spaces, a blacklist of "invalid" chars, and non-ascii letters (like é) with -
Replace repeated hyphens (ie --) with one hyphen (-)
For example, Is my résumé good enough? should convert to is-my-r-sum-good-enough-.
This Swift function converts t... | stackexchange/codereview |
I've written some code to brute-force enumerate the solution space of nonogram puzzles up to a certain size. It does a good job up to the first ~4 billion puzzles, but I run out of disk space to store any bigger collection of the solution space set.
Because of some incredibly interesting patterns within the encoded set... | stackexchange/codereview |
I was just wondering if this is a good example, following good practices, of a C program for launching an interpreted script from a native binary executable. Here the interpreter is Perl and the script an implementation of something analogous to du --apparent-size, but the idea is general.
Also, is this code secure aga... | stackexchange/codereview |
The program reads a .txt file that contains lines of numbers. The first one has one number N and the second one has \$N\$ numbers as the first line says.
The \$N\$ numbers is \$1 \le N \le 1.000.000\$.
The program read the \$N\$ numbers in an array and performs the following procedure:
Read the number one by one back... | stackexchange/codereview |
I am creating a HTML game where you fight monsters and stuff and this is part of the game loop for dealing damage:
var hp = 1000000000;
var speed = 10;
var power = 5;
var lastCalledTime;
var fps;
var GameLoop = function() {
if(!lastCalledTime) {
lastCalledTime = new Date().getTime();
fps ... | stackexchange/codereview |
I have a python print statement and inside the string I wish to print are four digits. I would like to apply the same formatting function to each param. I am not familiar with the latest and greatest features of python PEPs.
Is there a slick way to do this?
Code
statement = "Splitting up the {} file into {} chunks, wi... | stackexchange/codereview |
I am currently using the following query to add a specific row (with 10 columns) from an Excel spreadsheet (~1500 rows and hosted on SharePoint - I've also tested locally with the same issue) to an array in PowerShell.
$connection = New-Object System.Data.OleDb.OleDbConnection
$connectstring = "Provider=Microsoft.ACE.... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.