instruction stringlengths 71 95.1k |
|---|
This method is an attempt at removing duplicates from arrays without the use of extensions.
func arrayWithDuplicatesRemoved<T: Equatable>(from array: [T]) -> [T] {
var results = [T]()
return array.compactMap { (element) -> T? in
if results.contains(element) {
return nil
} else {
... |
I'm really new to Python (like only a month of study) and I was testing out dictionaries, so I tried to make an 'inventory' where you can pick an item from your inventory and examine it. But I can tell that I'm not doing this in the most efficient or elegant way.
Originally I thought I could make each item its separate... |
I am trying to write a Haskell function which takes a list ls and returns all sub-lists obtained by removing one element from ls. An additional constraint is that the returned list of lists must be in the order of the missing element.
Here is what I have. I know there must be a simpler solution.
subOneLists :: [a] -> [... |
I implemented this max-heap to satisfy the C++ Container requirements. I am fairly confident I implemented bubble_up, bubble_down, and sort correctly. It passes for small sets of numbers I give it. If you're wondering what bubble_down(iterator, iterator) does, it does the bubble down action but ignores positions past l... |
I am new to C++ threading library. I would love to get some comments on how to improve this code (if there are possible bugs, I would appreciate that feedback too). In particular, I want to refactor the code for the methods of the linked list:
How to return unique_lock in a function so that it didn't unlock the mutex ... |
My first attempt at Scheme (Chicken Scheme) - a simple RPN calculator. Please comment on exception handling as well as the general coding style. Here is the code:
(use stack)
(use srfi-69)
(use simple-exceptions)
(define prompt "> ")
(define stack (make-stack))
(define words (make-hash-table))
(define (init-words)
... |
I am creating a very small application to demonstrate solid principles and also a brief implementation of a builder pattern, does anyone have any feedback as to how this could be improved or how it breaks the solid principles? The app is a small app that just converts units, e.g. yards to meters, inches to cms.
Interfa... |
I'm working with a REST API, first time doing this and I have a working code but it's long and just looks messy to me. I just know there's a better and faster way to do it.
try {
$LOCATIONS = new \Picqer\Financials\Exact\ItemWarehouse($connection);
$LOCATIONS_GET = $LOCATIONS->get();
foreach($LOCATIONS_GET as $LOCATION... |
In one of my java projects I use singletons a lot and I was looking for a way to reduce repeating code. I made a SingletonUtils class that accepts a class and supplier parameter. Then stores the instance in a hash map. This way the static instance isn't stored as a static variable in the class I want to make a singleto... |
Given the Josephus Problem.
Josephus Problem
N people (numbered 1 to N) are standing in a circle. Person 1 kills Person 2 with a sword and gives it to Person 3. Person 3 kills Person 4 and gives the sword to Person 5. This process is repeated until only one person is alive.
Task:
(Medium) Given the number of people ... |
I have a file as content a list of dictionaries (Around 75000). For instance, this is an example of first line I got when reading the file (value for v):
{
"id": 1,
"name": "Explosives",
"category_id": 1,
"average_price": 294,
"is_rare": 0,
"max_buy_price": 755,
"max_sell_price": 1774,
"min_buy_price": 99,
"... |
I'm a junior programmer, and I've only been in the industry a couple of months.
One of the aspects that I struggle with most is testing my code. I can write tests, and I can ensure that my code passes the tests successfully. However the issues I have relates to whether or not I am doing my testing correctly. At the mo... |
I'd like to optimize my code and get a better understanding of how I can perform the task I am doing better. I've only used Perl threads about 3 or 4 times now.
The purpose of my code block is to scrape the Pastebin API for every new public paste that appears at regular intervals using a crontab. Then search inside tho... |
I need a concurrent data structure with the following properties:
Low overhead for enumeration
Insert only at end.
Removal from any point.
Enumeration should be safe with concurrent writing
Enumeration does not require the list to be in a constant state
Not a problem if I enumerate over removed items
I have designed ... |
Actually my implementation is not working very well for big areas (I don't know why) I already created a question on Stackoverflow. But I figured out how to do it to work with an O(n) implementation (you can see what I mean here (see the fiddle I attached)).
But for some reason as I said it is not working very well on ... |
I am trying to program the board game Orleans. I am planning on making a computer player that plays randomly at first. The part of the game that I'm struggling to code elegantly at the moment has to do with the planning of worker placement. I'll try to explain it in a way that doesn't require familiarity with the game.... |
The up-to-date code, along some documentation, can be found here.
We've implemented a version of the Simplex method for solving linear programming problems. The concerns I have are with the design we adopted, and what would be some refactorings that would improve it overall.
We defined two important global functions, ... |
I had searched for a solution to mvn clean install on my changed projects after a git pull. I even asked a question over at SO about the same thing. The answer I got pointed me into creating my own script to achieve what I wanted to accomplish. So I went, I saw, and I conquered the script that I wanted. However, it is ... |
This game is a variation of the Greed dice game. Imagine we have 5 dice. We roll, them, and jot down the results. Then, based on this chart:
Three 1's => 1000 points
Three 6's => 600 points
Three 5's => 500 points
Three 4's => 400 points
Three 3's => 300 points
Three 2's => 200 points
One 1 => 100 points
One ... |
TL;DR what should I do if I have too many methods in my parent component??
I'm making a card game (Pai Gow Tiles) using react and I am having trouble finding a way to format my parent component. I've always heard that you should keep your components small and mine is over 300 lines. Most of it are methods that I need f... |
This class is used to make Excel Cells behave like Checkboxes. Clicking the cell raises a CheckedRange_Clicked(Target as Range) event and toggles it's value between 0 and -1. A combination of Fonts and Custom NumberFormats display the cell values as Checkboxes, Checkmarks, Yes/No, True/False or a custom format.
Cla... |
Using Laravel, I need to export some value from the DB in a CSV and then upload the CSV via sFTP or return it in a Response.
I'm trying to be use S.O.L.I.D. principles but with this scenario, I'm not sure how to proceed. As I understand I should have one class that handles the CSV, one that handles the sFTP, one for th... |
I'm quite new to Swift, and although I've been programming as a hobby for many years, I'm still not very confident about my code.
I'm currently rewriting an old library of mine, an NMEA parser. NMEA is a standard for GPS sentences containing position, time, satellites signal power and so on.
Basically this code receiv... |
The problem with the original Lazy in C# is that you have to put the initialization in the constructor if you want to refer to this.
For me that is 95% of the cases. Meaning that I have to put half of my logic concerning the lazy property in the constructor, and having more boilerplate code.
See this question: https://... |
Given positive integers a,b,c and limit, I want to generate all products having the form
$$p^aq^br^c \leq limit$$ less than limit (where p,q,r are distinct primes). a,b and c are not necessary distinct.
I tried something like:
primes= [ 2,3,5,...] # primes up to 10**8
[ (p**a)*(q**b)*(r**c) for p in primes for q in pri... |
I made a quiz programme for my GCSE Computer Science NEA. I just want to make sure it is OK to submit.
There are also 5 files:
Usernames,
Passwords,
Song Names,
Artist Names and
High Scores.
Any feedback is appreciated, positive or negative!
import random # Imports the random module
def readData(): # Load Files and Log... |
The code below is for a board game program, which works by placing the user on a grid which then tasks the user with finding all the treasure chests. Each chest landed on gives 10 gold however landing on a bandit means all your gold is taken. The end score should be given once the user has found all the chests.
A few f... |
The scenario is the following. I get the string from an HTML element via outerHTML and I need to convert the 'rgb(r, g, b)' part into the hexadecimal representation. I tried this with regex and it seems to work but I have a feeling there are better ways to deal with this.
One particular thing I don't like is where I d... |
I'm trying to make a carousel with jQuery and I want to know, how to simplify the code further? so... this is my code:
$(document).ready(function () {
$(".cont-btn button").click(function (event) {
var detectId = event.target.id;
$(".cont-btn button").removeClass("active");
$(this).addCla... |
The Microsoft OCR API returns json, and if I want to extact the text data from this json:
response = \
{
"language": "en",
"textAngle": -2.0000000000000338,
"orientation": "Up",
"regions": [
{
"boundingBox": "462,379,497,258",
"lines": [
{
"boundingBox": "462,379,497,74",
... |
I am pretty much a python newbie and was looking at this question on StackOverflow.
Whereas the OP was interested in downloading the .htm |.txt files, I was simply interested in using Beautiful Soup and requests to gather all the links, to those files, into one structure. Ideally, it would have been a single list but I... |
I have a project where I work with digital addresses for a Programmable Logic Controller (PLC). The requirement is that the user gives a start address e.g. 1000.0 and then for example the next 20 things are numbered in increasing order.
In this example this would mean:
1000.0
1000.1
1000.2
1000.3
1000.4
1000.5
10... |
I have this array const idArray = ["12", "231", "73", "4"] and an object
const blueprints = {
12: {color: red, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
231: {color: white, views: [{name: "front}, {name: "back}]},
73: {color: black, views: [{name: "front}, {name: "back}, {name: "top}... |
I've been practicing recursion lately and wrote this code to get Pascal's triangle recursively.
How would you guys improve it ?
I don't really like the fact that the recursion goes for n+1 steps.
def RecPascal(n, m=1, prev=[]):
if m > n+1:
return []
elif m == 1:
return RecPascal(n, m+1 , [1])
... |
Introduction
This question was asked in a technical interview, I am looking for some feedback on my solution.
Given a list of integers and a number K, return which contiguous
elements of the list sum to K. For example, if the list is [1, 2, 3, 4, 5] and K is 9, then it
should return [2, 3, 4].
The Ask
My solution work... |
After understanding HashMaps, I decided to implement my own using 3 classes HashMap, LinkedList, and Node. I knew how to implement LinkedList from before.
Can you please give me feedback on this. Will this be an acceptable implementation for a technical interview?
Also do we actually need to implement the data structur... |
Here is my code for implementing Graph using adjacency matrix. The code should be Object-oriented and there is a method isPath() checking if there is a connection between two nodes. Some advice?
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
class Graph
{
protected:
int value;
... |
I am trying to create an evaluator in Kotlin for the Mastermind game which compares two strings and tells how many letters and letters on the right position they share.
I was hoping to get some comments on how I can improve the code below in any way. Many thanks in advance!
fun String.masterCompare(otherString:String)... |
A triangular number is a product of three factors as follows:
$$
\text{Triangular number} = x(x + 1)(x + 2)
$$
Is there a way to make this code faster? As it is the code calculates every triangular number less than or equal to the integer given by the user.
#include <stdio.h>
int main(void) {
int firstFact... |
I have written code using Python for Fully Constrained Least Squares (FCLS) Linear Spectral Mixture Analysis, which could be applied for unmixing multispectral image successfully.
However, the operation efficiency is very low, taking about 2 hours for each MODIS image (rows: 1620, columns: 3024, bands:7, blocksize: 512... |
I would like to verify that the code fulfills the specification of a red-black tree or receive suggestions for improvements.
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
static char BLACK = 'b';
static char RED = 'r';
struct node {
int key;
char color;
struct node *left, *... |
I am implementing the unit of work pattern to be used in the logic layer of my application. The goal is to abstract away the tasks of managing transactions
/ connections.
My implementation relies on generic repositories that exists during the life time of the unit of work class.
UnitOfWork
public class UnitOfWork : ... |
Below I have some code written in prolog as a brief example. The goal of the program is to take a Computer and Information Science (CISC) course number and return any CISC prerequisites (prereqs).
I would like to know if this code followed common practices in prolog.
%CISC Courses
cisc(100).
cisc(101).
cisc(103).
cisc... |
You may know Bocce, so you should know that I've tweaked the rules a little. Three types of balls are thrown: a red type, a blue type, and single black ball called the jack.
These are all on the Cartesian coordinate system. The coordinates of the jack are given, and also distances of an equal amount of red and blue bal... |
I've written a script in Python using the multiprocessing module to scrape values from web pages (one page per subprocess). As I'm very new to multiprocessing, I'm not sure whether I did everything in the right way. It works without error, though.
Here goes the full script:
import requests
from lxml.html import froms... |
there is my final code for implementing a Graph in C++ using adjacency list and Object-oriented. I got some help from StackOverflow and it was really helpful, but now I would ask about some advice for improving and a possible way of implementing two functions: isPath( v, w ) for finding if two nodes are connected and i... |
I'm just starting to learn OOP and I've setup a class to handle the database connections and wanted to check if I'm going about this the right way.
My website is already using PDO for prepared statements but it's procedural code otherwise. The site connects to multiple databases and one of the databases has two connec... |
Question
We are given an array (indexed from 1) of N elements on which we make M queries:
add(Left, Right, X) - all the elements between the position Left and Right (1<=Left<=Right<=N) are raising their values with X.
After all the operations are completed, print the array.
example
Array: 1 1 1 4 5 6
operations: (1, 5,... |
I have just finished my first version of a function that returns an array of video screenshots created with canvas. What I am looking for are ways to improve this speed by as much as possible. I want to almost be able to instantly display the results. Yes, this should be a backend thing, no I can't do it in the backend... |
I feel ready to show you my work on creating BST in C++ using double linked list and 3 more functions for manipulating the tree. There is also one more function checking if the tree is real or not.
Declaring the Node:
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
struct BstNode
{ //struc... |
I'm working on JIT-based programming language using DynASM (before I was generating instructions directly). Review of the code would be really appreciated - It's my first time fiddling with DynASM. Code was written to be tight and readable. You can find github repository here. Code consists mostly of one file as code i... |
This is a simple implementation of a knapsack written in Ruby. I've included all the relevant code here, but my question is concerning the contents setter .contents=
## item.rb
class Item
attr_accessor :weight
attr_accessor :data
def initialize(weight:, data: nil)
@weight = weight
@data = data
end
... |
Question: Take an input string and output the "encoded" string by using the following rules:
[1] vowels are replaced with number: a->1, e->2, etc
[2] consonants are replaced with previous letter b->a, c->b, etc
[3] y goes to space
[4] space goes to y
[5] numbers are reversed
[6] other characters remain unchange... |
My goal is to take a source list of vectors and apply a mapping to each vector. The mapping creates a list of lists. When the vector size in each list element is large (~20000), and the number of elements in the source list is large (~5000), my program does not seem to be efficient. How can I optimize my code?
I've tri... |
I am aware of Dijkstra's paper on why goto is harmful, but I thought it would still be fun to make a bidirectional bubble sort using goto. So I did. I thought I'd share the code here. Cheers!
void bubbleSort(int arr[], int size){
int counter = 0;
BottomUp: //This starts with the lowest array index and goes up to th... |
This code uses jQuery promises in combination with callbacks does the following:
Saves Group UUID to server using storeGroupOnServer()
Creates a DOM element for the group using createGroupDomNode()
Creates child elements for each image, using createNewChildDomNode()
How can this be written more flat (avoiding the nes... |
I am looking for the fastest way to find document distance. How can I improve this?
Split each document into words. replaceAll() is faster than replace()
String.prototype.replaceAll = function(search, replacement) {
return this.replace(new RegExp(search, 'g'), replacement);
};
Creating word array here:
const words... |
Often when reading data from a sequence (IEnumerable<T>) in multi-threaded code, a consistent snapshot needs to be taken inside a lock before using it in a longer operation. I'd like to simplify that by creating an API that does it within the enumerator implementation.
So in the manner of LINQ extension methods, I have... |
This is what I have so far but it's not perfect... Any input would be very helpful!
def picture_reset_pixels(filename, from_color, to_color, target_color):
img = Image.open(filename)
pixels = list(img.getdata())
red_list=[]
for i in pixels:
R= i[0]
G=i[1]
B=i[2]
if R... |
I just completed some beginner web-dev courses (cs:50 and such) and wanted to try my skills.
The CSS centering - ugh I just gave up on that, I wanted to make it responsive and the letters centered perfectly, but whatever...
So overall, how is this coded? is there a better way to code this?
let turn = true;
le... |
One year ago I asked for a yearly revision of my Interactive Linux upgrade script.
There is nothing new to the conditions, therefore please read the original question before you decide to comment and / or vote to close as unclear.
Additional notes:
The script will always run interactively as I want to have full contro... |
I am new to Python and have written a function which calls an API and does some processing. Please review the code and explain what is the right and pythonic way.
def fetch_storedetails(api_link, zone_id, latitude, longitude):
"""
:param api_link:
:param zone_id:
:param latitude:
:param longitude:
... |
Here is my next Numpy practice, I am not sure is it more accurate to call it "Stroke Algorithm" or "Draw edge stuff", xD.
Anyway I did in steps:
calculate each pixel's RGB absolute distance to pixels on its right and down side, the distance is simple measured by absolute different in each color value and sum them up.... |
I'm a first year student at a college that focuses heavily on self learning (SCRUM) without any classical lessons. Because of this, I basically learned everything I know from websites like this. I don't want to get any bad habits or wrong understandings. So, is this code any good? I'm not looking for optimization (woul... |
This is one of my first programmes which I had written (definitely first over 100 lines) and I could really use some feedback.
import time
import getpass
import random
def invalid():
print("")
print("INVALID INPUT")
time.sleep(sec)
def play_game(secret,sec): #the actual game
def correct_guess(guess,se... |
I'm pretty new to bash scripting. I want a script that I can run in a directory that contains .md files, runs pandoc on them, and delivers the output to a sibling folder html, i.e. my folder structure is like this:
.
├── html
└── md
Here is what I have working, I just don't know if I'm following good practices or if ... |
I am a C# developer learning F#. Would appreciate any suggestions on how this code can be improved. Main points I am interested in:
Functional style of the code, absense of imperative style(C#) artifacts
F# collection data types and functions usage
General code(not algorithm) efficiency
Code style, naming etc.
let lif... |
Challenge:
Two input files are given The first contains |N| ratios in the form of
two labels and a ratio:
USD, GBP, 0.69
Meter, Yard, 1.09
YEN, EUR, 0.0077
GBP, YEN, 167.75
Horsepower, Watt, 745.7
Each line A, B, C means that C is a conversion factor from A to B. In other words, multiply by C to go from A to B... |
Practicing hacker rank questions and would love some feedback on how I could perform optimizations on a Trie.
This code will add a bunch of names into a trie and then when asked will turn how many names belong to a partial match. eg.
jenn, jennifer, george, jenny
partial => jen
return => 3
using System;
using Syste... |
I have a test that I've already turned in but would like some outside review on where I could improve. Spent most of the day today trying my best to keep this O(n) complexity. Any help is very much appreciated.
If it's a bit difficult to read here feel free to check out the repository
Example of how it should be format... |
I am trying to improve the time complexity of my A* search algorithm and I have tried approaching this from every which way I believe is possible. I believe I may be doing something fundamentally wrong here and would appreciate a second look.
I start with a 4x4 board of values 0-15 that can be shuffled to achieve this ... |
Bist-o-yek (21) is a Persian card game very similar to blackjack, except it doesn't have things like double down and split. I did, though, change it a little. For example, added dealer dealing to 17.
First, there's a class called Cards that carries each card's name and score. Then, some functions for drawing, shuffling... |
I am referring to this problem https://practice.geeksforgeeks.org/problems/cycle-race/0.
The Problem description:
Jack and Jelly are two friends. They want to go to a place by a cycle ( Assume that they live in same house). Distance between the place and their house is 'N' km. Rules of game are as follows:
- Initiall... |
I'm learning Java and I've tried to write my own calculator with GUi based on this post. Here is the repo: https://github.com/MurDaD/java-calculator
Could someone check my code and tell me how to improve it?
The main problem I thing is in the Mediator class - it's huge, but I don't know what is the best way to refactor... |
I am creating what strives to be a truly random number generator. As of right now, the implementation uses a mix of mainly nonsense system data and some pseudo-random numbers to generate numbers that are different and use the last half of the number (which, statistically, I believe is sufficiently random). The advice I... |
Today, I gave myself a small task of detecting the total amount of RAM installed on a hardware from a Linux system using a POSIX shell script. I ended up using dmidecode utility and a rather complex looking code for such a simple task.
Though I found countless simple pieces of code on various places, they are all doing... |
Here is a big unsigned integer type I intend to use for learning and "fun" with cryptography.
It uses a std::vector for storing blocks of unsigned integers, the exact type of which can be changed with the template argument block_t. A double_block_t is used internally for the various math operations. This is selected au... |
I'm a member of a discord channel and sometimes people post simple coding exercises for fun. This time the exercise was:
Implement the following operations of a queue using stacks.
push(x) -- Push element x to the back of queue.
pop() -- Removes the element from in front of queue.
peek() -- Get the front element.
emp... |
I'm learning Haskell, and I've finally gotten around to coding up some Haskell. This code passed my tests.
This code takes a line from standard in which tells it how many cases it's going to have (1 to 5), and for each case, it takes a line telling it how many pairs (max of 100) of x's and y's it will get (integers fro... |
This is one of my first programmes in python and I really could use some feedback on how to improve. It's meant to be a multiplayer game by handing the computer to the next player at the end of each turn.
import random
import time
import os
import operator
def invalid():
print('\nINVALID INPUT')
time.sleep(0.8... |
I am trying to build a neural network classifier. I have created a neural network with 1 hidden layer (25 neurons) and 1 output layer (1 neuron/binary classification).
The dataset I am using has the following dimensions:
size(X_Train): 125973 x 122
size(Y_Train): 125973 x 1
size(X_Test): 22543 x 122
size(Y_test): 22543... |
Looking for feedback mostly on the from() and printf() implementations but I included everything for context. Please do not suggest crates, this was an exercise for me to better learn the primitives in Rust (including bitwise ops). Also, please do not suggest unsafe Rust! I need the code to use only safe Rust construct... |
In my app I need to query location and scan wifi periodically. To conserve power I need to change the rate dynamically, depending on the distance to the target. Also I want to wait for both asynchronous calls to complete. Coroutines seemed the obvious choice, but since this is my first take at coroutines I want to have... |
I've attempted to erite some VBA for this this question. The output is OK
but the code is not very elegant. I'm happy-ish with creating unique list of names and certificates, but the rest seems rather ugly. I'd love to learn how to make it more elegant and programmer-like (and less amateur-like-crap).
Sub PivotData... |
Problem: Given a singly linked list of integers l and an integer k, remove all elements from list l that have a value equal to k.
My solution works, but I suspect it's not smart and optimized because I have many extra variables to solve this question.
Node.h:
#ifndef NODE_H_INCLUDED
#define NODE_H_INCLUDED
templat... |
This was my first attempt at scraping approximately 1800 open datasets from the web. On the first go-around it takes approximately 1 hour to complete. Subsequent iterations only take 4 seconds. I'm guessing there are much better ways to implement the logic that I did with regard to filename structure and overall effici... |
I receive data with NA values. I would like to trim off the leading and trailing NA values, but to leave the interior NA values in place.
I've written the below in Rcpp, but it is very much a hand rolled solution -- and i'm alive to the fact that i'm going to make mistakes doing things this way.
What is the idiomatic... |
Here is my code for the design of a parking lot in C++.
The following assumptions are made. Referred from Geeks for Geeks
The parking lot has multiple levels. Each level has multiple rows of spots.
The parking lot can park motorcycles, cars, and buses.
The parking lot has motorcycle spots, compact spots, and large sp... |
I am trying to use the back end validation for front end validation and this is what I got. Maybe there is a better way to do this? If someone knows please share the knowledge.
HTML:
<form id="post-store-form" action="posts/store" method="POST">
<div class="form">
<input id="post-title" type="text" name="ti... |
I'm not a beginner programmer as I have experience in Node and Ruby, but I'm a beginner when it comes to C++. And as C++ is quite different from these two, I figured I could use any tips, tricks, hints and pointers (hah!) to learn how to actually write C++ and to get the most out of the language. I feel a bit like I'm ... |
I've an Audio Host application that sends block of samples to a DLL I'm building. It sends 44100 samples per seconds (i.e. Sample Rate 44100hz), per block, processing 16 distinct Voices.
It processes an Oscillator, which plays a basic sine wave, modulated at Audio Rate by Gain, Pitch and Offset.
Here's the C++ code I ... |
This is my array implementation on stack in Java. It involves push, pop, get and growth when limit of array size is reached.
I am a self-taught programmer starting to learn data structures and algorithms.
I am looking for
any recommendation on conventions
an honest opinion on how bad this piece of code if this is an i... |
I have an object of ingredients to be added to a burger. Its structure is as follows:
Input
ingredients: {
salad: 1,
cheese: 2,
meat: 2,
}
I want to transform it to an array of JSX elements. Each key in the original object has to be mapped to the number of JSX elements equivalent to the... |
In examples for fetch() I don't see many example for status code checking.
(1) I'm expecting to catch 403 unauthorised responses and push the login path to React router to render the login page. Haven't seen this elsewhere, but seems to work alright.
(2) Is it alright to nest the second .then the way I did or it should... |
I've written a library for Mongoose-OS C mgos_timers. I wanted to write a wrapper to take advantage of the full potential of C++ lambdas. The original C timers allow to pass a callback function pointer.
/* Timer callback */
typedef void (*timer_callback)(void *param);
mgos_timer_id mgos_set_timer(int msecs, int flags... |
I am semi new to coding and have been following a tutorial on making a "text based RPG" on CodeClub.
Here is the full code:
#!/bin/python3
# Replace RPG starter project with this code when new instructions are live
def showInstructions():
#print a main menu and the commands
print('''
RPG Game
========
Get to the... |
In this SO question the OP is unable to scrape a table from a dynamically loaded website. In monitoring the web traffic, via Chrome dev tools, I found that there is an API request made that returns a JSON string with the required info.
The following is the answer I wrote to extract the columns of interest from the API ... |
This Trie implementation works, however, I would like to get an advice on how to improve this code.
Any advice is appreciated: functions implementation, memory management, modern C++ usage, const-correctness, code readability, anything else I am missing? Any additional functions that would be useful?
Trie.hpp
#pragma... |
I've been trying to get into functional programming with javascript and have tried to make some experiments with currying and function composition.
What I've played with so far is a sorter function that sorts object keys either ascending or descending:
const data = [
{ grade: 4, name: 'Zoe'},
{ grade: 3, name: 'R... |
I'm learning JavaScript and have written a function that accepts a string and returns the first word with the greatest number of repeated letters. For example:
Input:"Hello apple pie" - Output:"Hello"
Input:"Hello apple pie yelllow" - Output:"yelllow"
I've tried to keep it as concise as possible. I wonder whether later... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.