instruction stringlengths 71 95.1k |
|---|
I'm trying to create pages for multiple content types in Gatsby and I was wondering if this is the right approach:
My gatsby-node.js file:
const path = require(`path`)
const { createFilePath } = require("gatsby-source-filesystem")
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = a... |
So for a class project, I have to figure out the most efficient way to draw on a canvas.
First thing that came to mind was using moveTo and lineTo repeatedly following mouse cursor, and thats exactly what I did.
I also added a strange "liner" pen which draws lines outwards from a point (side effect of bug, which I then... |
I wrote this function to fill a list with object based on the desired index they should have.
Here the func:
def fill(lst, index, add, fillvalue=None):
'''Fills a list with the add value based on desired index'''
'''Let the value in place if present... |
Terminology:
Host - Spectator and summoner of players involved in the 1v1 matches
Player - A player who is participating in the 1v1 matches
Phantom - A player summoned for a 1v1 (present in the host's game)
Summon - Bringing a player into the host's game (where the host can spectate the match)
Concept:
The goal of this... |
INTRO
About SNMP
SNMP stands for simple network management protocol. It is a way that
servers can share information about their current state, and also a
channel through which an administer can modify pre-defined values.
SNMP is a protocol that is implemented on the application layer of the
networking stack (click her... |
I'm writing the following program for a school assignment. The prompt is as follows:
A magic square is square grid filled with distinct positive integers such that each cell contains a different integer and the sum of the integers in each row, column and diagonal is equal.
My task is to make a boolean method, named m... |
I have created the below code which works for me, but I feel there might be a better way to accomplish this in a new Pythonic way or better Python syntactic way.
Code snippet:
bondCheck.py
#!/usr/bin/python
# Port bonding checker.
# cat /proc/net/bonding/bond0
import sys
import re
def usage():
print '''USAGE:... |
Here is a simple web crawler I wrote in Python 3 that counts the words in each page in a domain, displays word count per page, and sums them up.
Tested on a multitude of web pages, works correctly so far.
What do you think of my code?
import requests
from urllib.request import urlopen
from bs4 import BeautifulSoup
bas... |
The function below is part of an overall chunk of code to partition an array of size M into sub-arrays of size N. The function in question is written to handle the case: what if M isn't divisible by N? Then, the way the rest of the code works, the last element in the partitioned array might have fewer than N items. ... |
I have a table called tblStudent having data as
I want to retrieve records having single value compared against multiple columns. For example -
find all students having Grade 'C' in any of the subjects.
One way could be -
SELECT * FROM tblStudent
WHERE Grade_Maths = 'C' OR
Grade_Science = 'C' OR
Grade_English = 'C'... |
I am learning graph theory and I have implemented a Directed Graph with weights in Java. My next objective with this class is to learn more about algorithms like Dijkstra, Bellman-Ford, etc. I have split the implementation into two classes - GraphNode and DirectedGraphWithWeights.
GraphNode.java
public class GraphNode ... |
I was given the exercise of refactoring the following code, thus ensuring it was following the SOLID design principles. It refers to an Animal Park, where there are a couple of different species of animals, and it defines the rules in which these animals can eat other animals. The Animal Park class processes a polymorp... |
I think the algorithm implementation itself is reasonably efficient, but I'm not sure about proper use of good practices in software development in the code (variable naming, idioms, comments, error handling in inputs etc).
I'm attempting to get a first developer job, and since interviewers also evaluate how "clean" th... |
I'm a C Beginner and I am looking for feedback on my implementation of a singly linked list. The code is split between list.c and list.h.
list.h:
#ifndef LIST
#define LIST
#include <stddef.h>
typedef struct List {
int val;
struct List* next;
} List;
int list_len(List* head);
void list_insert(List* head, int va... |
I've been working on a parser for shop receipts which extracts data about the payment. Here is the text that I'm parsing:
* Vic107Payment
Text: PINNEN
TicketData: POI: 12345678
KLANTTICKET
--------------------------------
Terminal: ABC123
Merchant: 123456
P... |
Im making an application that i want to have the ability to send report emails with a frequency. daily, weekly or monthly.
Now i want those emails to be sent only if the app is running and if the user is using it (in my app you use the mobile as a kiosk, you open the app and leave it running all the time, screen will ... |
Here is a simple variant type I have made. For simplicity, it only can handle two different values. I am planning on using this to create a variadic variant template, using inheritance and recursion.
The requirements for my variant type:
It must have performance similar to std::variant
It must not dynamically allocate... |
Short and sweet...
I wrote a cross-thread method that displays the countdown [in seconds] of a delay on a label.
I'm fairly confident it's far from optimal, so I'm in need of that glorious optimization advice.
private async Task SnoozeAsync(int seconds)
{
for (var i = 0; i < seconds; i++)
{
Invoke((Meth... |
Peter loves dices and some special numbers. Therefore he thrown dice n times and concatenate the numbers. Compute the probability that if he throws 6 to 27 seven times dice and concatenate the numbers, the sequence contains at least one subsequence of number sequence
1, 2, 3, 4, 5, 6
1, 1, 2, 2, 3, 3
4, 4, 5, 5, 6, 6
... |
It appears to me that this has been before in all languages except dart...
Referenced in order btw, any improvements, any tips, any feed back would be appreciated...
// The Goal: raise (x + 1) to a power and get a list of strings output
final int power = 6; //determines which power
final String firstVar = "y"; //
fina... |
My code works, but it looks very bad.
I need to move .xlsx files from the previous days from one folder to another, but I should'nt move the files with today's date, just the files from previous days.
In my current code, I am moving the files by specifying each one of them with a Minus X days, but I think the code is n... |
I want to check if a variable is nan with Python.
I have a working method value != value gives True if value is an nan. However, it is ugly and not so readable. Plus, sonarcloud considers it as a bug for the reason "identical expressions should not be used on both sides of a binary operator".
Do you have a better/elega... |
I wrote a simple command-line script to count all words in all documents (of the supported formats) in the current directory. Currently it supports TXT, DOCX, XLSX, and PDF formats and has been satisfactorily tested with them. As a freelance translator and content writer, this script provides me with an excellent tool,... |
I've written the following single-script minesweeper console game and would appreciate your feedback!
What I'm interested in:
Enums: I think the usage of Enums could be better. It feels weird that I need to make the player_field a List[List[Union[int, PlayerFieldState]]] instead of simply a List[List[PlayerFieldState]... |
There are lots of shell programs that have /bin/sh as interpreter, yet use some features that are specific to bash or other popular shells. I have written a little program that detects these unportable features. It is not meant to compete with ShellCheck, its purpose is only to catch a few common mistakes.
Since the pr... |
I am at the moment trying to grasp multi-file programming instead of one big main.cpp.
The class I wrote is about ISBN 13.
Can you point out what could be done to improve my code?
Also is there a good guide how to write include guards? My sources differate in this respect.
Runnable code here on Wandbox
ISBN.hpp
#includ... |
I have created a Node class that I am using for various projects in my data structures class(at school) and I am overloading the insertion operator <<. I am using std::any for my container datatype inside Node class and am using std::any_cast to insert this data into a stream whenever possible. Std::any_cast requires t... |
Assignment description
I'd like to receive feedback on an assignment which I'm currently working on. I have to make two traffic lights which allow traffic to run smoothly. I'm using a master Arduino which handles the main serial communication and one slave Arduino which handles the light sequence. Both lights turn red ... |
I am learning graph theory in CS and for practice, I have implemented Djikstra's algorithm in Java. I have created a GraphVertex class that contains information about the vertex and WeightedEdge class which contains information about the edges and their weights. DirectedGraphWithHeights class contains the implementatio... |
I would like to use this feature
>>> def func():
>>> return 1, 2
>>> x, y = func()
But I have a formatting problem, because I want to assign values in the __init__() of a Class.
import csv
class Filewriter:
def __init__(self, jsonstring, filepath):
self.katAsk, self.katBid, self.promAsk, self.promBid,... |
Some Task methods don't take cancellation tokens. This is a problem because some long-running tasks may never finish and there is no way to send them a cancellation request. This seems a bit dodgy to me but this is a workaround. Is there anything wrong with this? Is there a better way?
public static Task<T> Synchronize... |
While working on a project to do some spatial data processing in PostgreSQL, I found it cumbersome to use the psycopg2.sql objects to safely compose queries. I wrote a small wrapper over the formatting functionality of psycopg2.sql.SQL.format which allows you to specify the type of argument that a query placeholder is... |
A while back I wrote a socket programmed chat in Python. This question isn't really about the program specifically, moreso on conventions of Python and my style of coding. I've only been using Python for a couple of months and any pointers would be appreciated.
Here's some code I'm curious about:
# in case of inappropr... |
Please review for performance and C# style.
I already solved this question in 1 way.
LeetCode: trapping rain water C#
I tried also the dynamic programming approch
https://leetcode.com/problems/trapping-rain-water/
using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ArrayQues... |
(Also, see the next iteration.)
I have this tiny class for downloading files from internet:
package com.github.coderodde.utils.io;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.... |
Im trying to write a College class equals method that compare the content of the arrays of the two objects of college class. So The method will compare the Student[] array in college object to other Student[] array in another college object and same for the teacher[] array. I have written an equals method for this, but... |
I'm looking for any advice on the way I have implemented methods (explained below). More specifically, is it a good practice or not? And if not, any suggestions?
NOTE - communications.js is used in many places throughout the app.
Search_user.js
This code searches for cookies and returns a user object if any matc... |
Recently started writing more rust code and interested in how anyone may get around using .clone() within a map of a referenced data structure. I've included a test so you can see exactly what the desired outcome is. That is, if any of the blocks are statement-permissions then filter any options that are not consent.
... |
Assignment description
This is the improved code for a question I've posted earlier. I'd like to receive feedback on an assignment which I'm currently working on. I have to make two traffic lights which allow traffic to run smoothly. I'm using a master Arduino which handles the main serial communication and one slave A... |
This is an improvement on the code presented here
I was given the exercise of refactoring some code that was breaking the Open-Closed Principle in a SOLID design, ensuring that the new code would follow all the SOLID design principles. It refers to an Animal Park, where there are a couple of different species of animal... |
I have written the below code which generates 4 random, whole integer values between 1 and 6 and then saves the sum of the 3 largest values. It generates a total of 6 values this way, displays the total along with all 6 values once finished.
The order in which each value was generated must be preserved.
The total of a... |
Run-length encoding (RLE) is a simple form of data compression, where runs (consecutive data elements) are replaced by just one data value and a count.
For example:
WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW
becomes this:
12W1B12W3B24W1B14W
Here's an implementation of RunLengthEncode and RunL... |
I'm studying design patterns from Head First Design Patterns and, in order to get confident, I plan to implement the each pattern in C++ after studying the corresponding chapter.
As regards the Strategy pattern, this is the result:
Duck.hpp:
#ifndef DUCK_H
#define DUCK_H
#include <memory>
#include "FlyBehavior.hpp"
#... |
I made a very simple Instagram Bot that can download images and videos of the user, like Gallery with photos or videos. It saves the data in the folder.
How it works:
Creating directory for saving images and videos
Using Selenium for links extraction
Check the availability of Instagram profile if it's private or exi... |
I just coded an object-oriented Sudoku solver, but I don't have any possibility to check whether I have written good code, so I thought I would just post it here for review. I have looked for other solutions online but they mostly use different approaches so it's hard for me to compare.
I'm just getting started and try... |
I have an array of objects, each with a dimensions field for storing various metrics related to the object, e.g. length, width, weight, etc. Each object may be different in terms of what metrics it has.
I have a solution but not sure if it's optimal.
let dimensions = [{ a: 1, b: 2, c: 3}, { a: 2, c: 1, d: 3 }, { b: 1,... |
Specifically the if/else statements trying to match model and brand. The code works, but it's ugly. Any suggestions to clean it up?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
nam... |
Problem my code solves:
Lack of lightweight numeric range classes which can tell if arbitrary values lie inside them, supporting more than just simple exclusive max modes and integers, and that support iteration with configurable stepsizes.
What I think My code does:
Provides a lightwieght class encapsulating a numer... |
I have code that creates an AlertDialog to select a date by a user. I ran into a problem that this code began to take up a lot of space. Could you offer ideas on how to shorten this code / put it into different methods. Thanks in advance
public static AlertDialog getTextDialog(Context ctx, final OnSelectNewValueList... |
I have built a maths project that asks the user an addition, subtraction, multiplication, division, power and square root questions based on the difficulty level they choose!
But I am trying to refactor the code so I don't repeat myself too many times.
Can anyone please help me make the code less repeatable?
Here is th... |
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#define STACK_SIZE 100
typedef struct _stack
{
char *mem;
size_t size;
int top;
} STACK;
STACK *stack_create(char *mem, size_t size);
void stack_push(STACK *stack, char c);
char stack_pop(STACK *stack);
char stack_peek(STACK *const stack);
void st... |
Problem Statement:
Consider the following example: a coin was tossed n=7 times and the results were
"Heads, Tails, Tails, Tails, Heads, Heads, Tails"
Therefore, the longest Heads streak was 2 and the longest Tails streak was 3.
Here is my code:
def getMaxStreaks(toss): #toss=> ["Heads, Tails, Tails, Tails, Heads, Hea... |
(See the first and initial iteration at RemoteFile in Java.)
I have added some new facilities for convenience. Now I have this in mind:
com.github.coderodde.utils.io.RemoteFileDownloadListener.java:
package com.github.coderodde.utils.io;
/**
* This interface specifies an application programming interface for
* {@li... |
This is a calculator I made for fun and also to practice a bit. My goal was to make a calculator that can handle user input as well as a scientific calculator.
I made it as a Singleton to keep things tidy and provide some additional calculator functionality.
#include <iostream>
#include <vector>
#include <utility>
#inc... |
I wanted to optimize the following code in terms of better looking code. The code is finding lowest and highest value used for StochRSI formula. An example might be using LINQ or a different data structure.
List<decimal> rsis = new List<decimal>();
decimal lowestLow = 1000000000000000m;
decimal highestHigh = -10000000... |
I wrote this program in C to solve a given Sudoku puzzle (represented as 2D array) using backtracking algorithm. How can I make it more efficient, maybe faster and more C-onic?
This is my first post here, all suggestions are welcome! (be pedantic with me!)
#include <stdio.h>
#define GRID_SIZE 9
typedef int (*grid)[GR... |
I was wondering if you'd be able to review my basic login system that uses sstream and fstream? I feel a lot is wrong with it in terms of efficiency. I've included validation such as if a username already exists they won't be able to use it.
To test it works, the text file needs the following format:
George,Password... |
I wrote my first unit testing code on a service class using Mockito. The code looks like this:
// Test Class
public class TestVideoService {
private VideoService videoService;
@Mock private VideoRepository videoRepository;
@Rule public MockitoRule mRule = MockitoJUnit.rule();
@Before
public void se... |
I wrote the following C program to compare software version strings. Please provide any general feedback you'd like, but with special focus on error handling decisions, user input validation/sanitation, and robustness. My end-goal is for the program to properly handle user input and not have non-graceful crashes, etc..... |
Given an array of numbers arr and a window of size k, print out the
median of each window of size k starting from the left and moving
right by one position each time.
For example, given the following array and k = 3:
[-1, 5, 13, 8, 2, 3, 3, 1]
Your function should print out the
following:
5 <- median of [-1, 5, ... |
An Instagram Bot which downloads the posts from profile
I have to mention my previous posts:
Instagram scraper Posts (Videos and Photos)
Scraping Instagram with selenium, extract URLs, download posts
My code:
import requests
import os
import time
from selenium import webdriver
from selenium.common.exceptions import N... |
i'm building an url router and i want to improve it to respect SOLID principles, i want suggestions of how can i make it less coupled.
here's my current code:
Router.php
namespace App\Helpers;
use App\Interfaces\Request\IRequest;
use App\Exceptions\MethodNotAllowedException;
class Router
{
private $routes = [];
... |
I need to show a map of the United States using Leaflet, where if the user clicks on a state, the map zooms in to view all of the state's census tracts. I need to do this without a significant delay in loading.
The best approach I have tried so far requests all of the census tract data when the page loads. I send these... |
I'm planning to use Tarjan's algorithm for a program in which I would be processing a file, converting the processed data to a dictionary, doing a topological sort on that dictionary (using this implementation), and then finding the longest path.
Is there any optimization that can be made to the below code, or can be ... |
In this code in Python, I used an API called CoinDesk to get the Bitcoin price as JSON.
I'm trying to follow the best practices in coding, so, I've used logging and I'm using a code formatter in my editor.
Kindly, any enhancements on this code will be appreciated.
# Project Idea: Bitcoin price program using CoinDesk AP... |
The following is the simulation of Central Limiting Theorem from Statistics:
class MyRandom:
m = 4294967296;# modulus
a = 1664525; # multiplier
c = 1013904223; # increment
seed = 1; #initial seed
def NextInt(self):
self.seed = (((self.a * self.seed + self.c) % self.m));
return self.s... |
I implemented an in-memory file system that should support basic Linux commands (mkdir, cd, mkfile...) on the current working directory. It can read commands from a file and process them.
I'm interested in a review from senior developers to see what makes a difference between a junior and senior (what should I focus on... |
Hi I have written the following code in Python. Any improvements on my code will be appreciated as this is my first shot at pygame!
There are some problems in terms of functionality, to state briefly ball sometimes gets stuck within a paddle, which I am continuing to resolve
import pygame, sys
import random
from mat... |
I would be especially happy to hear opinions about complement_union.
The rest of the code is just there to test the output.
program test_complement_union
implicit none(type, external)
call assert(all([3, 5] == complement_union([1, 2, 3], [1, 2], [5])))
call assert(all([2, 3, 4] == complement_union([1, 2, ... |
The function below is part of a trading system. Its purpose is to assign a volume (order size) to a bid (buy) quote and and ask (sell) quote, depending on the value of the position_size argument.
This trading system strictly cannot exceed a position limit of 100 in either direction, so our order volumes need to never ... |
Long time reader of Code Review with my first question. I'm self-taught and suspect this code can be improved. The project is really important to me and the team and I could really use the help.
I'm using this as part of a larger script run through the terminal which takes a GeoDataFrame and adds the GPS coordinates a... |
Q: Am I approaching writing idiomatic Rust code correctly?
Hi CodeReview, I'm a beginner Rustacean coming from Python going through Rust books (The Rust Book, Rust in Action). A lot of the beginner code has unwrap everywhere and I'd like to write more idiomatic Rust.
I wrote 2 versions of a simple CLI program that read... |
Please provide any suggestions on the below code for Kahn's algorithm. Can it be implemented in a better manner, or be improved:
def kahn(graph):
in_degree = {u : 0 for u in graph}
for vertices, neighbors in graph.items():
in_degree.setdefault(vertices, 0)
for neighbor in neighbors:
... |
For my robot hobby project I need to expose the system's configuration so I can quickly make changes to it. So I have made a very simple app that generates a form. In this form you can edit, save fields, cancel edits or remove a module from the configuration.
I wrote this with no prior knowledge of JS and React. But I ... |
I have a list like this
list_ = [" ", " ", "X", " ", " ", "Z", " ", "Y", " "]
I am writing a function that will result in
list_ = [" ", " ", " ", " ", " ", " ", "X", "Z", "Y"]
Basically it will push all the non-empty (I'll call " " as empty here for simplicity) to the end of the list while retaining their orders
M... |
My task is that of caching. If the folder exists then load the cache from disk, if it doesnt create new cache. This is trivial, what bothers me is if I want to create third mode of noop (don't do anything relating to cache).
Currently I have this:
class HeavyCalculationClass:
def __init__(self, cache_dir=None)
... |
I implemented a program that does the following:
Consider the positive quadrant of the xy plane. A colored point is a triple (x,y,c) where x is its x-axis coordinate, y is the y-axis coordinate, and c is an integer representing its color.
This program needs to read a set of N colored points, then take some queries and... |
First I've to indicate that this is my homework.
An example of a given input is:
s1 = {'p1': (x1, y1), 'p2': (x2, y2)}
where all names and coordinations are user input, only the input format is predefined; also p1 is the upper leftmost point and p2 is the lower rightmost point as shown below:
I can go on to get area,... |
I've written this react-native component which is giving me a bad feeling that it's not as good as my expectations.
I want to make it look cleaner with smart and less code.
import React, { Component } from 'react';
import {
SafeAreaView,
View,
Text,
ScrollView,
TextInput,
TouchableOpacity,
A... |
Design a class called Stopwatch. The job of this class is to simulate a stopwatch. It should
provide two methods: Start and Stop. We call the start method first, and the stop method next.
Then we ask the stopwatch about the duration between start and stop. Duration should be a
value in TimeSpan. Display the dura... |
The following is an implementation of Newton's method of finding root of a function.
using System;
using System.Drawing;
using ZedGraph;
//Newton's Method
//https://www.youtube.com/watch?v=2GrfaB88w4M&t=350s
//https://stackoverflow.com/questions/12915317/how-to-find-derivative-of-a-function-using-c
//https://www.gee... |
I'm representing coordinates in a multi-dimensional array, and I'd like to stick as closely to native arrays as possible.
nArray.hpp
#include <stdexcept>
// Array that allows for negative integers
template <typename T, int SIZE> struct nArray {
private:
T array[SIZE];
public:
nArray() {
... |
i would really appreciate if anyone could invest a bit of time to review what i did. Basically this is first time i do this, and that is reason why i need another set of eyes.
I have Spring Boot application and i decided to use docker containers on my server to run applications across multiple environments (DEV, QA and... |
The data bellow shows part of my dataset, that is used to detect anomalies
describe_file data_numbers index
0 gkivdotqvj 7309.0 0
1 hpwgzodlky 2731.0 1
2 dgaecubawx 0.0 2
3 NaN 0.0 3
4 lnpeyxsrrc 0.0 4
I used One C... |
Since couple of days ago I started to learn python by doing AoC 2019.
I would like to share with you my solution to day7 (Amplification Circuit) part 1 and part 2.
Challenge summary:
--- Day 7: Amplification Circuit ---
==================== Part 1 ====================
There are five amplifiers connected in series; each... |
I want to represent components of LXC in django; so I defined them in models: Container, Network, Profile and Devices where each one of them have a set of attributs, but when it comes to representing configuration (each component has a set of configuration fields), I don't know if it is the right approach to follow. Be... |
I am trying to write a human-readable tester for a functioning program.
There are four methods in the class Polynomial: public Polynomial(int[] coefficients), public int getDegree(), public int getCoefficient(int k), public long evaluate(int x).
Where coefficients is an immutable array of elements that represent a poly... |
Anyone could help me to optimize this block of code, I already did a bit improvement but since I'm really bad with this kind of algorithms this all I've done so far. Much appreciate if you can explain the improvement.
This basically fill a bus (k is the number of seats on the bus) if all seats are filled save the last ... |
This is part of my homework on digital logic design, so I would like to present some technical background first.
Quine–McCluskey algorithm is a method for minimizing Boolean functions. Given the truth table of a Boolean function, it tries to find the simplest sum-of-product to represent that function.
For example, the... |
I have written the following routine to clean an html raw code and extract the text.
It works, but the code is not very well written. Any ideas how to solve this faster and with fewer lines of code?
Thanks a lot for your help!
import re
def cleanhtml(raw_html):
cleanr = re.compile('<.*?>')
cleantext1 = re.sub(c... |
I made a program that merges all the PDFs in a certain map. The program is made so it merges only one sided PDFs. I would like your opinion on the code and how can it be improved.
while True:
print()
try:
map_name = input("Name of the map where PDFs are saved: ") # map where your documents are
... |
I made some changes in my code from the previous post.
The changes that I made:
I put all the functions to the class
All the global arrays I moved them to class too
Created PrivateException
I made property for search_name
I could do it with a different approach but I decided to do it step by step.
My idea was:
To cre... |
I have the following class structure:
MyAttribute.cs
public sealed class MyAttribute : Attribute
{
public MyAttribute(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException(nameof(name));
}
Name = name;
}
public string Name { get; }... |
This is a component for a lexer which operates on a byte input stream that handles reading and decoding the contents of a string contained within double-quotes. The validity of the encoding is handled by CharsetDecoder#decode() which will throw an exception on an invalid buffer.
The charset argument defines the encodin... |
I have some side projects by using a private module I have. My main goals are to match the list if they started with the pre-defined prefix, then put them into a list. From that filtered list, I extract two elements each time and modify their label name. I am trying to clean up my code to make it more concise and user-... |
I've created an integer index based union find implementation in C#, and am looking for some feedback. Unit tests have been written with NUnit. Some questions I am considering:
Can the implementation be made more performant?
Can the (C#) language be used more elegantly?
Are there any general style guidelines being vio... |
This function takes two lists of same length and a target number: the number which is to be summed. The function then returns a list of pairs whose sum is closest to the target number than any other pairs. It also finds the pair whose sum is equal to the target number.
def pair_finder(list1, list2, t):
list1.sort()... |
After sticking with the same handful of languages for years, I decided to learn C.
I've written a guess the number game, where it generates a random number based on the difficulty level, and then you have 5 attempts of guessing the number.
If you guess incorrect, it will give you a clue by telling you if the answer is... |
Introduction
At this moment in time, I'm in the process of creating some fluent interface, as a result, I've created a DSL style solution for authentication & authorisation.
As a result, the consuming code-base may look something along the lines of this:
public class Demo {
public String login() throws IllegalSt... |
I have the following classes. I wonder if this structure makes sense in any terms especially the usage of the UserDetails class from Spring. Should I use loadbyusername method to create and remove methods in account service or is it okay? Then where should we use loadbyusername method?
Base class to cover fundamental p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.