Tagged Questions
A generic term meaning the process by which text transformed into a more meaningful or clearer output. A typical example would be the transformation of a decimal into a particular currency format with the correct number of decimal places.
1
vote
2answers
25 views
3
votes
2answers
57 views
Function that strips trailing '0's from a float
I'm writing an embedded application in C, and at one point I need to convert a float into an ASCII representation of that float, so I can send the ASCII over a serial port. The protocol the serial ...
1
vote
0answers
24 views
Simple login script
This is a simple login script using Bcrypt. Is there anything wrong with this code? It works and my page loads O.K, but could this be optimized for better speeds?
...
5
votes
1answer
61 views
K&R 1-20 Solution
I'm currently reading the infamous K&R C book and trying to solve Exercise 1-20. My solution looks kind of too simple, but it works. I've searched the web for different solutions, but they all are ...
2
votes
1answer
37 views
Displaying a String array in tabular format
I have an array of strings called theArray. All strings in theArray are of length 20. I wish to display this array in tabular ...
4
votes
2answers
163 views
Converting all cells to text
Microsoft Excel cells basically have two values: the formatted value that is shown to the user, and the actual value of the cell. These two values can be extremely different when the cell has certain ...
1
vote
1answer
53 views
Remove non-printable characters from string in Python 3
My aim is to print bytes string lines in Python 3, but truncate each line to a maximum width so that it fits the current terminal window.
My first attempt was only ...
3
votes
1answer
54 views
Type safe variadic cout implementation
I use console a lot, so I thought this may help me. It's supposed to be simple, safe, and fast. Any ideas?
http://ideone.com/INXub0
...
4
votes
4answers
185 views
Helper function to format-output any type of variable
This question has already got some reviews, so I could partially improve my code: please look at my self-answer below, which also contains comments about the review.
I'm frequently interested to ...
6
votes
2answers
92 views
Prime multiplication table
I am new to Ruby (1 year as hobby project on weekends) and solved a code challenge and it was not as good as they wanted. I want to know how i could make it better and how to make the structure ...
15
votes
4answers
680 views
Generating formatted multiplication tables in C++
I am self studying C++ from Robert Lafore's OOP in C++. I am solving the first exercise questions of chapter-3 loop and decisions. I've written three different codes using different approaches. I want ...
4
votes
2answers
87 views
Colorful output on terminal
I went from manually outputting escape codes in each string to creating a utility struct/class full of static functions and variables that needed to be initialized in source files (static private ...
2
votes
1answer
48 views
Basic JSON Representation in Rust
This week I started reading "The Rust Programming Language". As I reached the chapters on enumerations and pattern matching I felt I had enough material to put together a simple representation of JSON ...
3
votes
1answer
62 views
Timestamp function with millisecond precision
I want to be able to print timestamps with milliseconds precision and time_t doesn't provide this. I also want the code to be portable, so operating specific ...
8
votes
0answers
138 views
+200
Printing binary trees
After writing this answer, I was inspired to try to design a more elegant solution to the problem of printing binary trees. And what better tool with which to seek elegance than Clojure?
Overall ...
4
votes
1answer
77 views
Preventing numbers from showing up in scientific notation
We have a StreamBuffer class which is not inherited from std::ios_base (or some of it's derivatives such as ...
-3
votes
2answers
37 views
Display calendar using a loop
Desired output:
Can I get an shorter version of this code? My instructor just wants me to figure it out my self.
...
4
votes
2answers
63 views
Library assistant
HackerRank currently has '7 days of JavaScript' going, a quick intro into the JavaScript language. Every day a couple of challenges will be made available. One of the challenges of today was this:
...
4
votes
1answer
76 views
Syntax highlighter for HTML and PHP
I've created a JavaScript application to highlight the syntax of HTML and PHP. I know a lot of syntax highlighter are available nowadays, I just created to extend my knowledge in JS and regular ...
-1
votes
1answer
59 views
5
votes
0answers
175 views
Document formatting markup engine in Postscript
I've been rewriting this same sort of thing off and on over the years, but finally here's the "perfected" monstrosity. Some kruft in the middle with attempting to predict the number of spaces that ...
6
votes
1answer
43 views
Printing a nested data structure in Clojure
I wrote the following code which transforms a nested data structure
...
1
vote
2answers
49 views
Converting an angle in degrees to a pretty string representing it in radians
Given an angle in degrees, output a pretty string representation of its value in radians as a fraction.
Where pretty means:
Simplified as much as possible.
With no unnecessary ones.
Using the ...
8
votes
1answer
204 views
Pretty printing degrees input to radians
I'm mostly concerned about edge cases, although I think I dealt with them all. Improvements on code quality would also be much appreciated.
...
4
votes
3answers
167 views
Use va_list to format a string
I wrote a function that basically works like sprintf, but instead returns the formatted string (std::string). I haven't worked ...
2
votes
1answer
36 views
Printing an array in columns
I'm trying to define a function which takes an array and prints it to a predefined total width in as many columns as needed. Think of the way ls prints files for ...
6
votes
1answer
47 views
Convert data back-and-forth between CSV files and pretty-print
I wrote a script to convert CSV files in human readable format and vice versa.
Human readable format is achieved like so:
...
0
votes
2answers
71 views
JLabel formatting on GPA calculator
I am currently working on a GPA Calculator side project over holiday break to become more familiar with Swing, but I find the number formatting is more complicated than in regular Java. At the moment ...
14
votes
2answers
116 views
Formatted print without the need to specify type matching specifiers using _Generic
This code allows printing in C with a style similar to C++ ostream. By using _Generic() (see ...
15
votes
2answers
336 views
K&R 1-21 write an “entab” program
From K&R 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. ...
11
votes
4answers
487 views
Function to format the local time
This is a statement that I use a lot in my code base:
(LocalDateTime.now()).format(DateTimeFormatter.ofPattern("ssmmHHddMMMuu"))
Should I create a static method ...
4
votes
3answers
568 views
Format of hexeditor
Is there a cleaner way to write this code? It's the start of a hexeditor I'm creating.
I'm aware that the variables aren't descriptive, this is just a test run for when I imbed it into a File ...
2
votes
2answers
34 views
Parsing users from a list of commands for email notifications
I want to make a list of the last words on each line of a file that looks like this:
...
3
votes
2answers
76 views
Print multiplication tables
Write a function that given a max argument will print a nicely aligned multiplication tables, for example, if max = 8
...
4
votes
1answer
61 views
String formatting of unit types
I have a units of measure library that I added string formatting to. Here is sample code:
...
4
votes
6answers
167 views
Centering a line of text
I need a procedure that "centers" a string inside a string that is consecutive characters of a fixed length. For instance,
...
7
votes
1answer
55 views
Function to wrap words in a text editor without breaking them
These are 3 functions I created in C language to read in a text file, remove the carriage returns from it in order to display on the screen, and display the file on screen wrapped with the words of ...
3
votes
1answer
59 views
Formatting “Bond, JAMES (Mr)”
I need to call this function over a big dataset. I need it to be as efficient as possible but still be readable. Can I make it anymore efficient by using a different function for capitalize or blank ...
2
votes
1answer
46 views
Printing polynomials
I am taking a class on ruby and our assignment is to take user input and print out a polynomial. Wondering if I can get any feedback to how to improve my code.
...
2
votes
3answers
36 views
Perl code that breaks a line after fixed number of columns
Here is a simple program that I created to print a file by breaking it after a fixed number of columns. I feel it can be optimized but not sure how. Any feedback is great.
...
7
votes
5answers
592 views
Normalizing `DateTime` values to strings
I have this as part of a project to normalize DateTime values to more readable strings, localized to the relative time in the past that they happened.
It allows ...
1
vote
2answers
197 views
Number to german decimal format converter function [closed]
I have a function that formats a number (even a float) to a German decimal format. I got this function from here ...
2
votes
1answer
105 views
A Scala script for beautify scientific notation strings from Excel
Excel renders scientific notation in the engineering fashion, e.g. “4.2E-5”. That’s OK, but when you are writing a scientific paper, it’s likely that you want it to look like this: “4.2×10⁻⁵”.
I have ...
2
votes
2answers
79 views
Updating a clock display with the time
Originally, I was going to post a question about how to condense four repetitive functions into a single function, but I wound up figuring it out myself before I could even post it.
However, the ...
5
votes
1answer
73 views
Using changeable column formatting to display table
When answering python tuition calculator v2, I got a little carried away, and started building a print_table() function which I don't like the resulting code for, ...
3
votes
2answers
57 views
Aligning text in Haskell
This Haskell program just aligns the text lines on the given substrings.
I took inspiration from here, but my code is not golfed.
...
7
votes
1answer
372 views
Replacement string Base64 (and a Base32) conversion [closed]
This provides (my own) implementation of ToBase64String and FromBase64String (since the .NET implementations suck), and a ...
1
vote
0answers
78 views
Parse a plain text newsletter and show it with nicer markdown formatting
I wrote some code to parse an e-mailed events newsletter I'm on and redisplay it with better formatting. I like the output, but I'm not thrilled with the code. It feels like there's a lot of ...
8
votes
1answer
74 views
Stream manipulating indenter
I've always wanted to be able to steer stream indentation, so that I could write code like this:
...
3
votes
1answer
145 views
Phone number format and data entry restriction
I created a form that formats phone numbers, allows only allowable keys to be pressed, and converts a lettered entry into its corresponding phone keypad number. Is there some cleanup or better coding ...