instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I have just written a simple program to implement the Caesar cipher using lists. The program assumes the input will be all capital letters. I'm quite new to Python and am just curious of some more efficient ways to write this code. Honestly I just want to work on defining functions and all that jazz. print("This encryp...
stackexchange/codereview
I've used multiple tutorials to get the exact look for show/hide using jQuery, but now that I've done it's too repetitive, I've tried to edit it using variables, but it didn't work. Is there a way to avoid repetitiveness here? $(document).ready(function() { $(document).click(function(event) { if ($(event.target)....
stackexchange/codereview
I'm learning algorithm and this is my implementation of quick sort, please guide how can i improve it further and what are other more optimal ways to implement quick sort? def quick_sort(arr): length = len(arr) if length <= 1: return arr else: pivot = arr.pop() items_greater = [] i...
stackexchange/codereview
I got asked this question in an interview and I came up with a solution which I shared in the below but apparently it was not enough to pass. I'm looking forward to hearing how this problem could be solved. The question is : You are given an array of numbers e.g arr= [1, 3, 2, 0, 1, 2, 8, 4, 1] that represents a board ...
stackexchange/codereview
I have a static class: public static class ConfigurationDetails { public static string SharepointServer { get; set; } public static string Username { get; set; } public static string Password { get; set; } public static string SharepointDomain { get; set; } public static string ServiceLibrary { get;...
stackexchange/codereview
I was tasked with using C++ to turn this "Hello Jarryd, do you like socks?" into: "socks? like you do Jarryd, Hello"; Edit: The condition was to reverse this in place. Here's what I came up with, knocked up in Visual Studio using the TestExplorer to run it. Criticism is much appreciated! .h namespace SentenceFlipNamesp...
stackexchange/codereview
I recently wrote code that would query a collection of objects and rank them according to a given criteria and then filter based on an object property. I attach the code below. I would like to know if my approach can be improved upon such as made more efficient and extensible. Is there a better approach or just another...
stackexchange/codereview
I am trying to write a text adventure as my first Python project. For this segment, I wanted a random enemy (part of a class with its own attributes) to appear and then enter a turn based battle with the player until either the enemies health is 0 or the player's health is 0. The player can use one of three moves to at...
stackexchange/codereview
I have this web site I inherited as part of my job and it has some old code. I'd like to optimize it, but I don't really have the time to do it right, so I'm looking for some "low hanging fruit" to optimize. Basically I want minimal change with the greatest performance improvement. One of the things I've come across i...
stackexchange/codereview
I have just started to play around with C++ and I want to make my code efficient and clutter free. Please critique this code constructively and give feedback that will help me in my programming career. #include <iostream> #include <iomanip> #include <limits> using namespace std; /* This structure will hold my initia...
stackexchange/codereview
I have come up with a class design for parsers (for xml,csv etc) and parser factory. I will be using it in my project.I will be configuring these as beans in the spring context file. I would like to get opinion on the class design. public interface Parser<T> { String fileFormatSupported(); List<T> parse(File fi...
stackexchange/codereview
So, I am trying to generate a web-page template with JavaScript according to user specified values. I tested it with just background-color and made it working. I wanted to add a bunch of new elements. Also I need to add style to each elements. I am able to do it with the current code. But the problem I am having is tha...
stackexchange/codereview
I've done tutorials as well as searches. I need assistance in simplifying this code. Please don't do it for me- instead inform me of what, where and why you are trying to simplify or write less code. I'm already working on an if loop to exit on enter. This is just version 3 for me. ## Program gets the date, Employee ID...
stackexchange/codereview
For past few months I was trying to understand genetic algorithms (GA) and most of the materials availble in the web was not always easy for me. Then I came across this article written by Ahmed Gad Genetic Algorithm Implementation in Python which implemented GA with numpy. Using this as a guiding tool I wrote my first ...
stackexchange/codereview
I have solved problem 10608 on UVA Online Judge using Python 3.5.1. My solution works, but it takes too long to run when the online judge evaluates it. Problem There is a town with N citizens. It is known that some pairs of people are friends. According to the famous saying that “The friends of my friends are my friend...
stackexchange/codereview
It randomly gets a word from an array of Strings. It prints out a '_' char for every letter of the word, displays the ones you have already guessed and displays the ones you have missed. Some advice would be welcome, such as what I should change, avoid and so on. Main class: import java.util.Scanner; public class Main ...
stackexchange/codereview
Release 1.1 of Rubberduck only had a handful of implemented code inspections, more as a proof of concept than anything else. For release 1.2, we now have 19 implementations of our IInspection interface - here is what happens when the user clicks the refresh button on the Code Inspections toolwindow: private void Refre...
stackexchange/codereview
I have a table that stores drop down list values. The table looks like this: id | display_text | value | context | special_case ------------------------------------------------------------ 0 | X | x | Global | - 1 | a | a | Screen1 | No 2 | b | b | Screen1 | No 3 | c ...
stackexchange/codereview
I do not receive files on holidays; I only receive files on regular days—i.e., non-holidays. I want to skip 2021-09-06 since that's a holiday (Labor Day) and I know I will not receive any files. Instead, I want to get a new file on 2021-09-07, since I will receive a file on that day. I created an automated skip logic f...
stackexchange/codereview
I'm working on a class project for my intro to Java class. My background is in accounting/finance so I decided to make this simple calculator that helps the user decide what they can afford and how much they can save on interest expense over the loan term. I'm just looking for general feedback on code structure and tip...
stackexchange/codereview
I would love some suggestions on this code of mine, pointers on overall design, code quality, optimization in terms of memory and speed. #include <stdlib.h> #include <stdio.h> #include <semaphore.h> #include <pthread.h> #include <time.h> #define NUM_OF_READERS 10 #define NUM_OF_WRITERS 100 static int glob = 0; stat...
stackexchange/codereview
I built a class to help me handle image data to use in machine learning. I thought that there would be a pre-existing package that did what I wanted but I couldn't find it so I wrote this. I am not intentionally trying to re-invent the wheel so if there's something that already does this please let me know (although I ...
stackexchange/codereview
I have created an accounting database as per my accounting knowledge. I want to check: Is that database correct which I design for the accounting system? I have table called Mst_AccountGroup(Asset,Liabilities,Capital/Equity,Income & Expense data to create a chart of the account). The database structure is given below. ...
stackexchange/codereview
Problem 1 StratifiedJS allows people to cleanly create observable streams using the Stream class from sjs:sequence: var {Stream} = require("sjs:sequence"); var integers = new Stream(function(emit) { for(var i = 0; true; i++) { emit(i); } }); Streams can then be iterated through using the each func...
stackexchange/codereview
Hi I have wrote a code here for predicting temperature across months. This is the dataset that I was using: https://www.kaggle.com/sumanthvrao/daily-climate-time-series-data I have used a SARIMA model and looking at the predicted results, it does seem to be pretty decent. Given that I just started learning about a mont...
stackexchange/codereview
Below is a code which creates a random colour and shows it to the user in a 64 x 64 square. The user must then use the 3 sliders (R, G, B) to match the colour as closely as possible from tkinter import * import random main = Tk() photo = PhotoImage(width = 64, height = 64) photo_2 = PhotoImage(width = 64, height = 64...
stackexchange/codereview
I have a function that reads a string like this (AnimalCount+HumanCount) and the result of this function is an array of strings [ "(" , "AnimalCount" , "+" , "HumanCount" , ")" ] Now, I have done 2 functions in order to do this: The first one to check if a given char is "special" from the input string function Valida...
stackexchange/codereview
I am creating a radio episode that will have multiple conductors (usually 1 to 3): inside a loop I am associating those conductors to director providing also the url linking to their respective conductors page: <h3 class="conductors"> Conducted by start loop... <span itemprop="director" itemscope itemtype...
stackexchange/codereview
This is a practice for operator overloading, I am well aware that some of these don't make sense. I am seeking review only on the code/practices, not the purpose. /* (C) 2017 ZACH HILMAN * PROPRIETARY/CONFIDENTIAL. ALL RIGHTS RESERVED * * * * * */ #ifndef COMPUTERSCIENCE_ENHANCED_STRING_H #define COMPUTERSCIENCE...
stackexchange/codereview
I'm reading the K&R book and I'm interested in a program which finds the longest line on the input. I've written the same code as in the book, but I wanted to do it myself. I tried to write my own code to do same thing. I think it's working, but my question is whether my code is "good" or if it's written in a "bad way"...
stackexchange/codereview
This is a Leetcode problem - Given a list of words (without duplicates), write a program that returns all concatenated words in the given list of words. A concatenated word is defined as a string that is comprised entirely of at least two shorter words in the given array. Note - The number of elements of the give...
stackexchange/codereview
Here is the original problem, and below is my solution. I wonder what can be improved? Or is there a fundamentally better algorithm out there? Thank you! My intuition is telling me that it can be more concise and efficient than this. Input Format The first line contains a single integer, , denoting the number of st...
stackexchange/codereview
Background Kind of a follow up - slightly related to my other SO question. I thought that if somehow I find a way in VBA to pass a single column to .NET and convert it to a native .NET type then I could finally overcome the mystery of explicitly looping on objects via COM (which is super slow as we all know). I'd then ...
stackexchange/codereview
I have two dictionary with different keys but each key in dictionary is matched like job matches JobType, position matches PositionName, etc and I will like to compare if datadict value equals to exp value. I have following code and result is correct. However, what is the better way for me to do it? res = {} exp = dict...
stackexchange/codereview
I just ended the console snake game and want to review it. I hope you'll review my codestyle (e.g. I don't know what to do with #ifdef inserts in init_game() and end_game() functions) and leave some comments about the game logic, maybe about the view (draw function). Edit: thank you pacmaninbw for remark! I added misse...
stackexchange/codereview
I made a program, but I not happy with the quantity of code. The end result is good, but I believe it can be made much easier, only I don't know how. The functionality: If equal items > 1 in list, then assign all equal items a unique set number. Below I made a unit test. I'm not happy with the class CreatSet. Can som...
stackexchange/codereview
To multiply the matrices A and B using the outer product of vectors, we can express each row of matrix A as a row vector and each column of matrix B as a column vector. Then, we can take the outer product of each row vector of A with each column vector of B and sum the results. The outer product of two vectors u and v ...
stackexchange/codereview
I am new to C and wanted to get feedback on a small project I was working on. Coming from python, I quickly learned that a lot of things we take for granted like list class and all of its useful functions are not implemented. I wanted to see if I could make a card library to help me build multiple types of card games...
stackexchange/codereview
I have been working my way through the exercises in the book Cracking the Coding Interview. I wanted to get feedback for the following exercise. Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end to hold the additional characters and that you a...
stackexchange/codereview
I'm trying to identify which cells in Column C in a spreadsheet of data are dates and if they are, then check if that date is older than 2 years old. If the second condition is met then the below code should copy the entire row from sheet "DUP_ALL" to a new sheet (Archive) and then delete the copied row from the "DUP_A...
stackexchange/codereview
I know that OOP is ubiquitous nowadays. Nonetheless I still write procedural PHP. It now seems to me that I had fallen into a spaghetti code trap, because my code starts to seem meaningless even to me (it's author :) Can you please tell me how bad is this? <?php /** * Created by PhpStorm. * User: Taras * Date: 23.01...
stackexchange/codereview
I'm writing a Diffusion-limited aggregation simulation, and need to pick a random point along the edge of an area defined by a dimension pair of [width, height]. The point shouldn't be deep within the area; it should always be on the border of one of the sides. This is the intended behavior: (let [rand-gen (Random.) ...
stackexchange/codereview
Background I have a list of strings containing numbers. Each string is 8 characters long. For example : '-123.456' ' -12.345' ' -1.234' ' 123.456' ' 12.345' ' 1.234' The longest number possible is ' 999.999' ; the smallest number is ' 0.000' and there always are 3 numbers in the decimal. What I want to do is com...
stackexchange/codereview
This is part of a script that I use for porting a TWRP theme from one resolution to another, respectively portrait to portrait and landscape to landscape. In this function entirely, it focuses on the images. What I am not showing is irrelevant since it focuses on porting the XML files. I compiled GraphicsMagick for ARM...
stackexchange/codereview
I was asked this interview question recently. I was able to come up with this which runs in \$O(k \log n)\$. Given k <= n sorted arrays each of size n, there exists a data structure requiring \$O(kn)\$ preprocessing time and memory that answers iterated search queries in \$O(k + \log n)\$ time. I have k sorted Lists,...
stackexchange/codereview
I am trying to implement a sub-string extractor with "start keyword" and "end keyword" and the extracted result is from (but excluded) the given start keyword to (but excluded) end keyword. For example: Input String Start Keyword End Keyword Output "C# was developed around 2000 by Microsoft as part of its .NET ...
stackexchange/codereview
I believe I have made the following data class quite decently, and I'd like a thorough review on it. The code is built on Java 8 and uses the Builder and Serialization Proxy pattern, it is used to store results from a web service call, and the only certainty I have is that the organization id will be an integer, as it'...
stackexchange/codereview
I made some code to check that e-mails given apply to the right format, and I'm sure there must be a better way to do this. import javax.swing.JOptionPane; public class MailTest { public static void main (String [] args){ String email=""; int at1=0,at2=0; int dot1=0; boolean at = fa...
stackexchange/codereview
I'm reviewing some code and I came across this: // Select the last parameter in the list if (parametersListBox.SelectedIndex > -1) { parametersListBox.SetSelected(parametersListBox.SelectedIndex, true); } ParametersListBox being a C# ListBox. Despite the fact that the comment is wrong, does this actually do someth...
stackexchange/codereview
I'm trying to extract all files (XMLs) from an ftp site with python and the ftplib module, but it's incredibly slow so I suspect I'm doing something wrong. The files are in subfolders, and all at the same "depth" eg: 'startingdir/folder1/place1/file.xml', 'startingdir/folder1/place1/file2.xml', 'startingdir/folder1/pla...
stackexchange/codereview
I use the below code to get a list of columns in a table, and assign the default value to the protected var $attributes in a Laravel Model. In this code, I use the DB function because I don't know how to achieve the same result with Eloquent. Model.php protected $attributes = []; public function __construct(array $att...
stackexchange/codereview
Input Format Input starts with an integer n (1 ≤ n ≤ 100) indicating the number of cases. The following n lines each contain a test case of a single even number x (4 ≤ x ≤ 32000). Output Format For each test case x, give the number of unique ways that x can be represented as a sum of two primes. Then list the sums (one...
stackexchange/codereview
Although I've been programming a fair while I'm learning Python and would like to know how I can make my code more "Pythonic". I'm have a CSV file of eBay categories, containing the name and numeric code which I want to import in to my database. Unfortunately the file does not include a 'parent' category ID for each ro...
stackexchange/codereview
I'm trying to create data feed script for real time bitcoin data for OkCoin exchange using their websocket API (documentation) and a database manager for storing. There are two channels I am interested in: trades and market depth. Once the socket is opened I subscribe to both of them so I have two types of messages com...
stackexchange/codereview
I wrote a matrix class in C++ with an addition and multiplication method. It works fine, but I don't think a C++ programmer would enjoy reading this. I would love some help with that. #include <iostream> #include <string> class Matrix { public: int rows; int columns; int* contents; // Constructor ...
stackexchange/codereview
Basically, I made a function which switches between stages (see the Switch class below). The way I call it is seen in the Controller below. I wanted to ask if this code (in the Switch class) is good practice or not. Login class: public class Login extends Application{ @Override public void start(Stage primaryS...
stackexchange/codereview
I have several Google Maps on one page and each has its own set of Lat/Lng co-ordinates. As a result I have added in the JavaScript options for each one individually as follows: function initialize() { var myLatlng1 = new google.maps.LatLng(49.18589, -2.19917); var myLatlng2 = new google.maps.LatLng(101.1986, -50...
stackexchange/codereview
I've updated my text-based terrain generator a lot. Even though I haven't worked on it all that much. I really just want to know, like usual, is there anything I can improve? How can I shorten the code? What can be made more efficient? Yada yada yada... #!/usr/bin/env python from random import choice from os import sy...
stackexchange/codereview
I have two objects, a bet and a match. A match has 2 teams and both teams get a score at the end of the match. A bet has two scores set up before the match begins. Here I need to know if the bet specified the same winner as it's set on the match (once it's done). // isGoodWinner // // @description :: return true if has...
stackexchange/codereview
I find that I often have to maintain a singleton primarily to hold an array that is sometimes persisted between user sessions, that should have only one class of items, and that sometimes needs to be ordered. I got tired of writing the same boilerplate over and over so came up with this. I'd welcome critiques (particul...
stackexchange/codereview
I'm using the following code to return the first index of a unique character in a large String. It works fine until I get to large strings, where it times out. Is there a faster way to accomplish the goal of getting a hold of the unique character's index using NSCountedSet? Update The string contains 25,000 characters....
stackexchange/codereview
I am soliciting some feedback on my doubly-linked list implementation. In particular, I am looking for your take on my unit-tests and their coverage of the code itself. That is, I developed this class using the test-driven development approach and am wondering how it turned out. In addition, I would welcome any suggest...
stackexchange/codereview
My task was to implement Euler's totient function, and I'm looking for any and all criticism. .386 .model flat, stdcall .stack 4096 ExitProcess PROTO, dwExitCode:DWORD .code ;------------------------------------------------------------------------------ ; _phi@4 (int x) ; ; Calculates Euler's totient function using...
stackexchange/codereview
I am finishing up an actor system (like those used in 90s games, like Doom, Unreal, etc.), which currently deals with damage and event handling. actor.cpp /* * Actor System * (with Event System included) * * Author: Gustavo Ramos "Gustavo6046" Rehermann. * (c)2018. The MIT License. * * This system basically allo...
stackexchange/codereview
I'm making this control toggle between hide and show base on the value in this hidden value. I wanted to use a Boolean because I can just do something like == true. Is this the best way to do this? Working sample https://jsfiddle.net/tjmcdevitt/4bdrfgcu/12/ $("#hdMeetingDateId").val(500); //"#hdMeetingDateId"...
stackexchange/codereview
I know that other people already did the same already, but I'm learning C++ (C++11/14) coming from C (I'm reading Programming: Principles and Practice Using C++, by Bjarne Stroustrup), and this is my OOP implementation of a matrix (N by M size). At the moment it doesn't use template for generic types and uses double, a...
stackexchange/codereview
#include <stdio.h> #define MAXLINE 1000 /* Maximum length of a line */ #define TABSTOP 4 /* Length of tabstop */ int getLine(char line[], int limit); int lookAhead(char line[], int start, int end); /* * Exercise 1-21 * Write a program entab that replaces strings of blanks * by the minimum...
stackexchange/codereview
Quite often, I find myself measuring how long some part of my code takes to complete. I normally do that by storing current time using time.time() and then subtracting time after the code is done. This normally gives me a float that I can then format and print for debugging purposes. This is the function that I have fo...
stackexchange/codereview
Is the algorithm correct? It seems to work. print("Multiple sequence longest common subsequence implementation in Python.\nFor example a naive algorithm would perfom c*128^128 elementary operations on a problem set of 128 sequences of length 128 elements.") print(" That is: ", 128**128, "operations.") from collections...
stackexchange/codereview
So I've started writing an OS to know how they work, and I came up with the following makefile to compile it. The reason I used a makefile is because I wanted to see everything it was doing and have full control over it, to be as explicit as possible. Hence, please don't tell me about CMake (I don't care enough to swit...
stackexchange/codereview
In "How Not To Sort By Average Rating", Evan Miller explained in simple terms and demonstrated with compelling examples that the usual naïve methods of calculating the average rating are flawed, and that the maths for this problem has been worked out almost a century ago—(lower bound of) the Wilson score confidence int...
stackexchange/codereview
In an interview I was asked to solve two JavaScript questions. I thought I did pretty well because I: Covered the edge cases Wrote comprehensive tests Documented the code using jsdoc The interviewer responded with this exact feedback: Overly Complex Solution, Strange Coding Conventions, Poorly Structured, Hard to ...
stackexchange/codereview
I'm currently doing an algorithms course and implemented this version of the quicksort algorithm. I would like to know if it is an efficient implementation. I've seen a couple others where there is a partition function that partitions the list is that a superior method to what I did? def quickSort(aList): first = [...
stackexchange/codereview
This program might seem lazy, I also tried iterating through the vector but performance was poor so I used this lazy approach that has more performance #ifndef BINARY_HH #define BINARY_HH /************************************************************************** * Name: Binary.hh * Author: Samuel Oseh * Date: 27/0...
stackexchange/codereview
I recently posted Spaces To Tabs Converter but it had lots of bugs, so I rewrote the code. I wanted to ask, is it good code? I didn't find any bugs. #include <stdio.h> #define TABVALUE 4 #define ARRAYSIZE 3 void emptyArray(int *a); int main(void) { int c, d, s; int savedChars[ARRAYSIZE]; c = s = d = 0; ...
stackexchange/codereview
The authors of this paper compute support_points of a 900×700 image in 118 ms. I have implemented their algorithm below in Halide. In my algorithm, the nested for loops over length and width iterate over xi and yi, which are points in output_x and output_y. Over each iteration of the nested for loops, a vector top_k is...
stackexchange/codereview
I am doing the Advent of Code challenge to learn Rust (obviously there may be spoilers if you still want to do the challenge). The instructions are too long to include verbatim so I will link them and give a summary for the two parts. In part 1, the programme must compare a user-provided list of integers and count ever...
stackexchange/codereview
I have made a flashcard program. It opens a small window and displays a series of questions. Since I am new to programming, how can my code be improved? from tkinter import * # This opening code is to create a window and menu options. I'm going for a # basic framework here in which everything else will fall under. d...
stackexchange/codereview
I have written the following Executor: /** * <p>This executor guarantees that there is never more than one element waiting to be executed. If an element is * submitted for execution and another element is still in queue, the newly submitted element replaces the previously * queued element in the queue</p> * * <p>A...
stackexchange/codereview
I have a LINQ query that I am having trouble optimizing and takes about 5.5 seconds to run. I am using a view called StaffingResourceData and a table called StaffingForecasts. Each StaffingResource has a ResourceId, a Division, and a Type. A StaffingForecast has a ResourceId, Project, Date (represents a Monday of a we...
stackexchange/codereview
as an exercise from multithreading and networking I have decided to create my own implementation of TCP server accepting connections from two clients (which is I think a pretty common case e.g. chess online games). The works as I wanted it to. Clients are connecting to server, messages from one client are passed to the...
stackexchange/codereview
I have a solution to the following question which seems straightforward enough. However, I feel as if I am missing something. The question: Objective: You have given a character ‘A’ which is already printed. You are allowed to perform only 2 operations – Copy All – This operation will copy all the printed characters. P...
stackexchange/codereview
I recently started studying python with a much heavier study regimen, I wanted someone to review my code to see what they thought. I do have a to do list at the start of the code so any tips on how I could complete those would be appreciated. Also, how are my comments? I'm really new to this whole code annotation thin...
stackexchange/codereview
This is a fairly simple Ruby solution to the August 2016 community challenge. Ok, the title is way too dramatic. But tributary is a nice word, and the alliteration was too good to pass up. Besides, konijn started it! I didn't bother to output a 2D "map" of the basins, I just print their sizes as the challenge requires....
stackexchange/codereview
Recently I've been wondering about ways of implementing objects in code that can be represented by other primitives. An example of this is a Vector, which can be represented by a Vector\$N\$D where \$N\$ is the dimension of vector, or it can be represented by an \$N\$-tuple. The reason this is causing me so much trou...
stackexchange/codereview
We have following endpoint on our api that should grab some events from db, aggregate them and output as a json. But I am having hard time reading this function and hope you could help me out with some ideas how to refactor this to something more reasonable. Or maybe its fine and I just need to read harder? [HttpGet] p...
stackexchange/codereview
I have server-client communication architecture where there is one server and 150 clients. The server-client communication happens via Java NIO where all the clients send some or the other data every 10 seconds. Previously we used to queue all the process messages and process all those in a single thread, as the number...
stackexchange/codereview
Im implementing a BST using templates and dynamic memory, here is my attempt: This is the BSTNode.hh #ifndef BSTNODE_HH #define BSTNODE_HH #include <list> #include <algorithm> using namespace std; template <class K, class V> class BSTNode { public: BSTNode(const K &key) { this->key = key; this->va...
stackexchange/codereview
I want to combine elements in different lists. For example, here are 3 lists. list_a : [ 1,2,3 ] list_b : [ 4,5,6 ] list_c : [ 7,8 ] Selecting elements from list_b and list_c is mutually exclusive. When including an element from list_b, I'd like to also include an element from list_bb; when including an element from ...
stackexchange/codereview
I am trying to implement a small programming language, in Nim, as a way of improving my (close to non-existent) programming skills. The programming language is intended to have IF-GOTO, variables, and the ability to read from stdin. First, I wrote the VM, this thing: import strutils #Nim module for string handling proc...
stackexchange/codereview
I created a login service which holds a boolean based on if a user is logged in or not. angular.module('deafApp') .service('LoginService', function(){ var $this = this; $this.loggedIn = false; }); Inside my login controller (LoginCtrl), I attach the LoginService to a local scope object an...
stackexchange/codereview
This is a simple program I've made using Qt Creator and Pyside: I made a list of activities that I would like to enforce Then I made a program that randomly pick them based on chance It has some buttons to set an activity as Completed/Postponed It can be added new activities for extra 'points' Some activities can take...
stackexchange/codereview
What i have so far is a nice and rapid algorithm for finding the pixel dominant from bmp image. I am not sure how to make it to work.. i though it works, but the program freezes. RGB bitfox_get_primecolor_direct (char *FILE_NAME) { RGB primecolor; BYTE rgb[3]; dword *counts = calloc(pow(256, 3), sizeof(*co...
stackexchange/codereview
After lots of attempts thanks to all the Android enthusiasts, I've found a method to handle large images efficiently in Android Applications in order to get rid of OutOfMemoryError. But I really need to know is this the correct formal way of doing this? Do I need to add some more, or should any changes be made? Please ...
stackexchange/codereview
Function to use several blocks of if:elif:else: that all take slightly different conditional statements. I'm trying to format integers into a 2 digit string, adding a leading 0 for single digits. It is working great, but there has to be DRY way of doing the same thing. Also, the timezone formatting is a bit of a mes...
stackexchange/codereview
Please comment on this. class MinHeap<T> where T: IComparable { List<T> elements; public MinHeap() { elements = new List<T>(); } public void Add(T item) { elements.Add(item); Heapify(); } public void Delete(T item...
stackexchange/codereview
i'm rewriting some Matlab code to c++ using armadillo, a libs for linear algebra. really good libs, IMHO. but i had to translate some matlab construct because armadillo isn't matlab. i want to share my little snippet because i think there should be a better way (in terms of speed, mainly) to solve thoose little problem...
stackexchange/codereview
This is my first real attempt at a Scala program. I come from a predominantly Java background, so I'd like to know if the program sticks to Scala conventions well. Is it well readable or should it be formulated differently? To me, there is a lot of lines in the main function which doesn't quite bode right. It is func...
stackexchange/codereview
I am working on a puzzle to find the minimum number of coins needed to buy a product. I am given three coins: 1 3 5 and also a number representing the price of a product: 11 The answer here would be three, since it takes at least three coins to reach this number. 5, 5, 1 I decided it was best to use Ruby's repeate...
stackexchange/codereview
So I have a system that uses multiple threads to process data. These data could be processed individually but it would be better to process them in batches. Lets assume we have a class Data, a class OtherData and a class Processor which implements Function<List<Data>, List<OtherData>>. To process objects of type Data f...
stackexchange/codereview