instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
Here is some VB code that is part of a major system of apps that I have been asked to maintain, one of the more fun things that I get to do is rewrite some code here and there, I have done a little bit of that here, I finally have it functioning properly and would like to see if I am still on an upward stride in my V...
stackexchange/codereview
I have a domain object that I have no control over which itself contains a collection of this same type. This is a classical hierarichal representation like in a tree node hierarchy. I would like to be able to enumerate the whole hierarchy in a single call so I came up with this extension method: public static class My...
stackexchange/codereview
I have a Data First Migration and have been struggling a little with storing an enum value as a string. (Im aware that enums should be stored as ints but, personally I have never liked this, yes enums are hard and fast values but I have always percived them to vary a little bit as the code evolves, i am therefore worri...
stackexchange/codereview
I want to represent components of LXC in django; so I defined them in models: Container, Network, Profile and Devices where each one of them have a set of attributs, but when it comes to representing configuration (each component has a set of configuration fields), I don't know if it is the right approach to follow. Be...
stackexchange/codereview
I have a JSON array or literal (passes through JSON.parse). Requirement: an array of tasks which contains operations which are key/value pairs. Array of tasks > Array of operations (array of operations at times will contain duplicate key/value pairs) [ [ { resize: [1200, 1200] }, { ...
stackexchange/codereview
I have a performance issue in R. I have a function that iterates over a dataframe for different levels of "site" and "method". The function samples 1:1000 interactions (rows), converts these to matrices and calculates a value of connectance for each matrix. This is repeated n times. The function runs exactly as I want ...
stackexchange/codereview
I would like to refactor code below and get rid of if statements for classes from view. .container .tabbable.tabs-left %ul.nav.nav-tabs - @related_tasks.each do |task| %li{class: ("active" if @task == task)} = link_to task.name, "#tab#{task.id}", data: { toggle: 'tab' }, class: @current_us...
stackexchange/codereview
I have created canvas (800x400) - and filled it with a grid. It works but the rendering of the grid (lines) takes around 3 seconds, which seems excessively long. Am I doing something wrong? var drawGrid = function(w, h, id) { var canvas = document.getElementById(id); var ctx = canvas.getContext('2d'); ctx...
stackexchange/codereview
For learning purposes and maybe later on implementing it in React, I made an event system that responds to mouse event to allow element resizing, both in width and height. For now is just Vanilla JS and a few lines of CSS. I would appreciate any criticism especially for the event system that I use. Basically, the black...
stackexchange/codereview
fun readLines(path: String): Stream<String> = try { Files.lines(Paths.get(path)).use { it } } catch (ex: Exception) { ex.printStackTrace() Stream.empty<String>() } I added .use { it } to tack on try-with-resources like behaviour for autoclosing the file handle (?) in case of excepti...
stackexchange/codereview
I have the following code which iterates through some divs of an array to show() them. I was wondering if there is any way to rewrite the for loop using filter(). Will this have a better performance over my initial code? var selectEnabledGenerators = function(generators) { //List of generator indexes to show va...
stackexchange/codereview
I recently wrote my first WordPress plugin, which was also my first PHP project. After I was done, I didn't care for the code at all, so I have spent the past couple of days refactoring it. I'm trying to take a more OOP approach to improve readability and make it easier to optimize. Prior to this, my only real exposure...
stackexchange/codereview
This is my homework. Kindly help me check it? The instructions are: Implement an infix expression to postfix expression converter. You are to implement the infix to postfix algorithm presented in the lecture. You are to use only the stack that was provided in the lab lecture. The use of the stack of JDK or any other ...
stackexchange/codereview
This working script reads a list of URLs from one or more text files, and for each, retrieves the page title from the Internet and appends the results in the format <url/>\t<title/>\n to the output file (for each input file it creates a corresponding output file). I am a Python newbie and would appreciate any feedba...
stackexchange/codereview
I'm trying to implement the game of Yahtzee in java. This is for a project at my university so I tried to be as clean and to use the best code practices as possible. The part in particular that I would like some suggestion on is the one dedicated on keeping the scores (ScoreCategory, ScoreTable and their implementation...
stackexchange/codereview
I want to learn how/when/why to use the GoF Design Patterns. These last days are dedicated to the Bridge Pattern, which means: Decouple an abstraction from its implementation so that the two can vary independently. Everyone has a different understanding of this vague description, but if I well-understood the globa...
stackexchange/codereview
Thanks for the help so far! Especially all of the people who helped out on part I - seen here. Making a report from payroll details Here's the revisions to the code based on feedback from that thread. The goals of this code are to take payroll details in spreadsheet format, and to make a properly formatted report that ...
stackexchange/codereview
I got bored with opening and closing files whenever I need to write to one, so I wrote a FileWriter class that's used like this: Public Sub TestWriter() On Error GoTo ErrHandler Dim writer As New FileWriter If writer.OpenFile("c:\test.txt") Then writer.WriteLine "foo" End If ErrHandler: If...
stackexchange/codereview
From my original question on Stack Overflow: Is my implementation of reversing a linked list correct? I'm a beginner at C and I'd like to know about style, and correctness of the reverse algorithms. What about memory management? #include <stdio.h> #include <stdlib.h> typedef struct Node { int val; struct Node ...
stackexchange/codereview
I have this small piece of code written in a class. I am looking for a nicer way to write this, preferably avoiding nested if statements like what I currently have: @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { TheatreListDataWrapper[] selectedOperations = getSelectedDatas(); boolean ...
stackexchange/codereview
I have just discovered the beauty of prepared statements in PHP and how they protect against SQL injection. In my first time using them, I am attempting to grab a hashed password from a database and seeing if it matches up against the password the user inputted into the login form. Is this the most efficient way to: G...
stackexchange/codereview
I have to update user email and password if they are present in the params, I have other user information also which can be updated. this is the method I have written, but it doesn't seem like a good method def update if user_params[:current_email].present? if @current_user.has_valid_email?(user_params[:curre...
stackexchange/codereview
I have written a C++ program that uses the Crypto++ library to encrypt files using AES-256Bit (in GCM mode). I am planning to eventually have the program store the keys for the files in a file e.g. keys.txt and encrypt that file again, maybe with a different algorithm which apparently adds security instead of using the...
stackexchange/codereview
Inspired by this question: Split a string into chunks of the same length The code is designed to work on text elements rather than chars to avoid unicode problems. public static class StringExtensions { public static IEnumerable<string> Partition(this string value, int chunkSize) { if (value == null) ...
stackexchange/codereview
This question is the follow-up to this previous question. Background Using this simulation I investigate a system in which enzymes proliferate in cells. During the replications of enzymes, parasites can come to be due to mutation. They can drive the system into extinction. I'm interested in where in the parameter spac...
stackexchange/codereview
The first request is sent asynchronously, then the id value is taken from the response to the first request and used in the second asynchronous request. And then both responses to request 1 and request 2 are combined. The example below works, but the code looks so clunky. Is there a better, shorter way to implement thi...
stackexchange/codereview
Please comment on my DFS implementation and test, I would like to get comments about algorithm correctness. Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. One starts at the root (selecting some arbitrary node as the root in the case of a graph) and explores as far a...
stackexchange/codereview
UPDATED I would like to create a class, which is intended to represent a field of values on a 2D grid. So, I would like to access the elements with a double square bracket A[i][j], and inside the __global__ or __device__ function access the dimensions of the field - nx_, ny_, because I do not want to pass them each tim...
stackexchange/codereview
Please see the following code. I am using it to calculate the double integration. Please help me to improve the code. import numpy as np from scipy import integrate from scipy.special import j1 from scipy.special import j0 from numpy import sin from numpy import cos from numpy import pi import time import numba as nb ...
stackexchange/codereview
== UPDATED: next revision HERE == My previous two iterations were here and here. I've since finalized the concept as described in the title, and would appreciate any feedback on the new solution located on GitHub. Introduction: value_ptr is a C++11 header only, deep-copying smart pointer that preserves value semantic...
stackexchange/codereview
I am trying to write a constructor method that takes dd, hh, mm and ss as parameters and change it as a normal type of Time struct (e.g you enter 25 hours as the hh parameter, it changes it to 1 day and 1 hour). struct Time { public Time(int dd, int hh, int mm, int ss) { seconds= ss % 60; ...
stackexchange/codereview
FI_name ISN Sector Industry REC INE02 PS FS HDB INE03 PR FS ABC INE04 PR FS RHC INE05 PR CO ZHE INE06 PR FS HSE INE07 PR FS ZAK INE08 PS MT HGB INE09 PR FS YUJ INE10 PR MT WSD INE11 PS FS REC INE12 PS FS HDB INE13 PR FS ABC INE14 PR FS RHC INE15 PR CO ZHE INE16 PR FS HSE INE17 PR F...
stackexchange/codereview
I am moving a project from Python to C++, partly in order to achieve a speed up. This part of the code reads large .txt data files (well only about 2MB per file, but quite a lot of files), and needs to convert the data to floating point. This C++ code does is not faster than Python bytecode (.pyc). Regardless, my appl...
stackexchange/codereview
I wrote the script below as my first python program that will be running in a production environment. Essentially this program looks at a source location and moves all the files to a destination location if the file is older than 14 days old and does not exists in the destination. I had a user on stack overflow suggest...
stackexchange/codereview
With the comments on the same line as the code, it refers to. e.g NumBob = 0 s = 'sexbobombob' i = range(len(s)+1) #Generates a list from 0 to the length of s u = 0 # This would be the variable storing each value of the list for ans in i: # this allows me to extract each value of i if ans > 0: # Completely arbitrar...
stackexchange/codereview
After reading a certain question on the Stack Overflow website, I tried to write a solution to the problem just for fun. I'm, however, left with the nagging feeling there is a beautiful one-liner that can be used instead. The question's premises: Create a function that will receive a string. The function will count ea...
stackexchange/codereview
I am working on an interview question from Amazon Software: Design an algorithm to take a list of strings as well as a single input string, and return the indices of the list which are anagrams of the input string, disregarding special characters. I was able to design the algorithm fine. What I did in psuedocode was:...
stackexchange/codereview
Here is my code which is going to through multiple for loops to get the matching product attribute. I have single product with attributes trying to find out the matching product with same attribute value from a list of Product. I am having a multiple for loop. Can anyone suggest a way to optimize this solution? // This...
stackexchange/codereview
Is it possible to call multiple metaboxes in Wordpress with less duplicate functions? For instance, these are my current metaboxes (3 of them, one is a checkbox and two others are text input fields): /* * STICKY POSTS * */ function add_sticky_metabox(){ add_meta_box( 'sticky_post_metabox', 'Sticky Post',...
stackexchange/codereview
I am making my first object-oriented program in python and I am having trouble with the __str__ part of Board() class. I want it to be a visual representation of the tic-tac-toe board. I have achieved this but the code looks ridiculous and I know there must be a better way! Here is my project so far: class Space(object...
stackexchange/codereview
Sometime ago I asked a question regarding a slow Filtering method for my DataGrid. Months later and I have a relatively quick method, though I am still looking to improve performance, especially when the user is deleting text from the SearchBox as this seems to slow down more than if the user is typing characters in. O...
stackexchange/codereview
I have researched ways to implement a simpler alternative for C++ exceptions. The problem I had with exceptions was the complex and not-portable stack unwinding process which makes it hard to implement for a multiple systems. However, the alternatives didn't look clean enough to indicate about an error case. In other w...
stackexchange/codereview
I already posted a not (yet) complete version of this class, but that question got closed, because it contained not passing tests. Here is the full version, all 5 tests pass. Originally there was only processPlayer when I found a very rare case (see the last test Special case). The method player is a patch to handle th...
stackexchange/codereview
A followup on my previous question Using blocking queue to calculate data stream. This time suppose we have a list of blocking queues as stated in the following manner: Suppose you have a list of independent blocking queues that will keep getting new data, the new data will always be greater than the last element of t...
stackexchange/codereview
In my react application I have Tabs done with Material UI. Some of those tabs are shown or hide depending on an option is true or false. The code is not a clean solution but I have no experience working with this and was wondering to see a better solution to what I have done. We have 3 options: isEngagementPortal isRe...
stackexchange/codereview
I've been studying data structures and making implementations for different types. This is my linked list code. Please let me know if there's anything here that could be improved upon or changed for better performance. I should mention that it compiles and functions as intended. Also, I'm not sure what I need the frien...
stackexchange/codereview
I am trying to do certain operations in dataframe as shown in my code below. Though this works fine.However I am repeating the same statements twice or following a dirty approach to perform the operations twice. Can you help me to make it efficient and elegant? I have a dataframe df in which I have to apply certain rul...
stackexchange/codereview
I made a random maze generator that is also playable. The performance is crap and I'd like to improve it. I'll be working on this for a few more days to make it run better myself, but just thought I'd leave this here if people want to help. import random, sys, time, pygame from fractions import gcd from pygame.locals i...
stackexchange/codereview
My attempt at writing code to input values of arbitrary bitlength based on a bytearray in Factor. Any comments on the correctness or style would be appreciated. USING: kernel locals accessors math sequences math.bitwise ; TUPLE: bitreader bytearray curpos curbit ; : <bitreader> ( bytearray -- bitreader ) 0 0 bitreader...
stackexchange/codereview
I'm taking CS50 Intro to CS. In this assignment, we're asked to make a program that can identify what type of credit card (AMEX, Visa, MasterCard) is given in the input (and whether it is valid.) Validity is checked using Luhn's Algorithm. Here's how the algorithm works: Multiply every other digit by 2, starting with ...
stackexchange/codereview
This program is an implementation of the Blackjack which is similar to what is played in the casinos. Here were the requirements: I needed to create a simple text-based BlackJack game The game needs to have one player versus an automated dealer The player can stand or hit The player must be able to pick their betting ...
stackexchange/codereview
I have a set of code that calculates how well a templates fits a users details. It's kind of long, so I've cut out all the code that does it's job well and only included the bottle neck and surrounding code. My target here is speed! A couple of notes on the variables: Calculated at run time (changes each user): TopSec...
stackexchange/codereview
The following method works. I am looking for advice to make it more readable. To see if I could avoid any unneccesary checks / casting and the instance of check. Also not a fan of having to recreate the initial String with every loop but not sure if there is a way around it. Things to note. I am using Java 8 and S...
stackexchange/codereview
#pragma comment(lib, "sfml-network.lib") #include <iostream> #include <SFML/Network.hpp> const unsigned short PORT = 5000; const std::string IPADDRESS("192.168.0.100");//change to suit your needs std::string msgSend; sf::TcpSocket socket; sf::Mutex globalMutex; bool quit = false; void DoStuff(void) { static st...
stackexchange/codereview
I successfully create a for loop to generate a new column in my data. This column access if there is retention of the customer on a Radio station. The data looks like this: ID Date Time Station 1 10-06-2017 8:45 SuperRadio 1 10-06-2017 8:56 SuperRadio 1 10-06-2017 9:10 A...
stackexchange/codereview
I tried starting off with something like below. Note that traversal etc. is not included, this is the portion for storage and modifications. It feels like this could be much more elegant at places but not exactly sure how. I'm mainly trying to improve how the code almost repeats for getters and setters for left and rig...
stackexchange/codereview
Is there a more efficient/performant way to accomplish this with vanilla js (no libs please) as the looping is slow? Also, how can I make it more flexible, so the HTML option values can vary a little, if need be? I need to cover different option values in HTML but they mostly follow the same format. Here are some other...
stackexchange/codereview
I'm writing a program that creates curling sequences -- in short this means that we start with a given sequences, consisting of 2's and 3's (i.e. a mix of 22 of them), and look for repetition at the end of the sequence. The curling number, i.e. highest frequency of a period at the end of the sequence is then appended t...
stackexchange/codereview
I am currently working on a Python project. It is some sort of a hub, where you can do some cool but basic stuff, such as: setting timers, launching websites, doing basic math, ping and view source codes of URLs, and more. I want to make this code just a little more compact. I especially want my math menu more compact...
stackexchange/codereview
I've written this code to simulate the Ising Model. The idea is a system represented as a matrix with each element having value 1 or -1. The input is an initial matrix of 1 and -1; it is then being subjected to this algorithm: Pick a random element of the matrix calculate the energy change of the system if that elemen...
stackexchange/codereview
I have image files consisting of black and white pixels encoded as RGB8. I want to count the number of blobs i.e. contiguous areas of white pixels. I rewrote this algorithm in haskell. The algorithm works as follows: The image is traversed and whenever a white pixel is encountered the counter is incremented and all acc...
stackexchange/codereview
I made this code because, I figured that it might be an interesting concept, and that it would be nice to see it work. It enables the toggling of strict mode in any string of code. It even allows you to set a scope to run it through, although it does use eval. Examples: toggleableStrict("var a = 1; console.log(b) 'tog...
stackexchange/codereview
I would like to know if this is the correct way to use try/catch when dealing with multiple MySQL queries and PDO: try { $create = $con[$_POST['user-selected-connection']]->query("..."); KD::notice('success','table successfully created'); try { $insert = $con[$_POST['user-selected-connection']]->que...
stackexchange/codereview
I have a nasty (IMO) piece of code for a datatable configuration, how do i best remove the duplication here? I've tried the obvious things I know (collapsing into one statement and trying inline conditionals) but it isn't working and I can't help thinking there must be a more elegant Ruby way here. if show_status == "...
stackexchange/codereview
I'm practicing my C coding and I wanted to implement my own version of the getline function in C for learning purposes. I'd like a review on coding style, correctness, improvements I can make for performance, and overall quality of the code. My main concerns are correctness and performance (in that order). #include <st...
stackexchange/codereview
The below code runs a t-statistic within a large dataframe (rnadf) based on masked values from another dataframe (cnvdf_maked). Before, I was putting my results into a dictionary and turning it into a pandas dataframe. These dataframes became too large for my memory, so I had to switch to writing the results to a fil...
stackexchange/codereview
Read the current inventory from a file. Either adjust inventory based on orders or generate a purchase of new inventory. When a product goes below a certain point, it will be asked to calculate it and then restock it to a target point. I am trying to make it more efficient, such as making it shorter. check = 0 GTINC...
stackexchange/codereview
I've been doing a lot of searching on PHP, logins, forms, cookies, sessions, etc. And so, I've tried to gather all the info that I got from all over the place. But, I didn't find a place with all the info, and tried to do the best secure login I could do. This is what I have. If this ends up being good, others can u...
stackexchange/codereview
I have a Ruby function which generates and saves a report. I'm looking for a Clean Code way of writing this: def generate violations = relevant_violations comments = convert_to_cleaned_up_comments(violations) text = convert_to_text(comments) save_to_file(text) end But I hate single-use low-semantic-value var...
stackexchange/codereview
I have an implementation of the flood fill algorithm. Assume that an image is provided as a vector of vectors. It takes in parameters of a square to segment the image into two regions. It also takes in a point where mouse click is detected. Based on the point, a particular segment in the image will be filled by a custo...
stackexchange/codereview
This is my code in C# for performing insertion sort: static int[] performInsertionSort(int[] inputarray) { for (int i = 0; i < inputarray.Length-1; i++) { int j = i+1; while (j>0) { if (inputarray[j-1] > inputarray[j]) { int temp = inputarray[j-1]...
stackexchange/codereview
I made an algorithm to calculate when the user has to purchase material adjusting the date in which the order has to be made, I'm using datagridviews to make it work, but I was wondering if there is a better way using a DataTable. private void Suggestion() { for (int i = 1; i < dataGridView9.RowCount; i++) {...
stackexchange/codereview
I worked through the Flowers challenge on hackerrank.com and would like to get feedback on solution and algorithm implementation. It was suggested by hackerrank to review greedy algorithm to solve this challenge. As far as I understand this is an implementation of greedy algorithm. You and your \$K−1\$ friends want ...
stackexchange/codereview
If I draw something in Illustrator and extract it with AI2Canvas I want it to be customizable so I wrote this simple program. It adds two variables: one to resize and one to shift the path coordinate. #include <fstream> #include <regex> #include <string> int main(int argc, char *argv[]) { std::string path = argv[1];...
stackexchange/codereview
I like to compute dummy variables based on the existing values in a dataframe and a dictionary with certain "cut off" points. I wonder whether I need to get rid of the for loop in the example below. And if so, how? The second answer in this Stackoverflow post compellingly urges to avoid looping through dataframes. In m...
stackexchange/codereview
I really hate copy and pasting my code from one method to another. It signals something in my brain, "This could be done either more efficiently or more readable". This is used in a minesweeper program I am implementing with a JavaFx GUI (that's not very relevant, but it might help to know). Hopefully this is enough co...
stackexchange/codereview
I was reading about similar problems to the one I am having, and my guess is that I am having a 'memory leak'. I'm not sure exactly what that means, or how to correct it. Could you take a look at my code and help me optimize? LastRow in this bit is a little over 70000. start = Timer For Row = 4 To LastRow DoEvents ...
stackexchange/codereview
I am looking for some advice to this code I made, which enables a fellow programmer to create his own AI for Connect Four whilst not really having to code the game itself. Match class public sealed class Match { public const int cWidth = 7; public const int cHeight = 6; private static Random Random = new Ra...
stackexchange/codereview
I have used tkinter in Python 3 to create my own version of Conway's Game of Life. What could I do better in terms of optimisation of speed and memory and PEP8 and cleaning up my code? Also, what can I add to make it more functioning as I only have it generating random maps every time? My Code (commented very heavily ...
stackexchange/codereview
I need to transfer data from one vendor's system to another. The source vendor has a view that generates data that combines invoice and line-item data into records w/ line-item cardinality: "Invoice","Date","Line","Description","Price" "A","2/1/2020","1","something","100" "A","2/1/2020","2","something else","75" "B","1...
stackexchange/codereview
I am currently rewriting a todo app from java to clojure. This is my first "real" clojure project so I'm not sure that what I write is idiomatic clojure code. I have just finished rewriting the domain module and I'd like to know how can I improve on it to have something which is idiomatic. I had some simple classes in ...
stackexchange/codereview
in my application i have a form 'DetailScreenView' which implements 'IDetailScreenView'. It is connected to 'DetailScreenPresenter' by the Passive View MVP pattern. I also have a 'DetailScreenUserControl' which needs to be put onto the 'DetailScreenView'. I have looked at how other people have implemented it, such as ...
stackexchange/codereview
I have the following code I would like reviewed. I was recently tasked with sorting products coming from SOLR. The sorting is not by description or by the product number but rather by the below criteria. Normally I use linq to use grouping and sorting, but in this case I have existing (older code) and my approach was t...
stackexchange/codereview
This code is supposed to find, in a graph, the node with the smallest maximum distance to all the other nodes. The problem from Quora is : How do I find the node that has the least maximum distance to all the other nodes in a tree? "So you're thinking about moving into an unknown city. You have been given a map of...
stackexchange/codereview
The problem is from the cracking coding Interview programming book. The problem is that: Sort Stack: Write a program to sort a stack such that the smallest items are on the top. You can use an additional temporary stack, but you may not copy the elements into any other data structure (such as an array). Below ...
stackexchange/codereview
The following code executes asynchron on the SQL database. Is the closing of the connection implemented in the right way? Are there any missing features regarding connection handling which need to be added? public void deleteData(Node node, User user) { SqlConnection connection = getConnection(); ...
stackexchange/codereview
I am processing around 3 billion records using this piece of code. It's pretty slow; it would be really helpful if you could suggest better ways to do this. ''' Created on 27-Mar-2015 @author: siddarth ''' import rake import multiprocessing as mp import time import os import csv filename = 'Large_Input_File.csv' out...
stackexchange/codereview
I'm working on a program that will (hopefully) eventually allow me to perform frame rate analysis like Digital Foundry does. The code below works (as far as I know), but before I iterate on it, I'd like some feedback as I'm new to both C++ and OpenCV. I say "as far as I know" because I'm not sure how "lossless" my lo...
stackexchange/codereview
I have to register different callback functions to a scheduler. The callback signature defines a void * parameter. Some callbacks don't use a parameter. This works, but is it clean? I expected at least an incompatible pointer type warning for the missing cast on the parameterless call which I actually get when using a ...
stackexchange/codereview
I would like a class to store a default string, and also store translated values for that string. The results will be stored in json. I'm looking for a peer review on how this could be improved. My biggest problem with this is to get the string value from the class you have to use the concrete type, using var will retu...
stackexchange/codereview
I'm packaging data for use in a JavaScript charting library that expects a somewhat odd structure of data in which there is an array of labels and an array of dataItems where each data item has a label and an array of data that corresponds to the array of labels. I'm creating the dataItems from a list of objects in wh...
stackexchange/codereview
I have a MediaWiki 1.33.0 website with only one external addon installed (external extension), which is ContactPage. I have created the following script with that logic: if there is an upgrade to either MediaWiki core OR ContactPage these will be upgraded respectively; else, the script keeps the original state (that i...
stackexchange/codereview
I'm writing a conversion mechanism in C#. I deserialize a big XML document of one type and return a big XML document of another type (via serialization of another object). While I'm doing the conversion, I find myself doing a TON of null checks (checking whether or not a certain property has a value, which then would ...
stackexchange/codereview
Based on Marc Gravell's BlockingQueue I wanted to know if there is a way to wait for an object that meets an expression. I have coded a method 'TryDequeueWhere' I am not sure if there is something that I have not take into account, or if there is gap in my code... public class BlockingQueue<T> { /// ...
stackexchange/codereview
Title says the biggest part. The class is designed to be used to search for very big prime numbers, hence the element type is templated. The performance, neither in space nor time, is considered. Users are free to provide any type that supports required semantics. It also supports traverse performance of std::vector du...
stackexchange/codereview
I was thinking in a way to improve the following query if possible: SELECT CONCAT(DATE_FORMAT(start_date, '%Y'), ',', (MONTH(start_date) -1), ',', DATE_FORMAT(start_date, '%d')) as start_date FROM PROJECTS I need start_date in this format: dd/mm-1/yyyy. Note: I am using an API that use month from 0 to 11, and ...
stackexchange/codereview
I haven't been coding super long in this language so if someone could take a look and help me improve my code and make it more efficient, that would be great! The HTML is one input field that you can type a show and then you get the result on the screen. From the beginning you get the top ten shows with the highest rat...
stackexchange/codereview
This function was hard to write as a Clojure newbie, and I don't like the result. Can you help me find a better (more readable) way to do it? (defn split-seq "Splits a seq into blocks defined by start-fn and stop-fn. Returns a lazy seq of seqs" [start-fn stop-fn lines] (let [step (fn [c state] ...
stackexchange/codereview
To be honest, I am pretty new to coding. I want to analyse the articles my local newspaper publishes on ther website. To do that, I have a list of URLs and from that, I want to download and save all the articles published. This is my code: from bs4 import BeautifulSoup import urllib.request import pickle import time d...
stackexchange/codereview
I’ve never used ResourceBundle before. I have a simple Google Play Scraper (uses Jsoup library) which I want to customize and introduce multilingual support. I have some classes. First you have to get html Document to parse later. GooglePlayConnection class (provides Connection, then I just need to invoke method get())...
stackexchange/codereview