instruction stringlengths 71 95.1k |
|---|
This is a follow-up question for Three dimensional data structure in C++. I am trying to implement multi-dimensional image data structure with variadic template functions. For example, image.at(4, 3) is to access the element at location x = 4 and y = 3 in two dimensional case. In three dimensional case, image.at(4, 3, ... |
I'm a relative bash novice but have found it along with jq a great way to manipulate json scraped from various sources. I couldn't find any ready-made scripts to convert arbitrarily deep json to bash arrays, so wrote my own.
My jq script kept in a separate file looks like this:
def recursive_function(key; val): val |
... |
I have this stupid code block below to save multiple files in Python. It is kind of repetitive (but it works). I was wondering how to improve it, notably:
Is it worth it to write a function for two lines of code ?
Is it possible to get the generic object name so that i don't have to specify it in the 'open' ? Are there... |
Part 1:
The task involves analyzing an environmental report from an oasis using the
Oasis And Sand Instability Sensor (OASIS). The report consists of multiple
histories, each containing a sequence of values over time. The goal is to
predict the next value in each history by creating a sequence of differences at
each st... |
I'm currently learning C, and decided to practice what I've been working on with a project, namely implementing Conway's Game of Life as a terminal visualization. This is my first project in C.
The result:
and my code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h... |
I am exploring functional programming design with C++. The code below uses a struct passed to ranges::fold_left for processing. The final result is returned in the struct.
**Updated to remove a toy version of code since full code was requested and supplied
Is this an appropriate functional programming design? Specifica... |
I was looking at this question on SO, because I needed something similar. There are eight answers to it, and I wasn't satisfied with any of them - so I've written my own solution (please see below). It's in C++, so I decided not to add the ninth answer to the C-oriented question.
The solution tries to use the multibyte... |
Wrote a slot machine for a larger casino TUI project I'm creating. Would like some general feedback, along with some specific things:
Coloring: Currently I have three loops that are almost identical, only differing in the index where they stop. Is there an easier way to do this?
Separation: Did my best to separate spe... |
I'm using React and Tailwind to generate cards like the example below. I was hoping to get feedback on the CSS rules I used, the order of the Tailwind classnames, and the HTML structure. I'm using flex in several places because I'm used to it, but isn't there a better alternative "best practices"-wise?
Example card, Me... |
I want to set up a Python class so that it can be constructed with one set of parameters or another. I'm trying to mimic C++ function templates. I tried alternate constructors. In the actual code I'm working on I have subclasses that are also going to have alternate argument sets. Alternate constructors got real messy.... |
I'm currently learning Go. To enhance my understanding of Go goroutine, I write a parallelized version of classic merge sort where I try to split the workload into parallel goroutines.
Implementation
package sorting
import (
"cmp"
)
const degradeThreshold int = 8
func ParallelMergesort[T cmp.Ordered](input []T) ... |
Source Code
I've attempted to create a simple logging library in cpp. My goal was to make it lightweight to incorporate and easy to add to the codebase.
/**
* @file herrlog.hh
* @author Saphereye
* @brief Header file only logging library
* @version 0.5
* @date 2023-12-30
*
* @copyright Copyright (c) 2023
*/
#p... |
I needed a very space-efficient structure to store an array for which elements are unsigned integers with an upper bound known at runtime.
I'm not an expert in pointer arithmetic, so I'm not sure if what I did is the best way to achieve this.
#pragma once
#include <cstdint>
#include <stdexcept>
#include <cmath>
names... |
Part 1:
The task involves initializing the Lava Production Facility using an
initialization sequence. The sequence consists of steps, each requiring the
application of the Holiday ASCII String Helper algorithm (HASH). The HASH
algorithm involves turning a string into a single number in the range 0 to 255.
The sum of th... |
I have been learning Python for 1.5 months now. I am learning in my free time between jobs and other life commitments so my progress may be slow or it may take time for me to reply but I am interested in anyone's opinion and review about my code in order to get better, faster, and get some focus about the mistakes I so... |
I have been learning python for 1.5 month now I am learning in my free time between job and other life commitments so my progress may be slow. It may take time for me to reply but I am interested in opinions and reviews on my code in order to get better faster and identify any mistakes I have made.
I would appreciate i... |
Rails 7.1.2
I have a form to create a new Employer that exists on the Employers#index view
# app/views/employers/index.html.erb
<div class="p-3">
<h1 class="text-2xl">Add an Employer</h1>
<%= form_with scope: @employer, url: employers_path, method: :post, data: { controller: "reset-form", action: "turbo:submit-end... |
I have written a simple app that generates a menu in the form of a list of recipes.
It furthermore generates a shopping list, given a menu, consisting of the (unique) ingredients in the recipes that make up the menu.
A database provides a list of all possible recipes and the related ingredients. Here is its structure:
... |
This C code does DBSCAN - Density-based spatial clustering of applications with noise. It's a cluster algorithm for turining unsupervised (no labels) data to become supervised (labels e.g class number) data. And it's also fast. The drawback with DBSCAN is that it consumes a lot of memory, but its speed is excellent!
So... |
This is a follow-up question for Multi-dimensional Image Data Structure with Variadic Template Functions in C++. Considering the suggestion from G. Sliepen:
Make everything work for more than 5 dimensions
I can see why you stopped at 5 dimensions if you still have to manually write the code for each number of dimensio... |
I was wondering if it would be possible to create a C# like syntax for dependency injection. My device is running constantly and acting more or less like a service. I came up with the following. My question, is it a good idea to use this, or something along the lines of this?
#include <iostream>
#include <memory>
#incl... |
I was practicing question 1 of the 2020 british informatics olympiad past paper:
The Roman look-and-say description of a string (of Is, Vs, Xs, Ls, Cs, Ds and Ms) is made by taking each
block of adjacent identical letters and replacing it with the number of occurrences of that letter, given in
Roman numerals (*), foll... |
I am trying to write a python function to convert an array of strings into an array of datetime objects where string can be in one of two formats, and would like to know how the following code can be optimized:
import datetime
def con(data) -> list:
op = []
for i in data:
if len(i) <= 8:
t... |
Suppose we have a sequence of sequences <1, 2> <3, 4>. There, we have two groups: <1, 2> and <3, 4>. The idea is to permute <1, 2>, and for each such permutation permute the <3, 4>. So all possible permutations are:
<1, 2> <3, 4>
<1, 2> <4, 3>
<2, 1> <3, 4>
<2, 1> <4, 3>
Also, my algorithm can handle both null elemen... |
Problem Statement
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.
Basically, the deletion can be divided into two stages:
Search for a node to remove.
If the node is found, delete the node.
Here is my soluti... |
This is a React icon component, with a few Tailwind classes.
This icon component looks as follows in the UI. The name LongIcon is to differentiate with smaller, fully round icons that are used elsewhere.
Normal:
Hovered:
I'm using flex to center the icon SVG inside the green background.
import Image from 'next/image'... |
Here is a simple Learner practice piece of Code, which supposses to comply and give solutions to a Quadrant Equity problem (requires to give it values of a, b and c for a Quadrant function). Please any tips and Tricks highly welcome, and suggestions of Improving the code. Thanks.
#include <iostream>
#include <math.h>
... |
Description:
The task involves processing a set of workflows, each comprising rules. These rules define conditions based on part ratings and dictate the destination workflow if the conditions are satisfied. The objective is to compute the total rating of the parts that are eventually accepted after traversing the workf... |
For fun I decided to try to emulate lambda functions in plain old C. It turns out it can be easily done with a bit of macro abuse.
CLambda struct stores function pointer to the function and has its own "stack" for capturing local variables. Function signature is erased in the process and there is no type checking when ... |
I've made a little header-only library for handling user input for console applications, I'd really appreciate it if you guys took a short look at it and told me what you think. The goal of the library is to provide a simple and quick way of setting up programs with a usable CL interface.
My repository (including a bas... |
There's a problem on hackerrank called fraudulent activity notifications: given an array of integers and a value k, I'm supposed to increment a counter if the median of the numbers up until k , multiplied by 2 is greater than or equal to the current value being read at k + 1.
So for instance:
given an array: [10, 20, ... |
I was just wanting a code review on this image slider I made. I don't have anyone else to give me their opinion on the code I write outside of work, so I'm asking here.
okay so i had made an image slider and now i want to give an automatic option to it too. have any one any idea? feel free to tell me your answers.
than... |
I developed an application that stores large files. Those files are stored in plain text. Now the project owner wants those files be encrypted on storage, he wants confidentiality, integrity, and authenticity.
The application is written in C# using .NET Framework 4.8. There are no authenticated encryption stream cypher... |
I've developed an image optimization service in Node.js, leveraging the Sharp library for image processing. The service is designed to handle various image formats, offering resizing and format conversion features.
I'm looking for feedback on the overall structure, performance optimization, and best practices in my imp... |
Below is a piece of template code which allows for adding a Tag to structure or class types.
#include <type_traits>
#include <concepts>
//Source: https://stackoverflow.com/questions/31171682/type-trait-for-copying-cv-reference-qualifiers
// Copies the const and volatile qualifiers from T to U;
// Example copy_cv< cons... |
I have two lap time strings I need to subtract, the format is minutes, seconds, milliseconds. This is to compare a new world record time to the previous holder's time. The result will always be positive.
Example input:
x = "1:09.201"
y = "0:57.199"
# 12.002
I have two working solutions, but I'm not sure I'm content. A... |
I'm often updating the Pokemon model with more detail. This detail is then sent to the UI to be displayed in the new sections I add over time.
Since there are currently 1302 pokémon entries in the PokéAPI, I thought it would be more polite to not just request everything all at once. Instead I'm trying to fetch data for... |
I have created a templated linked list to take different objects. I was told to put this up for code review as it could use some improvements. To be honest, I am not completely sure when to use the 'new' keyword for all instances. Also, I am not completely confident on my use of the template syntax. I did get it to wor... |
Was thinking about extending the C switch beyond integers. Here is what it came to - will gladly accept any suggestions for improvement.
Note: "Any class" in the title is not quite correct - the class should have equal operator and hash function to be used in this switch.
#include <iostream>
#include <unordered_map>
#i... |
Take a resume (or “CV” outside of the US) and return all the text within it in a formatted way. Right now the below script outputs it to a txt file.
I used this guide as inspiration and have looked to improve on it, by using slightly saner control flow and functions. Although the script works as intended, there are qui... |
I'm trying to access an API using the requests library in as clean a manner as possible. The API is accessing various settings of various devices. I'd like to keep my code as readable and comprehensible as possible, thus I want to avoid setting up my API access functions too abstractly. Therefore, instead of setting_10... |
I'm a somewhat new programmer developing a WinForms application in C# that has the option to change the theme/colors depending on user input. Due to the complexity of the application and the amount of panels, tabs, and labels that it needs to change the colors of, it ends up being a hassle to constantly keep updating t... |
I wrote the following code in Rcpp, i.e. it is C++ code that is compiled in R for making faster calculations. The code in Rcpp is intended to calculate in a recursive way the likelihood function for an Hidden Markov Model, the likelihood function in this case is Like_Fun_acoustic_FAST. First I provide the code in Rcpp... |
I am working on a program that sorts data using mergesort. I implemented functions to 'Person' class to make it comparable, sortable, subscriptable, iterable, and castable (to float, int, and string). I want to define everything once that no code is repeated - i.e. have D.R.Y. code. Did I implement some functionality (... |
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <wininet.h>
const char thisVersionDate[] = "2024-01-05";
bool isMostRecentVersion(HINTERNET* hInternet, HINTERNET* hConnection, HINTERNET* hData) {
char currentVersionDate[sizeof(thisVersionDate)] = {};
*hIntern... |
Code:
# Range 32-126 (inclusive) is printable
# We'd store the result of '126-32+1' into cell 1 and start printing
# from 32 until cell 1 becomes 0 and then print again for the zeroth
# index
+++++>++++++++++[<+++++++++>-] # 95
>++++++++[<++++>-]<< # 32
[>.+<-]>.
<+++... |
The problem:
Given a string s. For each i from 1 to |s|, find the number of occurrences of its prefix of length i in the string.
Input:
The first line of input contains an integer q (1≤q≤10⁵) — the number of datasets in the test.
Each dataset consists of a string s. The length of the string s is from 1 to 10⁶ characte... |
I'm going through some exercises to learn about working with Pins. In the followinge example, I'm implementing Future for a wrapper around another Future. Calling poll on the wrapper will print the elapsed duration if the Future is Ready. I implemented this without relying on the pin_project crate.
struct MeasurableFut... |
My attempt at coding an adjusting calendar grid. It seems to work in most cases I've tried (although I haven't tested it exhaustively yet) but my DOM is a bit rusty and I wonder if there's better ways to do what I'm doing here.
class Session {
day: number;
hour: number;
length: number;
week: number;
... |
Problem
The scrolling looks smooth on Windows, but very laggy on Linux (Webkit webview and Webkit browsers).
Any thoughts on what could be optimized or what's obviously broken?
Demo playground:
https://stackblitz.com/edit/sigma-scrollkit-demo?file=README.md
Code
Full source code
The main logic is happening in this comp... |
I have implemented the Caesar Cipher in Swift and incorporated it into an iOS-app.
I guess it's formally correct. Please see the attached images, which show how the usage of the app is meant.
Here's the relevant code:
struct ContentView: View {
@State var input = ""
@State var output = ""
@State var shi... |
I'm working with Kotlin for some time. Compared to Java it's more concise. Still it has some legacy inherited from Java. For example the try-catch-construct. Though it has been upgraded from a statement in Java to an expression in Kotlin, it's still some kind bulky in writing, assuming we stick to the officially mentio... |
The final product is the following pokédex page, here for Bulbasaur:
the blurry sprite is just a placeholder
the perspective effect disappears when the mouse hovers over the text
Any place where I pass pokemon.type1 or type directly in the className field gets the corresponding rule from global.css. The content is t... |
I needed something that would help me keep dialogs in my Jetpack Compose desktop application under control and without dozens of *Visible variables etc, so I created the following system.
It's built upon the DialogManager class and the Dialog interface that dialogs need to implement. It reacts to the changes of the cur... |
While grinding for coins on the GTA San Andreas casino poker machines I started to
wonder how exactly one might implement a luck modifier to a video poker game without
it being completely obvious to the player, like it is in GTA.
This project implements it by brute force. When dealing cards it calculates the
probabilit... |
I have a Makefile that I've been using to compile my shared libraries and an executable for an APR based application.
APR_CONFIG = $(shell which apr-1-config)
APU_CONFIG = $(shell which apu-1-config)
BIN = main
BIN_DIR = bin
CC = $(shell ${APR_CONFIG} --cc)
CFLAGS = $(shell ${APR... |
Given a txt input which represents extracted resume (or “CV” outside of the US) data, pass the text to an AI model and return a JSON version of the original input.
I have created the below script, which tries to prompt gpt3-turbo in order to process and return the JSON.
As well as the usual review, I am also looking fo... |
Not sure how to show this here, but the stripes of the gauges shown below move from left to right:
The gauges represent a pokémon's base stats (here, Bulbasaur). The length of each gauge is determined as a % of the max value (65 in this particular case).
/*-------------------------------
Stat gauge animation
-... |
I am very new to C++ and I've tried to write a simple number guessing game. I know it is a basic task but I'd really appreciate any feedback that could help me improve my writing. Thanks!
#include <iostream>
#include<cstdlib>
int main(){
//This is a number guessing game.
std::cout << "Welcome to the number guessing g... |
I'm trying to integrate Arrow-kt's Either into an application that needs to parse and validate filter input. This input is a comma separated list of criteria. Either sound like a good candidate for that job because it does both jobs at the same time.
Big-Picture
I've got a parser that takes care of the first step:
inte... |
After reading many people talk about the need for a SynchronizedObservableCollection and their implementations I decided to roll my own. I wanted to add a AddRange, RemoveRange, and a way to Replace the entire contents without detaching event listeners.
This is supposed to be a thread-safe collection that produces chan... |
I made a simple search engine using the xkcd API in Rust which turned out better than I'd hoped for!
I decided to use tf-idf as a way to rank results, which I feel like has some room for improvement. Any ideas regarding different algorithms would be fantastic.
The way I tried to organize the data was using separate str... |
I recently made a tool called mkfh to create a FHS compliant filesystem structure.
I aimed to make it as portable as possible, so I wrote it in C89 and also tried to catch the vibe of old-school tools!
Did I achieve that? Is it really that portable? Anything I could improve?
It consists of 2 files, mkfh.c and usr.c, wh... |
As a beginner, this is my second game in C++. It is a very simple rock-paper-scissors game. User or computer wins the game after a given number of rock,paper or scissors matches. I'd appreciate any comment improving or criticising my code in any way. Thanks!
// Rock-Paper-Scissors game
#include <iostream>
#include <ra... |
I am re-implementing the damage calculations for the game Final Fantasy 9, based on the documentation provided in the GameFaqs Battle Mechanics Guide. Currently, I have two main methods for performing calculations: BattleEngine.Attack and BattleEngine.Magic.
BattleEngine.Attack
public AttackResult Attack(Unit attacker,... |
The usual way of dealing with a SemaphoreSlim is
await semaphore.WaitAsync();
try
{
await DoStuff();
}
finally
{
semaphore.Release();
}
To help with not making mistakes like not releasing the semaphore or putting the semaphore in the try block, I created this extension class
public static class SemaphoreSlimE... |
This is the plain websocket code that connects with mobile app. Once we send a REST request from another service say B to our service A we send a websocket payload over the response. This runs in kubernetes pod. Could you suggest how to improve this?
@Component
public class WebSocketServer {
private static final Lo... |
I'm looking for a function in C++ that can determine, how accurate all floating point numbers in a given range can be represented as strings, without the use of e.g. boost library, etc.
Please take a look at my code and tell me how it can be improved.
#include <iostream>
#include <cmath>
#include <cfloat>
/**
* Calcu... |
There is a way to not rewrite the same part (the cycle for i = 1...end) twice?
local function myfunc(frame,method)
if frame:IsShown() then
for i = 1, #frame.buttons do
frame.buttons[i]:HookScript("OnMouseDown", method)
end
else
self:SetScript(
"OnShow",
... |
My 2nd take of the problem in Determine top t values with few calls to order(), a given procedure to order k values:
Given an array and a procedure to order \$k\$ elements,
return an array containing the top \$t\$ elements
using no other comparisons of elements.
The challenge:
For \$n\$ elements, use fewer calls to t... |
How can I optimize the performance of the code below? Destruction of the condition variable at the end of main blocks, not sure why this behavior is occurring. Is it possible to remove some of the sleep statements and while loops? What are other general best practices for proper implementation of this type of program. ... |
In our apps we're using a shared inhouse library which provides filesystem functions. All the functions are noexcept.
In several apps i found that similar or identical error return translations are implemented again and again [which are then reported on a console or some windows app] and was wondering
if it might be a... |
/.htaccess
ErrorDocument 404 /inc/index.php
ErrorDocument 500 /inc/index.php
RewriteEngine ON
RewriteRule ^([a-z_-]+)$ index.php?page=$1 [L]
/index.php
<?php
if(isset($_GET['page'])) {
switch ($_GET['page']) {
case 'login':
require 'inc/login.php';
include 'tpl/login.tpl.php';
... |
I created this save method that has two conditions. One condition is checking if coordinatorsId is not 0 and another one is checking if Subject is not empty string. Is there a better way to do the two conditions?
I have come up with the below for the SaveRequest entity. I am looking for advice on ways to improve this. ... |
How can I horizontally align one HTML element to one elsewhere in the document? I came up with this solution aligning “aligned text” with “| text after alignment”, but I think that it is not good because it requires a lot of extra tags, and it seems that there should be a more standard way. I would like to use it for a... |
Good evening. I am studying mathematics at the moment, so I have little to no formal education in actual computer engineering. However, I am trying my hands at learning Python because I will need lots of it for my future career. I hope you can point out any bad practices or mistakes on my part, so that I can fix them e... |
The code is a bunch of Prisma models, starting from Move. This model stores data about pokémon moves as can be obtained from the PokéAPI. Further models are shown in order of appearance inside the Move model, with comments for context.
Relations are as follows:
one move to many effect entries
one move to many flavor t... |
In a Java 8 project, I'm using several maps, many of which contain static or default content. In Java 9 and newer, there's the convenient Map.of() method and I want something similar convenient. So, I came up with the following implementation:
public class CollectionUtils {
private static final String INCOMPATIBLE... |
Implementation to progressively draw symbols, when provided with symbol implementations it supports any type of symbols, though for the review purpose just two hand written latin symbols are supported (q and x). It also supports font size, drawing line thickness and drawing speed configuration, pausing and notifying o... |
I have reached a point in my course that I feel I could use some feedback as to how my code looks and hopefully some direction on some best practice methodology going forward. I know I have a long way to go and there are problem a million better ways of doing what I did but I did use every concept I was taught up to th... |
This is my third project for review; I would like feedback on:
code readability
code efficiency
particularly good parts
The project is called BirthdayBackup. It's a
GUI app that allows you manage a list of everyone you know with their email, name and birthday date. It can send a random birthday blessing to people w... |
This program solves the minimum dominating set but it takes an insanely long time to run. In case you do not know, in graph theory, a dominating set for a graph G is a subset D of its vertices, such that any vertex of G is either in D, or has a neighbor in D. Can someone help me make my code more efficient.
import java... |
I'm fairly new at coding and looking to improve. Down below is all of my files for a TCP chatroom with a GUI in java. This is my first networking project so I'm sure it has many problems and does not scream clean code. Because of that I'm looking for some help to identify my blind spots and bad practices. If you have a... |
I'm a CS undergrad, so I don't have much experience. But while coding vanilla PHP projects, I found that I was repeating myself a lot with the CRUD operations. So overtime, I developed a single file called config.php that I use in all the projects where I use PHP as a backend (70% of the time). Basically, the workflow ... |
I am currently working on a function to check for active SQL Server connections. While the function is functional, I find its implementation a bit verbose. Could you provide suggestions or improvements on how to write it more succinctly and efficiently?
function get-activeConnection
{
param(
[parameter(Mandator... |
I am trying to learn React basics and completed a chat app. My main purpose was to create user-specific text areas and preserve the draft when changing between people. Beforehand I had some trouble with the ContactList and posted it on StackOverflow. Thankfully it got solved and I finished this assignment. I don't know... |
The nested JSON file contains names of US states and corresponding cities.
City.json
[
{
"header": "Michigan ",
"id": "MI",
"PlaceList": [
{
"title": "Detroit",
"slug": "detroit"
},
{
"title": "Lansing ",
"slug": "lansing"
}
... |
i am trying to practice on matlab with the code below:
I randomly generated x and y variable to implement the following formula in matlab : $${\sum_{i=1}^{n-ln} \bar{Y}_{i}\left(\bar{X}_{i} - \frac{1}{k_n} \sum_{j=0}^{kn-1} \bar{X}_{(i+j)}\right)}$$ where the quantity \$\bar Y\$ and \$\bar X\$ are obtained according ... |
In recent times, I've been using the following algorithm repeatedly in different languages (Java, Python, ...) to search and replace strings. I don't like this implementation very much, it's very procedural and not very descriptive, but I have yet to come up with a better one. How could the implementation be improved?
... |
I have a server-side component getting an id from the url query string to fetch data before displaying it. Everything works, but the request failure handling looks off. I'm just not sure what to put instead.
I first request pokémon because I figured out there's no point in fetching species data if I don't have a pokémo... |
As I newbie in (java and MVC), I want to know if I understand MVC using java.
My concern is that some of the calls of the class are in the wrong place or, for example, I should have used the interface (of course, I don't know the advantage of using the interface assigned to the class in this case).
I also want to know ... |
I have written recently the SQL query to MariaDB that I want to move into PHP code. Below is my test.sql file. What do you think about my SQL code?
CREATE TABLE IF NOT EXISTS user_roles (
id int(11) NOT NULL auto_increment,
name VARCHAR(255) NOT NULL default '',
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXIS... |
After finding out that my previous implementations are incorrect, I decided to give it another try. I relied on this post.
(The entire project resides in this GitHub repository. Contains some unit tests that are not included in this post.)
Code
com.github.coderodde.pathfinding.BidirectionalDijkstrasAlgorithm.java:
pack... |
Greetings.
Lately I've tried to use a branch of text_formatting rules to enhance my productivity while working with different integration tools such as Git, but this formatting convention went so
deep into my life that I thought that writing my To-Do list while adhering to it would be
a good idea.
Since the element or... |
The task
The goal here is to build a RPS engine that can run tournaments of RPS games between different players. The initial version has been written with the Rock Paper Scissors Spock Lizard ruleset, but it is expected that weapons will be frequently added or removed.
Within each game of RPS, each player will be restr... |
The goal of the code is to convert a Graphviz DOT file to an SVG file, and it achieves this by creating a child process and executing the "dot" command.
#include <stdio.h>
#include <stdlib.h>
#if defined(_WIN32)
#include <windows.h>
#define OS_WINDOWS 1
#elif defined(__unix__) || defined(__unix) || defined(__linux__)... |
code feature: read a list of value display it depends on pagesize and current page
original code:
public static <T> List<T> pageBySubList(List<T> list, int pagesize, int currentPage) {
int totalcount = list.size();
if (totalcount == 0) {
return new ArrayList<>();
}
int page... |
This is library for fast converting "HEX strings" to unsigned numbers and vice versa.
The result is not defined, if input is incorrect, e.g. string "ZZZ1" will be converted to number 1.
Special attention is made the conversion to string to work inside existing buffer (see ">>>:0000:<<<"). In this case the programmer is... |
In my deep dive into the study of workers I started trying to create a worker that could run on the same file but return values from the sent function.
Something like this but more sophisticated.
/**
* identifier internally used to identify the symbol
* on the hole stringify/unstrigify of params send to
* the functi... |
As stated in the javadoc below, this is intended for monitoring and debugging. I've found it especially useful for figuring out which tasks got stuck and prevented clean terminations of my Executors.
I've run some simple benchmarks for TaskTrackingThreadPoolExecutor (see below) and performance penalty is up to 1.15x fo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.