instruction stringlengths 71 95.1k |
|---|
Background
Our team has a utility called envmgr to set aws iam roles. The credentials are only good for 4 hours or so. As such, I have a number of scripts that call the command $(envmgr -e ENVIRONMENT -r ROLE) to refresh the credentials and avoid a time-out while in the middle of a process.
The problem is that there i... |
As an exercise, I found a basic way of updating pages without refreshing, partially mimicking the behaviour of SPAs and routing libraries such as React Router. I was not looking for something as advanced as those libraries, but I thought it was interesting to find a quick way of doing this.
The idea is that, when click... |
I'm trying to write a minimal, high performance uncomplicated ECS for a simple game in which I have a good idea of all of the Entity and Component types from the get-go.
I want to take advantage of compiler optimisations such as inlining and others, therefore I would like to avoid dynamic dispatch.
To do this, I am usi... |
I have a method that on click produces an excel file with information in it. I have been asked to pull images from the data base and add them within the excel file as well. This is how I am pulling the images:
ProductImages = new List<ProductImageAndMeta>();
var flyerBlocks = await FlyerBlockRepository... |
I was watching this Numberphile video: https://youtu.be/Wim9WJeDTHQ on multiplicative persistence (multiplying digits of a number over and over until one digit remains). I decided to take up the challenge, first of creating a program that calculates the multiplicative persistence of a given number, then reversing the p... |
FI_name
ISN
Sector
Industry
REC
INE02
PS
FS
HDB
INE03
PR
FS
ABC
INE04
PR
FS
RHC
INE05
PR
CO
ZHE
INE06
PR
FS
HSE
INE07
PR
FS
ZAK
INE08
PS
MT
HGB
INE09
PR
FS
YUJ
INE10
PR
MT
WSD
INE11
PS
FS
REC
INE12
PS
FS
HDB
INE13
PR
FS
ABC
INE14
PR
FS
RHC
INE15
PR
CO
ZHE
INE16
PR
FS
HSE
INE17
PR
F... |
Part 2/3
Part 3/3
I have this library for performing shortest path queries on dags (directed acyclic graphs). This post presents the graph data structure:
com.github.coderodde.graph.AbstractGraph.java:
package com.github.coderodde.graph;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
/**
*... |
Part 1/3
Part 3/3
I have this library for performing shortest path queries on dags (directed acyclic graphs). This post presents the shortest path algorithms and the topological sorters. Two algorithms for topologically sorting the graph nodes are compared:
com.github.coderodde.graph.impl.DFSTopologicalSorter (See thi... |
I am a beginner. I wrote a C program that calculates the first n powers of x and I don't even know if this is legit C code or strictly C++ code. Please criticize it and help me improve it.
#include <stdlib.h> //to use malloc and delete
#include <stdio.h> //to use printf
#define uint64 unsigned long long int //for simp... |
I've learned that magic numbers are bad in code. However, should the coordinates, and rotation angles of all the sprites be stored in variables? Is the convention in game development to leave those hard-coded values as arguments to set the coordinates or the angles of the transformable?
// Create a texture to hold a gr... |
The following function executes each action from the list until a predicate returns True. I have a feeling that this function can be rewritten using fold and without the do construct but I don't know how.
execUntil :: (Eq a, Monad m) => [m a] -> (a -> Bool) -> m ()
execUntil [] p = return ()
execUntil (a:as) p = do
... |
I'm writing memory manager for my toy operating system and I would like to get some feedback. There is physical memory manager, which uses bitmap, virtual memory manager which uses buddy algorithm for managing virtual space. Here is my code:
Physical_memory_manager.c
#include <stdint.h>
#include <stdbool.h>
#include <k... |
The problem statement is as follows:
I have a database of name tag data. I want to display these name tags to the screen. Each item of information on a nametag has certain rules for its display.
Here I have encoded those rules for display into a function nameTagConvertToDisplay to show what I mean. This function is jus... |
I'm making an out the door calculator for my dispensary. As it stands now the program works 100%, im planning on adding a GUI and such in the future but right now im focused on not have a god class and splitting stuff up into methods for less repetition. I want to be able to get gramPrice, eighthPrice, quarterPrice, ha... |
Batch processing steps:
When a job is posted, push it to the queue.
Get the required number of items from the queue and put it in the batch.
If a batch was processed before this, wait till BATCH_INTERVAL time has passed.
Process the batch.
Clear the batch.
Monitor the queue. Back to step 2.
batcher.js
const QUEUE_MON... |
I have written below program to count the number of static and dynamically created object of the class.
#include <iostream>
class Test
{
public:
Test()
{
stackCount++;
}
void* operator new(size_t objSize)
{
void* ptr = malloc(objSize);
heapCount++;
return ptr;
... |
I am working on the USACO problem Arithmetic Progression. Here is their problem statement:
An arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb where n=0, 1, 2, 3, ... . For this problem, a is a non-negative integer and b is a positive integer.
Write a program that finds all arithmetic progres... |
The below logic is working fine. But is there any way to optimize this logic ?
Gamer is the root level object, it will have Characters. Character will have set of Skills & a weapon
I want to update the Gamer object along with its child objects
public async Task UpdateGamerCharacterAsync(Gamer existingGamer, Gamer g... |
I have been trying for so long to code an encryption/decryption algorithm using the modulus operator. Basically my code does a basic mathematical operation on given text and key then do a modulus 255 as in 255 ASCII characters. But I was never able to successfully reverse a modulus operator. I have finally programmed s... |
I need to take sum of all the person's ages and heights.
Input Array:
[
{
"personId": 1,
"ages": [
1,
4,
5
],
"heights": [
1,
1,
2
]
},
{
"personId": 2,
"ages": [
4,
2,
2
],
"heights": [
1,
4,
2
]
},
... |
I am currently working on The Odin Project and have reached the JavaScript Part. There is a project, to create a Website that serves a a library. You can add a book and it appears on the site as a tile/panel.
I have finished the project and as far as I can see it works fine. But I feel like my JavaScript code is extrem... |
Hello beautiful people!
I have currently worked on a small script that I would of course continue to work with whenever I get a good feedback from the best code reviewer in here <3 - I have worked on a small template of monitor where I use threadpoolexeuctor to do a GET requests on multiple URL's where each URL will re... |
I made a Python voice assistant. It takes the user's voice input and there are multiple if-else statements that specify a condition and if it satisfies that condition it executes a specific function. How I can implement if-else statements in a more efficient way?
async def main():
def there_exists(terms):
... |
The rules for the puzzle are:
Each triplet has the rules of how the letters are ordered in the secret word (each letter is followed by the next letter inside the triplet array).
all the letters of the secret word are distinct.
Example input:
triplets1 = [
['t','u','p'],
['w','h','i'],
['t','s','u'],
['a','t',... |
LeetCode Link
Here is the problem statement. I came up with a code that is 36% faster than other online submissions and the memory usage is 35% less than other online submissions.
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Symbol
Value
I
1
V
5
X
10
L
50
C
100
D
... |
This is my new code for a calculator Ive been working on. I ditched the idea of multiple class files as soon as I started working on the GUI. Just looking for some feedback on if im doing something weird or wrong. Thanks for any input. The program works, but not sure if its effiecient or conventional or anything. Im pl... |
I am working with an API that delivers some data in a QStringList or basically a list of strings. The data contains keys and values but it is not a map or anything like that...just plain list.
The list has always an even number of elements where each pair are like key, value.
I need to efficiently create an object out ... |
I've been learning python for some time and I've come up with the idea to practice it a little. I created a script that removes files by their extension .html and .srt and also empty directories. It works good, but I've got a feeling that it could be improved. Can someone help me improve the code? Also I know it is not... |
I've improved my in-memory B-Tree (Link) to release a B-Tree with support for memory-mapped disk files and fixed-size allocators:
Repository: https://github.com/frozenca/BTree
Code:
#ifndef __FC_BTREE_H__
#define __FC_BTREE_H__
#include <algorithm>
#include <cassert>
#include <concepts>
#include <cstdint>
#include <fu... |
I have implemented a Binary Search Tree and would really appreciate it if someone could take time to check it and give me feedback.
I try to keep my code clear and simple.
Is it readable?
Is the API of constructors well-designed?
Did I handle the nullable fields of the tree and iterators well?
Please be as strict as po... |
I just finished the chapter about collections from the Rust book, and it recommended trying some exercises provided there, such as a Pig Latin translator.
Convert strings to pig latin. The first consonant of each word is moved to the end of the word and “ay” is added, so “first” becomes “irst-fay.” Words that start wi... |
Application: replacing enum type / description tags in modular software, allowing adding new enum values without updating one definition.
Say we have a video processing pipeline not unlike gstreamer. The main program manages the pipeline where selected modules can read, create or modify image frames. Each frame has sev... |
I came up with the following code while trying to solve the Leetcode partition list problem
Though my solution is accepted, I am not happy with a few of the additional variables which I am creating. In the code below, I would like to avoid creation of tailEnd and headEnd variables somehow.
Can you please review the cod... |
I am learning Rust from the official book, and I have solved the following recommended challenge from the end of chapter 8:
Using a hash map and vectors, create a text interface to allow a user to add employee names to a department in a company. For example, “Add Sally to Engineering” or “Add Amir to Sales.” Then let ... |
My first ever lines of Clojure and while the script seems to work as expected, I'm sure it's far from idiomatic Clojure. Thank you for any suggestions.
#!/usr/bin/env bb
; =============================================================================
; PHOTOS.CLJ
; USE: ./photos.clj --src [src-dir] --dest [dest-dir]
; ... |
For a long time I've used Python strictly to get something done even though I knew there was likely a much more "pythonic" way of accomplishing a given task. In the example below I have a table that is saved as a CSV and when I need to return an alias I use the alias function.
def alias(old,new):
frame = pd.read_cs... |
I'm implementing a JNI library that needs to dispose a few native objects after use. The main library class implements Closeable and is almost always used within try-with-resources. Even then, as the library will be used in by a larger audience within the company, I want to make a safe-guard to make it harder to introd... |
I'm trying to use this library in my haskell program to generate a source map file, but getting some performance issue. The size of the mapping file generated was about 30M bytes, and it took almost 130 secs to get it. It's much more slower than I expected, though I can not figure out what's the problem causing it. Her... |
This is an implementation of a generic Trie DS, in Swift-lang, that is using however, for the sake of a easy example, strings.
It implements two operations, insert and search. So it can insert a text, and look for substrings of that text, for example.
I'd be interested in recommendations as to how correct the code is, ... |
I'm trying to pool & recycle a number of classes, A, B and C which are all subclasses of Z. I'd like to have one class that handles all of the pools, such as
internal class Pooled {
Queue<A> AvailableA;
Queue<B> AvailableB;
Queue<C> AvailableC;
}
I'd like to save myself some redundant typing so ideally we'... |
I made this python program to find the 64 most common elements of a list stored in a text file. Since this works using binomial names of trees I decided to use the number of mentions in PubMed Central as a metric of popularity.
I am just a beginner and somewhat self-taught so I'd like to know if there are any ways of e... |
This function below return true/false. How I could possibly improve the code quality?
function uploadcontrolhasError() {
if (dialogisVisible === true) {
let uploadcontrol = $("#upImport").data("kendoUpload"),
files = uploadcontrol.getFiles();
console.log(files);
let FileLink = $... |
I made a tic tac toe game using JavaScript. I tried to focus on a logical and well structured program. Could someone give me some feedback on the structuring of the JavaScript code?
//create and manage gameboard
const GameBoard = (function () {
//represents board on website
let board = ["0", "1", "2", "3", "... |
Yesterday I wrote a serialization/deserialization for my B-Tree library.
Since the code for whole tree is too large to upload here, I'll upload only serialization/deserialization and node class definition/tree class member variable parts here.
I think my code is not broken, but I want to know how to do error checks bet... |
I have written a program in C, which does the following operations:
creates or splits Camel Case variable, method, class names.
Input format
Each line of the input file will begin with an operation (S or C) followed by a semi-colon followed by M, C, or V followed by a semi-colon followed by the words you'll need to ... |
This is my first Python project in file management.
It's a finished and passed exercise from JetBrains (Duplicate File Handler).
The main job is reading a full path to folder from argument, list files of the folder, grouping them based on same size and md5 hash (md5 required for passing the test) and then asking for de... |
(See this repository for full code.)
Now I have rolled a simple class extending JavaFX Canvas for showing terminal like, colorful console:
TextUIWindow.java:
package com.github.coderodde.ui;
import javafx.scene.canvas.Canvas;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import com.sun.javafx.tk.Fon... |
I have a use case where I want to keep a pre-compiled regex, cached, for performance reasons, but the regex pattern also needs to be updated infrequently. Instances of CachedRegexFilter class will be used by multiple threads. The actual pattern for the regex is supplied as a custom class, StringConfig, which is basical... |
{-
| Copyright 2022 Pierre Abbat
* RandomLadder
This module performs a public-key encryption operation, such as modulo
exponentiation or elliptic curve scalar multiplication, in a way that makes it
difficult for an attacker to determine the exponent or multiplier by listening
to a side channel. Rather than performing t... |
In the process of writing a compiler, I wrote this dynamic string library to help with keeping track of heap allocated strings and to have an easy way to format them.
Note:
The macros ALLOC(), CALLOC(), and REALLOC() used in the implementation are equivalent to the C stdlib functions malloc(), calloc(), and realloc(). ... |
I implemented my first algorithm in golang - the caesar cipher. Is there something i could do more efficiently? I am quite new to go and any improvement suggestions are welcome.
package main
import "fmt"
// +1 encoding, -1 decoding
func main() {
var text string
var choice int
var shift int
... |
I would like to query a REST API (which uses Bearer token authentication), handling several exceptions that might occur. Could you tell me if the following code (which I explain later in this post) is any good, or do you have any advice on how to improve it?
Calling Script
This script asks the REST API to list all the ... |
I'm new to pygame and tried to write my own Event Manager because I couldn't find a solution I was satisfied with. So I wrote my own inspired by the observer pattern:
from typing import Callable
from pygame.event import Event
EventHandler = Callable[[Event], None]
_managers = dict()
class EventManager:
def __i... |
Hi I am new here and I just completed my first working version of a pokedex app with a GUI using tkinter. I used selenium to scrape the data from pokemondb.net, and then used pandas to clean up the dataset then finished it up with a tkinter GUI. The project is still in early stages and can be improved in the front and ... |
I recently had a programming interview with a Silicon Valley tech company and wanted some different opinions on one of the problems they had me solve and how others might complete it. Essentially, given an array of objects:
const events = [
{'category': 'Bug',
'date': '26.07.22',
'resolved': false},
{'category': 'Breac... |
I have the SQL Products table migrated from MongoDb and I use ASP Core + MediatR. The filtering data comes from frontend Autocompletes where user can select multiple values (3 different ProductGroups + 2 different Suppliers for example). Wanted to ask is my implementation optimal, or did I miss something?
Below the cod... |
Preface
Please review my implementation of a job queue for linux/unix systems. This is my first time coding in C, although I have quite some experience in C++.
I know this is a moderate amount of loc, so please focus on jobq.c, jobq_server. c, manager.c, and server.c. I have uploaded the other files for context. I am ... |
Problem Statement :
Write a function called matchSquare, which accept two arrays (arr1, arr2)
Criteria:
The function should return true, if every value in the arr1, has its corresponding values squared in the second array arr2
The frequency of the values must be the same.
Ex:
matchSquare([1,2,3], [4,1,9]) //true
mat... |
I have written a program in C, which given a time in 12-hour AM/PM format, converts it to military time (24 hours).
Function Description
The timeConversion function should return a new string representing the input time in 24-hour format.
timeConversion has the following parameter(s):
string s: a time in 12 hour format... |
In a docker compose solution, there are multiple ASP.NET Core projects. Each of them provide a service. Some of them can be accessed from internet (with REST APIs), some of them are for local docker network only (with gRPC APIs), and some of them have both public REST endpoints and private gRPC endpoints.
Only one proj... |
I wrote a method that multiplies two integers. Is there a faster approach that doesn't use the * operator?
The method mult(a, b) multiplies two arbitrary integers. Is there a quicker way to multiply two numbers, without using * in java?
static int mult(int a, int b) {
if (a > b)
return recMult(a, b);
re... |
I made an app for my internal use that collects some metrics & puts them into a DB. I'd be happy if someone could comment on my code, commenting, design choices and so. I hope I did enough commenting, aside from the code quality - the app run pretty well! I apologize for only including the initial commit - it's a small... |
How would I simplify the following function to reduce repetitive code? I would like to define "arg" as an array since that is the only changing aspect of each case.
function jumpMovement(iMovement) {
switch (iMovement) {
case 0:
document.getElementById('opus-08a').contentWindow.po... |
I'm working on an app to display statistics based on user data from a third-party service's API. The authentication flow for the service's API that I wrote works, but some parts of it feel a bit awkward, so I want to make sure I'm holding Combine and SwiftUI correctly.
Some notes and specific questions:
readFromKeycha... |
I wrote my implementation to Stack array based. And I need a review for it to improve it and improve my coding skill. I also will but this implementation on my GitHub account.
One more thing: I am not sure why my stack works after I clear it. I used free which will free the allocated array from the heap memory and I th... |
I am using libtelnet to design a telnet client by sending text commands to a telnet server and receiving text responses. I am utilizing telnet-client.c. For simplicity, I made send and receive functions. The complete code is shown below:
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
#i... |
This is my second implementation of the Stack in c++. I already implemented it as an array-based here
I need a review for it to improve it and improve my coding skill. I also will but this implementation on my GitHub account
//======================================================
// Author : Omar_Hafez
// Created... |
I can't improve the performance of the following Sudoku Solver backtracking solution. I know there are 3 loops here and they probably cause slow performance but I can't find a better/more efficient way.
I tried to isolate "board" from mutation but it hasn't changed the performance. I also tried to use list comprehensio... |
I'm currently trying to find out what's the best networking architecture for MVVM applications. I couldn't find many resources and decided to go with dependency injection based architecture as per the very less reading resources that I have found.
I'm not using any 3rd party for web service testing and whatever the net... |
I have a motionManager class which uses CMMotionManager() to send rotationRate and attitude values to a publisher in the form of a MotionValueModel.
final class MotionManager: MotionManagerProtocol {
private let manager = CMMotionManager()
init() {
getMotionData()
}
let motionPubl... |
I have been writing a monitoring script where I check for whenever there is changes on a webpage. When a change has happend I want to be notified by printing out that there is a difference.
I have also written a spam filter function that could be caused due to a cache issue where a repo count can go from a old count to... |
this is my first C program. It creates a bloom filter from an array of N char arrays and k hash functions.
I'm not particularly concerned about maximum performance at this point, as I'm just starting with C. Any suggestions on making my code more idiomatic would be highly appreciated.
// Bloomfilter.c
#include <stdio.h... |
After watching Computerphile videos on WW2 cryptography and radioteletype I decided to code a translator to Baudot code. I wonder if it can be somehow improved?
def translate_to_baudot(untranslatedtext):
from textwrap import wrap
def getdic():
chars=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ ∆-:$3!\'().,9014‽5... |
This is an implementation of a mathematical vector.
I am currently working on a linear algebra project and before proceeding further with other classes (matrix, polar_vector etc.) I would like to have some code review if someone's up for that.
Currently complex components are supported but not all operations are define... |
Recently I found that the binary search (std::ranges::lower_bound and std::ranges::upper_bound) is the main bottleneck in my library.
So I wanted to improve it, one attempt was to use SIMD to replace the C++ standard library binary search. In short, the result was actually little bit slower than original binary search.... |
The code I am using is:
#!/bin/bash
pid=$(pidof "mpv")
if [[ "$pid" ]]; then
wmctrl -x -R gl.mpv
echo "{ \"command\": [\"loadfile\", \"$1\", \"append\"] }" | socat - "/tmp/mpv-socket"
echo playlist-next | socat - "/tmp/mpv-socket"
else
mpv --input-ipc-server=/tmp/mpv-socket --player-operation-mode=pseudo-gui "$1"... |
This is my homemade Polish Notation implementation in C++.
I need a review for it to improve it and improve my coding skill. I also will put this implementation on my GitHub account
//======================================================
// Author : Omar_Hafez
// Created : 28 July 2022 (Thursday) 6:10:44 AM
... |
I've recently developed two functions to functions to essentially convert a list of strings that look something like this (these strings are 101 characters long in my case):
['AGT', 'AAT']
To a numpy array:
array([[[[1],
[0],
[0],
[0]],
[[0],
[1],
[0],
[0]]... |
I'm working on a fun project where I'm trying to implement Random Forest algorithm in pure Python, i.e. without NumPy. But then I'll still be dealing with arrays all the time and so I'm writing my own Array class to use in place of NumPy's ndarray. Although I'm only focusing on 2d arrays as I don't need n-dimensional s... |
You are given an array of strings sentences, where each sentences[i]
represents a single sentence. Return the maximum number of words that appear in a single sentence.
Example
Input: sentences = ["alice and bob love leetcode", "i think so too", "this is great thanks very much"]
Output: 6
Explanation: The first sentenc... |
Here is a function that will take each text file in a directory, do the Mann-Kendall and Pettitt tests, and then write the output to a text file. Would you please suggest me improve the code to make it more robust overall?
My attempt is:
## importing required python modules/libraries
import ntpath
import glob
import nu... |
I have this XML from a SOAP call:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<SessionID xmlns="http://www.gggg.com/oog">5555555</SessionID>
<QueryResult xmlns="http://www.gggg.com/oog/Query" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instan... |
The strategy pattern is applied in the code below in the payment separation solution. Please evaluate if it is well done according to standards. I would be very grateful for suggestions.
<?php
interface PaymentMethod
{
public function processPayment(Module $module, $order_id, array $client);
public function p... |
UEFI bootloader.
It reads the file kernel.elf on the disk image, reads through the program headers, copies the LOAD segments into memory, and finally calls kmain()
The kmain() is nothing but an infinite loop because I want to get feedback on the bootloader before starting to make the kernel
Parts of the Makefile are co... |
Upon suggestion in the original question within Stack Overflow, I'm bringing my question here.
We have created a function that will convert the data into the desired format, but it has a lot of code and is difficult to understand. If a new person has seen this code means, it's very hard for them to know the functionali... |
I wrote an improvement from my previous graph class: Link
#include <algorithm>
#include <concepts>
#include <list>
#include <map>
#include <ranges>
#include <unordered_map>
#include <unordered_set>
#include <stdexcept>
#include <vector>
namespace frozenca {
template <typename T>
concept Arithmetic = std::is_arithme... |
I wrote my implementation to Queue array based. And I need a review for it to improve it and improve my coding skill. I also will put this implementation on my GitHub account.
Thanks in advance.
//======================================================
// Author : Omar_Hafez
// Created : 29 July 2022 (Friday) ... |
I am trying to understand the estimator proposed in ["Multidimensional outlier detection and robust estimation using Sn covariance"][1]. I wrote the code in a basic line-by-line form which is time-consuming as the number of observations and dimension of the variable increase. Since I am a beginner in R coding I need he... |
All help welcomed!
I posted a big chunk of code here - but feel free to review only a small section. I will use answers to improve this deployed open source software.
About the code
This code works. But can be improved in code quality. Feedback is highly welcomed!
codespell, ktlint, Android Studio validator were alread... |
A task:
You need to open the parentheses combined category and the object that belongs to it.
The combination of categories means that we have a category and its objects, for example genre (rock, pop, hip-hop) needs to be converted to genre_rock, genre_pop, genre_hip-hop. At the input and output of the code is a string... |
I have a web application that I'm writing in Go, using the Iris package. This app needs to listen to Azure Service Bus for messages, and take action when they come in. This is my first time writing Go, and I want to make sure I am using the concurrency model properly.
The requirements for the app lifecycle are fairly... |
Update
After examining the NameRulesUnicode64k.xlsm spreadsheet in excel-names, it appears that my NameIsValid() is in close agreement. When examining whether or not a single character is OK as a valid name, there are only 2 discrepancies across 65,535 characters:
Chr-Code
Char
Other Case
OK
...
NameIsValid()
... |
I need to convert the ENUM to a respective string value for which I came up with two approaches and I'm trying to see why would a second approach be better than the first one if even in terms of performance and practicality?
Both approaches work. The second requires additional work of having to create an array of struc... |
I'm trying to write a simple program to find a certain file name within a directory tree. I use up to 30 coroutines.
Is there anything wrong with this code or what needs to be improved?
import (
"fmt"
"io/ioutil"
"path/filepath"
"sync"
)
const tofind = "select-test.go"
func main() {
wg := sync.Wai... |
I wrote my implementation to Queue Linked List based. And I need a review for it to improve it and improve my coding skill. I also will put this implementation on my GitHub account.
//======================================================
// Author : Omar_Hafez
// Created : 30 July 2022 (Saturday) 8:02:31 AM
... |
I have the following code which is a model where each agent makes decisions and accumulates efficiency over time.
With the def scenario function, the idea is to create a simulation that returns the averaged cumulative_efficiency (i.e. mean_eff) of a population of agents at each time step.
Is there a more pythonic or ef... |
I have the following df
df_dict = {"week":[1,1,1,4,5],
"store":["A","B","C","A","C"],
"var": [1,1,1,1,1]}
df = pd.DataFrame(df_dict)
week store var
0 1 A 1
1 1 B 1
2 1 C 1
3 4 A 1
4 5 C 1
My goal is to sum variable A... |
I'm interested in creating a successor to the expected monad in C++. Specifically I want it to be capable of storing error which may has one of many types, and a value. I believe this is enough to be able to build execution pipelines with easy error handling.
The limitation of the simple expected is that we have to wri... |
This is yet another improvement from my graph class - Link
Now property maps are no longer parts of Graph type, they are just stored in a member variable.
This seems much more reasonable for me! It is wise to combine dynamic polymorphism and static polymorphism appropriately.
#include "GraphProperties.h"
#include <memo... |
I know very little about databases and even less about how to optimize them, but I have a problem which calls for a database so here I am...
I created a sqlite3 database using the following script:
sqlite3 my.db <<EOF
create table bpe_lookup (id integer primary key, bpe text);
create unique index idx_id on bpe_lookup(i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.