instruction stringlengths 71 95.1k |
|---|
A bit of context:
I have 100 addresses that can send transactions to a blockchain, and I have a web app that works like this:
Get request and handle it in a thread
Get a free address from the queue
Send a transaction
Return address to the queue
It's important to know that one address cannot send two transactions at o... |
Relatively new here so please let me know if I'm doing something wrong.
I'm mostly wondering if there's any additional way I can make this code more efficient. Specifically the moveset and win condition part of the code feels unnecessarily long or overcomplicated. Still a beginner in python, so any feedback regarding ... |
I have a table that in one of the columns exists a list of file names. The names comes from other tables and the files in a folder.
Not all the files are used, may be attached to parcels that no longer are active. My list is of only the active parcels.
After creating the table I want to go through the folder of files... |
I am implementing a library (Linux) and I created some functions to block new instances of a running program and I was wonder if there are some better improvements for it.
Here is a program which describes what I am trying:
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>... |
I've written a simple web scraper in Python. As it is my first venture in Python, I'd like to ask for a code review from more experienced coders. All input is welcome.
A little bit of background:
I'm a huge fan of video games. In Japan, there is a company called Media Create which tracks all sales of games and consoles... |
I created a graph to show the change in the percentage of questions answered over time. The first version fetched data from chat transcripts using PHP. The sub-domain I have registered for my webspace doesn't offer support for HTTPS so the calls to file_get_contents() would fail when run there. Because of this, I start... |
I've been using flask-jwt-extended for my application and one of the problems I had was logging a session out and making sure the token is not usable anymore.
I've based my solution on the Blacklist and Token Revoking documentation page with a custom RevokedToken model:
from flask_sqlalchemy import SQLAlchemy
db = SQ... |
I have a large data frame that I want to merge with another dataset. In order to do so I need to get the names of individuals into a certain format. The function below converts the name in 'column' to the desired format (mostly) and stores it in newColumn.
My question is, is there a better (faster and/or more pythonic)... |
I was wondering how efficient my code is creating custom indexOf for strings in JavaScript using regex instead of looping with a for statement the whole way in most solution I find and I believe this got \$O(1)\$ since no loop is needed.
The idea is to use regex that put either the key or any list of word that is not k... |
This is a programming exercise from chapter 8 of a C learning book by K N King. The program should prompt a user for a message, and return it after translating it to B1ff speak. e.g A->4, b->8 etc
The program works as asked in the exercise, however how can I create a more efficient declaration of the message[] array? C... |
I have question regarding best practices. I've decided instead having config inside either app.config or xml file to have my config file inside SQLite file database. This config will contain basic information for specific class. Config will be managed from SQLite database browser. My question is is it fine assuming tha... |
So, I'm building export/import CSV helper. I have some performance issues in the code below. it takes me to parse CSV of 25,000 rows at 7 seconds.
If someone can help, it will be awesome!
public System.IO.Stream ParseContent<T>(IEnumerable<T> entities) where T : class
{
if (entities == null)
... |
As in classical bin packing problem, this is an algorithm that optimises the number of bins of a certain size used to hold a list of objects of varying size.
In my variant I also work with a second constraint that is the bins must hold a certain minimum size in them. For example :
max_pm = 10, min_pm = 5 ; If we input... |
I'm required to perform a slight conversion on a string which contains html.
The conversion should transform a elements such that they become span elements. The conversion should also place the href attribute from the original a element into the span.
I have what I think is a working solution, but the code feels overco... |
I wrote the Game Of Life algorithm with Go. There are a million ways that we can implement the algorithm, but I want to know is it implemented in good-way or not?
I wonder how can I improve the performance and the code quality?
package main
import (
"math"
"math/rand"
"strconv"
"time"
"github.co... |
Almost like this question here, I'm playing with some methods that may fail, but in my case, the method failing is not a exceptional case; it just means I need to try running it again.
The method I'm writing is inherently stochastic, so running it multiple times yields different results. Some are valid, some are invali... |
I'm working to implement some simple bigint functions for addition, multiplication and powers. They work correctly but the larger the numbers the longer the time it takes.
For example 210000 takes a very long time.
Here are all the functions I'm using.
char *ft_strnew(size_t size)
{
char *temp;
size_t... |
Given a camelcase string and an index, return the subword of the string that includes that index, e.g.:
find_word('CamelCaseString', 6) -> 'Case'
find_word('ACamelCaseString', 0) -> 'A'
My code:
def find_word(s, index):
for i in range(index, 0, -1):
if s[i].isupper():
left = i
break... |
The problem: find and return the first nonrepeating character in a string, if the string does not have a nonrepeating character return an empty string. For purposes of finding the nonrepeating character it's case insensitive so 't' and 'T' appearing in the string would imply that that 't' and 'T' are not candidates fo... |
On looking at the components(separatedBy separator: String) -> [String] method from the Swift Standard Library, I tried to come up with an implementation just for practice. Your comments are welcome to improve the same. Thanks.
Input:
func main() {
let sampleString = "Do not be sorry. Be better."
print(sampleS... |
The task:
You will be given several lines of messages containing data. You have
to check for the validity of the lines. A valid line should be in the
format: ""s:{sender};r:{receiver};m--"{message}"
sender – could contain any ASCII character except for ;
receiver – could contain any ASCII character except for ;
m... |
I wrote my first project in Python and I would like to know if this is correct. I prepared some guidelines I want to ask. (I know that I don't have any documentation yet). In the future I want to extend my project about new algorithms such as search, crypto, machine learning, hashes, graphs and so on. Also, I would lik... |
Problem: find the number of distinct quantities of money that a pile of coins can make.
The vector coins contains the values of the coins, and the corresponding vector quantity contains the number of coin there are (let's say coins = {1} and quantity = {5}, this means I have 5 pennies).
Although I have solved this p... |
This is a solution to Advent of Code Day 13 (problem specification, test input), for which I was asked to read a layout of tracks and mine carts and detect 1) where the first crash would occur and 2) where the final remaining cart would be after the rest had crashed.
The tracks consist of:
spaces: there's nothing there... |
I think Ruby is kinda interesting, so did this Game of life implement in Ruby. I am wonder is there is some magic in Ruby can let my code more elegant.
I am a python coder and I think my Ruby kinda smell like Python now xD(and with lots end)
def lifegame(grid)
alive = 1
die = 0
while not lifeless(grid, ali... |
I am new to Java and had some difficulty creating this simple Publisher Subscriber class. It finally seems to be working and I wanted to check if I have been following best practices and see if there are any improvements I can make.
The following Java class accepts any topics as a string (e.g. "rand_int") and forwards ... |
This is my first attempt at React and I don't want to pick up any bad habits for the long term. The code is adopted from a example app, but I have added a fair amount of new features. I.e.
Clicking on the item allows it to be edited
Delete Option
Option to mark the items as Complete / Uncompleted
Any feedback would be... |
This question is a small subset of the problem I am trying to solve.
I am trying to learn to break problems into better abstractions.
The original problem I am trying to solve is:
Write a JS library which allows an user to select an Image and then divide the image into square tiles. Calculate the average color of each... |
I wrote a program as an excercise, to check the openpyxl module, which inserts blank rows into an excel file. See the docstring in the code for more description.
I would like to know what you think about the code.
Is it easy / difficult to follow?
Is it structured good / bad?
What can be improved?
blank_row_inserter.... |
I've implemented Luhn's algorithm for checking credit card numbers.
My code works, but I wanted to learn about a more efficient and more Pythonic way of doing this.
def validate_credit_card_number(card_number):
#start writing your code here
#Step 1a - complete
temp_list=list(str(card_number))
my_list=[... |
Has everyone moved over to CSS Grid and/or Flexbox? If not, I've maintained and evolved this system over a fair amount of time, the concept was derived originally, I believe, from Mary Lou, although I don't recall where the article is.
I was never a proponent of floats, although the using font-size:0 to clear whitespac... |
We have been given a list of strings which are blacklisted. The goal is to identify if a given text contains any of these blacklisted strings. The restriction here is that the blacklisted string needs to match on the word boundary e.g. consider a blacklist string "abc" and text "abc pqr", the text in this case is unsaf... |
There is a Min-Heap implementation in Java. BubbleUp() and BubbleDown() could have been coded using recursion but I prefer without recursion. Would there be a major difference if had used recursion?
package heap;
import interfaces.queue.PriorityQueue;
import java.util.Arrays;
import java.util.stream.Collectors;... |
In Algorithms Fourth Edition by Robert Sedgewick and Kevin Wayne, the exercise 2.2.10 states that:
Implement a version of merge() that copies the second half of a[] to
aux[] in decreasing order and then does the merge back to a[]. This
change al- lows you to remove the code to test that each of the halves
has be... |
I saw a question about prime factorization on Stack Overflow and realized I had never attempted it before. This was what I ended up with after some playing around and tweaking.
I'd like improvements on anything here.
I know I could use a sieve instead of the naive method (I may switch later), but it was sufficient her... |
I was asked this question and got no feedback, so I'd like to ask you for any feedback on my solution, Thanks!
Think of an audio sample as a rubber-band that you want to pin to a musical time ruler. The pins are called Warp Markers. A Warp Marker locks a specific point in the sample (in sample time) to a specific place... |
I am self taught, so I'm consistently seeking ways to code better, and more efficiently. If anyone has the time, please advise me on what can be done better with explanations as to why the old method is considered inefficient, and why the new method proves to be better. Also, where I can implement more self explanatory... |
I'm doing a simple calc for my school. The code looks okay to me, but I'm not sure if there is something to improve, but probably there is always something to improve. Any ideas how to make it look and work better?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Thread... |
I've been playing around with functional programming and testing with jest recently.
An issue I've run into, is that it's hard to mock ES6 module exports directly. See this Stack Overflow question for more details.
The solution I've come up with is to inject the dependency functions into the function that is calling it... |
Given a Linked List of integers, write a function to modify the linked
list such that all even numbers appear before all the odd numbers in
the modified linked list. Also, keep the order of even and odd
numbers same. - (from geeksforgeeks: Segregate even and odd nodes in a Linked List)
Example:
Input:
3
7
17 15 ... |
Let's assume we have the following situation:
Multiple project topics exist, each corresponding to a natural number n,
students can sign in and choose two projects and give them either priority_1 or priority_2,
The name and the time when they sign in is tracked as well.
With all of the information above assume you r... |
The end result of this is to allow a user to log in and/or register themselves for a dice game. Please post some suggestions for improvement.
import pickle
logged_in = False
with open('users.pickle', 'rb') as a_file:
users = pickle.load(a_file)
login_or_signup = input('do you want to login or signup? ')
# sign ... |
This isn't so much, HOW do I make it work, as this code works, rather how could I make it better. The way this code works is it guides a person to the correct answer by getting "Yes", "No" or "I don't know" (in some cases from the person).
It's intended to run in HTML5/JavaScript (kind of like an online interactive gui... |
Similar to this question, here's another implementation. Assume the input is already a set.
(defn powerset
[set]
(reduce
(fn [xs x] (concat xs (map #(cons x %) xs)))
[()]
set))
|
I am attempting to, given two dimensions (width and height) which represent a quadrilateral, partition that quad in to N parts where each part is as proportionally similar to the other as possible.
For example, imagine a sheet of paper. It consists of 4 points A, B, C, D. Now consider that the sheet of paper has the di... |
This is my quicksort
There are many like it but
This quicksort is mine.
So, quicksort, in C, with a big framework to test it six ways from Sunday. Passed the tests nicely, but there may be warts, or subtle mistakes I didn’t think of, or code that’s hard to follow, or just better ways to do things. Have at it.
EDIT: For... |
Goal of the program
The goal of the program is to translate a nucleic acid sequence into its corresponding amino acid sequence. The nucleic sequences
have to be formatted in a specific format called fasta. There is an existing implementation of this program in C here: emboss transeq
Fasta format
A fasta file looks like... |
There is an implementation of Binary Search Tree. This is kind of based on Set Theory that duplicates are not allowed but an attempt to adding the same node twice will replace the older node.
BSTNode Class:
package nodes.treeNodes.binaryTreesNode.bstNode;
import java.util.Iterator;
import java.util.LinkedList;
import ... |
A little bit about myself: I am 18 years old, a student living in Germany and currently working on an android app.
I would like if someone has the time to review my code. I am especially interested if this code has any vulnerabilities and if the efficiency could be improved. Thanks in advance :)
import javax.crypto.*;
... |
I've created a script using Python in association with Scrapy to parse the movie names and its years spread across multiple pages from a torrent site. My goal here is to write the parsed data in a CSV file other than using the built-in command provided by Scrapy, because when I do this:
scrapy crawl torrentdata -o out... |
The following script is part of a further education I'm currently enrolled into.
Not all of the code is written by myself. Function signatures for example. Therefore I have put the sections, written by myself, put into # -- Own ---- comment-lines.
Moreover you were given three CSV-files with business data from differen... |
Here is MaxHeap implementation in pure JavaScript:
/**
* We initialize index 0 because, calculations for finding
* children of a node and the parent of a node is easier
* parent = [ k/2 ], children: [ k*2, k*2+1 ]
*/
class Heap {
constructor() {
this.queue = [0];
};
/**
* Bottom-up rehea... |
Part of the program I wrote simulates a Chess game choosing random moves for each player until it's a draw or win for either player. It takes 3 seconds to complete 1 simulation and since it trains this way it will be much too slow to get real progress in chess because of the insane branching factor.
I tried dividing th... |
I have written an implementation of the Strassen Vinograde Algorithm, but it's running slowly because of recursive creation of static arrays. I know that dynamic arrays would solve this problem, but I'm not allow to use them. So the main idea of this version of Strassen: We use corner elements of each square instead of... |
I needed some data structure for holding Uris so I thought I try the Uri class. It quickly turned out that it's very impractical because:
it's missing an implicit cast from/to string
it doesn't automatically recognize uris as absolute or relative without specifying the UriKind
it doesn't parse the query-string so it c... |
There is a Java program to check if a Heap (Min) is in the correct order. Heap Order means the parent is less than both left child and right child.
package testers;
import heap.Heap;
import java.util.List;
public class HeapTester
{
public static void main(String[] args)
{
Heap<Integer> heap = new Heap... |
I am trying to create an event system that would be quite easy to use. The idea is that a user would only need to create a custom function and tell which event should fire that function. It works as is, but I was wondering if there is a more efficient way to accomplish this of which I'm not aware.
The main classes of t... |
After my last review request, I decided to try and make a "tree" visualization, and thought that I could benefit from making find-prime-factors lazily produce prime factors so the visualization can be updated in real time as factors are found.
This is what I ended up with. I was actually surprised how easy it was to ad... |
I'm attempting to create a function that will select the correct carton based on the qty of the carton content.
Here are my cartons that have the number of items they can hold:
SMALL_PASCAL = 300
BIG_PASCAL = 600
BABY_BOX = 1200
A485_1201 = 1800
A4140_1901 = 3000
A485 = 5000
And here is the method that will return t... |
I want to return all of the permutations of an integer in Swift.
var outputArray = [[Int]]()
func perms ( _ input: [Int], _ output: [Int]) {
if input.count == 0 {
outputArray.append( [ Int( output.map{ String($0) }.joined() )! ] )
}
else {
for i in 0..<input.count {
let current... |
I wrote the Sierpinski’s Gasket Triangle in JavaScript, but I feel the code can be better, especially from L32 to L47. Could you make it more organized?
var canvas = document.getElementById('chaos');
var ctx = canvas.getContext('2d');
const GenerateRand = () => Math.floor(Math.random() * 7);
const updateDot = (x, y,... |
It was suggested I place this code here. I had posted it on StackOverflow for a kind of review.
I have tried to generate Hamming numbers using primes but the speed of the generation slows the higher the number generated and the prime list grew proportionately. I then started to find if a number could be factored down t... |
Here is code implementing Passport authentication with a Google Strategy. It uses Mongoose to store and retrieve user data.
You might need to be familiar with both of these technologies to review this code if not check out the two links I provided.
I have included only the Passport file. I was told I am not using promi... |
Program:
I have designed a program in python that does the following (in order):
Webscrapes google trends for the most popular searches
Stores the searches and traffic of the searches in an in-memory database along with a timestamp
Finds the trends that no longer exist (I.E the trends that are no longer in googles to... |
The idea is that I have a subset of the movements of material of a factory (over 700k rows), and I want to separate these movements by the reference of each product to plot the stock of each product over time.
But the dataframe has repeated days, and the stock at the end of every month (STOCK FINAL) is in another dataf... |
After some research I found the following information: In this closed question I found a solution which does not work well when pop-up has height bigger than screen (and some jquery solution). Here is a question about showing outside page in popup. And here are some theoretical and angularJS solutions. However, those a... |
I have a class which represents some translations of a keyword.
public abstract class Name {
private String name;
private String name_de;
private String name_it;
private String name_fr;
private String name_hu;
private String name_cs;
public Name(String name_key, String name_de, String nam... |
I'm trying to read a text file formatted as in this example:
5 3
3 1 5
6 6
6 1 3 2 5 4
Where the lines are coupled, with the line above always being of length equal to 2 and the line below having length equal to the the last digit in the line above.
(Unfortunately this is from an old note I took and I don't remember w... |
I have the following script to find files containing a certain string and then report on the location of the file along with the size in bytes.
It works, but I seem to have made heavy weather of finding the string which involves a fair bit of tidying up afterwards to produce some clean output.
Any idea how I could mak... |
This function's goal is to reduce the length of a sentence to exactly max_length characters by cutting each word in the sentence to a length of minimum 4 characters, if cutting each word to 4 characters isn't enough the the sentence is returned anyway.
All sentences are free of special characters and words are separate... |
I'm generating a URL (in string) that depends on 3 optional parameters, file, user and active.
From a base url: /hey I want to generate the endpoint, this means:
If file is specificied, my desired output would is: /hey?file=example
If file and user is specified, my desired output is: /hey?file=example&user=boo
If user... |
I am trying to solve Project Euler Problem 224:
Let us call an integer sided triangle with sides a ≤ b ≤ c barely obtuse if the sides satisfy a2 + b2 = c2 - 1.
How many barely obtuse triangles are there with perimeter ≤ 75,000,000?
For large v_max and v_max_n, the generator below yields very slow when I have 75000000... |
Follow-up question: Display all files in a folder (object) along with nested subdirectories part 2
Task: Given a main directory/folder, list all the files from it and if this directory have other nested sub-directories, list files from them also.
Background history: short story long - I got an internship, no past exper... |
I've got a .csv file with ZIP codes containing the city and its sub-districts
67401,City 1,district_a
67401,City 2,district_b
67401,City 3,district_c
67401,City 3,district_d
67401,City 3,district_e
67401,City 3,district_f
67401,City 3,district_g
67401,City 3,district_h
67401,City 3,district_i
67401,City 3,district_j
6... |
This is refactored and much more expanded version of the script reviewed here. The whole authorization process is added.
import os
import secrets
import string
import time
import webbrowser
import furl
import requests
import simplejson as json
import config
URL_CODE_BASE_VK = 'https://oauth.vk.com/authorize'
URL_CO... |
I am working on a math library for an online game. I want to prevent as many errors as possible and I want to catch all errors as early as possible to simplify debugging in the long run. However, I feel like I drown in details. This is quite different from "let it crash" motto.
point has {number(), number()} type or be... |
I'm coding for fun with the secret ambition of making a fun little game for mobile. So I started out building this little jumping game with Javascript and jQuery.
The game relies heavy on css transformations to do the animations. This way it is not nessecary to do the hard animations work by javascript. I suspect it i... |
I tried to make a MVC in PHP with OOP approach. Code Review this so I can understand whether am I using the best practices and can I legally call it a MVC framework or not. Also, I am going with 1 controller for each action.
This blockquote might help you review my code better.
The default thing is actually works like... |
I am using Python threads to download images. I have a JSON file that contains URLs to the images in the following structure:
images = {'images: [{'url': 'https://contestimg.wish.com/api/webimage/5468f1c0d96b290ff8e5c805-large',
'imageId': '1'},....]}
There are over 1,000,000 images. After using 20 threads, I onl... |
Annother little excercise with openpyxl:
Say you have a Excel file like this:
The Goal is to make make it look like this:
My code to acomplish this:
inversion.py
"""
Inverts the content of table row and columns
"""
from copy import copy
import openpyxl
from openpyxl.utils import get_column_letter
def save_workboo... |
Here is how I'm detecting a field separator and line break in a CSV file for which I do not already know the format. Does this look sufficient, or are there other things I should be adding here?
SEPARATORS=['\x00', '\x01', '^', ':', ',', '\t', ':', ';', '|', '~', ' ']
LINE_TERMINATORS_IN_ORDER = ['\x02\n', '\r\n', '\n... |
I've been reading around how golang writes to a file, and this stack overflow question and this reddit question highlights the fact Go doesn't gurantee atomicity when writing to a file system. Although I didn't see any interleaved writes (which I guess could be due to writev(2)), I didn't want to risk it so I built a a... |
I implemented an algorithm that takes only sublinear extra space as required in the exercise description:
Develop a merge implementation that reduces the extra space
requirement to max(M, N/M). (dividing the array into N/M blocks of
size M).
def insert_sort(a, lo, hi):
for i in range(lo+1, hi):
j = i... |
I have been doing OOP and imperative programming my whole career but I wanted to dabble in Scala along with functional programming. Rather than writing Java like code in Scala I wanted to try a more functional approach. I decided to try a simple Kata with Scala, Game of Life. The following is what I came up with. I adm... |
I am refactoring my existing product's webapi part of the solution. Current Repo pattern does not allow me to add custom functions to a specific repository. In result, most of the functions directly use the Db context in the controller.
I read various articles and come up a good way of implementation to achieve my targ... |
This is the simple game of hangman. Guess letters and six wrong letters means you're dead.
This took me about 20 hours. And I learned enough to be certain I could make something better now in half the time. Still, give me your honest (and brutal) opinion, since that will help me improve the most.
<?php
//init
... |
I want to create a function that unpacks nested dataclasses and namedtuples (or a combination of both)
my attempt
I found this answer about how to unpack a named tuple, and i am simply extending it:
the unpack function
def unpack(obj):
if isinstance(obj, dict):
return {key: unpack(value) for key, value in ... |
I am creating a test class for the following code. splay_test.py which is the unit test code for splay tree. I needed help with writing unit tests for python to get %100 coverage. I am very bad at unit testing but have started off ok. just need someone to help me finish it off and maybe find any more bugs. My coverage ... |
I have project on Django wich use Django Channels. I use Django Channel for sending notifications to users who are subscribed to articles changes (adding/editing/deleting comments on article).
So I've chosen this way of realization: every group of channels is an article and when changes happen, script sends notificatio... |
Today I tried Bonobo + SQLAlchemy (for the first time), so it's bound to be full of bad practices. However, this is working code. I'm hoping for some feedback to for doing it correctly.
I started out using the SQLAlchemy extension for Bonobo, but I ran into limitations, so I wrote my own loader. My DB is SQLite3, so it... |
I was trying my hand at learning Elixir via ancient adventofcode puzzles and was trying to write a function to satisfy this requirement:
It contains a pair of any two letters that appears at least twice in
the string without overlapping, like xyxy (xy) or aabcdefgaa (aa), but
not like aaa (aa, but it overlaps).
H... |
I recently started coding and after learning a bit about functions and basics I tried to make a simple text escape room game. My code is working and the game functions as intended but I now there are probably neat ways to reduce the long amount of code using techniques I haven't yet heard about. I would really apprecia... |
I have a function that's doing this correctly, but I feel as though this can be done (possibly) with minimal code, with recursion, but I'm just wracking my brain. Basically I have JSON that gets decoded to an array. What I want to do is turn this:
{
"parentView": {
"childViews": [
{
"type": "contai... |
I'm working in a Tableau driven system, with large numbers of charts, I needed a way to reduce the strain of the initial load of our app. It's fairly simple, but wanted to ensure I accounted for every scenario, I don't generally utilize lazy loading.
Print isn't a priority.
jsfiddle: Demo (Tableau doesn't work within S... |
Lets say you have several .txt files in a folder and want to merge all text files into a single Excel document:
A.txt
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
A11
A12
A13
A14
A15
A16
A17
A18
A19
A20
A21
A22
B.txt
B1
B2
B3
B4
B5
B6
B7
B8
B9
B10
B11
B12
B13
B14
C.txt
C1
C2
C3
C4
C5
C6
C7
C8
C9
C10
C11
C12
C13
C14
C15
C16
C17
C18... |
I use a Thymeleaf template to inject a set of files (which contain precalculated HTML) into one big HTML. The files with their metadata are stored in a map called files, the files content is stored in another map called content. Both maps share the same key which is basically an id of the files.
The relevant section of... |
This method add all numbers in list and return it as double
public HashMap<String, Double> add(HashMap<String, List<? extends Number>> map){
HashMap<String, Double> result = new HashMap<>();
map.forEach((key, value) -> {
Double sum = 0.0;
for (Number num : value){
sum += num.double... |
I asked about an abstraction layer for accessing files (link) a couple of days ago (I decided to not call it a follow-up anymore as there are too many changes). I tried to incorporate many of the ideas from the feedbacks but it wasn't easy. In the meantime I noticed that what I'm actually doing is nothing else but CRUD... |
I need to upload images to a remote HTTP server from a local script. The image name format is {32-char MD5}.jpg. Server directory format is 6c/d3/6cd3556deb0da54bca060b4c39479839.jpg. So, for example, if I upload the image called 6cd3556deb0da54bca060b4c39479839.jpg, it should be available at https://example.com/6c/d3/... |
I am making a library where I need to generate a unique ID for a type where the ID must be known at compile time. I first relied on the address of a template function, but it proved itself unreliable both with MSVC and Clang on windows.
Then I came up with the address of a static data member inside a template class.
I ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.