instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
By applying the get_name and get_mac functions to the specified IP address, it is possible to estimate the network availability of a segment: #include <Winsock2.h> #include <iphlpapi.h> #include <cstdio> #pragma comment(lib, "iphlpapi.lib") #pragma comment(lib, "ws2_32.lib") bool get_name(unsigned char* name, char de...
stackexchange/codereview
Here's all the functions in C that does all the arithmetic operators without using arithmetic operators themselves, mostly using bitwise operators. Recursive functions and comparison operators are also allowed. int add ( int augend, int addend ) { return addend ? add ( augend ^ addend, ( augend & addend ) << 1 ) :...
stackexchange/codereview
I am working on a game where the player can walk around a world comprised out of a grid of tiles. The World object contains a HashMap of Region objects which each has a HashMap of Tile objects. For the libGDX side of things, the Game object creates the different Screens of the game, and switching between Screens is ...
stackexchange/codereview
It's a task from a Ruby-course, in which I'm currently enrolled: Ruby Course - Page Precisely it's one of the assignments for the first week. Following idea: Your are given a list in which finished work-tasks are logged. [ {work: "item 1", date: "2017-04-26", time: 20}, {work: "item 2", date: "2017-04-27", time: 27...
stackexchange/codereview
The problem is to find all divisors of a given integer n. (It may be better to implement a true prime generator, rather than a fixed set, as discussed with examples here, but that was not my immediate concern. Also, I am aware that there are much faster algorithms to generate fixed number of prime numbers—I am avoiding...
stackexchange/codereview
Here's a simple authentication server. It's pretty basic but has the core functionality of sign-up and log-in handling. Your best bet is to simply run the docker-compose file Main package com.example.tokenservice; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBo...
stackexchange/codereview
Here is an attempt I made at a simple Substitution based cipher machine, it shifts input characters by an amount then returns an unreadable string which can then be decrypted back to its original self: package Pack; import java.io.UnsupportedEncodingException; import java.util.Arrays; import java.util.HashMap; import ...
stackexchange/codereview
I have a tree view with a list of cars and a webservice to get the details for each car. On page load, there are no cars selected so the details footer is loaded with all cars. $.ajax({ type: 'POST', url: '@Url.Content("/GTracker/Cars/CarTreeDetails")', data: { "id": [] }, // not cars filter ...
stackexchange/codereview
I would like to improve the interfaces of some polymorphic classes going from positional to named parameters and I came up with the fluent interface. The following is the most clean, compact and compilable (-std=c++11 required) example that I have been able to come up with: #include <iostream> #include <cmath> #include...
stackexchange/codereview
For reference: L-system I'm mostly looking for general style stuff here and in particular: if my type parameters are too crazy — I wanted two parameters so that variables and constants could have their own types. if I could be using some library features that I don't know about. if there might be some type based way t...
stackexchange/codereview
I have a loop in my main sub routine which creates multiple graphs. This is run across a number of sheets, creating the same graphs for each sheet, but with different ranges and other variables. I have a separate subroutine for each graph (two are shown below, others are similar and can be posted if necessary), however...
stackexchange/codereview
I have a React component that renders the form of a model (called riskModel). This form is used in two different context; for creation and edition of a specific model. In this form, there are many different complex inputs, such as: Dynamic graph sections that include a .json file of a specific format, a title and a de...
stackexchange/codereview
I tried to implement the Repository pattern for my project: MemberController.php -- this one is a bit too long and has repetitive code <?php class MemberController extends \BaseController { private $repo; public function __construct(MemberRepository $repo) { $this->repo = $repo; } //////...
stackexchange/codereview
Problem Statement Create one form having following fields 1) Email ( with html5 email validation). 2) Password (It should take minimum 6 charactors ). 3) Your project URL ( with html5 url validation). 4) Project completion date ( with html5 date validation). 5) Current month ( with html5 month validation). 6) Current ...
stackexchange/codereview
I wrote a logger module in C, that is essentially a printf wrapper + some additional color coding: I'd like get feedback how I can improve performance and also use better coding style. Right now, I feel like a lot of the code is redundant/can be written in a better way. log.c #include <stdarg.h> #include <stdio.h> #in...
stackexchange/codereview
I wrote the following Concern module. Is it good practice to perform all the calculations in the included scope? How can it be improved? module Pagination module Helper extend ActiveSupport::Concern included do class << self def paged(params, custom_per_page = nil, custom_page = nil) ...
stackexchange/codereview
I have a list of Workshops, each having open days (Monday, Tuesday etc.) and open time and close time (which will be same for each day). Now, Based on the current time, I need to find out next 7 days available slots. A slot is of 2 hour and is available if any of the workshop is open in that 2 hour time. The first slot...
stackexchange/codereview
I've been glancing at Game of Life for quite a while, but been reluctant towards graphical packages like pygame. But today I finally got over myself and did it. Did you know that there the "problem" computationally only depends on one condition? I didn't, and followed the conditions of the game at first. At first I use...
stackexchange/codereview
I'm new to web scraping and tried building a web scraper for Amazon customer reviews. The program works fine as is but I wanted to improve the design and get some feedback. The basic idea was to scrape customer review contents on Amazon product review pages using specific URL structures. 1. URL to search for product na...
stackexchange/codereview
I'm implementing the Binary Search Tree data structure in Swift. It looks like this: class BinarySearchTree<Key: Comparable, Value> { let key: Key var value: Value var left, right: BinarySearchTree<Key, Value>? init(key: Key, value: Value) { self.key = key self.value = value } ...
stackexchange/codereview
I coded this function to check for a violation of a primary key in a DataTable. The main idea is to retrieve a list of every row that the same value of the column in input and set an error to it. Private Sub PrimaryKeyCheck(Of ColumnType)(dt As DataTable, ColumnName As String) Dim violatingGroups = dt.AsEn...
stackexchange/codereview
I have collected a .csv file with some statistics about football games in the following format. Here is a sample .csv file. Date,Home,Away,HomeShots,AwayShots,HomeBT,AwayBT,HomeCrosses,AwayCrosses,HomeCorners,AwayCorners,HomeGoals,AwayGoals,HomeXG,AwayXG My code does the following: Calculate a summary of statistics...
stackexchange/codereview
This is actually my version of a project I'm giving to my class of High School juniors. I'm not the greatest programmer and also a new teacher so I was hoping someone could check out this code and give me any suggestions or advice they see on it. Please just keep in mind that it's written to be at a High School student...
stackexchange/codereview
I am sorting an array (filtered) containing JS-Objects by their attribute sortdist: filtered.sort(function (a, b) { if (!a.sortdist) { return 1;} else if (!b.sortdist) { return -1;} else if (a.sortdist > b.sortdist) { return 1;} else { return -1; } }); However, I am sorting 9000 datasets, which takes a really ...
stackexchange/codereview
I have the following problem and I am new in Java: I have an initial capital of 10 000. I invest this initial capital of 10 000 in the bank for a interest rate per month of 0.04/12. My net income is 3000 per month and my expenses per month is 2000. I invest also my monthysavings = net income - expenses = 3000 - 2000 = ...
stackexchange/codereview
We are using Keycloak v4.4.0 as SSO for multiple microservices and SPAs. The main goal is to prevent user entering his credentials when landing to another SPA UI. I've not worked with such authentication mechanism before, so I'm trying to use all its features. This js module is compiled via webpack. decodeToken funct...
stackexchange/codereview
I have two questions about my code: Are there any performance improvements in this implementation or generally (register int ?) that I could make? What could I improve in my coding style? void mergesortArray(int data[], int amount){ if(amount == 1) return; //Precomputing values int sizeint = sizeof(int...
stackexchange/codereview
#include <stdio.h> #include <stdint.h> #include <assert.h> typedef uint8_t byte; typedef struct { byte i, j; byte S[256]; } Rc4State; void swap(byte *a, byte *b) { byte temp = *a; *a = *b; *b = temp; } /*Initialization & initial permutation also initialize i&j counters in state for stream genera...
stackexchange/codereview
I'm not really sure what the preferred way is to deal with records not found in the database. Is it better to write a Find method which returns null or a Get method which raises a RecordNotFoundException? [AuthenticateFilter(UsernameAndSecretKey)] [Route("api/v1/activities/emails/{id}")] [HttpGet] public IHttpActionRes...
stackexchange/codereview
I've created a console customizer for a C# console application. This is not finished yet but I'm looking for tips, requests and suggestions so I can make some updates. Sample Preview The following code is use to create a customize Write() and WriteLine() and I also make some Typewriter effect on it. namespace GetBoot...
stackexchange/codereview
Cross post from stackoverflow, as suggested. I have an ordereddict, and I need to store it in CSV file. Input: dic = collections.OrderedDict([('k1', 'v1'), ('k2', 'v2'), ('k3', [ [('k3a',21), ('k3b',22)], [('k3a',23), ...
stackexchange/codereview
Pillow is a popular library for handling images in Python. My code adds support for the QOI image format to Pillow. Aside from loading and saving QOI images, my goal was to write a streaming decoder and encoder deriving from PIL.ImageFile.PyDecoder and PIL.ImageFile.PyEncoder respectively, which, as far as I know, has ...
stackexchange/codereview
How can I make this code run faster: for a in range(1,1001): for b in range(1, 1001): for c in range(1, 1001): if pow(a, 2) + pow(b, 2) == pow(c, 2): print(str(a) + "," + str(b) + "," + str(c))
stackexchange/codereview
I've written this relatively simple class to help with managing arrays of anonymous objects in my scripts. /** * AoHandler - accepts an array of objects or creates a new array * @param {array} ao */ function AOHandler(ao) { this.ao = typeof ao === 'object' ? ao : []; /** * pluck() * @param {object} se...
stackexchange/codereview
For my own game engine I need an event system. I tried to avoid the single-huge-enum-approach for minimizing compile times. The BasicEventListener is the (obviously) base class of the EventListener and is needed for storing EventListeners in a list: class BaseEventListener { friend class EventDispatcher; std::...
stackexchange/codereview
I wrote simple compiler for Brainfuck with tcc backend (dont ask for assembler/assembly code generator!). It's output runs incredibly slow. Even Hello World program takes a LOOONG while to execute. I have added some optimizations, but it didnt help. This is code i actually made; It actually doesn't hang, but output wor...
stackexchange/codereview
Question I love using NMAP and other related tools to scan networks really fast. But using a tool and understanding how it works are 2 different things, thus I tried creating a program where I can scan a subnet for open TCP-Ports. I am using scapy on a *NIX machine in python2.7 It works, but is rather slow. Will be wor...
stackexchange/codereview
I have this short Python script for making images brighter: import skimage.io import math import sys def square_root_filter(input_image_file_name, output_image_file_name): image_data = skimage.io.imread(input_image_file_name) image_data_height = len(image_data) image_data_width = len(image_da...
stackexchange/codereview
I have written a small module for accessing data on isotope masses and relative abundances. My long term aim is to build tools in Haskell for working with mass spectrometry data. Any comments on how to improve this module will be greatly appreciated. I am considering uploading this to Hackage, though I want to be sure ...
stackexchange/codereview
I'm pretty confident in this code but I want to be sure I haven't missed anything to do with optimization or error handling. The program takes input in the form of {number} {operator} {number} and prints the result. If the input is invalid it prints nothing. Example input: 1.0 + 2.0 Output: 3 #include <iostream> #inclu...
stackexchange/codereview
So I have encountered a problem with asking user for input to be exact what is the best way to ask yes/no, for example accepting y / n and why is if i == no or i == c_n: not working? What are other mistakes or bad practices that I'm doing here? i = input('yes/no: ') success = "Success" exit = "EXIT" error = 'ERROR' ye...
stackexchange/codereview
class HashTable: ''' Only supports integers as keys right now. Values cannot be None, obviously. Every operation is theoretically most efficient. Uses probing as collision resolution strategy. ''' def __init__(self, init_size=8, load_factor_max=0.75): # A hash table entry will b...
stackexchange/codereview
DIVSUM - Divisor Summation #number-theory Given a natural number n (1 <= n <= 500000), please output the summation of all its proper divisors. Definition: A proper divisor of a natural number is the divisor that is strictly less than the number. e.g. number 20 has 5 proper divisors: 1, 2, 4, 5, 10, and the divisor...
stackexchange/codereview
Update from Paper label system in Python I have not updated the security on the app, need to have a proper look into it. Have decided to use docx module, instead of using print-screen. I have added few important if statements when handling .docx files in folders depending what the user has clicked etc.. My current is...
stackexchange/codereview
I created this custom binding handler: ko.bindingHandlers.line = { update: function (element, valueAccessor, allBindings) { // First get the latest data that we're bound to var value = valueAccessor(); // Next, whether or not the supplied model property is observable, get its current value ...
stackexchange/codereview
I'm building a procedure which compares two JSON objects and return two JSON objects with differences between each (compared keys and values). But I have relatively superficial SQL knowledge, so I need your review to avoid any simple mistakes and improve my code. Compares "first" against "second" and returns the values...
stackexchange/codereview
I have an image upload form with which I call multiple functions before uploading the file such as checking the size and dimensions, and that it is in a valid image. The code works, but calling the functions and dealing with the results seems quite cumbersome and complex. Is there a tidier way of structuring the code? ...
stackexchange/codereview
Help me find out if the approach I took to generate random strings here is correct to be able to return the appropriate short URLs. import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Random; /** * * Given a input string create ...
stackexchange/codereview
I have a situation when there could be and could not be values in database, which is why i return optional, so the response object that goes back to the UI could be different depending on the existing or not values. Examples : new UserLogsResponse(auditEntity.get().getTimestamp(), latestRetrievedDocumentDateAndTime.g...
stackexchange/codereview
Link here I'm currently learning c++ coming from a python background, so I'll include a solution in python and in c++ for the following problem statement and based on very helpful answers obtained on my previous question I made some improvements in the c++ implementation: Given a string s, find the length of the longe...
stackexchange/codereview
I've just implemented a simulation of tower of hanoi in Java. Any suggestions are welcomed. Here's my code: static class Node{ int data; Node next; public Node(int data){ this.data = data; } } static class Stack{ Node top; String stackName; public Stack(String name){ stackNam...
stackexchange/codereview
This Python code looks messy to me. Am I doing any wrong style, or is this how Python looks like? def is_prime(number): """check whether the @param number is a prime number""" is_prime = True for i in range(2, (number - 1)): is_prime = ((number % i) != 0) if not is_prime: return ...
stackexchange/codereview
Here are two implementations I wrote to randomly shuffle cards. The first method (shuffle) selects a random card, then swaps it to the front. The second method (shuffle_v2) assumes that if i-1 cards are shuffled well, try to randomly swap card i with any card from 0 to i-1. Are both methods are good to randomly (unif...
stackexchange/codereview
I have a query I am writing where I want output if a person has some service provided, then I want all the services they had provided after that and I don't want the individual returned if that is the only service they had (the criteria service) I have some example data: In this instance above I would not want the las...
stackexchange/codereview
I need to create a customer and I have foreign keys for each table. Below is an image displaying the relationships of the tables when I want to insert a new customer. Then below the diagram I list out 3 methods that I would like to know any suggestions on how to best remove all the duplication. The main obstacle I enco...
stackexchange/codereview
I had been trying to find a suitable solution to implement localization in my Phonegap/Cordova application. My search proved that any localization through seperate .xml or .json files was a nightmare (mostly due to cross-access-origin). Because of this, I decided to create a (very) simple, lightweight localization solu...
stackexchange/codereview
I'm working to get some practice with SQL functions which are often used in a financial setting, and I created this simple table with products, prices and tax rates basically. I then wrote a query to simulate a purchase invoice type of result set (I realize things like that are most often done at application level, or ...
stackexchange/codereview
Please bear with me, I'm only about a week into Python. This code is something that I wanted to do once I completed the chapters dealing with opening and reading files, and RegEx. I always feel like I'm over complicating the code. Please take a look and let me know if this is sound and where it can be improved. There a...
stackexchange/codereview
I've written an extension method to truncate strings: /// <summary> /// Returns the string, or a substring of the string with a length of <paramref name="maxLength"/> if the string is longer than maxLength. /// </summary> /// <param name="maxLength">The maximum length of the string to return.</param> /// <exception cr...
stackexchange/codereview
Edit: New version improved with the answers and comments received here: Generic circular doubly-linked list v2 I have written a linked list library that I can use whenever I need a linked list, so I tried to have all the functionality that one could expect from a linked list. From the different types of linked lists, ...
stackexchange/codereview
Context: I have a client app which consumes an API. I want to call this API is async way (using java.net.http.HttpClient) and once I receive this data then I want to model the response because it can have either error or actual data in java.net.http.HttpResponse<String>. So it will be good if I cloud transform to model...
stackexchange/codereview
I have written a simple script for managing hashtag notes. I am not familiar with bash scripting so I would really appreciate it if someone could give me some pointers about it. #!/bin/bash #setting default variable values; FILE="$HOME""/allnotes.txt" F_ADD=0 F_LIST=0 while getopts ':t:lf:h:a:' opt; do case $opt...
stackexchange/codereview
I'm trying to figure out what is best and fastest implementation of a browser-like find and highlight function inside a website using JavaScript. This function is for one HTML element without any children. Of course it can be expanded to elements with children with some simple loops. That is not part of question. I wro...
stackexchange/codereview
I am experimenting with performance evaluation. From the hardware architecture point of view, two main factors are cache misses and incorrect prediction of conditional branches which can degrade the performance of an application. I have considered a small application for each case: Cache Misses: In this application, ...
stackexchange/codereview
Since memmem() isn't cross-platform, I'm trying to rewrite it from scratch. How does this look? #define MemContainsStr(Str, StrLen, Substr) MemContainsMem(Str, StrLen, SubStr, sizeof(SubStr)) void *MemContainsMem(const void *StrStart, register unsigned long StrLen, const char *Substr, register const unsigned char Subst...
stackexchange/codereview
I wrote a small utility for searching our web app log files for certain strings. The idea is that if the search string is found somewhere in the entry, the entire entry should be printed. The constraints are: One log entry can have one to many lines (stacktraces for example) Each log entry starts with an uppercase str...
stackexchange/codereview
I am trying to split and assign the url's to the variable, I am getting the desired result but I know there is a way where I can improvise the current code. JSON FILE { "Result": [ "Url::Link::Url1", "Url::Link::Url2", "Url::Link::Url3", "Url::Link::Url4", "Url::Link::Url5", "Url::Link::Url6", "Url::Link::Url7" ], "...
stackexchange/codereview
I am just starting to program in C#, so I am a beginner. I've been practicing some coding and I would like your opinion on something. I have a flying direction for a plane, e.g. ''London - Berlin'' (direction). I want to create a method that will return the first and the last consonant of the plane's starting point (...
stackexchange/codereview
Consider the following simplified HTML code: <body> <form> <textarea></textarea> <input type="email"> <button type="submit"></button> </form> <form> <textarea></textarea> <input class="optional" type="email"> <button type="submit"></button> </form> ...
stackexchange/codereview
Using Python/Cython, I am trying to construct an efficient way to index boolean values. I have been trying to use the bitarray and/or bitstring packages to construct a fast, non memory intensive way to hold a lot of booleans. My goal was for a list like object that could be sliced as such, and actually managed the bool...
stackexchange/codereview
I wrote a short bash script for a completion check of downloading images. goal of this code (Added) I have some downloading content directories. Each of them has a script for downloading images(tmp.sh), for example, the following one: wget -nc ¥ http://www.example.com/001.jpg ¥ http://www.example.com/002.jpg ¥ .....
stackexchange/codereview
It's easy to write a function that adds two ints in F#: let add x y = x + y Actually, it's the same as: let add (x:int) (y:int): int = x + y If you need to make it generic so that it can take arguments of other type than int, you should use inline keyword: > let inline add x y = x + y;; val inline add : x: ^a -> y...
stackexchange/codereview
Tom Sawyer has many friends who paints his fence. Each friend painted contiguous part of the fence. Some planks could stay unpainted, some could be painted several times. Program must output the number of painted planks. Input format: First line: N smaller than 100000 - number of Tom Sawyer's friends. N lines (f...
stackexchange/codereview
I've been reviewing some code that I maintain recently, and I came across this wrapper object for the serial port class. I'm trying to understand the advantage of this seemingly redundant object: Public Class SerialPort_Class Private WithEvents Serial_Port As IO.Ports.SerialPort Private SerialPort_ReOpen_Flag As Boole...
stackexchange/codereview
I'm changing the inner implementation of a project. In order to do so, I've created an interface that will be implemented in 2 different ways. One of this ways is by class A, which is a wrapper for an outside class (class "B") from a .dll file (a product of other team). Class B is a private a member of class A. Class...
stackexchange/codereview
I would like to chart my data. However, the data I get from server needs to be completely transformed, and I would like to transform it as quick as possible. I believed reduce would be the best way to go about this in linear time. However, I am not sure if I am fully exploiting it. The data from server needs to be reo...
stackexchange/codereview
I'm still pretty new to programming, only been doing it a week. I'm just wondering if I made any glaring mistakes or anything that could be improved code wise? import random the_board = [] players = [{'type': 'player', 'piece': 'X'}, {'type': 'player', 'level': 'smart', 'piece': 'O'}] def print_board(boar...
stackexchange/codereview
I need to write a code for conversion between the decimal numbers and binary numbers. I have tried the problem and what I have is 3 classes and 1 enum type import java.util.Iterator; import java.util.NoSuchElementException; /** * The {@code Immutable} class {@code BinaryNumber} wraps a string * representation of a b...
stackexchange/codereview
I need to test a specialized input stream class that takes input from a TCP/IP network connection. I particularly need to ensure that the blocking and availability behavior is correct. To help me with this, I wrote this "white box" input stream so that test scenarios can provide the necessary test conditions to exercis...
stackexchange/codereview
I have been working on this: Design a class for a bank database. The database should support the following operations: ❍ deposit a certain amount into an account ❍ withdraw a certain amount from an account ❍ get the balance (i.e., the current amount) in an account ❍ transfer an amount from one account to another Th...
stackexchange/codereview
Basically I need to order a list, so that an element is not the same as the element that comes after or before it. For example [1,2,2,3,1,3,3] should come out as [3,1,2,3,1,2,3], [3,2,3,1,2,3,1] or [2,1,3,1,3,2,3] and so on. I searched for a solution but couldn't find one so I wrote this function myself. def unorder(al...
stackexchange/codereview
In preparing a solution for the CodeChef "Will India Win" challenge, I am trying to find out the xor of list of numbers. The first line of input contains the number of test cases, 1 ≤ T ≤ 106. Subsequent lines contain fifteen space-delimited numbers (each between 1 and 231), to be XORed together. def main(): t = in...
stackexchange/codereview
I am learning Lua and wrote this little calendar/time-tracking script. It allows me to create tasks to do with a deadline, print them, and mark them as being done. A task is a table with the following fields: name: a string due: the due date, itself a table with number fields day, month and year comment: a string done...
stackexchange/codereview
I'm implementing a Mediator and I'd like to simplify the callback notation a bit. My mediator has Register and Notify methods : public class Mediator { private Dictionary<Messages, Action<object>> registeredCallback; public void Register(Messages message, Action callback) { registeredCallback[message] ...
stackexchange/codereview
I wrote a little function that monitors some directories. If a file gets created, it will check in the extension list for a match. Can you please tell me if I could make my function better in any way? private void sysWatcher_Created(object sender, FileSystemEventArgs e) { try { if (File.Exists(e.FullPath)...
stackexchange/codereview
I have a 2D array matches where I store the game id and another array of objects games where I store gameId with the playerId. Here is what I have done so far: Step 1: I get the opponent's gameId against the gameId from "matches" array. e.g. gameId "2" has an opponent "1" Step 2: check opponent_game in games and retu...
stackexchange/codereview
I wrote a function in Python to call 7zip to compress a folder. The code works and is able to perform the task, however I do not know if this is the most optimal way. Are there any ways to improve the code, any redundant steps? def Compress_7z(Initial_path,Container_Name,File_List, compression_level = -1,DAC = False): ...
stackexchange/codereview
Thought this would be a fun thing to code, basically it is a simulation of the prisoners dilemma. I'm trying to improve my coding so any critiques about how to get better would be appreciated. Also if you have any suggestions for other strategies for the game, those would be appreciated as well. The goal is to have the...
stackexchange/codereview
This is my solution to the Codewars problem TV Remote (symbols). Description In short, you are given a virtual keyboard with 3 modes between which can be switched by pressing the Shift button on the virtual keyboard. You have to navigate using only arrow buttons (up, right, down, left) and an OK-button to press the cu...
stackexchange/codereview
How could I rewrite this jquery code to compact it in a more elegant form: $(document).ready(function(){ $('input[name="table_exist"]').click(function(){ if($('input[name="table_name"]').val()=='users' && $('input[name="table_exist"]').is(':checked')) { $('input[name="table_name"]').val(''); } ...
stackexchange/codereview
Inspired by this website, I wrote the following function to automatically generate a div and load a page for each page listed in an array of page names. The idea is that if I want to conveniently display webpages or other pre-packaged content, I just need to make an array of the file names/URLs and then the function cr...
stackexchange/codereview
For a project I'm working on I have the following requirements: We have two student types: Domestic and International public enum StudentType { Domestic,International } Students of both types must have a ID number, First/Last name but only international students require documentation (Passports, drivers licence, e...
stackexchange/codereview
I wrote a min-heap using a binary tree. How can I improve the time complexity of insert and delete function to be \$\mathcal{O}(log(n))\$? ''' Min Heap Tree Implementation ''' class Node: def __init__(self, data): self.data = data self.left = None self.right = None class HeapBT: def __...
stackexchange/codereview
I am getting images using this glob pattern, but the code looks really bad. First I get all images which have the name screenshot + a number from 0-9 in an array, after that I get all screenshort + a number from 10-99 and so on. I want to improve this code. $dirScreenshotsOne[] = glob($value.'/screenshot[0-9].png...
stackexchange/codereview
I'm building this menu builder with JS. So far I have a simple version 1 implementation that does what I want but it needs improving. Couple of things that I'd like to improve: Prevent unwanted input Control input when there is margin for error, ie for the target field I'd like to have either a drop down or a checkbox...
stackexchange/codereview
I've been learning C++ on my own and working solo on trying to implement some of the concepts I've been reading. I'm wondering if this is the correct group to get someone to point me to other info regarding the code I've wrote or if I'm getting the concepts right. I've tried to build Tic Tac Toe using a class system. I...
stackexchange/codereview
This was just an experiment to see if it was possible to build a stateless builder in ES6. I was able to do it, but when I took it a step further I got stuck trying to DRY it out. In this case, we have a MoveableBuilder and a ParticleBuilder. A Particle is a Moveable, so the ParticleBuilder could reuse a lot of the cod...
stackexchange/codereview
I'm just starting to learn programming again after a long break and decided on Python. Here's my code: #"Code Wars: Where my anagrams at?" A program that finds all anagrams of "word" in "wordList". import copy def anagrams(word, wordList): result = [] #List to store all the anagrams. for i in wordList: #Oute...
stackexchange/codereview
I have a simple program where I am deserializing my bytes byteSlice into a ClientProduct array struct. And then I iterate over that ClientProduct array and construct definitions.CustomerProduct struct for each ClientProduct. Below is my struct details: type ProductInfo struct { Name map[Locale]map[int]string } typ...
stackexchange/codereview
I have a nested hazelcast distributed map: Map<CountryId, Map<CityCode, Map<data_key,data_value>>> where "data_key" is "population", "literacy_rate" and "gender_ratio". Below is the class where I have implemented a method which adds new city data to a specified country. import java.util.HashMap; import java.util.Map; ...
stackexchange/codereview