instruction stringlengths 71 95.1k |
|---|
This is a percolation of ideas which originated this SO question:
Compound pointer traits class with method generalizing make_shared and make_unique?
The std::pointer_traits class offers the following traits, basically:
Types: pointer, element_type, difference_type, and rebind (given a pointer-like type for pointing to... |
I have Products table which looks like this:
I have some data in this table and I want to filter it depending on this columns (Filtering with columns type of string isn't problem). For this I have the code (in ASP.NET Core Web API Project) shown below. I know it's not a good approach. I have another table which has mo... |
I have a method that generates the S3 key prefix according to the provided args. However, my gut feeling is that this method is not as elegant as it should be, maybe I just don't have an eye for it. Care to instruct me on how to make this little bit less sketchy?
private String generateFullQualifiedS3KeyPrefix(DataStr... |
There is a question in a contest but it doesn't have any answer. I solve it but I get time limit for most of test case. Is it possible to improve my code or give a better approach?
Question
There is a directed graph with vertices \$1,...,n\$ and each vertex has a label which is \$a_i\$ (a number not character). we star... |
To get points which lie on the border of a rectangle, I use 4 for loops. At first I thought about creating Rectangle and using PathItterator, but it confused me very much. Is there a better way than mine?
int r = 5;
int x = 0;
int y = 0;
int length = r * 2 + 1;
for (int i = 0; i < length; i++) {
System.out.print(St... |
I'm a beginner to Haskell (intermediate in web-dev stuff and JavaScript) and I'm not really sure what I could do better for Homework 1 of CIS194 that I'm taking online.
The problem statement is as follows (shortened):
Validate a credit card number by the following steps:
Double the value of every second digit from th... |
Inspired by the talk of Herb Sutter in CppCon2016, I decided to make a doubly linked list using templates, smart pointers, and raw pointers (for back-pointers, having a cycle of std::unique_ptrs would be a bug).
The following proof-of-concept implementation compiles and works properly.
I would love to hear your suggest... |
I wanted to create a simple function that can read and return the HTML content from a specified URL. This is what reading here and there lead me to:
from socket import timeout
from urllib.request import Request, urlopen
from urllib.error import URLError, HTTPError
def get_html_content(url, max_attempt = 3):
req = ... |
As a part of a challenge, I was asked to write a function to determine if there was repetition in a string (if no repetition, output is 1), and if a substring is repeated throughout the string (for example if the string is "abcabc," "abc" is repeated twice 2, if the string is "bcabcabc," the repetition is 0 since we st... |
I'm looking for the most simple and efficient way to track the number of string elements in a container.
I'm currently using std::vector but I wonder if there's a better container which is more suitable for my purpose.
My Code :
#include <iostream>
#include <string>
#include <vector>
class Table
{
public:
void ins... |
I wrote this code because I was often annoyed that I couldn't get the parent object. This class allows you to traverse the parent-child relationship between objects, in both directions. It also preserves prototypes.
For example:
let myTree = new Tree({a:{b:{k:2}}});
myTree.a.b; // { k: 2 }
myTre... |
I solved the maze backtracking question using a stack however could not find any other solution like that anywhere (to validate my solution is actually a valid one).
The problem statement is as follows -
Imagine a robot sitting on the upper left corner of grid with r rows
and c columns. The robot can only move righ... |
I am participating in a challenge and one of the challenges was to write a script to sort a list of software versions (ex: 1.0, 1.3.2, 12, 1.3.0). Here is the my solution:
def answer(l):
return sorted(l, key=lambda s: [int(i) for i in s.split('.')])
print(answer(eval(raw_input())))
In this code, I am essentially ... |
In my game you can earn either a bronze, silver or gold medal. There is 4 difficulties which you can earn a medal on.
I want to display a medal depending on the lowest common medal earnt if that makes sense.
So if the user has bronze in 3 and gold in the other, it will display bronze.
Gold in 3 of them but no medal in... |
I have a method that is responsible for receiving an object and perform the information saved with Entity Framwork, using the Repository pattern. The issue is that this object is, basically, a DTO. The information contained in this object must be assigned to the models managed by the data layer, which is a bit confusin... |
I'm looking for the most simple and efficient way to track the number of string elements in a container.
Previously, I used std::vector but I tried changing the container to std::unordered_map since I hear that it can be easier and more performant for my use.
My Code :
#include <iostream>
#include <string>
#include <un... |
I made a text based board game that takes inspiration from DnD/Eldritch Horror (another board game)/Lovecraftian literature. Below you'll see a small excerpt that handles the bulk of the game processes, and there were several things I feel that could have been done better.
One thing I am not particularly proud of and ... |
As you might know, Python's tarfile does not have the ability to append to the files that compressed with e.g. gz or bz2. I tried to implement this functionality which works fine but operates slowly. The following function accepts a string or bytes object and appends it as a file to an existing tarfile. I'm not sure if... |
I am learning c++ and read why we can't use realloc() in std::vector, but i think we can use realloc() for pods, so here is my attempt to write std::vector like class template specialized for PODs
#include <malloc.h>
#include <stdexcept>
#include <type_traits>
namespace gupta {
namespace detail {
namespace podvector {... |
I have some code that produces a similarity matrix. However, despite feeling happy with the output, I'm not convinced that my code is the most efficient or the most pleasing on the eye.
I'm looking to make it more efficient and tidier, as well as open to advice on what could be implemented to make the end product bette... |
I have this Python code that implements a rectangular numerical integration. It evaluates the (K-1)-dimensional integral for arbitrary integer \$K \geq 1\$
$$\int_{u_K = 0}^{\gamma}\int_{u_{K-1} = 0}^{\gamma-u_K}\cdots\int_{u_2}^{\gamma-u_K-\cdots-u_3}F_U(\gamma-\sum_{k=2}^Ku_k)f_U(u_2)\cdots f_U(u_K)\,du_2\cdots du_K$... |
This code is extremely slow and ideally I would appreciate someone walking me through getting this going on the GPU, but if nobody has time for that which is understandable, any and all optimisations would be most welcome!
Private Sub Picture(source As Image, picturebox As PictureBox)
Dim r As Double
Dim g As D... |
This is a question from the book "Cracking the Coding Interview".
Implement an algorithm to determine if a string has all unique
characters What if you can not use additional data structures?
I can use std::map but in interview they check logic. Suggest me some improvement for optimization.
#include <iostream>
#inc... |
On my application, I have a JavaScript cycle that updates tag contents on my page regularly:
<script type="text/javascript">
var players = [];
players.push($('#p0'));
players.push($('#p1'));
players.push($('#p2'));
players.push($('#p3'));
i=0;
/*
* cycle through the players.
*/
... |
I created a generator function to iterate through all possible dice rolls, and then applied it the ability score generating methods in Pathfinder RPG. (Obviously, there are more efficient ways to approach probability outcome analysis from a number theoretic perspective, but this allows generic and quick analysis withou... |
this is a follow up of:Text based game “Hunt the Wumpus” Version 2
this code was used as a base to turn this game into a gui game with fltk: Hunt the Wumpus GUI (FLTK)
I took the suggestions made there and corrected the code. I think now it got a lot more simple.
Please let me know if you still find something smelly i... |
The LAMBCHOP doomsday device takes up much of the interior of Commander Lambda's space station, and as a result
the prison blocks have an unusual layout. They are stacked in a triangular shape, and the bunny prisoners are given
numerical IDs starting from the corner, as follows:
| 7
| 4 8
| 2 5 9
| 1 3 6 10
Each cell... |
I created a Student Management System based on these directions:
Ask the user how many new students will be added to the database
The user should be prompted to enter the name and the year for each student
The student should have a 5-digit unique ID with the first number being their grade level
A student can enroll in... |
Problem Statement:
The Christmas tree is comprised of the following Parts Stand Each Part
is further comprised of Branches. Branches are comprised of Leaves.
How the tree appears as a function of days should be understood. Basis
that print the tree as it appears on the given day. Below are the
rules that govern ... |
I made a simple dungeon generator in C# using MonoGame that works by placing rooms in a grid and connecting them via "tunnels". I would like feedback on how this could be improved in terms of efficiency and code style. Also, please ignore the Render() function in DungeonGenerator.cs as it is only temporary.
Here is one... |
Given a graph and a starting vertex print the value of each vertex in a breadth first order.
Let's code out a general BFS algorithm printing each vertex's value in a BFS order. We are given a graph in the form of an adjacency list, as well as a starting vertex.
To analyze the complexity of a graph, we need to consider ... |
Merge two sorted lists
# Input: lst1 {List}
# Input: lst2 {List}
# Output: {List}
#
# Example: merge([1, 4, 7], [2, 3, 6, 9]) => [1, 2, 3, 4, 6, 7, 9]
#
def merge(items1, items2):
# merge 2 list
# divide and conquer
# combine - step2
("\n"
" while left_index is not the length of left_arr... |
I came across problem 54 on projecteuler.net and decided to give it a go using ReactJS. I have had Angular experience prior to this. I wrote a couple of fully tested components. I think that they only have one purpose each, but they're still very big. I did my best code-wise because it's also a project where I want to ... |
I'm pretty new to C, started learning it less than a month ago, the only language I had previous experience was Javascript.
Anyways, I wrote a library for dealing with CLI flags. It's not a serious project by any means, I wrote it for practice and fun.
It's composed of a source file and a header file (with declarations... |
I'm a programming newbie. In fact, this is my second code ever (after Hello World). I did a lot of reading actually, here on Stack Overflow, and other websites. I would like to know if there's a way to further improve this code.
#include <iostream>
#include <string>
using std::cout; using std::cin;
int main()
{
cout <... |
I've written a Vim function that formats the file using shfmt. I'd like to know if there is a way I can improve this script.
I am bothered by the fact that I can't think of a way to do this without editing the file in the subprocess and reloading the file. Is there a way to do the equivalent of %!shfmt -options?
if exi... |
I'm trying to have a custom WPF control whose content is defined in XAML but avoiding the use of a UserControl. This is because a UserControl makes it impossible to add x:Name to its content: https://stackoverflow.com/questions/751325/how-to-create-a-wpf-usercontrol-with-named-content/3413382
My files are laid out like... |
I've created a service that connects to Dropbox and makes it possible to download and upload files, create and list folders and remove file or folder.
Full code is available on GitHub: https://github.com/MajewskiKrzysztof/spring-boot-dropbox
DropboxConfiguration
@Configuration
class DropboxConfiguration {
@Value("... |
I have been starting to learn MVVM to give my WPF projects better structure.
I have to sample classes, DeviceModel and DeviceViewModel. Currently it is set up so that the model is exposed as a property within the view model. The model can then be bound to directly in the view.
public DeviceModel Device
{
get { retu... |
This is my first nontrivial multi-threaded program. It recursively searches through a tree (haystack) to find the leaf where needle = true. It implements a thread pool and allows threads to exit early when another thread finds the answer.
It's worth noting that when using more than the main thread the program runs ~30 ... |
I recently finished writing an HoloLens proof-of-concept program. It involves generating a user interface based on a connection with an OPC server. OPC involves industrial PLCs, one or more PLCs send their data to an OPC server, and the OPC-client connects and process all the information in the form of JSON.
An example... |
What can be simplified, altered, or implemented differently? I would like to know if there's a way to further improve this code.
#ifndef _DEQUE_H_
#define _DEQUE_H_
//-------------------------------------------------------------------------
template <typename Type>
class Deque
{
private:
struct Node
{
T... |
I’m writing a small HTTP server (just for fun and education). One important part is the response dispatcher. Responses for each socket should be sent in the order the requests were received. The idea is:
There’s an asynchronous connection manager that registers the request (and get id) and sends it to some request han... |
The tweepy.models.Status class creates a 'tweet' object, it has attribute .created_at which is the posting time of the tweet in the form of Python datetime object.
Here is the case, I have a function time_distribution(tweets, **kwargs) which calculates the distribution of the tweets by time. The function is at the end... |
This is a question from the book "Cracking the Coding Interview".
Write code to reverse a C-Style String (C-String means that “abcd” is
represented as five characters, including the null character )
Please review this code.
#include <iostream>
void inPlaceReverseString(char str[], int size)
{
int j = size - ... |
I started self-learning Bash scripting yesterday, and I finished my first successful "advance" script.
Goal
To create an interactive step-by-step script to that allowed customizing various parts of the process of creating permanent swapfiles. I based my idea off of Ask Ubuntu Answer's #1 and #2.
Background
While creati... |
This is my first algorithm in C++ ever to check if two strings are permutations of each other. Please provide guidance on correctness of algorithm + ways to improve + thoughts on my use of the language itself.
The idea is two create two dictionaries which count the number of occurrences of each character using two for ... |
I am going in a circle over and over trying to write a "supermarket" application using OOP.
The app should be useful for the employees of a supermarket. The app reads data from a CSV file which looks like this:
name,amount
soap,4
rice,5
bread,10
The supermarket has cashiers and managers. Cashiers should only be able t... |
I am preparing for an interview, and here's a popular problem on the dynamic programming. And I want to see if there's any feedback or code review for my solution at dynamic programming question.
# Problem: Coin Sum
#
# Given an array of coins and a target total, return how many
# unique ways there are to use the c... |
Problem: Write a function that takes a positive integer and returns the next smaller positive integer containing the same digits.
My solution:
def next_smaller(n):
import itertools
x = list(str(n)) #list of digits
#permutates and joins digits
x = [int(''.join(i)) for i in list(itertools.permutations(x))... |
My directory folderMarket has lots of files with the same name but are tagged with a date string at the end. The date tag can be formatted differently, e.g. "2018-07-25" or "25Jul18". My helper function is tasked with extracting a path list matching each found file name against filename_list. is there a better way to... |
I made a function that makes font sizes in <div>s as big as possible without overflowing. It takes a long time to run. How do I optimize this?
$(document).ready(() => {
$('.text-fit').each((index, element) => {
let currentElement = $(element);
let fontSize = 999;
currentElement.wrapInner("<div class='wrap... |
I'm trying to set up an algorithm in python for getting all sets from a set (DataSet1) less any instances of data in a second set (DataSet2).
Objective:
DataSet1: DataSet2:
A B C A B C D
1 6 5 1 1 4 4 3 1
2 4 4 3 2 4 4 3 1
3 4 4 3 3 6 5 3 1
4 4 4 3 4 5 3 1 1
5 ... |
I'm trying to beat the native Double.TryParse for performance in parsing large multi-million row (simple) CSV files as much as possible. I do not have to support exponential notation, thousand separators, Inf, -Inf, NaN, or anything exotic. Just millions of "0.##" format doubles.
Here's my best attempt, which is ~350%... |
Have the function VowelSquare(strArr) take the strArr parameter being
passed which will be a 2D matrix of some arbitrary size filled with
letters from the alphabet, and determine if a 2x2 square composed
entirely of vowels exists in the matrix. For example: strArr is
{{"a","b","c","d"},{"e","i","k","r"}, {"o",... |
I wrote a simple sitemap.xml checker using asyncio and aiohttp. I followed the documentation demonstrating the producer/consumer pattern. However, I noticed that as the URLs scale larger, it seems to get slower in performance. Is there something I'm doing wrong? Can I improve request speed?
Use case:
When check() is gi... |
I'm fairly new to d3 and am wanting to create a visualization that will allow a user to check whether or not a device will be in range of a bluetooth speaker.
I was able to hack together most of what I want, but am not sure if I'm following d3 best practices. This will be eventually integrated with React. Any feedback... |
I am a novice programmer and am currently learning Python programming by myself through a book. I stumbled upon a question in a chapter and it took me 2 days to figure out a solution for it. Although, it may not be an efficient code for the problem, I would be grateful if you guys could review it. Just to let everyone ... |
I have a need to update thousands of database records at a time. I am using a loop to generate the necessary PreparedStatement updates, but am hoping for a more efficient method.
Normally, I would try to use a batch operation, but since the number of fields I need to update for each record differs, I need a new Prepare... |
I'm currently working on an approval system right now using PHP (Codeigniter) and I have this method of getting all the requests according to your department group and position depth.
The checking of the requests is based upon the user's position depth. 6 being the lowest and 1 being the highest. So basically there wil... |
I have made some code in c#. I am currently developing a Gameserver so I have a function to update fields in the database. I also have a function to update the player-cash, but its like almost the same code. So my question is, do you guys have an idea to put this into one function?
/// <summary>
/// This functio... |
Aim: To improve the speed of the following code. Current timing is about 80~ hours :0
Purpose: The code imports a dataset which contains 1.9 million rows and two columns. One of these columns contain text posts of var length. I then loop through each of these rows and query the post against an imported function that r... |
I have a real-world problem involving finding the best known term from a string containing sets of terms. We have Term objects that are comparable in that they have a method a_term.is_better_than(other_term). This method is Boolean -- if it returns False, then a_term may be as good as other_term, but isn't better.
Usin... |
Please critique this very, very basic routine which returns the length of a given char buffer or "string."
strlen: ; NOTE: RDI IS THE DEFAULT SRC FOR SCASB
push rdi
push rcx
xor rcx, rcx
mov rcx, -1
xor al, al
cld
repne scasb
neg rcx
sub rcx, 1
mov rax, rcx
pop r... |
The idiomatic way of reading lines from a file doesn't work for my purposes because the files I'm dealing with might have lines that are escaped. I came up with the below (which seems to meet my needs) and am wondering if anyone has ideas on how I can improve things:
import java.io.FileInputStream;
import java.io.FileN... |
I've made a simple dirbuster. (I wanted to play with threading.)
The program makes requests to fuzz for files and/or directories on a site.
Featuring
fuzzing for response codes
fuzzing for files
threading
You can critique any and all.
Troubling points
The way it handles threading
I think I'm over engineering the arg... |
I have an assignment to create a GUI with a keyboard and text area. Conceptually, the user would type on the physical keyboard and the respective key would change background on screen to reflect that key press. Pressing the onscreen keys yields no behaviour so I don't need to implement keyTyped(...) (I think).
For brev... |
I wonder if it's possible to optimize this code in CUDA. Could I get any hints how to? Equivalent algorithm runs faster in Matlab for me, but there I'm doing matrix operations.
Compution
I'm not asking how to change computation or optimize math operations. But nonetheless I will describe goal of this kernel.
Basically ... |
This is a question from the book "Cracking the Coding Interview".
Design an algorithm and write code to remove the duplicate characters
in a string without using any additional buffer NOTE: One or two
additional variables are fine An extra copy of the array is not
This is not the efficient code, but I want to pre... |
Any and all comments are welcome in this review.
Problem
I've been doing a lot with numerical integration methods recently and have mostly been programming in Python. But...speedups! And FPGAs are cool! Thusly, I'm attempting to implement the trapezoidal integration method in Verilog. (I have never programmed in Verilo... |
Problem Statement
A Chakravyuha is a wheel-like formation. Pictorially it is depicted as
below
A Chakravyuha has a very well-defined co-ordinate system. Each point
on the co-ordinate system is manned by a certain unit of the army. The
Commander-In-Chief is always located at the center of the army to
better c... |
I have a list of values which are parsed in other place and are populated in the List<string>compareValues list.
There is also a value with which I need to compare a list of compareValues which can be decimal (2.50), int (10), Date (31/07/2018 or 7-31-2018 etc) or a string.
For the comparison operators, I have an enum ... |
I'm asking myself if there's any better/shorter way of getting a module entry by its name from an external process.
This is the code I have so far:
MODULEENTRY32 GetModule(const char* ModuleName) {
HANDLE Module = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
MODULEENTRY32 Entry;
Entry.dwSize = sizeof(... |
I was asked to perform the following tasks at one of the technical interviews. I did the BST implementation in python. I think the solution passed all of the solution. I broke down the tasks in the following bulletin:
# 1) initilize the binary Search tree
# 2) Implement the "put" and "contains" methods with helper fu... |
I was asked to solve a problem for \$\binom{n}{k}\$. I did the following implementation and am wondering if there's any feedback.
Input:
n = Integer
k = Integer
Output:
result = Array of arrays of integers
Constraints:
Time: \$O(\binom{n}{k})\$
Space: \$O(\binom{n}{k})\$
The order of the output array DOES NOT MATTER.
n... |
Given an integer, sort the digits in ascending order and return the
new integer.
Ignore leading zeros.
Parameters:
Input: num {Integer}
Output: {Integer}
Constraints:
Do not convert the integer into a string or other data type.
Time: O(N) where N is the number of digits.
Space: O(1)
Examples:
8970 --> 789
324... |
So after getting a very thorough review and feedback from indi in my previous attempt, SDL/C++ High-Low Guessing Game, I decided to go through the game and fix as many mistakes as I could. But going through the feedback also just opened up even more questions.
Things I was unable to do
Get rid of all global variables.... |
If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit.
Example one:
Input: [7,1,5,3,6,4]
Output: 5
Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5. Not 7-1 = 6, as selling price... |
I've just finished the first iteration of my new project. It's the first time I publish Python code and I would like to know what you think about the structure of the project, the API, testing, the documentation and obviously the implementation.
The goal of this library is to offer a flexible tool to perform generative... |
I have this item (an item is an object linked to a xml view), to build it I need 2 things, get labels from codes, and get text from the strings.xml android file.
please ignore the long to int and int to long convertion, for some reason the database value where randomly set to long and int but they could all be int,
I w... |
In a party everyone is in couple except one. People who are in couple
have same numbers. Find out the person who is not in couple.
Input:
The first line contains an integer \$T\$ denoting the total
number of test cases. In each test cases, the first line contains an
integer \$N\$ denoting the size of array. The... |
I am building an application that is becoming some kind of social media platform. I need to work a lot with the entities ID's in the HTML and Javascript for the purpose of AJAX calls. However, for security reasons I don't want the original ID's exposed.
Instead of encrypting an ID every time it is displayed or being se... |
An attempt with regular expression to do a foolproof validation of an IV4 or Hostname:port Number.
Example texts that can be validated for any of the following:
www.google.com:8080
127.0.0.1:8000
localhost:65535
codereview.stackexchange.com:9000
www.n-plus-t.com:4000
30my_domain.test-ng.com:754
((?:(?:25[0-5]|2[0-4... |
First time posting in Code Review! I have started learning front-end development to complement my UI design skillset and am starting with CSS Grid and bootstrap.
Have a look at the snippets. I think the 2 work quite well, using CSS Grid for layout and the Bootstrap library for things like buttons, forms and navs etc.
C... |
Kindly provide your review comments:
//SmartPtr.h
class RefCount {
public:
void AddRef() {
++(this->_count);
}
int Release() {
return --(this->_count);
}
private:
int _count;
};
template <class T>
class SmartPtr {
public:
// constructor
SmartPtr();
SmartPtr(T* iObject)... |
In my ASP.NET MVC application there are occasions where I need to generate an absolute URI, such as when sending an email confirmation link to a user. The most straightforward approach is to use UrlHelper.Action() with the protocol parameter, and this has worked well for me.
However, now my server is behind a reverse p... |
I have a Calculation class. It is persisted in the DB and users can modify it.
The aim of the CompareWith function is to display to the users which parameters have been changed.
A good part of the function is just the same code duplicated. I have been thinking about a way to abstract it out in a function, but have not ... |
I have a big file, which contains column names in the first row. The data is about 20GB and consists of 10s of millions of rows. Every other row contains data which I would like to append to other files depending on the distinct entries in a particular column (depending on index). When the program encounters a new dist... |
I'm new to programming and this is one of my first programs. I had no idea what I was doing so most of this program was made from bad bug-fixing that barely managed to fix the bugs. I'm sure that there are many things that I did wrong or very inefficiently. Please tell me what I did wrong and how I can improve this pro... |
Task
control how much coroutines are running simultaneously with ability to stop the process from inside.
Use case
when scraping websites you want to control how much memory program consumes and how much load on target it produces.
Usage
create an instance
call attach_coroutines_generator to attach some generator whic... |
I have written an Angular Directive that disables a button after it has been clicked, to prevent double posting / saving of data. This works fine in most of our use cases. However, in some situation we want to re-enable the button. For example: the button-click triggers a form submit, but the server-side validation fai... |
This is legacy, so I'm not really looking for improvements on architectural approach.
Here's what the method does:
Extracts filename from a string containing full file path (passed in as parameter)
Checks to see if the filename extracted is not null or empty or just white spaces
If check in step 2 passes, then it uses... |
I was doing a recursion problem called power set, and would like to get code review. Here's the problem.
# Power Set: Given a set S, return the powerset P(S), which is
# a set of all subsets of S.
#
# Input: A String
# Output: An Array of String representing the power set of the input
#
# Example: S... |
I have been working with some matrix functions and need the determinant. I have looked at several examples, but they all seem to use a hard coded size for the matrix, or calculate for a matrix of int, etc.
My data is stored in a vector<vector<double>> and can be of any size. This is a typical square matrix of a matrix ... |
I had to do a CLI script that does something, I also had to add a validation that checks if it runs inside the Docker. After some research I found a solution that people check some processes via cat /proc/self/cgroup and then grep to search for a docker phrase within.
So I ended-up with this method. It works pretty wel... |
I'm new to Python but I've coded in other languages mainly for hardware. I made Pong in Python using turtle but it's a little glitchy. I was wondering if any of you guys could check it out and give advice. If you have any advice on how to improve collision detection let me know please.
import os
import math
import rand... |
I completed this challenge Search and Replace and passed the tests:
Perform a search and replace on the sentence using the arguments provided and return the new sentence.
First argument is the sentence to perform the search and replace on.
Second argument is the word that you will be replacing (before).
Third argument... |
I've been roughing out a proof of concept enabling admin staff to flag submitted applications with issues as needed. We have many forms some of which are nested. So we end up with these big hashes to validate. Primarily we have issues with uploaded images (too blurry, too dark etc) but it could be any field.
So admin m... |
I'm clearing all the controls on a windows form with the following
form.Controls.Cast<dynamic>().ToList().ForEach(c =>
{
switch (c)
{
case CheckBox t when c is CheckBox:
c.Checked = false;
break;
case System.Windows.Forms.ComboBox t when c is System.Windows.Fo... |
I have this regex:
(\d?)[A-Za-z](?=(\d?)(.*))(?=(.* ){5})
It would be used by me for Chess FEN strings.
I wonder if regex [A-Za-z] is faster than [RNBQKrnbqk]? I only need to check the given letters (but no other letters will appear).
My thoughts are:
[A-Za-z] - the regex engine can match if a char is 65 <= c <= 90 o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.