instruction stringlengths 71 95.1k |
|---|
Took a shot at implementing std::deque in C++. I aimed for amortized O(1) push_front and push_back, O(1) pop_front and pop_back, and O(1) random access.
I do this by maintaining two vectors of pointers to fixed-size blocks of size 16, called front_blocks and back_blocks. Initially, push_front operations add to the bloc... |
Is there a chance to implement the code below better with the features of recent C++ versions?
Functional specification
Having a large text and already built prefix array find the longest substrings (limited by the number of repetitions) getting benefit from already existing prefix array, if reasonable. Provide the ver... |
original code:
import, hide some irrelevant company package
import cn.hutool.core.date.LocalDateTimeUtil;
import java.lang.reflect.Field;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.binding.MapperMethod;
import org.apache.... |
A standard beginner problem is to determine whether a particular input is palindromic, i.e. reads the same in reverse as it does forwards.
I thought it might be fun to provide a distinctly non-beginner solution to this problem, so here's a version that is hugely over-engineered for a homework answer.
#include <algorith... |
I recently started learning python and came up with this solution to the "Chess Dictionary Validator" exercise which is given in the end of chapter 5 in the book "Automate the Boring Stuff" by Al Sweigart:
In this chapter, we used the dictionary value {'1h': 'bking', '6c': 'wqueen', '2g': 'bbishop', '5h': 'bqueen', '3... |
I needed to unpack a byte into the LSBs of each byte in an 8-byte integer. After some testing, I derived a surprisingly efficient and elegant solution that uses magic numbers multiplication, though this is nothing new. Upon further investigation I found a similar solution, and from that I have adopted another.
My first... |
Let's say I have data like this:
DATA = {
"Alfa-1": {...},
"Beta-1": {...},
"Beta-2": {...},
"Delta-1": {...},
"Delta-2": {...},
# and so on
}
I want to perform extraction, but I want the key to also support the "glob" syntax.
So if I specify ["Alfa-1", "Delta-*"] it should return the data points for "Alfa... |
This package is a part of a web application which is an internal company tool. This web application may need access to a number of secretes stored in hashicorp vault. The secrets rarely change, although in case they occasionally do there is a UI button to invalidate the secrets cache so it could be reloaded. I felt tha... |
This is intended for temporary ad-hoc changes to logging config, for example when debugging etc. Also included are functions to easily manipulate config from a code (for example at the beginning of a given program's main method or from @BeforeClass JUnit method).
I'm looking mainly for reviews of the API design (whethe... |
import numpy as np
def eliminateCol(A, k=0):
# guarantee that A is float type
if A.dtype.kind != 'f' and A.dtype.kind != 'c': return None
# load dimensions
dim0,dim1 = np.shape(A)
# initialize outputs
swap = np.identity(dim0,dtype=float)
oper = np.identity(dim0,dtype=float)
# k < dim1
... |
A single directory should simply be backed up with the zip tool, and the time of the backup should be preserved in the file name. I have written a Posix shell script for this.
Can this script simply be converted into a .bashrc alias?
#!/bin/sh
if [ -z "$1" ]
then
echo "No argument supplied"
exit
fi
fn=$(echo ... |
The following sample code is for finding DIGIT_WORDS and their first occurrence in sentence line (Rust Playground)
fn main() {
const DIGIT_WORDS: &'static [&'static str] = &[
"one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
];
let line = "threehpbsevenffnqgdjcftjkdjhhk7dvzmkm... |
Update
I have posted a sequel (here) with my prototype for the "missing piece": the combination and propagation of variable names, especially within nested c(...) syntax.
Background
After wrangling one too many lists of column names, I sought an analog in M for tidyselect in R. I call it Selex, and its purposes are t... |
I'd like to preface this by saying firstly, my code is absolutely nowhere near complete, and secondly that I am essentially brand new to coding and this is my first real project.
I like to be thrown in the deep end and so have set myself the challenge of making a chess AI using machine learning. I'm still in the logic ... |
I am trying to implement the Iterable interface on an object, where the hasNext method on iterator will depend on mutable object state. This state is mutated by explicit function call after call to each next. Basically I am doing such implementation to keep it consistent across multiple implementation.
First implementa... |
a C-Squares encoder in Julia.
FYI, C-Squares is a geocoding algorithm that assigns GPS coordinates to a spatial grid with a chosen resolution. Its specifications is here: https://www.cmar.csiro.au/csquares/spec1-1.htm
intended usage:
# random coordinates
LATITUDES = 180 .* rand(50) .- 90
LONGITUDES = 360 .* rand(50) .... |
I have implemented the sieve of Atkin in Rust. It can find all primes till 1,000,000,000 in 4.5 s using 34.4 MiB on my 1.4 GHz machine. This is a direct implementation (with some optimisations made from empirical observations) of Atkin and Bernstein's paper. Here, sieve is Vec<u16> in which the ith element indicates wh... |
So I need a PRNG in Python and JavaScript that yields the same results, which is the reason I can't use the built-in methods. It doesn't have to be very good or even cryptographically secure, since it's only for generating mock data for tests.
The algorithm used is the very short one by George Marsaglia described here.... |
I'm interested in a fast 8x8 32-bit float matrix multiply in Rust, assuming availability of AVX2. After learning about the AVX2 intrinsics, here is what I came up with:
pub unsafe fn mm8_simd(c: &mut [f32], a: &[f32], b: &[f32], lda: usize, ldb: usize) {
use std::arch::x86_64::*;
let av0 = _mm256_loadu_ps(a.get... |
Your opinion interests me regarding this program.
This program encrypts a text message using the AES256 algorithm and CBC.
It allows the creation of an encrypted message that contains:
The salt used for the creation of the AES256 key
The salt used for the creation of the derived key used for calculating the HMAC for m... |
Recently I needed to support someone who wanted to ingest some data from on of our API's but had tooling that struggled with the authentication bit. While I'm sure there are some off-the-shelf products that could have been made do somehow, I decided to take this as a learning opportunity to learn Rust and create a smal... |
Mobile development is quite new for me, and I would like to ask about a solution review. I'm not sure the way I publish the application is correct, I think good companies may do it differently.
I have two environments: development and production. For each environment there are different URLs for API services. I publish... |
This is a follow-up question for A recursive_foreach_all Template Function Implementation in C++. I am trying to implement recursive_all_of template function in this post.
The experimental implementation
recursive_all_of Template Functions Implementation
namespace impl {
template<std::ranges::input_range T, class... |
In my current project there is a lot inter dependency between different structs, so instead of having Arc<Struct> as members for each of the dependent Structs. I thought of using Singleton Design Pattern to get the instance of that Struct in the impl block. This is a sample code that I've written. I would like to know ... |
THE TASK
We are dealing with a string of symbols and need quick responses to queries of the following types:
What is the position of the k-th occurrence of symbol X in the string?
Reading from position k to the right, which symbol do we encounter first, X or Y?
How many X symbols are there between positions i and j?
... |
I am a "new" coder to Python - saying this because I got stuck in the tutorial hell - and I saw that doing projects was a way of consolidating what I had learnt from those tutorials, so here I am.
I made a little rock paper scissors game, and I am kind of a novice when it comes to making my code effective. So please be... |
Suppose that I want to subdivide a bash script into small idempotent functions, and I also want that those functions can depend on each other. For example, assume that I want to configure_Y and configure_Z, but they both require that I install_X.
I would like to do something like this to express dependencies between X,... |
I have a malware detection system that includes a subsystem responsible for IBAN checks. Initially, this subsystem needs to load and parse data from a specific URL. Subsequently, it checks whether the IBANs are present in the blacklist.
I opted to write separate utility classes for the blacklist and IBAN checks. These ... |
My deployment and configuration process entails multiple processes trying to invoke dpkg on my VM at the same time. While dpkg has a locking mechanism, it causes anyone not holding the lock who is trying to acquire it to fail, as opposed to blocking.
I want blocking behavior, so I renamed dpkg to dpkg-exec and am using... |
In Dungeons and Dragons, when one puts on multiple magical items, all of its effects will take place. These effects are to be cumulative, so if Girdle of Strength adds 2 to one's strength, and a Helmet of Power multiplies
one's strength by 1.5, then wearing both will have both changes (and the order does matter), and ... |
I’m trying to implement, for educational purposes only, an example of the Postel’s law on a demonstrative function.
This function is not for production code, it’s for pedagogical purposes only and might be considered as an over abstraction to an easy to understand list comprehension. This isn’t the topic I’m interreste... |
Without ping-pong websocket connections are usually dropped by intermediary proxies/routers after some time of inactivity, so you can't go make yourself a coffee because your chat connection will break by the time you come back ;-] (most browsers such as Chrome or Firefox currently do not do any automatic pinging and t... |
This is a follow-up question for A recursive_all_of Template Function Implementation in C++ and A recursive_count_if Function For Various Type Arbitrary Nested Iterable Implementation in C++. Besides recursive_all_of template function implementation, I am trying to implement recursive_any_of and recursive_none_of templ... |
I am using the Advent of Code 2023 to study functional programming and the ranges library in C++. This code is for the second part of Day 3 and is the best solution using FB I've created. I'd appreciate comments or advice on how this code might be improved.
The input for the problem is:
467..114..
...*......
..35..633.... |
I am inexperienced with writing multithreaded applications, and I am trying to wrap a ConditionalWeakTable (CWT) for use as a generalized container type. I'm aware that CWT is thread-safe, but I want to synchronize access to the table with other operations in the collection without locking. This is my attempt so far:
p... |
I built a project in which I provide a string input or a whole matrix to configure a frame, create a bunch of different frames and push them into a queue and finally print them in order of the queue.
I would like some advice on how to improve the design of the frame class as I feel it became a spaghetti code. I'll be h... |
I have written a .Net Client wrapper for Google Gemini (Generative AI) REST API and published it as a Nuget package. I am seeking a review of the code.
I have spent quite some time in designing how it is right now, so kind of out of ideas but I am certain that it needs lots of improvements. I aim to incorporate best co... |
This is the second iteration of the Fast search for the longest repeating substrings in large text code review. Special thanks goes to G. Sliepen who conducted the first review.
Functional specification
Having a large text and already built suffix array find the longest substrings (limited by the number of repetitions)... |
I wanted to make certain panels have their own custom border color, and the only way to accomplish this (as far as I know) is to manually subscribe every individual panel to a paint event that changes the color, and call it that way.
Eventually, half the code is going to look like this, which isn't very friendly and is... |
I'm an autodidact working on map coloring algorithms with backtracking, see chapter 2 of this book.
I tested this implementation with success but I'm still unsure whether it is tricking me somewhere, or if I could improve it.
Color = int
def paint(graph: dict[Node, list[Node]]) -> list[tuple[Node, Color]]:
"""An i... |
The code in question is in GitHub here. arm.h, armconstants.h and arm.cpp. Here are the key passages:
arm.h
class Arm {
public:
Arm();
void setup(ros::NodeHandle& nh);
String getState();
void armCommand(String command);
void armCommand(String command, float arg);
void loop();
private:
Adaf... |
For a school project I've created a database program in COBOL and now that I'm finished, I have to write a report on the project.
As one aspect of the report, we have to discuss whether the product (the program) achieved all of the "success criteria" we created earlier in the process. One of my success criteria was cod... |
Its been done to death, but the particular prompt (see Assignment 4) guiding me has strict+simple requirements that lead to a nice reduced environment to critique poor form. The project implements a heap-based binary tree structure with insert, find, and remove functions.
Both the binary tree nodes' IDs as well as data... |
Background
In an earlier post, I prototyped an M equivalent of tidyselect in R: in particular, its general syntax and selection helpers. In this post, I prototype a syntactic engine for combining and propagating field names.
Challenge
The M language has two "near misses" for imitating a vector in R: essentially a homo... |
I made this code to encrypt a string with the One Time Pad method. Is this pythonic code, and are there obvious ways I can improve?
The program accepts a plaintext and can either accept an inputted key or generate one itself. It adds the key and plaintext character by character, keeping it within the bounds of the stri... |
This is a wrapper I wrote for math.random(). I have a larger program that will create a JSON file to 'load' from when I want to resume. However my program heavily used math.random() which made it hard to debug and test the program because different results would occur depending on if the program was started fresh, or f... |
So I have been working on different projects in Scratch, and I decided to make a jumping mechanicproject here using both blocks that are normally accessible and hacked/hidden blocks.
Now here is how I am defining a jumping mechanic in a game for this project:
There must be some defined area where the player can land. ... |
This is a follow-up question for recursive_any_of and recursive_none_of Template Functions Implementation in C++. I am trying to follow the suggestion of G. Sliepen's answer to implement recursive_find_if_all template function in this post.
The experimental implementation
recursive_find_if_all Template Function Implem... |
I would appreciate a review of the following Rust implementation of high performance matrix multiplication.
After reviewing available literature, including Anatomy of High Performance Matrix Multiplication paper and How to Optimize GEMM, I came up with an implementation that performs very poorly compared to publically... |
I use the following code for a manual single value decomposition using numpy. Depending on the array I choose it sometimes works out well and I can verify the svd and sometimes it does not work out straight aways and requires a sign flip.
Code
import numpy as np
array = np.array([[-3,3,6],
[3,8,7]]) ... |
So I've decided to flex showcase my "enum that accepts strings etc..." here.
I don't know if it's great but I'm pretty sure it's decent. It is implemented in less than 200 lines of code (not counting boost helper macros), while something like magic_enum is thousands of lines of code.
An enum-like structure is created f... |
This is my first java program. I'm coming from a python background. This is a text based combat arena game.
Are there any ways I could better implement the overall code structure?
How might I improve the math of the attack() function?
It prompts the user for a hero name, then generates hero and enemy objects of the c... |
Some (skippable) context:
I'm writing program that minimizes an arbitrary logical function. Such function takes an unsigned integer as an argument and returns either true or false.
The input to my program is a list of all values for which the minimized function returns true. Those values are called "minterms".
Because ... |
Objective:
The goal of this script is to tokenize and print out all the words from the provided bible.txt file.
Constraints:
It should differentiate between 'U.K' and 'UK.' when removing extra symbols from the word.
It should exclude duplicates.
It should exclude words that contain digits.
Existing code:
#!/usr/bin/e... |
I'm relatively new to C programming and currently tackling exercises on Advent of Code. The challenge I'm working on involves calculating the sum of integers within each group from a file and identifying the top 3 groups based on their sums.
Here's an example of the input format:
group1 value 1
group1 value 2
group2 v... |
I think the only big improvement that can be made is to check which shard to query based on the userIds of the followed users. One easy way is to check the last number of each userId (0,1,2,3,4,5,6,7,8,9) and then find which shard I need to query if I have 10.
Besides that is there anything wrong?
I am wondering if it ... |
Relatively new to C++, not sure if I'm doing everything right, any advice would be appreciated. The site does not allow me to post this question with that little actual text, so I am artificially extending it with this dummy text. Here's what I wrote:
#include <iostream>
template<typename T>
class DefaultPointer {
... |
The M-Shell (msh) provides a basic command-line interface similar, and features some builtins (cd, exit, help, whoami, kill).
#ifdef _POSIX_C_SOURCE
#undef _POSIX_C_SOURCE
#endif
#ifdef _XOPEN_SOURCE
#undef _XOPEN_SOURCE
#endif
#define _POSIX_C_SOURCE 200819L
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <st... |
Introduction
I have this GitHub repository (version 1.0.0.). It implements a rank(i) operation in \$\Theta(1)\$ time, and select(i) operation in \$\Theta(\log n)\$ time.
(This post has an continuation post, version 1.0.1.)
Code
com.github.coderodde.util.RankSelectBitVector.java:
/**
* This class defines a packed bit ... |
I have to implement a class with method that takes document:
struct TDocument {
string url; // document identifier
uint64_t pubDate;
uint64_t fetchTime;
string text;
uint64_t firstFetchTime = 0;
};
The method should return document with updated fields according to the following rules:
text and f... |
I'd like to know if I'm doing this badly or involving any antipatterns. Masterlist.json contains a list full of all of the posts that exist and should be fetched on the page. Post metadata is extracted with matter.
Would it be better to map to a <Post /> component and to pass in all the information that way?
For more c... |
I wrote a Vector (dynamic array) class with an iterator usable with std::sort() . It seems to pass my tests.
I wondering about the issues one can spot on this implementation. I compiled with C++17.
#include <iostream>
#include <numeric>
using std::cout, std::endl;
template<typename T>
struct Vector
{
struct Itera... |
This is the third iteration of the Fast search for the longest repeating substrings in large text (Rev.2) code review. Special thanks goes to G. Sliepen who conducted the first two reviews.
Functional specification
Having a large text and already built suffix array find the longest substrings (limited by the number of ... |
I've got an open-source project that I've been working on for a while, and I'm looking for advice on handling large classes. It's a Laravel 10+ package for building forms, and everything works fine, but every time I look at these field classes, I feel like there could be a better way or that I might be doing this ineff... |
Since initial question Increasing binary search for mismatch in sorted range contained defects in code and can confuse the readers, here is the updated version of the question.
Is the code below correct and efficiently implemented to solve the following task? Can this code be improved with reuse of other C++ Standard L... |
C++ Standard Library functions like std::tolower, std::isalpha, etc. could be quite slow when it comes to large texts and handling locales.
So, I decided to have fast tolower function, caching the values. They are blazingly fast.
Assumption: nobody will intentionally try to hack the code, trying all possible and imposs... |
I'm working on making a matrix math object that's as generic as possible. I currently have done multiplication. I've run into a decision I have to make, but first, here's the code.
namespace MatrixMath
{
/// <summary>
/// Matrix is a class designed to do math on matrices for you.
/// Matrix methods assume t... |
In fact, this is a throttling proxy.
It can work in two modes: "paired" and "multi-Client".
In "pair" mode, two clients connect to each other through a proxy, very similar to a p2p network, this is the BrokerPair class.
Data sent by the first client passes through the proxy and is delivered to the second client.
The sa... |
I recently had this (admittedly slightly crazy idea) on how to design a building block that can be used in safe Rust to build self-referential structs. Unlike gsrs or selfref it works completely without macros. I will present my idea next, my question is mainly if it is indeed impossible to create UB from safe code usi... |
I wrote a function that accepts a destination vector and a vector of all the types that are currently available. Its job is to iterate over all the available types (strings) and for each type, if it's required, the respective derived class should be added to the vector. I also want to enforce a constraint that only one... |
I am new to the FastApi world. Can somebody review my below Fast API design? It is working but doesn't follow FastApi conventions. I find it much cleaner and follows layered architecture taking inspiration from Java Spring-boot landscape. What are pros and cons of this desing.
routes -> services -> crud -> models and u... |
I need help optimizing the performance of this, which is essentially similar to the traveling salesman problem, with the addition that I want to make the graph complete first, with the weight of the new edges depending on the distance (it is also crucial for me to pass every node once and just once, which is also why I... |
This is in Star Basic but most likely quite a few languages would have similar structure.
I am comparing rows in two sorted sheets. I have a comparison function which returns -1 / 0 / 1 similarly to StrComp() depending whether the row passed as the first argument is before / equal / after the row passed as the second a... |
This is a logic to create sessions on RoR 7.1.2 based on the last version of the website which was in vanilla PHP, with the upgrade I have to deal with the users that were already signed up but not have a password_digest attribute on his database just a password hashed by PHP which RoR with the gem Bcrypt cant understa... |
I need to insert many million rows + many GB of data into a database for a project that uses Spring boot. I recreated a minimal example with a one to many relationship and am trying to find the fastest solution. The full code is here: https://github.com/Vuizur/springmassinsert, but the rough structure is:
// Email.java... |
I read a book named Effective SQL and found this interesting part.
Enforcing and maintaining business rules and relationships in
the data is part of the data model, and the responsibility belongs to the database, not the
application program. Data rules should be separated from the applications in order to ensure that
... |
Just wanted some code review for correctness here. This is a little app for plotting newborn feeding data (important to keep track of in the first 48 hours of so) that I hope to provide to a clinic, but I wanted some extra eyes on it if possible before doing so (important to get this right!). We have the times of the ... |
I am new and only know the basics of C++. Any help will be appreciated. I want to know how to make my code less lines, more efficient, proper practice and play better.
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstdio>
using std::cout;
using std::cin;
using std::string;
using st... |
I tried to create simple application, yet I encountered problem with relationship using Core Data in SwiftUI.
I have 2 simple models, ParentEntity:
public class ParentEntity: NSManagedObject, Identifiable {
static func fetchRequest() -> NSFetchRequest<ParentEntity> {
NSFetchRequest<ParentEntity>(entityName:... |
I am currently developing a C++ OpenGL game engine to help myself learn computer graphics and game design later on. However, this project is becoming really big, and I am unsure if I am making the correct design choices with the code. Parts of the code are also becoming harder to add to, especially the parts that deal ... |
This is a competitive programming problem which has never been solved in Python within the time limit of 2 seconds. It is about Disjoint Set Union:
Source: Algorithms In Context #10: Disjoint Sets
Description:
The input comes from a text file with 100 test cases defined by a few million of numbers. The first line of e... |
This is a function that checks if a valid FAT12 image would be created. Since all the information to create it is available on the "boot sector", this is the parameter. I wanted the code to be pretty readable, but I may have overdone it.
fat.h
/* This file defines some FAT structures, and functions for validating a FAT... |
I made an extension and got it to the point where it does what I want how I want. At this point, I have a little capacity to work on code refactoring, readability and such. And I would love some feedback from more senior JS devs.
The extension does multiple different and sometimes not very connected things, all aiming ... |
previusly I make a post for Session Logic for User Verification in Rails Migration.
Now the improvement version following advice of the comments is here.
The problem was the use of `` for executing in shell on a RoR application when making the log in. I remove it and change for system method.
module Shared
extend Act... |
I'm semi-new to programming and want to improve my skills by understanding how people might optimize their code and how the code should be structured since I've been told it needs to do more than just work properly.
It gets the brightness of each pixel and the darker the pixel, the denser the ASCII character it writes ... |
A combination of various css transitions (background-color, box-shadow, opacity, transform) and getComputedStyle method of window object made up an effect resembling dust scattering that takes on the color of the dusty element.
<html>
<head>
<style>
.centered {
bottom: 0;
left: 0;
margin: auto;
pos... |
This is a follow-up question for A recursive_find_if_all Template Function Implementation in C++ and A recursive_all_of Template Function Implementation in C++. To support std::string, std::wstring, std::u8string and std::pmr::string (making recursive_all_of template function more generic), I am trying to implement rec... |
Can someone review the code for this dodging game I made a while back? I want to see if there are any improvements or optimizations I can make as I am more or less a Python beginner.
# A basic dodging game in Pygame
import pygame, sys
import numpy as np
from pathlib import Path
pygame.init()
# Defines window size
wi... |
Have been using std::variant for the first time.
Accidentally stumbled on a pattern that seems resonable but wanted to get a second opinion.
I have a class that can contain value (its for another language simulation). To represent this in C++ I though the value can use a variant and thus I can retain type safety. But n... |
Background:
The program reads 1000000 lines in the file. Every four line will be parsed into an object in a vector. If it has 2 objects with the same name, it will drop 1 object and increment one of the field in another object. After that, the vector is required to sort out. Finally, it writes to output file.
The main ... |
I've implemented a Collison Manager using the Separating Axis Theorem (SAT), and I'm looking for suggestions to enhance the performance of the Minimum Translation Vector (MTV) calculation. The collider works well, but I want to explore potential optimizations, especially in the MTV calculation process.
I'm particularly... |
Verse is a command-line program that allows you to retrieve specific verses
from the Quran. It takes a chapter and verse number as input and provides you
with the corresponding Quranic verse.
Dependencies:
libcurl
libjansson
strtoi.h:
#ifndef STRTOI_H
#define STRTOI_H
typedef enum {
STRTOI_SUCCESS,
STRTOI_OV... |
I'm refactoring a code-base in React, and our design team have decided to move a button out of its usual flow and instead to a component that's very much not a descendant of the logic.
I'm relatively new to React; however, if I was doing this in Blazor I know I could just create a singleton object and use dependency in... |
I am relatively new to C programming and am currently completeing challenges of Advent of Code 2021 to elevate my skills. I am excited to share my solution for the puzzle on Day 3 and am eager to receive constructive feedback to enhance the quality of my code.
Problem Summary
The problem is divided into two distinct pa... |
The colorproof dust effect could be enhanced with positionproof feature getting the position of the dusted element (dust container) from its getBoundingClientRect method additionally to a combination of various css transitions (background-color, box-shadow, opacity, transform) and getComputedStyle method of window obj... |
(This post is the continuation of Bit vector in Java supporting O(1) rank() and O(log n) select(). It resides here (version 1.0.1).)
Basically, I have implemented everything harold suggested, except faster bit-shuffling in select(i). This time, rankThird is guaranteed to run in \$\mathcal{O}(1)\$ time, and selectThird ... |
I wrote a simple PHP login form for a website. It has an initialization script, as well as a form to allow a user to login, plus a link to log the user out after logging in.
lib/app_init.php
<?php
declare(strict_types=1);
require_once 'config/db.php';
try {
$db_conn = new PDO(PDO_DSN, DB_USER, DB_PASS);
$db_... |
I have written a Python program to parse the Master File Table located by //?/X:/$MFT.
Of course trying to open it normally will result in PermissionDenied. I got around this by open(f"//?/{drive}:", "rb"), and get the starting cluster of $MFT and read the first 1024 bytes starting at 4096 * cluster count.
I wrote this... |
I use a lot <cctype> functions, but they're not very type safe and
and calling them with a negative char is (theoretically) undefined behavior,
so my code is cluttered with static_casts like:
[](const char ch){ return static_cast<char>(std::tolower(static_cast<unsigned char>(ch))); });
So I started to write a simple w... |
This function takes a file path to a PDF file, and a search string(s). It spits out a count of the number of times the string(s) shows in the PDF. Any ideas how I can make it faster?
It can be tested with any PDF (not password protected.)
I frequently use this to scan a list of words in a large number of PDFs and it is... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.