instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
The problem is to ask the user to guess a number between 1 to 100 and compare it with a random number of that range. If user guessed number is lesser/greater than the random number print "too low" or "too high" accordingly. Take new input asking the user to guess the correct number again. When the guessed number matche...
stackexchange/codereview
I've rewritten my original parser generator to a header-only library which uses templates and functionals for better type safety and clarity. The generated parser creates an abstract syntax tree which can be evaluated effectively using functionals and a visitor pattern. The parser memorizes intermediate steps resulting...
stackexchange/codereview
from bs4 import BeautifulSoup import csv import re import sys import os import urllib2 import html5lib from numpy import genfromtxt import time tropelist = [] numoftropes = 0 start = time.time() #compare the tropelist to the master tropelist and return a 1 dimensional binary array def binarizer(tropelist): master...
stackexchange/codereview
I'm taking my first steps in the Scala world, though I'm not wholly unfamiliar with functional style. Apparently one way of calculating Pi is to sum the terms of the infinite series: $$4 * (\frac{1}{1} - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \frac{1}{9} \dots)$$ So I wrote this simple implementation in a Scala work...
stackexchange/codereview
I compiled this with wxDevC++, and it needs the GDI+ library and header includes for Windows, to compile. On a larger program I have had memory fluctuating from plus minus 4MBs. Not a lot, but why is it doing that? This is a short replication, which fluctuates by .1MB. I'm wondering if there is a mistake, or is that n...
stackexchange/codereview
Bitmap page allocator that scans the bitmap linearly looking for size amount of pages. Everytime it founds a free page, it check if the next size pages are also free, if yes it marks them as allocated and returns a pointer to the first page uint64_t *bitmap; #define setpage(p, x) bitmap[p / 64] = x << (p % 64) | bitm...
stackexchange/codereview
I need help with this code. How can I make it shorter? How can I create an array with the names, for example, errors, and modify code without so many If statements? I still can't solve it. I'm a beginner in PHP. $error1 = $error2 = $error3 = $error4 = $error5 = $error6 = $error7 = $error8 = ""; if ($_SERVER["REQUEST_...
stackexchange/codereview
I want to merge two sorted lists of Integers but this is not the general mergesort case because the same number may appear in both lists. (However, each number can only appear once in a particular list.) The easiest way I've found to do that is (mergeWithSet method): Add all numbers from list one to a treeSet Add all ...
stackexchange/codereview
I am currently trying out a programming problem, SPOJ Alphacode, that involves dynamic programming. In an encoding system where A=1, B=2, …, Z=26, a message 25114 is ambiguous, and could be decoded in 6 ways (BEAN, BEAAD, YAAD, YAN, YKD, or BEKD). The challenge is to count the number of ways each given input number c...
stackexchange/codereview
I am parsing the responses from our Varnish load balancers in order to monitor the status of various nodes. One of the responses we get is text consisting of multiple blocks of data, one for each server in the load balancer. This is one such block: Backend web05 is Healthy Current states good: 10 threshold: 8 window...
stackexchange/codereview
I have been messing around with practicing some c++ making a little console game, and I would like to receive some advice and tips on how to improve my code. Some of the code is not done, meaning that some of the functions are not done and some are not called but I have tested it and it does all works. Some of my conce...
stackexchange/codereview
I'm looking for input on the code itself and formatting/style. This script parses the output of df -h on a Linux server and emails the user if the usage percentage is above the threshold (90% in this case). #!/usr/bin/perl use warnings; use strict; use Mail::Sendmail; my $svr = `hostname`; my @output = `df -h`; my ...
stackexchange/codereview
I have the following code that allows easy creation, pulling, and deletion of Tickets in a CakePHP application. App::uses('Component', 'Controller'); App::uses('Ticket', 'Model'); App::import(array('Security')); class TicketComponent extends Component { public $name = 'Ticket'; // Create a new ticket by provi...
stackexchange/codereview
Learn You a Haskell shows the words function. words and unwords are for splitting a line of text into words or joining a list of words into a text Example: ghci> words "hey these are the words in this sentence" ["hey","these","are","the","words","in","this","sentence"] ghci> words "hey these are the w...
stackexchange/codereview
I need to use sockets from winsok2.h. So, I written a class NetObject to use it. But, when I do compilation I am getting an error: error LNK2019: unresolved external symbol "public: int __thiscall wsa::NetObject::connect(void)" (?connect@NetObject@wsa@@QAEHXZ) referenced in function _main I do this using Visual C++ co...
stackexchange/codereview
I'm trying to implement a suffix array for use in programming competitions. I'm using the CodeForces example and trying to "make it my own" so I can make sure I understand it and feel better about using it. Here's what I have so far: struct SuffixArray { vector<int> sa, pos, tmp; int n, gap; SuffixArray(st...
stackexchange/codereview
Code works fine. What I'm looking for is C# syntax to make the foreach loop below more elegant, compact and readable. The foreach with the multiple if's takes up too much space and looks too ugly. I'm thinking LINQ syntax maybe? (Assume all the variables are strings. The final version will have better variable naming) ...
stackexchange/codereview
TERMINOLOGY We are given a directed acyclic graph (dag) \$G = (V, A)\$, where \$V\$ is the set of nodes and \$A \subseteq V \times V\$ is the set of directed arcs, and a weight function \$p \colon V \to [0, 1]\$. For any node \$u \in V\$, \$parents(u) =\{v \in V \colon (v, u) \in A\}\$, which is a set of parent (or inc...
stackexchange/codereview
Implementing signal slot mechanism again seems quite dumb because there are so many people already done this before but it is for learning and I intended some specific goals. I had some library in mind which is easy and safe to use and relies on C++14 only. The possibility of member function connection and disconnectio...
stackexchange/codereview
As part of studying algorithms, I needed to make a function to count occurrences of characters in a string. My solution is below. I'd like some feedback about how I did - could the implementation be cleaner? Are there any conceptual gaps my code suggests? <?php function ra_count_chars($str){ $dict = str_split(strto...
stackexchange/codereview
Note: This is the first time I've written anything whatsoever in straight C. In other words: I have no idea what I'm doing. I recently had a task that involved temporarily relaying responses from one server, through a web-facing server, and then on to the client. Along the way, the relay server had to dynamically add a...
stackexchange/codereview
I was looking for a way to better define email recipients along the lines of the To/CC/BCC convention. Although SYSTEM/STANDARD/EMAIL contains CC and BCC fields, they are not currently functional, see: "How to Add Addresses to the BCC Field Using Rebol's Send Function" Therefore in this solution, I've reorganised the S...
stackexchange/codereview
First attempt was done here: My second attempt (now using jslint to make sure the spacing is correct and have incorporate the majority of the feedback from previous attempt). /* * Export single function that creates the passportControl object * The function has two parameters: * app: The nodejs/expre...
stackexchange/codereview
Can anyone help me with checking this code? It is for connecting to a database. The method getFromDatabase is to take values from the database and put it to a dataset, and the other method getFromDatabaseToCombo is to get from the database to a comboBox. I can't shake off this feeling that the last two methods can be c...
stackexchange/codereview
When it come to security I try to be to better as possible but I don't have the knowledge. According to what I read on-line my following code should be good but I could use some of your comment/critic/fixes Here is a simple class just to example how I would do a login. Does it look secure enough? class UserClass { pri...
stackexchange/codereview
I was trying to implement a dp + graph problem. After completing the solution I tried to compare it with solution in tutorial to figure out which one was better and to find a way to improve mine if I could. But I was not able to figure out which one is better, so please help. And if there is a way to improve my algorit...
stackexchange/codereview
I want to convert these loops into simple loop. I want the code to look neat and short. I saw answers related to LINQ but couldn't make out from that. Are there any other possible ways for this snippet? XmlDocument manifestXmlFile = new XmlDocument(); manifestXmlFile.Load(manifestFileName); foreach (XmlNode rules in m...
stackexchange/codereview
I've started learning C++ and I wanted to ask you to take a look at my linked list implementation and give comments what's wrong with. It compiles and runs fine, but I am curious about const correctness, proper use of pointers/references, etc., so feel free to go super tough on me! I've read about these concepts online...
stackexchange/codereview
So I have a working game of Tic-Tac-Toe with an AI that plays random moves. Is anyway to maybe shorten the endturn() function so it's not so long? Also is this set up well enough to add a mode where the computer plays optimal or sub-optimal moves and a mode impossible to beat? using System.Collections; using System.Col...
stackexchange/codereview
This post builds on my post about quickly evaluating analytic Jacobian in Matlab. The key difference is that I am now working with the Hessian and I have to evaluate close to 700 matlabFunctions (instead of one matlabFunction like I did for the Jacobian) each time the hessian is evaluated. So there is an opportunity to...
stackexchange/codereview
Input categories - an array of categories [ { id: 1, title: 'Smartphones' }, { id: 2, title: 'Laptops' } ] products - an array of products, linked to categories [ { id: 1, title: 'iPhone X', category_id: 1, price_min: 1200, price_max: 1700 }, { id: 2, title: 'MacBook Pro Retina 13', category_id: 2, pri...
stackexchange/codereview
I was messing around with GPU compute shaders the other day and created a Mandelbrot shader. Unfortunately, Metal doesn't support double-precision in compute shaders, so beyond a certain zoom level, I need to switch back to the CPU. In doing so, I decided to try writing SIMD code for the calculations to make it faster....
stackexchange/codereview
This code belongs to a shopping cart which I want to print multiple times with the help of a loop. There are 9 SQL queries and I want all these queries to run at a time with the below table every time the SQL query changes, but the below table remains the same. //SQL query define in array $query = array(...
stackexchange/codereview
I have this code I use to connect to the database and get a thing from it secure, How can I make more secure?? class db { // The database connection protected static $connection; /** * Connect to the database * * @return bool false on failure / mysqli MySQLi object instance on success ...
stackexchange/codereview
I am working on a PHP MVC project for my portfolio. Its an web app where you can store contacts (email and phone number). I am having trouble with filtering contacts based on filter form that has 3 options https://ibb.co/8dJbSWd I wrote code that works fine but I am sure there is better way of doing this. Here is the c...
stackexchange/codereview
I want to create a hierarchy of Typescript interfaces because I think classes would be an overkill in my case. The main obstacle is checking if an object has a specific type. I solved it this way: enum AnimalId { Mammal = 1, Fish = 3, } interface BaseAnimal { id: number categoryId: AnimalId name: string } i...
stackexchange/codereview
Now that async generators are available in the platforms I care about, I figured I'd try porting Python's ingenious with construct to JS as a utility. My first stab looks like this: type Index = string | symbol | number; function isIndex(obj: any): obj is Index { return ( typeof obj === 'string' || ...
stackexchange/codereview
I have written a rolling z-score function myself. Is my implementation of rolling z-score function correct? #x is an xts object and y duration eg rollz(x,25) rollz<-function(x,y){ avg=rollapply(x, y, mean) std=rollapply(x, y, sd) z=(x-avg)/std return(z) } EDIT Here is the description of z-score. A rolling (mov...
stackexchange/codereview
I've written a piece of code which combines given letters in groups of n letters, and writes all the combinations in a text file. This is my first attempt and I wonder if there is an optimal way to do this. letter_input = raw_input(' Type in letters: ') number_input = int(raw_input(' Letters per word: ')) split_lette...
stackexchange/codereview
I'm working in a very large project and in this post I'll share only the function that I feel it could be written in better way. I have a function called M44toM33 with quite many declarations, variables and repeated operations.. What do you think about this function? could be better? I'm quite open and flexible for a...
stackexchange/codereview
using XNA and C# I built a game as a tutorial, but I have since added functionality to allow the player to move around on a world map which requires the camera to "move" but I no longer like the look of the if statements. is there some way that I can clean this up? private static Rectangle scrollArea = new Rectangle...
stackexchange/codereview
I have been trying to implement parallel merge sort in Scala. My current implementation is about as fast as .sorted, but I have no idea what would be the right aproach to parallelize it. Input file with 1.2M integers: 1.333580 seconds (my implementation) 1.439293 seconds (.sorted) How should I parallelize this? objec...
stackexchange/codereview
I have a bit of EF Lambda code which returns a list of data from the db table, then orders by a field called IsDefault At first, the code was var listOfData = Db .TableName .Where(u => u.UserId == userId) .OrderBy(u => u.IsDefault) .ToList(); Which when writing down, sounds correct. However is wrong as...
stackexchange/codereview
Problem 11: In the 20×20 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 11 42 69 24 68 56 01 3...
stackexchange/codereview
I have about 977 obs in top500Stocks which contains name of 977 stocks. head(top500Stocks,10) ï..Symbol 1 RELIANCE 2 TCS 3 HDFCBANK 4 INFY 5 HINDUNILVR 6 HDFC 7 ICICIBANK 8 KOTAKBANK 9 SBIN 10 BAJFINANCE and I have Date, OHLC and Adj.Close, Vol and Ret of each stocks from th...
stackexchange/codereview
I have this PowerShell code that loops through Excel files in a specified directory; references a list of known passwords to find the correct one; and then opens, decrypts, and saves that file to a new directory. This currently processes ~40 workbooks in roughly 5 minutes, which is still longer than I'd like (but bette...
stackexchange/codereview
DESCRIPTION: [Inspired by Chandler's GameOfCups with Joey in "Friends"]. Program gets 5-digit zipcode from user. (Assume user won't make a mistake, and will enter exactly 5 digits). Program awards points based on a series of rules, and reports the total points earned at the end. The...
stackexchange/codereview
Description Print all student names from a CSV file. CSV Format: CSV file does not contain string delimited by double quotes. None of the cells has "," character or "\"" character. There are exactly two columns. No empty cells. Code csvread.pl #!/usr/bin/perl use strict; use warnings; my $filename = "students.csv"...
stackexchange/codereview
import csv import logging import itertools from random import choice from string import ascii_lowercase from collections import namedtuple from tempfile import NamedTemporaryFile DELIMITER = '\t' ENCODING = 'utf-8' def get_random_cursor_name(length=7): return ''.join(choice(ascii_lowercase) for i in range(lengt...
stackexchange/codereview
I decided to go with a very simple CGI user registration program to pair with Apache's mod_auth_form wrapper around a private site. It was only just after I finished writing that I realized I'd written security-sensitive code in a language I'm not my best at. Is this code secure from parameter injection attacks? I.e., ...
stackexchange/codereview
I have a webpage with a table. The table, with 10 columns, can be sorted by each column ascending or descending. At this moment I control order by big switch: Func<IQueryable<DeviceUsage>, IOrderedQueryable<DeviceUsage>> orderBy; IOrderedEnumerable<DeviceUsage> info; switch (sortOrder) { ...
stackexchange/codereview
This is a follow my rock-paper-scissors program, original post here: Simple rock-paper-scissors game Looking for any feedback and recommendations on ways to keep improving. Quick notes on changes: Removed the use of using namespace std; Added inheritance structure. Added the use of enum variables to replace strings to...
stackexchange/codereview
This program simulates flipping a coin repeatedly and continues until however many consecutive heads are tossed. I'm wondering if there are any issues when initializing a variable in a for loop the way I did. Also I assume assigning -1 to i was an appropriate move as well because after a loop cycle it will iterate (i...
stackexchange/codereview
I am writing a C++ client application which will send some data to server and wait for its response. Now the protocol is to wait for a specific timeout and then retry for specific times. If all goes wrong, the client will report a communication failure. I have implemented the whole matter in a non blocking socket opera...
stackexchange/codereview
This is my second algorithm and I will try to make it as simple for you to understand how it works. It is pretty expensive and I'd like to make it more efficient. . It works by splitting a square into 4 sides and then by determining if an edge is within a side (which is a triangle). Then collision can respond by using...
stackexchange/codereview
I am working with an encryption algorithm that looks like this The key is a number stored in 4 bytes. For each byte in the message, XOR it with the corresponding byte in the key When you reach the end of the key, multiply the key by 13, and then continue looping Translated, it looks like this for (int i = 0; i < data...
stackexchange/codereview
So basically, a user is prompted to input a number of stairs and a staircase when a guy on it is generated. I know this is sloppy and my variable names are rough, I'm actively working to change them now. I thought I would go ahead and post the working code though. How can I improve on this? What can I do better to do m...
stackexchange/codereview
Recently I was given homework to make a hangman game, where I wrote the below. How can I refactor this to use classes? import secrets def guess_the_word(): tries_left = 9 output = ["_"] * len(secret_word) print(str(' '.join([letter for letter in output])).strip()) while tries_left >= 0 and not secre...
stackexchange/codereview
I currently try to learn some Haskell to improve my overall programming skills. To practice, I implement the C course exercises that I very familiar with. One is this: Write a function that finds an array (needle) inside of another array (haystack). Return the index where the first match starts. If it cannot be found,...
stackexchange/codereview
The task is to model a Solar system using OOP. The planets are orbiting and its needs to find distances between planets. My approach is something like this. public abstract class SolarSystem { // TODO } public class Planet extends SolarSystem { private final String name; private final double x; privat...
stackexchange/codereview
I wrote the following lines of code to compare some strings with contents of columns (string) in SQLite database: void PaymentTransaction::setAttributesBySqliteStmt(sqlite3_stmt * statement) { ZF_LOGD("setAttributesBySqliteStmt\n"); int columnCnt = sqlite3_column_count(statement); for (int i = 0; i < column...
stackexchange/codereview
I wonder Is it appropriate to hide imported classes (collections and UserDict in this case) from Python IDE (e.g. IPython)? Is there a more efficient algorithm/implementation? Please feel free to comment on how you would improve this class. import collections as _collections import UserDict as _UserDict class _IdDi...
stackexchange/codereview
I am trying to create a directory, but I have to check whether /usr is present initially, later /usr/local is present and so on, is this an elegant way of writing it? #include <stdio.h> #include <string.h> int main () { char str[] ="/usr/local/mnt/"; char path[40] = {0}; char temp[40] = {0}; char *slash = "/";...
stackexchange/codereview
Objective: Create a heap sort that returns a unsorted list to sorted from greatest to least. Does this implementation look correct? Do you have any tips for optimizing this? '''HeapSort. Best: n log(n) Average: n log(n) Worst: n log(n) ''' #Calls heapify and returns sorted list from greatest to least. def heapSort...
stackexchange/codereview
I have some entities in use in my project, and to make things easier, I would like to have the type of the key for that entity defined via a generic. E.g.: public abstract class Entity<T> { public virtual T Id { get; set; } } This way, I can pull the Id field into the base entity and not have to define it every ti...
stackexchange/codereview
EDIT2: There is a summary below of the findings with new improved code and run time results achieved. Multi threaded follow up has been posted here. I find, in my daily programming, that text-file parsing (various CSV, and ad-hoc formats etc) is still very common. When data size gets to >1MB, performance becomes a c...
stackexchange/codereview
I decided to subclass SKSpriteNode for a game test in Swift today and soon realised that it was not as simple as my Objective-C background suggested. After a little hunting around and a bit of testing in Playgrounds I have come up with the following (See below). I have not tested this in a project as I am just starting...
stackexchange/codereview
My CSS feels dirty and I have no idea how to improve it. Suggestions are greatly appreciated! html, body { border:0; margin:0; padding:0; } body { font: normal 12px helvetica,sans-serif; } .header { background-color:#242424; height:40px; } .header h1, h2 { text-transform:uppercase; } .header h1 { color:#F...
stackexchange/codereview
The following function represents the electrostatic potential, in spherical coordinates, due to a ring of charge \$q=1\$ and radius \$R=1\$, placed in the plane \$x\$-\$y\$: $$\phi(r,\theta) = \sum_{n=0}^\infty \frac{r_\min^n}{r_\max^{n+1}} P_n(\cos\theta) P_n(0) $$ where \$P_n\$ are the Legendre Polynomials of degree ...
stackexchange/codereview
I don't see any way to refactor this, but something tells me I'm missing something. if val.instance_of?(Hash) then @fields.has_key?(key) ? @fields[key].merge!(val) : @fields.merge!({key => val}) elsif val.instance_of?(Array) then @fields.has_key?(key) ? @fields[key].push(val) : @fields.merge!({key => Array.new....
stackexchange/codereview
In a header I have something like: #define OPENGL_TARGET_VERSION_MAJOR 4 #define OPENGL_TARGET_VERSION_MINOR 0 #define OPENGL_TARGET_VERSION ( OPENGL_TARGET_VERSION_MAJOR * 10 \ + OPENGL_TARGET_VERSION_MINOR * 1 ) And then a lot of checks like: #if OPENGL_TARGET_VERSION < 44 #ifdef G...
stackexchange/codereview
I'm back after Tic-Tac-Toe in Haskell with a new version. I added Haddock documentation and wrote a generalized version known as the m,n,k-game. By doing so, I had to redefine Game and getSeqs. getSeqs as of now contains two annoyingly-long list comprehensions which I'd like to get rid of. I tried to integrate gameStat...
stackexchange/codereview
Please review my Secret Santa random pair allocator written in JavaScript. Random pairs will be generated every time you run the code. Input data is hardcoded for now (line # 41). I would love to know if you have any suggestions on improving the algorithm or any other feedback that you might have. function getSecretS...
stackexchange/codereview
I'm learning Tornado and Momoko for an upcoming project and I made a simple API with a GET user/{id} endpoint that queries a database in order to search a User from a database I created before for another project. Here's the code: import tornado.ioloop import tornado.web import tornado.gen as gen import momoko from psy...
stackexchange/codereview
I am interested in seeing how people would refactor this code to make it more readable, remove local variables, etc. The code checks a string against a number of arrays. The first (0) field of each array is the root word and the rest of the words are its synonyms. The idea is to replace any word in the user-provided st...
stackexchange/codereview
I have a text file with lines that look like this: Robot(479.30432416307934|98.90610653676828) Robot(186.42081184420528|213.11277688981409) Robot(86.80794277768825|412.1359734884495) or, more general: Robot(DOUBLE|DOUBLE) How should I parse it in Java? I have written the following (tested and working) code: private s...
stackexchange/codereview
I have a code to get riders from certain teams and calculate the number of riders in those teams in that category: valid_clubs = [] with open("validclubs.txt") as f: for line in f: valid_clubs.append(line) disqualification_reasons = ["WKG", "UPG", "ZP", "HR", "HEIGHT", "ZRVG", "new", "AGE", "DQ", "MAP", "...
stackexchange/codereview
It is my first program in Clojure. It read RSS feed's list from text file, get each feed and store result into sqlite database. project.clj: (defproject cowl "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://...
stackexchange/codereview
I have implemented selection sort in java using arraylist. This selection sort is only for integers . Please have a look and give feedback. can we improve it ? package selectionSort; import java.util.ArrayList; import java.util.Scanner; public class SelectionSort { private ArrayList<Integer> num_sort=new ArrayList<>(...
stackexchange/codereview
This program asks the user for a players name, # of goals, saves, games played, etc. This information is ten organized on a .txt file along with the time the information was logged. users can also compare the players based on # of goals, Assists and saves made. If anything can be improved, cleaned or replaced let me kn...
stackexchange/codereview
Here is some code that reads Active Directory to get a person's manager and parses the result for the managers name. It omits the remaining information. I was just wondering if there might be some more efficient way of doing this instead of the code I am currently using. var Manager = (string)UserDirectoryData.Properti...
stackexchange/codereview
I am fairly new to AngularJS and I am trying to improve my knowledge of this JavaScript Framework by building small real-world web-apps. In this case, I have built a currency converter app with harnesses an exchange rate API built by me which runs here. I want to know whether there exists a scope of improvement and opt...
stackexchange/codereview
This is the first little project I've made that didn't feel it was complete gibberish. But I couldn't tell. The biggest problem I had with this was using the BoardValue enum working like I wanted to. I understand that classes should have a level of abstraction to them and I suspect that the way I implemented the at(int...
stackexchange/codereview
Could someone give some feedbacks from perspective of oo design and coding style on the following codes: Question: Given n points on a 2D plane, find the Line with maximum number of points that lie on it. Similar to https://leetcode.com/problems/max-points-on-a-line/description/. I was given Point interface, empty Line...
stackexchange/codereview
Can please someone review and give me suggestions for improving this code? I am very new to JavaScript. I need to create a method in JavaScript which will take parameters as DateRange (possible values as Today/This Week/This Month BooleanFullDate (possible values as true/false) Now, when the parameter value is Toda...
stackexchange/codereview
I've got this own made grid system made in SASS: @import "../mixins/cross-browser-elements/box"; $columns: 12 !default; $gutter-width-px: 20px !default; @function calculate-column-width($index) { @return percentage($index / $columns); } .row { overflow: hidden; max-width: 100%; .column { float: left; ...
stackexchange/codereview
After almost completely redoing the first version I think I finally have it. I still have a few things to add/change, but I think it's pretty good and safe. I've improved security features as well as overall functionality. I haven't run this program through pycharm yet, so there might be a few PEP 8 errors. It took me ...
stackexchange/codereview
I need to check that a user is allowed to save/retrieve contacts to/from the database by calling a web service, and return an HTTP403 with an explanation if it is not the case. So for the sake of factorizing the code, I decided to use a boolean method that "never" returns false and is there only to check this, and thro...
stackexchange/codereview
I have just finished my first true console game using C++. I would love if I could get some feedback on my program, I have a few specific comments in my code that I have questions on and will list a few more that I ran into while building this game. Does main.cpp have enough data abstraction/any comments on my abstrac...
stackexchange/codereview
In a bigger project of mine I'm using angular to create a dropdown menu dynamically and then toggling a dropdown menu for some of the menu items. This is why I got a function that toggles the dropdown menus for only the items that should actually have one. However, I feel like I should try to DRY this out a bit since I...
stackexchange/codereview
Let me start by saying that I am very happy with this code. I want to share it with other people because I think they will find it helpful, but I want to make sure I did everything in good form before I do so. The code allows users to easily manage their image memory. The class handles all of your images, which means...
stackexchange/codereview
I have written my own deque class to get a better grasp of C++ pointers and memory management. The following code is part of a larger 2D isometric game I am developing. It compiles and runs fine using MSVS express 15. I have provided a unit test source + output. I am fairly sure there are no memory leak issues (using ...
stackexchange/codereview
Currently building my personal site using Jekyll, inuitcss and GitHub Pages. I'd like to hear your thoughts on the markup of my blog page and its post pages. What do you think about handling logo's like this? Also I'm not sure about the headings. The page-title probably should be part of the main section. blog markup: ...
stackexchange/codereview
I'm doing my best to explain how this works, but it's pretty confusing and lengthy. Let me know if there's something I can do to clarify. I'm building a class that models a custom Plist and sets its values to properties in the class automatically. Most importantly however is the core concept of populating the properti...
stackexchange/codereview
I'm working with knockout and am trying to stay true the MVVM structure and trying to make the objects have that dependency on each other. Model, ViewModel, Service definitions: var App = window.App || {}; (function(ns, $, ko) { ns.Models = {}; ns.ViewModels = {}; ns.Services = ns.Services || {}; //Se...
stackexchange/codereview
I have this class export class CurrentLanguageService { currentLanguage(loggedUser: User): string { if (sessionStorage.getItem(LanguageStorageKey) !== null) { if (Object.keys(Languages).includes(sessionStorage.getItem(LanguageStorageKey))) { return sessionStorage.getItem(LanguageStorageKey); }...
stackexchange/codereview
This is a follow-up from: Reversing a domain name string in Java There are a number of ways of splitting a String using a delimiter in Java, especially now with Java 8: StringTokenizer (not recommended) String.split (recommended replacement) Scanner with delimiter Scanner with Pattern Pattern.splitAsStream With the m...
stackexchange/codereview
I'm reading/writing half precision floating point numbers in C#. These are basically 16 bit floats, compared to the usual 32/64 bit floats and doubles we are used to working with. I've taken some highly tested Java code from an obvious "expert on the subject" here and modified it to work with C#. Is this correct? // ig...
stackexchange/codereview
I wrote a little Perl script to Caesar shift strings. Usage: $ # usage: caesar <string> [shifts,...] $ caesar abcde # The default shift is 13. nopqr $ caesar abcde 1 bcdef $ caesar abcde 1,13 # Multiple shifts are supported. bcdef nopqr $ caesar abcde 1-3,5-6 # Shift ranges are supported. bcdef cdefg defgh fghij gh...
stackexchange/codereview
Is it good to empty an array on focusout? var arr = []; $("#automobil").focus(function() { $.getJSON("auto.json", function(data) { $.each(data, function(key, value) { if ($.inArray(value.name, arr) === -1) { arr.push(value.name) } }) }); }).autocomplete({ ...
stackexchange/codereview