instruction stringlengths 71 95.1k |
|---|
Note: The important chunks of code are pasted in the question but the larger representation of the app is available on GitHub.
Some time ago I was tasked to create a simple FastAPI app. I did manage to pull it off and I already have it running with no errors, But I want to improve it. This project has a lot in common w... |
import mmh3
from random_things import string_generator
class HashMap:
def __init__(self, num_of_buckets=4, load_factor=0.75):
assert (num_of_buckets >= 1)
self.num_of_buckets = num_of_buckets
self.mp = [[] for i in range(num_of_buckets)]
self.LOAD_FACTOR = load_factor
self.... |
I'm very new to programming and coding and "wrote" my first program from scratch as an at home exercise after doing some online courses.
My question is not necessarily a problem I'm having with the program, but I suppose more so just insight to simplify my code. I could not really find anything anywhere for my question... |
Based on the previous question regarding Data transfer design, here's a major updated code per G. Sliepen's Answer recommendation per std::variant:
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <span>
#include <string_view>
#include <variant>
#include <functional>
#include <cstdint... |
I have seen two different methods - getter and setter method and property - being used in Python libraries which are written for communicating with instruments via VISA commands. An example is given below.
import pyvisa-sim
import pyvisa
# Method 1
class Instument1():
def __init__(self, rsc_addr, rn):
self._rm = ... |
I'm trying to make a partial function from any function.
Here is a working example:
function partial(fn) {
const argc = fn.length;
const argv = [];
return function part(...args) {
argv.push(...args);
return argv.length >= argc ? fn(...argv) : part;
}
}
Usage:
function foo(a, b, c, d) ... |
I am stuck trying to remove duplicate code from some of my classes. I have a network app that uses local files to store "databases" of all kinds (user data, posts, project specific information etc). For each database I have created a Serializable class which holds all information and I have created a generic serializer... |
This is a revised version of the code from the previous question. It corrects the spelling errors, add in appropriate comments for argument types and doc strings, rewrite number representation, and make the code reproducible by adding in the fake device yaml file. It will be great to get a review how I can improve the ... |
I've been working on implementing a multi-client socket communication system with a thread pool in C++. The system comprises three main components: logger.h, socket.h, and thread.h, which handle logging, socket operations, and thread pooling respectively. Additionally, I have a test suite tests_multisock.cpp that verif... |
Swing code may be hard to read. As is, it's not inherently visually modular, and component composition is not immediately clear. To address that, I created a simple framework called UIBuilder which, in my opinion, makes Swing code easier to write and read. Besides, it provides some nice implicit settings, like frame ce... |
I'm making a Start Screen class for my game, it has 3 buttons and they're spread out horizontally on the screen. The screen also has a scrolling background, moves from top to bottom. It's a very basic Start Screen but the code is 111 lines long. I'm sure there's a much more efficient way of doing things, any tips on ho... |
I have this repository. The most important source files follow.
com.github.coderodde.math.linear.matrix.AbstractMatrix.java:
package com.github.coderodde.math.linear.matrix;
import java.util.Objects;
/**
* This abstract class defines the API for the matrix data types.
*
* @param <M> the actual implementing matrix... |
My question got rejected the last time so I am trying a better approach to getting a solution:
df.head:
predicted_u4 u_2_5_weight predicted_o2.5_n predicted_score_difference dnb_weight total_score o_1_5_weight predicted_total_score away_score predicted_bttsu2.5_n home_score btts_u_2_5_weight result_match... |
I have this code, which is a pseudo-Sieve of Eratosthenes for generating primes:
module Prime where
import Data.List (unfoldr)
nth :: Int -> Maybe Integer
nth n
| n < 1 = Nothing
| otherwise = Just $ primes !! (n - 1)
primes :: [Integer]
primes = unfoldr (Just . f) [2..]
where
f :: [Integer] -> (Integer, ... |
I'm new to Python, and coming from Typescript, I tried to include types, but it's not obvious sometimes.
Currently this is the way I type objects:
Write own simple types
Import type from a library like torch.Tensor below
Use typing package for anything that looks not obvious to build the types of
import torch
from ty... |
As said in the title, I tried to come up with a sorting algorithm on my own to practice.
It seems to work, even though it's not in place. Is it "new" or does it already exist?
fn salmo_sort(v: &mut Vec<i32>) {
let mut c = v.clone();
for i in 0..v.len() {
let mut contatore = 0;
let mut n = 0;
... |
This is a follow-up question for A recursive_fold_left_all Template Function Implementation in C++. As mentioned in G. Sliepen's answer, I am trying to implement recursive_foreach_all template function in this post.
The experimental implementation
recursive_foreach_all Template Function:
/* recursive_foreach_all temp... |
One more BST implementation with iterators added. Did not manage to find another implementation with iterators and it is my first attempt at implementing them so thought to check on your opinion:
template<typename T, typename less_than = std::less<T>>
class BinaryTree {
public:
void insert(T&& value);
... |
I'm extending the sync.Pool type by limiting the amount of objects that can reside outside the pool. To achieve this I'm using sync.Cond to wait until a call to Pool.Put is made. To prevent users from creating a zero value of my struct, I'm not exporting it and defined an interface too.
My question is: when checking th... |
Overview
I have created a bash script (triggered via GitHub Actions) that does the following:
Parse a list of YouTube channel IDs and nicknames.
Fetch their metadata via YouTube's Channel API.
Build up Markdown tables using this metadata.
Load a Markdown template, and replace a placeholder with the generated Markdown.... |
I am new to python, so the challenges for me currently are:
Clear, simple code, trying to follow standard practices
Useful comments,
Use types (for better understanding of input/output relationships.)
Apart from that, the basic task here is to create a simple convolutional network to calculate rotation in a dataset o... |
This is a development of Nought and Crosses (tic-tac-toe) in C++ a learning project in C++. This time using C++20 modules. As before, any suggestions on improvements in style, clarity (or anything else) gratefully received.
A few specifics:
The diagram - is it helpful? What do people use? Is there a better way?
The p... |
Task:
develop a CLI utility for HTTP Health check at a given URL.
The check is performed in a cycle with a specified interval. On each iteration of the HTTP GET activity on the given URL.
There are three options for the test result:
OK(200), in case the request returned HTTP status code 200.
ERR({HTTP_CODE}) if the re... |
I've found several examples of code to increment various sequence values but they are usually specific to either alpha characters or numeric characters. I wanted something that could increment a sequence to append as a suffix to a file name to "ensure" uniqueness. The "catch" is that sometimes I want numeric values and... |
I have a PR swapping from Command::output() to a custom implementation using threads to handle the subprocess' stdout/stderr while the program is running, instead of waiting for it to complete. The approach was motivated by this answer.
// Executes the given command, capturing its output and exit code in the returned I... |
I am new to spring boot and wanted to make a simple application with JWT authentication. There is one problem with the response having 401 status when it should have 403 but otherwise everything seems to work as expected.
@Configuration
@EnableWebSecurity
@RequiredArgsConstructor
@EnableMethodSecurity
public class Secu... |
The below code is part of a program that, among other things, configures a Chromium profile:
#[cfg(target_family = "unix")]
use home::home_dir;
use rocket::serde::json::serde_json::Map;
use rocket::serde::json::{serde_json, Value};
use serde::Deserialize;
#[cfg(target_family = "windows")]
use std::env::var;
use std::fm... |
Downloading specific version like 3.11.1 from https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tgz and installing ./configure --enable-optimizations && make install is slow (30 - 40 mins), on GitHub actions.
Dockerfile:
FROM --platform=linux/amd64 ubuntu:22.04 as base
USER root
ENV PYTHONDONTWRITEBYTECODE 1
EN... |
Like title says programs shows you the number of streaks and how many of each. Is there anyway to break this down. Feels like it's too many variables.
numberOfStreaks = 0
flip = []
numofT = 0
numofH = 0
tStreak = 0
hStreak = 0
for experimentNumber in range(20):
if random.randint(0, 1) == 0:
flip.append('H')... |
I'm trying to solve the following Kata from Codewars in Python.
My code produces the desired result for all the tests, yet it is not optimal, so it takes too much time to accomplish the big tests.
def set_var(pol_1, pol_2):
if any(char.isalpha() for char in pol_1):
for char in pol_1:
if char.isa... |
Util functions to generate random numbers with upper bound or with both upper and lower bounds:
var waver = (function() {
return { between: function(min, max) {
return Math.floor( Math.random() * ( max - min + 1 ) + min );
}
, until: function(max) {
return Mat... |
I have the following simplification of a program which consists of 2 threads. One thread pushes packets to the back of a deque while another waits for user input before performing a "heavy" operation on the current deque (Here, we just look for the maximum id).
#include <iostream>
#include <thread>
#include <random>
#i... |
I wrote a terminal-based TicTacToe game in Kotlin to practice both Kotlin and OOP. Any feedback on structure and code would be appreciated.
Board.kt
package main.com.github.me.tictactoe
class Board {
val originalBoardConfig = listOf(
listOf("1", "2", "3"),
listOf("4", "5", "6"),
listOf("7",... |
I built a function in JavaScript which executes a search algorithm to find a town in a particular state. The dataset, referenced by the variable townsAndStates is an array of object pairs, each of which has a town and a state, and only returns the first few results. An example of an object in this array is {"state": "R... |
I have just started learning Rust and wanted some feedback on a simple program for calculating Elo ratings.
All of the following code was in a single file, but I imagine that this is the part that would be put into a library to be called by another program (see the next section).
enum Outcome {
Win,
Loss,
D... |
I have a csv with data. There are a total number of 9 samples, each sample has multiple fits. Each fit has an associated name, chi2, degrees of freedom, variable name that was fit, and the actual values.
Out of this huge table, I'd like to only extract a handful of fits. I'd then like to get the values of the fits, and... |
I programmed this type of Penrose Tilings in javascript and the algorithm is 'simple':
The cyan pentagon always have to draw the yellow losenge and the grey pentagon almost always have to draw two red pentagons and a half star, that will draw a grey and red pentagons that will draw a star and so on.
Sometimes we'll ne... |
I've begun my journey with game development a little while ago, thought recreating snake would be cool, except I plan on adding other cool mechanics and stuff to it later. The player controller script utilizes a looot of if statements, I'm sure there's a much better and cleaner way to do this, any tips or help is great... |
I've implemented a websocket wrapper around this library for a 3rd party API integration. The client manages logins, logouts, sends requests, and awaits corresponding responses. Responses can be matched to their initiating requests either by type or a request/response id. If a response isn't received within a specified... |
I get 25% CPU usage on this simple project. I hope it's okay if I just post the whole thing. It probably something to do with the rendering code. It's definitely the project though, my fans get loud, then I exit the program, and quiet again.
#python3 -OO main.py
import pygame
import json
import sys
import os
#OS
xMax ... |
I've implemented the Egg Drop Problem using Python. As described in the code, I'm trying to find the highest floor of a 102-story building from which I could drop an egg without it breaking.
The approach I took here is by using a binary search method, where I initialize the upper bound as the building height, the lower... |
Problem statement: Suppose that n random walkers, starting in the center of an n-by-n grid, move one step at a time, choosing to go left, right, up, or down with equal probability at each step. Write a program to help formulate and test a hypothesis about the number of steps taken before all cells are touched.
This is ... |
I am designing a very crude general-purpose input/output (GPIO) module to provide IO pin control to a RISC-V (like) architecture microprocessor I am currently playing with.
This is the code so far:
`timescale 1ns / 1ps
module gpio(
input clk_i,
input rst_ni,
input we_i,
input [7:0] wdata_i,
input [... |
I found an example using std::variant to provide compile time polymorphism as a possible optimisation to runtime polymorphism in 'Software Architecture Using C++', https://github.com/PacktPublishing/Software-Architecture-with-Cpp, in the Dependency Inversion Principle chapter.
I had a C++ code example using runtime pol... |
I'm trying to solve the following problem:
As you know Bob likes to destroy the buildings.
There are N buildings in a city, ith building has ai floors.
Bob can do the following operation.
Choose a building, and destroy its uppermost floor with cost h. Where h is building's height before removing the floor.
You can do ... |
int binsearch(int x, int v[], int n)
{
int low, high, mid;
low = 0;
high = n-1;
while (low <= high)
{
mid = (low+high)/2;
if (x < v[mid])
high = mid -1;
else if (x > v[mid])
low = mid + 1;
else
return mid; /* found match */
... |
I'm trying to solve the following problem:
You have a k-dice.
A k-dice is a dice which have k-faces and each face have value written from 1 to k.
Eg. A 6-dice is the normal dice we use while playing games.
For a given N, you have to calculate the number of ways you can throw this dice so that we get sum equal to N.
Sin... |
I am quite new to Haskell, and this problem is from dailycodingproblem.com:
Implement an autocomplete system.
That is, given a query string s and a set of all possible query strings,
return all strings in the set that have s as a prefix.
For example, given the query string de and the set of strings [dog, deer, deal], ... |
Exercise 1-13. Write a program to print a histogram of the lengths of
words in its input. It is easy to draw the histogram with the bars
horizontal; a vertical orientation is more challenging.
The code I wrote:
#include <stdio.h>
#define MAXWLEN 35 /* assuming no word longer than 35 characters will appear in the inp... |
I have recently done some functional java programming at https://github.com/zmacomber/zm0823 and I would like feedback for what could be improved in my coding approach.
Here is one of of the classes from that repo:
package org.example;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.Collections;
... |
Motivation
When I was young, I had to learn english in school and I was really bad. My father told me to write words on little cards, with a word on the one side and its foreign counterpart on the backside. These flashcards were in a box with 5 categories: 5 is very bad and 1 is very well trained. When i guessed a word... |
There are very few example on how to implement saga pattern with Kafka so I tried to come up with my own implementation choreography saga pattern using Kafka. I need to implement outbox pattern as well I guess.
public interface SagaPattern<M extends Message<?>> {
void beforeStart();
void beforeEnd();
}
public... |
Whatever language you choose, you may encounter a rounding problem. In fact, this is due to the limit of the required number of bits needed to get the right number after a calculation.
Simple example:
In javascript (like any other language), you may want to use a function to round the result after even a simple sum (w... |
Yes, I know this exercise has been posted before, but I'm posting it again because I want feedback on why certain parts of my code aren't idiomatic. I'm new to rust, and my code works, but as I said, I'd like to have parts pointed out that could be implemented another way, and why my way is "wrong". Thx in advance!
I h... |
I want some feedback about my code (anything is welcome). It is working, but it feels like a clumsy implementation. Because I am self-learning from a book without an answers section, it becomes difficult to know how to proceed.
module prefix_adder #(parameter N=4)
(input logic [2**N-1:0] a, b,
input logic cin,... |
I am building a template engine for js and I need some help refactoring the code for fast and more efficient performance. If you can help modify or suggest some updates I'll be grateful.
var TEMPLATE_CONTEXT_REGISTER = new(function ContextRegister() {})();
var TEMPLATE_HELPERS_REGISTER = new(function HelpersRegister() ... |
Exercise 1-21. Write a program entab that replaces strings of blanks
by the minimum number of tabs and blanks to achieve the same spacing.
Use the same tab stops as for detab. When either a tab or a single
blank would suffice to reach a tab stop, which should be given
preference?
The code I wrote :
#include <stdio.h>... |
I have written a function in c++, which accepts an "ifstream" object (file) to read from and a string to match a header token in the file. This way I am counting how many times a token appears in the file and that makes up my frame count. The data file is a repeating unit of the one shown below
ITEM: TIME
0
ITEM: TIMES... |
Below is a simple Rust program which inter-converts temperature between the Celsius scale and the Fahrenheit scale. It takes two inputs:
scale referring to the temperature scale of the next input
the value you you want to convert
use std::io;
fn main() {
loop {
println!("Enter the temperature scale ('c... |
This script just opens a TCP server to listen for real-time position data from a FANUC robot to pass to another sensor software we are using (Luna Terahertz sensor).
So far everything is working great, I get an .xml file generated with the data from the FANUC with each datapoint getting an accurate timestamp.
However I... |
The following function filters and formats /etc/fstab for future use. Comments are in TomDoc format.
# Internal: filters and formats lines in /etc/fstab using Perl.
# When run it: removes comments, splits fstab columns (listed below) into the $fstab array.
# fstab columns: <file system> <mount point> <type> <options> ... |
How safe is Cookie based Authentication/Authorization in ASP.NET C#? Take a look at the example below, don't worry about password hashing, All this code does is that it takes a username and a password and lets a user login. After they login, I have multiple pages that use the role for authorization purposes. is this a ... |
I need a distributed lock system for a service I'm writing. (There can be multiple instances of this service running at a time, and I need to make sure that only one instance does a particular cron job.)
According to this page, S3 has strong consistency, so I thought I'd make an attempt at implementing a distributed lo... |
def sam_flag_explainer(flag:int):
"""
Intepret sam flag and make a flag-explained-dictionary.
"""
try:
# Convert sam flags to binary format, like 0101001
# flag is a integer.
flag_binary = "{0:b}".format(flag)
except Exception as err:
if int(flag) == flag:
... |
The module measures input clocks. It requires some reference clock. There can be from one to five input clocks to measure it. Output values are usual unsigned ones. As expected, it should be reset before starting. If it is used in Vivado, the user can choose the number of ports to show, depending on the number of input... |
(See the next version here.)
Intro
I have this tiny JavaFX program that shows a 800x600 pixel canvas. You are supposed to drag the mouse within the canvas. When you are done dragging, the program will print in the standard output the number of frames per second.
For example,
my system prints
196 frames in 1566 millisec... |
The locking mechanism is implemented in the class RW_Lock.
The saved_async_completion_handler structure is used in RW_Lock to enqueue completion handlers that can't be called right away.
The rest of the code completes a test-scenario program for the lock. A group of threads run the main io_context where the lock and te... |
I am a new programmer, learning from youtube and other sites I can get my hands on. The assignment was clear. Create a Tic Tac Toe game using functions as much as possible and where needed.
I am posting this because I am very much interested what this community thinks of this effort and also if there would be any sugge... |
I have the following implementation of the Miller-Rabin test in Python:
from random import randint
import decimal
decimal.getcontext().prec = 10000000
def miller_rabin(n, k):
if n == 2 or n == 3:
return True
elif n == 1 or n <= 0 or str(n).isdigit() == False or n % 2 == 0:
return False
else:
s = 1
... |
I have made a search engine for recipes. Requirements for this JS Project are as follow:
Create a function called searchRecipes that takes all recipes and an object with search criteria. This should return an array of recipes that match the search parameters
Create a function called printRecipes that takes an array o... |
As a project to get more familiar with curl, I decided to write a program that downloads stock data from Yahoo Finance, and does arbitrary analysis on that data. I would like to receive any critiques about the way I went about this, especially setting up the curl "environment", along with any other C standards I might ... |
I made a simple flash card app. The general idea is from Head First Java, but it's one app instead of two (for both making cards and playing them) and the implementation is different. What do you think?
public class App {
public static void main(String[] args) {
FlashCardMaker flashCardMaker = new FlashCard... |
I want to implement the following case
Input - integer number n
Start 3 threads. The first thread prints 'a', the second prints 'b', the third prints 'c', then the first thread prints 'a' and so on
Example: Input - 6, Output - "abcabc"
I want to use condition variable to synchronise threads
My code
#include <iostream>
... |
I've been playing with perfect, amicable and social numbers lately, and created a class for investigating these. At present, it has functions to return the perfect and amicable numbers in a specified range (and also the primes, since they are found as a useful side-effect). It could be expanded to explore the implied ... |
im using spring boot and CrudRepository for my queries, the project is about posting content on a blog, so I have a post record with id, creator name, post name, the content itself likes and dislikes:
import org.springframework.data.annotation.Id;
public record Post(
@Id
Integer id,
String creatorName,
... |
Is this a good approach for validating user input in a chatbot? I am writing an autoposter telegram bot in PHP using the php-telegram-bot library (by Longman). I have a Task class that stores information about the task (repetition period, message data, etc.).
class Task
{
#[ORM\Id]
#[ORM\Column(type: 'integer'... |
Background
I'm mostly a c# and python programmer and am slowly learning Rust. I'm not sure if that is contributing to incorrect concepts as to how threading and io work in Rust, but that's what I'm trying to figure out here.
I've got a program that needs to handle a lot of packets. Ultimately, I'm looking to handle ... |
I am more on data analyst than a programmer, but I do enjoy coding for fun. I tried to implement a Heap in rust. I would appreciate any return you may have, so I can improve.
//! a minimal heap implementation support minimum and maximum heap, insertion,
//! heapify and pop/peeks at the top node.
//! Support optional da... |
I've got some pretty large Excel files with nearly 1M rows that are almost impossible to open and work with in Excel anymore that I'm migrating into a database. Desipte this these files will stick around for some time as other processes depend on them. This means that I'll be reading them more than once so this needs t... |
I'm writing a bit-level IO code that handles endianness conversion for the short/uint16_t type in the IO subroutines. Here's the code:
#ifndef header
#define header 1
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct {
FILE *fp;
uint8_t word[2];... |
(See also An extended JavaScript plugin for rendering radial pie charts.)
I have this JavaScript plugin:
rodde-radial-pie-chart.js:
class RadialPieChart {
static #rgb_alphabet_set = new Set();
#canvas_id;
#entries = [];
#maximum_radius;
#start_angle;
#empty_pie_chart_color = "";
#canva... |
Task description:
Implement a function, which receives an array of unsorted numbers from 1 to 100. In the array zero or more numbers might be missing. The function shall return an array containing the missing numbers.
Provided Test-data with expected result:
var arrTest = Array(1...100)
arrTest.remove(at: 25)
arrTest.r... |
To anyone who doesn't know WordFeud, but is familiar with Scrabble, WordFeud is just a variation with different letter bonus placements.
The code below is complete and runnable. Given a WordFeud board and 7 letters, it will generate all words that a player can place on the board with those letters, including their scor... |
recently I implemented a little helper class, which can be primarily utilized on perfect forwarding constructors.
Introduction
As a slight example, let me pull in two of the std::pair constructors:
template< class U1, class U2 >
constexpr pair( U1&& x, U2&& y ); // (1)
template< class... Args1, class... Args2 >
const... |
Observer implementation that leverages both behaviours observing a variable and observing for a value. Supports subscribing and withdrawing observers.
var Diffuser = (function() {
return { supply: function() {
return (function() {
var diffusees = [];
var oneTimeDiffusees = [];
... |
Here is a tiny (cli) tool to run a script with the state of any of a set of watched files when one of them is opened or closed. It applies basic debouncing to handle bursty access. It was written to run a script (oncall.py) whenever the webcam is accessed (hence the output semantics), without thrashing it. I thought... |
I'm working my way through "Prolog For Artificial Intelligence" by Ivan Bratko, and exercise 3.17 is to write a maxlist(L, M) that succeeds when M is the largest number in the list L.
My attempt at this was:
maxlist([H|T], Max) :-
maxlist(T, H, Max).
maxlist([], Max, Max).
maxlist([H|T], CurrentMax, Max) :-
(
C... |
This is a follow-up question for A recursive_transform_view Template Function Implementation and A recursive_transform_view Template Function which returns a view in C++. In those implementations above, when it comes to Clang 16.0.0, the compiling error occurred with message <source>:63:8: error: class template partial... |
#pragma once
#include <ntddk.h>
#include "move.h"
#include "testingMacro.h"
#include "util.h"
namespace anon {
namespace __vectorDetail {
//
// Global instance of a DPC queue of freeDpc
// which is necessary because we're not always at an
// IRQL level which allows us to call ExFreePool.
// It holds medium priority ... |
Please help me establish a solid foundation for this computational neuroscience project. I'd like to make sure I'm moving forward with something reasonable before I begin tackling the more complex parts involving the inclusion of a linear algebra library and algorithms for decoding/interpreting incoming streams of neur... |
I'm trying to solve the below question:
A string of characters X (all in lowercase) of length n is present. We can ask a query (i,j) such that if the substring(i,j) of X is a palindromic subsequence. The query return true if the substring(i,j) of X is palindromic else returns false. Each query takes O(1) time to proce... |
(See the continuation of this post in A JavaFX program to find out the mouse refresh rate v3.)
(This post is a continuation of A JavaFX program to find out the mouse refresh rate.)
After adopting the answer by @Reinderien, I ended up with this:
com.github.coderodde.javafx.mouseupdaterate.MouseUpdateRateFinder.java:
pac... |
I'm new in coding.
I have a shapefile (points) and some raster files. My purpose is get the values from all raster to point (each point will get value from 2 or 3 nearest cell,the value on the value of cell and distance of the point to cell).
I already built code for that and it is working but it takes so much time for... |
We're using std::chrono::steady_clock for most of our internal queues and relative timings. However, we're on a POSIX platform and steady_clock is implemented by using clock_gettime(CLOCK_MONOTONIC, ....
The CLOCK_MONOTONIC clock is not affected by discontinuous jumps in the system time (e.g., if the system admin... |
I'm working on a homework writing a toy interpreter. All the expressions in this language are prefix expressions. The language has a lot of lexical tokens and I wrote code as follows:
Value *expression() {
std::string token;
cin >> token;
if (token == "make")
return make();
else if (token == "t... |
This code installs the application, according to the type of application selected like alpha, beta, and released, also it checks for latest version in each type.
def install(
self,
app_version=None,
timeout=20,
cancel_button_verification=False,
install_type=None,
version_type=None,
latest_ch... |
(This post is the continuation of A JavaScript plugin for rendering radial pie charts.)
(See the continuation of this post.)
Now, you can mark up the radial pie charts via XML:
index.html:
<!DOCTYPE html>
<html>
<head>
<title>Radial pie chart demo</title>
<meta charset="UTF-8">
<meta name="v... |
(This post is the continuation of A JavaFX program to find out the mouse refresh rate v2.)
After taking @J_H's suggestions into account, I ended up here:
com.github.coderodde.javafx.mouseupdaterate.MouseRefreshRateFinder.java:
package com.github.coderodde.javafx.mouseupdaterate;
import java.text.DecimalFormat;
import ... |
Last week I wrote a simple server on FastApi to run ML model to classify a text on Chinese (split text on separate words). When I had clarified work of this model with API, it became time to confirm it correctness.
Here is a code:
/model.py
""" Chinese text classifier
@ref https://ckip-transformers.readthedocs.io/en/s... |
My goal is to have a memory pool non-template class that is used to store arrays of objects.
The same memory pool object must be reusable for a different array (difference size, different type and/or alignment).
I already posted a series of questions on SO about this subject:
Correctly using type-punning and erasure f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.