instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I am an owner of a small industrial business startup and I am learning to write software in order to efficiently keep track of our inventory and finances, as our needs have outgrown the capabilities of Excel. I was working on our perpetual FIFO inventory allocation method and I've inadvertently created a monster. This...
stackexchange/codereview
Reffering other "Stack Exchange" Sources, I've been told that the only way of swapping BGR to RGB involves buffering. While this isn't true, I could just perofrm a quick C-SA algorithm on fseek or bmp buffer byte offsets. I wrote a fast implementation of fwrite, that swaps the first byte with the 3rd. I do believe that...
stackexchange/codereview
I have a snap SVG animation which animates a bunch of circles, and draws a line between them if they are within a certain proximity of each other. However, I realize that there is a lot of optimizing I can do, but I'm not exactly sure how to do it. I feel like it would be useful to have a good example of proximity det...
stackexchange/codereview
Right now, I've got this really ugly loop in my code that waits for a boolean to be true before the method can return. It's triggered when "Done" is clicked. I'm wondering, what is the proper way for me to delay this method's return until the button is pressed? How should I refactor this code so that it follows common ...
stackexchange/codereview
After reading LYAH and using RWH as a reference, I've been doing the exercises from CIS194, which is often suggested to beginners on irc://freenode.net/#haskell and by this author. I've just completed Homework 12, which goes with Lesson 12 and focuses on Monads, using the template provided here. You can find the comple...
stackexchange/codereview
I am working on a vanilla Python menu system for the Linux console. The idea is to provide as much of the same functionality that a traditional DE provides - basic menus for accomplishing common tasks. Mostly it currently just launches specific packages, for example by default it uses "links2 -g google.com" when the us...
stackexchange/codereview
I have this small Java program for computing particurly large Fibonacci numbers (10000th Fibonacci number is computed in about 220 milliseconds). The key idea here is to use lists of digits, which is exactly what is done in java.math.BigInteger, yet I wanted to implement a simple digit list addition on my own. import j...
stackexchange/codereview
In the current project that I am working on, we are using dapper to query the database and sometime when mapping from dynamic types to concrete types we end up with a messy block of code. I created a folder called mappers and have created an Interface<T>, an abstract class inheriting from that interface and I have also...
stackexchange/codereview
I have a Python logistic project that implements several shipping APIs using class inheritance. Each of those classes must do three things: Fire requests to each endpoint with the proper parameters Serialize and map the original input in order to store it Finally, produce a document according to the specification of e...
stackexchange/codereview
I've created a program that will find if a word is a palindrome or a reverse string (emordnilap). How it works: The palindrome part works by reversing the string, and comparing the two strings using strcmp to see if they match one another. If they do match, it will return true, if they do not match false. How it chec...
stackexchange/codereview
I was trying to see what is the highest number of moving and colliding boxes (sprites) I could get in pygame? So that I could start working on game I want, I searched google and I found different people do it as a challenge, trying to get to the highest number of sprites. But none of them use the colliding, they just...
stackexchange/codereview
I finished a sorting algorithm visualizer (for now only uses bubble sort) and this is the code. I'd like some suggestions to improve the memory usage or time elapsed. Built with Cmake and Ninja on Windows Demonstration main.cpp #include "Engine.h" #undef main int main() { try { // if the amount is hig...
stackexchange/codereview
I have this code here which varies depending on the system architecture (typed arrays depends on endianness). I'm trying to get a 32bit ARGB data array. I was trying to learn DataView, which has a nice way of dealing with "endian-ness". Can you please help to revise this to use DataView, while working basically as clos...
stackexchange/codereview
I am a C++ student (1.5 months into it). Please give feedback to this different way I have thought of for Fibonacci series. If there are any improvements needed, please suggest them also. #include<iostream> using namespace std; void fibseries(long int n) { double x=0;double y=1; for (long int i=1;i<=n;i++) ...
stackexchange/codereview
I am reading data out of some large (~2GB each) binary files; these have a well defined structure: - Header (info about the next chunk of data) - Chunk of data (any type) - Repeat I am using the following function to extract data from the files: template<class T> std::vector<T> getFromBin(std::ifstream& ifs, int num);...
stackexchange/codereview
On my site I have a navbar component that I want to customize for each and every ng-view I end up loading. Currently I'm doing this as follows. I have a NavCtrl for the navbar itself and my ng-view directive sits outside the scope of this controller. And I use a navbar service to change/override functionality in the na...
stackexchange/codereview
This is a very simple task, but I'm curious if there is a better, more 'Pythonic' way to solve this. """The sum of the squares of the first ten natural numbers is, 1^2 + 2^2 + ... + 10^2 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)^2 = 552 = 3025 Hence the difference between the...
stackexchange/codereview
This is in ASP.NET MVC, but that shouldn't make a difference. I have a large number of rows in my database for Songs. var songIndex = Context.Songs.ToList().FindIndex(x => x.Id == 500); var songs = Context.Songs.OrderBy(x => x.Id).Skip(songIndex).Take(10); However, the ToList() and OrderBy seem pretty heavy just to ta...
stackexchange/codereview
I just wrote an echo server that responds to curl requests with the method used and the data sent. Sticking to GET and POST for now, but I would like to know if there's something I can do to improve my RESTful API. I'm supposed to: Only be able to call the /data endpoint Only allow JSON parameters Use best practices ...
stackexchange/codereview
The code works fine, but I'm not sure about the way I've created different functions and called them in others. I usually separate bigquery related functions to a utility module, but since there were only a couple, I included them inside the class; I'm not sure I like them that way. Another thing I don't like is how no...
stackexchange/codereview
What I'm trying to do abstract the caching actual cache provider (memory || distributed || ...). enable a caching diversity. each cached item type has different behavior. simply add more than one cache provider. and decide what provider to use with each cached record type based on configuration and settings there are...
stackexchange/codereview
I am doing a pre-cohort coursework for General Assembly and I am somewhat stuck. I have tried making several changes, but it never seems to work right. I am trying to use Career Karma to get assistance, but if you've ever worked with them, it is all dependent on how many people are online and who actually knows what th...
stackexchange/codereview
I wrote a little command line nerdy game, which helps you learn the basics of binary numbers. I would be happy to hear your comments: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define CHARSIZE 10 void printbitssimple(int); void createbitshape(int, char[]); int guess_num_from_binary(...
stackexchange/codereview
This question continues on my previous implementations of the Hand class of a Trading Card Game, earlier questions can be found here: Earlier model: Trading Card Game's Hand class and tests Older model having similar functionality as this one, likely deprecated for current one: Trading Card Game's Hand and HandView im...
stackexchange/codereview
I simply made this for practice. But I want to know if it can be used in the realworld or not. Please point out any bad programming practices and how I can change them and look out for them next time. Your advice or tip will be the invaluable rain on my deadly isolated programming land. import os import hashlib from b...
stackexchange/codereview
I had an interview recently and discovered that I'd forgotten some of the basics. I've been playing around again and have written a function that will take a binary string (there is no validation yet) and returns the ASCII representation of said string. I'm looking for advice or tips on how it could be improved. I don...
stackexchange/codereview
Although this code can be used for many different purposes, I'm building it for use in web-scraping. I would like to know if this is the best approach. Can you see any bugs or potential lockups? The idea is that I have a list of URLs to scrape. So to start processing it, I create a Process using the multiprocessing mod...
stackexchange/codereview
Consider following example (controller): MyController < ApplicationController def index @objects = Object.fancy_way_of_retrieval @properties = Property.fancy_way_of_retrieval_two @something_else = @objects.do_something end def another_method @something_other = SomethingOther.get_va...
stackexchange/codereview
I am trying to write a small python code,where I am reading a text file-which contains both Multiwords (MWEs) and singular words (NMWEs). I am trying to tag each one, as follows. I have a dictionary of entries, containing the MWE and tagged MWE. I am tagging them as replace, and whichever I could not tag as MWE -the N...
stackexchange/codereview
A list is said to have a “majority element” if more than half of its entries are identical. In this classical problem the goal consists of determining whether a list a of length n has a majority element, and, if so, to find that element. A tuple the final method returns, which contains a) Whether the list contains a ...
stackexchange/codereview
I created a syntax highlighter in JavaScript. The language it highlights is AdBlock Filter Syntax, the language used to write filters for ad blocker extensions in browsers. Shown here is the AdBlockSyntaxLine Class, which is the core class that dices a line of text into categories. These categories are used to do highl...
stackexchange/codereview
I am a complete beginner in JavaScript / Node.js / Express, but have some experience with php. I am trying to pass data from a SQLite database to the console. In my previous attempts, console.log() was executed before the database got queried. Now I got it to work in the correct order with what I think is a callback, ...
stackexchange/codereview
What I'm trying to do: Get user input for Google Play App page. e.g. https://play.google.com/store/apps/details?id=jp.scn.android Scrape 100 reviews from Google Play App and organize them into an array. My JavaScript function: function test() { var urlAdd = document.getElementById('input').value; var urlEn...
stackexchange/codereview
I just wrote my first C program for storing the time of the sunset and sunrise for a location given in latitude and longitude in a SQLite database. I usually write C# only. Since this runs on a RaspberryPi I decided to do it in C and I don't really need all that extra stuff that C++ has and I dislike writing anything i...
stackexchange/codereview
I know there are a few recursive ways to solve this problem but the code below is what came to mind for me. void create_bst(node *root, vector<int> arr) { int len = arr.size(); add_nodes(root,len-1); //Make the tree structure inorder_traversal(root,arr); } void add_nodes(node *n, int len) { queue<node *...
stackexchange/codereview
This is a very simple task, but I'm curious if there is a better, more 'Pythonic' way to solve this. """The sum of the squares of the first ten natural numbers is, 1^2 + 2^2 + ... + 10^2 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)^2 = 552 = 3025 Hence the difference between the...
stackexchange/codereview
This below program will be further enhanced for TicTacToe game with Human and Computer as players. Currently this program is written for choosing best move for a given grid position. package project2.tictactoe; enum TicTacToe{ X, O, NULL; @Override public String toString(){ switch(this){ ...
stackexchange/codereview
My goal is to scrape the no. 1 suggestion of the suggestion list on https://finance.yahoo.com for any entry. If there is no suggestion the code should write f"nan_{what_ever_the_entry_was}". As basis I used the solution from https://stackoverflow.com/questions/50355120/how-to-scrape-the-yahoo-finance-search-auto-sugges...
stackexchange/codereview
Finally after a few months of searching and learning AJAX with pagination PHP and History.pushState() I created AJAX PHP pagination. Test page 1. Ajax(index.php) $(window).on('load', function () { // makes sure that whole site is loaded $('#status').fadeOut(); $('#preloader').delay(350).fadeOut('slow'); }); ...
stackexchange/codereview
Recently, I added this 'batch' based rendering system in my game engine, which takes care of rendering Spatials (those are actually wrappers for a mesh and a transform) by giving it an environment parameter (taking care of uniform values, like light, fog, environmentMaps, ...). I would like to ask your advice on how I...
stackexchange/codereview
After a March update, Adobe Indesign will resurrect removed directories it was responsible for creating in the first place, but not any files except for one file called "AdobeFnt.lst". So where once you had a complex folder structure, but then deleted it, you'll now have the whole structure back, but one folder somewhe...
stackexchange/codereview
I have a function to review which implements Stern's diatomic series fusc for a single word (ulong = unsigned long) in place, as a part of an arbitrary-precision implementation. In fact, there's just one part of it that's bothering me, though I'd be happy to get feedback on any of it, of course. I have a (pseudofunctio...
stackexchange/codereview
I am working on a web app that uses a WebSocket to log in users. I would like to minimize bandwidth usage by using binary messages. I came up with the following, and would like to know whether there is something better I could be doing: -define(LOGIN, 1). websocket_handle({binary, <<?LOGIN:8,LengthUser:8, Rest/bitstri...
stackexchange/codereview
What is the recommended (standard, cleaner, more elegant, etc.) method in Python to get a string with all the alphabet letters? Here's three versions of code to generate a dictionary with keys as letters and 0 as all values. The aim is to parse a text and count how often a letter appears. from string import ascii_lowe...
stackexchange/codereview
I have spent quite a bit of time trying to optimize the performance of my 2D mining game. After a lot of research, experimentation, and testing, I finally found something very interesting that improved my performance pretty dramatically when rendering lots of tiles on the screen. Initially I divided my textures up int...
stackexchange/codereview
My goal is to make a very simple library with the authentications basics: create a user and save its hashed password, change its password, have a method to check if the password is correct for login. The usage I thought (you find everything in my Github repository), is this: var cs = "Data Source=localhost\\SQLExpress;...
stackexchange/codereview
After discovering Float Toy, my goal was to create my own version using Python and Tkinter. The results of the endeavor is shown below. Most of the functionality is complete, but the Equation widget does not automatically update itself yet. Does anyone have any simple suggestions for updating its labels? #! /usr/bin/en...
stackexchange/codereview
I have created a recursive function call in AngularJS and just wonder if is there a better way to solve this problem? The code works perfectly. My code is the following: function getLocation(query, map, object, delay) { var deferred = $q.defer(); var service = new google.maps.places.PlacesService(map); serv...
stackexchange/codereview
My goal is to look for nearest neighbours in a Boolean-assigned mapping (a Python dictionary). For this purpose I'm looping through the candidates, starting from those with the closest distance. The code will exit the loop once it finds a neighbour that meets additional criteria. My question here is for best practices ...
stackexchange/codereview
I am teaching a class on parallel computation and am looking for a simple example that illustrate the speed gains from using "CompletableFuture"s in Java. Currently my example problem is very simple: calculate the sum of an array. Each CompletableFuture calculates the sum of about 1/4 of the array, and when all of them...
stackexchange/codereview
Can anyone help me optimize the current VBA code below? It is taking 20 seconds currently to collect,store, check and validate 1000 data's. This program takes specific values from multiple sheets and does addition as the values goes beyond one column or row so loop for addition. And uses 4 values to check for duplicate...
stackexchange/codereview
I have implemented a Greedy Best First Search algorithm in Rust, since I couldn't find an already implemented one in the existing crates. I have a small pet project I do in Rust, and the Greedy BFS is at the core of it. The algorithm is designed to be as flexible as possible. Theoretically, this algorithm could be used...
stackexchange/codereview
Here's my array-based binary heap java implementation, looking for comments / suggestions on my approach. I used a base heap class to contain most of the logic, since the behavior of min/max heaps is quite similar. I found the array-based implementation quite simple to build compared to a tree-based structure, only mec...
stackexchange/codereview
Objective Determine whether a given word is contained in a 2D Array word search. Question 1. What are the time and space complexities of the current algorithm? Time complexity Linear: \$O(2(r * n))\$ There are iterations through the outer and inner loops for the rows and columns occurring twice, once for the horizont...
stackexchange/codereview
I have written a Python 2.5.4 function which accepts as input a list of numbers alongwith the desired number of classes and yields a frequency distribution (i.e. a histogram) of the same data. While setting class boundaries, I've attempted to increase the accuracy (i.e. number of digits after the decimal point). Here...
stackexchange/codereview
I implemented the following class to dispatch std::function<void(void)> objects to a thread pool. Multiple threads will block on the pop call until a task is available. I am using the C++14 standard. #pragma once #include<memory> #include<queue> #include<mutex> #include<condition_variable> namespace alpha { temp...
stackexchange/codereview
This code copies a specific range and a chart from an Excel sheet to Word. This code works fine but it is very slow. I have used delays(Wait) to work properly while dealing with clipboard copy-paste. If I don't use delays as error occurs. This program copies 140 Excel-ranges and 140 charts, so it takes a lot of time. A...
stackexchange/codereview
I wrote this to teach myself how to make a menu with buttons and I want to know if I've done well and if there's any way to make it shorter and/or more efficient. import pygame, sys from pygame import * run = True global newBG newBG = False #-----------------------------------------------------------------------------...
stackexchange/codereview
I'd like to form an algorithmic connections between a particular string and and a particular color, in such that each unique string is always the same color. My particular use case is for a kiosk where each user should immediately notice if someone else is logged in, so my strings are employee first names. Reinforcin...
stackexchange/codereview
I'm creating my first Bash script newpost.sh, which generates a Markdown file containing the metadata for a new blog post. This blog post will be hosted in a Jekyll engine, like GitHub pages. The idea is to facilitate: The generation of date The conversion from the post title to URL Compatible in both mac OS and Linux...
stackexchange/codereview
I'm new to JavaScript, and decided to learn the language by running through as many of the Project Euler problems as I have time to do. I just finished the first one, and am looking for some feedback, specifically on language specific features I could use to do this faster, and faster performance overall (it seems to r...
stackexchange/codereview
Just started learning how to use the canvas today as I wanted to copy an animated GIF. The GIF I tried to copy is below. The animation does work but I've hacked it left and right. There's obviously alot of refactoring to do but am I going about it the right way? <canvas id="canvas" width="300" height="300"></canvas> ...
stackexchange/codereview
I have two inputs (TextBox) on my front end. The following code parses them from their string representation to aDateTime object. If it fails, it then sets default values. DateTime dateFrom; DateTime dateTo; if (!DateTime.TryParse(txtDateFrom.Text, out dateFrom)) { dateFrom = DateTime.Today.AddDays(-7); } if (!DateTim...
stackexchange/codereview
This was the first kata I found hard so I wanted to ask about it. Any ways I could I have done it better? here's the question -> Most frequently used words in a text def check_alphabet(string): #checks if the given string contains at least one alphabet for i in string: if i.isalpha(): return Tru...
stackexchange/codereview
I have the following code in PHP that appends a file path with a timestamp of when it was last modified: function AssetTimestamp($filename) { if (file_exists($filename)) { return $filename . '?' . @filemtime($filename); } else { return $filename; } } I have written the equivalent in C# publ...
stackexchange/codereview
I'm looking for the best and fastest way to do a determinant, for determinants until 15x15. int Determinant(const vector<vector<int> > &a,int n) { int i,j,j1,j2; int det = 0; vector<vector<int> > m(n, vector<int>(n)); if (n == 1) { /* Shouldn't get used */ det = a[0][0]; } else if (n == 2) { ...
stackexchange/codereview
I'm relatively new to programming but my most familiar languages are Java, C# and Haskell and this is my first javascript program. All the concepts used in here were just the first thing that came to mind or the first thing that I stumbled across on google. I tried my best to follow come scoping rules but I think I fel...
stackexchange/codereview
I am relatively new to Python. I've so far mostly worked with PHP and C#, so most of it is relatively familiar. I'm making a simple console application that will store a few API calls in a local database through a cronjob. It will have a timeout, so if the program is run too often it won't spam the API and use up all ...
stackexchange/codereview
I have to load settings to an app when it's opened (It's an Electron application and I'm loading settings from the local json file) I'm loading settings right after the page is loaded: document.onreadystatechange = function(){ if (document.readyState === 'complete'){ loadSettings(); } } but I think th...
stackexchange/codereview
The below code works fine but I have the feeling that there must be something more idiomatic way to do this within the do-notation without having to resort to the two liftMs? main = do n <- (liftM read (liftM head getArgs)) :: IO Int putStrLN . show $ sum [1..n] If I do: main = do args <- getArgs arg1 <- head...
stackexchange/codereview
This will be tough to explain. I am implementing a tool to support RFC6020. But when it comes to the Choice Statement, things get weird. For the sake of better understanding, I have to remember you a couple of things: I have a XML and a YANG file according to the RFC. A Choice (and it's cases) are not included on the ...
stackexchange/codereview
Task: Create a service which will synchronize files on FTP server with files on local drive. FTP server allows up to 15 concurent connections Synchronize the files as fast as possible Files on FTP server are archived after 7 day, we should archive them too at our side Files once put on the FTP server do not change Fol...
stackexchange/codereview
I am still new to rust, so any comment about what is the rust way of doing things is welcome. this is a hand-rolled implementation of fibers or user-land context-switching. #![feature(allocator_api)] #![feature(lazy_cell)] use std::{ alloc::{Allocator, Global, Layout}, arch::global_asm, sync::{LazyLock, Mutex}, ...
stackexchange/codereview
This is a follow-up to this post. In this project (C# Win forms) I'm supposed to calculate wages of employees. These are the steps: Calculate earnings from Attendance data. Here all regular earnings like BasicSalary, OverTimeAmount etc will be calculated. Then these earning details will be shown in a grid where user c...
stackexchange/codereview
I'm creating a game that implements a finite automaton and I don't know if I'm doing it right. Any advice? Game class import java.awt.Canvas; import java.awt.event.KeyListener; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.KeyEvent; import java.awt.image.BufferStrategy; import java.awt.imag...
stackexchange/codereview
I've implemented the basic logic of a stack data structure. How can I make this code more generic? Is there any better way to display the stack contents? StackMethods.java import java.util.Arrays; public class StackMethods { private int top; int size; int[] stack ; public StackMethods(int arraySize){ ...
stackexchange/codereview
I have written a haskell program for the following 'Code Monk' Challenge at HackerEarth. Here is the challenge description. Basically, we are looking for the number of vowels in a string. The first input n is the number of string to parse, followed by n number of random strings. And here is my implementation: import Da...
stackexchange/codereview
This is a simple calculator app that involves entering two numbers and allowing them to be editable and swappable. Calculations are done on the numbers, so the calculations should only be done when the inputs are blurred. The boxes' values need to be updated when the values are swapped. However, they also need to be ed...
stackexchange/codereview
Introduction I'm working on a Statistics Library that can record observations and produce a Summary of the statistics when there's enough observations. Right now, it's at its early stages and is expected to change a lot as I develop it gradually. Minimal Example Suppose I want to record the run time of a particular pi...
stackexchange/codereview
I know a lot of memory is being used, but how do I make this more efficient in space(and time) . public class AnagramsTogether { public static String getAnagramsTogether(String sentence){ if(sentence == null || sentence.trim().equals("")) return null; String[] words = sentence.split(" "); ...
stackexchange/codereview
I have a series if statements where I am trying to find the highest resolution file in an set of files. Is there a way that I can refactor this code to be shorter and or cleaner? begin icon = icons.find { |name, _| name.downcase.include? 'xxxhdpi' } if icon.nil? icon = icons.find { |name, _| name.downcase.inclu...
stackexchange/codereview
This code is working well. Is there a way to minimize the complexity of the code? final = [] a = [[10, 20, 30], [40, 50, 60], [70, 80, 90]] for i in range(len(a)): temp = [] for k in range(len(a)): m = 0 if i != k: for j in range(0, len(a)): DIFFERENCE = (a[i][j] - a[...
stackexchange/codereview
Unfortunately there is no URL where you can see the code working. I hope you all can figure out what the code does simply by looking at it. GitHub var FilteredNav = { wrapper: $(".dept-filters") , init: function() { FilteredNav.changeUrl(); FilteredNav.createUrl(); } , createUrl:...
stackexchange/codereview
I am experimenting with ECS design and I am looking for a solid way to implement a message bus for use between the different systems. Here is a stripped-down version of my current implementation: #include <iostream> #include <cstdlib> #include <functional> #include <vector> struct BaseEvent { static size_t type_co...
stackexchange/codereview
i'm wondering is there any way to optimize this code? It must be able to work with big files, for example, formatting raw 140kb .txt file (12.5k words) takes 2 seconds (measured with Stopwatch class). Text example http://pastebin.com/2p88v8EN Maybe i used here some bad techniques or there is some part to simplify? May...
stackexchange/codereview
I'm not a security expert, but while checking over our AES implementation for our flagship product, I've noticed some strange things, like the output length having a relation with the input length and no apparent use of an IV. @Service public class EncryptionServiceImpl implements EncryptionService { /** The logge...
stackexchange/codereview
I've been learning C# for 2 month and in the process of writing a quiz via file i/o. I want to know if there is a better way to getting the questions and answers rather than using switch statement so that it does not look too cluttered. I've tried using fields and properties but I don't know how to implement them into ...
stackexchange/codereview
Is this the correct way to block requests in Express? app.js app.use("/", indexRouter); app.use(function(req, res, next) { next(createError(404)); }); app.use(function(err, req, res, next) { res.locals.message = err.message; res.locals.error = req.app.get("env") === "development" ? err : {}; console.log(err);...
stackexchange/codereview
Here my attempt was to write a graph algorithm the way a competitive programmer would write under time pressure. The problem to solve was to find a shortest path in a directed, unweighted graph using breadth-first search algorithm (BFS, for short). Basically, I would like to hear comments on my style. Is it effective, ...
stackexchange/codereview
We are to normalize a database, though it is mostly all theoretical, we aren't actually plugging in the SQL. This is the Data we have normalized to these tables.. and here is our SQL for normalizing it. I'd just like to know if anyone spots any glaring issues. insert into bldg_table (bldg) Select distinct bldg from a...
stackexchange/codereview
I'm assigning values to an object by passing it to another class. Basically, I'm reading values from a file and assigning it by passing it to another class. This is the POJO class for the details in a file. public class FileDetails { String URL; String Port; String UserName; String Pwd; public Str...
stackexchange/codereview
I was just looking for a general feedback about this code, which encrypts a file with the Tiny Encryption Algorithm. I'm currently studying C, and I wanted to know if there was anything I could improve in my coding style or anything. Sorry for my english. #include <stdlib.h> #include <stdio.h> #include <unistd.h> #incl...
stackexchange/codereview
From the previous 2 versions: Sign an EC2/S3 URL Version 2 I fixed the comments from the previous version. Most of the code remains the same (so I have split out the new code for review). The main body of the code is provided as reference. The main addition is allowing six flags to be used. Four of these flags allow th...
stackexchange/codereview
I started writing a cyrptocoin from scratch, and then got sidetracked writing the database portion which I eventually turned it into its own project. Data is written to the database and then retrieved through an index, similar to a memory-mapped vector. The data are stored in "segments" that can have a configurable siz...
stackexchange/codereview
To practice the MVC pattern and Unittesting in Java I decided to make a simple TicTacToe Console Application. The features of this App are: Multiplayer-Mode Singleplayer-Mode (that should always result in a draw) My questions are: Have I applied the concept of the MVC pattern correctly? I implemented Unittests for...
stackexchange/codereview
I'm using the minified version of SJCL to encrypt the backup files requested by the users. It is in a Google Apps Script add-on for Google Sheets. I'm mostly concerned with correct use, exception handling and best practices of adding the encryption part in the script. It is currently working as expected in backup and i...
stackexchange/codereview
I have a JavaScript function (which uses the jQuery library but that should not be relevant here) that takes as input an ID (integer), a color, and a side (all, top, right, bottom, or left). For each side, a computation is run in an if-clause. For instance, of borderSide == "top" and anId >= width, do something. Even ...
stackexchange/codereview
This question was presented to me, adapted from Project Euler #8. The goal is to find the N adjacent digits in the 1000-digit number that have the greatest product. Range of N: 10 <= N <= 50. Not only I have to find the max product of 13 consecutive digits in a sequence, I also had to find the max product of 19, 35,...
stackexchange/codereview
I am learning the behavior of C++'s special member function, using a naive String class as example. (The code is modified from this tutorial) Here is the implementation so-question.cpp: #include <cstring> #include <iostream> #include <vector> using namespace std; class String { private: uint32_t size; char *buffe...
stackexchange/codereview
I've started to go through Node tutorials on nodeschool.io, and the second assignment was to write a program that will count the number of newlines in a file and print it out. My solution looks like this var fs = require('fs'); var file = process.argv[2]; var buff = fs.readFileSync(file); var str = buff.toString(); va...
stackexchange/codereview