instruction stringlengths 71 95.1k |
|---|
I'm practicing C and wrote a function to trim leading/trailing spaces in a string:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void string_trim(char **input) {
char *input_copy = strdup(*input);
int input_length = strlen(input_copy);
int start_index = 0;
while (*(input_copy++) == ' ') {
sta... |
I am making a program that parses profiles from a website. Some profiles are "public" and others are "private" with limited information. Public profiles contain a lot more data and have ~15 more attributes.
Should I have one Profile class and set all unobtainable attributes to None? Or should I have 2 different classes... |
I'm trying to come up with a solution to this interview question:
You have a stream of RPC requests coming into a server which is being
logged. Each log entry is of the form [id, timestamp,
type ('Start' or 'End')]. Given a sequence of log entries and a timeout value, you need to figure
out at the earliest possible ti... |
I'm trying to make a simple library for de/serialization in c++, but I know it can be tricky to implement, so I'd really like to have my code reviewed to see if there's anything that stands out and/or can be improved. Here is the full repo containing all the code. Any other necessary code can be found there, as most of... |
I'm new to C#, background in Ada, C. This is my second lab in a course, output works correct but I feel like I've missed something about OOP. I've asked for feedback from lab 1, but didn't get any.
Main objective of this lab is Inheritance, Abstract classes, Interface.
Broad advice are as useful as detailed advice!
It ... |
I am new to NextJS, it has somewhat been forced on me and the existing code was not authenticating correctly (after a period the site would hang - not return to login - this was due to the way we were using the refresh token). I decided to roll my sleeves up and re-write the way we were trying to do authentication foll... |
The problem statement is as follows:
Sudoku is a game played on a 9x9 grid. The goal of the game is to fill
all cells of the grid with digits from 1 to 9, so that each column,
each row, and each of the nine 3x3 sub-grids (also known as blocks)
contain all of the digits from 1 to 9.
Sudoku Solution Validator
**Write a ... |
I made a borders filter in C. It works properly, but I think it could be optimized and better designed; the formatting is abysmal. It uses too many lines for the border cases and has too many variables.
Basic Color Struct
typedef struct
{
BYTE rgbtBlue;
BYTE rgbtGreen;
BYTE rgbtRed;
} __attribute__((... |
I have implemented my stack based on a doubly linked list. The code is tested and works; however, I am interested in any improvement ideas.
#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
int data;
struct Node* prev;
struct Node* next;
} Node;
//---------------------Stack---------------------... |
Original post:
Based on feedback from J-H in his answer I have done another attempt.
Link to question:
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where:
'?' Matches any single character.
'*' Matches any sequence of characters (including the empty seque... |
cd "$(dirname "$0")"
javac -d . -sourcepath Source Source/project/Main.java
rm "Project.jar" 2>"/dev/null"
jar cfm "Project.jar" "Manifest.txt" project/*
This script would be placed in a Project directory, in which is Manifest.txt and a Source directory which contains the base package, i.e., Main.java would start with... |
I am sampling from m normal distributions n times each, and storing the samples in a 2-dimensional ndarray. I then need to turn this into a polars dataframe as I need to add some string columns and do a lot of querying/aggregating.
I think where I convert the array to a dataframe is inefficient. The Polars docs did not... |
I have implemented my queue based on doubly linked list. The codes is tested and works, however, I am interested in some improvement ideas, thanks
Based on some review remarks on my previous implementation of stack, I made the front a pointer, and I kept the size for reverse for example, and I kept the doubly linked li... |
Took me a couple days and I had to make 2 versions. Version 1.2 is better looking and more readable, with better functionality. No where near optimized though, as I know nothing about that.
Save and Load Functionality won't work on your OS unless you change the file paths in the code, but those took me a while to get w... |
Given an array of severity from an external risk management system
const severities = [
{ value: 'minor', enumFieldOptions: [{ value: 'catastrophic' }, { value: 'major' }, { value: 'minor' }] },
undefined,
{ value: 'catastrophic', enumFieldOptions: [{ value: 'catastrophic' }, { value: 'major' }, { value: 'minor' ... |
I have an input array of month-year strings of disabled months selected by the user:
disabledDates = [
"2020-01",
"2014-07",
"2020-03",
"2011-08"
"2011-10"
]
(But it can be much longer)
The user is displayed a calendar with years and months only - he can select an year using a dropdown. For each ye... |
What I Want?
I want to make an event system in React that cuts back on unnecessary re-renders and stops props drilling.
What I Did?
The code I came up with is the following:
import { useEffect } from "react";
const sourceList = {};
export const useBroadcast = <T>(name: string) => {
// if the event is already regist... |
The task I'm doing is, fetch external API, then save the results to database.
I'm a beginner, I really wanna improve my code, to handle error well, and remove redundant code. The code is working, but I'm bit confused with promise and try-catch. I watched some tutorial, still not sure in the situation which way is bette... |
I'm unsure if this question belongs on Code Review or Stack Overflow.
Another developer told me that I should consider adding type hints to my open source project WordHoard.
I have never used type hints before and the documentation doesn't seem intuitive. So I need to guidance on how to implement this functionality in ... |
The goal is to run a function compute in parallel on many inputs (10**6 in total, say) and store the results.
Each call to compute takes a few seconds and is independent of other computes.
Since running it on all inputs takes too long (even on many cores), I want to be able to start computing, interrupt it, and continu... |
I've written a JavaScript function to imitate PHP's array_intersect_key() function for objects. PHP uses arrays as both arrays and objects but JavaScript treats arrays and objects differently. I'm only interested in traditional objects since the equivalent for traditional arrays would be trivial.
The function returns a... |
I have the following function that takes too long to execute.
I need to made this at least 2x times faster.
for (size_t i = 0; i < mat1.size(); ++i)
{
for (size_t k = 0; k < mat1[0].size(); ++k)
{
for (size_t j = 0; j < mat2[0].size(); ++j)
{
res[i][j] += mat1[i][k] * mat2[k][j];
... |
This is a simple 2 player game made in NodeJS and the ExpressJS framework with typescript. I've built using OOP approach to as far of an extent as I know of it. I'm really curious as to how further more I could improve it to satisfy even more of OOP principles and enhance extensibility.
import { IRuleSet, ruleSet } fro... |
I am making a "wordlist cleaner" module that loads a words.txt file, and returns a list of cleaned/sorted words.
Full code:
import logging
MIN_WORD_LENGTH = 3
MAX_WORD_LENGTH = 25
class WordlistCleaner:
def _load_words_from_file(self, words_file: str):
"""Loads a list of words from a file"""
wor... |
I implemented the following code for determining if two floating point numbers are equal is_float_equal(...). It handles the tests for my use cases well, but I was wondering if the community could provide feedback on the implementation and its correctness?
My objectives are to consider two floating pointer numbers (rep... |
I'm building a Laravel app (with Vue3 and InertiaJS), and I'm attempting to create relationships between three models:
User
Area
WorkHours
where WorkHours is the primary model. In addition to the main data (date, hours, comments, reason), I need to create the following relationships:
User - the WorkHours entry is fo... |
I've made a little function for myself that replaces certain variables to text in an org file. I declare a bunch of variables in the beginning of the file and then the function replaces all references to the variable with the value. So for example
#+VAR:location=AAAAAA
text text text \v{location} text text text
becom... |
The problem:
I am given a data frame. Somewhere in that dataframe there is 3*N
number of columns that I need to modify based on a condition. The
columns of interest look like this:
names_1
address_1
description_1
names_2
address_2
...
Joe
joe_address
...
George
...
...
Kate
kate_address
...
Daphne
...
...
B... |
If you want to lexicographically compare two vectors in C++, you can simply write vec1 <=> vec2. But instead, if you want to compare them reversed, it is not as simple as writing (vec1 | std::views::reverse) <=> (vec2 | std::views::reverse). So, I decided to write comparison operators for ranges in C++.
This is what I ... |
I have a below code which reads all the S3 files from a particular S3 bucket and then it adds all those files in a objectList variable.
private static async Task<List<String>> ListObjects()
{
var objectList = new List<String>();
var firstRequest = new ListObjectsV2Request()
{
BucketName = _firstS3B... |
I have written code for this leetcode problem :-
Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right, and return the reversed list. For example :
Input: head = [1,2,3,4,5], left = 2, right = 4
Output: [1,4,3,2,5]
... |
This code does exactly what I want it to, however I want to try and get rid of the nested loop to make it more pythonic. I have been trying to somehow use broadcasting, including playing with np.newaxis, but cannot produce the same result.
M1 = np.array([[11,11,11],[12,12,12],[13,13,13]])
M2 = np.array([[21,21,21],[22,... |
I have been coding on Python for two weeks.
All I want the code to do is this:
Check if each word in sentence has an English category Wiktionary article
Ignore all words inside quotations and proper-nouns
If the word doesn't have an English category Wiktionary article, add it to a list of misspellings
For each misspel... |
I wrote this function and I'm interested if it can be sped up by improving the code.
The function accepts either column major 1D array or 2D row major array.
Maybe there are some obvious JS tricks that work faster?
const invert = (m, s, CM = false) => {
const zrow = new Array(s).fill(0);
const failCheck = (ind, p... |
The project is simple:
Login screen and a forgot password screen. You can navigate from Login to ForgotPassword.
I feel like I overcomplicated things, but I don't know if (and how) it can be simplified.
The code:
LoginRoute.kt
@Composable
fun LoginRoute(
viewModel: LoginViewModel = hiltViewModel(),
navControlle... |
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... |
Leet Question
Update Leet Code: 127. Word Ladder (Part 2)
A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that:
Every adjacent pair of words differs by a single letter.
Every si for 1 <= i <= k is in wordList. Not... |
So I'm simultaneously learning both Rust and Smoothed Particle Hydrodynamics.
I've been using this video from AMD as a reference and the provided smoothing kernels.
At this stage, I've not optimised the simulation with voxelisation, nor have I added hardware acceleration, so it is very slow. I've also not added a visua... |
Original Question:
Leet Question
A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that:
Every adjacent pair of words differs by a single letter.
Every si for 1 <= i <= k is in wordList. Note that beginWord does not... |
I made a script that scans a folder of 723 documents (pdf, pptx, docx) to extract the 'Name', 'Type', 'NbPages', 'Creation Date', 'Period Date', 'Countries', 'Summary', 'Indicateurs', 'Path'. I think I am not doing it right as I do several loops and each run through the text to extract their respective information. As ... |
The following code has a Handler class that follows the classic Chain of Responsibility pattern. But we don't want to write a new handler class for every new type that we want to handle. I tried making Handler a template class, but it could not work because the class Worker is to derive from Handler, and thus I resor... |
I have a form in a WinForms application that has a Textbox called txtSupplier, a button called btnSrchSuppliers, a label called lblSuppName, and a ListBox lstSuppliers.
When the user clicks the button, it goes to a database and fetches a list of suppliers and lists them in the ListBox, selecting a supplier from the lis... |
I found the two related questions but they, however, do not answer my question:
interval map implementation
Where exactly does my code not adhere to the specification of the key and value type?
The task is as follows:
Implement 'assign' function for the intervals container interval_map:
interval_map<K,V> is a data s... |
I have created Game of Life in C++ SFML. The code works just fine. However since I am not used to working with C++, I implemented a lot of stuff the way I would in python (for example I have not used pointers). So I would appreciate any feedback (even if it is really nitpicky) on my project. My goal with this project i... |
I'm working as a system administrator (sort of), but learning Python on the side.
Life gave me a chance to apply that knowledge, since our organization is being provided cloud email service, and it has a pretty terrible GUI (without even an option to download a list of user accounts), so the only option to do some thin... |
Based on this question, I tried to simplify the use case with simpler model,
Let me know if you have other suggests on optimizations potentially algorithmic.
#include <iostream>
#include <tuple>
#include <iostream>
class AtmHandler
{
static inline auto chain = std::make_tuple(
[](auto &amt)
{
... |
Here's yet another implementation of a singly linked list. You may base your review on the following questions:
Review goals:
Is the API well thought of?
Does this design include undefined behavior, allow unnecessary flexibility, or make unnecessary assumptions? Are there arbitrary details in the design?
Does the desi... |
I am new to Rust Programming so I decided to implement a Maze Solver using DFS. I was wondering if there is any way to optimize this code further
use std::collections::{HashMap, HashSet, VecDeque};
// Load maze from a given file name and return an array of strings
// fn load_maze(filename: &str) -> Vec<String> {
// ... |
I wrote a working linked list program in C. What can I improve in my code in your opinion? The first thing I think about is doing unit tests. I want to learn TDD. I'm not sure if it is a good idea to implement in the pop_front and pop_back functions handling empty list situations.
main.c
#include <stdio.h>
#include "li... |
I just created a Github API based backend, this api retrieves and stores information from the github users api
app/Http/Controllers/GitController.php ,I am using Requests, Actions and services
<?php
namespace App\Http\Controllers;
use App\Actions\CreateUserAction;
use App\Actions\SearchUserAction;
use App\Http\Reques... |
The project is named winlin; it's a portmanteau of the words window and Linux.
I'm working on a CPython extension to interact with the X server and manipulate windows. I don't have a ton of functionality yet but I think I'm to a good point where most of the basic facets are established and I can start to expand it. But... |
I want to show you my implementation of the array list in C. Is there something I can improve or fix?
Header
#ifndef ARRAY_LIST_H
#define ARRAY_LIST_H
#include <stdlib.h>
static const int AL_INITIAL_CAPACITY = 16;
struct array_list {
int *array;
size_t capacity;
size_t count;
};
struct array_list *al_ne... |
I'm making a calculator that is supposed to calculate the price of fruits in a trade (for a game)
omg, my code is so bad and messy that its embarrassing. I'm so sorry for anyone who has to look at this
def add(u, x, y, z):
return u + x + y + z
fruit1 = input("Enter first fruit: " )
fruit2 = input("Enter second frui... |
I have this piece of code that checks the input of a text box before I compute for my main logic. This looks like it should be refactored but I'm currently stumped how to do so. The only thing that comes to mind is to make 2 functions "processDecimal" and "processInt" and I just copy the code under their respective if ... |
I have this class component from the rc-year-calendar library.
import React from "react";
import PropTypes from 'prop-types';
import JsCalendar from "js-year-calendar";
import 'js-year-calendar/dist/js-year-calendar.css';
export default class Calendar extends React.Component {
static propsTypes = {
// ops... |
Motivation
When working with storage or wire protocols, we often read or write structures containing integers with specific byte-ordering (e.g. big-endian for Internet Protocol, or little-endian for USB).
It's common to use functions such as the htons() family to convert values, but it's easy to miss a conversion (part... |
The website TryHackMe came up with a challenge that involves using HTTP requests to interface with REST APIs (here, task #14/day 9). The challenge basically involves querying a basic REST API to reconstruct a string value from the information returned by the service. Specifically, the value key has a piece of the strin... |
Here is my attempt to write the infamous factorial using Data.IORef.
import Data.IORef
xgo accRef nRef = go where
go = do
acc <- readIORef accRef
n <- readIORef nRef
writeIORef accRef (acc * n)
writeIORef nRef (n - 1)
if (n > 2) then go else readIORef accRef
facM n = do
accRef <- newIOR... |
I am evaluating two implementations of a C++ logging mechanism.
The first implementation, below, unconditionally streams (calls the insertion operator) to the std::ostream& returned by a class's various warn()/info()/etc. functions. Those functions conditionalize which std::ostream& is returned: std::cout or a "do-noth... |
Based on previous examples and code submitted, I wrote this simple state machine, let me know if you have other suggests on optimizations potentially algorithmic.
#include <iostream>
#include <tuple>
#include <array>
#include <unordered_map>
#include <functional>
#include <string_view>
enum AccountTypes
{
Red,
... |
This code is supposed to fix JSON structures that are broken by having unescaped quotes in strings and try to recover if possible.
The code can only recover on certain cases and can be fooled by certain combinations, but that's to be expected. It's not trying to handle all possible cases, which is impossible anyway. Th... |
I made my own dynamic array type using void pointers. I'd like to know what you think of my implementation. void pointers are nice but I fear they may be inefficient. The compiler cannot tell what you are doing because it has no size information. Either way i like the flexibility and the fact that i do not have to u... |
What is this?
My university's Wi-Fi network requires students to visit a specific URL and login to the network before we can use the actual internet. This project replicates that same process by calling just one command, and I've successfully implemented it using Windows Task Scheduler and some cron black magic on Ubun... |
I have a couple of questions regarding how builder should be implemented idiomatically in Rust when it's necessary to call its parts depending on some flags.
Here's my take on three different designs of builders (also with usage example on rust-playground):
#[derive(Debug, Default)]
pub struct MutableBuilder {
valu... |
I'd like to wrap all my sqlite statement functions with a decorator which collects the statement and the lists of values I will inject in place of placeholders in my statement (to avoid sql injection).
Code looks like this:
#decorator
def dbexecute(func):
def withcon(*args):
conn = sqlite3.connect(sqlite_fi... |
Motivation
When working with storage or wire protocols, we often read or write structures containing integers with specific byte-ordering (e.g. big-endian for Internet Protocol, or little-endian for USB).
It's common to use functions such as the htons() family to convert values, but it's easy to miss a conversion (part... |
This is my try, based on good inputs from different places.
I ended up saving the DMX-values in two arrays (one for sine and one for cosine) as I guess that will make stuff easier later on when I want to add offset (and so on) to the lamps receiving the dmx-values.
This how I declare the two arrays and how the code is ... |
I built a fully functional American football scoreboard in React. I know that I made a lot of terrible design choices, but I would like to know what they are:
import React, { useState, useEffect } from 'react';
import './App.css';
function App() {
const quarterLength = 720; // 900 = 15 minute quarters, 720 = 12 minu... |
With the following code I implemented the mini-game "Tic-Tac-Toe" in Python. However, I am still a beginner in programming and I wanted to ask if someone could give me some tips on how to make the code more elegant and better. But please don't be too strict, because as already mentioned I am a beginner.
So the code wor... |
I'm trying to understand the DDD architecture pattern. I wrote a simple project in which I tried to use DDD arch. Here are my doubts after implementing it:
Does it make sense to use an ORM for a DDD project? Maybe I should drop the use of Base class from declarative_base?
Where should I define validators - in domain o... |
Here's my first program in C, which is not my first language.
I have been reading Modern C and I attempted this challenge on page 26. The prior pages are pretty much the only exposure I have had to C, for reference. I have a rough understanding of pointers but I have read no formal material on the subject.
#include <st... |
Looking for feedback, bugs, performance reports, and general code review of this simple file-watcher.
Basic algorithm: The MacOS version just sets the relevant paths to be watched from the CLI arguments. The Linux version watches the whole filesystem and filters out irrelevant paths.
#if !defined(__APPLE__)
#define _... |
I'm struggling a bit with a USACO silver question using python, http://usaco.org/index.php?page=viewproblem2&cpid=992.
The question provides an unsorted list of numbers (cows) and a number of edges (wormholes), each with a weight, connecting two numbers. The question ask for the maximum weight for which, each edge of t... |
The idea is to add a given 16-bit number N to each element of an array of 16-bit integers of arbitrary length, taking advantage of 64-bit integer types and instructions to perform the additions 4 at a time. The function accepts an arbitrary nonzero length. As far as I can tell there is no undefined behavior, but I woul... |
I am writing a wrapper library for network functionality in C and wanted to let the user let the user initialize a struct sockaddr_storage with a format string.
Format ist like: "proto:host:port/servicename"
Example: "tcp:localhost:8080", "udp:8.8.8.8:dns"
Possible Protocols Strings: tcp, tcp4, tcp6, udp, udp4, udp6
So... |
The PHP manual states that the regular shuffle() function isn't cryptographically secure, but that random_int() is. I thought, then, that I'd make something to leverage the latter for the former purpose. (PHP 8.2 includes Random\Engine, which includes a shuffler, but I wasn't aware of that when I started thinking about... |
I have a master .xlsx file on which other spreadsheets depend. Each week, I export a new .xlsx file (from MRP) that may or may not be the same as the master. The columns are always identical. Rows may increase or decrease. Cell values may change, usually just one (price value, column AB).
I wrote a Python program that ... |
On a project I'm working on, I have a need for a mutual-exclusion primitive behaving like std::mutex or std::recursive_mutex, except that it needs to accept locking and unlocking from different threads.
This is a very special and unique case in the software; I'm not trying to replace std::mutex in general.
But there's ... |
I was recently presented with the following problem...
You are given a collection of singly-linked lists (SLLs).
Return true if any of them share a common node (or “intersect”), or false otherwise.
Additional notes
Please don’t use recursion.
Assume the SLLs might be very large in length (in the millions).
Stop traver... |
This is the No of Island code challenge.
Please review my implementation in Haskell. I know there must be some better way of doing this.
Given an m x n 2D binary grid grid which represents a map of '1's
(land) and '0's (water), return the number of islands.
An island is surrounded by water and is formed by connecting ... |
This is a follow-up question for A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++. I am following the suggestions proposed by G. Sliepen in the answer. The techniques including passing a range to std::ranges::transform() and using std::invoke() a... |
My code below is used as a back testing tool to review a past Daily Fantasy Sports slate. This code works perfectly but when the contest size (total entrants) gets up to the 30,000 range it takes quite a long time, and I don't even attempt to review a slate that is 100,000 entrants. I would like some advice on how to s... |
I have a sample svg file from the graphics program Inkscape. My objective is to collect every third pair from a very long line of floating point numbers. That seems simple enough. The larger objective is to write out svg code with calculated parameters - because Inkscape cannot do this in a "batch" mode - only "by hand... |
I'm looking to integrate Kotlin idioms (including code style) and maybe better performance. I wonder if there's a better way to do line 17 (the str.split(' ') one).
// 0L: Empty 1L: Inactive
// Maps have been truncated
// Full map has 2 empties, 5 inactives, and 15 18-digit numbers (IDs)
val game = mutableMapOf(
"w... |
I'm gradually writing an arbitrary-precision arithmetic library for C++. I've decided it could be useful to have the default constructor produce an object of indeterminate value, rather than relying upon {} = 0, to make my code more explicit.
I'm not yet sure whether I want operations like division by zero or square ro... |
I'm piecewise reimplementing an existing iOS app. My initial go at it visually looks like this:
I'm looking for any feedback on more idiomatic ways to implement what I've done. There's a couple of questions in the code. It's a stock "Emtpy Compose App" with com.google.accompanist:accompanist-navigation-animation:0.29.... |
I wrote a little library to generate wrappers for SDL2 in C++20 with the idea to build a simple video game with it afterwards, and was looking for some feedback on the code!
The idea is not to create new classes (this will be done at a later stage and higher level), but just to wrap the SDL2 functions into functions th... |
My ASP Core web application was recently upgraded from NET6 to NET7. Almost zero problems except one, which still puzzles me.
With the "old" NET6 version, once an user log then app in (without the "remember me" flag), his/her access was granted for several hours. I never measured exactly how lasted, but I remember pret... |
About the code
Object detection YOLO v1 loss function implementation with Python + TensorFlow 2.x. It based on the Pytorch implementations below and re-implemented with TensorFlow based on my research on the paper and other resources. Added comments which part of the YOLO v1 paper corresponds to the code lines.
githu... |
I am writing a simple text adventure in python that will eventually have the capability of running other text adventures within it, but my code is all over the place and the UI is terrible. What are your recommendations for improving the UI and cleaning this up
To clarify: I will continue using print statements for the... |
There is a site with posts that have tags. The site has a search for these tags, that is, you enter words / letters separated by a space and tags are displayed for you by matches. These tags can be selected and double-clicked to disable. When you enter words in the search bar, a query is sent to the database and a resp... |
I'm new to Rust and I would like to implement a function to compare 2 collections of strings. The function should compare them as if they are unordered.
In Python, I would implement something like this:
from collections.abc import Iterator
def unordered_eq(a: Iterator[str], b: Iterator[str]):
a = sorted(a)
b =... |
Thanks to Rotem and his help with this issue, I can offer an implementation that allows to use cvtColor to convert an AVFrame YUV420P into a BGR cv::Mat. The key is to create a temporary intermediate cv::Mat where all the AVFrame data is copied in the way cvtColor expects it.
#include <cstdint>
#include <vector>
#inclu... |
I want to check if a given string is a date of the form YYYY-mm-dd, including all the steps in it, i.e. YYYY-mm-dd, YYYY-mm and YYYY.
For example, all of the following dates are valid:
2014
2014-07
2014-07-03
This is my current regex:
^\d{4}(:?-\d{1,2}(:?-\d{1,2})?)?$
Is it OK?
|
Technical task.
user visits amazon.com website
user fills out a search field with the product name and activates
search ==>
a page with search results is displayed.
user looks for the product having maximum reviews
count user extracts minimum product price (with applied discount - if
any) from the page
user assigns am... |
I have written a small class that works in extracting Snapchat usernames from common conventions of sentences, manipulating the positioning of certain characters to hopefully extract a valid username.
The script does have some partial protection for validity with its call to SnapchatUtilities.IsUsernameWellFormatted(ex... |
The purpose of this code is to evaluate simple integer expressions that make use of the C arithmetic and bitwise operators while respecting C operator precedence and parenthesis. I wrote this code with portability in mind, making no use of implementation defined, or undefined constructs to my knowledge. However there a... |
Is there a better or simplified approach to create an array which contains one object per objectid with an array of contacts that matches globalLkupRemoveContactReviewer by userid and then send each array which contains one object to the database in the form of
[
{
objectid: '222',
contacts: [
{ isdel... |
I recently discovered the atomic wait/notify mechanism in C++20 and wrote this readers-writer lock in the style of Linux kernel Seqlock. Writes have to be inside a lock/unlock, while reads are optimistic. It is very fast, but I am wondering if it's wrong in some way, e.g. could it lock up beyond hypothetical timing iss... |
I am currently making a game for myself and i have a lot of code in a function which does almost the exact same thing with some minor differences. I was wondering if there is an way to optimize this
code and still get the same output.
import pygame, os, random
def draw_game():
player = pygame.Rect(450, 350, HOOFD_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.