instruction stringlengths 71 95.1k |
|---|
I am trying to create a custom WordPress/WooCommerce function in PHP. I am a newbie and would really appreciate some feedback on my code and how to improve the code! Right now it feels like there is a lot of duplication where there probably is a smarter and better way to do it.
Overall the function is used to hide ship... |
I'm trying to return a list of objects called orders based on a string search that the user enters. orders has a title and a description. The function loops through the orders object and tries to find matches between the search string and order titles or descriptions. The search should be able to find matches even if t... |
I've been revamping on my coding puzzles practices. What is the complexity (both time and space) for this method?
public static String reverse(String word) {
if (word == null || "".equals(word) || word.length() == 1) {
throw new IllegalArgumentException("Invalid Entry");
}
StringBuilder result = n... |
I'm going through the K&R C book (coming from Python) and am on exercise 1-18, which states:
Write a program to remove trailing blanks and tabs from each line of input, and to delete entirely blank lines.
I wasn't able to find another solution online that looks quite like mine so I am questioning whether it is truly ... |
I'm trying to work HTML5 canvas video into a React application while making the code as clean as possible. What kind of improvements should be made to improve the performance utilizing the React to its fullest potential?
import React, { Component } from 'react';
import './App.css';
import video from './video.mp4';
impo... |
I wanted to create a loan calculator, but the code I could think of was using 3 functions, and calling them and getting result. But I felt it was easy but bad code because I thought this can be written in fewer lines and with more quality. I wanted to ask what are some things to keep in my mind while trying to write be... |
I am a newbie to C++ and I want to do some cool stuff with it. Here I have implemented my own getline function which reads from a file. so what do you think of this getline function?
#include <iostream>
#include <fstream>
using namespace std;
class Foo {
private:
char ch;
public:
void getline(fstream& in, stri... |
I wrote this Paginator module that's part of a small application that displays Elixir Github repos in a table.
I'm new to Elixir and looking for code improvements with as much as possible. Best practices. Commenting. Optimizations. The usage of structs for input output. Etc.
paginator.ex
defmodule Paginator do
@modu... |
This question has been asked for other languages, but I haven't seen it for C++. Most notably here and here.
Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 dupl... |
I am trying to model this:
a Map can have multiple child of type Biomes and no parent
a Biome can have multiple child of type Landforms and a Map as its parent
a Landform can have multiple child of type Tiles and a Biome as its parent
a Tile has no child and a Landform as its parent
I want it to be generic so I can e... |
The Task:
Given a set of closed intervals, find the smallest set of numbers that
covers all the intervals. If there are multiple smallest sets, return
any of them.
For example, given the intervals [0, 3], [2, 6], [3, 4], [6, 9], one
set of numbers that covers all these intervals is {3, 6}.
My solution:
const in... |
I have written a random-walk routine that I hope to build upon in the future. Before doing so, I was hoping to get some critique.
I believe the implementation is correct. I noticed that many other implementations found online use for-loops or modules I am unfamiliar with;
my goal was to vectorize the walk in n-dimensi... |
I'm writing a Python Script for a Raspberry Pi to measure different sensors. We are planning to send the Pi with that Script running to the stratosphere, so the power usage for the Pi is limited.
I excuse myself in advance for the code, I had no prior experience with Python.
Are there any ways I can make this code more... |
I'm writing web application that uses Google Proximity Beacon API to interact with beacon data. In order to access that data, I need to grant access to use beacons' information for my web application with my Google account. When my app is authorized, it receives credentials needed to call desired API. Because I don't w... |
For self-study homework I made a Java program that takes user input, creates people as objects, and says "Happy Birthday" to each person.
I am just wondering what mistakes I made here or how it could have been better.
PERSON CLASS
public class PeopleObjects{
// For practice, make the people objects rather than just... |
Please can any code experts review and improve my code?
HTML
<!DOCTYPE html>
<html>
<head>
<title>API</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=font1|font2|etc" type="text/css">
<link... |
After reading "How to deal with dirty side effects in your pure functional JavaScript," I've decided to take something I do on a regular basis ("Original approach" below)—connect to a Postgres database from Node.JS, perform some operations, and log what is going on—and try to make my code much closer to "purely functio... |
Introduction
I'm writing a script in YAML for building ASP.NET Core 2.2 project using GitLab Continuous Integration. In all YAML samples I could find (and there are not many) for building .NET Core based applications using GitLab CI I could see something like this:
before_script:
- 'dotnet restore'
before_script is ... |
I wrote this after using strtok_r and needing something similar that can copy the input string and handle multiple characters in the delimiter. Its functionally similar to Python's str.split(), as it keeps empty spaces without trimming.
tokens.h
#ifndef TOKENS_H
#define TOKENS_H
#include <string.h>
struct Tokens {
... |
The Task:
The user enters a path to a dictionary file (one word per line) and a phrase as system arguments. My code must then find phrases containing only valid English words, generated by removing one consonant from the user's phrase.
I wrote this as part of an effort to learn Rust, the task is copied from a piece o... |
I'm learning the Elixir language and the Phoenix web framework. And I had an idea. What if, in a web wizard (multi-step form) scenario, I stored the intermediate data in a ETS table instead of the relational database?
So I wrote this controller:
defmodule PlayPhoenixWeb.ThingsController do
use PlayPhoenixWeb, :contro... |
The goal is to have a function that can transform any python function into a curried version of this function. The code is available here, I'll only update the code on repl.it so everyone can make sense of all the remarks and comments made on the code I'll post on codereview.
To be precise, consider this code:
def f(x... |
iextrading has two APIs (v1, v2) which provide financial market data. Following script records a JSON file with their equity information (using a CRON job).
Would you be kind and review it for any possible improvement or anything that may be incorrect?
<?php
date_default_timezone_set("UTC");
ini_set('max_execution_... |
I saw a question on Stack Overflow asking for a review of a custom try...catch construct that made use of Optionals, and got the idea to try writing my own version. Mine doesn't use Optionals though. Each supplied catch handler is expected to return a value.
I realized about half way through writing this that this is p... |
I'm writing a small class that wraps the existing functionality of browser.history.search in Firefox's WebExtensions API. The current API only directly searches for unique webpages as a HistoryItem that shows the last visit, but I need to get all visits within a given time frame.
This is done by finding all the History... |
My question is more of a "can someone give me tips" rather than "can you do it for me"
I have been writing a C code implementation that takes a 32-char String in the form of binary (supposed to act as a 32-bit instruction) and divides it to four 8-char strings. Those four strings are converted to Hex and fed to a small... |
Im relatively new in python. I've wrote my "first" script to do some staff for me. I am creating Image dataset for Mashine Lerning. In Photoshop, I select the area I need in the large image and using the Photoshop script I save the selected area to a folder tree_checker. I have different scripts configured in Photoshop... |
I am writing a function that reads all consecutive blanks in a string, moves the pointer to the next non-blank char, and return a struct "token" that contains the blanks it found.
The main function is defined as
int match_ws(const char** p, struct token* tok)
where p points to the beginning of the strings to analyze, ... |
I wrote a simple String class implementation using unique_ptr and move semantics. Is my implementation good enough in terms of design and efficiency?
Stringy.h
#pragma once
#include <iostream>
#include <cstring>
#include <memory>
class Stringy {
private:
std::unique_ptr<char[]> p;
std::size_t size;
std::s... |
Here is my source code:
// start at zero
var count = 0;
// loop through the items
for(var i = 0; i < hours.length; i++) {
// 1. check to see if the current item has a key called "description"
// 2. check to see if the current item's "description" key isn't empty
// NOTE: white-space only values aren't valid
if(... |
A unival tree (which stands for "universal value") is a tree where all
nodes under it have the same value.
Given the root to a binary tree, count the number of unival subtrees.
For example, the following tree has 5 unival subtrees:
0
/ \
1 0
/ \
1 0
/ \
1 1
class DailyCodingProblem8 {
p... |
I have a small python project, which draws graphics and text onto a graphics context using MacOS's Core Graphics APIs. The idea is to make it easy for the user to write a few short lines, in order to add graphics to a page.
Currently, I'm committing the cardinal sin of a global variable for the graphics context, which ... |
I needed a monadic version of partition today. I settled on the following version:
partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a])
partitionM p xs = bimap (map fst) (map fst) . partition snd . zip xs <$> mapM p xs
Then I realized it's already implemented here:
partitionM :: Monad m => (a -> m Bool) -> [... |
I know the difference between the Entity Framework connected mode vs disconnected mode. In connected mode we do all the stuff inside one single DbContext instance. In disconnected mode we do the stuff and then attach the Entity to a new DbContext instance.
My problem is that I - for a specific reason - had to create th... |
I am attempting to teach myself C++ by writing a simple multi-line text reader that reports the lengths of each line. What can I do better now that I have something that "works?"
Conventions:
variables and members are declared const, if I found it possible
variables and private members are written in camelCase
private... |
I am new to programming and I have made a program to make all repeating numbers in an array 0 and put those all 0s in left side:
import java.util.*;
class ArrayWork
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int arr[],n,i,j,nr[]= new int[5];
System.ou... |
I have the following code, is there a way to optimize it/reduce the code?
#!/bin/bash
if [[ "${active_gpu}" == 'true' ]]; then
if [[ "${version}" == 'dev-gpu' ]]; then
pip install "${version}"
else
pip install package-gpu=="${version}"
fi
else
if [[ "${version}" == 'nightly' ]]; t... |
I am trying to get ordered components of an interface properly without having a local variable orderedComponents outside, and here is my current code.
Reason is because orderedComponents will be in Interface.java and getChildren will be in componentDefinitions.java and I want a more controllable code.
I was also thinki... |
I am working on Leetcode challenge #3 (https://leetcode.com/problems/longest-substring-without-repeating-characters/)
Here is my solution using sliding window and a dictionary. I specifically added start = seen[s[i]]+1 to skip ahead. I am still told I am far slower than most people (for example, given abcdefgdabc, I am... |
Pretty obvious what it's doing here, but It seems pretty silly. What's a better way?
public bool DidHitBounds
{
get {
if (hitBounds == true)
{
hitBounds = false;
return true;
} else
{
return false;
}
}
set
{
h... |
I am using Spring Data JPA with Spring boot application. My requirement is to insert 50K rows in JPA entity table in one hour or less.
I have 3 entities A, B and C. Entity A has a one to many association with entity B and a one to one association with entity C.
@Entity
public class A {
@OneToMany(mappedBy = "chip... |
I'm an absolute python beginner.
I created a draw poker game that works fine up to about ten thousand hands, at which point it starts to freeze and not generate the hands. Given that straight flushes only generate about once per 70 thousand hands (it may be more common bc my program uses multiple decks for the many han... |
As my answer to Iterating over an odd (even) elements only in a range-based loop, I wrote this function, with the following driver program and output:
#include <array>
#include <vector>
#include <iterator>
// Forward iteration from begin to end by step size N.
template<typename Container, typename Function>
void for_e... |
I have following Python code:
def get_subject_from_stream_id_and_subject_id(stream_id, subject_id):
#(stream_id, subject_id): ("subject_name")
return {
(1, 1): "Accounts",
(1, 2): "English",
(1, 3): "Organization of Commerce",
(2, 1): "Physics",
(2, 2): "English",
... |
I am new to programming and I am trying to solve the 8-puzzle using brute force algorithm. The code works for very simple puzzle configuration but freaks out when the even a modest puzzle is input to it.
Initially I was working with a format for board as:
[['1','2','3'],['4','5','6'],['7','0','8']]
But after some sugg... |
Introduction
The Radio Data System (RDS) is a digital signal modulated onto a 57 kHz subcarrier of broadcast FM
radio (above the 19 kHz pilot tone and 38 kHz stereo difference channel). The details of the
modulation scheme are unimportant here; we assume that the output of demodulation is a series of 0
or 1 bits corre... |
I have data as follows:
Payment Date 11/01/18 01/01/2019 11/01/09 11/01/20
Total Amount 4536.87 4654.98 4698.63 4687.69
I need to add up all of the Total Amount starting from 11/01/18 through 11/01/20.
For the months in between dates, I need to use the amount from previous month. I also need to change th... |
Business logic
It would take us too far to explain the whole business case behind this code, so I'll try to be as succinct as possible.
There are Persons,
and Persons can have Profiles,
and the combination of those two is a PersonProfile.
There is also a table called ProfilesToReplace, which contains Profiles that... |
This is my try on the 99 bottles of beer on the wall lyrics, made in Python 3. I am a beginner willing to learn so be gentle :)
def lyrics():
if count > 1:
print(f"{count} bottles of beer on the wall,")
print("")
print(f"{count} bottles of beer.")
print("")
print("Take one do... |
I created a boilerplate from react-boilerplate. I have removed redux and immutable for use context API and immer.
I wonder if I use the context API with a good design pattern.
I use like this:
// ./app/containers/LanguageProvider/index.js
import React from 'react';
import PropTypes from 'prop-types';
import { IntlProvi... |
I've seen this today on a mock interview and wanted to give it a try. I'd love to hear some feedback from you guys. This is my second attempt at the problem, initially I had a mess of if/else towers and nested loops.
/*
* Write a function that takes two strings s1 and s2 and returns the
* longest common subsequences... |
For my game engine I needed a simple templated array class that can be safely passed across module boundaries. It's not supposed to be a replacement for std::vector and thus doesn't need all of its features. Instead it is intended to be used in the interface where binary compatibility is important.
For malloc and free ... |
I have a time series data in long format which looks like as follows:
+======+==========+======+======+
| Name | Date | Val1 | Val2 |
+======+==========+======+======+
| A | 1/1/2018 | 1 | 2 |
+------+----------+------+------+
| B | 1/1/2018 | 2 | 3 |
+------+----------+------+------+
| C | 1/1... |
Quite often, I find myself measuring how long some part of my code takes to complete. I normally do that by storing current time using time.time() and then subtracting time after the code is done.
This normally gives me a float that I can then format and print for debugging purposes. This is the function that I have fo... |
This is another review on a program I've asked about before, with a different target in mind.
Program Function
As before, this program makes emergency changes to medical claim files, delivers all the corrected files analysts need, and produces a changelog as well for their review.
Core Problem - tl;dr Use of diction... |
I'm building an IntelliJ Plugin which will allow a person to select an XML file (and even a snippet of XML in the file, if they like) and, using a really brief GUI, generate classes / code in one of a selection of languages that will read the XML via native functions and generate code to do so on a regular basis.
The i... |
I am making a profile picture selection screen, basically you select a picture pic1, if another picture pic2 is selected, then we cancel the highlight of pic2 and highlight pic1. Here is my code right now for it in React (btw, I am using CSS to take care of the highlighting).
How I am doing it currently (let's say I on... |
I wrote this code about one year ago. I'm looking to refactor it to be solid SOLID and secure, as this is being generated off a custom endpoint. The script is to read parameters from a query and generate custom CSV exports based off categories, tags, and order completion date. These reports can be weekly, monthly, y... |
I created this game in Python as a learning experience and was hoping for advice to make it better. I also used global and was hoping for good alternatives.
import random
import pickle
import os
enemy_count = 0
health_pot_count = 5
level_up_counter = 1
class Player:
def __init__(self, name):
self.name = ... |
Here's what I came up with for a 2-dimensional random walk exercise. It takes a number of steps as input and iterates through them, while drawing every step as a line on the canvas. The direction is randomized.
#rndwalk.py -- Simulates a 2-Dimensional random walk
from random import random
import math
from graphics imp... |
Is that standards-compliant?
#include <string>
#include <algorithm>
#include <iostream>
#include <cctype>
std::string remove_excessive_ws(std::string const &str)
{
std::string result{ str };
auto end{ std::remove_if(std::begin(result), std::end(result),
[](std::string::value_type c... |
I write a lot of mini apps. Each app has its own InputHandler for input from the keyboard. It's time to make a lib for that purpose - a CommandLineInterface.
NOTE: there exists a follow up Question here
Can you review my code on
Design
OOP
Clean Code
Naming (my bad englisch leads to bad naming)
Interface CommandLineI... |
I have the written the following (crude) code to find the association strengths among the words in a given piece of text.
import re
## The first paragraph of Wikipedia's article on itself - you can try with other pieces of text with preferably more words (to produce more meaningful word pairs)
text = "Wikipedia was la... |
I'm in the process of trying to do "object oriented thinking", as to improve my code skill.
I've the following method that creates a lightbox for every item with the class .has-lightbox. Is this something that would benefit from being a class? A LightboxCollection class for example? That has an array Lightbox?
import ... |
I'm adding prefixes to headers in markdown using a script. For example, if I have:
# Hello
## World
### Let's add
## Some headers
### Yay!
# Foo
## Bar
I transform it to:
# 1 Hello
## 1.1 World
### 1.1.1 Let's add
## 1.2 Some headers
### 1.2.1 Yay!
# 2 Foo
## 2.1 Bar
I currently have the following working... |
I would like to apply a transformation, say uppercase, to all the text nodes inside a given node. I came up with the following code which works fine for my sample input.
Is there something else that should be considered? I felt that the usage of text vs tail in lxml is a bit asymmetric because text needs to be applied ... |
I am practicing Singleton pattern in kotlin.
It is a quiz app which has question tile with four options and one correctIndex.
McqOldActivity.classs
class McqOldActivity : AppCompatActivity() {
var questions = mutableListOf<QuestionBO>()
lateinit var mcqPagerAdapter: McqPagerAdapter
override fun onCreat... |
I have a method that can take in a time string in one of the following formats:
HHmmss - e.g. 073055 = 07:30:55
HHmm - e.g. 0730 = 07:30:00
HHmm'H - e.g. 0730H = 07:30:30
a whitespace or empty string - return null
My current code is as follows:
private final static String timeFormatPattern = "HHmmss";
private final s... |
Given a list of integers, write a function that returns the largest
sum of non-adjacent numbers. Numbers can be 0 or negative.
For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and
5. [5, 1, 1, 5] should return 10, since we pick 5 and 5.
Follow-up: Can you do this in O(N) time and constant space?
... |
Purpose of this code is to have buffer which will batch messages based on configured timeout. For example, one thread will continuously push data to this buffer, and when configured timeout pass, it will trigger event to process data (like batch and send to external source).
BufferReadyEventArgs.cs
public class BufferR... |
As soon as I saw this open source paper, I thought that the best way to replicate their code would be using a python class. After having replicated and extended the paper arxiv link here entirely using a class, I saw this question here that uses loops.
I still think that when one sees the Stable Marriage Problem, an ag... |
I have the following BLL (Business Logic Layer) class. It is the first class I have created that takes away all responsibility from the UI (where this class is instantiated/created/called) in terms of checking against business rules. My aim for this code is to be reusable and flexible in instances where I need to add a... |
I'm going to put this script into production in a mail server /etc/aliases file: we have a system that receives email but the subject line must be limited to a certain size. The proposed usage in the aliases file:
alias_name: "| email_filter.sh -s 200 actual.recipient@example.com"
It will be deployed on a gnu/linux sy... |
There's something I completely dislike when importing a module in an interactive Python shell, typing the name of the module, hitting tab and getting the automatic completion cluttered with other modules that the module itself had imported (but are internal implementation details that are not really useful for me).
Exa... |
I Have a class which calls a method, that will convert an excel file, and each sheet will be a DTO, and returns a list containing those DTOs
List<Object> dtos = convertExcelToDTO();
Inside this list, I have 9 DTOs.
But I need to get some attributes individually from each DTO.
At first, I could iterate that list doing ... |
I'm trying to learn programming and this Tic-Tac-Toe is one of my first projects. The user gets to start first as 'x' or second as 'o'.
Please give me any criticism you find on the code and give suggestions on where I can improve the structure and style.
#include <stdio.h>
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#d... |
Context
Usually, when I have to deal with a collection of items (especially objects) I tent to create a container class for that collection (wrapper?). What I mean by that is: when I have to handle multiple clsCars objects I collect them inside clsCars class.
Building blocks
clsCar
Private pModel as String
Private pM... |
The original question was in the context of an array, but I just used a list without changing the length for easier debugging purposes of toString().
Given an unsorted list of integers, design a \$O(n)\$ algorithm to transform the list such that the integers are replaced by the next bigger integer on their right. If t... |
So I have the following data structures
export class BudgetGroupInfo {
name: string;
bcInfo: BudgetCatInfo[] = [];
}
export class BudgetCatInfo {
name: string;
description: string;
bcAccounts: BCAccountInfo[] = [];
}
export class BCAccountInfo {
name: string;
description: string;
}
What I nee... |
I'm currently developing an app that requires sending and receiving of data from android studio going to MySQL and then data coming from MySQL will be saved from the SQLite. I need advice on how to make the process faster. Right now I'm inserting 80,000 + rows of data coming from MySQL and then saving it to SQLite and ... |
My program generates public private keys, encrypts, decrypts, signs and verifies, while using AES for the bulk of the data for speed, and encrypts the random key with RSA. Many operations were chosen for speed. This works out of the box on 3.6+ . Windows idle env disallows it from working there, but Linux and mac is id... |
I have an array of objects:
const dataset = [
{name: 'Marie', year: 12, country: 'Canada'},
{name: 'Jeff', year: 18, country: 'France'},
{name: 'Joss', year: 10, country: 'Spain'},
{name: 'Carrie', year: 45, country: 'Belgium'},
{name: 'Linda', year: 32, country: 'France'},
]
I want two array: one with names... |
I'm currently developing an app that requires sending and receiving of data from android studio going to MySQL and then data coming from MySQL will be saved from the SQLite. I need advice on how to make the process faster. Right now I'm inserting 80,000 + rows of data coming from MySQL and then saving it to SQLite and ... |
I have a list of animals with their counts:
import numpy as np
import pandas as pd
from random import randint
table = np.zeros((5,1), dtype=int)
for i in range(5):
table[i]=randint(10, 20)
df1 = pd.DataFrame(columns=['Animal', 'Count'])
df1['Animal'] = animal_list
df1['Count'] = table
df1
And I have a matrix of... |
I am writing an Angular Websocket service that can send messages to a server and then can subscribe to the response.
I am grateful for every suggestion to improve this.
import { Injectable, OnDestroy } from '@angular/core';
import {webSocket, WebSocketSubject} from "rxjs/webSocket";
import {of, from, Observable, timer,... |
what do you think of my BlackJack game in regards in Object-Oriented Programming?
My code is at https://github.com/ngaisteve1/BlackJack
A follow-up question is available: Follow-Up
using System;
using System.Threading;
public class BlackJackGame
{
private static deckCard deck;
public void Play()
{
bool continuePl... |
I am a beginner in Android and this is my first big project in it. I am trying to communicate with an STM Discovery board using an ESP01 module.
Below is the client connection class
package com.example.remote_dslr;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedRea... |
I'm working to use everything I'm learning in my reading and former code reviews to keep making this program better. I'm getting stuck on the following issue: the play_many_games and game_is_over methods in the GamesEngine class both call reports. I don't like this because the method names don't at all lead one to beli... |
I'm running through the popular python practice exercises located at github:
https://github.com/zhiwehu/Python-programming-exercises/blob/master/100%2B%20Python%20challenging%20programming%20exercises.txt
I recently discovered recursive functions. So when asked the following in the above link:
Question 9
Level 2
Quest... |
I wrote an command line interpreter (CLI) in Java and got some real helpful hints on how to improve.
The cli is responsible to pick up the users input (via keyboard aka command line) into any app that implements the CommandLineInterpreter.
The app itself offers commands to the CLI that can be executed. If the user typ... |
Today I've found /r/dailyprogrammer and I've solved an easy challenge. I'm new to coding and I'm not sure if this is good way to solve this kind of problems. Could you, please, give me some hints? How to make my code more clear and readable? Thanks!
Challange description:
A number is input in computer then a new no sh... |
Given a string S and a set of words D, find the longest word in D that is a subsequence of S.
Word W is a subsequence of S if some number of characters, possibly zero, can be deleted from S to form W, without reordering the remaining characters.
Note: D can appear in any format (list, hash table, prefix tree, etc.)
Fo... |
I have been trying to create arduino code where my MPU6050 reads its angle and based on that angle, change the motor speed. For example, 45° is the max motor speed, 22° is roughly half speed, and so on.
I have a 5065 200kv brushless motor going to a ESC with a bec which I can attach to the Arduino. I have modified some... |
I made a simple web-based file browser with Flask. It also shows some metadata of a file. I have a few questions regarding security though. Is it possible for an attacker to escape out of the preset root directory? Are there any ways to make my code more readable and/or more efficient? Would love to hear some feedback ... |
I have started working on the code below here. I want to practice my C coding skills.
It is a grading program: given a set of subject marks, calculates the sum, average and it converts the computed average to an alphabetic grade letter.
I would love to be pointed out any mistakes that I have made or any opinions to mak... |
I am very new to Tasks and therefore new to handling task cancellations and task exceptions.
I wrote this method that gets a List which is then used to populate an ObsservableCollection shown in a ListView but I am not sure if I am handling cancellations and exceptions properly.
I would like to cancel awaited tasks if... |
I have to do a project on a game of rock, paper, and scissors, and the code I have so far is a complete code for the game, but my professor does not like it since it is too redundant. Is there anyway to shorten it or make it more simple?
import random
while True:
bot = random.choice(["Rock", "Paper", "Scissors"]).l... |
I'm currently making a text based choose your own adventure game with possible RPG elements.
I'm somewhat new at programming. My father is very good ad QB64, but isn't always able to help me with my problems. I'm not asking about story help but with ways I could make my code run more efficiently. I've recently replaced... |
I have a curl based working bash script, but I have many duplicates on the "CURL" body.
How do I improve it efficiently to eliminate duplications?
if ! npm test
then
# Tell the human about the failure, if the npm output wasn't enough
echo >&2 "Testing failed"
curl -X POST -H 'Content-type: appli... |
This is working. Is it ok?
import calendar
from datetime import datetime
def second_fourth_saturday(year):
holidays = {}
for month in range(1, 13):
cal = calendar.monthcalendar(year, month)
if cal[0][calendar.SATURDAY]:
holidays[month] = (
cal[1][calendar.SATURDAY],... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.