instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I made a DLL Injector in C++. It provides multiple functionalities. What could be added or improved in the code? It works well as far as I've used it. #include <iostream> #include <Windows.h> #include <TlHelp32.h> void display_usage(const char* argv0_) { std::cout << "Usage: " << argv0_ << " <DLL File> <[-c <Prog...
stackexchange/codereview
The objective is to find all primes between two given numbers. It is specified that the two numbers are \$\le\$ 1 billion and the difference between the two numbers is ~100,000. We are to repeat the whole process for a \$t\$number of times, where \$t\$ is given \$\le\$ 10. Detail of the problem: PRIME1 The following co...
stackexchange/codereview
I am making a download manager and in Java. My code is currently working and downloads at 430-450 kb/s. The same file, when downloaded using downthemall, gives 440-460 speed, and when using an Internet download manager, it gives 500+ kb/s. I am looking for performance pitfalls (inefficient use of CPU, memory and netwo...
stackexchange/codereview
Application Logic The software take odds data from an internet site and store them inside my own database, this application is basically a scraper. There are different types of odds, eg: FullTime Under / Over Double Chance My goal I want avoid code redundancy, for doing so, I created a method called GetOddsRow which ...
stackexchange/codereview
Is there a way to improve this code? (specially how I built the recursion and the breaking out of the loops and conditionals) # Returns sum of present value of a sequence of cash flows # rate = interest rate (month) # initial amount = balance at the beginning # *amounts = sequence of cash flows (1 or more) def prese...
stackexchange/codereview
I've read a little about binary heaps/priority queues and decided to try my hand at making my own implementation of one. I'm not the most experienced programmer and I would be really grateful if you guys could take a look at my heap class and tell me if it's a good implementation. What can I improve here? Any feedback ...
stackexchange/codereview
I have completed my project which simulates the path of a particle trapped in a device known as a magnetic mirror. I would like your thoughts and improvements on my implementation. Here is the code: from numba import jit import numpy as np import matplotlib.pyplot as plt # Plot attribute settings plt.rc("xtick", lab...
stackexchange/codereview
Please check my code below. I don't have any problems but I'm not aware how far the code will work, release and kill excel instances.. try { wBook = xCel.Workbooks.Open(excelfilepath); xCel.Visible = false; this.xCel.DisplayAlerts = false; wSheet = (Excel.Worksheet)wBook.Worksheets.ge...
stackexchange/codereview
I'm using C++11 and I have the following problem (pseudo C++): template<typename T, R1 (*F1)(Args1...)> class one_size_fits_them_all {}; template<typename T, typename U, typename V, R1 (*F1)(Args1...), R2 (*F2)(Args1...)> class one_size_fits_them_all {}; template<typename T, typename U, R1 (*F1)(Args1...), R2 (*F2)(A...
stackexchange/codereview
I'm writing a Ruby script to reverse engineering message log files. They come from an external system with the following characteristics: Each line of the log file has at least one message. Each line of the log file can have multiple messages. Each message consists of a set of numbers separated by spaces (e.g. 30 0 ...
stackexchange/codereview
I end up writing a lot of the same code when I query a database I thought I would try to encapsulate that all in a class that could be used by any provider that implemented IDbConnection. i'm not looking to do much, return a DataTable when I want a result set, things like that. Here is my first attempt. I've tested tha...
stackexchange/codereview
This is a shopping list program made in Python 3 and it will send the list by email. I am not very experienced but I consider this program as a starting point to what I will do next. import smtplib from email.message import EmailMessage from getpass import getpass name = str(input("Name: ")) email = str(input("Email...
stackexchange/codereview
I have two local maven projects A, and B. B is dependent on A. A |- resources/log4j2.xml B |- resources/META-INF/log4j.xml |- Maven Dependencies |- A |- And other dependencies... Both A, and B exports the log4j xmls to jar. However, as I only need the B/resources/META-INF/log4j.xml to my final B.jar, I tried...
stackexchange/codereview
I wrote this code over the last few days and I learned a lot, and it works as I expect. However I suspect it's woefully inefficient: import requests, bs4, os os.chdir('../../Desktop') wallpaperFolder = os.makedirs('Wallpapers', exist_ok=True) pageCount = 1 GalleryUrl = 'https://wall.alphacoders.com/search.php?search=...
stackexchange/codereview
I have this piece of code to replace current text inside an array of html divs with values coming from a JSON file: $.each($('.something'), function(){ if($(this).text()=="1"){ $(this).html(jsondata.CameraTypeLabel1); }else if($(this).text()=="2"){ $(this).html(jsondata.Camer...
stackexchange/codereview
Some fellow code reviewers (hi @Janos!) have been inquiring about a SEDE query to allow to check progress of the Red Shirt "hat" progression. Try it here! Background Red Shirt cast 5 downvotes on posts that are later deleted or closed Limitations There are certain Stack Exchange limitations which make querying th...
stackexchange/codereview
Since I am not a fan of having using large web-frameworks and libraries just to setup a simple blog, I decided to write my own static blog site generator in pure shell script. The script uses pandoc, to convert markdown files to html files. To test the script, check out the μblog repository. It contains documentation +...
stackexchange/codereview
I have developed the following code to hold n latest items it has received, and when asked for provide these n latest items. The interface is: public interface ICircularBuffer<T> { void Put(T item); // put an item T[] Read(); // provides the last "n" requests } The idea is to build a buffer that will ...
stackexchange/codereview
I have this code to open an outlook appointment item: Public Sub OpenOutlookAppt() Set myolApp = CreateObject("Outlook.Application") Set objExpCal = Session.GetDefaultFolder(olFolderCalendar).GetExplorer Set objNavMod = objExpCal.NavigationPane.Modules.GetNavigationModule(olModuleCalendar) Set objNa...
stackexchange/codereview
I'm trying it out just to see if I could solve it. It would be great if I could receive tips on how to improve it. //input var decimal = prompt("Please enter a decimal number"); if (decimal >= 1 && decimal < 1000000000) { //convert to binary var binConvert = parseInt(decimal, 10).toString(2); //reverse bin...
stackexchange/codereview
I'd like to know if I can improve the performance of my recent bot, and maybe some design patterns too. So far, it's warning a user if it's using some bad words (which are parsed from bad_words.txt) and it's entertaining the users by posting jokes from jokes.txt. from selenium import webdriver import time import random...
stackexchange/codereview
Can someone help me make this code more professional? I'm trying my best to find something similar, but I wasn't successful. I want to avoid the repeat of the code for every single value and also I can't find a solution to avoid select. I only get it run when I repeat the code and count rng, rng1, rng2 etc. Sub a() ...
stackexchange/codereview
I've implemented a simple class for managing a Tic-Tac-Toe game's logic and state in Typescript. This code is intended to be used by a larger program; it doesn't implement any aspects of a UI. I've designed the class to present an immutable API, although it's mutable internally; I'm not using ImmutableJS or other, simi...
stackexchange/codereview
I've created a text based game based on D&D as part of exercise No.45 Learning Python the Hard Way v3.0 I've implemented a few features from the game: Character Selection, Fight Scene, Rolling. Full Program World of wizzard and warriors EX45 I've created a sentence handle and would appreciate adivce on how it code be ...
stackexchange/codereview
I have the following sample Triangle class and I want to validate the set accessors' values, obviously I cannot have a zero side or height Triangle. But while I am writing the validation rules for each property I found myself repeating the same code over and over again. Is there a more concise way to write these proper...
stackexchange/codereview
I have a sleep function which displays the time remaining in sec, some feedback would be appreciated use warnings; $x=$ARGV[0]; $|++; $n=0; # arguments could be 1, 1s , 1m or 1h if($x=~/([0-9]+)([a-zA-Z]?)/) { $t = lc($2) ; if($t eq "h"){$n = $1*3600;} elsif( $t eq "m" ){$n = $1*60;} elsif( $t eq "s...
stackexchange/codereview
Project Euler problem 11 says: In the 20×20 grid below, four numbers along a diagonal line have been marked in bold. [red in the original] 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 ...
stackexchange/codereview
Problem description: You are given a segment [568023; 569230]. Find integer within given range that has the most natural dividers. If 2 or more integers are found, return the lowest integer among them. Solution: def allnums(k): cnt = 0 for i in range(2, k // 2): if k % i == 0: cnt += 1 r...
stackexchange/codereview
I am trying to implement the Wikipedia definition of a MultiSet and need feedback on the implementation. class MultiSet include Enumerable attr_reader :members def initialize enum={} @members = {} raise_error unless enum.class.include? Enumerable enum.each do |item| if @members.include?(item) ...
stackexchange/codereview
Continuing with algorithms I've implemented a binary search tree validator. I don't like the two boolean variables within NodeFollowsBSTContract as it feels too complicated. I feel like it should be cleaned up but don't see how, yet. Also, before each recursive step down, to check child nodes, a new list is created. Is...
stackexchange/codereview
As a learning exercise, I'm developing my own PHP framework. I'm looking for a way to "load views" (kinda like CodeIgniter does it), without polluting my general scope. I came up with the following, basic, example: $data['test'] = 'Hello world'; $str = load_view($data, true); echo $str; function load_view($dat...
stackexchange/codereview
I have a HashMap<Token, Integer>, which counts occurrences of Token. Each time Token is found, the value in the map should be incremented. Map<Token, Integer> occurrences = new HashMap<Token, Integer>(); // ... public void tokenFound(Token token) { Integer numberOfOccurs = occurrences.get(token); Integer newN...
stackexchange/codereview
This is my solution to Project Euler Problem 48. Problem: The series, \$1^1 + 2^2 + 3^3 + ... + 10^{10} = 10405071317\$ . Find the last ten digits of the series, \$1^1 + 2^2 + 3^3 + ... + 1000^{1000}\$. I would like feedback/advice to possibly increase efficiency and/or correct incorrect practices. public static vo...
stackexchange/codereview
This code (Windows Forms) shows a series of timers so that the user can manually time a series of tasks. I decided to put this together today because next weekend I want to go through an activity (about 4-5 distinct tasks) and see how long it takes. The main window is where all the action takes place. The task button...
stackexchange/codereview
I tried to make an is_Prime() function in PHP. What do you think about this code? <?php function is_Prime($x) { if($x <= 1) { echo $x. " is not a prime number.</br>"; return false; } $data = array(); for ($i=1;$i<=$x;$i++) { if(is_integer($x/$i)) { array_push($data, ($x/$i)); }...
stackexchange/codereview
I'm trying to solve a LeetCode problem target-sum, in two languages: Python & Dart. The difference of time taken is shocking for me" Python took ~70ms while Dart took ~900ms !! Why does Dart take so long? screenshot What should I do to improve Dart performance? Solution in two different languages are as follows (same...
stackexchange/codereview
I have an interview coming up in the next few weeks, and I'm choosing to be interviewed in Python. I began programming in Python (it was about four years ago), so the syntax is natural to me, but I only learned about some useful tools of Python just this past year, when I took a class that recommended using it. The Pro...
stackexchange/codereview
Here is my code: import sys import math def dist(a,b): return math.hypot((b[0]-a[0]),(b[1]-a[1])) def minimum_distance(x, y): points = list(zip(x,y)) points_y = sorted(points, key= lambda z:z[1]) points.sort(key=lambda g:g[0]) return min_dist(points,points_y) def min_dist(points,points_y): if ...
stackexchange/codereview
I've written the following function on Python (3.3) to take a list of 6 integers and return the maximum score for a game of Farkle. While the results are correct I don't feel it's a very Pythonic implementation. I'd like to hear from the community on how I could make it better and more Pythonic. Any and all tips are mo...
stackexchange/codereview
This is related to here and here. These two methods are used to programatically add a text field to a PDF document. The field can be of any user determined size and have any user determined title, and will be on the pages specified by an enum value. private void AddFieldToPdf(Field field, iTextSharp.text.pdf.PdfSta...
stackexchange/codereview
I have a few lines where I am trying to get a list of the 25 most popular Items sold on an E-Commerce web site. The code works but I would like hints on how to optimize it. var ecommerceItems = await _context.BmaEcItems .Select(e => e.Itemnmbr) .ToListAsync(); IList<PopularItem>...
stackexchange/codereview
I wrote up the following script for the realtime synchronization service, MobWrite, to be used with the browser-based editor, CodeMirror: // Based on MobWrite's code for TextBoxes /*Instructions for use: Set an 'id' property for your codeMirror obj import this code after you import MobWrite. */ //Licence: http://creat...
stackexchange/codereview
The elevator system has the following functions: There is one building, and the number of elevators can be set arbitrarily. Requests can be sent from outside the elevators, in this case the request will have its original floor, and also the direction (going up or down). Requests of this kind are first sent to a "centr...
stackexchange/codereview
My goal is to grab some data inside asp.net core app on server from external source via wcf service. In future i would like wcf responses to be cached on server and provide asp.net app clients "normal" errors if they appear. Some things to notice: I'm using .net core 2.0 and generated wcf service proxy with a help of W...
stackexchange/codereview
Introduction I want to create an Inventory App in C#. I was thinking of someone who sells a few products and only needs to have a few product properties in the program to search or sort by, and then click on ‘sold’ or click on ‘order’. An Excel export is also to be realised. Today, I wrote my search function. The searc...
stackexchange/codereview
This is my UIView class: class OnboardingView: UIView { @IBOutlet weak var scrollView: UIScrollView! @IBOutlet weak var skipButton: UIButton! @IBOutlet weak var nextButton: UIButton! @IBOutlet weak var pageControl: UIPageControl! @IBOutlet weak var skipButtonTopConstraint: NSLayoutConstraint! ...
stackexchange/codereview
This problem can be found at LeetCode. Since I was studying idiomatic or 'pythonic' code in my language today, I decided to take the most 'pythonic' approach and challenged myself to do this in one line only. LeetCode problem description : You are given a large integer represented as an integer array digits, where ea...
stackexchange/codereview
Code first, elaboration later: // Fizzbuzz: 1..100, %3->fizz, %5->buzz, %15->fizzbuzz // noif: do not use if/switch statements or ternary expressions // LIMIT must be a power of 10 // WIDTH must be equal to log10(LIMIT) #include <stdio.h> #include <string.h> #define LIMIT 100 #define WIDTH 2 char * itoa(int n) { ...
stackexchange/codereview
This is basically my school homework and I want to know what to improve, and what not to do. The homework basically is this: You will get a input in seconds, which is supposed to be shown as H:MM:SS where H is hours M is minutes and S is seconds. The formatting is supposed to look like in my example. ( note: In output,...
stackexchange/codereview
I've made a small "rover game" similar to this one, except made in C#, using OOP, and prettier menus. Here's how it works: There is one Rover class which is instantiated into an array containing all rovers. This class contains certain actions that a rover might need like, MoveRover, or RoverDead. There is also a RoverM...
stackexchange/codereview
Please review my code and help me to improve it. #include <iostream> #include <vector> #include <limits> #include <map> class Graph { int vertex_count; enum { INF = std::numeric_limits<int>::max() }; struct Vertex { int id; int distance; Vertex * parent; Vertex(int _i...
stackexchange/codereview
extern crate pancurses; extern crate rand; use rand::Rng; use std::io::Write; #[derive(Copy, Clone, Eq, PartialEq)] struct Position(i32, i32); struct State { player: Position, velocity: Position, size: Position, tail: Vec<Position>, length: usize, apple: Position, } impl State { fn tick(...
stackexchange/codereview
I'm trying to do some datetime processing. The input is a string of the form 20141005 ('%Y%m%d') and I want to return a data structure that stores the day before the input date, the day from the input, and the day after along with the day after that in a %y%m%d format (141005) This is my function right now, and I'm won...
stackexchange/codereview
I have created the following class to read Serializable object from file and write to a file. import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.File; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.RandomAccessFile; im...
stackexchange/codereview
What would be a cleaner way to write the following? // Check if add user was attempted if ($params['submit']) { // Verify all fields are filled in if (Utilities::checkAllFieldsNotEmpty($params)) { // Make sure username is not taken if (Admin::checkUsername($params['username'])) { // ...
stackexchange/codereview
I'm very new to AngularJS. I'm using a directive for translation of category objects like: { "id":17, "order":2, "published":false, "createdAt":"2014-12-29T16:22:43.000Z", "updatedAt":"2014-12-29T16:23:22.000Z", "CategoryTranslations":[ { "id":13, "name":"Fishes", "description":"Fishes desc", ...
stackexchange/codereview
Introduction It is a spin-off to my compiler creation. Problem Traverse the markargs::syntax_tree in order, e.g. first goes left_operand, then operator, then right_operand. It can be used to collect statistics, run searches, transform some nodes, copy into istreams, etc. In general, it is a good skill to have, in my op...
stackexchange/codereview
This is my solution to the PermMissingElem problem, I wonder what can be improved? Expected worst case time complexity is O(N), but the performance test shows that it's O(N) or O(N * log(N)), which I suppose there's some solution out there that can truly achieve pure O(N)? function solution(A) { const size = A.leng...
stackexchange/codereview
<edit: There's a major problem in the code. It is basically the one in the comment regarding backpressure. I'll rework the code within a a few days... It's time for a quick code review, good points, examples, handholding if anyone has time to spare for commenting and, yes, even nitpicking too. I wrote a short piece of ...
stackexchange/codereview
This logger is for a game engine I'm writing it has a core side which is the game itself and a client side which is the engine. The architecture of the code I feel like is messy it has the main log files which is a .h and a cpp and each client and core has its own .h and cpp file. Is there any way I can improve this lo...
stackexchange/codereview
I instantiate GtkInfobars a lot in my GTK+ application in order to communicate with the user. There are various types of infobars, depending on the message. Basically, any infobar could be a combination of the 4 different infobar message types and 5 different icons (which are painted on the left side of the infobar). I...
stackexchange/codereview
I'd like to check the following process relating to the uploading of data by FTP, after the data is read from a database. I have a stored procedure that returns data in the following pipe delimited format in a single column. It typically returns around 300 rows, each row has about 300 bytes. 1234|||||PROPERTY|||MARKE...
stackexchange/codereview
This craps game simulator is based on someone else's posted Python code that I've redone for practice. I'm interested in improving readability and making it more pythonic. I used unittest instead of nose because I'm using an online IDE. from random import randrange import unittest class CrapsGame: def __init__(sel...
stackexchange/codereview
I was writing a basic calculator program to practice my skills at python. I'm a beginner at Python and was wondering if there is a way to simplify this code of mine? It seems a little bit too long and messy in some sort of way. Again, I'm still a beginner so I don't know all the tricks in the book! import math import t...
stackexchange/codereview
This is a simple script that I use for wrapping a selected word in a textarea field. I'm looking to: make sure my logic is valid/see what others have done in a relative context. request improvements to the OO approach I'm going for. Formatter = {}; Formatter.getSelection = function(event) { var text = document.g...
stackexchange/codereview
Problem description: The sum of the squares of the first ten natural numbers is, 1² + 2² + … + 10² = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + … + 10)² = 55² = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is: 3025 – 385...
stackexchange/codereview
I have recently been teaching a JavaScript module on a games programming undergraduate course and I made this game as a learning exercise and as an example for my students to study. I have made games before but never in JavaScript. Could you have a look at my style and let me know if there are any obvious improvements?...
stackexchange/codereview
Practicing objected oriented design. This time, it's designing the TicTacToe game. One difference between the real TicTacToe game is that I've made my TicTacToe game to have variable sized board. Please review in terms of OOD and I've also left some comments in my code where I want feedback in particular. Thank you ver...
stackexchange/codereview
I'm working on an astrology project, and I have a component for each sign: function Sign({ name, image }) { return ( <div class="tile is-parent"> <article class="tile is-child box"> <div class="card-image"> <img src={image} alt="Image"></img> </div> <p class="title">{name}</...
stackexchange/codereview
This is the script I wrote to make an automated POC baby-sitter in 5 lines. I first found this on a GIF or meme site and thought of making a POC script that does the same. #How Linux users babysit while : do eject eject -t done I don't know aything about bash. So, I want improvements. You can find the origin...
stackexchange/codereview
I was given this small task in an interview recently. I'm usually terrible at coding questions in interviews, because with the time constraint and the lack of google I usually overthink and rush stuff and just end up with a mess of a program. The task was to write a program that would compress the length of string, an...
stackexchange/codereview
Push a button and an LED lights up1 and sends a signal to another computer that plays a song. First project on the Raspberry pi, really simple but definitely fun and educational to implement. Also, second time using python and sockets so I'd especially appreciate input on anything I do inefficiently.2 Mostly feedback ...
stackexchange/codereview
Intro I wrote this code to solve sudoku as part of an assignment (closed now) for an AI course. The program works correctly and I am quite happy with the code. Please let me know if I am rightfully pleased or if the implementation could be so much better. This is a pure code review question so don't hold back on anyth...
stackexchange/codereview
I've got my answer working (up until a 7-digit answer is requested, anyway), and would like some help returning the correct answer speeding up the results I was thinking of storing the values of the possible palindromes before beginning my calculations, but I know it wouldn't speed things up anyhow. I've also read a...
stackexchange/codereview
This is the Longest lines challenge from CodeEval: Challenge Write a program which reads a file and outputs a specified number of lines, sorted on length in descending order. Specifications The first argument is a path to a file. The file contains multiple lines. The first line indicates the number of lines to out...
stackexchange/codereview
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. <?php function isPalindrome($input) { return (string) $input === strrev($input); } $max = 999; $min = 100;...
stackexchange/codereview
I'm trying to create a Bindable FlowLayoutPanel that can take a DataSource and map it the specified generic parameter <T> controls. Only minimal requirements are to have a selectable index and to be able to change the background color of the selected and deselected controls. I've tried to leave out the implementation...
stackexchange/codereview
I often find myself having to do np.intersect1d() multiple times because I need to find the intersection of a number of list like or array like things. So I ended up creating a function for it. Though, if possible I'd like to simplify / and or speed up the code for when the input becomes rather large. def overlap(spli...
stackexchange/codereview
I'm representing coordinates in a multi-dimensional array, and I'd like to stick as closely to native arrays as possible. nArray.hpp #include <stdexcept> // Array that allows for negative integers template <typename T, int SIZE> struct nArray { private: T array[SIZE]; public: nArray() { ...
stackexchange/codereview
I am trying to implement a HTTP Server in Java, I want the server to use a persistent connection per thread for request and response. After some research on Google, this is how my program looks like. It runs fine without any exceptions but I am unable to tell if it is doing what I want it to do, that is connection per ...
stackexchange/codereview
I have this number returned from an Ajax request: 015-0011-00001. I want to increment the last part of the number (00001) on document load. What I did was get the last number and increment it then combine the numbers again. Is there a cleaner way of incrementing this number without slicing the number into many parts? D...
stackexchange/codereview
I've created a basic client/server model using user defined signals (SIGUSR1 representing bit 1 and SIGUSR2 for bit 0). At a high level the algorithm looks something like: The server reveals its PID and starts listening. The client takes a string from standard input, encodes it to binary and starts streaming it to the...
stackexchange/codereview
I have two tables (parent-child model): Loans & Transactions. Each Loan row has multiple Transaction rows. I want to select all rows from Loans together with most recent row from Transactions. Here is my select to achieve this. SELECT L.*, T.* FROM Loans L CROSS APPLY ( SELECT TOP 1 * FROM Transactions AS T ...
stackexchange/codereview
This is my attempt to build a simple simulation of a direct mapped cache, I'm new to C and trying to learn some low level concepts. I had some difficulties with the design, because I'm used to program in a object-oriented style. #include <stdio.h> int create_mask(int num_of_bits, int pos) { return (1 << num_of_...
stackexchange/codereview
I've implemented a destructive merge and quick sort in common lisp, but the code feels verbose and highly imperative. I was wondering if anyone could offer guidance on idioms that could make the code more readable, or more lispy. Any other criticism and advice is also welcome. I chose to make these functions destruct...
stackexchange/codereview
My problem is related to data manipulation: on the basis of the existing variables in a given data set, I would like to create new ones. Bonus points for performance as well as code readability. Let's consider a reproducible example for the famous "iris" data set. My goal is to create a new variable, which can be descr...
stackexchange/codereview
This code is extremely slow and ideally I would appreciate someone walking me through getting this going on the GPU, but if nobody has time for that which is understandable, any and all optimisations would be most welcome! Private Sub Picture(source As Image, picturebox As PictureBox) Dim r As Double Dim g As D...
stackexchange/codereview
I am writing a Python script that will be used to generate line protocol for inserting metrics into an InfluxDB. I'm parsing the status page of my cable modem. That part works. I receive the data and can extract the table of information I need. The HTML for the table looks like this (yes, it has the commented out line...
stackexchange/codereview
Is this a good way to prevent two sequential numbers from repeating, or is there a better, more efficient way of doing this? By efficient, I mean a less CPU and memory consuming process. while (random === lastrandom) { random = Math.floor(Math.random() * 3) + 1; } lastrandom = random;
stackexchange/codereview
I have a list of rectangles as tuples (x, y, w, h). I need to find which ones intersect and if they do, average all the intersecting rectangles into a new rectangle. I also track the resultant averaged rectangle "weight" (the number of intersecting rectangles) as an addition member in the new tuple. (x, y, w, h, weigh...
stackexchange/codereview
I would like to know if this function is correct (I know that it works, but I have not got enough knowledge so as to demonstrate that it is correct). Indication: a colleccio is defined as a vector< int > always of size 12, so I can represent the number of banknotes and/or coins of value 50, 20, 10, 5, 2, 1, 0.50, 0.20...
stackexchange/codereview
So I created this custom application and ported it into a few websites. It uses the Twitch API and pulls in active streams and the viewer count. The problem I run into is when the list gets so big it seems to become too much to do though ajax. I think this because sometimes it will show a stream online when it has been...
stackexchange/codereview
I am a first year CS student. We are currently learning Java and my latest assignment was to create this random number game. I am hoping to get some feedback on code style etc so that I know what not to do in the future and so that I can avoid getting into bad habits from the start. I don't know all that much so any ex...
stackexchange/codereview
I have a program that will get all possible permutations of a certain equation: A + 13 * B / C + D + 12 * E - F - 11 + G * H / I - 10 == 66 Where A, B....I is a value 1-9, and where each digit is used only once in the equation (So if A is 1, no other variable can be 1). There are 136 different solutions for this. usi...
stackexchange/codereview
Can you improve my state engine which consists of the state engine based on an interface and an example menustate? It all works fine but seems a bit cumbersome in terms of the way I have to change states and also report on what state the engine is in. Can this be coded more elegantly? public class StateEngine { //P...
stackexchange/codereview
I am trying to write a procedure that finds the power set of a list, that is, the set of 2n subsets (where n is the number of elements in the list). I simply quite find all the subsets. I feel my code is a lot more work than it should be. (define (element-of-set? x set) (cond ((null? set) false) ((not(pair? s...
stackexchange/codereview
I have a products page with a search box. When a search is submitted there's a redirection to a search results page. If another search is submitted then the query string remains intact (results are populated via ajax). So what I've done is running twice to the server, one time using ajax to set the Session value and an...
stackexchange/codereview
I want to use the Stack exchange data explorer in order to display some basic information about the top tags. The query should print the number of questions and answers, the average number of answers per question and the average score of posts(questions and answers under such questions). The query is ordered by the tot...
stackexchange/codereview
I'm beginner at programming (I guess it's quite obvious) and this is my small "app" I tried to make, that takes username and password from the user. Could you give me some advice on how can I improve it? using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace...
stackexchange/codereview
I've just started practicing Functional Programming in Scala in some days. This is the code I used to perform KS-test on a random number generator. class RNG { def next(): Double; } import scala.math.sqrt; object main { val length: Int = 100000; def main(args: Array[String]) { // generate 100000 random num...
stackexchange/codereview