Skip to main content

Questions tagged [converting]

Converting involves changing data from one data type or format to another.

5votes
1answer
118views

Replacement for 'enum class' with string functionality

Because I think maintainability can be done better with strings instead of plain enumerator-values when doing fstream IO, I wanted a replacement struct in my project that behaves like an ...
ScratchingTheSurface's user avatar
2votes
0answers
161views

PHP Parser and converter - SOLID and DRY

I am working on a PHP application that transforms data from the input CSV (JSON, TXT, or XML) into an output CSV (JSON or database, for example). The output format differs from the input: some columns ...
friday-json's user avatar
8votes
1answer
770views

library for converting numbers to HEX

This is library for fast converting "HEX strings" to unsigned numbers and vice versa. The result is not defined, if input is incorrect, e.g. string "ZZZ1" will be converted to ...
Nick's user avatar
  • 1,594
2votes
1answer
67views

How better methods of remaking the code by array without changing its functionality, and performance but reducing amount by ~10 times

Can anybody help me with examples of code? How is the approach to optimize code relative to my example with using "switch case" to "arrays"? Without changing its functionality, but ...
Vladistone's user avatar
0votes
1answer
293views

WordPress Plugin for WebP/AVIF Image Conversion

I'm looking for feedback on a WordPress plugin I developed for automatically converting images to WebP and AVIF formats. The goal is to optimize image loading performance. The plugin has the following ...
KermitTheFrog's user avatar
1vote
1answer
105views

safe numeric type converter

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....
Diederick C. Niehorster's user avatar
1vote
1answer
294views

C++ arbitrary base convertor

This is my second C++ program. Again, I wrote it all by myself. I only started learning C++ yesterday. The concept of the program is simple; it should read input from ...
Ξένη Γήινος's user avatar
4votes
2answers
489views

fast convert string_view to floating point

The code makes following assumptions: std::string_view is not null-terminated there are no exponents, all floating point inputs are in the way 123.123 limiting ...
Nick's user avatar
  • 1,594
1vote
0answers
87views

Python script that turns a gigantic text file into an IP geolocation database

I have written a Python script that turns a gigantic text file into a SQLite3 database. The text file is truly gigantic, it is 133MiB or 140,371,572 bytes in size, and contains 140,371,572 characters ...
Ξένη Γήινος's user avatar
5votes
1answer
722views

Python script that identifies the country code of a given IP address

This is a Python script I wrote to identify the country code of a given IP address, using data obtained from tor. It uses geoip.txt to identify country code for IPv4 addresses, and geoip6.txt to do so ...
Ξένη Γήινος's user avatar
5votes
1answer
2kviews

Convert bool to int and int to bool

I'm a noob. I wrote this code to convert bools to ints and ints to bools as a past-time but I would like to know whether to continue programming - this is the kind of thing I've been doing, no useful ...
user avatar
4votes
1answer
228views

Fahrenheit <=> Celsius converter in Rust

It's one of the tasks suggested in the Rust Programming Language book by Steve Klabnik and Carol Nichols, and to a complete Rust newbie like me, figuring out converting scale from ...
szychy's user avatar
6votes
1answer
221views

General bytes to number converter (c++)

I've written a bytes to number converter for cpp similar to the python int.from_bytes. It does not make any assumptions on: The endianness of the input buffer The ...
Sam Coutteau's user avatar
2votes
2answers
2kviews

Mapping pandas' Series to dataclasses

I've got something really simple this time where I'm mapping pandas' Series to dataclasses with a oneliner helper function (as ...
t3chb0t's user avatar
  • 44.4k
2votes
3answers
362views

length unit converter

I'm trying to make a imperial/metric length unit converter in Python. Here is my full code: ...
Rozy0930's user avatar

153050per page
close