instruction
stringlengths
71
71.9k
I've created a program for my own purposes in three different languages, Perl, Python, and Ruby. Each program will be posted in with their own tag but I will add links to them through on each post. The program itself is very simple, all it does is ask the user about three different languages which are saved into an arr...
I've written a parser with the help of some experienced Haskellers. The parser is not bad, but the same kind of parser written in PHP7 with regular expressions is much faster (takes 25% of the time that takes the Haskell one). This is a subset of the file I want to parse: lpaste link The main objective of the parser is...
I've just started writing asynchronous methods for the first time having watched some tutorials. I have a method where I run two tasks in parallel (notifySales, insertDownload): Task insertDownload = _downloadService.InsertDownloadRequestAsync(model, Request.UserAgent); if (product.NotifySalesByEmail) { Task notif...
I have some part of my code that uses reflection and there is some slowdown issue that I have to fix. After some research I found that expression tree seem to be a good candidate to fix it also it MUST work under .NET 3.5. I have less than a week of experience with expression tree and the code below was found on some b...
I have two threads, one produces images and one processes them. For the synchronization, I created a class where you can set and get images, and it always waits until an image is available or a worker thread is not busy anymore. Additionally, a call to SetFinish stops both threads, while a call to Clear clears the curr...
This is my first attempt to make a game on my own. I just want to see if anyone has any comments. Am I doing things, at least, sort of alright? Is there a better way I could deal with the input? import sys, platform, os import time, random, math class Entity(object): '''Basic entity object Has position and...
I am studying data structures and I have implemented a stack using a linked list. stack.h #ifndef STACK_H #define STACK_H #include <stdbool.h> typedef char StackElement; typedef struct stack_CDT *Stack; Stack stack_init(); void stack_destroy(Stack s); bool stack_is_empty(Stack s); void stack_push(Stack s, Sta...
I call a service which returns an array of tags. The array may be empty, and if so, it just saves the tag. Otherwise, it checks if the tag is in the array. If so, then the tag is removed, otherwise it's saved. Can this be optimized for efficiency? function processTag(total, tag, associatedTicker) { var foundFlag = ...
I tried to draw a Sierpinski triangle by shading the even number entries of the Pascal triangle. Could you please suggest improvements? public class Sierpinski { public static void main(String[] args) { int no_of_row = 50; int[][] tri = new int[no_of_row][no_of_row]; for (int i = 0; i < no_...
The last time I wrote any serious code was the 90's, so a lot has changed and I am finding I am having to relearn pretty much everything. I have leaned a lot from previous posts and this is the result. So as the title states I need a code review to help me identify where I am making mistakes by today's standards. To th...
In my program there is the following piece of code where I must delete a ' ' from the second to last index in a StringBuilder: builder.deleteCharAt(builder.length() - 2); I do not surround it with checks to either condition builder.length() >= 2 or builder.charAt(builder.length() - 2) == ' '), because I am 100% sure t...
I'm currently working myself through K&R and just read about implementing getch() and ungetch(). In K&R these functions are implemented like this: #include <stdio.h> #define BUFSIZE 100 char buf[BUFSIZE]; /* buffer for ungetch */ int bufp = 0; /* next free position in buf */ int getch(void) /* get a (p...
Description of challenge: Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to ob...
Post a cursory read of this I implemented a simple dictionary and an interface to assign, replace, look up, and redefine its terms to apply the concepts. It's simple, but I'd still like to know any way I could make this cleaner and more pythonic. def print_dict(dictionary): for key in dictionary: print("{} : {}"...
I have only dabbled in Java before (my previous experience being mostly with PHP and JavaScript) but a request come through for a small application that seemed like a good chance to get some experience. We receive two types of .csv from a third party: The first is the 'offer' file, which contains a collection of detai...
I am very fresh to python. As part of an assignment, I've written the following code to remove punctuation from a string and convert it to lowercase. import string words = "Dave, Laura, Maddy, Dave, Laura, Maddy, Dave, Laura, Dave"; translation = str.maketrans("","", string.punctuation); new = words.translate(translat...
I am trying to speed up a function to return the longest common substring. The requirements: The function takes two strings of arbitrary length (although on average they will be less than 50 chars each) If two subsequences of the same length exist it can return either Speed is the primary concern This is what I have ...
Inspired by the work Charles Duffy did in this answer and the work of Jonathan Leffler in this one and because I couldn't leave well-enough alone. I went and wrote expandTilde.sh: #!/bin/bash doExpand() { local path local -a resultPathElements for path in "$@"; do : "$path" case $path in "~+") ...
I have a program that reads a .txt file from a given directory. Each record line contains a data and I am parsing it. I think this is costly with it comes to performance but I might be wrong. Here is the method. How can I improve it to improve performance? currentLine = uploadFileReader.readLine(); while (!isBlankOrNu...
I have developed this 8-puzzle solver using A* with manhattan distance. Appreciate if you can help/guide me regarding: 1. Improving the readability and optimization of the code. 2. I am using sort to arrange the priority queue after each state exploration to find the most promising state to explore next. Any way to opt...
I wrote a wrapper for Java's ConcurrentHashMap that enables you to add a decay time to inserted values, meaning they will be automatically removed after the given time. This functionality is implemented by a cleaning thread that runs until .close() is called. I deliberately did not extend the ConcurrentHashMap because ...
I've created a caching service using OOP techniques combined with the revealing module pattern and the angular-cache library. New CacheDataClass objects are instantiated using the Factory pattern with RequestFactory. It has generic methods for get, set and reset data. It can be extended to override those methods. I wou...
I am trying to find non bouncy numbers under \$10^x\$ where \$1\le x\le 1000\$. \$123456\$ is an increasing number where every digit is greater than or equal to the previous digit (\$1223344\$ is also counted as an increasing number). Similarly a decreasing number is one where every digit is smaller than or equal to th...
I wrote a small function in powershell that works fine, however I feel its extremely hacky and I'm sure there must be a smarter way to do this. In the interests of learning, what can I do to improve on this? function WhatsMyIP { return ((Invoke-RestMethod -Uri http://ifconfig.co).split("`n") | where {$_ -match "`"ip`""...
I read three files and parse a few individual fields from each row of the XML. Using these fields, I find the dictionaries that contain the same keys (ItemK and either SensorK for sensors or PointK for points) I then append the masterkey and Sensor/Point ID to a new list. Is there any improvements i can make? from xml....
I needed to write my own lightweight GO multi-output logger for a work project and I've come up with https://github.com/asticode/go-logger. Basically the projects works like this: // Create the logger l, e := logger.NewLogger("myproject", logger.LevelDebug, "%message%") // Add a stream handler h, e := logger.NewHandle...
I have the following function, it works exactly how I need it to; however I think there is room for improvement. The script is supposed to loop through all input and text area html elements. It should only work with elements that have a name, and a value, and it should ignore "hidden". However some of the elments do no...
I'm fairly new to JQuery/JavaScript and I'm trying to refactor the following code: $('#hour').click(function() { $('#clockHours').slideToggle(); $('#clockMinutes').hide(); }); $('#minutes').click(function() { $('#clockMinutes').slideToggle(); $('#clockHours').hide(); }); //print clicked onto views $('.timeSel...
In a recent interview I was asked to solve the below problem. Problem: Given a string with variables in them, e.g. "I am a string with {{ variable }} in them" Create an output where the {{ variable}} is replaced with their actual values. So if given the input: var template = { "sentence": "The {{ object }} {{ ver...
I've written this program yesterday, and I was reminded why I dreaded C++ before turning to Java: pointers and associated terms (like destructors, initializations and copy/move constructors) are making me rather anxious about possible logical oversights every time I need to write a C++ program, however simple or comple...
I need a procedure that "centers" a string inside a string that is consecutive characters of a fixed length. For instance, ======================== Instructions ============================ or **************************** hehe ******************************** might be printed by calling PrintBetweenChars("Instruct...
is there an easier/more efficient way to join two JSON objects on a common property than this? It's a GeoJSON file (basically an array of objects), and I want to pull in a property from another JSON file (array of objects) based on a common property, similar to a SQL SELECT a.*, b.* FROM a LEFT JOIN b ON a.id = b.a_id ...
One year ago I published an F# solution of the same task and there is an old C# solution. But I think it's a simple task and require a simple solution. What do you think? using System; using System.Collections.Generic; namespace SalesTaxes { class Program { static void Main(string[] args) { ...
The following is my implementation of a command-line Tic-Tac-Toe game, written in Ruby. This was my first attempt at practicing object-oriented design principles. require 'colored' module TicTacToe class Player attr_accessor :symbol def initialize(symbol) @symbol = symbol end end class Board ...
Here's a function: func checkIfObjectsHaveCoordinates() { PFQuery(className: "Products").findObjectsInBackgroundWithBlock { (objects: [PFObject]?, error: NSError?) -> in if error == nil && objects != nil { for object in objects! { if object["Latitude"] == nil || object["L...
I have the following task: to find the largest sequence of increasing numbers in an array. I'll give you an example : 2 3 4 1 50 2 3 4 5 will return the sequence of 2 3 4 5 - that is the largest sequence of increasing numbers in the given array. Another one is : 5 -1 10 20 3 4 which will return -1 10 20. If there are t...
I am still a Python beginner and would appreciate some help with this code. I am looking through some firewall log files, more specific all lines with Deny in them. For those files I am extracting the protocol, source IP, destination IP and destination port. The output is summarized and a hit counter is added (thanks m...
I'm working on a program that corrects all punctuation spacing in a String. Examples: // "Hello ,World" -> "Hello, World" // "9 :00 A .M ." -> "9:00 A.M." // "can 't even." -> "can't even." Here's how it works: My process is to first add a space between all punctuation and then remove any unnecessary spaces. T...
Having mostly used Qt and its classes like QString, I wrote a little exercise with plain C++11. I'm looking for two kinds of input: generally improving the code and/or doing it better in an entirely different way (still standard C++11 or C++14, no Boost or anything). The code is for printing doubles with given number o...
A continuation of this queston. The task's description can also be found there. After reformatting the code and getting rid of the ArrayIndexOutOfBounds check,it now looks like this: public static List<Integer> findLongestIncreasingSequence(int[] numbersToBeProcessed) { if (numbersToBeProcessed.length == 0) {...
I'm new to programming, became interested in learning a while ago and only got to it recently. I'm working on a very simple text-based adventure game using Python, and would like some tips on simplifying my code. Any other tips are also welcome. Please don't criticize the storyline though, since this is not the point o...
This is for a university assignment (don't worry the code is in working order), and while I could hand it in as-is and receive full marks I feel like there is probably a more efficient and better way to handle what I am doing. What the code does Takes user input of 4 names and for each name take True / False assignment...
I use this code to get values from SharedPreferences. public static String getSharedPreferenceValue(Context context, String key) { SharedPreferences sp = context.getSharedPreferences( Utility.PREFERENCES_NAME, Context.MODE_PRIVATE); String value = sp.getString(key, Utility.EMPTY_STRING); return value; }...
Description: Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. ... Of course I didn't include the numbers in the description... I am sure there is a better way to do this. I just did a simple solution, where I add all the numbers and take the first 10 digits. import java.math.B...
I have made a custom keyboard that gets loaded from an .xib file. I decided to go with an in-app only keyboard rather than a system-wide keyboard because the documentation states: Make sure a custom, systemwide keyboard is indeed what you want to develop. To provide a fully custom keyboard for just your app or to ...
This is a hash map library for C that stores void* pointers with char* strings (null terminated) for keys // ColiisionHashMap // Copyright © 2015 Leo Dastur. // #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct HashMapNode { char* key; void* data; } HashMapNode; typedef struct HashL...
I have written this function (and others similar to that one) But I am not sure I am using references on their full power. My currently concerns is if I make a huge use of memory. The subroutine recieve a reference to two files, the subroutines, like these one return a hash (except &log_time, which returns a scalar). T...
The code works as it is but it's very messy. Is there a way to clean up the null checking in the if statement? public function submitCoil ($data) { $db = Database::getInstance(); //Define certain query values $uniqueID = $this->hash("id"); $queryData = array( 'fields' => array( 'uni...
I wrote a Logger which uses the destruction of temporary objects to Log their values including a scope time logger. Lets see what i can improve here to increase the performance and everything else. class Logger { public: static inline LogMessage Log(LoggerTypes type, const std::string& file, ...
I have implemented a dynamic programming solution of the egg-dropping problem (this problem, but generalized for any number of eggs and floors): #include <iostream> #include <limits.h> //Optimal sub-structure //We have K floor and N eggs //Case1: If egg break of X floor then we have x - 1 floor and N - 1 egg //Case2: ...
I used to get a JSON file with some configuration settings from the file system, using this class: public class ConfigurationFileService : IConfigurationService { private readonly IConfigurationManager _configurationManager; public ConfigurationFileService(IConfigurationManager configurationManager) { ...
I have the following function for turning on some ports on a piece of hardware: public Boolean SwitchOn(Int32 portNumber) { HttpCommandBuilder builder = new HttpCommandBuilder(_ipAddress); builder.Command = HttpCommandBuilder.CommandType.SetPower; String result; if (portNumber == 1...
I wrote a simple program to sum the digits of a number in Clojure for learning purpose. Not very complex (I hope) so not adding any explanation. I am a beginner in Clojure so please don't mind pointing out even the most obvious mistakes. NOTE: It recursively calculates the sum of digits in the result until a single dig...
First, some code. I have a class, Circle: package aag; public class Circle{ private final int RADIUS; private float xVector; private float yVector; private float xCurrent; private float yCurrent; public Circle(int radius, int xCurrent, int yCurrent){ RADIUS = radius; this.xCu...
I really like c#'s Using statement as it allows you to pair Open statements with their corresponding Close/Dispose statements in an elegant way which matches C#'s syntax. I realised that something similar can be achieved in PowerShell; e.g. Push-Location should be paired with a Pop-Location, and this can be enforced by...
Here is my code in Ruby that shows the look-and-say sequence. It shows correct result, but my teacher said, that I could actually make it better. Can you tell me what the flaws are there in my code? In the input I tell how many sequence elements I want to see. For example I type 5 and get: 1 11 21 1211 111221 class ...
For my assignment, I have to take a data set and stratify sample it into three different training sets (one with 10%, one with 30%, and 50%). Then I have to classify it using a Naive Bayesian classifier I believe I did here, but since the code is very non-functional, I'm not sure if I'm going about it the right way. I...
Does exist a cleaner way to call a static method inside ES6 Array.filter function ? mine(input = '') { var translatedAnswers = this.constructor.translate(this._defaultAnswers); var self = this; return translatedAnswers.filter(function (answer) { return self.constructor.match(input, answer); });...
Given four lists of numbers, calculate how many ways there are to choose one element from each to get a sum of zero. The input is given on stdin, first the length of all lists n, then n tuples containing an element from each, like this: 6 -45 22 42 -16 -41 -27 56 30 -36 53 -37 77 -36 30 -75 -46 26 -38 -10 62 -32 -...
I'm currently working on a project where I have to map some objects to several properties. Basically I need a Dictionary with Tuples as keys and instances of MyClass as values. As using tuples can quickly lead to an obscure (because of item1, item2... properties) and verbose code I decided to make a class to wrap the t...
I am fairly new to Python. I implemented a short cross-validation tool for gradient boosting methods. import numpy as np from sklearn.metrics import roc_auc_score as auc from sklearn import cross_validation from time import time def heldout_auc(model, X_test, y_test): score = np.zeros((model.get_params()["n_estim...
A lucky number is defined as a positive integer whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. I need to check if a given number is evenly divisible by any lucky number or not. Now, suppose I want to add all Lucky Numbers under a g...
I have posted my first version of RockPaperScissors a while back. It was on an old version of python with improper use of some functions. This version was updated to a more recent version of python and has a little extra for users who run on terminal. Is there anything I should add or change? Are my classes used correc...
I'm relatively new to Python scripting. I made a script that takes two raw data files and merges them into one CSV file, but it takes a long time to complete. Are there any logic problems in this code? input_fileVms = open( 'vms.csv', 'rb') if site == 'eg': output_merge = open('mergedFileEG.csv', 'wb') elif site=...
To learn about classes, I chose to create a little something that checks if you have included the following: @ sign Provider (e.g. 'hotmail') Domain extension (e.g. '.com') It also checks if you entered spaces in the address and gave the option to keep them or get rid of them. I would really like some feedback on wha...
I'm an 'old school' programmer (C, C++), and I have step-by-step, algorithmic thinking. I'm writing some code in Angular + Django and I know that this code is ugly but I don't have any idea how to refactor it. First of all, I have the models: class Product(models.Model): name = models.CharField(max_length=100) ...
Lets say we need to write an algorithm for giving money to the bank. We need to know interest rate, money which we put every year on our account, and amount of money we want to get. F.e int. rate is 1%, money we put every year is 1000 (or whatever) and we want to get 10000 (not more). It'd look like this: MoneyOnAcc=1...
I tried to make an is_Prime() function in PHP. What do you think about this code? <?php function is_Prime($x) { if($x <= 1) { echo $x. " is not a prime number.</br>"; return false; } $data = array(); for ($i=1;$i<=$x;$i++) { if(is_integer($x/$i)) { array_push($data, ($x/$i)); }...
I have taught some SQL to others before, and I thought of making a script that has these attributes, for the purposes of teaching: Fully functional to run on local DB instance with no fuss Easy to follow along Representative examples of real-life types of operations Documented The example first goes over some Data De...
def toPairs[A](xs : Seq[A]) : Seq[Tuple2[A,A]] = { @tailrec def accumulator(as : Seq[A], accum: Seq[Tuple2[A,A]]) : Seq[Tuple2[A,A]] = as match { case Nil => accum case x :: tail => tail match { case Nil => accum case _ => accumulator(as.tail, accum :+ (x,tail.head))...
Now I have task very similar to this: Job is a group of print items. For example, a job can be a run of business cards, envelopes, and letterhead together. Some items qualify as being sales tax free, whereas, by default, others are not. Sales tax is 7%. Also applies a margin, which is the percentage above printi...
I find it hard to do integration tests for a repository and very time consuming. Things I think about when creating integration tests for a repository: Should I skip them? Should I create an in memory database? Should I create a local database for the test? Should I delete inserted data? Is my repository caching resul...
Following is my hand-rolled implementation of name demangling for names generated by Microsoft's compiler, partially reimplementing the UnDecorateSymbolName WinAPI function. static std::string getCallConv(char code) { static const std::map<char, std::string> callConvs{ { 'A', "__cdecl " }, { 'I', ...
I'm pretty sure there's no better way to do this but I thought a consensus on here might be nice. Let me know what you think. public static TValue GetValueOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue = default(TValue)) { TValue value; return dictionary.TryGetVa...
I'm training my coding and wish you guys to see how my code is. I made a cat clicker based on the MVC pattern. Basically it shows a list of cats and when you click a cat name it shows an image, and if you click the cat image it increments the number of clicks you made in the image and shows it. By the image there is an...
I made a dynamic CSV formatter as a personal challenge after having to hardcode a behavior to convert some data to CSV earlier. You input any List that contains supported types as properties (all primitive types, strings, or collections of primitive types or strings). And it will spit out a list of strings that are eac...
My current student accommodation uses a manual paper and pen system for checking if students have mail so I made this simple Python script to help mitigate the problem of manually searching through spreadsheets just to see if you have mail or not, which I have been asked to demo soon. It's quite basic but I figured I s...
I made a differential equation solver to forecast heat loss through a pipe with heat loss coefficient contours. It does what I want it to do but I had to use global variables to change the outputs of my simulation function - is there a better way to deal with this issue? Another problem I have is that my code is very s...
I recently participated in a small friendly competition and this was one of the questions: A number whose only prime factors are 2, 3, 5 or 7 is called a humble number. The first 20 humble numbers are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... Given n, find the nth humble number. E...
I'm on a quest to combat all the magic strings which tends to pile up in an ASP.NET MVC application. All reviews will be highly appreciate but please note that: Some of the classes contains more (unrelated) code than I've presented here. I do not use the c/c++ type aliases (unless forced to as with base type of an enu...
I have the class SeguimientoSeccion with this relevant attributes public class SeguimientoSeccion implements Serializable { private Integer id; private Transportista transportista; private String fijacion; private Integer month; private Integer year; } I created a custom comparator to sort by ye...
I'd like to see if I can somehow make this loop more effective (smaller?). I'm using MultiDatesPicker to make a reservation plugin. And I've set everything right, and everything works, but I'd like to see if my jquery code can be optimized somehow. HTML looks like this (minus the actual calendar): <div class="reservati...
I have a WCF service that work with databse. The service should handle incoming message and store messagId into database. Please suggest me how can I improve it? public class DBWorker { static DBWorker instance; private string connectionString; private SqlConnection connection; protected DBWorker() ...
I recently read K&R The C Programming Language and wanted to write a small program to count the occurrence of each word in the input (std-input - I piped a file with all shakespeare pieces in there). Since I wanted to learn how to split source files into multiple files with this project I pretty much outsources every f...
I have a function that generates a URL using a stringbuilder: internal String GenerateUrl() { StringBuilder urlBuilder = new StringBuilder("http://"); urlBuilder.Append(IpAddress); urlBuilder.Append("/set.cmd?" + "user=" + Username + "+"); urlBuilder.Append("pass=" + Password + "...
I have written a class that connects to a database using MySQLi and has methods for the connection itself and returns the instance of the MySQLi class. This works, but feels a little "clunky" and can be a bit slow, can someone help me to improve this? The class is as follows: <?php /** * Connect to a db. */ class m...
Loosely basing myself on this blog post, I implemented an ordered dictionary. In essence, it's a wrapper struct for a list of tuples with some initialisers and some functions (map, filter, toArray, ...) added to it. struct OrderedDictionary<KeyType: Hashable, ValueType>: SequenceType { typealias KeyValueType = (key...
I'm currently trying to teach myself JavaScript. If someone could critique my implementation of Pascal's Triangle I would be very grateful. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Pascal's Triangle</title> <style> .container { displ...
After reviewing many Tic-Tac-Toe implementations, I decided to write my own. Here it is: Logic.hs module Logic ( Symbol(..) , Space , Board , Position , GameResult(..) , GameState , placeSymbolAt , isFree , gameResult , initialState , makeTurn ) where import Data.Maybe (isNothing, isJust) import Data.List (find, trans...
I want to calculate all the prime factors of a number in the range 2 ≤ N ≤ 107. Here is my function: public static long cal_me(int a, long[] A){ long ans=1; int count=0; while(a%2==0){ a/=2; count++; } if(count!=0) // I am calculating value which depend on Number of prime Num...
I've made a login page using Python Flask which works with MySQL. I started learning Flask 2 days ago and it was fun, so I came up with this: from flask import Flask, session, redirect, url_for, escape, request, render_template from hashlib import md5 import MySQLdb app = Flask(__name__) ####################### # D...
Background: You have an eCommerce order of 10 products but you want to refund only 5 of them. The stock managing system needs to preserve the order of row number (orderline) when you do the returns, but don't send the items that are not refunded. The order looks like this: "Poduct1" Orderline ="1" "Poduct2" Orderline =...
I'd like to eliminate the code duplication in the following two methods by moving the common code into a separate method callable by both. The comments indicate the blocks of code that have a differing implementation in each method. def compute_totals_h(self, size, bad_codes): with open(self._in_file_path, self._FI...
I wanted a reusable class for generating a list of primes till some arbitrary (but reasonable) limit. So, I wrote a class Primes that implements the Sieve of Eratosthenes and another method that makes use of this sieve. The implementation is done on the basis of clarity and swiftly obtaining results. I admit that using...
I wanted to get into C#, so I tried making a simple game. My first language was Java, so it was pretty easy to get the hang of C#. I know that there are multiple other posts of Tic Tac Toe games, but I want some critique on my own code. Is there any cleaner way? Any redundant code? Parts that I can jam together? using...
public byte[] PackToZip(IEnumerable<byte[]> files) { using (var archiveStream = new MemoryStream()) { using (var archive = new ZipArchive(archiveStream, ZipArchiveMode.Create)) { foreach (var file in files) { var entryName =...
I spent far too much time trying to simply get data from an Xbox controller with Python. This is the cleaned up result, classified. This requires xinput1_3 or possibly 1_4 - I'm running Windows 7 and cannot use 1_4. import ctypes import threading import time xinput = ctypes.windll.xinput1_3 class controller_manager(): ...
This is the first AJAX website I constructed. I am trying to have information generated according to the name that user types in. It works well but I have some problem with the slow performance. Is there anything I can do to improve the performance of this code please? HTML: <body background = "http://starecat.c...
I wanted to write an add function that implemented currying in JavaScript. I welcome criticism and suggestions for improvement. function add(...args1) { if(!args1.length) { return sum(args1); } return (...args2) => { if(!args2.length) { return sum(args1.concat(args2)); } return add.apply(n...
I have a 2 dimension matrix : public struct Matrix2D { private double[,] matrix; public Matrix2D(double[,] matrix) { if (matrix == null) throw new ArgumentNullException(nameof(matrix)); this.matrix = matrix; } private double[,] Matrix => matrix ?? (matrix = new double[0, 0]); ...