instruction
stringlengths
71
71.9k
I have written some sorting algorithms in Rust and wanted to see how terrible they were. What I am looking for: Bugs Performance improvements Idiomatic code Maybe even a functional approach to the sorting algos Why is the merge sort so slow? Is it my implementation? Note you will need rand = '*' in your Cargo.toml fo...
I have slightly altered Marc Gravells 2-tier cache code which can be seen here. I changed it to use Stackexchange.Redis instead of Booksleeve and also added some retry logic and serialization. public class AzureRedisCache : ICacheService { private static Lazy<string> _configurationOptions = new Lazy<string>(() => ...
I am trying to implement Google Maps in Android. I am also trying to learn different design patterns. I want to use location in more than one Activity hence I have used a class named 'GoogleLocation' so that I can reuse the code in other activities too. I am using MyApplication class to get the context. GooglePlacesAct...
I am beginner in Java. I coded Directed weighted Graph data structure by myself without anyone's help i want to have some constructive feedback regarding my program design, weather my code is perfect or it needs some improvements, Here is my code : import java.util.ArrayList; import java.util.HashMap; import java.util...
For my first JavaScript/jQuery project, I made a simple Blackjack game. However, I would like to have a more object oriented approach. I would truly appreciate it if someone can review my code and point out how I can make it more object oriented. function reset(){ // Reset $(".dealer-cards").html("<div class='...
In my web application I want to load all data to client side from the server on power up. After that I want all communication be managed through Signalr - meaning that each update the server will send notification to all clients and they will ask for the updated data. However, I don't know what to do when the SingalR c...
I needed to write zlib wrapper class for my application, so I can change it with different algorithm later if I want to do so. Here is the simple version: struct ZLibEasyCompressor{ bool operator()(const char *data_in, size_t const size_in, char *data_out, size_t &size_out); }; struct ZLibEasyDeCompressor{ boo...
I'm writing a Twitter™ bot for the Retrocomputing Stack Exchange site using JavaScript. To ensure that it doesn't tweet about the same question twice in a row, I request the account's timeline. My code should work, but I have a feeling that there's something "wrong" with the way I've written it. The get_request functio...
This is a question from HackerRank. I have solved it and want to know if it's the best answer I could have given in Python 3. Sample code: >>> from collections import Counter >>> >>> myList = [1,1,2,3,4,5,3,2,3,4,2,1,2,3] >>> print Counter(myList) Counter({2: 4, 3: 4, 1: 3, 4: 2, 5: 1}) >>> >>> print Counter(myList).i...
I put together a ProducerConsumer class that wraps the C#'s BlockingCollection class with some bells and whistles (producers can have multiple consumers, consumers can have lambdas, built in parallel execution, exceptions thrown on cycles, etc). As you can imagine it uses generics. var producer = new GhostLine<int>(); ...
I've never been too bothered by the lack of present (and thus print) support for Factor collections and other objects, but I've never needed to generate Factor programs from JSON until now. To that end, I use these methods to turn arrays, hashtables and assocs into roundtrippable strings: M: f present drop "f" ; M: ...
I created a basic desktop calculator using Python. Does anyone have any suggestions as far as coding best practices, readability issues, or just generic coding mistakes I might have missed? Any professional input you could provide would be greatly appreciated. import tkinter as Tk class Calculator: ''' main class...
Initially I got this code: import sys import os import random from PyQt5 import QtWidgets from PyQt5 import QtGui from PyQt5 import QtCore random.seed(1) class Model(QtCore.QObject): item_added = QtCore.pyqtSignal(int) item_removed = QtCore.pyqtSignal(int) def __init__(self): super().__init__(...
I have implemented the \$O(logN) + O(N)\$ version for the problem: How to find 1st and 2nd largest element in a non-negative unique array? The algorithm principle is from this stackoverflow answer.The comparison information in finding 1st helps find 2nd faster (\$log N\$ time). But I am really depressed that my code is...
Type a number \$n\$. Then calculate \$f(n)\$, where $$ f(n) = \begin{cases} n-10 & \text{if}~ n > 100\\[1.5ex] f(f(n + 11)) & \text{otherwise} \end{cases} $$ The output must show all the computations, such as $$f(99) = f(f(110)) = f(100) = f(f(111)) = f(101) = 91$$ Is there a shorter and better way I can solve this? #...
To be honest, I am pretty new to coding. I want to analyse the articles my local newspaper publishes on ther website. To do that, I have a list of URLs and from that, I want to download and save all the articles published. This is my code: from bs4 import BeautifulSoup import urllib.request import pickle import time d...
is there anyway to improve? Thank you! def fahren_to_celsius(fahrenheit): return round((fahrenheit - 32) / 1.8, 2) def celsius_to_fahrenheit(celsius): return round((celsius * 9/5) + 32) def celsius_to_kelvin(celsius): return round(celsius + 273.15) def kelvin_to_celsius(kelvin): return round(kelvin - 27...
I have the following data frame: set.seed(1) SOURCE <- as.data.frame(matrix(c((1:10), sample(c("20-24","25-28"), 10, replace = TRUE), sample(c("10000", "20000"), 10, replace = TRUE), sample(c(1, NA), 10, replace = TRUE), ...
#include <iostream> #include <string> #define NL "\n" int main(void) { //Acquires players first name std::string introOne = "Welcome to The World of Magick\nWhat is your name?\n"; std::cout << introOne; std::string playerName; std::cin >> playerName; //Asks for players gender while(tru...
This is my solution to exercise 1.6 in Cracking the Coding Interview. I am interested in receiving feedback on the coding style and time/space complexity. The exercise statement is: Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa wou...
I created this Blackjack program as a first attempt at Ruby. Would appreciate a code review to see if I am doing things the Ruby way (is there a better way to get user input?), using OOP correctly and anything else you want to point out. class Card def initialize(suit, face_value) @suit = suit @f...
I need to compare two XML columns. I currently have about 1000 rows of data that this is running against and it takes about 20min. Is there anyway I can improve this query to run faster. SELECT MAX(T.CaseName) AS CaseName, T.PartNumber, T.NodeName, T.OldValue, T.NewValue FROM (SELECT C.CaseName, old.N.va...
I have made a form where the submit button will show if the text box is focused and the button will hide if the text box is blurred. These codes work fine. But I wonder if the jQuery code could be more simplified. Or is there any toggle function available? var search = $("#search"); var button = $("#submit-button"); ...
I am building an implementation of System.Windows.Input.ICommand that is like the commonly used RelayCommand, but doesn't keep a strong reference to targets of the delegates it uses. Such a structure is useful for when a control wants to expose some of its functionality as a command (which can be assigned to a ViewMode...
I'm writing a piece of JavaScript to make one or two ajax calls. There will always be one ajax call fired but it might be two based on cookie setting. If user is logged in then we call another service to get the data. I would want this to fire async that's why I didn't put the second ajax call in the callback of the fi...
I am currently refining my understanding of data structures and as such, decided to implement a popular application of the Stack. Below you will find my implementation of the Balancing Symbols algorithm written in JavaScript. My basic questions are: How clean would you rate my code? Is time complexity O(n): Linear? Ho...
I wrote this as an exercise. I think that I have some repetitive code in the "winner" function but I don't know exactly how to reduce it. Any other general advice would be welcome too. #include<iostream> #include<iomanip> char table[3][3]; int turn=1; void print_table() { for (int i=0;i<3;i++) { for (...
I created this based on this website which calculates IP address information such as hosts, netmasks etc. I'm quite new to C and I'm still grasping the idea of the whole array and pointers and bit manipulations. Code works the way I want it to work but I'd like to improve this. I would like to know how I did as well as...
Just a little exercise to make me more affluent with strings and error handling, any improvements welcome! #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdbool.h> #include <math.h> #define MAXSIZE 1024 void retreiveStringInput(char *str, size_t buffersize) { for (;;) { if (fgets(st...
I'll start off by saying I'm way off in how this should be done. After spending much time on getting this to be clean it wasn't going to happen so I just did it anyway I could. I'm trying to make some FlxStates that will show off some nice menus that I want to create. What I'm doing in this code is moving UI buttons f...
Challenge Find all possible moves for a knight on an empty chessboard. Specifications The first argument is a path to a file. The file contains multiple lines. Each line is a test case representing the position of the knight in CN form. C is a letter from “a” to “h” and denotes a column. N is a number from 1 to 8 an...
This is my solution to Exercise 1.7 from Cracking the Coding Interview. I would appreciate any feedback on coding style and algorithm efficiency. I do know that there is an existing function in numpy for rotating a matrix, however I am trying to implement this as an exercise. The problem statement follows: Given an...
I have four loops to populate and compare two two-dimensional arrays then add the results to the first array before writing back to the active worksheet. Wondering if anyone has a cleaner alternate or more elegant method? It works as is but haven't tested it on large arrays yet! Function lastRow(x As Range, y As Work...
I'm new to competitive programming and C++ in general. I have solved the Kattis Animal Classification challenge. We are given two classification trees, each represented using nested parentheses. For example, ((3,(1,(5,2))),4) and (((5,1),(2,3)),4) represent the trees ╱╲ ╱╲ ╱╲ 4 ...
Learning React, I have created a basic App Component and Modal Component, the App Component renders 2 actions - hold and cancel, and a Modal based on the state modalVisible. I've kept the Modal Component light opting to pass the events back to the App Component (not sure if this is recommended), my reasoning is that th...
The problem is also known as GSS4. The exact detail can be seen here but I reached TLE. You are given a sequence A of N(N <= 100,000) positive integers. There sum will be less than \$10^{18}\$. On this sequence you have to apply M (M <= 100,000) operations: (A) For given x,y, for each elements between the x-th and...
This Activity has got a RecyclerView that is inflated with an ArrayList that is ca. 400 Elements. This is what an Element of the ArrayList looks like: chords.add(new Accordo(new int[]{ R.drawable.do_maggiore, R.drawable.do_maggiore_alt1, R.drawable.do_maggiore_alt2, R.drawable.do_maggiore_alt3, ...
I had this idea to exploit anonymous lambdas that are immediately executed that wrap around an allocation function to track those allocations in a statically created Stats object. This is the code I came up with after some time #define TW_INLINE __attribute__((always_inline)) #include <iostream> #include <cstdin...
I created a class called HomeService that extends the android.app.Service. I then declared and implemented a class called BackgroundService which extends Thread. In the run method of the class I call the member method run of Runnable which calls my sendRequest method which is responsible for the Volley string request. ...
Here's my attempt at porting the Lua codebase for my programming language to C++(11). This is just the first step, the tokenizer, and I wanted to remove all the bad performance / practices / code before passing to the next steps. I'm also still learning C++ as I go through this experience, so I wanted to get it reviewe...
This is a program that loads a dictionary into a hash-table, and spell checks a text file provided as a command-line argument. The dictionary is formatted as such (just alphabetically): python bar foo code review When the program is done I am provided with output that looks like : This is part of a problem set where...
I need to print (or store) all diagonals of a matrix. This includes the main diagonal ( { (i,i) | i = 1, 2, ... min(m,n) } ). Then all super and sub diagonals. For example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 The diagonals should be (order doesn't matter): [ [1, 6, 11, 16], [2, 7, 12], [5, 10, ...
I wrote code in Python that takes a string s as input and determines the longest substring of s that’s in alphabetical order. In the case where there are two strings of the same length, code outputs the first one. I'm a beginner with 1.5 weeks of experience and wrote both versions myself. Which one is better, and why?...
I would like general ideas on improvement for this implementation of Minesweeper I wrote in C++. I am not really good in OOP yet, so I want ideas about how I can refactor the code by adding objects (or structs) without it getting too bulky. /*Minesweeper C++ Written by:-Teodor D.*/ #include<iostream> #include<time.h...
But it looks like it is getting to big. How can I break this up into smaller pieces? In general this seems messy and I'm trying to make it more readable. /******************************************************************************************************************(120) ** BVFave ** - renders favorites using unders...
This is a velocity, distance, and time calculator that I wrote not too long ago. How can I improve upon this code? import java.util.Scanner; import javax.swing.JOptionPane; //imports //--------------------------BEGIN PROGRAM--------------------------------------------------------// public class justForFun {public ...
I am writing a JavaScript application and would like to validate function arguments in many places. Most of these checks will be for correct argument types, or numeric values within specific ranges. Here is a simple function I came up with to check any number of preconditions: function requires(conditions) { for (...
I wrote this function to check if a given string is in alphabetic order. How can I improve? def alphacheck(x): '''This function checks if a given string is in Alphabetical order''' # Creating a variable to allow me to efficiently index a string of any length i = len(x) - 1 # Using a recursive formula a...
I have a folder that contains around 1000 text files, their sizes varies from few KBs up to 500 MB (Total size is around 60 GB). I have a text file that contains a 166k lines, each line contains a set of numbers (length up to 11), what I'm doing here is to go through each file in that folder and try to find a match bet...
With the comments on the same line as the code, it refers to. e.g NumBob = 0 s = 'sexbobombob' i = range(len(s)+1) #Generates a list from 0 to the length of s u = 0 # This would be the variable storing each value of the list for ans in i: # this allows me to extract each value of i if ans > 0: # Completely arbitrar...
One day I stumbled upon a question on Stack Overflow: How do I create an array in javascript whose index starts from 1. The top answer says that it's impossible. However, that answer was posted in 2010 and things changed since then. ECMAScript 6 introduced Proxy, which allows to intercept basic language operations like...
I'm trying to make an SMS Shortner for a kata at Codewars: Your task is to shorten the message to 160 characters, starting from end, by replacing spaces with camelCase, as much as necessary. I've tried with a while loop and although the logic is correct, it's taking too long to process my tests. How can I optmize thi...
Below is my code for an attempted solution to cracking the coding interview exercise 1.8 written in python 3.5. The problem statement is: Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0. I looked at the hints for this problem so I do know that my solution is n...
I am working through the book Algorithms in a Nutshell by George T. Heineman and trying to translate the pseudocodes into Rust. Here is a naive convex hull algorithm: use std::cmp::Ordering::Equal; use std::cmp::Ordering; use std::ops::{Add, Sub, Mul}; use std::collections::BTreeSet; #[derive(Debug, Copy, Clone)] pu...
This script documents every website visited and writes the text content of each webpage to its own individual file. It seems to work as intended. Is there anything I could do to improve it? #!/bin/bash ##################### ##### Functions ##### ##################### chrome() { osascript -e \ 'tell applicat...
I end up writing a lot of the same code when I query a database I thought I would try to encapsulate that all in a class that could be used by any provider that implemented IDbConnection. i'm not looking to do much, return a DataTable when I want a result set, things like that. Here is my first attempt. I've tested tha...
Is this a proper MVVM implementation? I copied it off a sample but the source would not open so I have to put stuff in spots? Should I call in different files? My first MVVM and have trouble with the concept. XAML <Window x:Class="MVVM01.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/present...
There are a lot of numerical properties to be invoked many times with an expensive calculation. Let’s say for the sake of example, they expose a Factorial: public class Analysis { public double n10 => F(10); public double n100 => F(100); double F(int n) => n <= 1 ? 1 : n * F(n-1); } I was looking ...
Challenge Determine the largest contiguous sum of integers in a list. Specifications The first argument is a path to a file. The file contains multiple lines. Each line is a test case represented by a comma separated list of integers. For each test case, find and print the largest contiguous sub-array sum. Sample Inp...
I'm new to C# and am trying to write a program that randomly generates complete Sudoku grid of variable size. I'm able to generate a 25x25 grid in usually less than 10 seconds but I haven't been able to make a 36x36. This is the method I thought of to create a grid: Instantiate structure classes: cells, rows, columns,...
I found this question on Hackerrank in dynamic programming: Define a modified Fibonacci sequence as: $$t_{n+2} = t_n + t_{n+1}^2$$ Given three integers, \$t_1\$, \$t_2\$, and \$n\$, compute and print term \$t_n\$of a modified Fibonacci sequence. Could this efficiency be improved? t1,t2,n = map(int, raw_input().s...
I wrote simple code to spell the number below 1,000,000,000. It works perfectly as per my intention. However, I do think my code is a little bit messy since I only able to imagine of using decision statements in my function/method. I'm still learning in writing Python function/method code. I will be glad if anyone here...
I have an array that contains n arrays and each of these arrays contain a different number of string elements. Each string contains a key word like evar#, event# or prop# (where # is a number). This is my goal: return all the key words from a string that is different with at least one of the other arrays return the ke...
Let's say I have a data collection, like a list, containing a set of objects with particular properties. Let's go with animals: [ cow, sheep, orangutan ] An animal has a property animal_data that contains taxonomic information, like kingdom, class, family and species. This establishes a hierarchy which says that each...
So my code here takes some parameters and then creates an SQLesque type of string (JQL). function makeJQL(status, project, priority, description, summary){ var arr = new Array(); // Could put a null check here if all parametres are undefined if(status.length > 0){ jql = "status="+'"'+status...
To check if a given point is inside a polygon or not is a very useful piece of code. Here is my implementation in JavaScript of an algorithm counting the number of times a ray crosses the perimeter of the polygon, and subsequently checking the parity. I have included an initial test doing a fast comparison with the rec...
I mean, that code should be written more clearly. Can you help me, have you yet one idea ? I Need to assign the value list_new to variable depending on the list value. The list value is not constant and list_new it's also not constant and depends on the list value. Wenn I have for example [1,1,1] then I have new list w...
Minimum working example below. The Matlab filter function filters the input data x using a rational transfer function defined by the numerator and denominator coefficients b and a and initial conditions z. My C++ version of the code is way slower than the Matlab one. My signal x is a huge valarray, a and b are three el...
I am reading some HTML files and returning them upon request, but when they go through my codes I need to filter out some stuff from these HTMLs, everything is working fine and I'm using about 20 or more str_replace and preg_replace to do that which works pretty fine. Until I used this $responseBody = preg_replace('/<s...
I have created a class which handles (what i call) idle chores. These chores need to be executed every x seconds (x is random every time but within a certain range defined in the settings) With this code review I'm hoping to find inefficiencies in the code, I need to optimise this because the performance is somewhat la...
I have a function that returns true or false depending upon whether there are any weekend days left in the month. Is there a better/cleaner way that I can write this? function checkWeekendsLeft(month, year) { var iDaysInMonth = new Date(year, month, 0).getDate(); var iCurDayInMonth = new Date().getDate(); var ...
I'm trying to make my script cross-Python (Python 2 and 3 compatible), and to solve an import problem I did this: __init__.py file import sys if (sys.version_info[0] < 3): from core import translate else: from .core import translate Is it the good way to do it?
I have a piece of code that works but, as I start learning OCaml, I am not confortable with the "functionnal style" to write code. The following code create two threads. One for a tcp server that accepts one client and sends him the "test" string. In the other thread, there is a client that reads in a socket after 2 se...
For my computer science class, I was required to write a lexical analysis program that would perform several functions on a std::string. The assignment required a function for each of the following: count number of a certain substring count number of words excluding numbers count number of unique words (excludes repea...
Continuing the Algorithm in a Nutshell series, here is the code: trait MaxElem<T> { fn max_elem<'a>(&'a self) -> &'a T; } impl<T> MaxElem<T> for Vec<T> where T: PartialOrd { fn max_elem<'a>(&'a self) -> &'a T { max_elem_helper(self, 0, self.len()) } } fn max_elem_helper<'a, T>(vec: &'a Vec<T>, le...
I'm working on an assignment which entails creating communicators following the diagonals of an n x n process grid. I'm interested to get feedback regarding the correctness of the solution I developed as well as feedback regarding the efficiency of the solution. #include <stdlib.h> #include <stdio.h> #include <math.h> ...
I would like some help with a review of a program that I wrote to identify the longest continuous sub-string that is in alphabetical order within a string. This is a JavaScript adaptation of an exercise originally written in Python. I am new to JavaScript. I would like any help identifying ways that this program cou...
Before you read ahead: ES6 may not be used. Consider a web-page showing a report of some data that is structured as follows: <button id='sort-by-category'>Category</button> <button id='sort-by-timestamp'>Timestamp</button> <section id='report-body'> <section class='report-section' data-category-name='fruit' data-it...
In reviewing an older project of mine, I noticed that in a particular class definition I'm doing this: var defaultOptions = { ... object of default options ... } var SDKClient = function(options) { var self = this ... _.defaults(self, options, defaultOptions) Object.defineProperty(self, 'clientId', ...
Adopted some suggestions from the answer of my previous post. Here is the code: trait MaxElem<T> { fn max_elem<'a>(&'a self) -> &'a T; } impl<T> MaxElem<T> for [T] where T: Ord { fn max_elem<'a>(&'a self) -> &'a T { max_elem_helper(self, 0, self.len()) } } fn max_elem_helper<'a, T>(array: &'a [T]...
I am currently rewriting a todo app from java to clojure. This is my first "real" clojure project so I'm not sure that what I write is idiomatic clojure code. I have just finished rewriting the domain module and I'd like to know how can I improve on it to have something which is idiomatic. I had some simple classes in ...
I had some great feedback on my code previously here and I was hoping that I could get some further help with writing a column of the array to the worksheet. I have an example here where I write one column of my array to the worksheet with a loop, but I'm wondering if there wouldn't be a more efficient way to do this: ...
I've implemented the coin change algorithm using Dynamic Programming and Greedy Algorithm w/ backtracking. The description is as follows: Given an amount of change (n) list all of the possibilities of coins that can be used to satisfy the amount of change It would be nice to have a code review to show me where I can ...
I am trying to solve the below problem from an online coding site: Fredo is pretty good at dealing large numbers. So, once his friend Zeus gave him an array of N numbers, followed by Q queries which he has to answer. In each query, he defines the type of the query and the number f for which Fredo has to answer. ...
I recently came across a need to display very large decimal numbers and realized that I could use a BigDecimal class. After some tinkering I decided to leverage the BigInteger class to do the heavy lifting. using System; using System.Numerics; using System.Text; namespace Numerics { public class BigDecimal : ICom...
This is an updated version of the script Fahrenheit / Celsius temperature converter. I have changed the script to be non-interactive, using positional parameters instead of asking for user input once the script is running. In my testing of the script, everything seems to work as it should. But I am quite new to using p...
We have a dynamically created map with two dimensional coordinates. There's an object in this map on a random position and I need to validate the four adjacent fields. However, I need to leave out the corners since they are not relevant for the validation! This is an illustration of what needs to be validated (the gree...
I am converting a non ARC projecs to ARC. I just found that after login in my old app, the data is stored in app delegate objects, like Home_DataArray, various flags and some other objects. I am bit confused at it, because my app delegate is looking like constant class and BoolDidFinishLaunch looks like parent of vario...
Any comments? I tried to make my code modular and testable. I tried to make use of dependency injection without using any frameworks. All the classes are stateless, immutable and thread-safe (I think). I also tried to code to interfaces, not implementations. Utils package biz.tugay.sakila.core.utils; import javax.pers...
We are being needlessly curtailed by the standard-supplied function containers, a lot more flexibility is possible. Try any_function, which can contain an arbitrary functor without having to specify it's signature. namespace { template <typename> struct signature { }; // template <typename> struct class_ref; // temp...
I have built a tiny script to send out push notifications. I would be glad to receive general suggestions / feedback. My main problem is that the only security offered is coming from the OS filesystem settings (making the config file not readable to other users) and I would be very happy to improve my code and make it ...
I have implemented three ways of Singleton idiom in Java, and now I want to write some test code to see there performance. Here is my code: public static void main(String...args) { long startTime, endTime; int MAX_ITE = Integer.MAX_VALUE; // Eagerly initialized static instance guarantees thread safety. ...
I have a list of units (as in entities in a game): workers = [engineer1, engineer2, scientist1, scientist2] These workers have a couple of properties I want to group them by: city and specialization. This grouping is nested, first we group by specializations and then by cities. Then we throw the list of workers that m...
I need make validation of Multipart file in form class. I wrote custom annotation for form class which validate Multipart file. This code works great, but I don`t know if this is a good approach. This code validates the Multipart file and shows a message on page if validation is invalid using jsp tag (form:errors cssCl...
I am trying to learn web scraping in Python using Beautiful Soup and requests. My program goes to the book page on Project Gutenberg with the given book number (Example). It then finds the link for the given format (text in this case) and then writes the contents of the book to a file on the hard disk. How and what can...
I'm repeatedly faced with writing proxy classes for various purposes, recently lazy evaluation and IPC. This usually means having a single method pattern, which just forwards the call. I'm having a hard time to do this efficiently and readable. Let's consider an example of a (trimmed down) lazy evaluation proxy: class...
So this is my first time implementing the MVP pattern in Android. As I understand the presenter should not contain any Android specific code. I am using TextInputLayout and I want to validate my text fields and show an error message using TextinputLayout.setError(""). Now the edittext validation logic is implemented i...
I'm iterating this JSON using a for loop: var movieObj = { "cat": { "moveName": "Breath", "rating": [4, 5, 4, 3] }, "cat1": { "moveName": "shallow", "rating": [5, 5, 5, 5, 4] } } Is there any way to improve this code? var sum; Array.prototype.getSum = function (ele) { ...
The Needleman–Wunsch algorithm is an algorithm used in bioinformatics to align protein or nucleotide sequences. Here is an implementation in Rust: #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum Direction { Match, // go diagonally, left and up Left, Up, Undefined, } #[derive(Debug, Copy, Clone, ...
So the task was to first create a custom TCP protocol (namely ebl0) with certain parameters in its header and a number of methods to use with it (e.g. Login, Create, Join etc.). I'm not listing it here because it was relatively easy. The next step was building a server using this protocol that complies to the following...