instruction stringlengths 71 95.1k |
|---|
I made an CRUD application in Java with JavaFX, H2 Embedded Database and Maven. Can you review my code quickly? Is it well written? What should I improve on it? I don't know if my code is written correctly, I'm a beginner in Java programming and I'm looking for advices. Where should I look for reviews of my code?
For m... |
This is the Ansible role that installs and configures SSH service. What do you think about it? Is there something to improve? Thanks
defaults/main.yml
---
# ssh daemon settings
sshd_listen_port: 22
sshd_address_family: any
sshd_listen_address:
ipv4: '0.0.0.0'
ipv6: '::'
sshd_protocol_2: 'yes'
sshd_host_key: ed25519... |
The following function searches for disks whose partitions all have an attribute that match a filter when listed with lsblk. Comments are in TomDoc format.
# Public: finds drives in /dev/sd* whose partitions all have an attribute that matches a filter.
#
# $1 - filter (default: '.*')
# $2 - attribute (default: 'MOUNTP... |
This metaclass utility is written to make subclassing builtins easier, such as int, str, and most importantly, complex. All dependencies are part of the standard library. I'm concerned with 1. readability, and 2. possible performance implications of wrapping every single inherited method of the created classes. The opt... |
The code itself is a random password generator which is encapsulated.
The other question about this code is whether it should be encapsulated on its main function.
Or is it enough to exist in its own module with the main function?
def _generate(_what_to_generate_from : list[any]):
"""Generate random characters ba... |
I'm trying to solve the following problem:
Joker has a deck of n cards, each with a value written on it. The cards are arranged in ascending order from top to bottom. Joker's master performs a hidden operation: picking a random number k between 0 and n, and moving the top k cards to the bottom. This results in a new a... |
In the world of Binary Search Tree (BST) enthusiasts, where collecting and trading BSTs is a craze, you have a beloved BST with n nodes. In this scenario:
(a) Identifying Swapped Nodes and Common Ancestors (10 points):
Recently, a rival group attempted to steal your prized BST. Although you thwarted their attempt, they... |
This method returns the topological ordering of a Guava graph starting from a given set of nodes. It's from my personal project github.com/jbduncan/guava-graph-utils, where I'm exploring utilities for Guava graphs. I'm aware of JGraphT, which has a topological ordering iterator that can be used with Guava graphs, but I... |
I was suggested by @Bergi on StackOverflow that Async Promise constructors are any pattern.
The argument behind this is that async Promise swallows the errors. In my case, I have try..catch so I'm not sure if the argument is valid. But here is my code - the core of the Wayne JavaScript library.
export class HTTPRespons... |
OK writing a C++ wrapper on top of openSSL.
Setting up the SSL_CTX* object. There are a whole bunch of extra functions to specify functionality on how this object works.
I wanted a way to logically organize them and correctly initialize the object in the constructor. So I have set up the constructor to take 5 parameter... |
I'm writing a pure-python geometry tool for technical drawings / computational geometry (not a solver, as a solver has to work with constraints). I've already mentioned a previous version on code review, as an example for Metaclass Wrapping Builtin to Enforce Subclass Type. This question is about the Point class and th... |
I needed something to map named SQL parameters into indices for JDBC queries so I wrote the ParameterMap class that takes an SQL query, searchers for parameters prefixed with a colon : and while replacing each instance it counts their indices adding them to the map as a list associated with each name. There is also an ... |
I made a template for a thing that displays the technical stats of 3D art. To make it quicker to fill in the numbers and because I can't use JS for this: I use custom properties and spans to make makeshift text variables that can be slotted into the HTML.
What I made works, but I'm wondering if it can be simplified.
... |
I got tired of having to extract the provided input from the requests manually so I made a library with which I can extract the values from the request a build a given DTO. The idea is to create structs which to fill out by coordinating through tags. Then, once the struct is filled out, we can pass the struct to the va... |
I develop my own application. I would like to write a good and elegant mapper. My idea is to use an extension methods. Could you please rate the following solution. I use Threading.Tasks.Result because its the Main method. Normally I want to use await. I know that the Project method doesn't look the best, but I want to... |
This problem can be found at LeetCode. Since I was studying idiomatic or 'pythonic' code in my language today, I decided to take the most 'pythonic' approach and challenged myself to do this in one line only.
LeetCode problem description :
You are given a large integer represented as an integer array digits, where ea... |
This is a NumPy script that converts BGR arrays to HSL arrays and back, without using OpenCV. Input and output values are arrays of 3 dimensions with values ranging from 0 to 1, the shape of the arrays are (height, width, 3) and the data type is float.
I will use it in my GUI program, to implement non-separable blend m... |
I have written code related to network communication interface which basically has functionalities of create socket and send & receive data. Currently this supports only IPV4 but facing lot of difficulties when making it to work with both IPV4 and IPV6.
use std::net::{UdpSocket, SocketAddrV4, Ipv4Addr};
use std::net::S... |
In the previous question I showed you my first attempt to handle named SQL parameters with JDBC and you were right, it wasn't as intuitive as I thought. The ParameterMap requires there an aditional variable to store it and has an unrelated property sqlWithQuestionMarks that holds the JDBC compatible string.
Since we're... |
I was reading Head First Java. The book featured a project called BeatBox that allowed you to make, play, save, and load beat patterns using Java's Sequencer API and Swing API. While the idea belongs to the author, I implemented it vastly differently and made the app way more complex and flexible. For example, the app ... |
I just started my programming lessons in school today and I decided to start learning more at home. This is my first day and I know the basics of if conditions, for and while loops and variables.
I decided to start my dice game project and the point of the game is to have 2 players competing against each other and diff... |
I was asked below quesion in Amazon sde2 low level design interview recently and I have shown below my solution during the interview. I was rejected in this round.
// There are a wide variety of Alexa devices
// 1. Alexa devices that only have a speaker (Echo Dot, Echo Flex, https://www.amazon.com/dp/B07FZ8S74R)
// 2. ... |
I've been working on creating a simple Class for a Cellular Automata. It generates a grid of NxM dimensions populated by Cell objects - Pretty straightforward class to save the state of the cell-. It allows to update the world grid using two sets of rules a the moment: solidification rules and Conway's game of life rul... |
main.py
The "main.py" script is a Python program designed to organize files within a specified directory based on their file extensions. It enhances file organization and grouping for better management by moving files into subdirectories that correspond to specific categories, such as programming languages, file types,... |
I've developed a custom vector class in C++, complete with functionalities like assignment, push_back(), emplace_back(), pop_back(), clear(), and size(). I would greatly appreciate any feedback on design or implementation details to ensure the class is as robust as possible.
#include <iostream>
template<typename T>
cla... |
(See also the continuation of this post.)
This time, I have a mapping type:
com.github.coderodde.mapping.Mapping.java:
package com.github.coderodde.mapping;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* This class implements a mapping from a domain set to a range set.
*
* @param ... |
Task description:
Implement a generate_unique_phone_numbers function.
The function shall parse the given text-file.
Content-example:
Trinidad Kemp,(838) 352-2212
Noel Bush,(647) 477-7093
Claudette Davila,(686) 868-8153
Shaun Mcbride,(433) 380-7556
Katy Blanchard,(792) 460-2468
...
Then return a Set with unique phone-n... |
I am working on a MERN stack app that is a CRM with a couple of modules. Now when the user sends x request to the server to do a supposed action (such as delete something), the server first checks if the user has access by checking the MongoDB database users' collection's permissions property for an array of "permissio... |
I built RESTFUL api for a blog using java and spring boot(without a frontend).
What it does
the code manages all the http methods on a post inside the blog and comments on that post.
the post consists of an id, name of the creator, title, body, amount of likes and dislikes, the comments are very similar they consist of... |
Cat
Hello everyone! I am working on this TUI framework which aims to abstract the ncurses library. I was wondering how understandable it is, and what I can improve! Any feedback is welcome!!
My framework aims to be easily extendible, while also being able to do what you want to do quickly so you can focus on your task.... |
I recently had an interview where I was tasked with implementing a custom C++ string class without using the STL. The interviewer provided the function signatures and variable declarations, specifying that the APIs and parameters were fixed and could not be altered. My responsibility was to complete the function implem... |
The task is a simple coding challenge I took part in. It is a spin on the two sum problem.
In the two sum problem you are given an validation sequence A and a test input I. I is valid if it's the sum of any two elements in the A. You can solve this in O(Nlog(N)) by first sorting A first, then using the two pointer tech... |
Here is a follow up on Reusable storage for array of objects, taking into account the provided answers.
The following code should be compliant at least with gcc, clang, msvc and for C++14 and beyond.
#include <cstddef>
#include <cstdint>
#include <functional>
#include <iostream>
#include <new>
#include <type_traits>
t... |
I recently started taking on the Gossip Glomers distributed systems challanges as a way for me to practice writing Go and learn something new. In order to solve one of the challenges, I had a request being delegated to a goroutine, which in turn retries sending the request at regular intervals until a response is recei... |
Here is a second follow up on Reusable storage for array of objects and Reusable storage for array of objects V2, taking into account the provided answers.
The following code should be compliant at least with gcc, clang, msvc and for C++14 and beyond.
#include <cstddef>
#include <cstdint>
#include <functional>
#include... |
I've just completed the generation of magic bitboard attack tables for bishops and rooks in my C++ chess engine.
Main Questions
The functions generateMagicNumbers() and populateAttackDatabase() take 4 parameters, and searchForMagicNumber() takes 5. Is this too many? Is there a way to improve on this?
calculateAttacks... |
I implemented a program for computing Conway's Game of Life iterations in Python starting from an initial grid configuration given as input. It is intended to handle arbitrarily large grids. I tried to be as concise and efficient as possible and it seems to be working appropriately. Are there any improvements I could m... |
VSCode's portable mode doesn't support auto-updates, unlike its normal installer-based versions. I happen to use MSYS2's UCRT64 environment which makes the Linux tools I like play nice with the Windows environment I need, so I wrote a script to do the updating for me.
I prefer zsh, but shellcheck doesn't support zsh or... |
So this is my header file (registry.hpp):
#pragma once
#include <initializer_list>
#include <memory>
#include <stdexcept>
#include <string>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#include "steering.hpp" // This just provides a Vec2d class (has x and y members) and a KinematicObject cl... |
I have a DataFrame (database_df) that contains the general record with the IDs that are the same team in each of the lines, containing these values I need to find in two APIs (api_1_df, api_2_df) that I collect the data if there is a way to find the same home team and the away team on the same line in both APIs.
When f... |
Based on a small suggestion here , this code tries to find lexicographically minimal rotation (question) by successively comparing two adjacent substrings in the very left , that can potentially give us the answer.
Note : Will refer lexicographically smaller char as smaller char and 0-indexing is used
Ex - "abbaad"
Fin... |
I want to perform statistical analysis and index subtitles that are stored in the WebVTT (Web Video Text Tracks) format. Before I can do that I need to remove duplicated text since each cue can contain text from previous cues.
This duplication is a side effect of making the subtitled words appear closer to when they ar... |
Here is a thirdfollow up on Reusable storage for array of objects, Reusable storage for array of objects V2 and Reusable storage for array of objects V3, taking into account the provided answers.
The following code should be compliant at least with gcc, clang, msvc and for C++14 and beyond.
In this version, I leave on... |
A bit of background:
Most often I am analysing data (mostly timeseries) of mechanical machine conditions (vibrations, temperatures...) that were acquired in different 'runs'. All runs were acquired over distinct non-overlapping periods in time. While they were all acquired in a common testing campaign with a certain sa... |
I've read this paper where they basically run a network backwards.
And decided to try. Luckily, many useful functions are implemented already in pytorch.
The main idea is this:
Write a convnet
Write a reverse convnet
Attach hooks to all layers and extract what we need
Train the convnet
Run the reverse net as well to s... |
I am making a hobby OS, and I thought about adding a command for interactively rendering the Mandelbrot set. The "interactive" part is not really important, but I wanted to check if the Mandelbrot algorithm is as good as it can be.
The most performance-sensitive part is the code inside the inner for loop, the one that ... |
We have a module which can be used by user to store and load value of variables. Every variable has an index associated with it (in the shown code cample this is ommitted and index is instead the data type) which refers to index in data table.
Shown code below is a minimum working example of what we currently have. To ... |
As a practice of implementing RAII-enabled class, I prepared a class called DynamicWallet that wraps around two raw pointers. I am well aware that using smart pointers instead of raw pointers could save a lot of hassles but the point of the practice is to get down to gory details so I would like to keep them. Given thi... |
I have to read console input and store data in the vector of structs. In case of any data format violation I have to print "Malformed Input" and return 1
Data format:
1 The first line is "#job_id,runtime_in_seconds,next_job_id"
2 The next lines are three comma separated integers (number of lines can be different)
Examp... |
I created a DDD aggregate for booking seats in cinema. Is it corect or it should be model in other way?
Business rules:
1.Seat can be booked at least 1h before screening
2.Screening can has only 1 active booking for seat
3.Booking can be cancelled at least 24h before screening
public class Screening {
private Long id;... |
I've designed and implemented a CPU architecture in one day. Of key architectural details: Processor is supposed to support updatable microcode, Architecture extensions and Is designed to be implemented sortof like a real CPU (at least in Logisim Evolution). As I was coding for speed, this 0.5 kiloline monster appeared... |
I have created a Typewriter component that animates a span to display text for my portfolio website. The goal was to have an array of strings that are cycled through and an animation that types them out and deletes them one character at a time.
My first solution was agnostic to the size of each string. The animation wo... |
I tried to do the Hangman Refactoring Kata for the piece of code over here - https://www.youtube.com/watch?v=-0MeoFTj6DU
This is how the initial code looks like after first set of refactorings (i.e. after refactoring + adding tests) - https://github.com/yadavvi91/hangman-kata/blob/f9db05fe38516d2fc23f2352c97dcfdf900d74... |
My project is a blogging app, which is a recruitment assignment. It is now finished and working.
Following function handles updating a comment votes, very similar as on StackExchange sites, preventing duplicated votes and ensuring single vote per IP address.
I am not sure how to make the following function unit testabl... |
I have recently started learning Rust and thought I'd start out with the classic Todo List application.
The application simply loops forever asking the user to type a number to do specific actions, and will quit if the corresponding action (in this case, 4) is pressed.
There are comments that I think are parts of the c... |
Took a shot at implementing std::shared_ptr, with a thread-safe refcount and weak count. Didn't do weak_ptr, I'm doing this for learning purposes, and I think from an educational standpoint there's not much to learn from adding it.
Also tried to implement the "we know where you live" optimization, with the control bloc... |
I have a 1D tensor of tokens that belong to different batches. The batch sizes here are uneven. Each batch needs to be multiplied with a corresponding weight matrix. My current approach is using a batch pointer vector and a series of distinct weight matrices corresponding to the unique pointers along with a for loop. I... |
To clarify: The code in "What I achieved" is working. I'm looking for suggestions so I can improve.
I'm quite new with JQuery (and javascript) and I've been learning while styling a forum. Recently I came across a section of information that is added automatically from a form (its the output). I can't manipulate the HT... |
I am a beginner who wrote this simple Hangman game in C for fun and to practice programming. I am looking for advice on optimizing this code and making it adhere to best practices. Are there too many variables, conditionals, and loops?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#includ... |
I'm trying to solve the following problem here:
First line of input contains the number of days D. The next d lines contains a character c and a number x. If c is B, then buy stock . If c is S, then sell stock x if it is present. If c is R, then ask if the stock x was present in his portfolio. For each of the days of ... |
I'm trying to solve the following question:
You have an array A of size n, containing −1 or 1 only, and s segments (not necessarily different). Each segment is defined by 2 integers li and ri (1 ≤ li ≤ ri ≤ n) and represent the subarray Ali, Ali +1 , ..., Ari of the array A.
A segment [li, ri] is called positive if ... |
There is a question to basically find the largest sum in an array, such that no two elements are chosen adjacent to each other. The concept is to recursively calculate the sum, while considering and not considering every element, and skipping an element depending on whether the previous element was selected or not.
I u... |
The following is my solution to Project Euler Problem 1: Multiples of 3 or 5.
use clap::Parser;
use std::ops::RangeFrom;
use std::process::exit;
const VALID_NUMBER_RANGE: RangeFrom<u64> = 2..;
#[derive(Parser)]
struct Arguments {
#[arg(index = 1)]
first_number: u64,
#[arg(index = 2)]
second_number: u6... |
I have written a function for casting between built in numeric types. I built it to check if the source value is within the range of the destination value, and to provide a nicely legible error if not. I also built it such that float -> conversions round instead of truncate and so that int -> float conversions do not e... |
I've wrote a code to scrape the Divar, which is an equivalent of Ebay in Iran. I have a few questions:
Am I doing the error handling and logging ok?
Is there a better way to optimize this code? (note that the API is limited to 30 calls in a minute for page retrieval, but isn't limited by the post retrieval)
What's the... |
I'm a newbie to python object oriented programming, Unfortunately in all the ways, Classes that I write turn into a true mess.
I'd be glad if someone would be able to point me some of my mistakes.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():
from decimal import Decimal
from typing import List
... |
I've been working on an assignment that involves optimizing a duplicate finding algorithm for sorted arrays, and I'd like to get your thoughts on the implementation. Here's the code I've come up with:
private static int findDuplicatesFinalVersion(int[] arr1, int[] arr2) {
int count = 0;
int index1 = 0;
int ... |
This is my Mandelbrot set program - it includes Smooth Coloring, perodicity checks, and my approach to biomorphs.
I know of Edge Detection, but I couldn't find a simple explanation that I can understand. Any help appreciated!
How do I optimize the Mandelbrot set plotting algorithm implemented in escapesmooth() and disp... |
I would greatly appreciate your feedback and review of our Spring Boot Azure Service Bus listener implementation. Your insights and suggestions will help us ensure its efficiency and reliability. Please take a moment to test it and provide your valuable feedback. Your input is invaluable in making our service even bett... |
I would like to improve the overall look and feel of the two log graphs generated by the Python code below. The first graph represents the optimized methods while the second graph represents the unoptimized methods. On each graph, the black curves represent Method A which has x as the parameter, while the green curve r... |
Please review this C++ listing of an implementation of Leapfrog integration.
Was the algorithm implemented correctly?
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <cmath>
#include <random>
// Constants for Argon
constexpr double epsilon = 119.8; // Depth of the potential well (in K)
constexpr d... |
I've created a Marketplace application on ruby on rails and would like to request a review of my code (Order Model) to check if I am in the right track or not...please kindly understand that I am a super webdev rookie and would really appreciate the kindness of the tech community to get useful advice and/or guidance. M... |
ShareImage is a project which lets you use an Image ("Template") and place text over it, to generate Social Media Preview Images, the ones used in the og:image tag. The project is available at the regraphic/si-rs repo. Here's the src/lib.rs file (which contains all the code):
use image::{DynamicImage, GenericImage, Gen... |
Currently I'm working with fastapi, sqlalchemy to connect to multiple databases. It checks params to ensure it has company_name, then will return the current table in that database, but if no company_name is set then it will return one record from each Table in the 2 databases.
class Params(BaseModel):
company_name... |
I wrote an n-dimensional convolutional neural network from scratch in Julia (check out the GitLab repo or the GitHub repo). It implements the following layer types:
Conv: convolutional layer
Pool: mean pooling, combine neuron clusters
Flatten: flatten output of Conv to vector
Dense: dense/fully connected layer
Even t... |
My code is working however it seems to be using old outdated php version so less secure and I'm still new to programming so I'd be more than thankful if someone shows me how an improved updated and secured version would look like
My code:
Login.php:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" c... |
In try to replicate the outcome of the following command sequence using php:
netstat -rn | grep "^0.0.0.0 " | cut -d " " -f10
I did this using a PHP script:
#!/usr/bin/env php
<?php
/**
* Xdebug ip detector for docker
* Copyright (C) 2023 Dimitrios Desyllas
* This program is free software: you can redistribu... |
I have designed and coded REST APIs to move the toy robot in 5*5 grid. Please let me know any feedback on improvements, etc
Complete Code here:
https://github.com/pkkht/RobotRESTApp
package com.robotposition.controller;
import com.robotposition.model.RobotPositionCommands;
import com.robotposition.model.RobotPosition;... |
I'm a DIY "dev" - so I really create things that I need or think they'll end up helping others.
I wrote this Swift Package so the iOS community could get device bezel radius' to help with UI design since it's not a value easily available.
In order to extract the data though it needs to run on a macOS system, with Xcode... |
I need a thread-safe counter that will see frequent increments but will be rarely read. This counter will be used to emit metrics, for example, the hit rate of a ConcurrentDictionary. I could use a simple Interlocked.Increment but it would lead to significant contention when written by multiple threads resulting in per... |
I just learned Python and Tkinter and I've just made a simple calculator using Tkinter for a small project at my school. It can do addition, subtraction, multiplication and division. I think that my code is hacky and not clean. How can I improve this?
import tkinter as tk
def button_0():
print("button 0 clicked")
... |
I've a raspberry Pico W and developed a simple stopwatch program in C. I configured GPIO pin 15 as an input and enabled the internal pull-up resistor. If the state is high, I will start the timer and print every second, if the state is low, I will stop the timer and reset the counter to 0. This is my code. However, I k... |
Task:
Sort the integers in sequence in sequence. But the position of zeros should not be changed.
Input: List of integers (int).
Output: List or another Iterable (tuple, generator, iterator) of integers (int).
Examples:
[5, 3, 0, 0, 4, 1, 4, 0, 7] => [1, 3, 0, 0, 4, 4, 5, 0, 7]
[0, 2, 3, 1, 0, 4, 5] => [0, 1,... |
I am a junior data engineer that have 3 years of experience with Python. I write a lot of Python code for my job and I came up with this question I can't solve by my own. I don't have the chance to have seniors developers to help at my job so let me asking you guys.
My question relates to simplifying functions. Basical... |
This post is the continuation of Mapping composition in Java.
This time, I:
Disallowed the null values as the range value.
Simplified the toString method via using the streams.
Code
com.github.coderodde.mapping.Mapping.java:
package com.github.coderodde.mapping;
import java.util.HashMap;
import java.util.Map;
import... |
The code below is modified slightly from the code in this previous post.
I believe the code below could be improved and more secured but i don't know how so someone please show me how an improved sample would look like
Validation.php
<?php
session_start();
$con = mysqli_connect('localhost','Bebo','Bebo');
mysqli_sel... |
Took a shot at implementing std::any. I think this should cover a majority of the functionality of the standard version, except there may be some missing auxiliary functions, and the overload resolution may not be exactly as is written in the standard.
#include <memory>
#include <typeinfo>
#include <utility>
#include <... |
So I've implemented the suggestions in Original question
And now my code looks like this:
<?php
require 'init.php';
$Email = $input['Email'] = trim(filter_input(INPUT_POST, 'Email'));
$Password = filter_input(INPUT_POST, 'Password');
$result = $db->execute_query("SELECT 1 FROM Users WHERE Email = ? && Password = ?", [... |
So I'm writing a Premier League score prediction app with Python, Flask and SQLalchemy and have almost finished the server side of it. I realised that no one has ever looked at my code and there could be plenty of mistakes that I simply never noticed. Also wondering if there is anything obvious that I'm missing (to do ... |
I made a Tetris game with C++ and ncurses. The game implemented the most core rules of the game such as 7-bag system or familiar rules you know about the Tetris, but lacks some features - for example, the game runs at same speed until it is over - for simplicity.
The code consists of four main classes - Block, Board, S... |
Please review this C++ listing of an implementation of Leapfrog integration.
This C++ listing is rewritten according to this review.
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <cmath>
#include <random>
#include <fstream>
typedef double real;
// Constants for Argon
constexpr real epsilon = 119.... |
I have lots of services which I am integrating. (also I am new to sql)
For each service integration I get different response,
For example, for zoom, I would just need to store the access_Token, for github, I would need to store the access_token and organization_idand asana would have something like "workspace_gid" and ... |
Parts
C++ Mock Library: Part 1
C++ Mock Library: Part 2
C++ Mock Library: Part 3
C++ Mock Library: Part 4
C++ Mock Library: Part 5
C++ Mock Library: Part 6
Note:
If you see an extra T on a macro ignore for now.
I will get to this in a subsequent review. There is to much for one review so I will do in stages.
Example... |
I'm doing a daily reward system on my site.
Users can pick up the reward only once a day. The next reward can be picked up the next day, also, only once.
When a user visits the site to pick up a daily reward, I put a timestamp in the database (e.g. "2023-09-15 15:36") when the user picked it up. The number of consecuti... |
I have been learning rust sporadically for a while now and decided to write some toy projects. While browsing https://github.com/codecrafters-io/build-your-own-x I came across some bittorrent client examples. As they contain many moving parts like parsing, networking and multithreading it seemed like a good idea for a ... |
Now i have a fully functional PHP codes for login and registeration i was wondering if anyone could offer improvements to the code
The code:
Config.php:
<?php
return [
'db' => [
'hostname' => 'localhost',
'username' => 'Bebo',
'password' => 'Bebo',
'database' => 'Bebo',
'port... |
Parts
C++ Mock Library: Part 1
C++ Mock Library: Part 2
C++ Mock Library: Part 3
C++ Mock Library: Part 4
C++ Mock Library: Part 5
C++ Mock Library: Part 6
Removing redundant MOCK_SYS usage
After writing a bunch of unit test we see a pattern emerge. The lambda's we are using don't actually do much and most of the ti... |
I have used this approach in my Golang MongoDB REST APIs' DAO layer, I need to clarify whether this is a good way or not, code is as follows,
func CreateUser(user *models.User) *commons.RequestError {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
DB := connections.C... |
I'm mostly trying to understand why the simpler char array mask below (to track which digits have been already used) is much faster than the one 16 bit uint mask along with intrinsic ops. On Ryzen 3700x, compiled with "-O3 -march=native", this version takes only 1.02 secs for 10 million calls, whereas the commented out... |
I have written this code for serializing and deserializing integer and floating point numbers to/from vector/array of bytes. The aim of the code is to provide a simple interface to use, but make it as readable on the caller side as possible (e.g. not allow hiding type conversions).
This code doesn't cover runtime valid... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.