instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I created this code in Svelte which will show a modal and remove it when the background is clicked, based on a native JavaScript implementation I wrote earlier.
In the *.svelte files, I put the focus on the code and components, the styles are not included so that the code won't be too long in total.
You can find the CS... | stackexchange/codereview |
I made a game requiring reaction time, and I just came here to see if there's anything I could improve on:
import datetime
import random
import time
points = {}
player_1 = input("Player one: ")
player_2 = input("Player two: ")
points[player_1] = 0
points[player_2] = 0
rounds = int(input("Rounds: "))
while rounds % 2 ... | stackexchange/codereview |
For development I'm using timer classes that are based on Win32 functions like QueryPerformanceCounter() or the time stamp counter of Intel-compatible CPUs. However, for self-contained little test programs that can be posted here (or put in a place like PasteBin and linked) I'm looking for a replacement that does not r... | stackexchange/codereview |
Instead of using 45 IF conditions , I put my two ranges into variant arrays.
Then I used the below code to loop between them and change values of the first array arr1 second elements based on condition.
the first range is only 10K rows and the second range is just 45 rows and code takes about 0.7 second to finish.
I tr... | stackexchange/codereview |
I am able to develop this matrix but I think code can be improved. I am creating a map on which each rectangle may have zero through many list items with their titles (still need to add code for adding titles):
var width = 600,
height = 600;
var margin = {top: -5, right: -5, bottom: -5, left: -5};
var zoom = d3.beha... | stackexchange/codereview |
I've written a function that should get rid of empty p, span, etc tags and those with just ' ' and am looking for ways to improve it. My original solution was very 'wet', but I've managed to come up with a drier solution.
The Original HTML:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"... | stackexchange/codereview |
Haven't put one of these together since college. How does this look overall?
public class HashTable<T, TU>
{
private LinkedList<Tuple<T, TU>>[] _items;
private int _fillFactor = 3;
private int _size;
public HashTable()
{
_items = new LinkedList<Tuple<T, TU>>[4];
... | stackexchange/codereview |
I program python as a hobby and wanted to learn how to apply databases in a functional program, while at the same time make something useful. so I made a to do application with some basic functionalities.
add new to do task
look at all tasks
delete a task
This is the first time I used sqlite3, and I'm not very experi... | stackexchange/codereview |
I am trying to learn Socket.io and develop a multiplayer tic tac toe game. Right now, I have developed a game that plays well when hosted locally, but I cannot seem to transmit game moves between the client(s) and the server. How can I improve my game?
Index.html (with client-side JS)
<body>
<h1 id="title">Let's Play ... | stackexchange/codereview |
So I wrote a rather primitive login logic in Node.js, which authenticates the user and handles JWT. Is it any good in terms of security, efficiency, building, async/sync, logging. SECURITY is my main concern.
On in a prettier format the question would be:
SECURITY: Is my website secure in any way, shape, or form? I'm ... | stackexchange/codereview |
I don't really like SFML's Vector Classes so I tried making my own. Any criticism is welcome.
class gVector2{
public:
float x, y;
float length = GetLength();
gVector2();
gVector2(float X, float Y) : x(X), y(Y){};
float GetLength(){ return sqrtf((x * x) + (y * y)); }
... | stackexchange/codereview |
I have been searching for a solution to show data of class with three assumptions:
Class Employee is not responsible for showing itself
Class Employee does not expose its data with getters
Classes responsible for showing data are immutable
So I created Employee class with its View interface:
public final class Employ... | stackexchange/codereview |
I have written my first shell script that uses inotify-tools to monitor my Downloads directory. What I intend to do with the script is that, as soon as a file is downloaded, it moves that file to a folder named after its extension. For example: if it is test.pdf it will be moved to a folder named pdf.
The script is her... | stackexchange/codereview |
var EVENT_TYPE = "touchstart" // Global Event Type
var H = 360,
S = 1.0,
V = 1.0
var randomColorsList = [],
staticColorsList = [
[r = 255, g = 56, b = 30],
[r = 22, g = 20, b = 32],
[r... | stackexchange/codereview |
I'm getting throw exception and need your review
The main function bellow trying to allocate memory several times and then throw the exception on the upper level.
#include <iostream>
#include <memory>
struct MiserlinessClass{
char * pMemory;
int memory_len;
const int max_size = 10;
Miserliness... | stackexchange/codereview |
I wrote a dirty and ugly code to show in console how many bugs are left until the release of elementary codename Isis.
The code works but it's pretty inefficient. What it does is:
downloads the entire Launchpad site
writes it down to a temp file
scans for the appropriate lines in said file
stores the number of bugs st... | stackexchange/codereview |
I was given the task of batch process a single-level control break program to produce a lecturer information report by lecturer from a university course file.
I have attempted to create a solution using a OO design in Java. I have run into some problems as I don't think the the modules are cohesive as they are not very... | stackexchange/codereview |
I have some sensor data that contains timestamps from when a machine is turned on and an indicator variable showing whether or not the machine is actively running. The data is mostly recorded every two minutes, but they there could be more or less time between two sensor readings due to issues with the sensor.
I wan... | stackexchange/codereview |
As per WIKI An anagram is direct word switch or word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once; for example, the word anagram can be rearranged into "nag a ram".
What is the Best solution in C# in terms of O(n)? I ... | stackexchange/codereview |
I have a Company Class, and separate normalized Address Class. I did this because the Address table will hold more than just Company Addresses, so I don't want "CompanyAddress", "EmployeeAddress", "MiscAddress" tables. The Address table will also hold historical addresses, which would only need to be seen on the Edit a... | stackexchange/codereview |
I'm working on a simple method that would censor emails (GPDR stuff) so they won't show the full name of a user, with 1st character, optional dot, 1st character after the dot and whatever is left after the @ to be left uncensored. So, the intent is like this:
Email to be censored: name.lastname@email.com
Desired effect... | stackexchange/codereview |
Problem
I have image files that are RAW data and have the extension .NEF Whatever edits I make to these files are stored in what is called a sidecar file with the extension .xmp
Given there are many photos and the photo numbering in the camera can only go up to 9999, there is a possibility that I may get duplicate file... | stackexchange/codereview |
I am working on the lossy 16 bit representation for 32 bit integers that catches all 32 bit range with precision depending on absolute value.
My idea is to store integer lv = sign(x)*ilog2(x) in first bite, and a tail that approximates the error x - 2^ilog2(x). In order to do that I divide possible error values in 256... | stackexchange/codereview |
I want to reduce time complexity of my code that solves the following problem.
The program receives a positive distance d followed by a sequence of n
events: An event can be either that a person appeared at some position, or that a person disappeared
from some position. After each event, your program should output
"re... | stackexchange/codereview |
I am building a Python app in which user can maintain wishlist of the products. I only support few e-commerce sites and do not support country specific sites (e.g I may support amazon.com but not amazon.in). I do not support mobile version of the URL (e.g. http://m.amazon.com) and also I am not interested in the query ... | stackexchange/codereview |
I am rendering a list from an array of objects. I want to check the correctness of the array before rendering. For that I am using typeof and null.
In real situation the list comes from the API.
Is it the correct way? and is there any better way to do it?
const activeEvents = [{
id: '1',
title: 'event 1'
}, {
... | stackexchange/codereview |
I have a website where people can write articles and publish/unpublish them. This is done via single button on the page:
<a id="publish-button" href="#" class="btn btn-default <%= 'btn-success' if @article.published? %>">
<span class="glyphicon glyphicon-globe"></span>
</a>
As you can see, if an article is already... | stackexchange/codereview |
I have a very simple Python script. All it does is open two data files from a given directory, read the data, make a series of plots and save as PDF. It works, but it is very slow. It takes almost 20 seconds for data files that have 50-100 lines and <30 variables.
import numpy as np
import matplotlib.pyplot as plt
from... | stackexchange/codereview |
def sam_flag_explainer(flag:int):
"""
Intepret sam flag and make a flag-explained-dictionary.
"""
try:
# Convert sam flags to binary format, like 0101001
# flag is a integer.
flag_binary = "{0:b}".format(flag)
except Exception as err:
if int(flag) == flag:
... | stackexchange/codereview |
I have a workbook that some very non-technical people will be entering data into. In the past, I've had them type over formulas and otherwise screw up the data, so I've locked everything except where they're supposed to enter data, then I've password protected the workbook and worksheet. Unfortunately, Microsoft, in th... | stackexchange/codereview |
Okay - so basically I have a login form that has a couple of 'states' it needs to display (connecting, input credentials, authenticating, invalid credentials, etc...etc...) - in the past I've literally tossed my views into my DI container and bound a ContentControl to a property on my ViewModel that holds a reference t... | stackexchange/codereview |
From some generated code I get a
javax.xml.datatype.XMLGregorianCalendar and I want to convert it to a LocalDateTime without any zone-offset (UTC).
My current code accomplishes it, but I think it must be possible to acheaf the same result in a more elegant (and shorter) way.
public static LocalDateTime xmlGregorian... | stackexchange/codereview |
Preliminaries
I have OWON oscilloscope that is able to record waveform in file in three formats:
Text format .txt: the first lines are some general information such as peak-to-peak value, period, frequency etc. Remaining lines are waveform points that is space-separated values.
Comma-separated-values format .csv: the ... | stackexchange/codereview |
I am writing a solved for 15 puzzle game which will find the solution path to any NxN board. For easier boards the algorithm works great solving almost any 3x3 boards, most 4x4 boards, but when I go 5x5 and higher I will often run out of memory. This is the implementation:
@WorkerThread
public Solution findPath(Board b... | stackexchange/codereview |
I've always wondered what's the most elegant way of implementing PrintLn in C++. I have not yet come with perfect conclusion. This is my shot.
Shortcut for std::cout, std::cerr and std::clog "print line" version. So you can type
CoutLn << "Hello world!"; instead of std::cout << "Hello world!" << '\n';
CoutLn, CerrLn, ... | stackexchange/codereview |
I am learning programming online and currently watching CS50 lectures, in third lecture, professor introduces us to merge_sort though only through pseudo code, so I wanted someone to review my implementation and tell me where I can improve and what I possibly missed.
#include <algorithm>
#include <assert.h>
#include <c... | stackexchange/codereview |
What would be the best way to refactor this class - if any at all? I'm using this class to get the current date and time and also to modify this date by being able to change its date and time. I have a lot of functions which appear to do similar things subtractSeconds, subtractMinutes, subtractDays etc.. But I'm not ... | stackexchange/codereview |
I have a matrix (500x500) of integers. For each entry, I need to look at its surrounding neighbours (so 8 elements) and determine what the integers are, and run a function on these integers.
Here what my function looks like right now (R code with the RCpp package).
fx2<- cppFunction('NumericMatrix getNeighbours(Numer... | stackexchange/codereview |
I have a component with this template:
<ion-card *ngIf="isActive">
<ion-card-header>{{question.question}}</ion-card-header>
<ion-grid>
<ion-row>
<ion-col *ngFor="let answer of question.answers">
<button ion-button outline (click)="answer.action()">{{answer.text}}</button>
</ion-col>
</i... | stackexchange/codereview |
I applied for an Application Developer position. They require all their applicants to complete 1 of 3 programming assignments. I picked one for sales tax calculation. It was quite simple.
Write a program the feeds in prices. If the item is a Book, Food or
Medical product there is no tax, if not there is a 10% t... | stackexchange/codereview |
This function takes as input float error and approximates constant π² to within error by computing this sum, term by term, until the difference between the new and the previous sum is less than error. The function should return the new sum.
$$ \pi^2 = 8 + \dfrac{8}{3^2} + \dfrac{8}{5^2} + \dfrac{8}{7^2} + \dfrac{8}{9^2... | stackexchange/codereview |
I have implemented a max-Heap data structure backed by an array. I wanted to know whether this is an acceptable implementation or not.
Any improvements or suggestions are welcome.
import java.util.Arrays;
import java.util.NoSuchElementException;
public class MaxHeapDemo {
int heap[],heapSize=0;
public MaxHeapDemo(... | stackexchange/codereview |
In an effort to create ever-improving code, I've written a DelegateCommand that takes a generic type parameter to be acted upon. It's pretty trivial, so it should hopefully be easy to review.
In order to do this, I had to create two interfaces: IGenericCommand and IWindowsUniversalCommand.
/// <summary>
/// Requires th... | stackexchange/codereview |
I've got a simple spec for defining character sets, ranges, or wildcards. I'd like to take the string and appropriately create an array based on these rules. I have a solution but I'm sure there is a better way!
Single characters may be used
Sets and ranges are enclosed in brackets []
Sets are comma separated, [1,3,S]... | stackexchange/codereview |
I have network printers which have different attributes (e.g. supported network protocols, languages, status, print modes).
public abstract class PrinterAttribute
{
protected PrinterAttribute(int value, string dsc)
{
this.Value = value;
this.Dsc = dsc;
}
protected PrinterAttribute(int value, string dsc... | stackexchange/codereview |
This is my first Spark Application. I am using "ALS.train" for training the model - Model Factorization. The total time that the Application takes is approx 45 mins.
Note: I think takeOrdered is the bottle neck. it takes 45ms per User for 60,000 Users.
What can I do further to increase its performance? (Decrease time... | stackexchange/codereview |
This code that I wrote for a lab works perfectly and gives the desired output. That said, it's over 200 lines of code to reach the result. This seems ridiculous, even when you consider that there is a restriction to only using the for loop to do it.
What are some ways I could have written this program better? Have I do... | stackexchange/codereview |
Is this a valid implementation of Decorator Pattern? Are there any possible improvements? Also, it is possible to remove decorations in a simple way?
public interface Enemy {
void fight();
String shoutIdentity();
}
public class UnarmedEnemy implements Enemy {
@Override
public void fight() {
... | stackexchange/codereview |
I have an object that has an array inside with another object inside. I iterate over the object and array to print out the first name and last name of the people inside the array of objects. I am wondering if there is a better way to do this.
Without having to use obj[i].first_name + " " + obj[i].last_name
Here is my... | stackexchange/codereview |
Below is a section from the dmidecode output. There is a part of this section that I want to break down. I want to get the 4 bytes after pattern 01 85 30. And I want to change the byte order. Then I will compare with the hex strings I have.
.......
Handle 0x0027, DMI type 219, 106 bytes
OEM-specific Type
Heade... | stackexchange/codereview |
I will design a list with a Font-Awesome design arrows.
My code already works fine, but I will improve it.
ul.long_arrow_right_red,ul.long_arrow_right_gold {list-style: none;}
ul.long_arrow_right_gold li:before {content:"\f178"; font-family: FontAwesome;display: block;float: left;width: 1.5em;color:gold;}
ul.long... | stackexchange/codereview |
So I have recently written a bubble sort in java and was wondering if the code is correct and if there was any way to make it even more efficient.
Here is my code:
void bubbleSort(int array[], int num){
if(num == 1)
return;
for(int i = 0; i < num - 1; i++){
if(array[i] > array[i+... | stackexchange/codereview |
I have the following code which switches between the states of hide() and show() of show prices button.I am aware about .toggle() in jQuery.But I couldn't find a workaround of it in this instance.
When I click the button the <p></p> element is appended to .msg class in the div and when I click it once again it hides it... | stackexchange/codereview |
I have the following working code
import numpy as np
r = np.loadtxt('CoordUnwrapped/ParticleCoordU.5000',skiprows=9,usecols = (4,5,6))
rcom = np.loadtxt('hexaCOM/COMA/COMA.5000',skiprows=10,usecols = (4,5,6))
N = 50
Sx1= []
Sx2 = []
Sx3 = []
for i in range(0,N):
S_data_1 = (r[i,0]-rcom[0,0])**2)
S_data_2 = (r... | stackexchange/codereview |
I've finished an implementation of what I believe the Publish-Subscribe pattern is for practice and possible use in personal projects even though this implementation is fairly similar to the Observer/Observable classes of the Java API.
I'm looking for a review of my code-style, JavaDoc usage, API usage, implementation ... | stackexchange/codereview |
I developed this grid which displays number of records for X & Y, user can click each number to see a list. (I didn't add list markup to fiddle yet - so lets not worried about it for now.)
What I believe is that I overcomplicated this simple project by choosing SVG, and it can be improved massively by using simple HTML... | stackexchange/codereview |
I have this small program in PHP implementing merge sort. I used one rather simple run time optimisation via using one additional array which allows faster merge operations:
function merge_impl(&$source,
&$target,
$source_offset,
$target_offset,
... | stackexchange/codereview |
I have recently finished my first iteration of a template method implementation for a JavaScript canvas animation of the snake game. However, I would love for the community to critique this code and inform me where I am going wrong?
In my opinion, a bad smell for me is the number of times this is used throughout. Furth... | stackexchange/codereview |
I am an amateur programmer and have just written a simple Capacitor Identifier mostly to practice. I have not had many people review my coding and thought this would be a good time to start. It is completed and works. Is there a better way I should have went about it? What should I look at in what and how I am writing ... | stackexchange/codereview |
I have this in place for an RSA Key generation class. I force the user to swipe on the screen randomly and use that as a entropy pool.
class TouchRandom extends SecureRandom {
private final Stack<Byte> pool = new Stack<>();
@Override
public synchronized void nextBytes(byte[] bytes) {
for (int i = ... | stackexchange/codereview |
There is a follow-up question available:
shell-sort-insertion-sort-bubble-sort-selection-sort-algorithms-python.
Selection Sort
The selection sort algorithm sorts a list (array) by finding the minimum element from the right (unsorted part) of the list and putting it at the left (sorted part) of the list.
Bubble So... | stackexchange/codereview |
I haven't spent too much time with CoffeeScript and am trying to have a simple counter:
casper.on('step.complete', ( ->
i = 0
return (step) ->
i += 1
@echo "Step#{ i }"
)())
Which works fine but seems to have a bit too many parenthesis for CoffeeScript.
| stackexchange/codereview |
I'm currently developing an application in ASP.NET Core 2.2 with Domain Driven Design. What you see in here is a Unit Creation page.
A Unit is composed of competences. A unit must have at least one competence and its name must not be in blank.
A Competence must have a descriptor, at least one indicator, and three evi... | stackexchange/codereview |
I am taking an algorithm course and we are to implement merge sort that handles list of elements with even or odd number of elements and handles duplication, so I wrote this function:
void mergesort (int* list, int len)
{
if(len == 1) return;
int i = len/2, j = len-i;
int list1[i], list2[j];
... | stackexchange/codereview |
This is a self-teaching implementation to get files for a given directory in order to simplify os.Walk in Go (avoid to pass a func for recursively walking across the files and directories).
I'm pretty new to the language and feel there is already something wrong with
the way the structure ""implements"" the interface.... | stackexchange/codereview |
The solution I have written is working as expected, but here is my function:
const dataExtraction = () => {
const { id, name, sprites, types } = data;
const pokemonType= types[0].type.name;
const { front_default } = sprites;
const animated= sprites.versions['generation-v']['black-white'].animated.front_default;... | stackexchange/codereview |
I've recently came across many inconsistencies in a code which I had to maintain and develop. Mainly in ajax and timing/interval functions. I'm quite a novice in the ways of JS but tried my best to standarize those into one timer class with passable functions for specific inpage changes since It was supposed to be univ... | stackexchange/codereview |
I'm preparing for an exam on C++, as part of my preparation I want to implement a generic map without using anything from the STD for educational purposes.
Before jumping into implementation of everything, I want to know that the skeleton for my Map is solid and I use templates and template inheritance correctly.
Above... | stackexchange/codereview |
This is my code to print letter 'F' with nested loop 2d array. Are there changes that could be made in it to make it look better or more efficient?
for (int i=0;i<=4;i++){
for(int j=0;j<=4;j++){
array[i][j]='*';
if ( array[1][1]=='*' || array[1][2]=='*' || array[1][3]=='*' || array[1... | stackexchange/codereview |
Challenge: 2520 is the smallest number divisible by 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by 1-20?
Solution:
public class Euler5 {
public static void main(String[] args) {
long startTime = System.nanoTime();
int result = 0;
for (int i =... | stackexchange/codereview |
I have a method which creates some default values in an ObservableCollection, nothing too fancy, but I'm trying to decide how to write the if statement.
private void CreateDefaultParameters()
{
//If there are no parameters, then create default ones.
if (this.Parameters == null || this.Parameters.Cou... | stackexchange/codereview |
My company is cheap but wanted a way to pinpoint bandwidth on certain computers. Me being a programming guy came up with the following small program. I just wanted some expert opinion on my code. I am especially interested in you opinion on how I usually pull permanent variables. I usually put these variables in a ... | stackexchange/codereview |
One of my functions must throws 2 exceptions, but I understand 1 exception per function is preferred (at least according to my client's Sonar ruleset). Can you suggest how I might refactor the following code to enable 1 or no exceptions on these functions?
Worth noting is that I have a global exception handler which w... | stackexchange/codereview |
I needed to find a way to convert a bunch of enums to string for displaying in C++. The two main ways I found when searching was using dark magic macros or voodoo magic template metaprogramming.
As I don't know much about any of them I thought building something myself would be a good opportunity to learn new things. H... | stackexchange/codereview |
Sonar/FxCop are telling us that we shouldn't use void async methods. That's ok.
This is the current implementation:
private async void InitMethod(ServiceControl serviceControl)
{
if (serviceControl != null)
{
await Task.Factory.StartNew(() => serviceControl.Execute());
}
}
// fire and forget ... c... | stackexchange/codereview |
I'm using the following structure:
class Map
{
public List<List<Point>> points;
public List<Base> bases;
}
Point and Base are over-normal sized classes (has more than 30 attributes).
And I'm iterating this Map class like this:
public static void calculateMatrix(Map map)
{
LineOfSight.LineOfSight los = new... | stackexchange/codereview |
$controller = new UserController();
if (isset($_POST['submitform']))
{
$validated = false;
$inputs = array (
'username', 'email', 'password',
'repassword', 'password_f', 'repassword_f',
'display'
);
$i = 0;
foreach ($inputs as $key)
{
if (isset($_POST[$key]... | stackexchange/codereview |
I have separated my application into two pieces. The first piece is my core functionality project. The other piece is the UI of the application. The core functionality should communicate with web services and interact with my SQLite databases.
In the core application I have four layers. These layers are:
Business Laye... | stackexchange/codereview |
For my first attempt at Scala I decided to solve a simple exercise on codingame.com.
Based on a string input containing the user location, the defibrillators count and a list of defibrillators entries (id, name, address, phone number, longitude, latitude), I have to print the closest defibrillator from the user. The di... | stackexchange/codereview |
This CSS code creates an animation that describes a random movement using the CSS transition property for box-shadow which properly results in what resembles an ascending effect followed by hovering.
<html><head>
<style>
body {
background-color: #fff;
height: 100%;
margin: 0px;
padding: 0px;
w... | stackexchange/codereview |
I have implemented a splash screen which is the main activity of my Android app. This splash screen shows an image, and after 1000ms there is an animation to show another activity's layout.
The code I've written is the following:
public class SplashScreen extends AppCompatActivity {
@Override
protected void on... | stackexchange/codereview |
Below is my code:
private double GetImageValue(Bitmap Image)
{
double ImageValue = 0;
for (int X = 0; X < Image.Width; X++)
{
for (int Y = 0; Y < Image.Height; Y++)
{
Color CurrentPixel = Image.GetPixel(X, Y);
ImageValue += CurrentPixel.A + CurrentPixel.B + CurrentP... | stackexchange/codereview |
I'm attempting to implement an algorithm that finds all subsets that sum to a number n. Here is my attempt so far:
function combos(n, combo, result){
combo = combo || [];
result = result || [];
if(sum(combo) === n) {
result.push(combo);
return;
}
if(sum(combo) > n) {
return;
}
for(var i = ... | stackexchange/codereview |
Presently my program is working properly, but how do i implement this program without using nested while loop(one while loop within another while loop).This is a kids way of programming and my office colleague doesn't want me to write code like this.So is there a different way for implementing this program or a proper ... | stackexchange/codereview |
I'm writing my own HTTP client, kinda like cURL. (I already know I'm reinventing the wheel, this is more or less getting an inside look of HTTP 1.x before 2 becomes a thing.)
So far pages download perfectly fine using OS provided socket libs. (Linux/Mac)
So what the problem/question is, how can I better my client? One ... | stackexchange/codereview |
A while ago, I was working on a chess project with a couple other people. In the end, I wrote all but a couple of the lines of code, including these:
class Piece(list):
def IsValidMovePattern(self, FromCoord, ToCoord):
print(self, "Validation not done")
return False
class King(Piece):
def I... | stackexchange/codereview |
In my application, the user may or may not want to ignore some directories. I can do that, but it seems like I am repeating myself. Does anyone have an idea to refactor that?
from os import walk, path
exclude = ['dir1/foo']
for root, dirs, files in walk('.', topdown=True):
if exclude != None:
dirs[:] = [d f... | stackexchange/codereview |
I've been learning more about PHP Objects and Classes, and my immediate reaction was to create a Database Object for handling the MySQLi Connection, Statements and Results. Its not meant to be an ultimate do-all object, but help with WET code. Obviously this has been done before... at least a hundred times.
There's... | stackexchange/codereview |
need some help or advice, HackerRank's frequency-queries challenge,
the challenge of this Hackerrank problem is to check if the frequencies of number in your data structure matches the queries.
small integer values, that occupy the first 2 bytes of the integer datatype are fast and passes the test, but for values close... | stackexchange/codereview |
Currently I'm developing my business entities. I feel that the structure is a tad cumbersome.
What I mean is that a store on a particular day can have different open and closing times. So it's not as simple as a store opens and closes at 09:00 and 17:00 respectively every day at the week. A store may open at 09:00 and... | stackexchange/codereview |
I've tried to make a custom file upload input. The goal was to just have a nicer looking file input compared to its unaltered version.
One thing I don't like is the CSS. I don't like altering the position, but maybe that is just how it has to be? (Since the input and input button are hidden from view. It was a bit diff... | stackexchange/codereview |
Just for fun, I created this small function that prints an iterator in a String:
use std::fmt::{Display, Write};
fn enumerate<T: Display, I: IntoIterator<Item = T>>(it: I) -> String {
let mut it = it.into_iter().peekable();
let mut result = String::new();
if let Some(first) = it.next() {
write!(re... | stackexchange/codereview |
I'm trying to design a Shader class. For now, I'm just trying to get basic outline for handling uniforms. Some design goals I aimed for is to avoid passing a string to a function as this is error prone and has no type checking. There's really only one place this can go wrong: if you mistype the name of the uniform wh... | stackexchange/codereview |
I have integrate aad authentication using react-adal client and secure paths using private routes method
I'm not satisfied with the code structure so I would like to improve it.
Here's the code
index.js
import { runWithAdal } from 'react-adal';
import { authContext } from './auth.js';
const DO_NOT_LOGIN = true;
runWi... | stackexchange/codereview |
The problem I have is to find the sum of 2 linked lists. Each linked list node contains 1 digit that represents a number.
My algorithm works but I was wondering if there is a more efficient (speed and memory wise) to solve this problem OR maybe some minor tweaks I can do to reduce space and runtime.
Example: 7 -> 5 -> ... | stackexchange/codereview |
int combiset(int ism,int inarr[],int inpth){
int r1,r2,r3,r4;
for(int i=0;i<inpth;i++){
r1 = inarr[i]+inarr[i+1];
r2 = r1+inarr[i+2];
r3 = r2+inarr[i+3];
r4 = r3+inarr[i+4];
if(r4==ism){
printf("%d %d %d %d %d\n",inarr[i],inarr[i+1],inarr[i+2],inarr[i... | stackexchange/codereview |
I am working on an e-commerce website called Shopless, which is similar to E-bay/Gumtree. Our website integrates with other DMS systems, in order to allow organisations to import products into our system.
The following diagram shows our B2B import process (note: black lines indicate tasks performed by our system)
Som... | stackexchange/codereview |
I had been working on a project for some time, and then it went on the way back burner after my daughter was born. I'm back to it, and now I discover that I'm best off using PDO over MySQLi. So, I'm working on the conversion, and I'd like to get some confirmation that I'm handling things well. Essentially: Does this... | stackexchange/codereview |
I've got the following PHP code, which is taking a search term, and checking if any of the search terms could be or could have a nickname.
$search = $_GET['search-term'];
$indiviudal_terms = explode(" ",$search);
foreach($indiviudal_terms as $term) {
foreach ($nicknames as $nameset) {//$nicknames is a multidimensio... | stackexchange/codereview |
The callable class below loads configuration data, formats it into a form compatible with my application(from its human-friendly version), performs some important checking, and finally makes it available to be accessed by calling the instance.
This is part of my(working) financial market trading application, written af... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.