instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
What I need to do is create a new object, modify it using a recursive function, then merge it with another object, and do this all in such a way that the values of the new object take precedence over the values in the object I'm merging it with. Currently, my code works, but I'd like to have more readable code, particu...
stackexchange/codereview
This is my .cs part code where I am calling storeprocedure in LINQ to SQL: var rr_j_cat = db.allcategories().ToList();//its store procedure calling thousands of rows if (rr_j_cat.Count() != 0) { DataTable dt = new DataTable();//making dynamic datatable dt.Columns.Add("sub_id"); //dynamic columns dt.Columns....
stackexchange/codereview
Hackerrank problem to reverse an array of size n. https://www.hackerrank.com/challenges/30-arrays/ Sample Input: 4 1 4 3 2 Sample output: 2 3 4 1 Much of this code was already given, you can skip to the "This is what I did" section. #include <bits/stdc++.h> using namespace std; vector<string> split_string(string); ...
stackexchange/codereview
Well, I'm writing a piece of code that will take a list of file names and should search a local drive for each file, determine if it's there or not, and return an array of all the paths found. Right now I'm using a function that searches for one file and I call this function for each file in the list: Public Function D...
stackexchange/codereview
Description Master Locksmith has just finished the work of his life: a combination lock so big and complex that no one will ever open it without knowing the right combination. He's done testing it, so now all he has to do is put the lock back into a neutral state, as to leave no trace of the correct combinatio...
stackexchange/codereview
Given an integer , compute the minimum number of operations(+1, x2, x3) needed to obtain the number starting from the number 1. I did this using this code: #include<iostream> #include<algorithm> #include<vector> using namespace std; int main() { int n; cin >> n; vector<int> v(n+1, 0); v[1] = 1; f...
stackexchange/codereview
Suppose we have two sorted lists, and we want to find one element from the first, and the other element from the 2nd list, where the sum of the two elements equal to a given target. If there are multiple combinations, need to find all the combinations. Any bugs, performance improvement ideas in terms of algorithm tim...
stackexchange/codereview
I am creating a social network and I want to know if this is a secure way of uploading pics/gifs and videos. if(isset($_POST['post'])) { $uploadOk = 1; $imageName = $_FILES['postToUpload']['name']; $errorMessage = ""; $picdate = date('Y-m-d_H-i-s'); if($imageName != "") { $targetDir = "ass...
stackexchange/codereview
What do you think of my code? I know it is a little rough around the edges but as of two days ago I had no idea how to use jQuery or JavaScript. $(document).ready(function () { var json = { "205100": { "success": true, "data": { "type": "game", "name": "MasterKin...
stackexchange/codereview
I have a node.js/express.js based REST application. In one GET service I am querying data based on different set of request parameters. I am looking for a better way to implement it. function handleGet(connection,req,res) { var sql = 'SELECT id, name, age, rent, marks FROM student WHERE class = 10'; if (req.param('mi...
stackexchange/codereview
On Sheet 1 is a legend that contains unique values in Column A every ten rows. To the right of each value in the next five columns over are a series of color filled cells that extend down ten rows to the start of the next unique value. The color fill of each 5x10 area is what I want transferred to the dataset sheet. Th...
stackexchange/codereview
I'm developing a simple Snake game in Java using Swing. So far I made the snake animation which is troubling me: when the snakes moves it seems like it starts to lag for no reason, but when I move it around with the arrow keys it goes smooth. How could I make it move smooth also when it goes on a straight line? GameFra...
stackexchange/codereview
I'd like feedback on the class below, from the perspective of wanting to write professional code that I would be paid to create. I would appreciate comments on details such as commenting, naming and layout as well as the actual functionality. The code is a class which takes two arguments (directory and extension) and s...
stackexchange/codereview
I have an application with HTML, external JavaScript and a bit of jQuery on the page which is initializing specific stuff to that page. I try to keep most of the JavaScript in other files. However I'm unsure if stuff in the DOM Ready function should be split into a separate file as well which is specific to that page. ...
stackexchange/codereview
With the following code, I want to count the Vote objects from a collection, filtering on one of their fields, Candidate. I have the feeling that I can get this done much more efficiently. // Get all votes from the database Collection<Vote> votes = getVotesFromCategoryAndRegion(c, r); // Filter distinct candidates Col...
stackexchange/codereview
This is code that produces a checkered flag-like GUI. I wanted to demonstrate, also learn in detail, how tkinter's geometry managers can be used modularly, so I decided that I could write code for a checkered flag that has frames inside frames, that which have their geometries managed independent of each other. The cod...
stackexchange/codereview
In .NET, the SecureString type exists to prevent leaking secrets in memory. I want to create a hash from the contents of a SecureString, without putting the contents in memory in a place where I can't delete them. I have come up with the following solution, where I pinvoke the winapi crypto functions to calculate a has...
stackexchange/codereview
I am very new programming and am trying to develop a small tycoon game as a hobby project in Unity. This algorithm executes beautifully but if 100+ agents are getting new paths simultaneously there is a significant drop in frame rate. Where should I start with optimizing? I use 4 classes for my pathfinding. The PathFin...
stackexchange/codereview
This is my attempt at creating a Union Algorithm for an arbitrary set of any number of arbitrary simple polygons. It works for both convex and concave polygons. public static List<List<Vector2>> UnionPolygon(List<List<Vector2>> uvPolygons) { List<List<Vector2>> newPolygons = new List<List<Vector2>>(); #region ...
stackexchange/codereview
I have a text file that contains 100,000 numbers from 1 ~ 100,000 in an unsorted manner (no duplicates). The name of the file is "IntegerArray.txt" My task is to count the number of inversions in the text file. An inversion is a pair of elements a, b where a comes before b, but a > b. Thus "1 2 3 6 4 5" contains two ...
stackexchange/codereview
My objective has been to build a custom dropdown like the one on Amazon's search scope selector. I do this by positioning a styleable element on top of a standard select list. I then use jQuery to keep the styleable element in sync with the select list. My code works fine, but I would love to learn how to do it cleaner...
stackexchange/codereview
I'm new to Ruby, but not to programming. I just need a simple script that, given a text file, will pull out around 10% of the lines at random. Below is what I came up with based upon a Python script I wrote. What do I need to do differently to make it more Ruby-like? prng = Random.new File.open('english-words-parti...
stackexchange/codereview
I have written a simple code for Runge-Kutta fourth order integration to solve a system of ordinary differential equations and parallelized it using OpenMP. I don't know if it is the best we can do for maximum performance of the code with little effort. I need all values of to be returned, so I kept values in all steps...
stackexchange/codereview
I wrote this small script to help porting msysGit sockets to WSL ("Bash for Windows"). I'm not a big Python programmer so any feedback would be well appreciated. By the way, I made it a public Gist so I want to make sure it is good quality before some other people are using it too. #!/usr/bin/python """ msysGit to Uni...
stackexchange/codereview
This Python code generates mazes with color and size customization. I intend to add several new maze generating algorithms(Sidewinder, Kruskal, Prim ...) to the Maze class but for now, there is only one (Binary tree algorithm). I need feedback for the overall code and there are a few specific points that I need suggest...
stackexchange/codereview
I would like to know an alternative, more elegant way to write the following methods. I am especially not enthusiastic of the nested if statement or if for validate null values. Now there are 3 if statement for null validation. Any method: private void LoadAlertas() { // *** OMITTED *** ...
stackexchange/codereview
I am trying to build functionality to check if an image taken by the camera is too dark. So I added the following 2 functions to a utility class: public static boolean checkIfImageIsTooDark(BitmapRegionDecoder bitmapRegionDecoder) { if(bitmapRegionDecoder == null) { Timber.e("Expected bitmapRegionDecoder w...
stackexchange/codereview
I was asked for an example of a class to wrap dynamically added controls as I suggested in this Answer. Although it is out of the context of a Code Review, I thought that it would make an interesting post. I'm looking for feedback on not only "How to improve my code" but also "How to better explain my code". Basic C...
stackexchange/codereview
This checks surrounding pixels to my object's pixel: self.surr = [None, None, None, None, None, None, None, None] for i in range(9): #for x in range(-1, 2): #for y in range(-1, 2): if i != 5: x = i % 3 - 2 y = int((i % 3) / 3) - 1 if x == 0 and y == 0: pass ...
stackexchange/codereview
I am trying to convert a BeautifulSoup4 HTML Table to a list of lists, iterating over each Tag elements and handling them accordingly. I have an implementation of this that works at a surface level using BeautifulSoup4. However, the code is getting repetitive and complicated needlessly, but every time I try to improve ...
stackexchange/codereview
My program is supposed to sort a stack such that the smallest item are on the top. I can use a temporary stack, but you may not copy the elements into any other data structure. The program works overall, but I was wondering if there is anything that I can do to make it more efficient/better. import java.util.Stack; pu...
stackexchange/codereview
Take an integer representing a day of the year and translate it to a string consisting of the month followed by day of the month. For example, Day 32 would be February 1. I've already submitted my first attempt, but after looking at ctime library, I came up with this method. So, the function just takes a single paramet...
stackexchange/codereview
This is my first attempt at writing some reusable OOP code. The problem I'm trying to simplify is the confusing (at least to me) structure of VBA string manipulation. Example Dim SomeString As String SomeString = "1234abc" SomeString = UCase(Left(StrReverse("1234abc"), 3)) I've been using VBA long enough, that I get i...
stackexchange/codereview
I wasn't quite sure where to go with this, and this seemed to be the best place I could think of so I thought why not. I threw together a build system for C++ projects today using CMake and I wanted your opinions on it, on things I could do better, or change to better comply with best practices. Here's my directory str...
stackexchange/codereview
I have something like a shop. It is limited to a checkout page, which will send an email. Nothing big, but a nice thing to learn more OOP. Almost every time I develop new classes I am wondering how to organize the flow of depending methods. Here is an example, a first draft of what I have: <?php // Outside the class: ...
stackexchange/codereview
I'm ultimately trying to compare the MD5 hashes for files in two disparate directory trees to see if files are missing from one directory or the other. More broadly, I'm pushing photos from my DSLR camera to Google Drive, and need to know which files need to be synced up. Pictures from my phone are automatically being ...
stackexchange/codereview
I have a helper extension method that I use for path string validation. It looks as below. It's purpose is to work with network paths as well, so in case a network resource is not available, I do not want my applications to freeze, hence the specified timeout etc. public static bool IsExistingFilePath(this string sourc...
stackexchange/codereview
I had the following three Tcl procedures, which calculate positions along three edges of a rectangle: #---- Numbered pins at the top --------------------------------------- # Given a list of triplets (number, name, index), place the pins for the # signals "name<index>" along the top edge, positioned vertically at 'y' #...
stackexchange/codereview
On my machine it runs in about 60 seconds and about 2-3 minutes live. The criteria needed are: Current month only (from first of month until current day) I need the rank of the currently logged in person based on total sales. I have two tables across two databases where this data is to be gathered: Database 1: ProPit...
stackexchange/codereview
I was wondering if it is better to use: double onJupiter() { return AgeInSeconds / (jupiterOrbitalInEarthYears * ageInEarthSeconds); } double onMars() { return inputAgeInSeconds / (marsOrbitalInEarthYears * ageInEarthSeconds); } Or: double onJupiter() { return onEarth() / JUPITER_ORB...
stackexchange/codereview
Student here. I'm practicing for coding interviews right now. In that context, how would you recommend I improve my code for this practice problem? import java.util.*; class Solution { private static final int maxMagnitude = 3; public String intToRoman(int num) { assert 1 <= num && num <= 3999 : num; ...
stackexchange/codereview
This is an attempt at a concise proof of the Monty Hall problem in probability and statistics in R. For those unfamiliar, the scenario is this: There exists a contestant on a game show. This contestant chooses between three doors (A, B, and C), behind one of which is a new car. The host (Monty Hall) reveals what is be...
stackexchange/codereview
I currently have an implementation that helps us deduplicate data but I know it's slow. Here's an example, note that I'm using OpenStruct here when really these are Mongoid objects pulled from the database. require 'ostruct' vendor_data = [ OpenStruct.new(activity_id: "abc123"), OpenStruct.new(activity_id: "def456...
stackexchange/codereview
I have written a program where the user inputs a regular expression and a replacement string, and the program will search through a set of files and do the replacements. The user is allowed to use backreferences in the replacement string (to refer to capture groups in the regex). The part of the program I would like ...
stackexchange/codereview
I was just playing around with some code and had the idea about writing some kind of ostream manipulator to delay the output of characters in a typewriter like style. The focus was mostly on how to use it and was inspired by std::fixed or std::setprecision. Overall it works pretty well. I just want to make sure that I ...
stackexchange/codereview
I've completed this Tic Tac Toe simulator in java and so far it's working. It's just supposed to generate a pre-played game and announce the winner. I'm required to use a 2D array and this is the way I've found to get it done. But I ask more experienced developers if there is a way to do this that is a little less conv...
stackexchange/codereview
I created a simple matrix implementation and would like some critique of it, for example: Things I could add to make it more useful Ways I could make it more efficient (for example __pow__ or ref()) How I could improve my code format / comments Source: import math class InvalidMatrixDimensions(Exception): """Ma...
stackexchange/codereview
I'm new to Java and coding in general. I'm about a week or two into learning Java, and I decided to make this simple four function calculator. Any feedback/tips? import java.util.Scanner; class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("What ...
stackexchange/codereview
This is the second time I am writing any practical JavaScript so it is pretty likely that I have messed something up. I am beginner, so just need a piece of advice before sharing the code: Do I need to be more focused on writing maintainable and flexible code or do I need to be more focused on writing as concise code a...
stackexchange/codereview
I'm a beginner in Java and I tried to create a program that will perform basic arithmetic operations on binary numbers. BinaryOperations class: package binaryoperations; import java.io.IOException; import static java.lang.System.in; import java.util.Scanner; public class BinaryOperations { public static void main...
stackexchange/codereview
I am implementing a like button for posts (Using a clustom Like model and the pre-defined User model from django.contrib.auth). Would appreciate hearing how I can improve this code. Also, I am struggeling with loading in the last state of every like button with the correct highlighting (liked or not liked) if the user ...
stackexchange/codereview
I saw this question and wondered how it'd be best to accomplish this using Ramda. I'm new to the library so I thought it'd be an interesting learning exercise. I have a working solution but it seems overly complicated and verbose. I'd be grateful for any suggestions on what other ways it would be possible to achieve th...
stackexchange/codereview
My apologies for a "repost", my original post was only partial and confusing. Here is a better snippet. This runs fairly slow (30 seconds or so) cycling through 20 workbooks. Any suggestions for improvement would be appreciated; I have left out my dimming of variables at the beginning, as well as my error handling port...
stackexchange/codereview
I recently had the need to implement Luhn's Algorithm in a Java/Kotlin application. I needed a function that would add the check digit to the string of a number like a credit card or IMEI. It could be easily modified to check if the last digit is valid. At first, I had a code of around 20 lines in Java, but by using ev...
stackexchange/codereview
This question is a follow-up. The original question was itself a follow-up to an older question by @LokiAstari. The idea is to provide a compile-time integer range. This version incorporates almost everything from the answers and comments to the previous iteration of the review (except the handling of corner cases s...
stackexchange/codereview
This is my second serious project using php, I made a groupme bot before but the only php was to write the post data to a file and run a bash script that did all of the work. I want to know if I did anything in this that is considered bad practice (I most likely did) and if anything I did caused potential security iss...
stackexchange/codereview
I wrote this script to help me keep track of who has worked together and for what project or discussion in my classes. I make a Google Sheet with the names of the students going across the first row and down the first column. Each student gets a number corresponding to their location in the spreadsheet. The value is th...
stackexchange/codereview
I have made a connection pool for SQL Connection objects. The purpose of this object is to provide multi threaded support for the accessing of the underlying database. The code works by using a reflection proxy for overriding the close() method of the returned connections, so it can detect when the consumer of the API ...
stackexchange/codereview
I'm looking for help speeding up some code I'm tinkering with. The rest of the code, as well as my 'benchmark', can be found here. #ifndef LALLOC_H #define LALLOC_H #define PAGESIZE (1048576) #include <stdbool.h> #include <stdlib.h> #include <sys/mman.h> #include <errno.h> typedef struct bblk bblock; typedef bbloc...
stackexchange/codereview
These are questions from an interview: Reverse a string Find matching anagrams in a word list using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { public class ReverseString { public ReverseString() { stri...
stackexchange/codereview
I have such objects that I need to merge: defaultConditions = where: enabled: true acc_id: ne: null conditions = where: id: 2 acc_id: ne: 5 This helper recipe, which replaces where from defaultConditions with where from conditions, is not quite right for this purpose. So I wrote...
stackexchange/codereview
Is there a better way to handle this ClassNotFoundException ? private Class<?> getClass(String value) { Class<?> columnClass = null; try { columnClass = Class.forName(StringUtils.trim(value)); } catch (ClassNotFoundException ex) { if (value.contains("double") || value.contains("D...
stackexchange/codereview
I am working with a little project intended to allow applications to benefit from aspect oriented programming. The first aspect is logging, which is already working. However I want this code to be more performatic and cleaner. Whole project The basic goals is to annotate methods - private/public static or instance - wi...
stackexchange/codereview
I want to compute the shortest distance between a position (x,y) and a rectangular box defined by (x_min, y_min) and (x_max, y_max). See the picture below with some examples. I know that in two dimensions there are 9 cases I have to take into account. Since this part of my code is used very often, I would like to know...
stackexchange/codereview
My PowerShell scripting skills are pretty poor, but I've managed to hobble together got this script: function Create-Process() { param([string] $fileName, [string] $arguments) $pinfo = New-Object System.Diagnostics.ProcessStartInfo $pinfo.RedirectStandardError = $true $pinfo.RedirectStandardOutput = $t...
stackexchange/codereview
I recently attempted to prove that given two lines, they intersect at one and only one point in Idris. Here is what I came up with: interface (Eq line, Eq point) => Plane line point where -- Abstract notion for saying three points lie on the same line. colinear : point -> point -> point -> Bool coplanar : point ...
stackexchange/codereview
I build a C# Rest Client library / framework. I noticed that it seemed to be significantly faster than RestSharp for GET at least. So, I decided to put together some benchmarks comparing it to other clients. I'm a bit new to bench-marking, but I don't want to get hung up on best practice. I'd just like to know, Have...
stackexchange/codereview
Some people are telling me that using string.Split is very inefficient since it creates a lot of arrays in the heap. So, what are the alternatives if its real? The challenge? Taking a large string that values are delimited by ',' and rows separated by ',\r\n' and trying to create class instances with no string.split!!...
stackexchange/codereview
Okay, first things first: Yes, I am aware of the logrotate tool, which would usually be used for something like this. However, since the logfile i want to rotate already contains a timestamp in the filename, logrotate will never delete old logs. This script is supposed to: tell the application to create a new logfile ...
stackexchange/codereview
I'm learning bash and my goal here is from any repository on my computer to be able to type github and it will open the remote in a browser for me. This works but I feel like I over complicated the remote=$(..) logic and arguably the get_ext() method. get_ext() allows you to type github issues and it will open the issu...
stackexchange/codereview
Here's is the code I'd like reviewed: module Main where import Control.Monad ( when ) import System.Exit ( exitSuccess ) import Idris.AbsSyntax import Idris.Error import Idris.CmdOptions import Idris.Info import Idris.Info.Show import Idris.Package import Idris.Main import Util.System ( setupBundledCC ) processShow...
stackexchange/codereview
Inspired by this answer from SO, I try to find a version of fork()/exec()/wait() which: starts a child process; catches stdout, stderr and return code separately; properly handles all possible errors from system calls (e.g., out of memory, unable to open files, file not found) and makes sure no resources are leaked no...
stackexchange/codereview
I created a script for interval timer with tkinter gui. Here the part that is displaying time looks to be done not in the best way. Any ideas would be greatly appreciated. This timer is intended for timing HIIT/Tabata workouts. User provides working time, rest time, preparation time in seconds and integer number of...
stackexchange/codereview
I was about to use the awful enum+map trick to switch on std::strings when I thought to see if I could let some variadic templates do the job for me and I started to play... #include <string> #include <iostream> #include <functional> #include <unordered_map> template<typename Key = std::string, typename Fun = std::fun...
stackexchange/codereview
I have a list of objects with a string (name) and a local date (date of deletion). I wish to implement uniqueness on these objects based on: If two objects have the same name, then I wish the one with no date of deletion to have priority. If two objects have the same name, and a date of deletion, then I wish the one ...
stackexchange/codereview
I'm trying to make a simple example showing how to create a RNN with Keras that accepts as input a sequence of arbitrary length. In my example, the LSTM is trying to classify whether a sequence has started with a 1 or a not. from keras.models import Sequential from keras.layers import LSTM, Dense import numpy as np d...
stackexchange/codereview
I ported the Star Trek 1971 game to Clojure to help me learn more about the language and functional programming in general. You can see the entire game on Github. The game plays (you can start it with lein run). Instructions are i game or you can see the first link to get more details on the history or gameplay. While ...
stackexchange/codereview
I have created an observer and an observable object class. The idea being that you can create an observer that does some action whenever object being observed changes value. Design goals: Be able to choose to notify all observers every time a value is assigned to the object being observed (even if that value is the s...
stackexchange/codereview
UEFI bootloader. It reads the file kernel.elf on the disk image, reads through the program headers, copies the LOAD segments into memory, and finally calls kmain() The kmain() is nothing but an infinite loop because I want to get feedback on the bootloader before starting to make the kernel Parts of the Makefile are co...
stackexchange/codereview
Given a binary tree, return the sum of values of its deepest leaves. Constraints: The number of nodes in the tree is between 1 and 10^4. The value of nodes is between 1 and 100. Please review for performance and style using GraphsQuestions; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace TreeQuest...
stackexchange/codereview
I have binary files that need to be efficiently processed. The first 8 bytes correspond to metadata, and all the rest is data. From the first 8 bytes I need the last 4 bytes to determine how to structure the rest of the data. Since I'm new to rust, this seemed like a good exercise. The following code complies and produ...
stackexchange/codereview
Yesterday morning I decided to stop procrastinating and start learning me some Haskell. So far I've made this, which is a simple cli 'dice rolling' utility that can be used like: $ ./dice 3d20 You rolled: 17 The code looks like this: import Data.List.Split import Data.Char import Control.Monad import Control.Monad.Ran...
stackexchange/codereview
I wrote this, and I would like to know if this code is clean. It lets me know if a point is in the middle of an isometric cell. const getMapPointFromCellId = cellId => { var {x, y} = getCoordinatesFromCellId(cellId) x = x * constants.cellWidth if (y % 2) x += constants.offsetWidth y = y * constants.o...
stackexchange/codereview
One way to write a client which uses a specific protocol, eg http like in this case, is to create a base class with the basic socket handling functionality with virtual functions which can be overridden with an inheriting derived class. But it is more flexible I think to be able to get the socket handling class to cal...
stackexchange/codereview
I decided to refactor the code for a responsive image gallery, that I setup not too long ago. Following the suggestions @joseph-the-dreamer made, and some other best practices, I cut down on the number of if statements. Is there anything else I could do to make the activateSlider function more concise? Is there another...
stackexchange/codereview
I have written a function buildGroupRequests() to build an array of multiple groups. It checks the size of the request group. If a request group is greater than MAXSIZE = 50 then it will create another group in an array. The logic seems to be complicated, is there a way to rewrite this to be more readable and maintaina...
stackexchange/codereview
So this is my solution to the following leetcode problem: https://leetcode.com/problems/largest-divisible-subset/description/ How could I optimize this code? I think the run time is \$\mathcal{O}(n^2)\$, is that correct? def largest_divisible_subset(nums) return nums if nums.length < 2 nums.sort! max_result = {} (0).up...
stackexchange/codereview
I refactored 2 seperate functions that I found here into a single function: <? function isValidBarcode($barcode) { $barcode = trim($barcode); //If value is not numeric, it is not valid. if ((!is_numeric($barcode)) && ((strlen($barcode) == 12) || (strlen($barcode) == 13))) return false; ...
stackexchange/codereview
This is a follow-up question for 3D Discrete Cosine Transformation Implementation in C++. In this post, I am trying to follow user17732522's answer to update dct3_detail and dct3 template functions, and propose idct3_detail and idct3 template functions. The formula of 3D Inverse Discrete Cosine Transformation is as fol...
stackexchange/codereview
I have to create open source code that allows a user to login to Facebook through an app and attaches that app's messenger bot to the user's pages. I have never written open source code before so I would like suggestions on how to improve the code. <?php require_once("/home/vjukebox/public_html/vendor/autoload.php"); ...
stackexchange/codereview
From "The C Programming Language" (K&R): Exercise 1-13. Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging. I wrote a program to generate a vertically-oriented histogram. It doesn't accurately...
stackexchange/codereview
Problem Statement: Given an array arr[] of N non-negative integers representing the height of blocks. If width of each block is 1, compute how much water can be trapped between the blocks during the rainy season. Input: N = 6 arr[] = {3,0,0,2,0,4} Output: 10 For complete description, please go to this link. My Co...
stackexchange/codereview
I have an SSIS package for SQL Server 2008. In this package, I need to verify that a file exists that matches a pattern of SomeFileName_*.txt where the wild card replaces a YYYYMMDD date. It doesn't matter what the date of the file is, just that any file matching that pattern exists. If a file does not exist, I need to...
stackexchange/codereview
I have a worker class that catches uncaught exceptions and logs them for tracking purposes. However, I do NOT want to swallow those exceptions, nor do I want to abstract them (i.e. losing the stack trace). I believe the best practice in the industry is to throw a new exception and set the inner exception to the caught ...
stackexchange/codereview
I have this code, which reads in a string password from the user and checks if it has a dollar sign $, a number, and an upper case letter. If it has all three, it prints: Your password is correct #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define MAXSIZE 100 void password_read(cha...
stackexchange/codereview
I am developing a FSM to segment Thai syllables with the following rules: Here are my util functions: package edu.washington.rippeth.ling473 package object proj3 { private[proj3] def optionallyAppend(sb: StringBuilder, char: Option[Char]): StringBuilder = char match { case Some(c) => sb.append(c) s...
stackexchange/codereview
Any advice would be great. I watched a few videos over the last 3 weeks and made a program up; what do you think? The program is a business ideal for a few computers in a shop, some computers with training and the rest of the computers without. (for gaming, etc.) import java.util.Scanner; public class n_com { pu...
stackexchange/codereview
Into my workbook I've the db of inventory, in another sheet I've one pvt and in the filter field I put the filed "Card". Now I want create one sheet for each "Card" usually I use this code for this operation: Sub cmdg2b2(control As IRibbonControl) 'genera una sheets per ogni card Application.ScreenUpdating = False App...
stackexchange/codereview
I began creating and refining my resume in LaTeX a long time ago. I recently modified it such that I would feel comfortable putting it out there for others to use as a template, if they wish. It has the unfortunate quality that when I begin modifying it, I have to tweak the white-space quite a lot if I wish to keep it ...
stackexchange/codereview
Please give thoughts and optimization tips on my thread library. Update 1 : I have renamed the different method types. unit AgThread13; interface uses SysUtils, Classes, Windows, Rtti; type {$SCOPEDENUMS ON$} TAgCallType = ( Direct, Synchronize, Queue ); TAgThread = class; TAgThreadSimpleObjectMethod ...
stackexchange/codereview